Convert all uses of uint8/16/32 to _t in nmbd and the include file.
[samba.git] / source3 / nmbd / nmbd_incomingrequests.c
index 292a580ef9b5d12b608b9efa5ae64cce8006c1a2..6f3eee368909666de8bd6ab0d46497a65b64a1a0 100644 (file)
@@ -25,6 +25,7 @@
 */
 
 #include "includes.h"
+#include "nmbd/nmbd.h"
 
 /****************************************************************************
 Send a name release response.
@@ -58,9 +59,9 @@ void process_name_release_request(struct subnet_record *subrec,
        struct in_addr owner_ip;
        struct nmb_name *question = &nmb->question.question_name;
        unstring qname;
-       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 bcast = nmb->header.nm_flags.bcast;
+       uint16_t nb_flags = get_nb_flags(nmb->additional->rdata);
+       bool group = (nb_flags & NB_GROUP) ? True : False;
        struct name_record *namerec;
        int rcode = 0;
   
@@ -153,7 +154,7 @@ void 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;
        struct in_addr from_ip;
   
        putip((char *)&from_ip,&nmb->additional->rdata[2]);
@@ -190,9 +191,9 @@ void process_name_registration_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;
-       uint16 nb_flags = get_nb_flags(nmb->additional->rdata);
-       BOOL group = (nb_flags & NB_GROUP) ? True : False;
+       bool bcast = nmb->header.nm_flags.bcast;
+       uint16_t nb_flags = get_nb_flags(nmb->additional->rdata);
+       bool group = (nb_flags & NB_GROUP) ? True : False;
        struct name_record *namerec = NULL;
        int ttl = nmb->additional->ttl;
        struct in_addr from_ip;
@@ -289,14 +290,14 @@ static int status_compare(char *n1,char *n2)
                ;
        for (l2=0;l2<15 && n2[l2] && n2[l2] != ' ';l2++)
                ;
-       l3 = strlen(global_myname());
+       l3 = strlen(lp_netbios_name());
 
-       if ((l1==l3) && strncmp(n1,global_myname(),l3) == 0 && 
-                       (l2!=l3 || strncmp(n2,global_myname(),l3) != 0))
+       if ((l1==l3) && strncmp(n1,lp_netbios_name(),l3) == 0 &&
+                       (l2!=l3 || strncmp(n2,lp_netbios_name(),l3) != 0))
                return -1;
 
-       if ((l2==l3) && strncmp(n2,global_myname(),l3) == 0 && 
-                       (l1!=l3 || strncmp(n1,global_myname(),l3) != 0))
+       if ((l2==l3) && strncmp(n2,lp_netbios_name(),l3) == 0 &&
+                       (l1!=l3 || strncmp(n1,lp_netbios_name(),l3) != 0))
                return 1;
 
        return memcmp(n1,n2,sizeof(name1));
@@ -314,14 +315,14 @@ void process_node_status_request(struct subnet_record *subrec, struct packet_str
        char rdata[MAX_DGRAM_SIZE];
        char *countptr, *buf, *bufend, *buf0;
        int names_added,i;
-       struct name_record *namerec;
+       struct name_record *namerec = NULL;
 
        pull_ascii_nstring(qname, sizeof(qname), nmb->question.question_name.name);
 
        DEBUG(3,("process_node_status_request: status request for name %s from IP %s on \
 subnet %s.\n", nmb_namestr(&nmb->question.question_name), inet_ntoa(p->ip), subrec->subnet_name));
 
-       if((namerec = find_name_on_subnet(subrec, &nmb->question.question_name, FIND_SELF_NAME)) == 0) {
+       if(find_name_on_subnet(subrec, &nmb->question.question_name, FIND_SELF_NAME) == 0) {
                DEBUG(1,("process_node_status_request: status request for name %s from IP %s on \
 subnet %s - name not found.\n", nmb_namestr(&nmb->question.question_name),
                        inet_ntoa(p->ip), subrec->subnet_name));
@@ -331,7 +332,7 @@ subnet %s - name not found.\n", nmb_namestr(&nmb->question.question_name),
  
        /* this is not an exact calculation. the 46 is for the stats buffer
                and the 60 is to leave room for the header etc */
-       bufend = &rdata[MAX_DGRAM_SIZE] - (18 + 46 + 60);
+       bufend = &rdata[MAX_DGRAM_SIZE-1] - (18 + 46 + 60);
        countptr = buf = rdata;
        buf += 1;
        buf0 = buf;
@@ -346,7 +347,10 @@ subnet %s - name not found.\n", nmb_namestr(&nmb->question.question_name),
                        unstring name;
 
                        pull_ascii_nstring(name, sizeof(name), namerec->name.name);
-                       strupper_m(name);
+                       if (!strupper_m(name)) {
+                               DEBUG(2,("strupper_m %s failed\n", name));
+                               return;
+                       }
                        if (!strequal(name,"*") &&
                                        !strequal(name,"__SAMBA__") &&
                                        (name_type < 0x1b || name_type >= 0x20 || 
@@ -373,6 +377,8 @@ subnet %s - name not found.\n", nmb_namestr(&nmb->question.question_name),
 
                /* Remove duplicate names. */
                if (names_added > 1) {
+                       /* TODO: should use a real type and
+                          TYPESAFE_QSORT() */
                        qsort( buf0, names_added, 18, QSORT_CAST status_compare );
                }
 
@@ -439,12 +445,12 @@ void process_name_query_request(struct subnet_record *subrec, struct packet_stru
        struct nmb_packet *nmb = &p->packet.nmb;
        struct nmb_name *question = &nmb->question.question_name;
        int name_type = question->name_type;
-       BOOL bcast = nmb->header.nm_flags.bcast;
+       bool bcast = nmb->header.nm_flags.bcast;
        int ttl=0;
        int rcode = 0;
        char *prdata = NULL;
        char rdata[6];
-       BOOL success = False;
+       bool success = False;
        struct name_record *namerec = NULL;
        int reply_data_len = 0;
        int i;