summaryrefslogtreecommitdiffstats
path: root/source/libsmb/nmblib.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-01-03 06:30:50 +0000
committerAndrew Tridgell <tridge@samba.org>2000-01-03 06:30:50 +0000
commit32f66f4ea63038cb4b3785bdf1762abdde076f5d (patch)
tree0c4e995fcc87612b3f3f6cbaaf82b66f48c7db54 /source/libsmb/nmblib.c
parent8767334d8a44db5cb8abf084d185dae6e32db062 (diff)
downloadsamba-32f66f4ea63038cb4b3785bdf1762abdde076f5d.tar.gz
samba-32f66f4ea63038cb4b3785bdf1762abdde076f5d.tar.xz
samba-32f66f4ea63038cb4b3785bdf1762abdde076f5d.zip
added suppport for unexpected udp/138 packets
I also fixed up the lookup_pdc_name() code so that it now works, even with a NT server that insists on replying to udp/138. The method I used to match packets was to use the mailslot string as a datagram ID. The true dgm_id doesn't work as NT doesn't set it correctly. uggh. PS: Jeremy, I had to change your code quite a bit, are you sure this worked with a Samba PDC?? The code looked broken, it got the offsets wrong in the SMB portion of the packet and filled in the IP incorrectly.
Diffstat (limited to 'source/libsmb/nmblib.c')
-rw-r--r--source/libsmb/nmblib.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/source/libsmb/nmblib.c b/source/libsmb/nmblib.c
index 13f7e111239..9ddfd3a6c66 100644
--- a/source/libsmb/nmblib.c
+++ b/source/libsmb/nmblib.c
@@ -979,7 +979,7 @@ struct packet_struct *receive_packet(int fd,enum packet_type type,int t)
queue. The packet must be a reply packet and have the specified trn_id
The timeout is in milliseconds
***************************************************************************/
-struct packet_struct *receive_reply_packet(int fd, int t, int trn_id)
+struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id)
{
struct packet_struct *p;
@@ -992,7 +992,48 @@ struct packet_struct *receive_reply_packet(int fd, int t, int trn_id)
if (p) free_packet(p);
/* try the unexpected packet queue */
- return receive_unexpected_137(trn_id);
+ return receive_unexpected(NMB_PACKET, trn_id, NULL);
+}
+
+/****************************************************************************
+ receive a UDP/138 packet either via UDP or from the unexpected packet
+ queue. The packet must be a reply packet and have the specified dgm_id
+ The timeout is in milliseconds
+ ***************************************************************************/
+struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name)
+{
+ struct packet_struct *p;
+
+ p = receive_packet(fd, DGRAM_PACKET, t);
+
+ if (p && match_mailslot_name(p, mailslot_name)) {
+ return p;
+ }
+ if (p) free_packet(p);
+
+ /* try the unexpected packet queue */
+ return receive_unexpected(DGRAM_PACKET, 0, mailslot_name);
+}
+
+
+/****************************************************************************
+ see if a datagram has the right mailslot name
+***************************************************************************/
+BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name)
+{
+ struct dgram_packet *dgram = &p->packet.dgram;
+ char *buf;
+
+ buf = &dgram->data[0];
+ buf -= 4;
+
+ buf = smb_buf(buf);
+
+ if (memcmp(buf, mailslot_name, strlen(mailslot_name)+1) == 0) {
+ return True;
+ }
+
+ return False;
}