summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1997-09-01 18:34:00 +0000
committerLuke Leighton <lkcl@samba.org>1997-09-01 18:34:00 +0000
commit918cc5f033360508da21d61ca1358ba8c7f0700d (patch)
tree17531769451fa37231ac9d001c993011006a00f6
parent3fc24dc9ed330d73aedbe2017cdfa5b5657e69cc (diff)
downloadsamba-918cc5f033360508da21d61ca1358ba8c7f0700d.tar.gz
samba-918cc5f033360508da21d61ca1358ba8c7f0700d.tar.xz
samba-918cc5f033360508da21d61ca1358ba8c7f0700d.zip
use of recursion_available and recursion_desired flag in netbios responses.
(This used to be commit 8235db6b4fbeced750c4c30edc84a61a35b39278)
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/namepacket.c15
-rw-r--r--source3/nameservreply.c61
3 files changed, 53 insertions, 29 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 3a012d379ae..5c770d7fcc1 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -474,7 +474,9 @@ void initiate_netbios_packet(uint16 *id,
int nb_flags,BOOL bcast,BOOL recurse,
struct in_addr to_ip);
void reply_netbios_packet(struct packet_struct *p1,int trn_id,
- int rcode, int rcv_code, int opcode, BOOL recurse,
+ int rcode, int rcv_code, int opcode,
+ BOOL recursion_available,
+ BOOL recursion_desired,
struct nmb_name *rr_name,int rr_type,int rr_class,int ttl,
char *data,int len);
void queue_packet(struct packet_struct *packet);
@@ -627,6 +629,8 @@ int get_printqueue(int snum,int cnum,print_queue_struct **queue,
print_status_struct *status);
void del_printqueue(int cnum,int snum,int jobid);
void status_printjob(int cnum,int snum,int jobid,int status);
+int printjob_encode(int snum, int job);
+void printjob_decode(int jobid, int *snum, int *job);
/*The following definitions come from quotas.c */
diff --git a/source3/namepacket.c b/source3/namepacket.c
index 086e32d9081..d60ef9f6ae2 100644
--- a/source3/namepacket.c
+++ b/source3/namepacket.c
@@ -183,10 +183,12 @@ void initiate_netbios_packet(uint16 *id,
/****************************************************************************
- reply to a netbios name packet
+ reply to a netbios name packet. see rfc1002.txt
****************************************************************************/
void reply_netbios_packet(struct packet_struct *p1,int trn_id,
- int rcode, int rcv_code, int opcode, BOOL recurse,
+ int rcode, int rcv_code, int opcode,
+ BOOL recursion_available,
+ BOOL recursion_desired,
struct nmb_name *rr_name,int rr_type,int rr_class,int ttl,
char *data,int len)
{
@@ -197,6 +199,11 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
p = *p1;
+ if (recursion_available && lp_wins_server())
+ {
+ DEBUG(0,("reply_netbios_packet: r_a not to be used when not a WINS server\n"));
+ }
+
switch (rcv_code)
{
case NMB_STATUS:
@@ -240,8 +247,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 = (lp_wins_support() ? True : False );
- nmb->header.nm_flags.recursion_desired = (lp_wins_support() ? recurse : False );
+ nmb->header.nm_flags.recursion_available = recursion_available;
+ nmb->header.nm_flags.recursion_desired = recursion_desired;
nmb->header.nm_flags.trunc = False;
nmb->header.nm_flags.authoritative = True;
diff --git a/source3/nameservreply.c b/source3/nameservreply.c
index e5976bb7429..f3048dd1b5c 100644
--- a/source3/nameservreply.c
+++ b/source3/nameservreply.c
@@ -42,7 +42,8 @@ extern struct in_addr wins_ip;
send a registration / release response: pos/neg
**************************************************************************/
static void send_name_response(int fd, struct in_addr from_ip,
- int name_trn_id, int opcode, BOOL success, BOOL recurse,
+ int name_trn_id, int opcode, BOOL success,
+ BOOL recursion_available, BOOL recursion_desired,
struct nmb_name *reply_name, int nb_flags, int ttl,
struct in_addr ip)
{
@@ -56,7 +57,7 @@ static void send_name_response(int fd, struct in_addr from_ip,
/* NEGATIVE RESPONSE */
rcode = 6;
}
- else if (opcode == NMB_REG && recurse == False)
+ else if (opcode == NMB_REG && !recursion_available)
{
/* END-NODE CHALLENGE REGISTRATION RESPONSE */
rcode = 0;
@@ -73,7 +74,8 @@ static void send_name_response(int fd, struct in_addr from_ip,
p.packet_type = NMB_PACKET;
reply_netbios_packet(&p,name_trn_id,
- rcode,opcode,opcode,recurse,
+ rcode,opcode,opcode,
+ recursion_available, recursion_desired,
reply_name, 0x20, 0x1,
ttl,
rdata, 6);
@@ -93,8 +95,10 @@ void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
nb_flags,ttl,REGISTER,register_ip,False,True);
/* reply yes or no to the host that requested the name */
+ /* see rfc1002.txt - 4.2.10 and 4.2.11 */
send_name_response(fd,from_ip, response_id, NMB_REG,
- new_owner, False,
+ new_owner,
+ True, False,
name, nb_flags, ttl, reply_to_ip);
}
@@ -160,7 +164,7 @@ subnet %s\n", namestr(&nmb->question.question_name), n->name.name_type,
/* 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, nmb->header.nm_flags.recursion_desired,
+ success, False, False,
&nmb->question.question_name, nb_flags, 0, ip);
}
@@ -179,6 +183,7 @@ void reply_name_reg(struct packet_struct *p)
int qname_type = question->name_type;
BOOL bcast = nmb->header.nm_flags.bcast;
+ BOOL release_is_to_wins_server = nmb->header.nm_flags.recursion_desired;
int ttl = GET_TTL(nmb->additional->ttl);
int nb_flags = nmb->additional->rdata[0];
@@ -301,7 +306,8 @@ void reply_name_reg(struct packet_struct *p)
/* send WAIT ACKNOWLEDGEMENT see rfc1002.txt 4.2.16 */
reply_netbios_packet(p,nmb->header.name_trn_id,
- 0,NMB_WAIT_ACK,NMB_WAIT_ACK,False,
+ 0,NMB_WAIT_ACK,NMB_WAIT_ACK,
+ False,False,
reply_name, 0x0a, 0x01,
15*1000, /* 15 seconds long enough to wait? */
rdata, 2);
@@ -311,7 +317,8 @@ void reply_name_reg(struct packet_struct *p)
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);
+ True, False,
+ n->ip_flgs[0].ip, p->ip);
}
else
{
@@ -320,7 +327,8 @@ void reply_name_reg(struct packet_struct *p)
*/
send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REG,
- success, nmb->header.nm_flags.recursion_desired,
+ success,
+ release_is_to_wins_server, False,
reply_name, nb_flags, ttl, ip);
}
}
@@ -471,7 +479,7 @@ void reply_name_status(struct packet_struct *p)
/* Send a POSITIVE NAME STATUS RESPONSE */
reply_netbios_packet(p,nmb->header.name_trn_id,
- 0,NMB_STATUS,0,True,
+ 0,NMB_STATUS,0,False, False,
&nmb->question.question_name,
0x21, 0x01,
0, rdata,PTR_DIFF(buf,rdata));
@@ -507,7 +515,10 @@ void reply_name_query(struct packet_struct *p)
struct nmb_packet *nmb = &p->packet.nmb;
struct nmb_name *question = &nmb->question.question_name;
int name_type = question->name_type;
+
BOOL bcast = nmb->header.nm_flags.bcast;
+ BOOL query_is_to_wins_server = nmb->header.nm_flags.recursion_desired;
+
int ttl=0;
int rcode = 0;
int nb_flags = 0;
@@ -520,22 +531,26 @@ void reply_name_query(struct packet_struct *p)
/* directed queries are for WINS server: broadcasts are local SELF queries.
the exception is Domain Master names. */
- int search = bcast ? FIND_LOCAL | FIND_WINS: FIND_WINS;
-
- if (search & FIND_LOCAL)
+ if (query_is_to_wins_server)
{
- if (!(d = find_req_subnet(p->ip, bcast)))
+ /* queries to the WINS server involve the WINS server subnet */
+ if (!(d = wins_subnet))
{
- DEBUG(3,("name query: bcast %s not known\n",
+ DEBUG(3,("name query: wins search %s not known\n",
inet_ntoa(p->ip)));
success = False;
}
}
else
{
- if (!(d = wins_subnet))
+ /* queries to the WINS client involve, unfortunately, the WINS subnet
+ because it contains WINS client (SELF) entries, as _well_ as WINS
+ server entries. not good.
+ */
+
+ if (!(d = find_subnet(*iface_bcast(p->ip))))
{
- DEBUG(3,("name query: wins search %s not known\n",
+ DEBUG(3,("name query: interface for %s not known\n",
inet_ntoa(p->ip)));
success = False;
}
@@ -544,12 +559,6 @@ void reply_name_query(struct packet_struct *p)
DEBUG(3,("Name query from %s for name %s<0x%x>\n",
inet_ntoa(p->ip), question->name, question->name_type));
- if (search == 0)
- {
- /* eh? no criterion for searching database. help! */
- success = False;
- }
-
if (!bcast && (name_type == 0x1d) && lp_wins_support())
{
/* see WINS manager HELP - 'How WINS Handles Special Names' */
@@ -560,7 +569,7 @@ void reply_name_query(struct packet_struct *p)
if (success)
{
/* look up the name in the cache */
- n = find_name_search(&d, question, search, p->ip);
+ n = find_name_search(&d, question, FIND_LOCAL, p->ip);
/* it is a name that already failed DNS lookup or it's expired */
if (n && (n->source == DNSFAIL ||
@@ -644,8 +653,12 @@ void reply_name_query(struct packet_struct *p)
putip(&rdata[2],(char *)&retip);
}
+ /* see rfc1002.txt 4.2.13 */
+
reply_netbios_packet(p,nmb->header.name_trn_id,
- rcode,NMB_QUERY,0,True,
+ rcode,NMB_QUERY,0,
+ query_is_to_wins_server, /* recursion_available flag */
+ True, /* recursion_desired_flag */
&nmb->question.question_name,
0x20, 0x01,
ttl,