Copying commit from HEAD.
authorChristopher R. Hertel <crh@samba.org>
Mon, 22 Apr 2002 03:09:23 +0000 (03:09 +0000)
committerChristopher R. Hertel <crh@samba.org>
Mon, 22 Apr 2002 03:09:23 +0000 (03:09 +0000)
My seven-year-old daughter calls me 'Captain Pedantic'.  I don't know which
is freakier... the name or the fact that a seven-year-old knows what it
means.

Small change to correct the value we place in the DGM_LENGTH field of
NBT Datagram messages.  We have been counting the full datagram, but it's
fairly clear in the RFCs that we should only count the source name,
destination name, and payload.  We've been overcharging by 14 bytes
(the size of the NBT DGM header).

This fix brings us in line with what Windows does, and what the RFCs
say should be done.  I'm a little surprised that this didn't cause any
bugs or error messages.  I guess no one actually checks this field.

source/libsmb/nmblib.c

index c78946fa09c991cb070b348ba285972326f0dc84..9a37b4252a449303a7c998cc1cb6b3443e2896a4 100644 (file)
@@ -766,6 +766,14 @@ static BOOL send_udp(int fd,char *buf,int len,struct in_addr ip,int port)
   XXXX This currently doesn't handle packets too big for one
   datagram. It should split them and use the packet_offset, more and
   first flags to handle the fragmentation. Yuck.
+
+    [...but it isn't clear that we would ever need to send a
+    a fragmented NBT Datagram.  The IP layer does its own
+    fragmentation to ensure that messages can fit into the path
+    MTU.  It *is* important to be able to receive and rebuild
+    fragmented NBT datagrams, just in case someone out there
+    really has implemented this 'feature'.  crh -)------ ]
+
   ******************************************************************/
 static int build_dgram(char *buf,struct packet_struct *p)
 {
@@ -795,8 +803,11 @@ static int build_dgram(char *buf,struct packet_struct *p)
   memcpy(ubuf+offset,dgram->data,dgram->datasize);
   offset += dgram->datasize;
 
-  /* automatically set the dgm_length */
-  dgram->header.dgm_length = offset;
+  /* automatically set the dgm_length
+   * NOTE: RFC1002 says the dgm_length does *not*
+   *       include the fourteen-byte header. crh
+   */
+  dgram->header.dgm_length = (offset - 14);
   RSSVAL(ubuf,10,dgram->header.dgm_length); 
 
   return(offset);