summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-03-25 01:27:27 +0000
committerJeremy Allison <jra@samba.org>1998-03-25 01:27:27 +0000
commita1db330263e15a9c5db9fe38a7278bd1408ae79d (patch)
treebdb8a4910772d71b476687e8ef5f1e27fef203d9 /source3
parentff71b96f4265e16f128b3aab61993daca2309211 (diff)
downloadsamba-a1db330263e15a9c5db9fe38a7278bd1408ae79d.tar.gz
samba-a1db330263e15a9c5db9fe38a7278bd1408ae79d.tar.bz2
samba-a1db330263e15a9c5db9fe38a7278bd1408ae79d.zip
RFC1002 says we must put compressed name pointers in the following
outgoing packets : NMB_NAME_REG_OPCODE, NMB_NAME_RELEASE_OPCODE, NMB_NAME_REFRESH_OPCODE, NMB_NAME_MULTIHOMED_REG_OPCODE. A WINS server written by Shadow Software was rejecting our packets as we weren't using name pointers in those requests (talk about picky :-). Jeremy. (This used to be commit a31aa09173db30c39f59d4ee5761075b0e00dd71)
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/nmblib.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index 1400b88434..f2aee12615 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -363,6 +363,27 @@ static int put_res_rec(char *buf,int offset,struct res_rec *recs,int count)
}
/*******************************************************************
+ put a compressed name pointer record into a packet
+ ******************************************************************/
+static int put_compressed_name_ptr(unsigned char *buf,int offset,struct res_rec *rec,int ptr_offset)
+{
+ int ret=0;
+ buf[offset] = (0xC0 | ((ptr_offset >> 8) & 0xFF));
+ buf[offset+1] = (ptr_offset & 0xFF);
+ offset += 2;
+ ret += 2;
+ RSSVAL(buf,offset,rec->rr_type);
+ RSSVAL(buf,offset+2,rec->rr_class);
+ RSIVAL(buf,offset+4,rec->ttl);
+ RSSVAL(buf,offset+8,rec->rdlength);
+ memcpy(buf+offset+10,rec->rdata,rec->rdlength);
+ offset += 10+rec->rdlength;
+ ret += 10+rec->rdlength;
+
+ return(ret);
+}
+
+/*******************************************************************
parse a dgram packet. Return False if the packet can't be parsed
or is invalid for some reason, True otherwise
@@ -808,10 +829,27 @@ static int build_nmb(char *buf,struct packet_struct *p)
offset += put_res_rec((char *)ubuf,offset,nmb->nsrecs,
nmb->header.nscount);
- if (nmb->header.arcount)
+ /*
+ * The spec says we must put compressed name pointers
+ * in the following outgoing packets :
+ * NAME_REGISTRATION_REQUEST, NAME_REFRESH_REQUEST,
+ * NAME_RELEASE_REQUEST.
+ */
+
+ if((nmb->header.response == False) &&
+ ((nmb->header.opcode == NMB_NAME_REG_OPCODE) ||
+ (nmb->header.opcode == NMB_NAME_RELEASE_OPCODE) ||
+ (nmb->header.opcode == NMB_NAME_REFRESH_OPCODE_8) ||
+ (nmb->header.opcode == NMB_NAME_REFRESH_OPCODE_9) ||
+ (nmb->header.opcode == NMB_NAME_MULTIHOMED_REG_OPCODE)) &&
+ (nmb->header.arcount == 1)) {
+
+ offset += put_compressed_name_ptr(ubuf,offset,nmb->additional,12);
+
+ } else if (nmb->header.arcount) {
offset += put_res_rec((char *)ubuf,offset,nmb->additional,
nmb->header.arcount);
-
+ }
return(offset);
}