1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-23 20:59:10 +03:00

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.
(This used to be commit 32f66f4ea6)
This commit is contained in:
Andrew Tridgell
2000-01-03 06:30:50 +00:00
parent 8d1d27b43c
commit 632b4f806e
6 changed files with 326 additions and 330 deletions

View File

@ -111,24 +111,28 @@ void clear_unexpected(time_t t)
static struct packet_struct *matched_packet;
static int match_trn_id;
static int match_id;
static enum packet_type match_type;
static char *match_name;
/****************************************************************************
tdb traversal fn to find a matching 137 packet
**************************************************************************/
static int traverse_match_137(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf)
static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf)
{
struct unexpected_key key;
struct packet_struct *p;
memcpy(&key, kbuf.dptr, sizeof(key));
if (key.packet_type != NMB_PACKET) return 0;
if (key.packet_type != match_type) return 0;
p = parse_packet(dbuf.dptr, dbuf.dsize, NMB_PACKET);
p = parse_packet(dbuf.dptr, dbuf.dsize, match_type);
if (p->packet_type == NMB_PACKET &&
p->packet.nmb.header.name_trn_id == match_trn_id) {
if ((match_type == NMB_PACKET &&
p->packet.nmb.header.name_trn_id == match_id) ||
(match_type == DGRAM_PACKET &&
match_mailslot_name(p, match_name))) {
matched_packet = p;
return -1;
}
@ -142,7 +146,8 @@ static int traverse_match_137(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf)
/****************************************************************************
check for a particular packet in the unexpected packet queue
**************************************************************************/
struct packet_struct *receive_unexpected_137(int trn_id)
struct packet_struct *receive_unexpected(enum packet_type packet_type, int id,
char *mailslot_name)
{
TDB_CONTEXT *tdb2;
@ -150,9 +155,11 @@ struct packet_struct *receive_unexpected_137(int trn_id)
if (!tdb2) return NULL;
matched_packet = NULL;
match_trn_id = trn_id;
match_id = id;
match_type = packet_type;
match_name = mailslot_name;
tdb_traverse(tdb2, traverse_match_137);
tdb_traverse(tdb2, traverse_match);
tdb_close(tdb2);