#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.45 2007-07-14 22:28:36 guy Exp $";
-#endif
-
#include <tcpdump-stdinc.h>
#include <stdio.h>
#include "extract.h"
#include "smb.h"
+static const char tstr[] = "[|SMB]";
+
static int request = 0;
static int unicodestr = 0;
#define FLG_CHAIN (1 << 0)
-static struct smbfns *
-smbfind(int id, struct smbfns *list)
+static const struct smbfns *
+smbfind(int id, const struct smbfns *list)
{
int sindex;
return(&list[0]);
}
-static struct smbfnsint *
-smbfindint(int id, struct smbfnsint *list)
+static const struct smbfnsint *
+smbfindint(int id, const struct smbfnsint *list)
{
int sindex;
}
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
-struct smbfnsint trans2_fns[] = {
+static const struct smbfnsint trans2_fns[] = {
{ 0, "TRANSACT2_OPEN", 0,
{ "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w, w, w, w, w])\nPath=[S]",
NULL,
print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
{
u_int bcc;
- static struct smbfnsint *fn = &trans2_fns[0];
+ static const struct smbfnsint *fn = &trans2_fns[0];
const u_char *data, *param;
const u_char *w = words + 1;
const char *f1 = NULL, *f2 = NULL;
}
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
}
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
}
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
}
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
}
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
}
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
-static struct smbfns smb_fns[] = {
+static const struct smbfns smb_fns[] = {
{ -1, "SMBunknown", 0, DEFDESCRIPT },
{ SMBtcon, "SMBtcon", 0,
int command;
u_int32_t nterror;
const u_char *words, *maxwords, *data;
- struct smbfns *fn;
+ const struct smbfns *fn;
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";
int smboffset;
if (command == 0xFF)
break;
TCHECK2(words[3], 2);
- newsmboffset = EXTRACT_LE_16BITS(words + 3);
+ newsmboffset = EXTRACT_LE_16BITS(words + 3);
fn = smbfind(command, smb_fns);
printf("\n");
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
}
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
fflush(stdout);
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
+/*
+ * Print an SMB-over-TCP packet received across tcp on port 445
+ */
+void
+smb_tcp_print (const u_char * data, int length)
+{
+ int caplen;
+ u_int smb_len;
+ const u_char *maxbuf;
+
+ if (length < 4)
+ goto trunc;
+ if (snapend < data)
+ goto trunc;
+ caplen = snapend - data;
+ if (caplen < 4)
+ goto trunc;
+ maxbuf = data + caplen;
+ smb_len = EXTRACT_24BITS(data + 1);
+ length -= 4;
+ caplen -= 4;
+
+ startbuf = data;
+ data += 4;
+ if (smb_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) {
+ if ((int)smb_len > caplen) {
+ if ((int)smb_len > length)
+ printf("WARNING: Packet is continued in later TCP segments\n");
+ else
+ printf("WARNING: Short packet. Try increasing the snap length by %d\n",
+ smb_len - caplen);
+ }
+ print_smb(data, maxbuf > data + smb_len ? data + smb_len : maxbuf);
+ } else
+ printf("SMB-over-TCP packet:(raw data or continuation?)\n");
+ return;
+trunc:
+ printf("%s", tstr);
+ return;
+}
/*
* print a NBT packet received across udp on port 138
printf("\n");
return;
trunc:
- printf("[|SMB]");
+ printf("%s", tstr);
return;
}
break;
if (memcmp(&data[i], "\377SMB", 4) == 0) {
smb_fdata(data, "\n>>> IPX transport ", &data[i], 0);
- if (data != NULL)
- print_smb(&data[i], maxbuf);
+ print_smb(&data[i], maxbuf);
printf("\n");
fflush(stdout);
break;