From ab4577f141b0c08a543d998a36892bbafae4e902 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Aug 1998 17:04:24 +0000 Subject: [PATCH] added a dest_port parameter to send_mailslot() so we send replies to the correct port in environments like ip masq. (This used to be commit 7d455ee637b6ff70c95845f89d71573ca07b83f3) --- source3/include/proto.h | 3 ++- source3/nmbd/nmbd_browsesync.c | 3 ++- source3/nmbd/nmbd_elections.c | 2 +- source3/nmbd/nmbd_incomingdgrams.c | 14 +++++++------- source3/nmbd/nmbd_packets.c | 7 +++---- source3/nmbd/nmbd_processlogon.c | 6 +++--- source3/nmbd/nmbd_sendannounce.c | 14 +++++++++----- 7 files changed, 27 insertions(+), 22 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 784d130d23e..ae38ece1a26 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -782,7 +782,8 @@ BOOL listen_for_packets(BOOL run_election); BOOL send_mailslot(BOOL unique, char *mailslot,char *buf,int len, char *srcname, int src_type, char *dstname, int dest_type, - struct in_addr dest_ip,struct in_addr src_ip); + struct in_addr dest_ip,struct in_addr src_ip, + int dest_port); /*The following definitions come from nmbd/nmbd_processlogon.c */ diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c index a4faca55152..8136568c6aa 100644 --- a/source3/nmbd/nmbd_browsesync.c +++ b/source3/nmbd/nmbd_browsesync.c @@ -122,7 +122,8 @@ Do not announce to ourselves.\n", work->work_group )); to %s for workgroup %s.\n", namestr(&work->dmb_name), work->work_group )); send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname, 0x0, work->dmb_name.name, 0x0, work->dmb_addr, FIRST_SUBNET->myip); + global_myname, 0x0, work->dmb_name.name, 0x0, + work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT); } diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c index 5c85191ec2c..cd310639e94 100644 --- a/source3/nmbd/nmbd_elections.c +++ b/source3/nmbd/nmbd_elections.c @@ -62,7 +62,7 @@ static void send_election_dgram(struct subnet_record *subrec, char *workgroup_na send_mailslot(False, BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), global_myname, 0, workgroup_name, 0x1e, - subrec->bcast_ip, subrec->myip); + subrec->bcast_ip, subrec->myip, DGRAM_PORT); } /******************************************************************* diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c index daa321b3ae9..36242d9ac2c 100644 --- a/source3/nmbd/nmbd_incomingdgrams.c +++ b/source3/nmbd/nmbd_incomingdgrams.c @@ -536,12 +536,12 @@ originate from OS/2 Warp client. Ignoring packet.\n")); /**************************************************************************** Send a backup list response. *****************************************************************************/ - static void send_backup_list_response(struct subnet_record *subrec, - struct work_record *work, - struct nmb_name *send_to_name, - unsigned char max_number_requested, - uint32 token, struct in_addr sendto_ip) + struct work_record *work, + struct nmb_name *send_to_name, + unsigned char max_number_requested, + uint32 token, struct in_addr sendto_ip, + int port) { char outbuf[1024]; char *p, *countptr, *nameptr; @@ -610,7 +610,7 @@ static void send_backup_list_response(struct subnet_record *subrec, outbuf,PTR_DIFF(p,outbuf), global_myname, 0, send_to_name->name,0, - sendto_ip, subrec->myip); + sendto_ip, subrec->myip, port); } /******************************************************************* @@ -687,7 +687,7 @@ and I am not a local master browser.\n", workgroup_name)); } send_backup_list_response(subrec, work, &dgram->source_name, - max_number_requested, token, p->ip); + max_number_requested, token, p->ip, p->port); } /******************************************************************* diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c index 65d98c9a596..816695833ac 100644 --- a/source3/nmbd/nmbd_packets.c +++ b/source3/nmbd/nmbd_packets.c @@ -1875,13 +1875,12 @@ BOOL listen_for_packets(BOOL run_election) /**************************************************************************** Construct and send a netbios DGRAM. - Note that this currently sends all packets to port 138. **************************************************************************/ - BOOL send_mailslot(BOOL unique, char *mailslot,char *buf,int len, char *srcname, int src_type, char *dstname, int dest_type, - struct in_addr dest_ip,struct in_addr src_ip) + struct in_addr dest_ip,struct in_addr src_ip, + int dest_port) { BOOL loopback_this_packet = False; struct packet_struct p; @@ -1936,7 +1935,7 @@ BOOL send_mailslot(BOOL unique, char *mailslot,char *buf,int len, dgram->datasize = PTR_DIFF(p2,ptr+4); /* +4 for tcp length. */ p.ip = dest_ip; - p.port = DGRAM_PORT; + p.port = dest_port; p.fd = find_subnet_mailslot_fd_for_address( src_ip ); p.timestamp = time(NULL); p.packet_type = DGRAM_PACKET; diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c index 2ad4a831ca8..29dc68fb800 100644 --- a/source3/nmbd/nmbd_processlogon.c +++ b/source3/nmbd/nmbd_processlogon.c @@ -112,7 +112,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) )); dgram->dest_name.name_type, dgram->source_name.name, dgram->source_name.name_type, - p->ip, *iface_ip(p->ip)); + p->ip, *iface_ip(p->ip), p->port); break; } @@ -167,7 +167,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", dgram->dest_name.name_type, dgram->source_name.name, dgram->source_name.name_type, - p->ip, *iface_ip(p->ip)); + p->ip, *iface_ip(p->ip), p->port); return; } @@ -243,7 +243,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", dgram->dest_name.name_type, dgram->source_name.name, dgram->source_name.name_type, - p->ip, *iface_ip(p->ip)); + p->ip, *iface_ip(p->ip), p->port); break; } diff --git a/source3/nmbd/nmbd_sendannounce.c b/source3/nmbd/nmbd_sendannounce.c index 6c9f67ab210..d43d2878e3e 100644 --- a/source3/nmbd/nmbd_sendannounce.c +++ b/source3/nmbd/nmbd_sendannounce.c @@ -54,7 +54,8 @@ void send_browser_reset(int reset_type, char *to_name, int to_type, struct in_ad p++; send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname, 0x0, to_name, to_type, to_ip, FIRST_SUBNET->myip); + global_myname, 0x0, to_name, to_type, to_ip, + FIRST_SUBNET->myip, DGRAM_PORT); } /**************************************************************************** @@ -84,7 +85,8 @@ to subnet %s\n", work->work_group, subrec->subnet_name)); p = skip_string(p,1); send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname, 0x0, work->work_group,0x1e, subrec->bcast_ip, subrec->myip); + global_myname, 0x0, work->work_group,0x1e, subrec->bcast_ip, + subrec->myip, DGRAM_PORT); } /**************************************************************************** @@ -124,7 +126,8 @@ static void send_announcement(struct subnet_record *subrec, int announce_type, p = skip_string(p,1); send_mailslot(False,BROWSE_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), - from_name, 0x0, to_name, to_type, to_ip, subrec->myip); + from_name, 0x0, to_name, to_type, to_ip, subrec->myip, + DGRAM_PORT); } /**************************************************************************** @@ -155,7 +158,8 @@ static void send_lm_announcement(struct subnet_record *subrec, int announce_type p = skip_string(p,1); send_mailslot(False,LANMAN_MAILSLOT, outbuf, PTR_DIFF(p,outbuf), - from_name, 0x0, to_name, to_type, to_ip, subrec->myip); + from_name, 0x0, to_name, to_type, to_ip, subrec->myip, + DGRAM_PORT); } /**************************************************************************** @@ -601,6 +605,6 @@ for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name global_myname, inet_ntoa(addr) )); send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf), - global_myname, 0x0, "*", 0x0, addr, FIRST_SUBNET->myip); + global_myname, 0x0, "*", 0x0, addr, FIRST_SUBNET->myip, DGRAM_PORT); } } -- 2.34.1