svn commit: samba r5222 - in branches/SAMBA_4_0/source/nbt_server: .

tridge at samba.org tridge at samba.org
Fri Feb 4 05:13:47 GMT 2005


Author: tridge
Date: 2005-02-04 05:13:46 +0000 (Fri, 04 Feb 2005)
New Revision: 5222

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5222

Log:
made the nbtd_self_packet() code more efficient




Modified:
   branches/SAMBA_4_0/source/nbt_server/packet.c


Changeset:
Modified: branches/SAMBA_4_0/source/nbt_server/packet.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/packet.c	2005-02-04 04:58:48 UTC (rev 5221)
+++ branches/SAMBA_4_0/source/nbt_server/packet.c	2005-02-04 05:13:46 UTC (rev 5222)
@@ -38,7 +38,8 @@
 
 
 /*
-  see if an incoming packet is from one of our own interfaces
+  see if an incoming packet is a broadcast packet from one of our own
+  interfaces
 */
 BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock, 
 		      struct nbt_name_packet *packet, 
@@ -48,20 +49,29 @@
 						      struct nbt_interface);
 	struct nbt_server *nbtsrv = iface->nbtsrv;
 	
+	/* if its not a broadcast then its not considered a self packet */
+	if (!(packet->operation & NBT_FLAG_BROADCAST)) {
+		return False;
+	}
+
+	/* if its not from the nbt port, then it wasn't a broadcast from us */
 	if (src_port != lp_nbt_port()) {
 		return False;
 	}
 
+	/* this uses the fact that iface->nbtsock is our non-broadcast
+	   listen address */
+	if (iface->nbtsock == nbtsock) {
+		return False;
+	}
+
+	/* we have to loop over our interface list, seeing if its from
+	   one of our own interfaces */
 	for (iface=nbtsrv->interfaces;iface;iface=iface->next) {
 		if (strcmp(src_address, iface->ip_address) == 0) {
 			return True;
 		}
 	}
 
-	if (nbtsrv->bcast_interface &&
-	    strcmp(src_address, nbtsrv->bcast_interface->ip_address) == 0) {
-		return True;
-	}
-
 	return False;
 }



More information about the samba-cvs mailing list