diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-02-04 05:13:46 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:09:32 -0500 |
commit | 6348a343de14daa4bf1d037d8e72e603a5d94383 (patch) | |
tree | effd7d75543ab1beae0f3472a071e835945a50cf | |
parent | db4ba6e6909b4cf80b2b18f1a0d34b613de4be25 (diff) | |
download | samba-6348a343de14daa4bf1d037d8e72e603a5d94383.tar.gz samba-6348a343de14daa4bf1d037d8e72e603a5d94383.tar.bz2 samba-6348a343de14daa4bf1d037d8e72e603a5d94383.zip |
r5222: made the nbtd_self_packet() code more efficient
(This used to be commit 8fe477955d0e28c891281803d625d80cb78a51b0)
-rw-r--r-- | source4/nbt_server/packet.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/source4/nbt_server/packet.c b/source4/nbt_server/packet.c index c5ed0b41ce..bb9e2459b1 100644 --- a/source4/nbt_server/packet.c +++ b/source4/nbt_server/packet.c @@ -38,7 +38,8 @@ void nbtd_bad_packet(struct nbt_name_packet *packet, /* - 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 @@ BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock, 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; } |