s3-spoolss: make some of the command hooks static.
[kai/samba.git] / source3 / nmbd / nmbd_namelistdb.c
index 736c9fd325ebb3da1c717590bf74a5e05e30cc20..6570fd4ec763c5a0f3a1335649cc62a02d235910 100644 (file)
@@ -16,8 +16,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/>.
    
 */
 
@@ -98,7 +97,7 @@ void remove_name_from_namelist(struct subnet_record *subrec,
 
 struct name_record *find_name_on_subnet(struct subnet_record *subrec,
                                const struct nmb_name *nmbname,
-                               BOOL self_only)
+                               bool self_only)
 {
        struct nmb_name uc_name;
        struct name_record *name_ret;
@@ -140,7 +139,7 @@ struct name_record *find_name_on_subnet(struct subnet_record *subrec,
 ************************************************************************/
 
 struct name_record *find_name_for_remote_broadcast_subnet(struct nmb_name *nmbname,
-                                               BOOL self_only)
+                                               bool self_only)
 {
        struct subnet_record *subrec;
        struct name_record *namerec;
@@ -180,7 +179,7 @@ void update_name_ttl( struct name_record *namerec, int ttl )
  Add an entry to a subnet name list.
 ***********************************************************************/
 
-BOOL add_name_to_subnet( struct subnet_record *subrec,
+bool add_name_to_subnet( struct subnet_record *subrec,
                        const char *name,
                        int type,
                        uint16 nb_flags,
@@ -189,10 +188,14 @@ BOOL add_name_to_subnet( struct subnet_record *subrec,
                        int num_ips,
                        struct in_addr *iplist)
 {
-       BOOL ret = False;
+       bool ret = False;
        struct name_record *namerec;
        time_t time_now = time(NULL);
 
+       if (num_ips == 0) {
+               return false;
+       }
+
        namerec = SMB_MALLOC_P(struct name_record);
        if( NULL == namerec ) {
                DEBUG( 0, ( "add_name_to_subnet: malloc fail.\n" ) );
@@ -294,7 +297,6 @@ void standard_success_register(struct subnet_record *subrec,
  ******************************************************************/
 
 void standard_fail_register( struct subnet_record   *subrec,
-                             struct response_record *rrec,
                              struct nmb_name        *nmbname )
 {
        struct name_record *namerec;
@@ -334,12 +336,12 @@ static void remove_nth_ip_in_record( struct name_record *namerec, int ind)
  Utility function to check if an IP address exists in a name record.
  ******************************************************************/
 
-BOOL find_ip_in_name_record( struct name_record *namerec, struct in_addr ip )
+bool find_ip_in_name_record( struct name_record *namerec, struct in_addr ip )
 {
        int i;
 
        for(i = 0; i < namerec->data.num_ips; i++) {
-               if(ip_equal( namerec->data.ip[i], ip)) {
+               if(ip_equal_v4( namerec->data.ip[i], ip)) {
                        return True;
                }
        }
@@ -392,7 +394,7 @@ void remove_ip_from_name_record( struct name_record *namerec,
        int orig_num = namerec->data.num_ips;
 
        for(i = 0; i < orig_num; i++) {
-               if( ip_equal( remove_ip, namerec->data.ip[i]) ) {
+               if( ip_equal_v4( remove_ip, namerec->data.ip[i]) ) {
                        remove_nth_ip_in_record( namerec, i);
                        break;
                }
@@ -505,8 +507,12 @@ void add_samba_names_to_subnet( struct subnet_record *subrec )
                        return;
                }
 
-               for( bcast_subrecs = FIRST_SUBNET, i = 0; bcast_subrecs; bcast_subrecs = NEXT_SUBNET_EXCLUDING_UNICAST(bcast_subrecs), i++ )
+               for( bcast_subrecs = FIRST_SUBNET, i = 0; bcast_subrecs &&
+                               i < num_ips;
+                               bcast_subrecs = NEXT_SUBNET_EXCLUDING_UNICAST(bcast_subrecs), i++ ) {
                        iplist[i] = bcast_subrecs->myip;
+               }
+               num_ips = i;
        }
 
        add_name_to_subnet(subrec,"*",0x0,samba_nb_type, PERMANENT_TTL,