mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
nameannounce.c: Made sure recurse flag set correctly.
namedbname.c: Made sure wins.dat updated when list changes.
Changed to returning 255.255.255.255 when 1e name
queried.
namepacket.c: Made sure recurse flags set correctly.
nameserv.c: Made sure recurse flags set correctly.
nameservreply.c: Made send_name_response() static, Made sure recurse flags set correctly.
Changed to returning 255.255.255.255 when 1e name
queried.
proto.h: Removed send_name_response().
Jeremy jallison@whistle.com
(This used to be commit 4e9fd24f65
)
This commit is contained in:
parent
7be4b90f26
commit
094f7ce427
@ -496,10 +496,6 @@ void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
|
||||
struct nmb_name *name,
|
||||
int nb_flags, int ttl, struct in_addr register_ip,
|
||||
BOOL new_owner, struct in_addr reply_to_ip);
|
||||
void send_name_response(int fd, struct in_addr from_ip,
|
||||
int name_trn_id, int opcode, BOOL success, BOOL recurse,
|
||||
struct nmb_name *reply_name, int nb_flags, int ttl,
|
||||
struct in_addr ip);
|
||||
void reply_name_release(struct packet_struct *p);
|
||||
void reply_name_reg(struct packet_struct *p);
|
||||
void reply_name_status(struct packet_struct *p);
|
||||
|
@ -234,7 +234,7 @@ void announce_server(struct subnet_record *d, struct work_record *work,
|
||||
NAME_QUERY_ANNOUNCE_HOST,
|
||||
work->work_group,0x1b,0,ttl*1000,
|
||||
server_type,name,comment,
|
||||
False, False, ipzero, d->bcast_ip);
|
||||
False, True, ipzero, d->bcast_ip);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -472,7 +472,7 @@ workgroup %s\n", am_master, work->work_group));
|
||||
NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
|
||||
name, type, 0,0,0,
|
||||
work->work_group,NULL,
|
||||
False, False, ipzero, ipzero);
|
||||
False, True, ipzero, ipzero);
|
||||
}
|
||||
else if(lp_wins_support())
|
||||
{
|
||||
|
@ -36,6 +36,7 @@ extern int DEBUGLEVEL;
|
||||
extern pstring scope;
|
||||
extern struct in_addr ipzero;
|
||||
extern struct in_addr wins_ip;
|
||||
extern BOOL updatedlists;
|
||||
|
||||
extern struct subnet_record *subnetlist;
|
||||
|
||||
@ -111,6 +112,9 @@ static void add_name(struct subnet_record *d, struct name_record *n)
|
||||
n2->next = n;
|
||||
n->next = NULL;
|
||||
n->prev = n2;
|
||||
|
||||
if(d == wins_subnet)
|
||||
updatedlists = True;
|
||||
}
|
||||
|
||||
|
||||
@ -133,6 +137,9 @@ void remove_name(struct subnet_record *d, struct name_record *n)
|
||||
if (nlist->prev) nlist->prev->next = nlist->next;
|
||||
free(nlist);
|
||||
}
|
||||
|
||||
if(d == wins_subnet)
|
||||
updatedlists = True;
|
||||
}
|
||||
|
||||
|
||||
@ -460,12 +467,6 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
|
||||
}
|
||||
}
|
||||
|
||||
if(type == 0x1e)
|
||||
{
|
||||
/* Add all 1e names as address 255.255.255.255 */
|
||||
ip = *interpret_addr2("255.255.255.255");
|
||||
}
|
||||
|
||||
n = (struct name_record *)malloc(sizeof(*n));
|
||||
if (!n) return(NULL);
|
||||
|
||||
|
@ -194,7 +194,6 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
|
||||
struct nmb_packet *nmb = &p.packet.nmb;
|
||||
struct res_rec answers;
|
||||
char *packet_type = "unknown";
|
||||
BOOL recursion_desired = False;
|
||||
|
||||
p = *p1;
|
||||
|
||||
@ -203,31 +202,26 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
|
||||
case NMB_STATUS:
|
||||
{
|
||||
packet_type = "nmb_status";
|
||||
recursion_desired = True;
|
||||
break;
|
||||
}
|
||||
case NMB_QUERY:
|
||||
{
|
||||
packet_type = "nmb_query";
|
||||
recursion_desired = True;
|
||||
break;
|
||||
}
|
||||
case NMB_REG:
|
||||
{
|
||||
packet_type = "nmb_reg";
|
||||
recursion_desired = True;
|
||||
break;
|
||||
}
|
||||
case NMB_REL:
|
||||
{
|
||||
packet_type = "nmb_rel";
|
||||
recursion_desired = False;
|
||||
break;
|
||||
}
|
||||
case NMB_WAIT_ACK:
|
||||
{
|
||||
packet_type = "nmb_wack";
|
||||
recursion_desired = False;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -246,8 +240,8 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
|
||||
nmb->header.opcode = opcode;
|
||||
nmb->header.response = True;
|
||||
nmb->header.nm_flags.bcast = False;
|
||||
nmb->header.nm_flags.recursion_available = recurse;
|
||||
nmb->header.nm_flags.recursion_desired = recursion_desired;
|
||||
nmb->header.nm_flags.recursion_available = (lp_wins_support() ? True : False );
|
||||
nmb->header.nm_flags.recursion_desired = (lp_wins_support() ? recurse : False );
|
||||
nmb->header.nm_flags.trunc = False;
|
||||
nmb->header.nm_flags.authoritative = True;
|
||||
|
||||
|
@ -115,7 +115,7 @@ void remove_name_entry(struct subnet_record *d, char *name,int type, BOOL direct
|
||||
/* local interface: release them on the network */
|
||||
queue_netbios_packet(d,ClientNMB,NMB_REL,NAME_RELEASE,
|
||||
name, type, 0, 0,0,NULL,NULL,
|
||||
True, True, d->bcast_ip, d->bcast_ip);
|
||||
True, False, d->bcast_ip, d->bcast_ip);
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags,
|
||||
queue_netbios_packet(d,ClientNMB,
|
||||
re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER,
|
||||
name, type, nb_flags, GET_TTL(0),0,NULL,NULL,
|
||||
True, True, d->bcast_ip, ipzero);
|
||||
True, False, d->bcast_ip, ipzero);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -273,7 +273,7 @@ on workgroup %s\n", myworkgroup));
|
||||
queue_netbios_pkt_wins(ClientNMB,NMB_QUERY,NAME_QUERY_DOMAIN,
|
||||
myworkgroup, 0x1b,
|
||||
0, 0,0,NULL,NULL,
|
||||
False, False, ipzero, ipzero);
|
||||
False, True, ipzero, ipzero);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -38,30 +38,10 @@ extern int DEBUGLEVEL;
|
||||
|
||||
extern struct in_addr wins_ip;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
add a netbios entry. respond to the (possibly new) owner.
|
||||
**************************************************************************/
|
||||
void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
|
||||
uint16 response_id,
|
||||
struct nmb_name *name,
|
||||
int nb_flags, int ttl, struct in_addr register_ip,
|
||||
BOOL new_owner, struct in_addr reply_to_ip)
|
||||
{
|
||||
/* register the old or the new owners' ip */
|
||||
add_netbios_entry(d,name->name,name->name_type,
|
||||
nb_flags,ttl,REGISTER,register_ip,False,True);
|
||||
|
||||
/* reply yes or no to the host that requested the name */
|
||||
send_name_response(fd,from_ip, response_id, NMB_REG,
|
||||
new_owner, True,
|
||||
name, nb_flags, ttl, reply_to_ip);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
send a registration / release response: pos/neg
|
||||
**************************************************************************/
|
||||
void send_name_response(int fd, struct in_addr from_ip,
|
||||
static void send_name_response(int fd, struct in_addr from_ip,
|
||||
int name_trn_id, int opcode, BOOL success, BOOL recurse,
|
||||
struct nmb_name *reply_name, int nb_flags, int ttl,
|
||||
struct in_addr ip)
|
||||
@ -99,6 +79,25 @@ void send_name_response(int fd, struct in_addr from_ip,
|
||||
rdata, 6);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
add a netbios entry. respond to the (possibly new) owner.
|
||||
**************************************************************************/
|
||||
void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
|
||||
uint16 response_id,
|
||||
struct nmb_name *name,
|
||||
int nb_flags, int ttl, struct in_addr register_ip,
|
||||
BOOL new_owner, struct in_addr reply_to_ip)
|
||||
{
|
||||
/* register the old or the new owners' ip */
|
||||
add_netbios_entry(d,name->name,name->name_type,
|
||||
nb_flags,ttl,REGISTER,register_ip,False,True);
|
||||
|
||||
/* reply yes or no to the host that requested the name */
|
||||
send_name_response(fd,from_ip, response_id, NMB_REG,
|
||||
new_owner, False,
|
||||
name, nb_flags, ttl, reply_to_ip);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
reply to a name release
|
||||
@ -150,7 +149,7 @@ void reply_name_release(struct packet_struct *p)
|
||||
|
||||
/* Send a NAME RELEASE RESPONSE (pos/neg) see rfc1002.txt 4.2.10-11 */
|
||||
send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REL,
|
||||
success, False,
|
||||
success, nmb->header.nm_flags.recursion_desired,
|
||||
&nmb->question.question_name, nb_flags, 0, ip);
|
||||
}
|
||||
|
||||
@ -193,7 +192,7 @@ void reply_name_reg(struct packet_struct *p)
|
||||
{
|
||||
/* apparently we should return 255.255.255.255 for group queries
|
||||
(email from MS) */
|
||||
ip = wins_ip;
|
||||
ip = *interpret_addr2("255.255.255.255");
|
||||
}
|
||||
|
||||
if (!(d = find_req_subnet(p->ip, bcast)))
|
||||
@ -298,10 +297,10 @@ void reply_name_reg(struct packet_struct *p)
|
||||
|
||||
/* initiate some enquiries to the current owner. */
|
||||
queue_netbios_packet(d,ClientNMB,NMB_QUERY,
|
||||
NAME_REGISTER_CHALLENGE,
|
||||
reply_name->name,reply_name->name_type,
|
||||
nb_flags,0,0,NULL,NULL,
|
||||
False, False, n->ip_flgs[0].ip, p->ip);
|
||||
NAME_REGISTER_CHALLENGE,
|
||||
reply_name->name,reply_name->name_type,
|
||||
nb_flags,0,0,NULL,NULL,
|
||||
False, False, n->ip_flgs[0].ip, p->ip);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -310,8 +309,8 @@ void reply_name_reg(struct packet_struct *p)
|
||||
*/
|
||||
|
||||
send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REG,
|
||||
success, True,
|
||||
reply_name, nb_flags, ttl, ip);
|
||||
success, nmb->header.nm_flags.recursion_desired,
|
||||
reply_name, nb_flags, ttl, ip);
|
||||
}
|
||||
}
|
||||
|
||||
@ -540,7 +539,7 @@ void reply_name_query(struct packet_struct *p)
|
||||
success = False;
|
||||
}
|
||||
|
||||
if (!bcast && name_type == 0x1d)
|
||||
if (!bcast && (name_type == 0x1d) && lp_wins_support())
|
||||
{
|
||||
/* see WINS manager HELP - 'How WINS Handles Special Names' */
|
||||
/* a WINS query (unicasted) for a 0x1d name must always return False */
|
||||
@ -585,8 +584,8 @@ void reply_name_query(struct packet_struct *p)
|
||||
{
|
||||
/* never reply with a negative response to broadcast queries */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* name is directed query, or it's self, or it's a Domain Master type
|
||||
name, or we're replying on behalf of a caller because they are on a
|
||||
@ -608,6 +607,13 @@ void reply_name_query(struct packet_struct *p)
|
||||
/* if the IP is 0 then substitute my IP */
|
||||
if (zero_ip(retip)) retip = *iface_ip(p->ip);
|
||||
|
||||
/* SPECIAL CASE... If we are a WINS server and the request is explicitly
|
||||
*to* the WINS server and the name type is WORKGROUP<0x1e> we should
|
||||
respond with the local broadcast address 255.255.255.255.
|
||||
*/
|
||||
if(!bcast && (name_type == 0x1e) && lp_wins_support())
|
||||
retip = *interpret_addr2("255.255.255.255");
|
||||
|
||||
if (success)
|
||||
{
|
||||
rcode = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user