]>
The Tcpdump Group git mirrors - tcpdump/blob - print-smb.c
2 * Copyright (C) Andrew Tridgell 1995-1999
4 * This software may be distributed either under the terms of the
5 * BSD-style license that accompanies tcpdump or the GNU GPL version 2
14 static const char rcsid
[] _U_
=
15 "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.35 2004-12-28 11:18:29 guy Exp $" ;
18 #include <tcpdump-stdinc.h>
23 #include "interface.h"
27 static int request
= 0 ;
29 const u_char
* startbuf
= NULL
;
36 void (* fn
)( const u_char
*, const u_char
*, const u_char
*, const u_char
*);
39 struct smbdescriptint
{
44 void (* fn
)( const u_char
*, const u_char
*, int , int );
52 struct smbdescript descript
;
60 struct smbdescriptint descript
;
63 #define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL }
65 #define FLG_CHAIN (1 << 0)
67 static struct smbfns
*
68 smbfind ( int id
, struct smbfns
* list
)
72 for ( sindex
= 0 ; list
[ sindex
]. name
; sindex
++)
73 if ( list
[ sindex
]. id
== id
)
74 return (& list
[ sindex
]);
79 static struct smbfnsint
*
80 smbfindint ( int id
, struct smbfnsint
* list
)
84 for ( sindex
= 0 ; list
[ sindex
]. name
; sindex
++)
85 if ( list
[ sindex
]. id
== id
)
86 return (& list
[ sindex
]);
92 trans2_findfirst ( const u_char
* param
, const u_char
* data
, int pcnt
, int dcnt
)
97 fmt
= "Attribute=[A] \n SearchCount=[d] \n Flags=[w] \n Level=[dP5] \n File=[S] \n " ;
99 fmt
= "Handle=[w] \n Count=[d] \n EOS=[w] \n Eoffset=[d] \n LastNameOfs=[w] \n " ;
101 smb_fdata ( param
, fmt
, param
+ pcnt
);
104 print_data ( data
, dcnt
);
109 trans2_qfsinfo ( const u_char
* param
, const u_char
* data
, int pcnt
, int dcnt
)
111 static int level
= 0 ;
116 level
= EXTRACT_LE_16BITS ( param
);
117 fmt
= "InfoLevel=[d] \n " ;
118 smb_fdata ( param
, fmt
, param
+ pcnt
);
122 fmt
= "idFileSystem=[W] \n SectorUnit=[D] \n Unit=[D] \n Avail=[D] \n SectorSize=[d] \n " ;
125 fmt
= "CreationTime=[T2]VolNameLength=[B] \n VolumeLabel=[s12] \n " ;
128 fmt
= "Capabilities=[W] \n MaxFileLen=[D] \n VolNameLen=[D] \n Volume=[S] \n " ;
131 fmt
= "UnknownLevel \n " ;
134 smb_fdata ( data
, fmt
, data
+ dcnt
);
138 print_data ( data
, dcnt
);
146 struct smbfnsint trans2_fns
[] = {
147 { 0 , "TRANSACT2_OPEN" , 0 ,
148 { "Flags2=[w] \n Mode=[w] \n SearchAttrib=[A] \n Attrib=[A] \n Time=[T2] \n OFun=[w] \n Size=[D] \n Res=([w, w, w, w, w]) \n Path=[S]" ,
150 "Handle=[d] \n Attrib=[A] \n Time=[T2] \n Size=[D] \n Access=[w] \n Type=[w] \n State=[w] \n Action=[w] \n Inode=[W] \n OffErr=[d] \n |EALength=[d] \n " ,
152 { 1 , "TRANSACT2_FINDFIRST" , 0 ,
153 { NULL
, NULL
, NULL
, NULL
, trans2_findfirst
}},
154 { 2 , "TRANSACT2_FINDNEXT" , 0 , DEFDESCRIPT
},
155 { 3 , "TRANSACT2_QFSINFO" , 0 ,
156 { NULL
, NULL
, NULL
, NULL
, trans2_qfsinfo
}},
157 { 4 , "TRANSACT2_SETFSINFO" , 0 , DEFDESCRIPT
},
158 { 5 , "TRANSACT2_QPATHINFO" , 0 , DEFDESCRIPT
},
159 { 6 , "TRANSACT2_SETPATHINFO" , 0 , DEFDESCRIPT
},
160 { 7 , "TRANSACT2_QFILEINFO" , 0 , DEFDESCRIPT
},
161 { 8 , "TRANSACT2_SETFILEINFO" , 0 , DEFDESCRIPT
},
162 { 9 , "TRANSACT2_FSCTL" , 0 , DEFDESCRIPT
},
163 { 10 , "TRANSACT2_IOCTL" , 0 , DEFDESCRIPT
},
164 { 11 , "TRANSACT2_FINDNOTIFYFIRST" , 0 , DEFDESCRIPT
},
165 { 12 , "TRANSACT2_FINDNOTIFYNEXT" , 0 , DEFDESCRIPT
},
166 { 13 , "TRANSACT2_MKDIR" , 0 , DEFDESCRIPT
},
167 { - 1 , NULL
, 0 , DEFDESCRIPT
}
172 print_trans2 ( const u_char
* words
, const u_char
* dat _U_
, const u_char
* buf
, const u_char
* maxbuf
)
174 static struct smbfnsint
* fn
= & trans2_fns
[ 0 ];
175 const u_char
* data
, * param
;
176 const u_char
* w
= words
+ 1 ;
177 const char * f1
= NULL
, * f2
= NULL
;
182 TCHECK2 ( w
[ 14 * 2 ], 2 );
183 pcnt
= EXTRACT_LE_16BITS ( w
+ 9 * 2 );
184 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 10 * 2 );
185 dcnt
= EXTRACT_LE_16BITS ( w
+ 11 * 2 );
186 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 12 * 2 );
187 fn
= smbfindint ( EXTRACT_LE_16BITS ( w
+ 14 * 2 ), trans2_fns
);
190 printf ( "%s \n " , fn
-> name
);
191 printf ( "Trans2Interim \n " );
194 TCHECK2 ( w
[ 7 * 2 ], 2 );
195 pcnt
= EXTRACT_LE_16BITS ( w
+ 3 * 2 );
196 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 4 * 2 );
197 dcnt
= EXTRACT_LE_16BITS ( w
+ 6 * 2 );
198 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 7 * 2 );
201 printf ( "%s param_length=%d data_length=%d \n " , fn
-> name
, pcnt
, dcnt
);
206 "Trans2Secondary \n TotParam=[d] \n TotData=[d] \n ParamCnt=[d] \n ParamOff=[d] \n ParamDisp=[d] \n DataCnt=[d] \n DataOff=[d] \n DataDisp=[d] \n Handle=[d] \n " ,
211 "TotParam=[d] \n TotData=[d] \n MaxParam=[d] \n MaxData=[d] \n MaxSetup=[d] \n Flags=[w] \n TimeOut=[D] \n Res1=[w] \n ParamCnt=[d] \n ParamOff=[d] \n DataCnt=[d] \n DataOff=[d] \n SetupCnt=[d] \n " ,
213 smb_fdata ( data
+ 1 , "TransactionName=[S] \n %" , maxbuf
);
215 f1
= fn
-> descript
. req_f1
;
216 f2
= fn
-> descript
. req_f2
;
219 "TotParam=[d] \n TotData=[d] \n Res1=[w] \n ParamCnt=[d] \n ParamOff=[d] \n ParamDisp[d] \n DataCnt=[d] \n DataOff=[d] \n DataDisp=[d] \n SetupCnt=[d] \n " ,
221 f1
= fn
-> descript
. rep_f1
;
222 f2
= fn
-> descript
. rep_f2
;
226 (* fn
-> descript
. fn
)( param
, data
, pcnt
, dcnt
);
228 smb_fdata ( param
, f1
? f1
: "Parameters= \n " , param
+ pcnt
);
229 smb_fdata ( data
, f2
? f2
: "Data= \n " , data
+ dcnt
);
239 print_browse ( const u_char
* param
, int paramlen
, const u_char
* data
, int datalen
)
241 const u_char
* maxbuf
= data
+ datalen
;
247 smb_fdata ( param
, "BROWSE PACKET \n |Param " , param
+ paramlen
);
251 data
= smb_fdata ( data
,
252 "BROWSE PACKET: \n Type=[B] (LocalMasterAnnouncement) \n UpdateCount=[w] \n Res1=[B] \n AnnounceInterval=[d] \n Name=[n2] \n MajorVersion=[B] \n MinorVersion=[B] \n ServerType=[W] \n ElectionVersion=[w] \n BrowserConstant=[w] \n " ,
257 data
= smb_fdata ( data
,
258 "BROWSE PACKET: \n Type=[B] (HostAnnouncement) \n UpdateCount=[w] \n Res1=[B] \n AnnounceInterval=[d] \n Name=[n2] \n MajorVersion=[B] \n MinorVersion=[B] \n ServerType=[W] \n ElectionVersion=[w] \n BrowserConstant=[w] \n " ,
263 data
= smb_fdata ( data
,
264 "BROWSE PACKET: \n Type=[B] (AnnouncementRequest) \n Flags=[B] \n ReplySystemName=[S] \n " ,
269 data
= smb_fdata ( data
,
270 "BROWSE PACKET: \n Type=[B] (WorkgroupAnnouncement) \n UpdateCount=[w] \n Res1=[B] \n AnnounceInterval=[d] \n Name=[n2] \n MajorVersion=[B] \n MinorVersion=[B] \n ServerType=[W] \n CommentPointer=[W] \n ServerName=[S] \n " ,
275 data
= smb_fdata ( data
,
276 "BROWSE PACKET: \n Type=[B] (ElectionFrame) \n ElectionVersion=[B] \n OSSummary=[W] \n Uptime=[(W, W)] \n ServerName=[S] \n " ,
281 data
= smb_fdata ( data
,
282 "BROWSE PACKET: \n Type=[B] (BecomeBackupBrowser) \n Name=[S] \n " ,
287 data
= smb_fdata ( data
,
288 "BROWSE PACKET: \n Type=[B] (GetBackupList) \n ListCount?=[B] \n Token?=[B] \n " ,
293 data
= smb_fdata ( data
,
294 "BROWSE PACKET: \n Type=[B] (BackupListResponse) \n ServerCount?=[B] \n Token?=[B]*Name=[S] \n " ,
299 data
= smb_fdata ( data
,
300 "BROWSE PACKET: \n Type=[B] (MasterAnnouncement) \n MasterName=[S] \n " ,
305 data
= smb_fdata ( data
,
306 "BROWSE PACKET: \n Type=[B] (ResetBrowser) \n Options=[B] \n " , maxbuf
);
310 data
= smb_fdata ( data
, "Unknown Browser Frame " , maxbuf
);
321 print_ipc ( const u_char
* param
, int paramlen
, const u_char
* data
, int datalen
)
324 smb_fdata ( param
, "Command=[w] \n Str1=[S] \n Str2=[S] \n " , param
+ paramlen
);
326 smb_fdata ( data
, "IPC " , data
+ datalen
);
331 print_trans ( const u_char
* words
, const u_char
* data1
, const u_char
* buf
, const u_char
* maxbuf
)
334 const char * f1
, * f2
, * f3
, * f4
;
335 const u_char
* data
, * param
;
336 const u_char
* w
= words
+ 1 ;
337 int datalen
, paramlen
;
340 TCHECK2 ( w
[ 12 * 2 ], 2 );
341 paramlen
= EXTRACT_LE_16BITS ( w
+ 9 * 2 );
342 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 10 * 2 );
343 datalen
= EXTRACT_LE_16BITS ( w
+ 11 * 2 );
344 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 12 * 2 );
345 f1
= "TotParamCnt=[d] \n TotDataCnt=[d] \n MaxParmCnt=[d] \n MaxDataCnt=[d] \n MaxSCnt=[d] \n TransFlags=[w] \n Res1=[w] \n Res2=[w] \n Res3=[w] \n ParamCnt=[d] \n ParamOff=[d] \n DataCnt=[d] \n DataOff=[d] \n SUCnt=[d] \n " ;
350 TCHECK2 ( w
[ 7 * 2 ], 2 );
351 paramlen
= EXTRACT_LE_16BITS ( w
+ 3 * 2 );
352 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 4 * 2 );
353 datalen
= EXTRACT_LE_16BITS ( w
+ 6 * 2 );
354 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 7 * 2 );
355 f1
= "TotParamCnt=[d] \n TotDataCnt=[d] \n Res1=[d] \n ParamCnt=[d] \n ParamOff=[d] \n Res2=[d] \n DataCnt=[d] \n DataOff=[d] \n Res3=[d] \n Lsetup=[d] \n " ;
361 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + 2 * words
[ 0 ], maxbuf
));
364 bcc
= EXTRACT_LE_16BITS ( data1
);
365 printf ( "smb_bcc=%u \n " , bcc
);
367 smb_fdata ( data1
+ 2 , f2
, maxbuf
- ( paramlen
+ datalen
));
369 if ( strcmp (( const char *)( data1
+ 2 ), " \\ MAILSLOT \\ BROWSE" ) == 0 ) {
370 print_browse ( param
, paramlen
, data
, datalen
);
374 if ( strcmp (( const char *)( data1
+ 2 ), " \\ PIPE \\ LANMAN" ) == 0 ) {
375 print_ipc ( param
, paramlen
, data
, datalen
);
380 smb_fdata ( param
, f3
, SMBMIN ( param
+ paramlen
, maxbuf
));
382 smb_fdata ( data
, f4
, SMBMIN ( data
+ datalen
, maxbuf
));
392 print_negprot ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
395 const char * f1
= NULL
, * f2
= NULL
;
400 f2
= "*|Dialect=[Z] \n " ;
403 f1
= "Core Protocol \n DialectIndex=[d]" ;
405 f1
= "NT1 Protocol \n DialectIndex=[d] \n SecMode=[B] \n MaxMux=[d] \n NumVcs=[d] \n MaxBuffer=[D] \n RawSize=[D] \n SessionKey=[W] \n Capabilities=[W] \n ServerTime=[T3]TimeZone=[d] \n CryptKey=" ;
407 f1
= "Coreplus/Lanman1/Lanman2 Protocol \n DialectIndex=[d] \n SecMode=[w] \n MaxXMit=[d] \n MaxMux=[d] \n MaxVcs=[d] \n BlkMode=[w] \n SessionKey=[W] \n ServerTime=[T1]TimeZone=[d] \n Res=[W] \n CryptKey=" ;
411 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + wct
* 2 , maxbuf
));
413 print_data ( words
+ 1 , SMBMIN ( wct
* 2 , PTR_DIFF ( maxbuf
, words
+ 1 )));
416 bcc
= EXTRACT_LE_16BITS ( data
);
417 printf ( "smb_bcc=%u \n " , bcc
);
420 smb_fdata ( data
+ 2 , f2
, SMBMIN ( data
+ 2 + EXTRACT_LE_16BITS ( data
), maxbuf
));
422 print_data ( data
+ 2 , SMBMIN ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
431 print_sesssetup ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
434 const char * f1
= NULL
, * f2
= NULL
;
440 f1
= "Com2=[w] \n Off2=[d] \n BufSize=[d] \n MpxMax=[d] \n VcNum=[d] \n SessionKey=[W] \n PassLen=[d] \n CryptLen=[d] \n CryptOff=[d] \n Pass&Name= \n " ;
442 f1
= "Com2=[B] \n Res1=[B] \n Off2=[d] \n MaxBuffer=[d] \n MaxMpx=[d] \n VcNumber=[d] \n SessionKey=[W] \n CaseInsensitivePasswordLength=[d] \n CaseSensitivePasswordLength=[d] \n Res=[W] \n Capabilities=[W] \n Pass1&Pass2&Account&Domain&OS&LanMan= \n " ;
445 f1
= "Com2=[w] \n Off2=[d] \n Action=[w] \n " ;
446 } else if ( wct
== 13 ) {
447 f1
= "Com2=[B] \n Res=[B] \n Off2=[d] \n Action=[w] \n " ;
448 f2
= "NativeOS=[S] \n NativeLanMan=[S] \n PrimaryDomain=[S] \n " ;
453 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + wct
* 2 , maxbuf
));
455 print_data ( words
+ 1 , SMBMIN ( wct
* 2 , PTR_DIFF ( maxbuf
, words
+ 1 )));
458 bcc
= EXTRACT_LE_16BITS ( data
);
459 printf ( "smb_bcc=%u \n " , bcc
);
462 smb_fdata ( data
+ 2 , f2
, SMBMIN ( data
+ 2 + EXTRACT_LE_16BITS ( data
), maxbuf
));
464 print_data ( data
+ 2 , SMBMIN ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
473 static struct smbfns smb_fns
[] = {
474 { - 1 , "SMBunknown" , 0 , DEFDESCRIPT
},
476 { SMBtcon
, "SMBtcon" , 0 ,
477 { NULL
, "Path=[Z] \n Password=[Z] \n Device=[Z] \n " ,
478 "MaxXmit=[d] \n TreeId=[d] \n " , NULL
,
481 { SMBtdis
, "SMBtdis" , 0 , DEFDESCRIPT
},
482 { SMBexit
, "SMBexit" , 0 , DEFDESCRIPT
},
483 { SMBioctl
, "SMBioctl" , 0 , DEFDESCRIPT
},
485 { SMBecho
, "SMBecho" , 0 ,
486 { "ReverbCount=[d] \n " , NULL
,
487 "SequenceNum=[d] \n " , NULL
,
490 { SMBulogoffX
, "SMBulogoffX" , FLG_CHAIN
, DEFDESCRIPT
},
492 { SMBgetatr
, "SMBgetatr" , 0 ,
493 { NULL
, "Path=[Z] \n " ,
494 "Attribute=[A] \n Time=[T2]Size=[D] \n Res=([w,w,w,w,w]) \n " , NULL
,
497 { SMBsetatr
, "SMBsetatr" , 0 ,
498 { "Attribute=[A] \n Time=[T2]Res=([w,w,w,w,w]) \n " , "Path=[Z] \n " ,
499 NULL
, NULL
, NULL
} },
501 { SMBchkpth
, "SMBchkpth" , 0 ,
502 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
504 { SMBsearch
, "SMBsearch" , 0 ,
505 { "Count=[d] \n Attrib=[A] \n " ,
506 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n " ,
508 "BlkType=[B] \n BlkLen=[d] \n * \n Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n Attrib=[a] \n Time=[T1]Size=[D] \n Name=[s13] \n " ,
511 { SMBopen
, "SMBopen" , 0 ,
512 { "Mode=[w] \n Attribute=[A] \n " , "Path=[Z] \n " ,
513 "Handle=[d] \n OAttrib=[A] \n Time=[T2]Size=[D] \n Access=[w] \n " ,
516 { SMBcreate
, "SMBcreate" , 0 ,
517 { "Attrib=[A] \n Time=[T2]" , "Path=[Z] \n " , "Handle=[d] \n " , NULL
, NULL
} },
519 { SMBmknew
, "SMBmknew" , 0 ,
520 { "Attrib=[A] \n Time=[T2]" , "Path=[Z] \n " , "Handle=[d] \n " , NULL
, NULL
} },
522 { SMBunlink
, "SMBunlink" , 0 ,
523 { "Attrib=[A] \n " , "Path=[Z] \n " , NULL
, NULL
, NULL
} },
525 { SMBread
, "SMBread" , 0 ,
526 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
527 "Count=[d] \n Res=([w,w,w,w]) \n " , NULL
, NULL
} },
529 { SMBwrite
, "SMBwrite" , 0 ,
530 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
531 "Count=[d] \n " , NULL
, NULL
} },
533 { SMBclose
, "SMBclose" , 0 ,
534 { "Handle=[d] \n Time=[T2]" , NULL
, NULL
, NULL
, NULL
} },
536 { SMBmkdir
, "SMBmkdir" , 0 ,
537 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
539 { SMBrmdir
, "SMBrmdir" , 0 ,
540 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
542 { SMBdskattr
, "SMBdskattr" , 0 ,
544 "TotalUnits=[d] \n BlocksPerUnit=[d] \n BlockSize=[d] \n FreeUnits=[d] \n Media=[w] \n " ,
548 { "Attrib=[A] \n " , "OldPath=[Z] \n NewPath=[Z] \n " , NULL
, NULL
, NULL
} },
551 * this is a Pathworks specific call, allowing the
552 * changing of the root path
554 { pSETDIR
, "SMBsetdir" , 0 , { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
556 { SMBlseek
, "SMBlseek" , 0 ,
557 { "Handle=[d] \n Mode=[w] \n Offset=[D] \n " , "Offset=[D] \n " , NULL
, NULL
, NULL
} },
559 { SMBflush
, "SMBflush" , 0 , { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
561 { SMBsplopen
, "SMBsplopen" , 0 ,
562 { "SetupLen=[d] \n Mode=[w] \n " , "Ident=[Z] \n " , "Handle=[d] \n " ,
565 { SMBsplclose
, "SMBsplclose" , 0 ,
566 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
568 { SMBsplretq
, "SMBsplretq" , 0 ,
569 { "MaxCount=[d] \n StartIndex=[d] \n " , NULL
,
570 "Count=[d] \n Index=[d] \n " ,
571 "*Time=[T2]Status=[B] \n JobID=[d] \n Size=[D] \n Res=[B]Name=[s16] \n " ,
574 { SMBsplwr
, "SMBsplwr" , 0 ,
575 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
577 { SMBlock
, "SMBlock" , 0 ,
578 { "Handle=[d] \n Count=[D] \n Offset=[D] \n " , NULL
, NULL
, NULL
, NULL
} },
580 { SMBunlock
, "SMBunlock" , 0 ,
581 { "Handle=[d] \n Count=[D] \n Offset=[D] \n " , NULL
, NULL
, NULL
, NULL
} },
583 /* CORE+ PROTOCOL FOLLOWS */
585 { SMBreadbraw
, "SMBreadbraw" , 0 ,
586 { "Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n Res=[d] \n " ,
587 NULL
, NULL
, NULL
, NULL
} },
589 { SMBwritebraw
, "SMBwritebraw" , 0 ,
590 { "Handle=[d] \n TotalCount=[d] \n Res=[w] \n Offset=[D] \n TimeOut=[D] \n WMode=[w] \n Res2=[W] \n |DataSize=[d] \n DataOff=[d] \n " ,
591 NULL
, "WriteRawAck" , NULL
, NULL
} },
593 { SMBwritec
, "SMBwritec" , 0 ,
594 { NULL
, NULL
, "Count=[d] \n " , NULL
, NULL
} },
596 { SMBwriteclose
, "SMBwriteclose" , 0 ,
597 { "Handle=[d] \n Count=[d] \n Offset=[D] \n Time=[T2]Res=([w,w,w,w,w,w])" ,
598 NULL
, "Count=[d] \n " , NULL
, NULL
} },
600 { SMBlockread
, "SMBlockread" , 0 ,
601 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
602 "Count=[d] \n Res=([w,w,w,w]) \n " , NULL
, NULL
} },
604 { SMBwriteunlock
, "SMBwriteunlock" , 0 ,
605 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
606 "Count=[d] \n " , NULL
, NULL
} },
608 { SMBreadBmpx
, "SMBreadBmpx" , 0 ,
609 { "Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n Res=[w] \n " ,
611 "Offset=[D] \n TotCount=[d] \n Remaining=[d] \n Res=([w,w]) \n DataSize=[d] \n DataOff=[d] \n " ,
614 { SMBwriteBmpx
, "SMBwriteBmpx" , 0 ,
615 { "Handle=[d] \n TotCount=[d] \n Res=[w] \n Offset=[D] \n TimeOut=[D] \n WMode=[w] \n Res2=[W] \n DataSize=[d] \n DataOff=[d] \n " , NULL
,
616 "Remaining=[d] \n " , NULL
, NULL
} },
618 { SMBwriteBs
, "SMBwriteBs" , 0 ,
619 { "Handle=[d] \n TotCount=[d] \n Offset=[D] \n Res=[W] \n DataSize=[d] \n DataOff=[d] \n " ,
620 NULL
, "Count=[d] \n " , NULL
, NULL
} },
622 { SMBsetattrE
, "SMBsetattrE" , 0 ,
623 { "Handle=[d] \n CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]" , NULL
,
624 NULL
, NULL
, NULL
} },
626 { SMBgetattrE
, "SMBgetattrE" , 0 ,
627 { "Handle=[d] \n " , NULL
,
628 "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D] \n AllocSize=[D] \n Attribute=[A] \n " ,
631 { SMBtranss
, "SMBtranss" , 0 , DEFDESCRIPT
},
632 { SMBioctls
, "SMBioctls" , 0 , DEFDESCRIPT
},
634 { SMBcopy
, "SMBcopy" , 0 ,
635 { "TreeID2=[d] \n OFun=[w] \n Flags=[w] \n " , "Path=[S] \n NewPath=[S] \n " ,
636 "CopyCount=[d] \n " , "|ErrStr=[S] \n " , NULL
} },
638 { SMBmove
, "SMBmove" , 0 ,
639 { "TreeID2=[d] \n OFun=[w] \n Flags=[w] \n " , "Path=[S] \n NewPath=[S] \n " ,
640 "MoveCount=[d] \n " , "|ErrStr=[S] \n " , NULL
} },
642 { SMBopenX
, "SMBopenX" , FLG_CHAIN
,
643 { "Com2=[w] \n Off2=[d] \n Flags=[w] \n Mode=[w] \n SearchAttrib=[A] \n Attrib=[A] \n Time=[T2]OFun=[w] \n Size=[D] \n TimeOut=[D] \n Res=[W] \n " ,
645 "Com2=[w] \n Off2=[d] \n Handle=[d] \n Attrib=[A] \n Time=[T2]Size=[D] \n Access=[w] \n Type=[w] \n State=[w] \n Action=[w] \n FileID=[W] \n Res=[w] \n " ,
648 { SMBreadX
, "SMBreadX" , FLG_CHAIN
,
649 { "Com2=[w] \n Off2=[d] \n Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n CountLeft=[d] \n " ,
651 "Com2=[w] \n Off2=[d] \n Remaining=[d] \n Res=[W] \n DataSize=[d] \n DataOff=[d] \n Res=([w,w,w,w]) \n " ,
654 { SMBwriteX
, "SMBwriteX" , FLG_CHAIN
,
655 { "Com2=[w] \n Off2=[d] \n Handle=[d] \n Offset=[D] \n TimeOut=[D] \n WMode=[w] \n CountLeft=[d] \n Res=[w] \n DataSize=[d] \n DataOff=[d] \n " ,
657 "Com2=[w] \n Off2=[d] \n Count=[d] \n Remaining=[d] \n Res=[W] \n " ,
660 { SMBlockingX
, "SMBlockingX" , FLG_CHAIN
,
661 { "Com2=[w] \n Off2=[d] \n Handle=[d] \n LockType=[w] \n TimeOut=[D] \n UnlockCount=[d] \n LockCount=[d] \n " ,
662 "*Process=[d] \n Offset=[D] \n Length=[D] \n " ,
663 "Com2=[w] \n Off2=[d] \n " , NULL
, NULL
} },
665 { SMBffirst
, "SMBffirst" , 0 ,
666 { "Count=[d] \n Attrib=[A] \n " ,
667 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
669 "BlkType=[B] \n BlkLen=[d] \n * \n Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n Attrib=[a] \n Time=[T1]Size=[D] \n Name=[s13] \n " ,
672 { SMBfunique
, "SMBfunique" , 0 ,
673 { "Count=[d] \n Attrib=[A] \n " ,
674 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
676 "BlkType=[B] \n BlkLen=[d] \n * \n Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n Attrib=[a] \n Time=[T1]Size=[D] \n Name=[s13] \n " ,
679 { SMBfclose
, "SMBfclose" , 0 ,
680 { "Count=[d] \n Attrib=[A] \n " ,
681 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
683 "BlkType=[B] \n BlkLen=[d] \n * \n Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n Attrib=[a] \n Time=[T1]Size=[D] \n Name=[s13] \n " ,
686 { SMBfindnclose
, "SMBfindnclose" , 0 ,
687 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
689 { SMBfindclose
, "SMBfindclose" , 0 ,
690 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
692 { SMBsends
, "SMBsends" , 0 ,
693 { NULL
, "Source=[Z] \n Dest=[Z] \n " , NULL
, NULL
, NULL
} },
695 { SMBsendstrt
, "SMBsendstrt" , 0 ,
696 { NULL
, "Source=[Z] \n Dest=[Z] \n " , "GroupID=[d] \n " , NULL
, NULL
} },
698 { SMBsendend
, "SMBsendend" , 0 ,
699 { "GroupID=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
701 { SMBsendtxt
, "SMBsendtxt" , 0 ,
702 { "GroupID=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
704 { SMBsendb
, "SMBsendb" , 0 ,
705 { NULL
, "Source=[Z] \n Dest=[Z] \n " , NULL
, NULL
, NULL
} },
707 { SMBfwdname
, "SMBfwdname" , 0 , DEFDESCRIPT
},
708 { SMBcancelf
, "SMBcancelf" , 0 , DEFDESCRIPT
},
709 { SMBgetmac
, "SMBgetmac" , 0 , DEFDESCRIPT
},
711 { SMBnegprot
, "SMBnegprot" , 0 ,
712 { NULL
, NULL
, NULL
, NULL
, print_negprot
} },
714 { SMBsesssetupX
, "SMBsesssetupX" , FLG_CHAIN
,
715 { NULL
, NULL
, NULL
, NULL
, print_sesssetup
} },
717 { SMBtconX
, "SMBtconX" , FLG_CHAIN
,
718 { "Com2=[w] \n Off2=[d] \n Flags=[w] \n PassLen=[d] \n Passwd&Path&Device= \n " ,
719 NULL
, "Com2=[w] \n Off2=[d] \n " , "ServiceType=[S] \n " , NULL
} },
721 { SMBtrans2
, "SMBtrans2" , 0 , { NULL
, NULL
, NULL
, NULL
, print_trans2
} },
723 { SMBtranss2
, "SMBtranss2" , 0 , DEFDESCRIPT
},
724 { SMBctemp
, "SMBctemp" , 0 , DEFDESCRIPT
},
725 { SMBreadBs
, "SMBreadBs" , 0 , DEFDESCRIPT
},
726 { SMBtrans
, "SMBtrans" , 0 , { NULL
, NULL
, NULL
, NULL
, print_trans
} },
728 { SMBnttrans
, "SMBnttrans" , 0 , DEFDESCRIPT
},
729 { SMBnttranss
, "SMBnttranss" , 0 , DEFDESCRIPT
},
731 { SMBntcreateX
, "SMBntcreateX" , FLG_CHAIN
,
732 { "Com2=[w] \n Off2=[d] \n Res=[b] \n NameLen=[d] \n Flags=[W] \n RootDirectoryFid=[D] \n AccessMask=[W] \n AllocationSize=[L] \n ExtFileAttributes=[W] \n ShareAccess=[W] \n CreateDisposition=[W] \n CreateOptions=[W] \n ImpersonationLevel=[W] \n SecurityFlags=[b] \n " ,
734 "Com2=[w] \n Off2=[d] \n OplockLevel=[b] \n Fid=[d] \n CreateAction=[W] \n CreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W] \n AllocationSize=[L] \n EndOfFile=[L] \n FileType=[w] \n DeviceState=[w] \n Directory=[b] \n " ,
737 { SMBntcancel
, "SMBntcancel" , 0 , DEFDESCRIPT
},
739 { - 1 , NULL
, 0 , DEFDESCRIPT
}
744 * print a SMB message
747 print_smb ( const u_char
* buf
, const u_char
* maxbuf
)
750 const u_char
* words
, * maxwords
, * data
;
752 const char * fmt_smbheader
=
753 "[P4]SMB Command = [B] \n Error class = [BP1] \n Error code = [d] \n Flags1 = [B] \n Flags2 = [B][P13] \n Tree ID = [d] \n Proc ID = [d] \n UID = [d] \n MID = [d] \n Word Count = [b] \n " ;
757 request
= ( buf
[ 9 ] & 0x80 ) ? 0 : 1 ;
761 fn
= smbfind ( command
, smb_fns
);
766 printf ( "SMB PACKET: %s (%s) \n " , fn
-> name
, request
? "REQUEST" : "REPLY" );
771 /* print out the header */
772 smb_fdata ( buf
, fmt_smbheader
, buf
+ 33 );
775 printf ( "SMBError = %s \n " , smb_errstr ( buf
[ 5 ], EXTRACT_LE_16BITS (& buf
[ 7 ])));
785 words
= buf
+ smboffset
;
788 data
= words
+ 1 + wct
* 2 ;
789 maxwords
= SMBMIN ( data
, maxbuf
);
792 f1
= fn
-> descript
. req_f1
;
793 f2
= fn
-> descript
. req_f2
;
795 f1
= fn
-> descript
. rep_f1
;
796 f2
= fn
-> descript
. rep_f2
;
800 (* fn
-> descript
. fn
)( words
, data
, buf
, maxbuf
);
804 smb_fdata ( words
+ 1 , f1
, maxwords
);
809 for ( i
= 0 ; & words
[ 1 + 2 * i
] < maxwords
; i
++) {
810 TCHECK2 ( words
[ 1 + 2 * i
], 2 );
811 v
= EXTRACT_LE_16BITS ( words
+ 1 + 2 * i
);
812 printf ( "smb_vwv[%d]=%d (0x%X) \n " , i
, v
, v
);
818 bcc
= EXTRACT_LE_16BITS ( data
);
819 printf ( "smb_bcc=%u \n " , bcc
);
822 smb_fdata ( data
+ 2 , f2
, data
+ 2 + bcc
);
825 printf ( "smb_buf[]= \n " );
826 print_data ( data
+ 2 , SMBMIN ( bcc
, PTR_DIFF ( maxbuf
, data
+ 2 )));
831 if (( fn
-> flags
& FLG_CHAIN
) == 0 )
839 TCHECK2 ( words
[ 3 ], 2 );
840 newsmboffset
= EXTRACT_LE_16BITS ( words
+ 3 );
842 fn
= smbfind ( command
, smb_fns
);
844 printf ( " \n SMB PACKET: %s (%s) (CHAINED) \n " ,
845 fn
-> name
, request
? "REQUEST" : "REPLY" );
846 if ( newsmboffset
< smboffset
) {
847 printf ( "Bad andX offset: %u < %u \n " , newsmboffset
, smboffset
);
850 smboffset
= newsmboffset
;
862 * print a NBT packet received across tcp on port 139
865 nbt_tcp_print ( const u_char
* data
, int length
)
867 const u_char
* maxbuf
= data
+ length
;
873 nbt_len
= EXTRACT_16BITS ( data
+ 2 );
880 printf ( " NBT Session Packet: " );
883 printf ( "Session Message" );
887 printf ( "Session Request" );
891 printf ( "Session Granted" );
901 printf ( "Session Reject, " );
904 printf ( "Not listening on called name" );
907 printf ( "Not listening for calling name" );
910 printf ( "Called name not present" );
913 printf ( "Called name present, but insufficient resources" );
916 printf ( "Unspecified error 0x%X" , ecode
);
923 printf ( "Session Keepalive" );
927 data
= smb_fdata ( data
, "Unknown packet type [rB]" , maxbuf
);
931 printf ( " \n >>> NBT Session Packet \n " );
934 data
= smb_fdata ( data
, "[P1]NBT Session Message \n Flags=[B] \n Length=[rd] \n " ,
938 if ( memcmp ( data
, " \377 SMB" , 4 ) == 0 ) {
939 if ( nbt_len
> PTR_DIFF ( maxbuf
, data
))
940 printf ( "WARNING: Short packet. Try increasing the snap length (%lu) \n " ,
941 ( unsigned long ) PTR_DIFF ( maxbuf
, data
));
942 print_smb ( data
, maxbuf
> data
+ nbt_len
? data
+ nbt_len
: maxbuf
);
944 printf ( "Session packet:(raw data?) \n " );
948 data
= smb_fdata ( data
,
949 "[P1]NBT Session Request \n Flags=[B] \n Length=[rd] \n Destination=[n1] \n Source=[n1] \n " ,
954 data
= smb_fdata ( data
, "[P1]NBT Session Granted \n Flags=[B] \n Length=[rd] \n " , maxbuf
);
964 data
= smb_fdata ( data
, "[P1]NBT SessionReject \n Flags=[B] \n Length=[rd] \n Reason=[B] \n " ,
968 printf ( "Not listening on called name \n " );
971 printf ( "Not listening for calling name \n " );
974 printf ( "Called name not present \n " );
977 printf ( "Called name present, but insufficient resources \n " );
980 printf ( "Unspecified error 0x%X \n " , ecode
);
987 data
= smb_fdata ( data
, "[P1]NBT Session Keepalive \n Flags=[B] \n Length=[rd] \n " , maxbuf
);
991 data
= smb_fdata ( data
, "NBT - Unknown packet type \n Type=[B] \n " , maxbuf
);
1005 * print a NBT packet received across udp on port 137
1008 nbt_udp137_print ( const u_char
* data
, int length
)
1010 const u_char
* maxbuf
= data
+ length
;
1011 int name_trn_id
, response
, opcode
, nm_flags
, rcode
;
1012 int qdcount
, ancount
, nscount
, arcount
;
1013 const char * opcodestr
;
1017 TCHECK2 ( data
[ 10 ], 2 );
1018 name_trn_id
= EXTRACT_16BITS ( data
);
1019 response
= ( data
[ 2 ] >> 7 );
1020 opcode
= ( data
[ 2 ] >> 3 ) & 0xF ;
1021 nm_flags
= (( data
[ 2 ] & 0x7 ) << 4 ) + ( data
[ 3 ] >> 4 );
1022 rcode
= data
[ 3 ] & 0xF ;
1023 qdcount
= EXTRACT_16BITS ( data
+ 4 );
1024 ancount
= EXTRACT_16BITS ( data
+ 6 );
1025 nscount
= EXTRACT_16BITS ( data
+ 8 );
1026 arcount
= EXTRACT_16BITS ( data
+ 10 );
1035 printf ( "NBT UDP PACKET(137): " );
1038 case 0 : opcodestr
= "QUERY" ; break ;
1039 case 5 : opcodestr
= "REGISTRATION" ; break ;
1040 case 6 : opcodestr
= "RELEASE" ; break ;
1041 case 7 : opcodestr
= "WACK" ; break ;
1042 case 8 : opcodestr
= "REFRESH(8)" ; break ;
1043 case 9 : opcodestr
= "REFRESH" ; break ;
1044 case 15 : opcodestr
= "MULTIHOMED REGISTRATION" ; break ;
1045 default : opcodestr
= "OPUNKNOWN" ; break ;
1047 printf ( "%s" , opcodestr
);
1050 printf ( "; NEGATIVE" );
1052 printf ( "; POSITIVE" );
1056 printf ( "; RESPONSE" );
1058 printf ( "; REQUEST" );
1061 printf ( "; BROADCAST" );
1063 printf ( "; UNICAST" );
1068 printf ( " \n TrnID=0x%X \n OpCode=%d \n NmFlags=0x%X \n Rcode=%d \n QueryCount=%d \n AnswerCount=%d \n AuthorityCount=%d \n AddressRecCount=%d \n " ,
1069 name_trn_id
, opcode
, nm_flags
, rcode
, qdcount
, ancount
, nscount
,
1074 total
= ancount
+ nscount
+ arcount
;
1076 if ( qdcount
> 100 || total
> 100 ) {
1077 printf ( "Corrupt packet?? \n " );
1082 printf ( "QuestionRecords: \n " );
1083 for ( i
= 0 ; i
< qdcount
; i
++)
1085 "|Name=[n1] \n QuestionType=[rw] \n QuestionClass=[rw] \n #" ,
1092 printf ( " \n ResourceRecords: \n " );
1093 for ( i
= 0 ; i
< total
; i
++) {
1097 p
= smb_fdata ( p
, "Name=[n1] \n #" , maxbuf
);
1100 restype
= EXTRACT_16BITS ( p
);
1101 p
= smb_fdata ( p
, "ResType=[rw] \n ResClass=[rw] \n TTL=[rD] \n " , p
+ 8 );
1104 rdlen
= EXTRACT_16BITS ( p
);
1105 printf ( "ResourceLength=%d \n ResourceData= \n " , rdlen
);
1108 p
= smb_fdata ( p
, "AddrType=[rw] \n Address=[b.b.b.b] \n " , p
+ rdlen
);
1112 if ( restype
== 0x21 ) {
1117 p
= smb_fdata ( p
, "NumNames=[B] \n " , p
+ 1 );
1120 while ( numnames
--) {
1121 p
= smb_fdata ( p
, "Name=[n2] \t #" , maxbuf
);
1125 switch ( p
[ 0 ] & 0x60 ) {
1126 case 0x00 : printf ( "B " ); break ;
1127 case 0x20 : printf ( "P " ); break ;
1128 case 0x40 : printf ( "M " ); break ;
1129 case 0x60 : printf ( "_ " ); break ;
1132 printf ( "<DEREGISTERING> " );
1134 printf ( "<CONFLICT> " );
1136 printf ( "<ACTIVE> " );
1138 printf ( "<PERMANENT> " );
1143 print_data ( p
, min ( rdlen
, length
- ( p
- data
)));
1151 smb_fdata ( p
, "AdditionalData: \n " , maxbuf
);
1165 * print a NBT packet received across udp on port 138
1168 nbt_udp138_print ( const u_char
* data
, int length
)
1170 const u_char
* maxbuf
= data
+ length
;
1172 if ( maxbuf
> snapend
)
1179 printf ( "NBT UDP PACKET(138)" );
1183 data
= smb_fdata ( data
,
1184 " \n >>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw] \n SourceName=[n1] \n DestName=[n1] \n #" ,
1188 /* If there isn't enough data for "\377SMB", don't check for it. */
1189 if (& data
[ 3 ] >= maxbuf
)
1192 if ( memcmp ( data
, " \377 SMB" , 4 ) == 0 )
1193 print_smb ( data
, maxbuf
);
1202 print netbeui frames
1204 struct nbf_strings
{
1206 const char * nonverbose
;
1207 const char * verbose
;
1208 } nbf_strings
[ 0x20 ] = {
1209 { "Add Group Name Query" , ", [P23]Name to add=[n2]#" ,
1210 "[P5]ResponseCorrelator=[w] \n [P16]Name to add=[n2] \n " },
1211 { "Add Name Query" , ", [P23]Name to add=[n2]#" ,
1212 "[P5]ResponseCorrelator=[w] \n [P16]Name to add=[n2] \n " },
1213 { "Name In Conflict" , NULL
, NULL
},
1214 { "Status Query" , NULL
, NULL
},
1215 { NULL
, NULL
, NULL
}, /* not used */
1216 { NULL
, NULL
, NULL
}, /* not used */
1217 { NULL
, NULL
, NULL
}, /* not used */
1218 { "Terminate Trace" , NULL
, NULL
},
1220 "[P7]Destination=[n2] \n Source=[n2] \n " },
1221 { "Broadcast Datagram" , NULL
,
1222 "[P7]Destination=[n2] \n Source=[n2] \n " },
1223 { "Name Query" , ", [P7]Name=[n2]#" ,
1224 "[P1]SessionNumber=[B] \n NameType=[B][P2] \n ResponseCorrelator=[w] \n Name=[n2] \n Name of sender=[n2] \n " },
1225 { NULL
, NULL
, NULL
}, /* not used */
1226 { NULL
, NULL
, NULL
}, /* not used */
1227 { "Add Name Response" , ", [P1]GroupName=[w] [P4]Destination=[n2] Source=[n2]#" ,
1228 "AddNameInProcess=[B] \n GroupName=[w] \n TransmitCorrelator=[w][P2] \n Destination=[n2] \n Source=[n2] \n " },
1229 { "Name Recognized" , NULL
,
1230 "[P1]Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n Destination=[n2] \n Source=[n2] \n " },
1231 { "Status Response" , NULL
, NULL
},
1232 { NULL
, NULL
, NULL
}, /* not used */
1233 { NULL
, NULL
, NULL
}, /* not used */
1234 { NULL
, NULL
, NULL
}, /* not used */
1235 { "Terminate Trace" , NULL
, NULL
},
1237 "[P3]TransmitCorrelator=[w][P2] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1238 { "Data First/Middle" , NULL
,
1239 "Flags=[{RECEIVE_CONTINUE|NO_ACK||PIGGYBACK_ACK_INCLUDED|}] \n ResyncIndicator=[w][P2] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1240 { "Data Only/Last" , NULL
,
1241 "Flags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}] \n ResyncIndicator=[w][P2] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1242 { "Session Confirm" , NULL
,
1243 "Data1=[B] \n Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1244 { "Session End" , NULL
,
1245 "[P1]Data2=[w][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1246 { "Session Initialize" , NULL
,
1247 "Data1=[B] \n Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1248 { "No Receive" , NULL
,
1249 "Flags=[{|SEND_NO_ACK}] \n DataBytesAccepted=[b][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1250 { "Receive Outstanding" , NULL
,
1251 "[P1]DataBytesAccepted=[b][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1252 { "Receive Continue" , NULL
,
1253 "[P2]TransmitCorrelator=[w] \n [P2]RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1254 { NULL
, NULL
, NULL
}, /* not used */
1255 { NULL
, NULL
, NULL
}, /* not used */
1256 { "Session Alive" , NULL
, NULL
}
1260 netbeui_print ( u_short control
, const u_char
* data
, int length
)
1262 const u_char
* maxbuf
= data
+ length
;
1265 const u_char
* data2
;
1266 int is_truncated
= 0 ;
1268 if ( maxbuf
> snapend
)
1271 len
= EXTRACT_LE_16BITS ( data
);
1274 if ( data2
>= maxbuf
) {
1282 printf ( "NBF Packet: " );
1283 data
= smb_fdata ( data
, "[P5]#" , maxbuf
);
1285 printf ( " \n >>> NBF Packet \n Type=0x%X " , control
);
1286 data
= smb_fdata ( data
, "Length=[d] Signature=[w] Command=[B] \n #" , maxbuf
);
1291 if ( command
> 0x1f || nbf_strings
[ command
]. name
== NULL
) {
1293 data
= smb_fdata ( data
, "Unknown NBF Command#" , data2
);
1295 data
= smb_fdata ( data
, "Unknown NBF Command \n " , data2
);
1298 printf ( "%s" , nbf_strings
[ command
]. name
);
1299 if ( nbf_strings
[ command
]. nonverbose
!= NULL
)
1300 data
= smb_fdata ( data
, nbf_strings
[ command
]. nonverbose
, data2
);
1302 printf ( "%s: \n " , nbf_strings
[ command
]. name
);
1303 if ( nbf_strings
[ command
]. verbose
!= NULL
)
1304 data
= smb_fdata ( data
, nbf_strings
[ command
]. verbose
, data2
);
1317 /* data2 was past the end of the buffer */
1321 /* If this isn't a command that would contain an SMB message, quit. */
1322 if ( command
!= 0x08 && command
!= 0x09 && command
!= 0x15 &&
1326 /* If there isn't enough data for "\377SMB", don't look for it. */
1327 if (& data2
[ 3 ] >= maxbuf
)
1330 if ( memcmp ( data2
, " \377 SMB" , 4 ) == 0 )
1331 print_smb ( data2
, maxbuf
);
1334 for ( i
= 0 ; i
< 128 ; i
++) {
1335 if (& data2
[ i
+ 3 ] >= maxbuf
)
1337 if ( memcmp (& data2
[ i
], " \377 SMB" , 4 ) == 0 ) {
1338 printf ( "found SMB packet at %d \n " , i
);
1339 print_smb (& data2
[ i
], maxbuf
);
1355 * print IPX-Netbios frames
1358 ipx_netbios_print ( const u_char
* data
, u_int length
)
1361 * this is a hack till I work out how to parse the rest of the
1362 * NetBIOS-over-IPX stuff
1365 const u_char
* maxbuf
;
1367 maxbuf
= data
+ length
;
1368 /* Don't go past the end of the captured data in the packet. */
1369 if ( maxbuf
> snapend
)
1372 for ( i
= 0 ; i
< 128 ; i
++) {
1373 if (& data
[ i
+ 4 ] > maxbuf
)
1375 if ( memcmp (& data
[ i
], " \377 SMB" , 4 ) == 0 ) {
1376 smb_fdata ( data
, " \n >>> IPX transport " , & data
[ i
]);
1378 print_smb (& data
[ i
], maxbuf
);
1385 smb_fdata ( data
, " \n >>> Unknown IPX " , maxbuf
);