From 30a1bc365071befd07e68e24ca4fa3843159ab13 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 28 Jan 2010 11:04:05 +0100 Subject: s3:nmbd: also listen explicit on the subnet broadcast addresses And send replies always via the unicast address of the subnet. This behavior is off by default (as before) and can be enabled with "nmbd:bind explicit broadcast = yes". metze --- source3/libsmb/namequery.c | 6 ++++-- source3/libsmb/nmblib.c | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'source3/libsmb') diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index a6fc612a0f..be038ecdad 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -289,7 +289,8 @@ NODE_STATUS_STRUCT *node_status_query(int fd, p.ip = ((const struct sockaddr_in *)to_ss)->sin_addr; p.port = NMB_PORT; - p.fd = fd; + p.recv_fd = -1; + p.send_fd = fd; p.timestamp = time(NULL); p.packet_type = NMB_PACKET; @@ -698,7 +699,8 @@ struct sockaddr_storage *name_query(int fd, p.ip = ((struct sockaddr_in *)to_ss)->sin_addr; p.port = NMB_PORT; - p.fd = fd; + p.recv_fd = -1; + p.send_fd = fd; p.timestamp = time(NULL); p.packet_type = NMB_PACKET; diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c index 5f3eda44fe..1a2106675b 100644 --- a/source3/libsmb/nmblib.c +++ b/source3/libsmb/nmblib.c @@ -601,6 +601,8 @@ static struct packet_struct *copy_nmb_packet(struct packet_struct *packet) /* Ensure this copy is not locked. */ pkt_copy->locked = False; + pkt_copy->recv_fd = -1; + pkt_copy->send_fd = -1; /* Ensure this copy has no resource records. */ nmb = &packet->packet.nmb; @@ -666,6 +668,8 @@ static struct packet_struct *copy_dgram_packet(struct packet_struct *packet) /* Ensure this copy is not locked. */ pkt_copy->locked = False; + pkt_copy->recv_fd = -1; + pkt_copy->send_fd = -1; /* There are no additional pointers in a dgram packet, we are finished. */ @@ -791,7 +795,8 @@ struct packet_struct *read_packet(int fd,enum packet_type packet_type) if (!packet) return NULL; - packet->fd = fd; + packet->recv_fd = fd; + packet->send_fd = -1; DEBUG(5,("Received a packet of len %d from (%s) port %d\n", length, inet_ntoa(packet->ip), packet->port ) ); @@ -1075,7 +1080,7 @@ bool send_packet(struct packet_struct *p) if (!len) return(False); - return(send_udp(p->fd,buf,len,p->ip,p->port)); + return(send_udp(p->send_fd,buf,len,p->ip,p->port)); } /**************************************************************************** -- cgit