X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source3%2Fnamepacket.c;h=418155bbd85b1fa19baa70093f432c3a1e39becc;hb=d98bea900ee694cdba83149620c65bd7f8765f26;hp=e62f3f00b0af52af12d822e1ad9f3164d951a680;hpb=33548ecd2de99e944baf93271e74a46d9b05d13f;p=samba.git diff --git a/source3/namepacket.c b/source3/namepacket.c index e62f3f00b0a..418155bbd85 100644 --- a/source3/namepacket.c +++ b/source3/namepacket.c @@ -2,7 +2,7 @@ Unix SMB/Netbios implementation. Version 1.9. NBT netbios routines and daemon - version 2 - Copyright (C) Andrew Tridgell 1994-1995 + Copyright (C) Andrew Tridgell 1994-1997 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ extern int num_response_packets; BOOL CanRecurse = True; extern pstring scope; -extern struct in_addr ipgrp; +extern struct in_addr wins_ip; static uint16 name_trn_id=0; @@ -91,9 +91,9 @@ static void update_name_trn_id(void) initiate a netbios packet ****************************************************************************/ void initiate_netbios_packet(uint16 *id, - int fd,int quest_type,char *name,int name_type, - int nb_flags,BOOL bcast,BOOL recurse, - struct in_addr to_ip) + int fd,int quest_type,char *name,int name_type, + int nb_flags,BOOL bcast,BOOL recurse, + struct in_addr to_ip) { struct packet_struct p; struct nmb_packet *nmb = &p.packet.nmb; @@ -141,7 +141,7 @@ void initiate_netbios_packet(uint16 *id, make_nmb_name(&nmb->question.question_name,name,name_type,scope); - nmb->question.question_type = 0x20; + nmb->question.question_type = quest_type == NMB_STATUS ? 0x21 : 0x20; nmb->question.question_class = 0x1; if (quest_type == NMB_REG || @@ -323,8 +323,10 @@ static BOOL listening(struct packet_struct *p,struct nmb_name *n) struct subnet_record *d; struct name_record *n1; + /* We explicitly don't search WINS here - this will be done + in find_name_search if it was a packet from a non-local subnet. */ d = find_subnet(p->ip); - + n1 = find_name_search(&d,n,FIND_LOCAL|FIND_WINS|FIND_SELF,p->ip); return (n1 != NULL); @@ -343,13 +345,21 @@ static void process_dgram(struct packet_struct *p) /* if we aren't listening to the destination name then ignore the packet */ if (!listening(p,&dgram->dest_name)) + { + DEBUG(5,("process_dgram: ignoring dgram packet sent to name %s(%x) from %s\n", + dgram->dest_name.name, dgram->dest_name.name_type, inet_ntoa(p->ip))); return; - + } if (dgram->header.msg_type != 0x10 && dgram->header.msg_type != 0x11 && - dgram->header.msg_type != 0x12) { + dgram->header.msg_type != 0x12) + { /* don't process error packets etc yet */ + DEBUG(5,("process_dgram: ignoring dgram packet sent to name %s(%d) from %s as it is \ + an error packet of type %x\n", + dgram->dest_name.name, dgram->dest_name.name_type, + inet_ntoa(p->ip), dgram->header.msg_type)); return; } @@ -362,7 +372,7 @@ static void process_dgram(struct packet_struct *p) len = SVAL(buf,smb_vwv11); buf2 = smb_base(buf) + SVAL(buf,smb_vwv12); - DEBUG(4,("datagram from %s to %s for %s of type %d len=%d\n", + DEBUG(4,("process_dgram: datagram from %s to %s for %s of type %d len=%d\n", namestr(&dgram->source_name),namestr(&dgram->dest_name), smb_buf(buf),CVAL(buf2,0),len)); @@ -512,7 +522,10 @@ void listen_for_packets(BOOL run_election) timeout.tv_sec = (run_election||num_response_packets) ? 1:NMBD_SELECT_LOOP; timeout.tv_usec = 0; + /* We can only take term signals when we are in the select. */ + BlockSignals(False, SIGTERM); selrtn = sys_select(&fds,&timeout); + BlockSignals(True, SIGTERM); if (FD_ISSET(ClientNMB,&fds)) { @@ -559,13 +572,12 @@ void listen_for_packets(BOOL run_election) Note that this currently sends all answers to port 138. thats the wrong things to do! I should send to the requestors port. XXX **************************************************************************/ -BOOL send_mailslot_reply(char *mailslot,int fd,char *buf,int len,char *srcname, +BOOL send_mailslot_reply(BOOL unique, char *mailslot,int fd,char *buf,int len,char *srcname, char *dstname,int src_type,int dest_type, struct in_addr dest_ip,struct in_addr src_ip) { struct packet_struct p; struct dgram_packet *dgram = &p.packet.dgram; - struct in_addr wins_ip = ipgrp; char *ptr,*p2; char tmp[4]; @@ -576,7 +588,8 @@ BOOL send_mailslot_reply(char *mailslot,int fd,char *buf,int len,char *srcname, update_name_trn_id(); - dgram->header.msg_type = 0x11; /* DIRECT GROUP DATAGRAM */ + /* DIRECT GROUP or UNIQUE datagram */ + dgram->header.msg_type = unique ? 0x10 : 0x11; dgram->header.flags.node_type = M_NODE; dgram->header.flags.first = True; dgram->header.flags.more = False;