RIP BOOL. Convert BOOL -> bool. I found a few interesting
[nivanova/samba-autobuild/.git] / source3 / nmbd / nmbd_winsserver.c
index 4338aeac93a7112d121e35c6c64a6fac4cbbd234..38962c2b3941f954208d9043ab328f06d670e7d5 100644 (file)
@@ -6,7 +6,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    Converted to store WINS data in a tdb. Dec 2005. JRA.
 */
@@ -208,7 +207,7 @@ static TDB_DATA name_to_key(const struct nmb_name *nmbname)
  on the linked list. We will free this later in XXXX().
 *****************************************************************************/
 
-struct name_record *find_name_on_wins_subnet(const struct nmb_name *nmbname, BOOL self_only)
+struct name_record *find_name_on_wins_subnet(const struct nmb_name *nmbname, bool self_only)
 {
        TDB_DATA data, key;
        struct name_record *nr = NULL;
@@ -263,7 +262,7 @@ struct name_record *find_name_on_wins_subnet(const struct nmb_name *nmbname, BOO
  Overwrite or add a given name in the wins.tdb.
 *****************************************************************************/
 
-static BOOL store_or_replace_wins_namerec(const struct name_record *namerec, int tdb_flag)
+static bool store_or_replace_wins_namerec(const struct name_record *namerec, int tdb_flag)
 {
        TDB_DATA key, data;
        int ret;
@@ -289,7 +288,7 @@ static BOOL store_or_replace_wins_namerec(const struct name_record *namerec, int
  Overwrite a given name in the wins.tdb.
 *****************************************************************************/
 
-BOOL wins_store_changed_namerec(const struct name_record *namerec)
+bool wins_store_changed_namerec(const struct name_record *namerec)
 {
        return store_or_replace_wins_namerec(namerec, TDB_REPLACE);
 }
@@ -298,7 +297,7 @@ BOOL wins_store_changed_namerec(const struct name_record *namerec)
  Primary interface into creating and overwriting records in the wins.tdb.
 *****************************************************************************/
 
-BOOL add_name_to_wins_subnet(const struct name_record *namerec)
+bool add_name_to_wins_subnet(const struct name_record *namerec)
 {
        return store_or_replace_wins_namerec(namerec, TDB_INSERT);
 }
@@ -308,7 +307,7 @@ BOOL add_name_to_wins_subnet(const struct name_record *namerec)
  on the linked list.
 *****************************************************************************/
 
-BOOL remove_name_from_wins_namelist(struct name_record *namerec)
+bool remove_name_from_wins_namelist(struct name_record *namerec)
 {
        TDB_DATA key;
        int ret;
@@ -413,7 +412,7 @@ static void update_wins_flag(struct name_record *namerec, int flags)
  Return the general ID value and increase it if requested.
 *****************************************************************************/
 
-static void get_global_id_and_update(SMB_BIG_UINT *current_id, BOOL update)
+static void get_global_id_and_update(SMB_BIG_UINT *current_id, bool update)
 {
        /*
         * it's kept as a static here, to prevent people from messing
@@ -483,7 +482,7 @@ static void wins_hook(const char *operation, struct name_record *namerec, int tt
 Determine if this packet should be allocated to the WINS server.
 *****************************************************************************/
 
-BOOL packet_is_for_wins_server(struct packet_struct *packet)
+bool packet_is_for_wins_server(struct packet_struct *packet)
 {
        struct nmb_packet *nmb = &packet->packet.nmb;
 
@@ -563,7 +562,7 @@ static int get_ttl_from_packet(struct nmb_packet *nmb)
 Load or create the WINS database.
 *****************************************************************************/
 
-BOOL initialise_wins(void)
+bool initialise_wins(void)
 {
        time_t time_now = time(NULL);
        XFILE *fp;
@@ -601,8 +600,8 @@ BOOL initialise_wins(void)
                int ttl;
                const char *ptr;
                char *p;
-               BOOL got_token;
-               BOOL was_ip;
+               bool got_token;
+               bool was_ip;
                int i;
                unsigned int hash;
                int version;
@@ -805,9 +804,9 @@ void wins_process_name_refresh_request( struct subnet_record *subrec,
 {
        struct nmb_packet *nmb = &p->packet.nmb;
        struct nmb_name *question = &nmb->question.question_name;
-       BOOL bcast = nmb->header.nm_flags.bcast;
+       bool bcast = nmb->header.nm_flags.bcast;
        uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
-       BOOL group = (nb_flags & NB_GROUP) ? True : False;
+       bool group = (nb_flags & NB_GROUP) ? True : False;
        struct name_record *namerec = NULL;
        int ttl = get_ttl_from_packet(nmb);
        struct in_addr from_ip;
@@ -1111,12 +1110,12 @@ void wins_process_name_registration_request(struct subnet_record *subrec,
        unstring name;
        struct nmb_packet *nmb = &p->packet.nmb;
        struct nmb_name *question = &nmb->question.question_name;
-       BOOL bcast = nmb->header.nm_flags.bcast;
+       bool bcast = nmb->header.nm_flags.bcast;
        uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
        int ttl = get_ttl_from_packet(nmb);
        struct name_record *namerec = NULL;
        struct in_addr from_ip;
-       BOOL registering_group_name = (nb_flags & NB_GROUP) ? True : False;
+       bool registering_group_name = (nb_flags & NB_GROUP) ? True : False;
        struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
 
        putip((char *)&from_ip,&nmb->additional->rdata[2]);
@@ -1274,7 +1273,7 @@ already exists in WINS as a GROUP name.\n", nmb_namestr(question) ));
        if ( namerec != NULL ) {
                pull_ascii_nstring(name, sizeof(name), namerec->name.name);
                if( is_myname(name) ) {
-                       if(!ismyip(from_ip)) {
+                       if(!ismyip_v4(from_ip)) {
                                DEBUG(3,("wins_process_name_registration_request: Attempt to register name %s. Name \
 is one of our (WINS server) names. Denying registration.\n", nmb_namestr(question) ));
                                send_wins_name_registration_response(RFS_ERR, 0, p);
@@ -1481,12 +1480,12 @@ void wins_process_multihomed_name_registration_request( struct subnet_record *su
 {
        struct nmb_packet *nmb = &p->packet.nmb;
        struct nmb_name *question = &nmb->question.question_name;
-       BOOL bcast = nmb->header.nm_flags.bcast;
+       bool bcast = nmb->header.nm_flags.bcast;
        uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
        int ttl = get_ttl_from_packet(nmb);
        struct name_record *namerec = NULL;
        struct in_addr from_ip;
-       BOOL group = (nb_flags & NB_GROUP) ? True : False;
+       bool group = (nb_flags & NB_GROUP) ? True : False;
        struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
        unstring qname;
 
@@ -1596,7 +1595,7 @@ already exists in WINS as a GROUP name.\n", nmb_namestr(question) ));
         */
 
        if((namerec != NULL) && (is_myname(namerec->name.name)) ) {
-               if(!ismyip(from_ip)) {
+               if(!ismyip_v4(from_ip)) {
                        DEBUG(3,("wins_process_multihomed_name_registration_request: Attempt to register name %s. Name \
 is one of our (WINS server) names. Denying registration.\n", nmb_namestr(question) ));
                        send_wins_name_registration_response(RFS_ERR, 0, p);
@@ -1995,11 +1994,11 @@ void wins_process_name_release_request(struct subnet_record *subrec,
 {
        struct nmb_packet *nmb = &p->packet.nmb;
        struct nmb_name *question = &nmb->question.question_name;
-       BOOL bcast = nmb->header.nm_flags.bcast;
+       bool bcast = nmb->header.nm_flags.bcast;
        uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
        struct name_record *namerec = NULL;
        struct in_addr from_ip;
-       BOOL releasing_group_name = (nb_flags & NB_GROUP) ? True : False;;
+       bool releasing_group_name = (nb_flags & NB_GROUP) ? True : False;;
 
        putip((char *)&from_ip,&nmb->additional->rdata[2]);
 
@@ -2111,7 +2110,7 @@ release name %s as this record is not active anymore.\n", nmb_namestr(question)
 static int wins_processing_traverse_fn(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
 {
        time_t t = *(time_t *)state;
-       BOOL store_record = False;
+       bool store_record = False;
        struct name_record *namerec = NULL;
        struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
 
@@ -2303,7 +2302,7 @@ static int wins_writedb_traverse_fn(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA db
 }
 
 
-void wins_write_database(time_t t, BOOL background)
+void wins_write_database(time_t t, bool background)
 {
        static time_t last_write_time = 0;
        pstring fname, fnamenew;
@@ -2333,6 +2332,7 @@ void wins_write_database(time_t t, BOOL background)
                if (tdb_reopen(wins_tdb)) {
                        DEBUG(0,("wins_write_database: tdb_reopen failed. Error was %s\n",
                                strerror(errno)));
+                       _exit(0);
                        return;
                }
        }
@@ -2380,7 +2380,7 @@ void nmbd_wins_new_entry(struct messaging_context *msg,
        struct name_record *namerec = NULL;
        struct name_record *new_namerec = NULL;
        struct nmb_name question;
-       BOOL overwrite=False;
+       bool overwrite=False;
        struct in_addr our_fake_ip = *interpret_addr2("0.0.0.0");
        int i;