Convert all uses of uint8/16/32 to _t in nmbd and the include file.
[samba.git] / source3 / nmbd / nmbd_incomingdgrams.c
index f646e397162a424c5f71ac02a24c2fc3def0771d..b728c13e5fe000d2d0750cf74e05ce3b1716a4d3 100644 (file)
@@ -7,7 +7,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
    
    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,
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    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/>.
    
 */
 
 #include "includes.h"
    
 */
 
 #include "includes.h"
+#include "../librpc/gen_ndr/svcctl.h"
+#include "nmbd/nmbd.h"
 
 
-extern BOOL found_lm_clients;
+extern bool found_lm_clients;
 
 #if 0
 
 
 #if 0
 
@@ -93,25 +94,22 @@ void tell_become_backup(void)
   Process an incoming host announcement packet.
 *******************************************************************/
 
   Process an incoming host announcement packet.
 *******************************************************************/
 
-void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        int ttl = IVAL(buf,1)/1000;
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        int ttl = IVAL(buf,1)/1000;
-       nstring announce_name;
-       uint32 servertype = IVAL(buf,23);
+       unstring announce_name;
+       uint32_t servertype = IVAL(buf,23);
        fstring comment;
        struct work_record *work;
        struct server_record *servrec;
        fstring comment;
        struct work_record *work;
        struct server_record *servrec;
-       nstring work_name;
-       nstring source_name;
-
-       START_PROFILE(host_announce);
+       unstring work_name;
+       unstring source_name;
 
        pull_ascii_fstring(comment, buf+31);
 
        pull_ascii_fstring(comment, buf+31);
-       comment[42] = 0;
   
   
-       pull_ascii_nstring(announce_name, buf+5);
-       pull_ascii_nstring(source_name, dgram->source_name.name);
+       pull_ascii_nstring(announce_name, sizeof(announce_name), buf+5);
+       pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
 
        DEBUG(3,("process_host_announce: from %s<%02x> IP %s to \
 %s for server %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
 
        DEBUG(3,("process_host_announce: from %s<%02x> IP %s to \
 %s for server %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
@@ -133,7 +131,7 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
        }
 
        /* For a host announce the workgroup name is the destination name. */
        }
 
        /* For a host announce the workgroup name is the destination name. */
-       pull_ascii_nstring(work_name, dgram->dest_name.name);
+       pull_ascii_nstring(work_name, sizeof(work_name), dgram->dest_name.name);
 
        /*
         * Syntax servers version 5.1 send HostAnnounce packets to
 
        /*
         * Syntax servers version 5.1 send HostAnnounce packets to
@@ -143,8 +141,8 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
         * to be our primary workgroup name.
         */
 
         * to be our primary workgroup name.
         */
 
-       if(strequal(work_name, global_myname()))
-               nstrcpy(work_name,lp_workgroup());
+       if(strequal(work_name, lp_netbios_name()))
+               unstrcpy(work_name,lp_workgroup());
 
        /*
         * We are being very agressive here in adding a workgroup
 
        /*
         * We are being very agressive here in adding a workgroup
@@ -171,7 +169,7 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl( servrec, ttl);
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl( servrec, ttl);
-                       fstrcpy(servrec->serv.comment,comment);
+                       strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
                }
        } else {
                /*
                }
        } else {
                /*
@@ -186,31 +184,28 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
 
        subrec->work_changed = True;
 done:
 
        subrec->work_changed = True;
 done:
-
-       END_PROFILE(host_announce);
+       return;
 }
 
 /*******************************************************************
   Process an incoming WORKGROUP announcement packet.
 *******************************************************************/
 
 }
 
 /*******************************************************************
   Process an incoming WORKGROUP announcement packet.
 *******************************************************************/
 
-void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        int ttl = IVAL(buf,1)/1000;
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        int ttl = IVAL(buf,1)/1000;
-       nstring workgroup_announce_name;
-       nstring master_name;
-       uint32 servertype = IVAL(buf,23);
+       unstring workgroup_announce_name;
+       unstring master_name;
+       uint32_t servertype = IVAL(buf,23);
        struct work_record *work;
        struct work_record *work;
-       nstring source_name;
-       nstring dest_name;
+       unstring source_name;
+       unstring dest_name;
 
 
-       START_PROFILE(workgroup_announce);
-
-       pull_ascii_nstring(workgroup_announce_name,buf+5);
-       pull_ascii_nstring(master_name,buf+31);
-       pull_ascii_nstring(source_name,dgram->source_name.name);
-       pull_ascii_nstring(dest_name,dgram->dest_name.name);
+       pull_ascii_nstring(workgroup_announce_name,sizeof(workgroup_announce_name),buf+5);
+       pull_ascii_nstring(master_name,sizeof(master_name),buf+31);
+       pull_ascii_nstring(source_name,sizeof(source_name),dgram->source_name.name);
+       pull_ascii_nstring(dest_name,sizeof(dest_name),dgram->dest_name.name);
 
        DEBUG(3,("process_workgroup_announce: from %s<%02x> IP %s to \
 %s for workgroup %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
 
        DEBUG(3,("process_workgroup_announce: from %s<%02x> IP %s to \
 %s for workgroup %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
@@ -243,33 +238,29 @@ void process_workgroup_announce(struct subnet_record *subrec, struct packet_stru
        subrec->work_changed = True;
 
 done:
        subrec->work_changed = True;
 
 done:
-
-       END_PROFILE(workgroup_announce);
+       return;
 }
 
 /*******************************************************************
   Process an incoming local master browser announcement packet.
 *******************************************************************/
 
 }
 
 /*******************************************************************
   Process an incoming local master browser announcement packet.
 *******************************************************************/
 
-void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        int ttl = IVAL(buf,1)/1000;
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        int ttl = IVAL(buf,1)/1000;
-       nstring server_name;
-       uint32 servertype = IVAL(buf,23);
+       unstring server_name;
+       uint32_t servertype = IVAL(buf,23);
        fstring comment;
        fstring comment;
-       nstring work_name;
-       struct work_record *work;
+       unstring work_name;
+       struct work_record *work = NULL;
        struct server_record *servrec;
        struct server_record *servrec;
-       nstring source_name;
-
-       START_PROFILE(local_master_announce);
+       unstring source_name;
 
 
-       pull_ascii_nstring(server_name,buf+5);
+       pull_ascii_nstring(server_name,sizeof(server_name),buf+5);
        pull_ascii_fstring(comment, buf+31);
        pull_ascii_fstring(comment, buf+31);
-       comment[42] = 0;
-       pull_ascii_nstring(source_name, dgram->source_name.name);
-       pull_ascii_nstring(work_name, dgram->dest_name.name);
+       pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
+       pull_ascii_nstring(work_name, sizeof(work_name), dgram->dest_name.name);
 
        DEBUG(3,("process_local_master_announce: from %s<%02x> IP %s to \
 %s for server %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
 
        DEBUG(3,("process_local_master_announce: from %s<%02x> IP %s to \
 %s for server %s.\n", source_name, source_name[15], inet_ntoa(p->ip),
@@ -338,7 +329,7 @@ a local master browser for workgroup %s and we think we are master. Forcing elec
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl(servrec, ttl);
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl(servrec, ttl);
-                       fstrcpy(servrec->serv.comment,comment);
+                       strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
                }
        
                set_workgroup_local_master_browser_name( work, server_name );
                }
        
                set_workgroup_local_master_browser_name( work, server_name );
@@ -347,7 +338,7 @@ a local master browser for workgroup %s and we think we are master. Forcing elec
                 * This server is announcing it is going down. Remove it from the
                 * workgroup.
                 */
                 * This server is announcing it is going down. Remove it from the
                 * workgroup.
                 */
-               if(!is_myname(server_name) && (work != NULL) &&
+               if(!is_myname(server_name) &&
                                ((servrec = find_server_in_workgroup( work, server_name))!=NULL)) {
                        remove_server_from_workgroup( work, servrec);
                }
                                ((servrec = find_server_in_workgroup( work, server_name))!=NULL)) {
                        remove_server_from_workgroup( work, servrec);
                }
@@ -355,8 +346,7 @@ a local master browser for workgroup %s and we think we are master. Forcing elec
 
        subrec->work_changed = True;
 done:
 
        subrec->work_changed = True;
 done:
-
-       END_PROFILE(local_master_announce);
+       return;
 }
 
 /*******************************************************************
 }
 
 /*******************************************************************
@@ -367,15 +357,13 @@ done:
 ******************************************************************/
 
 void process_master_browser_announce(struct subnet_record *subrec, 
 ******************************************************************/
 
 void process_master_browser_announce(struct subnet_record *subrec, 
-                                     struct packet_struct *p,char *buf)
+                                     struct packet_struct *p,const char *buf)
 {
 {
-       nstring local_master_name;
+       unstring local_master_name;
        struct work_record *work;
        struct browse_cache_record *browrec;
 
        struct work_record *work;
        struct browse_cache_record *browrec;
 
-       START_PROFILE(master_browser_announce);
-
-       pull_ascii_nstring(local_master_name,buf);
+       pull_ascii_nstring(local_master_name,sizeof(local_master_name),buf);
   
        DEBUG(3,("process_master_browser_announce: Local master announce from %s IP %s.\n",
                local_master_name, inet_ntoa(p->ip)));
   
        DEBUG(3,("process_master_browser_announce: Local master announce from %s IP %s.\n",
                local_master_name, inet_ntoa(p->ip)));
@@ -410,37 +398,41 @@ master - ignoring master announce.\n"));
        }
 
 done:
        }
 
 done:
-
-       END_PROFILE(master_browser_announce);
+       return;
 }
 
 /*******************************************************************
   Process an incoming LanMan host announcement packet.
 *******************************************************************/
 
 }
 
 /*******************************************************************
   Process an incoming LanMan host announcement packet.
 *******************************************************************/
 
-void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
 {
        struct dgram_packet *dgram = &p->packet.dgram;
-       uint32 servertype = IVAL(buf,1);
+       uint32_t servertype = IVAL(buf,1);
        int osmajor=CVAL(buf,5);           /* major version of node software */
        int osminor=CVAL(buf,6);           /* minor version of node software */
        int ttl = SVAL(buf,7);
        int osmajor=CVAL(buf,5);           /* major version of node software */
        int osminor=CVAL(buf,6);           /* minor version of node software */
        int ttl = SVAL(buf,7);
-       nstring announce_name;
+       unstring announce_name;
        struct work_record *work;
        struct server_record *servrec;
        struct work_record *work;
        struct server_record *servrec;
-       nstring work_name;
-       nstring source_name;
+       unstring work_name;
+       unstring source_name;
        fstring comment;
        fstring comment;
-       char *s = buf+9;
+       char *s = get_safe_str_ptr(buf,len,discard_const_p(char, buf),9);
 
 
-       START_PROFILE(lm_host_announce);
-       s = skip_string(s,1);
+       if (!s) {
+               goto done;
+       }
+       s = skip_string(buf,len,s);
+       if (!s) {
+               goto done;
+       }
        pull_ascii(comment, s, sizeof(fstring), 43, STR_TERMINATE);
 
        pull_ascii(comment, s, sizeof(fstring), 43, STR_TERMINATE);
 
-       pull_ascii_nstring(announce_name,buf+9);
-       pull_ascii_nstring(source_name,dgram->source_name.name);
+       pull_ascii_nstring(announce_name,sizeof(announce_name),buf+9);
+       pull_ascii_nstring(source_name,sizeof(source_name),dgram->source_name.name);
        /* For a LanMan host announce the workgroup name is the destination name. */
        /* For a LanMan host announce the workgroup name is the destination name. */
-       pull_ascii_nstring(work_name,dgram->dest_name.name);
+       pull_ascii_nstring(work_name,sizeof(work_name),dgram->dest_name.name);
 
        DEBUG(3,("process_lm_host_announce: LM Announcement from %s IP %s to \
 %s for server %s.\n", nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
 
        DEBUG(3,("process_lm_host_announce: LM Announcement from %s IP %s to \
 %s for server %s.\n", nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
@@ -478,8 +470,8 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
         * not needed in the LanMan announce code, but it won't hurt.
         */
 
         * not needed in the LanMan announce code, but it won't hurt.
         */
 
-       if(strequal(work_name, global_myname()))
-               nstrcpy(work_name,lp_workgroup());
+       if(strequal(work_name, lp_netbios_name()))
+               unstrcpy(work_name,lp_workgroup());
 
        /*
         * We are being very agressive here in adding a workgroup
 
        /*
         * We are being very agressive here in adding a workgroup
@@ -506,7 +498,7 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl( servrec, ttl);
                        /* Update the record. */
                        servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
                        update_server_ttl( servrec, ttl);
-                       fstrcpy(servrec->serv.comment,comment);
+                       strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
                }
        } else {
                /*
                }
        } else {
                /*
@@ -523,37 +515,36 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
        found_lm_clients = True;
 
 done:
        found_lm_clients = True;
 
 done:
-
-       END_PROFILE(lm_host_announce);
+       return;
 }
 
 /****************************************************************************
   Send a backup list response.
 *****************************************************************************/
 
 }
 
 /****************************************************************************
   Send a backup list response.
 *****************************************************************************/
 
-static void send_backup_list_response(struct subnet_record *subrec, 
+static void send_backup_list_response(struct subnet_record *subrec,
                                      struct work_record *work,
                                      struct nmb_name *send_to_name,
                                      unsigned char max_number_requested,
                                      struct work_record *work,
                                      struct nmb_name *send_to_name,
                                      unsigned char max_number_requested,
-                                     uint32 token, struct in_addr sendto_ip,
+                                     uint32_t token, struct in_addr sendto_ip,
                                      int port)
                                      int port)
-{                     
+{
        char outbuf[1024];
        char *p, *countptr;
        unsigned int count = 0;
        char outbuf[1024];
        char *p, *countptr;
        unsigned int count = 0;
-       nstring send_to_namestr;
+       unstring send_to_namestr;
 #if 0
   struct server_record *servrec;
 #endif
 #if 0
   struct server_record *servrec;
 #endif
-       fstring myname;
+       unstring myname;
 
        memset(outbuf,'\0',sizeof(outbuf));
 
        DEBUG(3,("send_backup_list_response: sending backup list for workgroup %s to %s IP %s\n",
                work->work_group, nmb_namestr(send_to_name), inet_ntoa(sendto_ip)));
 
        memset(outbuf,'\0',sizeof(outbuf));
 
        DEBUG(3,("send_backup_list_response: sending backup list for workgroup %s to %s IP %s\n",
                work->work_group, nmb_namestr(send_to_name), inet_ntoa(sendto_ip)));
-  
+
        p = outbuf;
        p = outbuf;
-  
+
        SCVAL(p,0,ANN_GetBackupListResp); /* Backup list response opcode. */
        p++;
 
        SCVAL(p,0,ANN_GetBackupListResp); /* Backup list response opcode. */
        p++;
 
@@ -562,15 +553,18 @@ static void send_backup_list_response(struct subnet_record *subrec,
 
        SIVAL(p,0,token); /* The sender's unique info. */
        p += 4;
 
        SIVAL(p,0,token); /* The sender's unique info. */
        p += 4;
-  
+
        /* We always return at least one name - our own. */
        count = 1;
        /* We always return at least one name - our own. */
        count = 1;
-       fstrcpy(myname, global_myname());
-       strupper_m(myname);
+       unstrcpy(myname, lp_netbios_name());
+       if (!strupper_m(myname)) {
+               DEBUG(4,("strupper_m %s failed\n", myname));
+               return;
+       }
        myname[15]='\0';
        myname[15]='\0';
-       push_pstring_base(p, myname, outbuf);
+       push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE);
 
 
-       p = skip_string(p,1);
+       p = skip_string(outbuf,sizeof(outbuf),p);
 
        /* Look for backup browsers in this workgroup. */
 
 
        /* Look for backup browsers in this workgroup. */
 
@@ -593,7 +587,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
     if(count >= (unsigned int)max_number_requested)
       break;
 
     if(count >= (unsigned int)max_number_requested)
       break;
 
-    if(strnequal(servrec->serv.name, global_myname(),15))
+    if(strnequal(servrec->serv.name, lp_netbios_name(),15))
       continue;
 
     if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER))
       continue;
 
     if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER))
@@ -606,20 +600,20 @@ static void send_backup_list_response(struct subnet_record *subrec,
     DEBUG(5,("send_backup_list_response: Adding server %s number %d\n",
               p, count));
 
     DEBUG(5,("send_backup_list_response: Adding server %s number %d\n",
               p, count));
 
-    p = skip_string(p,1);
+    p = skip_string(outbuf,sizeof(outbuf),p);
   }
 #endif
 
        SCVAL(countptr, 0, count);
 
   }
 #endif
 
        SCVAL(countptr, 0, count);
 
-       pull_ascii_nstring(send_to_namestr, send_to_name->name);
+       pull_ascii_nstring(send_to_namestr, sizeof(send_to_namestr), send_to_name->name);
 
        DEBUG(4,("send_backup_list_response: sending response to %s<00> IP %s with %d servers.\n",
                send_to_namestr, inet_ntoa(sendto_ip), count));
 
        send_mailslot(True, BROWSE_MAILSLOT,
                outbuf,PTR_DIFF(p,outbuf),
 
        DEBUG(4,("send_backup_list_response: sending response to %s<00> IP %s with %d servers.\n",
                send_to_namestr, inet_ntoa(sendto_ip), count));
 
        send_mailslot(True, BROWSE_MAILSLOT,
                outbuf,PTR_DIFF(p,outbuf),
-               global_myname(), 0, 
+               lp_netbios_name(), 0,
                send_to_namestr,0,
                sendto_ip, subrec->myip, port);
 }
                send_to_namestr,0,
                sendto_ip, subrec->myip, port);
 }
@@ -635,18 +629,17 @@ static void send_backup_list_response(struct subnet_record *subrec,
 ********************************************************************/
 
 void process_get_backup_list_request(struct subnet_record *subrec,
 ********************************************************************/
 
 void process_get_backup_list_request(struct subnet_record *subrec,
-                                     struct packet_struct *p,char *buf)
+                                     struct packet_struct *p,const char *buf)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        struct work_record *work;
        unsigned char max_number_requested = CVAL(buf,0);
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        struct work_record *work;
        unsigned char max_number_requested = CVAL(buf,0);
-       uint32 token = IVAL(buf,1); /* Sender's key index for the workgroup. */
+       uint32_t token = IVAL(buf,1); /* Sender's key index for the workgroup. */
        int name_type = dgram->dest_name.name_type;
        int name_type = dgram->dest_name.name_type;
-       nstring workgroup_name;
+       unstring workgroup_name;
        struct subnet_record *search_subrec = subrec;
 
        struct subnet_record *search_subrec = subrec;
 
-       START_PROFILE(get_backup_list);
-       pull_ascii_nstring(workgroup_name, dgram->dest_name.name);
+       pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
 
        DEBUG(3,("process_get_backup_list_request: request from %s IP %s to %s.\n",
                nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
 
        DEBUG(3,("process_get_backup_list_request: request from %s IP %s to %s.\n",
                nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
@@ -703,8 +696,7 @@ and I am not a local master browser.\n", workgroup_name));
                        max_number_requested, token, p->ip, p->port);
 
 done:
                        max_number_requested, token, p->ip, p->port);
 
 done:
-
-       END_PROFILE(get_backup_list);
+       return;
 }
 
 /*******************************************************************
 }
 
 /*******************************************************************
@@ -718,14 +710,12 @@ done:
 ******************************************************************/
 
 void process_reset_browser(struct subnet_record *subrec,
 ******************************************************************/
 
 void process_reset_browser(struct subnet_record *subrec,
-                                  struct packet_struct *p,char *buf)
+                                  struct packet_struct *p,const char *buf)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        int state = CVAL(buf,0);
        struct subnet_record *sr;
 
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        int state = CVAL(buf,0);
        struct subnet_record *sr;
 
-       START_PROFILE(reset_browser);
-
        DEBUG(1,("process_reset_browser: received diagnostic browser reset \
 request from %s IP %s state=0x%X\n",
                nmb_namestr(&dgram->source_name), inet_ntoa(p->ip), state));
        DEBUG(1,("process_reset_browser: received diagnostic browser reset \
 request from %s IP %s state=0x%X\n",
                nmb_namestr(&dgram->source_name), inet_ntoa(p->ip), state));
@@ -758,8 +748,6 @@ request from %s IP %s state=0x%X\n",
        /* Request to stop browsing altogether. */
        if (state & 0x4)
                DEBUG(1,("process_reset_browser: ignoring request to stop being a browser.\n"));
        /* Request to stop browsing altogether. */
        if (state & 0x4)
                DEBUG(1,("process_reset_browser: ignoring request to stop being a browser.\n"));
-
-       END_PROFILE(reset_browser);
 }
 
 /*******************************************************************
 }
 
 /*******************************************************************
@@ -770,15 +758,13 @@ request from %s IP %s state=0x%X\n",
   announcement is needed soon.
 ******************************************************************/
 
   announcement is needed soon.
 ******************************************************************/
 
-void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        struct work_record *work;
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        struct work_record *work;
-       nstring workgroup_name;
+       unstring workgroup_name;
  
  
-       START_PROFILE(announce_request);
-
-       pull_ascii_nstring(workgroup_name, dgram->dest_name.name);
+       pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
        DEBUG(3,("process_announce_request: Announce request from %s IP %s to %s.\n",
                nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
                nmb_namestr(&dgram->dest_name)));
        DEBUG(3,("process_announce_request: Announce request from %s IP %s to %s.\n",
                nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
                nmb_namestr(&dgram->dest_name)));
@@ -798,8 +784,7 @@ void process_announce_request(struct subnet_record *subrec, struct packet_struct
 
        work->needannounce = True;
 done:
 
        work->needannounce = True;
 done:
-
-       END_PROFILE(lm_host_announce);
+       return;
 }
 
 /*******************************************************************
 }
 
 /*******************************************************************
@@ -811,14 +796,12 @@ done:
   through the "lm announce" parameter in smb.conf)
 ******************************************************************/
 
   through the "lm announce" parameter in smb.conf)
 ******************************************************************/
 
-void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf)
+void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, const char *buf, int len)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
 {
        struct dgram_packet *dgram = &p->packet.dgram;
-       nstring workgroup_name;
-
-       START_PROFILE(lm_announce_request);
+       unstring workgroup_name;
 
 
-       pull_ascii_nstring(workgroup_name, dgram->dest_name.name);
+       pull_ascii_nstring(workgroup_name, sizeof(workgroup_name), dgram->dest_name.name);
        DEBUG(3,("process_lm_announce_request: Announce request from %s IP %s to %s.\n",
                nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
                nmb_namestr(&dgram->dest_name)));
        DEBUG(3,("process_lm_announce_request: Announce request from %s IP %s to %s.\n",
                nmb_namestr(&dgram->source_name), inet_ntoa(p->ip),
                nmb_namestr(&dgram->dest_name)));
@@ -839,6 +822,5 @@ void process_lm_announce_request(struct subnet_record *subrec, struct packet_str
        found_lm_clients = True;
 
 done:
        found_lm_clients = True;
 
 done:
-
-       END_PROFILE(lm_host_announce);
+       return;
 }
 }