X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3b8eb6c73024c35643be55c96d0a1b90010daf28..refs/heads/tcpdump-3.8:/print-smb.c diff --git a/print-smb.c b/print-smb.c index fb53dc2e..dc6cd3ea 100644 --- a/print-smb.c +++ b/print-smb.c @@ -11,13 +11,14 @@ #endif #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.20 2002-01-17 04:38:29 guy Exp $"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.27.2.2 2003-11-16 08:51:45 guy Exp $"; #endif +#include + #include #include -#include #include "interface.h" #include "extract.h" @@ -168,12 +169,12 @@ struct smbfnsint trans2_fns[] = { static void -print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf) +print_trans2(const u_char *words, const u_char *dat _U_, const u_char *buf, const u_char *maxbuf) { static struct smbfnsint *fn = &trans2_fns[0]; const u_char *data, *param; const u_char *w = words + 1; - const u_char *f1 = NULL, *f2 = NULL; + const char *f1 = NULL, *f2 = NULL; int pcnt, dcnt; TCHECK(words[0]); @@ -224,8 +225,8 @@ print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_ if (fn->descript.fn) (*fn->descript.fn)(param, data, pcnt, dcnt); else { - smb_fdata(param, f1 ? f1 : (u_char *)"Paramaters=\n", param + pcnt); - smb_fdata(data, f2 ? f2 : (u_char *)"Data=\n", data + dcnt); + smb_fdata(param, f1 ? f1 : "Parameters=\n", param + pcnt); + smb_fdata(data, f2 ? f2 : "Data=\n", data + dcnt); } return; trunc: @@ -329,7 +330,7 @@ print_ipc(const u_char *param, int paramlen, const u_char *data, int datalen) static void print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf) { - const u_char *f1, *f2, *f3, *f4; + const char *f1, *f2, *f3, *f4; const u_char *data, *param; const u_char *w = words + 1; int datalen, paramlen; @@ -359,12 +360,12 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf)); smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen)); - if (!strcmp(data1 + 2, "\\MAILSLOT\\BROWSE")) { + if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) { print_browse(param, paramlen, data, datalen); return; } - if (!strcmp(data1 + 2, "\\PIPE\\LANMAN")) { + if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) { print_ipc(param, paramlen, data, datalen); return; } @@ -381,27 +382,28 @@ trunc: static void -print_negprot(const u_char *words, const u_char *data, const u_char *buf, const u_char *maxbuf) +print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf) { - u_char *f1 = NULL, *f2 = NULL; + u_int wcnt; + const char *f1 = NULL, *f2 = NULL; TCHECK(words[0]); + wcnt = words[0]; if (request) f2 = "*|Dialect=[Z]\n"; else { - if (words[0] == 1) + if (wcnt == 1) f1 = "Core Protocol\nDialectIndex=[d]"; - else if (words[0] == 17) + else if (wcnt == 17) f1 = "NT1 Protocol\nDialectIndex=[d]\nSecMode=[B]\nMaxMux=[d]\nNumVcs=[d]\nMaxBuffer=[D]\nRawSize=[D]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[d]\nCryptKey="; - else if (words[0] == 13) + else if (wcnt == 13) 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="; } if (f1) - smb_fdata(words + 1, f1, SMBMIN(words + 1 + words[0] * 2, maxbuf)); + smb_fdata(words + 1, f1, SMBMIN(words + 1 + wcnt * 2, maxbuf)); else - print_data(words + 1, SMBMIN(words[0] * 2, - PTR_DIFF(maxbuf, words + 1))); + print_data(words + 1, SMBMIN(wcnt * 2, PTR_DIFF(maxbuf, words + 1))); TCHECK2(*data, 2); if (f2) @@ -415,10 +417,10 @@ trunc: } static void -print_sesssetup(const u_char *words, const u_char *data, const u_char *buf, const u_char *maxbuf) +print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf) { - int wcnt; - u_char *f1 = NULL, *f2 = NULL; + u_int wcnt; + const char *f1 = NULL, *f2 = NULL; TCHECK(words[0]); wcnt = words[0]; @@ -428,19 +430,18 @@ print_sesssetup(const u_char *words, const u_char *data, const u_char *buf, cons else 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"; } else { - if (words[0] == 3) { + if (wcnt == 3) { f1 = "Com2=[w]\nOff2=[d]\nAction=[w]\n"; - } else if (words[0] == 13) { + } else if (wcnt == 13) { f1 = "Com2=[B]\nRes=[B]\nOff2=[d]\nAction=[w]\n"; f2 = "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n"; } } if (f1) - smb_fdata(words + 1, f1, SMBMIN(words + 1 + words[0] * 2, maxbuf)); + smb_fdata(words + 1, f1, SMBMIN(words + 1 + wcnt * 2, maxbuf)); else - print_data(words + 1, SMBMIN(words[0] * 2, - PTR_DIFF(maxbuf, words + 1))); + print_data(words + 1, SMBMIN(wcnt * 2, PTR_DIFF(maxbuf, words + 1))); TCHECK2(*data, 2); if (f2) @@ -538,7 +539,7 @@ static struct smbfns smb_fns[] = { { pSETDIR, "SMBsetdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBlseek, "SMBlseek", 0, - { "Handle=[d]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL, NULL } }, + { "Handle=[d]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL, NULL, NULL } }, { SMBflush, "SMBflush", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, @@ -716,7 +717,7 @@ static struct smbfns smb_fns[] = { { "Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[d]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n", "Path=[S]\n", "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", - NULL } }, + NULL, NULL } }, { SMBntcancel, "SMBntcancel", 0, DEFDESCRIPT }, @@ -733,7 +734,7 @@ print_smb(const u_char *buf, const u_char *maxbuf) int command; const u_char *words, *data; struct smbfns *fn; - char *fmt_smbheader = + const char *fmt_smbheader = "[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"; @@ -762,9 +763,9 @@ print_smb(const u_char *buf, const u_char *maxbuf) TCHECK(words[0]); for (;;) { - const u_char *f1, *f2; + const char *f1, *f2; int wct; - int bcc; + u_int bcc; TCHECK(words[0]); wct = words[0]; @@ -805,7 +806,7 @@ print_smb(const u_char *buf, const u_char *maxbuf) smb_fdata(data + 2, f2, data + 2 + bcc); } } else { - printf("smb_bcc=%d\n", bcc); + printf("smb_bcc=%u\n", bcc); if (bcc > 0) { printf("smb_buf[]=\n"); print_data(data + 2, SMBMIN(bcc, PTR_DIFF(maxbuf, data + 2))); @@ -846,7 +847,7 @@ nbt_tcp_print(const u_char *data, int length) { const u_char *maxbuf = data + length; int flags; - int nbt_len; + u_int nbt_len; TCHECK2(data[2], 2); flags = data[0]; @@ -857,9 +858,9 @@ nbt_tcp_print(const u_char *data, int length) return; if (vflag > 1) - printf ("\n>>> "); + printf ("\n>>>"); - printf("NBT Packet"); + printf(" NBT Packet"); if (vflag < 2) return; @@ -948,8 +949,8 @@ nbt_udp137_print(const u_char *data, int length) const u_char *maxbuf = data + length; int name_trn_id, response, opcode, nm_flags, rcode; int qdcount, ancount, nscount, arcount; - char *opcodestr; - const char *p; + const char *opcodestr; + const u_char *p; int total, i; TCHECK2(data[10], 2); @@ -1078,14 +1079,14 @@ nbt_udp137_print(const u_char *data, int length) p += 2; } } else { - print_data(p, min(rdlen, length - ((const u_char *)p - data))); + print_data(p, min(rdlen, length - (p - data))); p += rdlen; } } } } - if ((u_char*)p < maxbuf) + if (p < maxbuf) smb_fdata(p, "AdditionalData:\n", maxbuf); out: