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

tridge at samba.org tridge at samba.org
Fri Feb 4 02:05:28 GMT 2005


Author: tridge
Date: 2005-02-04 02:05:27 +0000 (Fri, 04 Feb 2005)
New Revision: 5212

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

Log:
added checking for receiving our own packets as broadcasts


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


Changeset:
Modified: branches/SAMBA_4_0/source/nbt_server/interfaces.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/interfaces.c	2005-02-04 01:55:50 UTC (rev 5211)
+++ branches/SAMBA_4_0/source/nbt_server/interfaces.c	2005-02-04 02:05:27 UTC (rev 5212)
@@ -40,6 +40,12 @@
 		return;
 	}
 
+	/* see if its from one of our own interfaces - if so, then ignore it */
+	if (nbtd_self_packet(nbtsock, packet, src_address, src_port)) {
+		DEBUG(10,("Ignoring self packet from %s:%d\n", src_address, src_port));
+		return;
+	}
+
 	/* the request is to us in our role as a B node */
 	switch (packet->operation & NBT_OPCODE) {
 	case NBT_OPCODE_QUERY:

Modified: branches/SAMBA_4_0/source/nbt_server/packet.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/packet.c	2005-02-04 01:55:50 UTC (rev 5211)
+++ branches/SAMBA_4_0/source/nbt_server/packet.c	2005-02-04 02:05:27 UTC (rev 5212)
@@ -36,3 +36,32 @@
 	}
 }
 
+
+/*
+  see if an incoming packet is from one of our own interfaces
+*/
+BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock, 
+		      struct nbt_name_packet *packet, 
+		      const char *src_address, int src_port)
+{
+	struct nbt_interface *iface = talloc_get_type(nbtsock->incoming.private, 
+						      struct nbt_interface);
+	struct nbt_server *nbtsrv = iface->nbtsrv;
+	
+	if (src_port != lp_nbt_port()) {
+		return False;
+	}
+
+	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