4 * Copyright (C) Andrew Tridgell 1995-1999
6 * This software may be distributed either under the terms of the
7 * BSD-style license that accompanies tcpdump or the GNU GPL version 2
15 #include <sys/cdefs.h>
18 static const char rcsid
[] _U_
=
19 "@(#) Header: /tcpdump/master/tcpdump/print-smb.c,v 1.41.2.4 2007/07/14 22:29:05 guy Exp";
21 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
25 #include <tcpdump-stdinc.h>
30 #include "interface.h"
34 static int request
= 0;
35 static int unicodestr
= 0;
37 const u_char
*startbuf
= NULL
;
44 void (*fn
)(const u_char
*, const u_char
*, const u_char
*, const u_char
*);
47 struct smbdescriptint
{
52 void (*fn
)(const u_char
*, const u_char
*, int, int);
60 struct smbdescript descript
;
68 struct smbdescriptint descript
;
71 #define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL }
73 #define FLG_CHAIN (1 << 0)
75 static struct smbfns
*
76 smbfind(int id
, struct smbfns
*list
)
80 for (sindex
= 0; list
[sindex
].name
; sindex
++)
81 if (list
[sindex
].id
== id
)
82 return(&list
[sindex
]);
87 static struct smbfnsint
*
88 smbfindint(int id
, struct smbfnsint
*list
)
92 for (sindex
= 0; list
[sindex
].name
; sindex
++)
93 if (list
[sindex
].id
== id
)
94 return(&list
[sindex
]);
100 trans2_findfirst(const u_char
*param
, const u_char
*data
, int pcnt
, int dcnt
)
105 fmt
= "Attribute=[A]\nSearchCount=[d]\nFlags=[w]\nLevel=[dP4]\nFile=[S]\n";
107 fmt
= "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n";
109 smb_fdata(param
, fmt
, param
+ pcnt
, unicodestr
);
112 print_data(data
, dcnt
);
117 trans2_qfsinfo(const u_char
*param
, const u_char
*data
, int pcnt
, int dcnt
)
119 static int level
= 0;
124 level
= EXTRACT_LE_16BITS(param
);
125 fmt
= "InfoLevel=[d]\n";
126 smb_fdata(param
, fmt
, param
+ pcnt
, unicodestr
);
130 fmt
= "idFileSystem=[W]\nSectorUnit=[D]\nUnit=[D]\nAvail=[D]\nSectorSize=[d]\n";
133 fmt
= "CreationTime=[T2]VolNameLength=[lb]\nVolumeLabel=[c]\n";
136 fmt
= "Capabilities=[W]\nMaxFileLen=[D]\nVolNameLen=[lD]\nVolume=[C]\n";
139 fmt
= "UnknownLevel\n";
142 smb_fdata(data
, fmt
, data
+ dcnt
, unicodestr
);
146 print_data(data
, dcnt
);
154 struct smbfnsint trans2_fns
[] = {
155 { 0, "TRANSACT2_OPEN", 0,
156 { "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w, w, w, w, w])\nPath=[S]",
158 "Handle=[d]\nAttrib=[A]\nTime=[T2]\nSize=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nInode=[W]\nOffErr=[d]\n|EALength=[d]\n",
160 { 1, "TRANSACT2_FINDFIRST", 0,
161 { NULL
, NULL
, NULL
, NULL
, trans2_findfirst
}},
162 { 2, "TRANSACT2_FINDNEXT", 0, DEFDESCRIPT
},
163 { 3, "TRANSACT2_QFSINFO", 0,
164 { NULL
, NULL
, NULL
, NULL
, trans2_qfsinfo
}},
165 { 4, "TRANSACT2_SETFSINFO", 0, DEFDESCRIPT
},
166 { 5, "TRANSACT2_QPATHINFO", 0, DEFDESCRIPT
},
167 { 6, "TRANSACT2_SETPATHINFO", 0, DEFDESCRIPT
},
168 { 7, "TRANSACT2_QFILEINFO", 0, DEFDESCRIPT
},
169 { 8, "TRANSACT2_SETFILEINFO", 0, DEFDESCRIPT
},
170 { 9, "TRANSACT2_FSCTL", 0, DEFDESCRIPT
},
171 { 10, "TRANSACT2_IOCTL", 0, DEFDESCRIPT
},
172 { 11, "TRANSACT2_FINDNOTIFYFIRST", 0, DEFDESCRIPT
},
173 { 12, "TRANSACT2_FINDNOTIFYNEXT", 0, DEFDESCRIPT
},
174 { 13, "TRANSACT2_MKDIR", 0, DEFDESCRIPT
},
175 { -1, NULL
, 0, DEFDESCRIPT
}
180 print_trans2(const u_char
*words
, const u_char
*dat
, const u_char
*buf
, const u_char
*maxbuf
)
183 static struct smbfnsint
*fn
= &trans2_fns
[0];
184 const u_char
*data
, *param
;
185 const u_char
*w
= words
+ 1;
186 const char *f1
= NULL
, *f2
= NULL
;
191 TCHECK2(w
[14 * 2], 2);
192 pcnt
= EXTRACT_LE_16BITS(w
+ 9 * 2);
193 param
= buf
+ EXTRACT_LE_16BITS(w
+ 10 * 2);
194 dcnt
= EXTRACT_LE_16BITS(w
+ 11 * 2);
195 data
= buf
+ EXTRACT_LE_16BITS(w
+ 12 * 2);
196 fn
= smbfindint(EXTRACT_LE_16BITS(w
+ 14 * 2), trans2_fns
);
199 printf("%s\n", fn
->name
);
200 printf("Trans2Interim\n");
203 TCHECK2(w
[7 * 2], 2);
204 pcnt
= EXTRACT_LE_16BITS(w
+ 3 * 2);
205 param
= buf
+ EXTRACT_LE_16BITS(w
+ 4 * 2);
206 dcnt
= EXTRACT_LE_16BITS(w
+ 6 * 2);
207 data
= buf
+ EXTRACT_LE_16BITS(w
+ 7 * 2);
210 printf("%s param_length=%d data_length=%d\n", fn
->name
, pcnt
, dcnt
);
215 "Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",
220 "TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[b][P1]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[b][P1]\n",
221 words
+ 1 + 14 * 2, unicodestr
);
223 f1
= fn
->descript
.req_f1
;
224 f2
= fn
->descript
.req_f2
;
227 "TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[b][P1]\n",
228 words
+ 1 + 10 * 2, unicodestr
);
229 f1
= fn
->descript
.rep_f1
;
230 f2
= fn
->descript
.rep_f2
;
234 bcc
= EXTRACT_LE_16BITS(dat
);
235 printf("smb_bcc=%u\n", bcc
);
237 (*fn
->descript
.fn
)(param
, data
, pcnt
, dcnt
);
239 smb_fdata(param
, f1
? f1
: "Parameters=\n", param
+ pcnt
, unicodestr
);
240 smb_fdata(data
, f2
? f2
: "Data=\n", data
+ dcnt
, unicodestr
);
250 print_browse(const u_char
*param
, int paramlen
, const u_char
*data
, int datalen
)
252 const u_char
*maxbuf
= data
+ datalen
;
258 smb_fdata(param
, "BROWSE PACKET\n|Param ", param
+paramlen
, unicodestr
);
262 data
= smb_fdata(data
,
263 "BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
268 data
= smb_fdata(data
,
269 "BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
274 data
= smb_fdata(data
,
275 "BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",
280 data
= smb_fdata(data
,
281 "BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",
286 data
= smb_fdata(data
,
287 "BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n",
292 data
= smb_fdata(data
,
293 "BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",
298 data
= smb_fdata(data
,
299 "BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken=[W]\n",
304 data
= smb_fdata(data
,
305 "BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken=[W]\n*Name=[S]\n",
310 data
= smb_fdata(data
,
311 "BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",
316 data
= smb_fdata(data
,
317 "BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf
, unicodestr
);
321 data
= smb_fdata(data
, "Unknown Browser Frame ", maxbuf
, unicodestr
);
332 print_ipc(const u_char
*param
, int paramlen
, const u_char
*data
, int datalen
)
335 smb_fdata(param
, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param
+ paramlen
,
338 smb_fdata(data
, "IPC ", data
+ datalen
, unicodestr
);
343 print_trans(const u_char
*words
, const u_char
*data1
, const u_char
*buf
, const u_char
*maxbuf
)
346 const char *f1
, *f2
, *f3
, *f4
;
347 const u_char
*data
, *param
;
348 const u_char
*w
= words
+ 1;
349 int datalen
, paramlen
;
352 TCHECK2(w
[12 * 2], 2);
353 paramlen
= EXTRACT_LE_16BITS(w
+ 9 * 2);
354 param
= buf
+ EXTRACT_LE_16BITS(w
+ 10 * 2);
355 datalen
= EXTRACT_LE_16BITS(w
+ 11 * 2);
356 data
= buf
+ EXTRACT_LE_16BITS(w
+ 12 * 2);
357 f1
= "TotParamCnt=[d] \nTotDataCnt=[d] \nMaxParmCnt=[d] \nMaxDataCnt=[d]\nMaxSCnt=[d] \nTransFlags=[w] \nRes1=[w] \nRes2=[w] \nRes3=[w]\nParamCnt=[d] \nParamOff=[d] \nDataCnt=[d] \nDataOff=[d] \nSUCnt=[d]\n";
362 TCHECK2(w
[7 * 2], 2);
363 paramlen
= EXTRACT_LE_16BITS(w
+ 3 * 2);
364 param
= buf
+ EXTRACT_LE_16BITS(w
+ 4 * 2);
365 datalen
= EXTRACT_LE_16BITS(w
+ 6 * 2);
366 data
= buf
+ EXTRACT_LE_16BITS(w
+ 7 * 2);
367 f1
= "TotParamCnt=[d] \nTotDataCnt=[d] \nRes1=[d]\nParamCnt=[d] \nParamOff=[d] \nRes2=[d] \nDataCnt=[d] \nDataOff=[d] \nRes3=[d]\nLsetup=[d]\n";
373 smb_fdata(words
+ 1, f1
, SMBMIN(words
+ 1 + 2 * words
[0], maxbuf
),
377 bcc
= EXTRACT_LE_16BITS(data1
);
378 printf("smb_bcc=%u\n", bcc
);
380 smb_fdata(data1
+ 2, f2
, maxbuf
- (paramlen
+ datalen
), unicodestr
);
382 if (strcmp((const char *)(data1
+ 2), "\\MAILSLOT\\BROWSE") == 0) {
383 print_browse(param
, paramlen
, data
, datalen
);
387 if (strcmp((const char *)(data1
+ 2), "\\PIPE\\LANMAN") == 0) {
388 print_ipc(param
, paramlen
, data
, datalen
);
393 smb_fdata(param
, f3
, SMBMIN(param
+ paramlen
, maxbuf
), unicodestr
);
395 smb_fdata(data
, f4
, SMBMIN(data
+ datalen
, maxbuf
), unicodestr
);
405 print_negprot(const u_char
*words
, const u_char
*data
, const u_char
*buf _U_
, const u_char
*maxbuf
)
408 const char *f1
= NULL
, *f2
= NULL
;
413 f2
= "*|Dialect=[Y]\n";
416 f1
= "Core Protocol\nDialectIndex=[d]";
418 f1
= "NT1 Protocol\nDialectIndex=[d]\nSecMode=[B]\nMaxMux=[d]\nNumVcs=[d]\nMaxBuffer=[D]\nRawSize=[D]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[d]\nCryptKey=";
420 f1
= "Coreplus/Lanman1/Lanman2 Protocol\nDialectIndex=[d]\nSecMode=[w]\nMaxXMit=[d]\nMaxMux=[d]\nMaxVcs=[d]\nBlkMode=[w]\nSessionKey=[W]\nServerTime=[T1]TimeZone=[d]\nRes=[W]\nCryptKey=";
424 smb_fdata(words
+ 1, f1
, SMBMIN(words
+ 1 + wct
* 2, maxbuf
),
427 print_data(words
+ 1, SMBMIN(wct
* 2, PTR_DIFF(maxbuf
, words
+ 1)));
430 bcc
= EXTRACT_LE_16BITS(data
);
431 printf("smb_bcc=%u\n", bcc
);
434 smb_fdata(data
+ 2, f2
, SMBMIN(data
+ 2 + EXTRACT_LE_16BITS(data
),
435 maxbuf
), unicodestr
);
437 print_data(data
+ 2, SMBMIN(EXTRACT_LE_16BITS(data
), PTR_DIFF(maxbuf
, data
+ 2)));
446 print_sesssetup(const u_char
*words
, const u_char
*data
, const u_char
*buf _U_
, const u_char
*maxbuf
)
449 const char *f1
= NULL
, *f2
= NULL
;
455 f1
= "Com2=[w]\nOff2=[d]\nBufSize=[d]\nMpxMax=[d]\nVcNum=[d]\nSessionKey=[W]\nPassLen=[d]\nCryptLen=[d]\nCryptOff=[d]\nPass&Name=\n";
457 f1
= "Com2=[B]\nRes1=[B]\nOff2=[d]\nMaxBuffer=[d]\nMaxMpx=[d]\nVcNumber=[d]\nSessionKey=[W]\nCaseInsensitivePasswordLength=[d]\nCaseSensitivePasswordLength=[d]\nRes=[W]\nCapabilities=[W]\nPass1&Pass2&Account&Domain&OS&LanMan=\n";
460 f1
= "Com2=[w]\nOff2=[d]\nAction=[w]\n";
461 } else if (wct
== 13) {
462 f1
= "Com2=[B]\nRes=[B]\nOff2=[d]\nAction=[w]\n";
463 f2
= "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n";
468 smb_fdata(words
+ 1, f1
, SMBMIN(words
+ 1 + wct
* 2, maxbuf
),
471 print_data(words
+ 1, SMBMIN(wct
* 2, PTR_DIFF(maxbuf
, words
+ 1)));
474 bcc
= EXTRACT_LE_16BITS(data
);
475 printf("smb_bcc=%u\n", bcc
);
478 smb_fdata(data
+ 2, f2
, SMBMIN(data
+ 2 + EXTRACT_LE_16BITS(data
),
479 maxbuf
), unicodestr
);
481 print_data(data
+ 2, SMBMIN(EXTRACT_LE_16BITS(data
), PTR_DIFF(maxbuf
, data
+ 2)));
490 print_lockingandx(const u_char
*words
, const u_char
*data
, const u_char
*buf _U_
, const u_char
*maxbuf
)
493 const u_char
*maxwords
;
494 const char *f1
= NULL
, *f2
= NULL
;
499 f1
= "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n";
502 f2
= "*Process=[d]\n[P2]Offset=[M]\nLength=[M]\n";
504 f2
= "*Process=[d]\nOffset=[D]\nLength=[D]\n";
506 f1
= "Com2=[w]\nOff2=[d]\n";
509 maxwords
= SMBMIN(words
+ 1 + wct
* 2, maxbuf
);
511 smb_fdata(words
+ 1, f1
, maxwords
, unicodestr
);
514 bcc
= EXTRACT_LE_16BITS(data
);
515 printf("smb_bcc=%u\n", bcc
);
518 smb_fdata(data
+ 2, f2
, SMBMIN(data
+ 2 + EXTRACT_LE_16BITS(data
),
519 maxbuf
), unicodestr
);
521 print_data(data
+ 2, SMBMIN(EXTRACT_LE_16BITS(data
), PTR_DIFF(maxbuf
, data
+ 2)));
530 static struct smbfns smb_fns
[] = {
531 { -1, "SMBunknown", 0, DEFDESCRIPT
},
533 { SMBtcon
, "SMBtcon", 0,
534 { NULL
, "Path=[Z]\nPassword=[Z]\nDevice=[Z]\n",
535 "MaxXmit=[d]\nTreeId=[d]\n", NULL
,
538 { SMBtdis
, "SMBtdis", 0, DEFDESCRIPT
},
539 { SMBexit
, "SMBexit", 0, DEFDESCRIPT
},
540 { SMBioctl
, "SMBioctl", 0, DEFDESCRIPT
},
542 { SMBecho
, "SMBecho", 0,
543 { "ReverbCount=[d]\n", NULL
,
544 "SequenceNum=[d]\n", NULL
,
547 { SMBulogoffX
, "SMBulogoffX", FLG_CHAIN
, DEFDESCRIPT
},
549 { SMBgetatr
, "SMBgetatr", 0,
550 { NULL
, "Path=[Z]\n",
551 "Attribute=[A]\nTime=[T2]Size=[D]\nRes=([w,w,w,w,w])\n", NULL
,
554 { SMBsetatr
, "SMBsetatr", 0,
555 { "Attribute=[A]\nTime=[T2]Res=([w,w,w,w,w])\n", "Path=[Z]\n",
556 NULL
, NULL
, NULL
} },
558 { SMBchkpth
, "SMBchkpth", 0,
559 { NULL
, "Path=[Z]\n", NULL
, NULL
, NULL
} },
561 { SMBsearch
, "SMBsearch", 0,
562 { "Count=[d]\nAttrib=[A]\n",
563 "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\n",
565 "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",
568 { SMBopen
, "SMBopen", 0,
569 { "Mode=[w]\nAttribute=[A]\n", "Path=[Z]\n",
570 "Handle=[d]\nOAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\n",
573 { SMBcreate
, "SMBcreate", 0,
574 { "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[d]\n", NULL
, NULL
} },
576 { SMBmknew
, "SMBmknew", 0,
577 { "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[d]\n", NULL
, NULL
} },
579 { SMBunlink
, "SMBunlink", 0,
580 { "Attrib=[A]\n", "Path=[Z]\n", NULL
, NULL
, NULL
} },
582 { SMBread
, "SMBread", 0,
583 { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL
,
584 "Count=[d]\nRes=([w,w,w,w])\n", NULL
, NULL
} },
586 { SMBwrite
, "SMBwrite", 0,
587 { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL
,
588 "Count=[d]\n", NULL
, NULL
} },
590 { SMBclose
, "SMBclose", 0,
591 { "Handle=[d]\nTime=[T2]", NULL
, NULL
, NULL
, NULL
} },
593 { SMBmkdir
, "SMBmkdir", 0,
594 { NULL
, "Path=[Z]\n", NULL
, NULL
, NULL
} },
596 { SMBrmdir
, "SMBrmdir", 0,
597 { NULL
, "Path=[Z]\n", NULL
, NULL
, NULL
} },
599 { SMBdskattr
, "SMBdskattr", 0,
601 "TotalUnits=[d]\nBlocksPerUnit=[d]\nBlockSize=[d]\nFreeUnits=[d]\nMedia=[w]\n",
605 { "Attrib=[A]\n", "OldPath=[Z]\nNewPath=[Z]\n", NULL
, NULL
, NULL
} },
608 * this is a Pathworks specific call, allowing the
609 * changing of the root path
611 { pSETDIR
, "SMBsetdir", 0, { NULL
, "Path=[Z]\n", NULL
, NULL
, NULL
} },
613 { SMBlseek
, "SMBlseek", 0,
614 { "Handle=[d]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL
, NULL
, NULL
} },
616 { SMBflush
, "SMBflush", 0, { "Handle=[d]\n", NULL
, NULL
, NULL
, NULL
} },
618 { SMBsplopen
, "SMBsplopen", 0,
619 { "SetupLen=[d]\nMode=[w]\n", "Ident=[Z]\n", "Handle=[d]\n",
622 { SMBsplclose
, "SMBsplclose", 0,
623 { "Handle=[d]\n", NULL
, NULL
, NULL
, NULL
} },
625 { SMBsplretq
, "SMBsplretq", 0,
626 { "MaxCount=[d]\nStartIndex=[d]\n", NULL
,
627 "Count=[d]\nIndex=[d]\n",
628 "*Time=[T2]Status=[B]\nJobID=[d]\nSize=[D]\nRes=[B]Name=[s16]\n",
631 { SMBsplwr
, "SMBsplwr", 0,
632 { "Handle=[d]\n", NULL
, NULL
, NULL
, NULL
} },
634 { SMBlock
, "SMBlock", 0,
635 { "Handle=[d]\nCount=[D]\nOffset=[D]\n", NULL
, NULL
, NULL
, NULL
} },
637 { SMBunlock
, "SMBunlock", 0,
638 { "Handle=[d]\nCount=[D]\nOffset=[D]\n", NULL
, NULL
, NULL
, NULL
} },
640 /* CORE+ PROTOCOL FOLLOWS */
642 { SMBreadbraw
, "SMBreadbraw", 0,
643 { "Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[d]\n",
644 NULL
, NULL
, NULL
, NULL
} },
646 { SMBwritebraw
, "SMBwritebraw", 0,
647 { "Handle=[d]\nTotalCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\n|DataSize=[d]\nDataOff=[d]\n",
648 NULL
, "WriteRawAck", NULL
, NULL
} },
650 { SMBwritec
, "SMBwritec", 0,
651 { NULL
, NULL
, "Count=[d]\n", NULL
, NULL
} },
653 { SMBwriteclose
, "SMBwriteclose", 0,
654 { "Handle=[d]\nCount=[d]\nOffset=[D]\nTime=[T2]Res=([w,w,w,w,w,w])",
655 NULL
, "Count=[d]\n", NULL
, NULL
} },
657 { SMBlockread
, "SMBlockread", 0,
658 { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL
,
659 "Count=[d]\nRes=([w,w,w,w])\n", NULL
, NULL
} },
661 { SMBwriteunlock
, "SMBwriteunlock", 0,
662 { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL
,
663 "Count=[d]\n", NULL
, NULL
} },
665 { SMBreadBmpx
, "SMBreadBmpx", 0,
666 { "Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[w]\n",
668 "Offset=[D]\nTotCount=[d]\nRemaining=[d]\nRes=([w,w])\nDataSize=[d]\nDataOff=[d]\n",
671 { SMBwriteBmpx
, "SMBwriteBmpx", 0,
672 { "Handle=[d]\nTotCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\nDataSize=[d]\nDataOff=[d]\n", NULL
,
673 "Remaining=[d]\n", NULL
, NULL
} },
675 { SMBwriteBs
, "SMBwriteBs", 0,
676 { "Handle=[d]\nTotCount=[d]\nOffset=[D]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\n",
677 NULL
, "Count=[d]\n", NULL
, NULL
} },
679 { SMBsetattrE
, "SMBsetattrE", 0,
680 { "Handle=[d]\nCreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]", NULL
,
681 NULL
, NULL
, NULL
} },
683 { SMBgetattrE
, "SMBgetattrE", 0,
684 { "Handle=[d]\n", NULL
,
685 "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D]\nAllocSize=[D]\nAttribute=[A]\n",
688 { SMBtranss
, "SMBtranss", 0, DEFDESCRIPT
},
689 { SMBioctls
, "SMBioctls", 0, DEFDESCRIPT
},
691 { SMBcopy
, "SMBcopy", 0,
692 { "TreeID2=[d]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n",
693 "CopyCount=[d]\n", "|ErrStr=[S]\n", NULL
} },
695 { SMBmove
, "SMBmove", 0,
696 { "TreeID2=[d]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n",
697 "MoveCount=[d]\n", "|ErrStr=[S]\n", NULL
} },
699 { SMBopenX
, "SMBopenX", FLG_CHAIN
,
700 { "Com2=[w]\nOff2=[d]\nFlags=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]OFun=[w]\nSize=[D]\nTimeOut=[D]\nRes=[W]\n",
702 "Com2=[w]\nOff2=[d]\nHandle=[d]\nAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nFileID=[W]\nRes=[w]\n",
705 { SMBreadX
, "SMBreadX", FLG_CHAIN
,
706 { "Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nCountLeft=[d]\n",
708 "Com2=[w]\nOff2=[d]\nRemaining=[d]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\nRes=([w,w,w,w])\n",
711 { SMBwriteX
, "SMBwriteX", FLG_CHAIN
,
712 { "Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nCountLeft=[d]\nRes=[w]\nDataSize=[d]\nDataOff=[d]\n",
714 "Com2=[w]\nOff2=[d]\nCount=[d]\nRemaining=[d]\nRes=[W]\n",
717 { SMBffirst
, "SMBffirst", 0,
718 { "Count=[d]\nAttrib=[A]\n",
719 "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
721 "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",
724 { SMBfunique
, "SMBfunique", 0,
725 { "Count=[d]\nAttrib=[A]\n",
726 "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
728 "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",
731 { SMBfclose
, "SMBfclose", 0,
732 { "Count=[d]\nAttrib=[A]\n",
733 "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n",
735 "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n",
738 { SMBfindnclose
, "SMBfindnclose", 0,
739 { "Handle=[d]\n", NULL
, NULL
, NULL
, NULL
} },
741 { SMBfindclose
, "SMBfindclose", 0,
742 { "Handle=[d]\n", NULL
, NULL
, NULL
, NULL
} },
744 { SMBsends
, "SMBsends", 0,
745 { NULL
, "Source=[Z]\nDest=[Z]\n", NULL
, NULL
, NULL
} },
747 { SMBsendstrt
, "SMBsendstrt", 0,
748 { NULL
, "Source=[Z]\nDest=[Z]\n", "GroupID=[d]\n", NULL
, NULL
} },
750 { SMBsendend
, "SMBsendend", 0,
751 { "GroupID=[d]\n", NULL
, NULL
, NULL
, NULL
} },
753 { SMBsendtxt
, "SMBsendtxt", 0,
754 { "GroupID=[d]\n", NULL
, NULL
, NULL
, NULL
} },
756 { SMBsendb
, "SMBsendb", 0,
757 { NULL
, "Source=[Z]\nDest=[Z]\n", NULL
, NULL
, NULL
} },
759 { SMBfwdname
, "SMBfwdname", 0, DEFDESCRIPT
},
760 { SMBcancelf
, "SMBcancelf", 0, DEFDESCRIPT
},
761 { SMBgetmac
, "SMBgetmac", 0, DEFDESCRIPT
},
763 { SMBnegprot
, "SMBnegprot", 0,
764 { NULL
, NULL
, NULL
, NULL
, print_negprot
} },
766 { SMBsesssetupX
, "SMBsesssetupX", FLG_CHAIN
,
767 { NULL
, NULL
, NULL
, NULL
, print_sesssetup
} },
769 { SMBtconX
, "SMBtconX", FLG_CHAIN
,
770 { "Com2=[w]\nOff2=[d]\nFlags=[w]\nPassLen=[d]\nPasswd&Path&Device=\n",
771 NULL
, "Com2=[w]\nOff2=[d]\n", "ServiceType=[R]\n", NULL
} },
773 { SMBlockingX
, "SMBlockingX", FLG_CHAIN
,
774 { NULL
, NULL
, NULL
, NULL
, print_lockingandx
} },
776 { SMBtrans2
, "SMBtrans2", 0, { NULL
, NULL
, NULL
, NULL
, print_trans2
} },
778 { SMBtranss2
, "SMBtranss2", 0, DEFDESCRIPT
},
779 { SMBctemp
, "SMBctemp", 0, DEFDESCRIPT
},
780 { SMBreadBs
, "SMBreadBs", 0, DEFDESCRIPT
},
781 { SMBtrans
, "SMBtrans", 0, { NULL
, NULL
, NULL
, NULL
, print_trans
} },
783 { SMBnttrans
, "SMBnttrans", 0, DEFDESCRIPT
},
784 { SMBnttranss
, "SMBnttranss", 0, DEFDESCRIPT
},
786 { SMBntcreateX
, "SMBntcreateX", FLG_CHAIN
,
787 { "Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[ld]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n",
789 "Com2=[w]\nOff2=[d]\nOplockLevel=[b]\nFid=[d]\nCreateAction=[W]\nCreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W]\nAllocationSize=[L]\nEndOfFile=[L]\nFileType=[w]\nDeviceState=[w]\nDirectory=[b]\n",
792 { SMBntcancel
, "SMBntcancel", 0, DEFDESCRIPT
},
794 { -1, NULL
, 0, DEFDESCRIPT
}
799 * print a SMB message
802 print_smb(const u_char
*buf
, const u_char
*maxbuf
)
808 const u_char
*words
, *maxwords
, *data
;
810 const char *fmt_smbheader
=
811 "[P4]SMB Command = [B]\nError class = [BP1]\nError code = [d]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [d]\nProc ID = [d]\nUID = [d]\nMID = [d]\nWord Count = [b]\n";
815 request
= (buf
[9] & 0x80) ? 0 : 1;
816 flags2
= EXTRACT_LE_16BITS(&buf
[10]);
817 unicodestr
= flags2
& 0x8000;
818 nterrcodes
= flags2
& 0x4000;
823 fn
= smbfind(command
, smb_fns
);
828 printf("SMB PACKET: %s (%s)\n", fn
->name
, request
? "REQUEST" : "REPLY");
833 /* print out the header */
834 smb_fdata(buf
, fmt_smbheader
, buf
+ 33, unicodestr
);
837 nterror
= EXTRACT_LE_32BITS(&buf
[5]);
839 printf("NTError = %s\n", nt_errstr(nterror
));
842 printf("SMBError = %s\n", smb_errstr(buf
[5], EXTRACT_LE_16BITS(&buf
[7])));
853 words
= buf
+ smboffset
;
856 data
= words
+ 1 + wct
* 2;
857 maxwords
= SMBMIN(data
, maxbuf
);
860 f1
= fn
->descript
.req_f1
;
861 f2
= fn
->descript
.req_f2
;
863 f1
= fn
->descript
.rep_f1
;
864 f2
= fn
->descript
.rep_f2
;
868 (*fn
->descript
.fn
)(words
, data
, buf
, maxbuf
);
872 smb_fdata(words
+ 1, f1
, words
+ 1 + wct
* 2, unicodestr
);
877 for (i
= 0; &words
[1 + 2 * i
] < maxwords
; i
++) {
878 TCHECK2(words
[1 + 2 * i
], 2);
879 v
= EXTRACT_LE_16BITS(words
+ 1 + 2 * i
);
880 printf("smb_vwv[%d]=%d (0x%X)\n", i
, v
, v
);
886 bcc
= EXTRACT_LE_16BITS(data
);
887 printf("smb_bcc=%u\n", bcc
);
890 smb_fdata(data
+ 2, f2
, data
+ 2 + bcc
, unicodestr
);
893 printf("smb_buf[]=\n");
894 print_data(data
+ 2, SMBMIN(bcc
, PTR_DIFF(maxbuf
, data
+ 2)));
899 if ((fn
->flags
& FLG_CHAIN
) == 0)
907 TCHECK2(words
[3], 2);
908 newsmboffset
= EXTRACT_LE_16BITS(words
+ 3);
910 fn
= smbfind(command
, smb_fns
);
912 printf("\nSMB PACKET: %s (%s) (CHAINED)\n",
913 fn
->name
, request
? "REQUEST" : "REPLY");
914 if (newsmboffset
<= smboffset
) {
915 printf("Bad andX offset: %u <= %u\n", newsmboffset
, smboffset
);
918 smboffset
= newsmboffset
;
930 * print a NBT packet received across tcp on port 139
933 nbt_tcp_print(const u_char
*data
, int length
)
938 const u_char
*maxbuf
;
944 caplen
= snapend
- data
;
947 maxbuf
= data
+ caplen
;
949 nbt_len
= EXTRACT_16BITS(data
+ 2);
956 printf(" NBT Session Packet: ");
959 printf("Session Message");
963 printf("Session Request");
967 printf("Session Granted");
982 printf("Session Reject, ");
985 printf("Not listening on called name");
988 printf("Not listening for calling name");
991 printf("Called name not present");
994 printf("Called name present, but insufficient resources");
997 printf("Unspecified error 0x%X", ecode
);
1004 printf("Session Keepalive");
1008 data
= smb_fdata(data
, "Unknown packet type [rB]", maxbuf
, 0);
1012 printf ("\n>>> NBT Session Packet\n");
1015 data
= smb_fdata(data
, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n",
1019 if (nbt_len
>= 4 && caplen
>= 4 && memcmp(data
,"\377SMB",4) == 0) {
1020 if ((int)nbt_len
> caplen
) {
1021 if ((int)nbt_len
> length
)
1022 printf("WARNING: Packet is continued in later TCP segments\n");
1024 printf("WARNING: Short packet. Try increasing the snap length by %d\n",
1027 print_smb(data
, maxbuf
> data
+ nbt_len
? data
+ nbt_len
: maxbuf
);
1029 printf("Session packet:(raw data or continuation?)\n");
1033 data
= smb_fdata(data
,
1034 "[P1]NBT Session Request\nFlags=[B]\nLength=[rd]\nDestination=[n1]\nSource=[n1]\n",
1039 data
= smb_fdata(data
, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf
, 0);
1044 const u_char
*origdata
;
1048 data
= smb_fdata(data
, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n",
1052 if (nbt_len
>= 1 && caplen
>= 1) {
1053 ecode
= origdata
[4];
1056 printf("Not listening on called name\n");
1059 printf("Not listening for calling name\n");
1062 printf("Called name not present\n");
1065 printf("Called name present, but insufficient resources\n");
1068 printf("Unspecified error 0x%X\n", ecode
);
1076 data
= smb_fdata(data
, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf
, 0);
1080 data
= smb_fdata(data
, "NBT - Unknown packet type\nType=[B]\n", maxbuf
, 0);
1094 * print a NBT packet received across udp on port 137
1097 nbt_udp137_print(const u_char
*data
, int length
)
1099 const u_char
*maxbuf
= data
+ length
;
1100 int name_trn_id
, response
, opcode
, nm_flags
, rcode
;
1101 int qdcount
, ancount
, nscount
, arcount
;
1102 const char *opcodestr
;
1106 TCHECK2(data
[10], 2);
1107 name_trn_id
= EXTRACT_16BITS(data
);
1108 response
= (data
[2] >> 7);
1109 opcode
= (data
[2] >> 3) & 0xF;
1110 nm_flags
= ((data
[2] & 0x7) << 4) + (data
[3] >> 4);
1111 rcode
= data
[3] & 0xF;
1112 qdcount
= EXTRACT_16BITS(data
+ 4);
1113 ancount
= EXTRACT_16BITS(data
+ 6);
1114 nscount
= EXTRACT_16BITS(data
+ 8);
1115 arcount
= EXTRACT_16BITS(data
+ 10);
1124 printf("NBT UDP PACKET(137): ");
1127 case 0: opcodestr
= "QUERY"; break;
1128 case 5: opcodestr
= "REGISTRATION"; break;
1129 case 6: opcodestr
= "RELEASE"; break;
1130 case 7: opcodestr
= "WACK"; break;
1131 case 8: opcodestr
= "REFRESH(8)"; break;
1132 case 9: opcodestr
= "REFRESH"; break;
1133 case 15: opcodestr
= "MULTIHOMED REGISTRATION"; break;
1134 default: opcodestr
= "OPUNKNOWN"; break;
1136 printf("%s", opcodestr
);
1139 printf("; NEGATIVE");
1141 printf("; POSITIVE");
1145 printf("; RESPONSE");
1147 printf("; REQUEST");
1150 printf("; BROADCAST");
1152 printf("; UNICAST");
1157 printf("\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
1158 name_trn_id
, opcode
, nm_flags
, rcode
, qdcount
, ancount
, nscount
,
1163 total
= ancount
+ nscount
+ arcount
;
1165 if (qdcount
> 100 || total
> 100) {
1166 printf("Corrupt packet??\n");
1171 printf("QuestionRecords:\n");
1172 for (i
= 0; i
< qdcount
; i
++) {
1174 "|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",
1182 printf("\nResourceRecords:\n");
1183 for (i
= 0; i
< total
; i
++) {
1187 p
= smb_fdata(p
, "Name=[n1]\n#", maxbuf
, 0);
1190 restype
= EXTRACT_16BITS(p
);
1191 p
= smb_fdata(p
, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p
+ 8, 0);
1194 rdlen
= EXTRACT_16BITS(p
);
1195 printf("ResourceLength=%d\nResourceData=\n", rdlen
);
1198 p
= smb_fdata(p
, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p
+ rdlen
, 0);
1202 if (restype
== 0x21) {
1207 p
= smb_fdata(p
, "NumNames=[B]\n", p
+ 1, 0);
1210 while (numnames
--) {
1211 p
= smb_fdata(p
, "Name=[n2]\t#", maxbuf
, 0);
1217 switch (p
[0] & 0x60) {
1218 case 0x00: printf("B "); break;
1219 case 0x20: printf("P "); break;
1220 case 0x40: printf("M "); break;
1221 case 0x60: printf("_ "); break;
1224 printf("<DEREGISTERING> ");
1226 printf("<CONFLICT> ");
1228 printf("<ACTIVE> ");
1230 printf("<PERMANENT> ");
1235 print_data(p
, min(rdlen
, length
- (p
- data
)));
1243 smb_fdata(p
, "AdditionalData:\n", maxbuf
, 0);
1257 * print a NBT packet received across udp on port 138
1260 nbt_udp138_print(const u_char
*data
, int length
)
1262 const u_char
*maxbuf
= data
+ length
;
1264 if (maxbuf
> snapend
)
1271 printf("NBT UDP PACKET(138)");
1275 data
= smb_fdata(data
,
1276 "\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#",
1280 /* If there isn't enough data for "\377SMB", don't check for it. */
1281 if (&data
[3] >= maxbuf
)
1284 if (memcmp(data
, "\377SMB",4) == 0)
1285 print_smb(data
, maxbuf
);
1294 print netbeui frames
1296 struct nbf_strings
{
1298 const char *nonverbose
;
1299 const char *verbose
;
1300 } nbf_strings
[0x20] = {
1301 { "Add Group Name Query", ", [P23]Name to add=[n2]#",
1302 "[P5]ResponseCorrelator=[w]\n[P16]Name to add=[n2]\n" },
1303 { "Add Name Query", ", [P23]Name to add=[n2]#",
1304 "[P5]ResponseCorrelator=[w]\n[P16]Name to add=[n2]\n" },
1305 { "Name In Conflict", NULL
, NULL
},
1306 { "Status Query", NULL
, NULL
},
1307 { NULL
, NULL
, NULL
}, /* not used */
1308 { NULL
, NULL
, NULL
}, /* not used */
1309 { NULL
, NULL
, NULL
}, /* not used */
1310 { "Terminate Trace", NULL
, NULL
},
1312 "[P7]Destination=[n2]\nSource=[n2]\n" },
1313 { "Broadcast Datagram", NULL
,
1314 "[P7]Destination=[n2]\nSource=[n2]\n" },
1315 { "Name Query", ", [P7]Name=[n2]#",
1316 "[P1]SessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nName=[n2]\nName of sender=[n2]\n" },
1317 { NULL
, NULL
, NULL
}, /* not used */
1318 { NULL
, NULL
, NULL
}, /* not used */
1319 { "Add Name Response", ", [P1]GroupName=[w] [P4]Destination=[n2] Source=[n2]#",
1320 "AddNameInProcess=[B]\nGroupName=[w]\nTransmitCorrelator=[w][P2]\nDestination=[n2]\nSource=[n2]\n" },
1321 { "Name Recognized", NULL
,
1322 "[P1]Data2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nDestination=[n2]\nSource=[n2]\n" },
1323 { "Status Response", NULL
, NULL
},
1324 { NULL
, NULL
, NULL
}, /* not used */
1325 { NULL
, NULL
, NULL
}, /* not used */
1326 { NULL
, NULL
, NULL
}, /* not used */
1327 { "Terminate Trace", NULL
, NULL
},
1329 "[P3]TransmitCorrelator=[w][P2]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1330 { "Data First/Middle", NULL
,
1331 "Flags=[{RECEIVE_CONTINUE|NO_ACK||PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1332 { "Data Only/Last", NULL
,
1333 "Flags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1334 { "Session Confirm", NULL
,
1335 "Data1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1336 { "Session End", NULL
,
1337 "[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1338 { "Session Initialize", NULL
,
1339 "Data1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1340 { "No Receive", NULL
,
1341 "Flags=[{|SEND_NO_ACK}]\nDataBytesAccepted=[b][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1342 { "Receive Outstanding", NULL
,
1343 "[P1]DataBytesAccepted=[b][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1344 { "Receive Continue", NULL
,
1345 "[P2]TransmitCorrelator=[w]\n[P2]RemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
1346 { NULL
, NULL
, NULL
}, /* not used */
1347 { NULL
, NULL
, NULL
}, /* not used */
1348 { "Session Alive", NULL
, NULL
}
1352 netbeui_print(u_short control
, const u_char
*data
, int length
)
1354 const u_char
*maxbuf
= data
+ length
;
1357 const u_char
*data2
;
1358 int is_truncated
= 0;
1360 if (maxbuf
> snapend
)
1363 len
= EXTRACT_LE_16BITS(data
);
1366 if (data2
>= maxbuf
) {
1374 printf("NBF Packet: ");
1375 data
= smb_fdata(data
, "[P5]#", maxbuf
, 0);
1377 printf("\n>>> NBF Packet\nType=0x%X ", control
);
1378 data
= smb_fdata(data
, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf
, 0);
1383 if (command
> 0x1f || nbf_strings
[command
].name
== NULL
) {
1385 data
= smb_fdata(data
, "Unknown NBF Command#", data2
, 0);
1387 data
= smb_fdata(data
, "Unknown NBF Command\n", data2
, 0);
1390 printf("%s", nbf_strings
[command
].name
);
1391 if (nbf_strings
[command
].nonverbose
!= NULL
)
1392 data
= smb_fdata(data
, nbf_strings
[command
].nonverbose
, data2
, 0);
1394 printf("%s:\n", nbf_strings
[command
].name
);
1395 if (nbf_strings
[command
].verbose
!= NULL
)
1396 data
= smb_fdata(data
, nbf_strings
[command
].verbose
, data2
, 0);
1409 /* data2 was past the end of the buffer */
1413 /* If this isn't a command that would contain an SMB message, quit. */
1414 if (command
!= 0x08 && command
!= 0x09 && command
!= 0x15 &&
1418 /* If there isn't enough data for "\377SMB", don't look for it. */
1419 if (&data2
[3] >= maxbuf
)
1422 if (memcmp(data2
, "\377SMB",4) == 0)
1423 print_smb(data2
, maxbuf
);
1426 for (i
= 0; i
< 128; i
++) {
1427 if (&data2
[i
+ 3] >= maxbuf
)
1429 if (memcmp(&data2
[i
], "\377SMB", 4) == 0) {
1430 printf("found SMB packet at %d\n", i
);
1431 print_smb(&data2
[i
], maxbuf
);
1447 * print IPX-Netbios frames
1450 ipx_netbios_print(const u_char
*data
, u_int length
)
1453 * this is a hack till I work out how to parse the rest of the
1454 * NetBIOS-over-IPX stuff
1457 const u_char
*maxbuf
;
1459 maxbuf
= data
+ length
;
1460 /* Don't go past the end of the captured data in the packet. */
1461 if (maxbuf
> snapend
)
1464 for (i
= 0; i
< 128; i
++) {
1465 if (&data
[i
+ 4] > maxbuf
)
1467 if (memcmp(&data
[i
], "\377SMB", 4) == 0) {
1468 smb_fdata(data
, "\n>>> IPX transport ", &data
[i
], 0);
1469 print_smb(&data
[i
], maxbuf
);
1476 smb_fdata(data
, "\n>>> Unknown IPX ", maxbuf
, 0);