Merge branch 'v3-2-test' of ssh://jra@git.samba.org/data/git/samba into v3-2-test
[kai/samba.git] / source3 / nmbd / nmbd_sendannounce.c
index 6670c55bf310ce72c3c9716446ea0d6e3a447a4a..3cc9bb52b0957222c3e89a5625c29ab988db4dcb 100644 (file)
@@ -34,7 +34,7 @@ extern bool found_lm_clients;
 
 void send_browser_reset(int reset_type, const char *to_name, int to_type, struct in_addr to_ip)
 {
-       char outbuf[PSTRING_LEN];
+       char outbuf[1024];
        char *p;
 
        DEBUG(3,("send_browser_reset: sending reset request type %d to %s<%02x> IP %s.\n",
@@ -59,7 +59,7 @@ void send_browser_reset(int reset_type, const char *to_name, int to_type, struct
 
 void broadcast_announce_request(struct subnet_record *subrec, struct work_record *work)
 {
-       char outbuf[PSTRING_LEN];
+       char outbuf[1024];
        char *p;
 
        work->needannounce = True;
@@ -90,7 +90,7 @@ static void send_announcement(struct subnet_record *subrec, int announce_type,
                               time_t announce_interval,
                               const char *server_name, int server_type, const char *server_comment)
 {
-       char outbuf[PSTRING_LEN];
+       char outbuf[1024];
        unstring upper_server_name;
        char *p;
 
@@ -131,7 +131,7 @@ static void send_lm_announcement(struct subnet_record *subrec, int announce_type
                               time_t announce_interval,
                               char *server_name, int server_type, char *server_comment)
 {
-       char outbuf[PSTRING_LEN];
+       char outbuf[1024];
        char *p=outbuf;
 
        memset(outbuf,'\0',sizeof(outbuf));
@@ -457,10 +457,11 @@ void announce_remote(time_t t)
        char *s;
        const char *ptr;
        static time_t last_time = 0;
-       pstring s2;
+       char *s2;
        struct in_addr addr;
        char *comment;
        int stype = lp_default_server_announce();
+       TALLOC_CTX *frame = NULL;
 
        if (last_time && (t < (last_time + REMOTE_ANNOUNCE_INTERVAL)))
                return;
@@ -473,8 +474,9 @@ void announce_remote(time_t t)
 
        comment = string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH);
 
-       for (ptr=s; next_token(&ptr,s2,NULL,sizeof(s2)); ) {
-               /* The entries are of the form a.b.c.d/WORKGROUP with 
+       frame = talloc_stackframe();
+       for (ptr=s; next_token_talloc(frame,&ptr,&s2,NULL); ) {
+               /* The entries are of the form a.b.c.d/WORKGROUP with
                                WORKGROUP being optional */
                const char *wgroup;
                char *pwgroup;
@@ -488,8 +490,8 @@ void announce_remote(time_t t)
                else
                        wgroup = pwgroup;
 
-               addr = *interpret_addr2(s2);
-    
+               (void)interpret_addr2(&addr,s2);
+
                /* Announce all our names including aliases */
                /* Give the ip address as the address of our first
                                broadcast subnet. */
@@ -510,6 +512,7 @@ void announce_remote(time_t t)
                                                comment);
                }
        }
+       TALLOC_FREE(frame);
 }
 
 /****************************************************************************
@@ -518,20 +521,21 @@ void announce_remote(time_t t)
 **************************************************************************/
 
 void browse_sync_remote(time_t t)
-{  
+{
        char *s;
        const char *ptr;
-       static time_t last_time = 0; 
-       pstring s2;
+       static time_t last_time = 0;
+       char *s2;
        struct in_addr addr;
        struct work_record *work;
-       pstring outbuf;
+       char outbuf[1024];
        char *p;
        unstring myname;
+       TALLOC_CTX *frame = NULL;
+
        if (last_time && (t < (last_time + REMOTE_ANNOUNCE_INTERVAL)))
                return;
-   
+
        last_time = t;
 
        s = lp_remote_browse_sync();
@@ -548,12 +552,12 @@ void browse_sync_remote(time_t t)
                        lp_workgroup(), FIRST_SUBNET->subnet_name ));
                return;
        }
-         
+
        if(!AM_LOCAL_MASTER_BROWSER(work)) {
                DEBUG(5,("browse_sync_remote: We can only do this if we are a local master browser \
 for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
                return;
-       } 
+       }
 
        memset(outbuf,'\0',sizeof(outbuf));
        p = outbuf;
@@ -563,13 +567,14 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
        unstrcpy(myname, global_myname());
        strupper_m(myname);
        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(outbuf,sizeof(outbuf),p);
 
-       for (ptr=s; next_token(&ptr,s2,NULL,sizeof(s2)); ) {
+       frame = talloc_stackframe();
+       for (ptr=s; next_token_talloc(frame,&ptr,&s2,NULL); ) {
                /* The entries are of the form a.b.c.d */
-               addr = *interpret_addr2(s2);
+               (void)interpret_addr2(&addr,s2);
 
                DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n",
                        global_myname(), inet_ntoa(addr) ));
@@ -577,4 +582,5 @@ for workgroup %s on subnet %s.\n", lp_workgroup(), FIRST_SUBNET->subnet_name ));
                send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
                        global_myname(), 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT);
        }
+       TALLOC_FREE(frame);
 }