summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfenner <fenner>2001-09-17 21:57:50 +0000
committerfenner <fenner>2001-09-17 21:57:50 +0000
commitc672f002763b3a4fc30ca229e57f50d3b2e6d766 (patch)
treeee681c42232037a77b9f4413202971bfd41bf0d9
parentd5c621ba52626b1cc9778850bf7997cc227d230d (diff)
downloadtcpdump-c672f002763b3a4fc30ca229e57f50d3b2e6d766.tar.gz
Eliminate some unused parameters.
Use const more. Use EXTRACT_* macros more. Use TCHECK* more. Use tok2str() to replace some home-grown workalikes. smb: - Get rid of private types, use tcpdump-defined types - Rename fdata and fdata1 to smb_fdata and smb_fdata1 to avoid conflict with IRIX library function.
-rw-r--r--addrtoname.c60
-rw-r--r--addrtoname.h18
-rw-r--r--dhcp6opt.h4
-rw-r--r--extract.h36
-rw-r--r--interface.h24
-rw-r--r--nfsfh.h4
-rw-r--r--parsenfsfh.c6
-rw-r--r--print-802_11.c34
-rw-r--r--print-ah.c9
-rw-r--r--print-arcnet.c26
-rw-r--r--print-arp.c28
-rw-r--r--print-atalk.c8
-rw-r--r--print-bgp.c26
-rw-r--r--print-bootp.c35
-rw-r--r--print-bxxp.c6
-rw-r--r--print-cdp.c4
-rw-r--r--print-chdlc.c11
-rw-r--r--print-cip.c14
-rw-r--r--print-cnfp.c14
-rw-r--r--print-decnet.c6
-rw-r--r--print-dhcp6.c4
-rw-r--r--print-domain.c6
-rw-r--r--print-egp.c12
-rw-r--r--print-frag6.c10
-rw-r--r--print-igmp.c30
-rw-r--r--print-ip.c6
-rw-r--r--print-ip6.c16
-rw-r--r--print-isoclns.c91
-rw-r--r--print-smb.c210
-rw-r--r--smb.h22
-rw-r--r--smbutil.c50
-rw-r--r--telnet.h14
32 files changed, 398 insertions, 446 deletions
diff --git a/addrtoname.c b/addrtoname.c
index aff1c0fc..fb5320b4 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -23,7 +23,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.82 2001-06-28 10:27:08 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.83 2001-09-17 21:57:50 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -71,7 +71,7 @@ static RETSIGTYPE nohostname(int);
struct hnamemem {
u_int32_t addr;
- char *name;
+ const char *name;
struct hnamemem *nxt;
};
@@ -96,7 +96,7 @@ struct enamemem {
u_short e_addr0;
u_short e_addr1;
u_short e_addr2;
- char *e_name;
+ const char *e_name;
u_char *e_nsap; /* used only for nsaptable[] */
#define e_bs e_nsap /* for bytestringtable */
struct enamemem *e_nxt;
@@ -109,7 +109,7 @@ struct enamemem bytestringtable[HASHNAMESIZE];
struct protoidmem {
u_int32_t p_oui;
u_short p_proto;
- char *p_name;
+ const char *p_name;
struct protoidmem *p_nxt;
};
@@ -118,7 +118,7 @@ struct protoidmem protoidtable[HASHNAMESIZE];
/*
* A faster replacement for inet_ntoa().
*/
-char *
+const char *
intoa(u_int32_t addr)
{
register char *cp;
@@ -170,7 +170,7 @@ nohostname(int signo)
* Return a name for the IP address pointed to by ap. This address
* is assumed to be in network byte order.
*/
-char *
+const char *
getname(const u_char *ap)
{
register struct hostent *hp;
@@ -227,13 +227,13 @@ getname(const u_char *ap)
* Return a name for the IP6 address pointed to by ap. This address
* is assumed to be in network byte order.
*/
-char *
+const char *
getname6(const u_char *ap)
{
register struct hostent *hp;
struct in6_addr addr;
static struct h6namemem *p; /* static for longjmp() */
- register char *cp;
+ register const char *cp;
char ntop_buf[INET6_ADDRSTRLEN];
memcpy(&addr, ap, sizeof(addr));
@@ -281,7 +281,7 @@ getname6(const u_char *ap)
}
}
}
- cp = (char *)inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
+ cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
p->name = strdup(cp);
return (p->name);
}
@@ -326,7 +326,7 @@ lookup_emem(const u_char *ep)
*/
static inline struct enamemem *
-lookup_bytestring(register const u_char *bs, const int nlen)
+lookup_bytestring(register const u_char *bs, const unsigned int nlen)
{
struct enamemem *tp;
register u_int i, j, k;
@@ -347,7 +347,7 @@ lookup_bytestring(register const u_char *bs, const int nlen)
if (tp->e_addr0 == i &&
tp->e_addr1 == j &&
tp->e_addr2 == k &&
- memcmp((char *)bs, (char *)(tp->e_bs), nlen) == 0)
+ memcmp((const char *)bs, (const char *)(tp->e_bs), nlen) == 0)
return tp;
else
tp = tp->e_nxt;
@@ -371,7 +371,7 @@ static inline struct enamemem *
lookup_nsap(register const u_char *nsap)
{
register u_int i, j, k;
- int nlen = *nsap;
+ unsigned int nlen = *nsap;
struct enamemem *tp;
const u_char *ensap = nsap + nlen - 6;
@@ -389,7 +389,7 @@ lookup_nsap(register const u_char *nsap)
tp->e_addr1 == j &&
tp->e_addr2 == k &&
tp->e_nsap[0] == nlen &&
- memcmp((char *)&(nsap[1]),
+ memcmp((const char *)&(nsap[1]),
(char *)&(tp->e_nsap[1]), nlen) == 0)
return tp;
else
@@ -400,7 +400,7 @@ lookup_nsap(register const u_char *nsap)
tp->e_nsap = (u_char *)malloc(nlen + 1);
if (tp->e_nsap == NULL)
error("lookup_nsap: malloc");
- memcpy((char *)tp->e_nsap, (char *)nsap, nlen + 1);
+ memcpy((char *)tp->e_nsap, (const char *)nsap, nlen + 1);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
error("lookup_nsap: calloc");
@@ -436,7 +436,7 @@ lookup_protoid(const u_char *pi)
return tp;
}
-char *
+const char *
etheraddr_string(register const u_char *ep)
{
register u_int i, j;
@@ -450,7 +450,7 @@ etheraddr_string(register const u_char *ep)
#ifdef USE_ETHER_NTOHOST
if (!nflag) {
char buf[128];
- if (ether_ntohost(buf, (struct ether_addr *)ep) == 0) {
+ if (ether_ntohost(buf, (const struct ether_addr *)ep) == 0) {
tp->e_name = strdup(buf);
return (tp->e_name);
}
@@ -471,8 +471,8 @@ etheraddr_string(register const u_char *ep)
return (tp->e_name);
}
-char *
-linkaddr_string(const u_char *ep, const int len)
+const char *
+linkaddr_string(const u_char *ep, const unsigned int len)
{
register u_int i, j;
register char *cp;
@@ -501,7 +501,7 @@ linkaddr_string(const u_char *ep, const int len)
return (tp->e_name);
}
-char *
+const char *
etherproto_string(u_short port)
{
register char *cp;
@@ -527,7 +527,7 @@ etherproto_string(u_short port)
return (tp->name);
}
-char *
+const char *
protoid_string(register const u_char *pi)
{
register u_int i, j;
@@ -554,7 +554,7 @@ protoid_string(register const u_char *pi)
return (tp->p_name);
}
-char *
+const char *
llcsap_string(u_char sap)
{
register struct hnamemem *tp;
@@ -573,7 +573,7 @@ llcsap_string(u_char sap)
return (tp->name);
}
-char *
+const char *
isonsap_string(const u_char *nsap)
{
register u_int i, nlen = nsap[0];
@@ -598,7 +598,7 @@ isonsap_string(const u_char *nsap)
return (tp->e_name);
}
-char *
+const char *
tcpport_string(u_short port)
{
register struct hnamemem *tp;
@@ -617,7 +617,7 @@ tcpport_string(u_short port)
return (tp->name);
}
-char *
+const char *
udpport_string(register u_short port)
{
register struct hnamemem *tp;
@@ -691,8 +691,8 @@ init_eprotoarray(void)
}
static struct protoidlist {
- u_char protoid[5];
- char *name;
+ const u_char protoid[5];
+ const char *name;
} protoidlist[] = {
{{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" },
{{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" },
@@ -736,8 +736,8 @@ init_protoidarray(void)
}
static struct etherlist {
- u_char addr[6];
- char *name;
+ const u_char addr[6];
+ const char *name;
} etherlist[] = {
{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" },
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL }
@@ -788,7 +788,7 @@ init_etherarray(void)
#ifdef USE_ETHER_NTOHOST
/* Use yp/nis version of name if available */
- if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) {
+ if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
tp->e_name = strdup(name);
continue;
}
@@ -858,7 +858,7 @@ init_addrtoname(u_int32_t localnet, u_int32_t mask)
init_protoidarray();
}
-char *
+const char *
dnaddr_string(u_short dnaddr)
{
register struct hnamemem *tp;
diff --git a/addrtoname.h b/addrtoname.h
index 6c170126..1a35f4c8 100644
--- a/addrtoname.h
+++ b/addrtoname.h
@@ -18,21 +18,21 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.17 2001-06-18 09:12:28 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.18 2001-09-17 21:57:51 fenner Exp $ (LBL)
*/
/* Name to address translation routines. */
-extern char *linkaddr_string(const u_char *, const int);
-extern char *etheraddr_string(const u_char *);
-extern char *etherproto_string(u_short);
-extern char *tcpport_string(u_short);
-extern char *udpport_string(u_short);
-extern char *getname(const u_char *);
+extern const char *linkaddr_string(const u_char *, const unsigned int);
+extern const char *etheraddr_string(const u_char *);
+extern const char *etherproto_string(u_short);
+extern const char *tcpport_string(u_short);
+extern const char *udpport_string(u_short);
+extern const char *getname(const u_char *);
#ifdef INET6
-extern char *getname6(const u_char *);
+extern const char *getname6(const u_char *);
#endif
-extern char *intoa(u_int32_t);
+extern const char *intoa(u_int32_t);
extern void init_addrtoname(u_int32_t, u_int32_t);
extern struct hnamemem *newhnamemem(void);
diff --git a/dhcp6opt.h b/dhcp6opt.h
index a9428259..fac577d3 100644
--- a/dhcp6opt.h
+++ b/dhcp6opt.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6opt.h,v 1.3 2000-12-17 23:07:49 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6opt.h,v 1.4 2001-09-17 21:57:51 fenner Exp $ (LBL) */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@@ -47,7 +47,7 @@
struct dhcp6_opt {
u_int code;
int len;
- char *name;
+ const char *name;
int type;
};
diff --git a/extract.h b/extract.h
index 6aa21e87..0117f389 100644
--- a/extract.h
+++ b/extract.h
@@ -18,40 +18,40 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.16 2000-10-03 02:54:55 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.17 2001-09-17 21:57:52 fenner Exp $ (LBL)
*/
/* Network to host order macros */
#ifdef LBL_ALIGN
#define EXTRACT_16BITS(p) \
- ((u_int16_t)*((u_int8_t *)(p) + 0) << 8 | \
- (u_int16_t)*((u_int8_t *)(p) + 1))
+ ((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
+ (u_int16_t)*((const u_int8_t *)(p) + 1))
#define EXTRACT_32BITS(p) \
- ((u_int32_t)*((u_int8_t *)(p) + 0) << 24 | \
- (u_int32_t)*((u_int8_t *)(p) + 1) << 16 | \
- (u_int32_t)*((u_int8_t *)(p) + 2) << 8 | \
- (u_int32_t)*((u_int8_t *)(p) + 3))
+ ((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 3))
#else
#define EXTRACT_16BITS(p) \
- ((u_int16_t)ntohs(*(u_int16_t *)(p)))
+ ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
#define EXTRACT_32BITS(p) \
- ((u_int32_t)ntohl(*(u_int32_t *)(p)))
+ ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
#endif
#define EXTRACT_24BITS(p) \
- ((u_int32_t)*((u_int8_t *)(p) + 0) << 16 | \
- (u_int32_t)*((u_int8_t *)(p) + 1) << 8 | \
- (u_int32_t)*((u_int8_t *)(p) + 2))
+ ((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 2))
/* Little endian protocol host order macros */
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
- ((u_int16_t)*((u_int8_t *)(p) + 1) << 8 | \
- (u_int16_t)*((u_int8_t *)(p) + 0))
+ ((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
+ (u_int16_t)*((const u_int8_t *)(p) + 0))
#define EXTRACT_LE_32BITS(p) \
- ((u_int32_t)*((u_int8_t *)(p) + 3) << 24 | \
- (u_int32_t)*((u_int8_t *)(p) + 2) << 16 | \
- (u_int32_t)*((u_int8_t *)(p) + 1) << 8 | \
- (u_int32_t)*((u_int8_t *)(p) + 0))
+ ((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
+ (u_int32_t)*((const u_int8_t *)(p) + 0))
diff --git a/interface.h b/interface.h
index 6eb19db5..1db7c7b5 100644
--- a/interface.h
+++ b/interface.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.170 2001-09-17 20:06:17 fenner Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.171 2001-09-17 21:57:52 fenner Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -61,7 +61,7 @@ extern char *strdup(const char *);
struct tok {
int v; /* value */
- char *s; /* string */
+ const char *s; /* string */
};
extern int aflag; /* translate network and broadcast addresses */
@@ -134,7 +134,7 @@ extern const u_char *packetp;
extern const u_char *snapend;
/* True if "l" bytes of "var" were captured */
-#define TTEST2(var, l) ((u_char *)&(var) <= snapend - (l))
+#define TTEST2(var, l) ((const u_char *)&(var) <= snapend - (l))
/* True if "var" was captured */
#define TTEST(var) TTEST2(var, sizeof(var))
@@ -151,7 +151,7 @@ extern void relts_print(int);
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
extern const char *tok2str(const struct tok *, const char *, int);
-extern char *dnaddr_string(u_short);
+extern const char *dnaddr_string(u_short);
extern void info(int);
extern int infodelay;
@@ -167,11 +167,11 @@ extern char *copy_argv(char **);
extern void safeputchar(int);
extern void safeputs(const char *);
-extern char *isonsap_string(const u_char *);
-extern char *llcsap_string(u_char);
-extern char *protoid_string(const u_char *);
-extern char *dnname_string(u_short);
-extern char *dnnum_string(u_short);
+extern const char *isonsap_string(const u_char *);
+extern const char *llcsap_string(u_char);
+extern const char *protoid_string(const u_char *);
+extern const char *dnname_string(u_short);
+extern const char *dnnum_string(u_short);
/* The printer routines. */
@@ -209,7 +209,7 @@ extern void ieee802_11_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern void gre_print(const u_char *, u_int);
extern void icmp_print(const u_char *, u_int, const u_char *);
-extern void igmp_print(const u_char *, u_int, const u_char *);
+extern void igmp_print(const u_char *, u_int);
extern void igrp_print(const u_char *, u_int, const u_char *);
extern void ip_print(const u_char *, u_int);
extern void ipN_print(const u_char *, u_int);
@@ -286,7 +286,7 @@ extern void zephyr_print(const u_char *, int);
extern void hsrp_print(const u_char *, u_int);
#ifdef INET6
-extern void ip6_print(const u_char *, int);
+extern void ip6_print(const u_char *, u_int);
extern void ip6_opt_print(const u_char *, int);
extern int hbhopt_print(const u_char *);
extern int dstopt_print(const u_char *);
@@ -297,7 +297,7 @@ extern int rt6_print(const u_char *, const u_char *);
extern void ospf6_print(const u_char *, u_int);
extern void dhcp6_print(const u_char *, u_int, u_int16_t, u_int16_t);
#endif /*INET6*/
-extern u_short in_cksum(const u_short *, register int, int);
+extern u_short in_cksum(const u_short *, register u_int, int);
#ifndef HAVE_BPF_DUMP
struct bpf_program;
diff --git a/nfsfh.h b/nfsfh.h
index fef4ab1e..db87af4e 100644
--- a/nfsfh.h
+++ b/nfsfh.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.11 2001-06-28 10:17:21 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.12 2001-09-17 21:57:52 fenner Exp $ (LBL) */
/*
* Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
@@ -65,4 +65,4 @@ typedef struct {
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
dev_eq(a.Fsid_dev, b.Fsid_dev))
-extern void Parse_fh(caddr_t *, int, my_fsid *, ino_t *, char **, char **, int);
+extern void Parse_fh(caddr_t *, int, my_fsid *, ino_t *, const char **, const char **, int);
diff --git a/parsenfsfh.c b/parsenfsfh.c
index e9fce107..eb1313ff 100644
--- a/parsenfsfh.c
+++ b/parsenfsfh.c
@@ -42,7 +42,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.22 2001-06-24 21:41:29 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.23 2001-09-17 21:57:53 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -116,8 +116,8 @@ register caddr_t *fh;
int len;
my_fsid *fsidp;
ino_t *inop;
-char **osnamep; /* if non-NULL, return OS name here */
-char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */
+const char **osnamep; /* if non-NULL, return OS name here */
+const char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */
int ourself; /* true if file handle was generated on this host */
{
register unsigned char *fhp = (unsigned char *)fh;
diff --git a/print-802_11.c b/print-802_11.c
index 3a6914f7..864ab92f 100644
--- a/print-802_11.c
+++ b/print-802_11.c
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.5 2001-07-05 18:54:13 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.6 2001-09-17 21:57:53 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -534,7 +534,7 @@ static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length)
if (!TTEST2(*p, CTRL_PS_POLL_LEN))
return 0;
printf("Power Save-Poll AID(%x)",
- EXTRACT_LE_16BITS(&(((struct ctrl_ps_poll_t *)p)->aid)));
+ EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid)));
break;
case CTRL_RTS:
if (!TTEST2(*p, CTRL_RTS_LEN))
@@ -543,7 +543,7 @@ static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length)
printf("Request-To-Send");
else
printf("Request-To-Send TA:%s ",
- etheraddr_string(((struct ctrl_rts_t *)p)->ta));
+ etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
break;
case CTRL_CTS:
if (!TTEST2(*p, CTRL_CTS_LEN))
@@ -552,7 +552,7 @@ static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length)
printf("Clear-To-Send");
else
printf("Clear-To-Send RA:%s ",
- etheraddr_string(((struct ctrl_cts_t *)p)->ra));
+ etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
break;
case CTRL_ACK:
if (!TTEST2(*p, CTRL_ACK_LEN))
@@ -561,7 +561,7 @@ static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length)
printf("Acknowledgment");
else
printf("Acknowledgment RA:%s ",
- etheraddr_string(((struct ctrl_ack_t *)p)->ra));
+ etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
break;
case CTRL_CF_END:
if (!TTEST2(*p, CTRL_END_LEN))
@@ -570,7 +570,7 @@ static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length)
printf("CF-End");
else
printf("CF-End RA:%s ",
- etheraddr_string(((struct ctrl_end_t *)p)->ra));
+ etheraddr_string(((const struct ctrl_end_t *)p)->ra));
break;
case CTRL_END_ACK:
if (!TTEST2(*p, CTRL_END_ACK_LEN))
@@ -579,7 +579,7 @@ static int ctrl_body_print(u_int16_t fc,const u_char *p, u_int length)
printf("CF-End+CF-Ack");
else
printf("CF-End+CF-Ack RA:%s ",
- etheraddr_string(((struct ctrl_end_ack_t *)p)->ra));
+ etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra));
break;
default:
printf("(B) Unknown Ctrl Subtype");
@@ -651,31 +651,31 @@ static void ctrl_header_print(u_int16_t fc,const u_char *p, u_int length)
switch (FC_SUBTYPE(fc)) {
case CTRL_PS_POLL:
printf("BSSID:%s TA:%s ",
- etheraddr_string(((struct ctrl_ps_poll_t *)p)->bssid),
- etheraddr_string(((struct ctrl_ps_poll_t *)p)->ta));
+ etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid),
+ etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta));
break;
case CTRL_RTS:
printf("RA:%s TA:%s ",
- etheraddr_string(((struct ctrl_rts_t *)p)->ra),
- etheraddr_string(((struct ctrl_rts_t *)p)->ta));
+ etheraddr_string(((const struct ctrl_rts_t *)p)->ra),
+ etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
break;
case CTRL_CTS:
printf("RA:%s ",
- etheraddr_string(((struct ctrl_cts_t *)p)->ra));
+ etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
break;
case CTRL_ACK:
printf("RA:%s ",
- etheraddr_string(((struct ctrl_ack_t *)p)->ra));
+ etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
break;
case CTRL_CF_END:
printf("RA:%s BSSID:%s ",
- etheraddr_string(((struct ctrl_end_t *)p)->ra),
- etheraddr_string(((struct ctrl_end_t *)p)->bssid));
+ etheraddr_string(((const struct ctrl_end_t *)p)->ra),
+ etheraddr_string(((const struct ctrl_end_t *)p)->bssid));
break;
case CTRL_END_ACK:
printf("RA:%s BSSID:%s ",
- etheraddr_string(((struct ctrl_end_ack_t *)p)->ra),
- etheraddr_string(((struct ctrl_end_ack_t *)p)->bssid));
+ etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra),
+ etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid));
break;
default:
printf("(H) Unknown Ctrl Subtype");
diff --git a/print-ah.c b/print-ah.c
index b2441aaa..6450295b 100644
--- a/print-ah.c
+++ b/print-ah.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.14 2000-12-12 09:58:40 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.15 2001-09-17 21:57:54 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -52,11 +52,10 @@ ah_print(register const u_char *bp, register const u_char *bp2)
int sumlen;
u_int32_t spi;
- ah = (struct ah *)bp;
+ ah = (const struct ah *)bp;
ep = snapend; /* 'ep' points to the end of available data. */
- if ((u_char *)(ah + 1) >= ep - sizeof(struct ah))
- goto trunc;
+ TCHECK(*ah);
sumlen = ah->ah_len << 2;
spi = (u_int32_t)ntohl(ah->ah_spi);
@@ -64,7 +63,7 @@ ah_print(register const u_char *bp, register const u_char *bp2)
printf("AH(spi=0x%08x", spi);
if (vflag)
printf(",sumlen=%d", sumlen);
- printf(",seq=0x%x", (u_int32_t)ntohl(*(u_int32_t *)(ah + 1)));
+ printf(",seq=0x%x", (u_int32_t)ntohl(*(const u_int32_t *)(ah + 1)));
if (bp + sizeof(struct ah) + sumlen > ep)
fputs("[truncated]", stdout);
fputs("): ", stdout);
diff --git a/print-arcnet.c b/print-arcnet.c
index 8d24b348..4250c3a1 100644
--- a/print-arcnet.c
+++ b/print-arcnet.c
@@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.5 2001-09-10 00:20:43 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.6 2001-09-17 21:57:54 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -47,10 +47,7 @@ struct rtentry;
int arcnet_encap_print(u_char arctype, const u_char *p,
u_int length, u_int caplen);
-struct arctype_map {
- const int arctype;
- char * const name;
-} arctypemap[] = {
+struct tok arctypemap[] = {
{ ARCTYPE_IP_OLD, "oldip" },
{ ARCTYPE_ARP_OLD, "oldarp" },
{ ARCTYPE_IP, "ip" },
@@ -68,9 +65,7 @@ static inline void
arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
{
const struct arc_header *ap;
- struct arctype_map *atmp;
- char *arctypename;
- char typebuf[3];
+ const char *arctypename;
ap = (const struct arc_header *)bp;
@@ -84,16 +79,7 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
return;
}
- for (arctypename = NULL, atmp = arctypemap; atmp->arctype; atmp++) {
- if (atmp->arctype == ap->arc_type) {
- arctypename = atmp->name;
- break;
- }
- }
- if (!arctypename) {
- arctypename = typebuf;
- (void)snprintf(typebuf, sizeof(typebuf), "%02x", ap->arc_type);
- }
+ arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
if (!phds) {
(void)printf("%02x %02x %s %d: ",
@@ -132,7 +118,7 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
- struct arc_header *ap;
+ const struct arc_header *ap;
int phds, flag = 0, archdrlen = 0;
u_int seqid = 0;
@@ -146,7 +132,7 @@ arcnet_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
goto out;
}
- ap = (struct arc_header *)p;
+ ap = (const struct arc_header *)p;
arc_type = ap->arc_type;
switch (arc_type) {
diff --git a/print-arp.c b/print-arp.c
index cbeb47af..a9e3a990 100644
--- a/print-arp.c
+++ b/print-arp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.50 2001-06-18 09:12:28 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.51 2001-09-17 21:57:54 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -80,10 +80,10 @@ struct arphdr {
u_char ar_tha[]; /* target hardware address */
u_char ar_tpa[]; /* target protocol address */
#endif
-#define ar_sha(ap) (((caddr_t)((ap)+1))+0)
-#define ar_spa(ap) (((caddr_t)((ap)+1))+ (ap)->ar_hln)
-#define ar_tha(ap) (((caddr_t)((ap)+1))+ (ap)->ar_hln+(ap)->ar_pln)
-#define ar_tpa(ap) (((caddr_t)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
+#define ar_sha(ap) (((const caddr_t)((ap)+1))+0)
+#define ar_spa(ap) (((const caddr_t)((ap)+1))+ (ap)->ar_hln)
+#define ar_tha(ap) (((const caddr_t)((ap)+1))+ (ap)->ar_hln+(ap)->ar_pln)
+#define ar_tpa(ap) (((const caddr_t)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
};
#define ARP_HDRLEN 8
@@ -106,14 +106,11 @@ arp_print(const u_char *bp, u_int length, u_int caplen)
const struct arphdr *ap;
u_short pro, hrd, op;
- ap = (struct arphdr *)bp;
- if ((u_char *)(ap + 1) > snapend) {
- printf("[|arp]");
- return;
- }
- if ((u_char *)(ar_tpa(ap) + PLN(ap)) > snapend) {
+ ap = (const struct arphdr *)bp;
+ TCHECK(*ap);
+ if ((const u_char *)(ar_tpa(ap) + PLN(ap)) > snapend) {
(void)printf("truncated-arp");
- default_print((u_char *)ap, length);
+ default_print((const u_char *)ap, length);
return;
}
@@ -132,7 +129,7 @@ arp_print(const u_char *bp, u_int length, u_int caplen)
case ARPOP_REQUEST:
(void)printf("arp who-has %s", ipaddr_string(TPA(ap)));
- if (memcmp((char *)ezero, (char *)THA(ap), HLN(ap)) != 0)
+ if (memcmp((const char *)ezero, (const char *)THA(ap), HLN(ap)) != 0)
(void)printf(" (%s)",
linkaddr_string(THA(ap), HLN(ap)));
(void)printf(" tell %s", ipaddr_string(SPA(ap)));
@@ -157,9 +154,12 @@ arp_print(const u_char *bp, u_int length, u_int caplen)
default:
(void)printf("arp-#%d", op);
- default_print((u_char *)ap, caplen);
+ default_print((const u_char *)ap, caplen);
return;
}
if (hrd != ARPHRD_ETHER)
printf(" hardware #%d", hrd);
+ return;
+trunc:
+ (void)printf("[|arp]");
}
diff --git a/print-atalk.c b/print-atalk.c
index 3cc55500..0c6da834 100644
--- a/print-atalk.c
+++ b/print-atalk.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.68 2001-07-18 09:19:47 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.69 2001-09-17 21:57:55 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -112,7 +112,7 @@ llap_print(register const u_char *bp, u_int length)
register const struct atShortDDP *sdp;
u_short snet;
- lp = (struct LAP *)bp;
+ lp = (const struct LAP *)bp;
bp += sizeof(*lp);
length -= sizeof(*lp);
switch (lp->type) {
@@ -390,7 +390,7 @@ nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
register u_char snode, register u_char skt)
{
register const struct atNBPtuple *tp =
- (struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
+ (const struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
int i;
const u_char *ep;
@@ -466,7 +466,7 @@ print_cstring(register const char *cp, register const u_char *ep)
return (0);
}
while ((int)--length >= 0) {
- if (cp >= (char *)ep) {
+ if (cp >= (const char *)ep) {
fputs(tstr, stdout);
return (0);
}
diff --git a/print-bgp.c b/print-bgp.c
index 6d17f6f6..08522fad 100644
--- a/print-bgp.c
+++ b/print-bgp.c
@@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.22 2001-01-28 09:52:47 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.23 2001-09-17 21:57:55 fenner Exp $";
#endif
#include <sys/param.h>
@@ -270,10 +270,10 @@ bgp_notify_minor(int major, int minor)
}
static int
-decode_prefix4(const u_char *pd, char *buf, int buflen)
+decode_prefix4(const u_char *pd, char *buf, u_int buflen)
{
struct in_addr addr;
- int plen;
+ u_int plen;
plen = pd[0];
if (plen < 0 || 32 < plen)
@@ -291,10 +291,10 @@ decode_prefix4(const u_char *pd, char *buf, int buflen)
#ifdef INET6
static int
-decode_prefix6(const u_char *pd, char *buf, int buflen)
+decode_prefix6(const u_char *pd, char *buf, u_int buflen)
{
struct in6_addr addr;
- int plen;
+ u_int plen;
plen = pd[0];
if (plen < 0 || 128 < plen)
@@ -306,7 +306,7 @@ decode_prefix6(const u_char *pd, char *buf, int buflen)
addr.s6_addr[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname6((char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen);
return 1 + (plen + 7) / 8;
}
#endif
@@ -348,7 +348,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
printf("%s", (p[0] & 1) ? "{" : "");
for (i = 0; i < p[1]; i += 2) {
printf("%s%u", i == 0 ? "" : " ",
- ntohs(*(u_int16_t *)&p[2 + i]));
+ EXTRACT_16BITS(&p[2 + i]));
}
printf("%s", (p[0] & 1) ? "}" : "");
p += 2 + p[1] * 2;
@@ -365,7 +365,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
if (len != 4)
printf(" invalid len");
else
- printf(" %u", (u_int32_t)ntohl(*(u_int32_t *)p));
+ printf(" %u", EXTRACT_32BITS(p));
break;
case BGPTYPE_ATOMIC_AGGREGATE:
if (len != 0)
@@ -376,7 +376,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
printf(" invalid len");
break;
}
- printf(" AS #%u, origin %s", ntohs(*(u_int16_t *)p),
+ printf(" AS #%u, origin %s", EXTRACT_16BITS(p),
getname(p + 2));
break;
case BGPTYPE_COMMUNITIES:
@@ -386,7 +386,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
}
for (i = 0; i < len; i += 4) {
u_int32_t comm;
- comm = (u_int32_t)ntohl(*(u_int32_t *)&p[i]);
+ comm = EXTRACT_32BITS(&p[i]);
switch (comm) {
case BGP_COMMUNITY_NO_EXPORT:
printf(" NO_EXPORT");
@@ -405,7 +405,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
}
break;
case BGPTYPE_MP_REACH_NLRI:
- af = ntohs(*(u_int16_t *)p);
+ af = EXTRACT_16BITS(p);
safi = p[2];
if (safi >= 128)
printf(" %s vendor specific,", af_name(af));
@@ -487,7 +487,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
break;
case BGPTYPE_MP_UNREACH_NLRI:
- af = ntohs(*(u_int16_t *)p);
+ af = EXTRACT_16BITS(p);
safi = p[2];
if (safi >= 128)
printf(" %s vendor specific,", af_name(af));
@@ -545,7 +545,7 @@ bgp_open_print(const u_char *dat, int length)
printf(" Option length %u", bgpo.bgpo_optlen);
/* ugly! */
- opt = &((struct bgp_open *)dat)->bgpo_optlen;
+ opt = &((const struct bgp_open *)dat)->bgpo_optlen;
opt++;
for (i = 0; i < bgpo.bgpo_optlen; i++) {
diff --git a/print-bootp.c b/print-bootp.c
index 04f767ee..f0cc5aec 100644
--- a/print-bootp.c
+++ b/print-bootp.c
@@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.59 2001-07-04 21:18:12 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.60 2001-09-17 21:57:56 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -48,8 +48,8 @@ struct rtentry;
#include "ether.h"
#include "bootp.h"
-static void rfc1048_print(const u_char *, u_int);
-static void cmu_print(const u_char *, u_int);
+static void rfc1048_print(const u_char *);
+static void cmu_print(const u_char *);
static char tstr[] = " [|bootp]";
@@ -61,10 +61,10 @@ bootp_print(register const u_char *cp, u_int length,
u_short sport, u_short dport)
{
register const struct bootp *bp;
- static u_char vm_cmu[4] = VM_CMU;
- static u_char vm_rfc1048[4] = VM_RFC1048;
+ static const u_char vm_cmu[4] = VM_CMU;
+ static const u_char vm_rfc1048[4] = VM_RFC1048;
- bp = (struct bootp *)cp;
+ bp = (const struct bootp *)cp;
TCHECK(bp->bp_op);
switch (bp->bp_op) {
@@ -130,14 +130,14 @@ bootp_print(register const u_char *cp, u_int length,
register const char *e;
TCHECK2(bp->bp_chaddr[0], 6);
- eh = (struct ether_header *)packetp;
+ eh = (const struct ether_header *)packetp;
if (bp->bp_op == BOOTREQUEST)
e = (const char *)ESRC(eh);
else if (bp->bp_op == BOOTREPLY)
e = (const char *)EDST(eh);
else
e = 0;
- if (e == 0 || memcmp((char *)bp->bp_chaddr, e, 6) != 0)
+ if (e == 0 || memcmp((const char *)bp->bp_chaddr, e, 6) != 0)
printf(" ether %s", etheraddr_string(bp->bp_chaddr));
}
@@ -164,13 +164,12 @@ bootp_print(register const u_char *cp, u_int length,
/* Decode the vendor buffer */
TCHECK(bp->bp_vend[0]);
- length -= sizeof(*bp) - sizeof(bp->bp_vend);
- if (memcmp((char *)bp->bp_vend, (char *)vm_rfc1048,
+ if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
sizeof(u_int32_t)) == 0)
- rfc1048_print(bp->bp_vend, length);
- else if (memcmp((char *)bp->bp_vend, (char *)vm_cmu,
+ rfc1048_print(bp->bp_vend);
+ else if (memcmp((const char *)bp->bp_vend, vm_cmu,
sizeof(u_int32_t)) == 0)
- cmu_print(bp->bp_vend, length);
+ cmu_print(bp->bp_vend);
else {
u_int32_t ul;
@@ -348,7 +347,7 @@ static struct tok arp2str[] = {
};
static void
-rfc1048_print(register const u_char *bp, register u_int length)
+rfc1048_print(register const u_char *bp)
{
register u_char tag;
register u_int len, size;
@@ -486,10 +485,10 @@ rfc1048_print(register const u_char *bp, register u_int length)
while (size >= 2*sizeof(ul)) {
if (!first)
putchar(',');
- memcpy((char *)&ul, (char *)bp, sizeof(ul));
+ memcpy((char *)&ul, (const char *)bp, sizeof(ul));
printf("(%s:", ipaddr_string(&ul));
bp += sizeof(ul);
- memcpy((char *)&ul, (char *)bp, sizeof(ul));
+ memcpy((char *)&ul, (const char *)bp, sizeof(ul));
printf("%s)", ipaddr_string(&ul));
bp += sizeof(ul);
size -= 2*sizeof(ul);
@@ -619,7 +618,7 @@ trunc:
}
static void
-cmu_print(register const u_char *bp, register u_int length)
+cmu_print(register const u_char *bp)
{
register const struct cmu_vend *cmu;
@@ -628,7 +627,7 @@ cmu_print(register const u_char *bp, register u_int length)
printf(" %s:%s", s, ipaddr_string(&cmu->m.s_addr)); }
printf(" vend-cmu");
- cmu = (struct cmu_vend *)bp;
+ cmu = (const struct cmu_vend *)bp;
/* Only print if there are unknown bits */
TCHECK(cmu->v_flags);
diff --git a/print-bxxp.c b/print-bxxp.c
index 091ef900..4067f3d3 100644
--- a/print-bxxp.c
+++ b/print-bxxp.c
@@ -11,7 +11,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/Attic/print-bxxp.c,v 1.4 2001-06-15 07:45:42 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/Attic/print-bxxp.c,v 1.5 2001-09-17 21:57:56 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -38,10 +38,10 @@ static const char rcsid[] =
* Looks at the first few chars up to tl1 ...
*/
-static int l_strnstart(const u_char *, u_int, const u_char *, u_int);
+static int l_strnstart(const char *, u_int, const char *, u_int);
static int
-l_strnstart(const u_char *tstr1, u_int tl1, const u_char *str2, u_int l2)
+l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
{
if (tl1 > l2)
diff --git a/print-cdp.c b/print-cdp.c
index b8ede526..caa8f1ef 100644
--- a/print-cdp.c
+++ b/print-cdp.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.10 2001-08-25 09:46:33 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.11 2001-09-17 21:57:56 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -54,7 +54,7 @@ void
cdp_print(const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst)
{
- int i;
+ u_int i;
int type, len;
/* Cisco Discovery Protocol */
diff --git a/print-chdlc.c b/print-chdlc.c
index b415d4e7..4aacfc7b 100644
--- a/print-chdlc.c
+++ b/print-chdlc.c
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.12 2001-07-05 18:54:14 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.13 2001-09-17 21:57:57 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -42,6 +42,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
+#include "extract.h"
#include "ppp.h"
#include "chdlc.h"
@@ -85,7 +86,7 @@ chdlc_print(register const u_char *p, u_int length, u_int caplen)
return;
}
- proto = ntohs(*(u_short *)&p[2]);
+ proto = EXTRACT_16BITS(&p[2]);
if (eflag) {
switch (p[0]) {
case CHDLC_UNICAST:
@@ -102,7 +103,7 @@ chdlc_print(register const u_char *p, u_int length, u_int caplen)
}
length -= CHDLC_HDRLEN;
- ip = (struct ip *)(p + CHDLC_HDRLEN);
+ ip = (const struct ip *)(p + CHDLC_HDRLEN);
switch (proto) {
case ETHERTYPE_IP:
ip_print((const u_char *)ip, length);
@@ -151,14 +152,14 @@ struct cisco_slarp {
static void
chdlc_slarp_print(const u_char *cp, u_int length)
{
- struct cisco_slarp *slarp;
+ const struct cisco_slarp *slarp;
if (length < SLARP_LEN) {
printf("[|slarp]");
return;
}
- slarp = (struct cisco_slarp *)cp;
+ slarp = (const struct cisco_slarp *)cp;
switch (ntohl(slarp->code)) {
case SLARP_REQUEST:
printf("slarp-request");
diff --git a/print-cip.c b/print-cip.c
index 45ece55f..55cd8418 100644
--- a/print-cip.c
+++ b/print-cip.c
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.14 2001-07-05 18:54:15 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.15 2001-09-17 21:57:58 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -69,7 +69,7 @@ cip_print(register const u_char *bp, int length)
} else {
for (i = 0;i < RFC1483LLC_LEN - 2; i++)
(void)printf("%2.2x ",bp[i]);
- etherproto_string(((u_short*)bp)[3]);
+ etherproto_string(((const u_short *)bp)[3]);
}
} else {
if (qflag)
@@ -90,11 +90,11 @@ cip_print(register const u_char *bp, int length)
void
cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
- int caplen = h->caplen;
- int length = h->len;
+ u_int caplen = h->caplen;
+ u_int length = h->len;
u_short ether_type;
u_short extracted_ethertype;
- u_short *bp;
+ const u_short *bp;
++infodelay;
ts_print(&h->ts);
@@ -118,12 +118,12 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (memcmp(rfcllc, p, sizeof(rfcllc))==0) {
length -= RFC1483LLC_LEN;
caplen -= RFC1483LLC_LEN;
- bp = (u_short *)p;
+ bp = (const u_short *)p;
p += RFC1483LLC_LEN;
ether_type = ntohs(bp[3]);
} else {
ether_type = ETHERTYPE_IP;
- bp = (u_short *)p;
+ bp = (const u_short *)p;
}
/*
diff --git a/print-cnfp.c b/print-cnfp.c
index e10e2478..5f9d1a3c 100644
--- a/print-cnfp.c
+++ b/print-cnfp.c
@@ -34,7 +34,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.7 2001-02-21 09:05:39 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.8 2001-09-17 21:57:58 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -92,10 +92,10 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
int nrecs, ver;
time_t t;
- ip = (struct ip *)bp;
- nh = (struct nfhdr *)cp;
+ ip = (const struct ip *)bp;
+ nh = (const struct nfhdr *)cp;
- if ((u_char *)(nh + 1) > snapend)
+ if ((const u_char *)(nh + 1) > snapend)
return;
nrecs = ntohl(nh->ver_cnt) & 0xffff;
@@ -110,16 +110,16 @@ cnfp_print(const u_char *cp, u_int len, const u_char *bp)
if (ver == 5 || ver == 6) {
printf("#%u, ", (unsigned)htonl(nh->sequence));
- nr = (struct nfrec *)&nh[1];
+ nr = (const struct nfrec *)&nh[1];
snaplen -= 24;
} else {
- nr = (struct nfrec *)&nh->sequence;
+ nr = (const struct nfrec *)&nh->sequence;
snaplen -= 16;
}
printf("%2u recs", nrecs);
- for (; nrecs-- && (u_char *)(nr + 1) <= snapend; nr++) {
+ for (; nrecs-- && (const u_char *)(nr + 1) <= snapend; nr++) {
char buf[20];
char asbuf[20];
diff --git a/print-decnet.c b/print-decnet.c
index bb5f075f..f83173cb 100644
--- a/print-decnet.c
+++ b/print-decnet.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.32 2001-01-28 08:06:06 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.33 2001-09-17 21:57:59 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -730,7 +730,7 @@ print_reason(register int reason)
printf("%s ", tok2str(reason2str, "reason-%d", reason));
}
-char *
+const char *
dnnum_string(u_short dnaddr)
{
char *str;
@@ -745,7 +745,7 @@ dnnum_string(u_short dnaddr)
return(str);
}
-char *
+const char *
dnname_string(u_short dnaddr)
{
#ifdef HAVE_LIBDNET
diff --git a/print-dhcp6.c b/print-dhcp6.c
index 6c732577..6cb83ea6 100644
--- a/print-dhcp6.c
+++ b/print-dhcp6.c
@@ -29,7 +29,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.13 2001-01-28 09:49:49 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.14 2001-09-17 21:57:59 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -61,7 +61,7 @@ static struct dhcp6_opt *dhcp6opttab_byname(char *);
#endif
static struct dhcp6_opt *dhcp6opttab_bycode(u_int);
-static char tstr[] = " [|dhcp6]";
+static const char tstr[] = " [|dhcp6]";
static struct dhcp6_opt dh6opttab[] = {
/* IP Address Extension */
diff --git a/print-domain.c b/print-domain.c
index 22b70884..2e73a8e5 100644
--- a/print-domain.c
+++ b/print-domain.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.76 2001-06-26 06:19:04 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.77 2001-09-17 21:58:00 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -42,13 +42,13 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
-static char *ns_ops[] = {
+static const char *ns_ops[] = {
"", " inv_q", " stat", " op3", " notify", " update", " op6", " op7",
" op8", " updataA", " updateD", " updateDA",
" updateM", " updateMA", " zoneInit", " zoneRef",
};
-static char *ns_resp[] = {
+static const char *ns_resp[] = {
"", " FormErr", " ServFail", " NXDomain",
" NotImp", " Refused", " YXDomain", " YXRRSet",
" NXRRSet", " NotAuth", " NotZone", " Resp11",
diff --git a/print-egp.c b/print-egp.c
index 4446974b..90fa6c5b 100644
--- a/print-egp.c
+++ b/print-egp.c
@@ -20,7 +20,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.27 2001-06-15 22:17:31 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.28 2001-09-17 21:58:01 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -99,7 +99,7 @@ struct egp_packet {
#define egp_sourcenet egp_pands.egpu_sourcenet
};
-char *egp_acquire_codes[] = {
+const char *egp_acquire_codes[] = {
"request",
"confirm",
"refuse",
@@ -107,7 +107,7 @@ char *egp_acquire_codes[] = {
"cease_ack"
};
-char *egp_acquire_status[] = {
+const char *egp_acquire_status[] = {
"unspecified",
"active_mode",
"passive_mode",
@@ -118,18 +118,18 @@ char *egp_acquire_status[] = {
"protocol_violation"
};
-char *egp_reach_codes[] = {
+const char *egp_reach_codes[] = {
"hello",
"i-h-u"
};
-char *egp_status_updown[] = {
+const char *egp_status_updown[] = {
"indeterminate",
"up",
"down"
};
-char *egp_reasons[] = {
+const char *egp_reasons[] = {
"unspecified",
"bad_EGP_header_format",
"bad_EGP_data_field_format",
diff --git a/print-frag6.c b/print-frag6.c
index ecb28bac..533d730d 100644
--- a/print-frag6.c
+++ b/print-frag6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.12 2000-10-07 05:53:10 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.13 2001-09-17 21:58:02 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -52,12 +52,8 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
register const struct ip6_hdr *ip6;
register const u_char *ep;
-#if 0
-#define TCHECK(var) if ((u_char *)&(var) >= ep - sizeof(var)) goto trunc
-#endif
-
- dp = (struct ip6_frag *)bp;
- ip6 = (struct ip6_hdr *)bp2;
+ dp = (const struct ip6_frag *)bp;
+ ip6 = (const struct ip6_hdr *)bp2;
/* 'ep' points to the end of available data. */
ep = snapend;
diff --git a/print-igmp.c b/print-igmp.c
index dbafcd3f..98fd61b7 100644
--- a/print-igmp.c
+++ b/print-igmp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.4 2001-05-11 02:13:19 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.5 2001-09-17 21:58:02 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -114,7 +114,7 @@ static struct tok igmpv3report2str[] = {
static void
print_mtrace(register const u_char *bp, register u_int len)
{
- register struct tr_query *tr = (struct tr_query *)(bp + 8);
+ register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
printf("mtrace %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
@@ -127,7 +127,7 @@ print_mtrace(register const u_char *bp, register u_int len)
static void
print_mresp(register const u_char *bp, register u_int len)
{
- register struct tr_query *tr = (struct tr_query *)(bp + 8);
+ register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
printf("mresp %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
@@ -138,11 +138,10 @@ print_mresp(register const u_char *bp, register u_int len)
}
static void
-print_igmpv3_report(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+print_igmpv3_report(register const u_char *bp, register u_int len)
{
- int group, nsrcs, ngroups;
- register int i, j;
+ u_int group, nsrcs, ngroups;
+ register u_int i, j;
/* Minimum len is 16, and should be a multiple of 4 */
if (len < 16 || len & 0x03) {
@@ -193,12 +192,12 @@ trunc:
}
static void
-print_igmpv3_query(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+print_igmpv3_query(register const u_char *bp, register u_int len)
{
- int mrt, mrc;
- int nsrcs;
- register int i;
+ u_int mrc;
+ int mrt;
+ u_int nsrcs;
+ register u_int i;
(void)printf(" v3");
/* Minimum len is 12, and should be a multiple of 4 */
@@ -244,8 +243,7 @@ trunc:
}
void
-igmp_print(register const u_char *bp, register u_int len,
- register const u_char *bp2)
+igmp_print(register const u_char *bp, register u_int len)
{
if (qflag) {
(void)printf("igmp");
@@ -257,7 +255,7 @@ igmp_print(register const u_char *bp, register u_int len,
case 0x11:
(void)printf("igmp query");
if (len >= 12)
- print_igmpv3_query(bp, len, bp2);
+ print_igmpv3_query(bp, len);
else {
if (bp[1]) {
(void)printf(" v2");
@@ -281,7 +279,7 @@ igmp_print(register const u_char *bp, register u_int len,
break;
case 0x22:
(void)printf("igmp v3 report");
- print_igmpv3_report(bp, len, bp2);
+ print_igmpv3_report(bp, len);
break;
case 0x17:
(void)printf("igmp leave %s", ipaddr_string(&bp[4]));
diff --git a/print-ip.c b/print-ip.c
index 8d1bbdad..da34def9 100644
--- a/print-ip.c
+++ b/print-ip.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.99 2001-08-20 17:52:39 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.100 2001-09-17 21:58:03 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -217,7 +217,7 @@ ip_optprint(register const u_char *cp, u_int length)
* don't modifiy the packet.
*/
u_short
-in_cksum(const u_short *addr, register int len, int csum)
+in_cksum(const u_short *addr, register u_int len, int csum)
{
int nleft = len;
const u_short *w = addr;
@@ -408,7 +408,7 @@ again:
#define IPPROTO_IGMP 2
#endif
case IPPROTO_IGMP:
- igmp_print(cp, len, (const u_char *)ip);
+ igmp_print(cp, len);
break;
case 4:
diff --git a/print-ip6.c b/print-ip6.c
index 1965c3fd..68d7d6e2 100644
--- a/print-ip6.c
+++ b/print-ip6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.17 2001-08-20 17:52:40 fenner Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.18 2001-09-17 21:58:03 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -51,11 +51,11 @@ static const char rcsid[] =
* print an IP6 datagram.
*/
void
-ip6_print(register const u_char *bp, register int length)
+ip6_print(register const u_char *bp, register u_int length)
{
register const struct ip6_hdr *ip6;
register int advance;
- register int len;
+ register u_int len;
register const u_char *cp;
int nh;
int fragmented = 0;
@@ -80,10 +80,7 @@ ip6_print(register const u_char *bp, register int length)
ip6 = (struct ip6_hdr *)abuf;
}
#endif
- if ((u_char *)(ip6 + 1) > snapend) {
- printf("[|ip6]");
- return;
- }
+ TCHECK(*ip6);
if (length < sizeof (struct ip6_hdr)) {
(void)printf("truncated-ip6 %d", length);
return;
@@ -100,7 +97,7 @@ ip6_print(register const u_char *bp, register int length)
while (cp < snapend) {
cp += advance;
- if (cp == (u_char *)(ip6 + 1)
+ if (cp == (const u_char *)(ip6 + 1)
&& nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
(void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src),
ip6addr_string(&ip6->ip6_dst));
@@ -222,6 +219,9 @@ ip6_print(register const u_char *bp, register int length)
(void)printf(", hlim %d", (int)ip6->ip6_hlim);
printf(")");
}
+ return;
+trunc:
+ (void)printf("[|ip6]");
}
#endif /* INET6 */
diff --git a/print-isoclns.c b/print-isoclns.c
index 538c5627..0e0a85f4 100644
--- a/print-isoclns.c
+++ b/print-isoclns.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.25 2001-09-11 02:38:04 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.26 2001-09-17 21:58:04 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -140,12 +140,7 @@ static const char rcsid[] =
#define ISIS_LSP_TYPE_UNUSED2 2
#define ISIS_LSP_TYPE_LEVEL_2 3
-struct isis_lsp_istype_values {
- u_char id;
- char *name;
-};
-
-static struct isis_lsp_istype_values isis_lsp_istype_values[] = {
+static struct tok isis_lsp_istype_values[] = {
{ ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
{ ISIS_LSP_TYPE_LEVEL_1, "Level 1 IS"},
{ ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
@@ -153,12 +148,7 @@ static struct isis_lsp_istype_values isis_lsp_istype_values[] = {
{ 0, NULL }
};
-struct isis_nlpid_values {
- u_char id;
- char *name;
-};
-
-static struct isis_nlpid_values isis_nlpid_values[] = {
+static struct tok isis_nlpid_values[] = {
{ NLPID_CLNS, "CLNS"},
{ NLPID_IP, "IPv4"},
{ NLPID_IP6, "IPv6"},
@@ -174,17 +164,12 @@ static struct isis_nlpid_values isis_nlpid_values[] = {
#define ISIS_PTP_ADJ_INIT 1
#define ISIS_PTP_ADJ_DOWN 2
-static int osi_cksum(const u_char *, int, u_char *);
+static int osi_cksum(const u_char *, u_int, u_char *);
static void esis_print(const u_char *, u_int);
static int isis_print(const u_char *, u_int);
-struct isis_ptp_adjancey_values {
- u_char id;
- char *name;
-};
-
-static struct isis_ptp_adjancey_values isis_ptp_adjancey_values[] = {
+static struct tok isis_ptp_adjancey_values[] = {
{ ISIS_PTP_ADJ_UP, "Up" },
{ ISIS_PTP_ADJ_INIT, "Initializing" },
{ ISIS_PTP_ADJ_DOWN, "Down" }
@@ -283,9 +268,9 @@ void isoclns_print(const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst)
{
u_char pdu_type;
- struct isis_common_header *header;
+ const struct isis_common_header *header;
- header = (struct isis_common_header *)p;
+ header = (const struct isis_common_header *)p;
pdu_type = header->pdu_type & PDU_TYPE_MASK;
if (caplen < 1) {
@@ -362,7 +347,7 @@ static void
esis_print(const u_char *p, u_int length)
{
const u_char *ep;
- int li = p[1];
+ u_int li = p[1];
const struct esis_hdr *eh = (const struct esis_hdr *) &p[2];
u_char off[2];
@@ -478,7 +463,7 @@ esis_print(const u_char *p, u_int length)
}
if (vflag)
while (p < ep && li) {
- int op, opli;
+ u_int op, opli;
const u_char *q;
if (snapend - p < 2)
@@ -504,7 +489,7 @@ esis_print(const u_char *p, u_int length)
continue;
}
printf (" %d:<", op);
- while (--opli >= 0)
+ while (opli-- > 0)
printf("%02x", *q++);
printf (">");
}
@@ -582,8 +567,8 @@ isis_print_tlv_ip_reach (const u_char *cp, int length)
int mask,prefix_len;
- struct isis_tlv_ip_reach *tlv_ip_reach;
- tlv_ip_reach = (struct isis_tlv_ip_reach *)cp;
+ const struct isis_tlv_ip_reach *tlv_ip_reach;
+ tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp;
while ( length > 0 ) {
if (length<12) {
@@ -654,35 +639,35 @@ isis_print_tlv_ip_reach (const u_char *cp, int length)
static int isis_print (const u_char *p, u_int length)
{
- struct isis_common_header *header;
+ const struct isis_common_header *header;
- struct isis_iih_lan_header *header_iih_lan;
- struct isis_iih_ptp_header *header_iih_ptp;
- struct isis_lsp_header *header_lsp;
- struct isis_csnp_header *header_csnp;
- struct isis_psnp_header *header_psnp;
+ const struct isis_iih_lan_header *header_iih_lan;
+ const struct isis_iih_ptp_header *header_iih_ptp;
+ const struct isis_lsp_header *header_lsp;
+ const struct isis_csnp_header *header_csnp;
+ const struct isis_psnp_header *header_psnp;
- struct isis_tlv_lsp *tlv_lsp;
- struct isis_tlv_ptp_adj *tlv_ptp_adj;
- struct isis_tlv_is_reach *tlv_is_reach;
+ const struct isis_tlv_lsp *tlv_lsp;
+ const struct isis_tlv_ptp_adj *tlv_ptp_adj;
+ const struct isis_tlv_is_reach *tlv_is_reach;
u_char pdu_type, max_area, type, len, tmp, alen, subl, subt, tslen, ttslen;
const u_char *optr, *pptr, *tptr;
u_short packet_len;
- int i,j,bit_length,byte_length,metric;
+ u_int i,j,bit_length,byte_length,metric;
u_char prefix[4];
u_char off[2];
float bw;
packet_len=length;
optr = p; /* initialize the _o_riginal pointer - need it for parsing the checksum TLV */
- header = (struct isis_common_header *)p;
+ header = (const struct isis_common_header *)p;
pptr = p+(ISIS_COMMON_HEADER_SIZE);
- header_iih_lan = (struct isis_iih_lan_header *)pptr;
- header_iih_ptp = (struct isis_iih_ptp_header *)pptr;
- header_lsp = (struct isis_lsp_header *)pptr;
- header_csnp = (struct isis_csnp_header *)pptr;
- header_psnp = (struct isis_psnp_header *)pptr;
+ header_iih_lan = (const struct isis_iih_lan_header *)pptr;
+ header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
+ header_lsp = (const struct isis_lsp_header *)pptr;
+ header_csnp = (const struct isis_csnp_header *)pptr;
+ header_psnp = (const struct isis_psnp_header *)pptr;
/*
* Sanity checking of the header.
@@ -823,7 +808,7 @@ static int isis_print (const u_char *p, u_int length)
printf("ATT bit set, ");
}
printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : "");
- printf("%s", isis_lsp_istype_values[ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)].name);
+ printf("%s", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)));
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
@@ -1037,7 +1022,7 @@ static int isis_print (const u_char *p, u_int length)
break;
case TLV_IS_REACH:
printf("IS Reachability (%u)",len);
- tlv_is_reach = (struct isis_tlv_is_reach *)pptr;
+ tlv_is_reach = (const struct isis_tlv_is_reach *)pptr;
printf("\n\t\t\tIS Neighbor: ");
isis_print_nodeid(tlv_is_reach->neighbor_nodeid);
@@ -1142,11 +1127,11 @@ static int isis_print (const u_char *p, u_int length)
break;
case TLV_PTP_ADJ:
printf("point-to-point Adjacency State (%u)",len);
- tlv_ptp_adj = (struct isis_tlv_ptp_adj *)pptr;
+ tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)pptr;
i=len;
if(i>=1) {
printf("\n\t\t\tAdjacency State: %s",
- isis_ptp_adjancey_values[*pptr].name);
+ tok2str(isis_ptp_adjancey_values, "#0x%x", *pptr));
i--;
}
if(i>=4) {
@@ -1169,13 +1154,7 @@ static int isis_print (const u_char *p, u_int length)
printf("Protocols supported (%u)", len);
printf("\n\t\t\tNLPID(s): ");
for(i=0;i<len;i++) {
- j=0;
- while(isis_nlpid_values[j].id) {
- if (*(pptr+i) == isis_nlpid_values[j].id)
- break;
- j++;
- }
- printf("%s (0x%02x)",isis_nlpid_values[j].name,*(pptr+i));
+ printf("%s (0x%02x)",tok2str(isis_nlpid_values, "Unknown", *(pptr+i)),*(pptr+i));
if(i<len-1)
printf(", ");
}
@@ -1202,7 +1181,7 @@ static int isis_print (const u_char *p, u_int length)
break;
case TLV_LSP:
- tlv_lsp = (struct isis_tlv_lsp *)pptr;
+ tlv_lsp = (const struct isis_tlv_lsp *)pptr;
printf("LSP entries (%u)", len);
i=0;
while(i<len) {
@@ -1293,7 +1272,7 @@ static int isis_print (const u_char *p, u_int length)
*/
static int
-osi_cksum(register const u_char *p, register int len, u_char *off)
+osi_cksum(register const u_char *p, register u_int len, u_char *off)
{
int32_t c0 = 0, c1 = 0;
diff --git a/print-smb.c b/print-smb.c
index 6687c826..37e54ca9 100644
--- a/print-smb.c
+++ b/print-smb.c
@@ -12,7 +12,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.17 2001-07-28 22:59:30 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.18 2001-09-17 21:58:04 fenner Exp $";
#endif
#include <stdio.h>
@@ -24,7 +24,7 @@ static const char rcsid[] =
static int request = 0;
-const uchar *startbuf = NULL;
+const u_char *startbuf = NULL;
struct smbdescript {
char *req_f1;
@@ -63,7 +63,7 @@ smbfind(int id, struct smbfns *list)
}
static void
-trans2_findfirst(const uchar *param, const uchar *data, ...)
+trans2_findfirst(const u_char *param, const u_char *data, ...)
{
char *fmt;
va_list ap;
@@ -79,7 +79,7 @@ trans2_findfirst(const uchar *param, const uchar *data, ...)
else
fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n";
- fdata(param, fmt, param + pcnt);
+ smb_fdata(param, fmt, param + pcnt);
if (dcnt) {
printf("data:\n");
print_data(data, dcnt);
@@ -87,7 +87,7 @@ trans2_findfirst(const uchar *param, const uchar *data, ...)
}
static void
-trans2_qfsinfo(const uchar *param, const uchar *data, ...)
+trans2_qfsinfo(const u_char *param, const u_char *data, ...)
{
static int level = 0;
char *fmt="";
@@ -102,7 +102,7 @@ trans2_qfsinfo(const uchar *param, const uchar *data, ...)
if (request) {
level = SVAL(param, 0);
fmt = "InfoLevel=[d]\n";
- fdata(param, fmt, param + pcnt);
+ smb_fdata(param, fmt, param + pcnt);
} else {
switch (level) {
case 1:
@@ -118,7 +118,7 @@ trans2_qfsinfo(const uchar *param, const uchar *data, ...)
fmt = "UnknownLevel\n";
break;
}
- fdata(data, fmt, data + dcnt);
+ smb_fdata(data, fmt, data + dcnt);
}
if (dcnt) {
printf("data:\n");
@@ -152,18 +152,18 @@ struct smbfns trans2_fns[] = {
static void
-print_trans2(const uchar *words, const uchar *dat, ...)
+print_trans2(const u_char *words, const u_char *dat, ...)
{
static struct smbfns *fn = &trans2_fns[0];
- uchar *data, *param;
- uchar *f1 = NULL, *f2 = NULL;
+ u_char *data, *param;
+ u_char *f1 = NULL, *f2 = NULL;
int pcnt, dcnt;
va_list ap;
- uchar *buf, *maxbuf;
+ u_char *buf, *maxbuf;
va_start(ap, dat);
- buf = va_arg(ap, uchar *);
- maxbuf = va_arg(ap, uchar *);
+ buf = va_arg(ap, u_char *);
+ maxbuf = va_arg(ap, u_char *);
va_end(ap);
if (request) {
@@ -183,15 +183,15 @@ print_trans2(const uchar *words, const uchar *dat, ...)
if (request) {
if (CVAL(words, 0) == 8) {
- fdata(words + 1,
+ smb_fdata(words + 1,
"Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",
maxbuf);
return;
} else {
- fdata(words + 1,
+ smb_fdata(words + 1,
"TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[d]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[d]\n",
words + 1 + 14 * 2);
- fdata(data + 1, "TransactionName=[S]\n%", maxbuf);
+ smb_fdata(data + 1, "TransactionName=[S]\n%", maxbuf);
}
f1 = fn->descript.req_f1;
f2 = fn->descript.req_f2;
@@ -200,7 +200,7 @@ print_trans2(const uchar *words, const uchar *dat, ...)
printf("Trans2Interim\n");
return;
} else {
- fdata(words + 1,
+ smb_fdata(words + 1,
"TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[d]\n",
words + 1 + 10 * 2);
}
@@ -211,109 +211,109 @@ print_trans2(const uchar *words, const uchar *dat, ...)
if (fn->descript.fn)
fn->descript.fn(param, data, pcnt, dcnt);
else {
- fdata(param, f1 ? f1 : (uchar *)"Paramaters=\n", param + pcnt);
- fdata(data, f2 ? f2 : (uchar *)"Data=\n", data + dcnt);
+ smb_fdata(param, f1 ? f1 : (u_char *)"Paramaters=\n", param + pcnt);
+ smb_fdata(data, f2 ? f2 : (u_char *)"Data=\n", data + dcnt);
}
}
static void
-print_browse(uchar *param, int paramlen, const uchar *data, int datalen)
+print_browse(u_char *param, int paramlen, const u_char *data, int datalen)
{
- const uchar *maxbuf = data + datalen;
+ const u_char *maxbuf = data + datalen;
int command = CVAL(data, 0);
- fdata(param, "BROWSE PACKET\n|Param ", param+paramlen);
+ smb_fdata(param, "BROWSE PACKET\n|Param ", param+paramlen);
switch (command) {
case 0xF:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
maxbuf);
break;
case 0x1:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
maxbuf);
break;
case 0x2:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",
maxbuf);
break;
case 0xc:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",
maxbuf);
break;
case 0x8:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n",
maxbuf);
break;
case 0xb:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",
maxbuf);
break;
case 0x9:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken?=[B]\n",
maxbuf);
break;
case 0xa:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken?=[B]*Name=[S]\n",
maxbuf);
break;
case 0xd:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",
maxbuf);
break;
case 0xe:
- data = fdata(data,
+ data = smb_fdata(data,
"BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf);
break;
default:
- data = fdata(data, "Unknown Browser Frame ", maxbuf);
+ data = smb_fdata(data, "Unknown Browser Frame ", maxbuf);
break;
}
}
static void
-print_ipc(uchar *param, int paramlen, uchar *data, int datalen)
+print_ipc(u_char *param, int paramlen, u_char *data, int datalen)
{
if (paramlen)
- fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen);
+ smb_fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen);
if (datalen)
- fdata(data, "IPC ", data + datalen);
+ smb_fdata(data, "IPC ", data + datalen);
}
static void
-print_trans(const uchar *words, const uchar *data1, ...)
+print_trans(const u_char *words, const u_char *data1, ...)
{
- uchar *f1, *f2, *f3, *f4;
- uchar *data, *param;
+ u_char *f1, *f2, *f3, *f4;
+ u_char *data, *param;
int datalen, paramlen;
va_list ap;
- uchar *buf, *maxbuf;
+ u_char *buf, *maxbuf;
va_start(ap, data1);
- buf = va_arg(ap, uchar *);
- maxbuf = va_arg(ap, uchar *);
+ buf = va_arg(ap, u_char *);
+ maxbuf = va_arg(ap, u_char *);
va_end(ap);
if (request) {
@@ -336,8 +336,8 @@ print_trans(const uchar *words, const uchar *data1, ...)
f4 = "|Data ";
}
- fdata(words + 1, f1, MIN(words + 1 + 2 * CVAL(words, 0), maxbuf));
- fdata(data1 + 2, f2, maxbuf - (paramlen + datalen));
+ smb_fdata(words + 1, f1, MIN(words + 1 + 2 * CVAL(words, 0), maxbuf));
+ smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen));
if (!strcmp(data1 + 2, "\\MAILSLOT\\BROWSE")) {
print_browse(param, paramlen, data, datalen);
@@ -350,22 +350,22 @@ print_trans(const uchar *words, const uchar *data1, ...)
}
if (paramlen)
- fdata(param, f3, MIN(param + paramlen, maxbuf));
+ smb_fdata(param, f3, MIN(param + paramlen, maxbuf));
if (datalen)
- fdata(data, f4, MIN(data + datalen, maxbuf));
+ smb_fdata(data, f4, MIN(data + datalen, maxbuf));
}
static void
-print_negprot(const uchar *words, const uchar *data, ...)
+print_negprot(const u_char *words, const u_char *data, ...)
{
- uchar *f1 = NULL, *f2 = NULL;
+ u_char *f1 = NULL, *f2 = NULL;
va_list ap;
- uchar *buf, *maxbuf;
+ u_char *buf, *maxbuf;
va_start(ap, data);
- buf = va_arg(ap, uchar *);
- maxbuf = va_arg(ap, uchar *);
+ buf = va_arg(ap, u_char *);
+ maxbuf = va_arg(ap, u_char *);
va_end(ap);
if (request)
@@ -380,28 +380,28 @@ print_negprot(const uchar *words, const uchar *data, ...)
}
if (f1)
- fdata(words + 1, f1, MIN(words + 1 + CVAL(words, 0) * 2, maxbuf));
+ smb_fdata(words + 1, f1, MIN(words + 1 + CVAL(words, 0) * 2, maxbuf));
else
print_data(words + 1, MIN(CVAL(words, 0) * 2,
PTR_DIFF(maxbuf, words + 1)));
if (f2)
- fdata(data + 2, f2, MIN(data + 2 + SVAL(data, 0), maxbuf));
+ smb_fdata(data + 2, f2, MIN(data + 2 + SVAL(data, 0), maxbuf));
else
print_data(data + 2, MIN(SVAL(data, 0), PTR_DIFF(maxbuf, data + 2)));
}
static void
-print_sesssetup(const uchar *words, const uchar *data, ...)
+print_sesssetup(const u_char *words, const u_char *data, ...)
{
int wcnt = CVAL(words, 0);
- uchar *f1 = NULL, *f2 = NULL;
+ u_char *f1 = NULL, *f2 = NULL;
va_list ap;
- uchar *buf, *maxbuf;
+ u_char *buf, *maxbuf;
va_start(ap, data);
- buf = va_arg(ap, uchar *);
- maxbuf = va_arg(ap, uchar *);
+ buf = va_arg(ap, u_char *);
+ maxbuf = va_arg(ap, u_char *);
va_end(ap);
if (request) {
@@ -419,13 +419,13 @@ print_sesssetup(const uchar *words, const uchar *data, ...)
}
if (f1)
- fdata(words + 1, f1, MIN(words + 1 + CVAL(words, 0) * 2, maxbuf));
+ smb_fdata(words + 1, f1, MIN(words + 1 + CVAL(words, 0) * 2, maxbuf));
else
print_data(words + 1, MIN(CVAL(words, 0) * 2,
PTR_DIFF(maxbuf, words + 1)));
if (f2)
- fdata(data + 2, f2, MIN(data + 2 + SVAL(data, 0), maxbuf));
+ smb_fdata(data + 2, f2, MIN(data + 2 + SVAL(data, 0), maxbuf));
else
print_data(data + 2, MIN(SVAL(data, 0), PTR_DIFF(maxbuf, data+2)));
}
@@ -705,10 +705,10 @@ static struct smbfns smb_fns[] = {
* print a SMB message
*/
static void
-print_smb(const uchar *buf, const uchar *maxbuf)
+print_smb(const u_char *buf, const u_char *maxbuf)
{
int command;
- const uchar *words, *data;
+ const u_char *words, *data;
struct smbfns *fn;
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";
@@ -728,7 +728,7 @@ print_smb(const uchar *buf, const uchar *maxbuf)
return;
/* print out the header */
- fdata(buf, fmt_smbheader, buf + 33);
+ smb_fdata(buf, fmt_smbheader, buf + 33);
if (CVAL(buf, 5)) {
int class = CVAL(buf, 5);
@@ -756,7 +756,7 @@ print_smb(const uchar *buf, const uchar *maxbuf)
else {
if (f1) {
printf("smbvwv[]=\n");
- fdata(words + 1, f1, words + 1 + wct * 2);
+ smb_fdata(words + 1, f1, words + 1 + wct * 2);
} else if (wct) {
int i;
int v;
@@ -769,7 +769,7 @@ print_smb(const uchar *buf, const uchar *maxbuf)
if (f2) {
printf("smbbuf[]=\n");
- fdata(data + 2, f2, maxbuf);
+ smb_fdata(data + 2, f2, maxbuf);
} else {
int bcc = SVAL(data, 0);
printf("smb_bcc=%d\n", bcc);
@@ -802,9 +802,9 @@ print_smb(const uchar *buf, const uchar *maxbuf)
* print a NBT packet received across tcp on port 139
*/
void
-nbt_tcp_print(const uchar *data, int length)
+nbt_tcp_print(const u_char *data, int length)
{
- const uchar *maxbuf = data + length;
+ const u_char *maxbuf = data + length;
int flags = CVAL(data, 0);
int nbt_len = RSVAL(data, 2);
@@ -826,7 +826,7 @@ nbt_tcp_print(const uchar *data, int length)
case 1:
printf("flags=0x%x\n", flags);
case 0:
- data = fdata(data, "NBT Session Packet\nFlags=[rw]\nLength=[rd]\n",
+ data = smb_fdata(data, "NBT Session Packet\nFlags=[rw]\nLength=[rd]\n",
data + 4);
if (data == NULL)
break;
@@ -840,20 +840,20 @@ nbt_tcp_print(const uchar *data, int length)
break;
case 0x81:
- data = fdata(data,
+ data = smb_fdata(data,
"NBT Session Request\nFlags=[rW]\nDestination=[n1]\nSource=[n1]\n",
maxbuf);
break;
case 0x82:
- data = fdata(data, "NBT Session Granted\nFlags=[rW]\n", maxbuf);
+ data = smb_fdata(data, "NBT Session Granted\nFlags=[rW]\n", maxbuf);
break;
case 0x83:
{
int ecode = CVAL(data,4);
- data = fdata(data, "NBT SessionReject\nFlags=[rW]\nReason=[B]\n",
+ data = smb_fdata(data, "NBT SessionReject\nFlags=[rW]\nReason=[B]\n",
maxbuf);
switch (ecode) {
case 0x80:
@@ -876,12 +876,12 @@ nbt_tcp_print(const uchar *data, int length)
break;
case 0x85:
- data = fdata(data, "NBT Session Keepalive\nFlags=[rW]\n", maxbuf);
+ data = smb_fdata(data, "NBT Session Keepalive\nFlags=[rW]\n", maxbuf);
break;
default:
printf("flags=0x%x\n", flags);
- data = fdata(data, "NBT - Unknown packet type\nType=[rW]\n", maxbuf);
+ data = smb_fdata(data, "NBT - Unknown packet type\nType=[rW]\n", maxbuf);
}
printf("\n");
fflush(stdout);
@@ -892,9 +892,9 @@ nbt_tcp_print(const uchar *data, int length)
* print a NBT packet received across udp on port 137
*/
void
-nbt_udp137_print(const uchar *data, int length)
+nbt_udp137_print(const u_char *data, int length)
{
- const uchar *maxbuf = data + length;
+ const u_char *maxbuf = data + length;
int name_trn_id = RSVAL(data, 0);
int response = (CVAL(data, 2) >> 7);
int opcode = (CVAL(data, 2) >> 3) & 0xF;
@@ -965,7 +965,7 @@ nbt_udp137_print(const uchar *data, int length)
if (qdcount) {
printf("QuestionRecords:\n");
for (i = 0; i < qdcount; i++)
- p = fdata(p,
+ p = smb_fdata(p,
"|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",
maxbuf);
if (p == NULL)
@@ -978,28 +978,28 @@ nbt_udp137_print(const uchar *data, int length)
int rdlen;
int restype;
- p = fdata(p, "Name=[n1]\n#", maxbuf);
+ p = smb_fdata(p, "Name=[n1]\n#", maxbuf);
if (p == NULL)
goto out;
restype = RSVAL(p, 0);
- p = fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8);
+ p = smb_fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8);
if (p == NULL)
goto out;
rdlen = RSVAL(p, 0);
printf("ResourceLength=%d\nResourceData=\n", rdlen);
p += 2;
if (rdlen == 6) {
- p = fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen);
+ p = smb_fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen);
if (p == NULL)
goto out;
} else {
if (restype == 0x21) {
int numnames = CVAL(p, 0);
- p = fdata(p, "NumNames=[B]\n", p + 1);
+ p = smb_fdata(p, "NumNames=[B]\n", p + 1);
if (p == NULL)
goto out;
while (numnames--) {
- p = fdata(p, "Name=[n2]\t#", maxbuf);
+ p = smb_fdata(p, "Name=[n2]\t#", maxbuf);
if (p[0] & 0x80)
printf("<GROUP> ");
switch (p[0] & 0x60) {
@@ -1020,15 +1020,15 @@ nbt_udp137_print(const uchar *data, int length)
p += 2;
}
} else {
- print_data(p, min(rdlen, length - ((const uchar *)p - data)));
+ print_data(p, min(rdlen, length - ((const u_char *)p - data)));
p += rdlen;
}
}
}
}
- if ((uchar*)p < maxbuf)
- fdata(p, "AdditionalData:\n", maxbuf);
+ if ((u_char*)p < maxbuf)
+ smb_fdata(p, "AdditionalData:\n", maxbuf);
out:
printf("\n");
@@ -1041,9 +1041,9 @@ out:
* print a NBT packet received across udp on port 138
*/
void
-nbt_udp138_print(const uchar *data, int length)
+nbt_udp138_print(const u_char *data, int length)
{
- const uchar *maxbuf = data + length;
+ const u_char *maxbuf = data + length;
if (maxbuf > snapend)
maxbuf = snapend;
@@ -1056,7 +1056,7 @@ nbt_udp138_print(const uchar *data, int length)
return;
}
- data = fdata(data,
+ data = smb_fdata(data,
"\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#",
maxbuf);
@@ -1072,12 +1072,12 @@ nbt_udp138_print(const uchar *data, int length)
print netbeui frames
*/
void
-netbeui_print(u_short control, const uchar *data, int length)
+netbeui_print(u_short control, const u_char *data, int length)
{
- const uchar *maxbuf = data + length;
+ const u_char *maxbuf = data + length;
int len;
int command;
- const uchar *data2;
+ const u_char *data2;
int is_truncated = 0;
if (maxbuf > snapend)
@@ -1100,62 +1100,62 @@ netbeui_print(u_short control, const uchar *data, int length)
}
printf("\n>>> NetBeui Packet\nType=0x%X ", control);
- data = fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf);
+ data = smb_fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf);
if (data == NULL)
goto out;
switch (command) {
case 0xA:
- data = fdata(data, "NameQuery:[P1]\nSessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nDestination=[n2]\nSource=[n2]\n", data2);
+ data = smb_fdata(data, "NameQuery:[P1]\nSessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nDestination=[n2]\nSource=[n2]\n", data2);
break;
case 0x8:
- data = fdata(data,
+ data = smb_fdata(data,
"NetbiosDataGram:[P7]\nDestination=[n2]\nSource=[n2]\n", data2);
break;
case 0xE:
- data = fdata(data,
+ data = smb_fdata(data,
"NameRecognise:\n[P1]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nDestination=[n2]\nSource=[n2]\n",
data2);
break;
case 0x19:
- data = fdata(data,
+ data = smb_fdata(data,
"SessionInitialise:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
data2);
break;
case 0x17:
- data = fdata(data,
+ data = smb_fdata(data,
"SessionConfirm:\nData1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
data2);
break;
case 0x16:
- data = fdata(data,
+ data = smb_fdata(data,
"NetbiosDataOnlyLast:\nFlags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
data2);
break;
case 0x14:
- data = fdata(data,
+ data = smb_fdata(data,
"NetbiosDataAck:\n[P3]TransmitCorrelator=[w][P2]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
data2);
break;
case 0x18:
- data = fdata(data,
+ data = smb_fdata(data,
"SessionEnd:\n[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n",
data2);
break;
case 0x1f:
- data = fdata(data, "SessionAlive\n", data2);
+ data = smb_fdata(data, "SessionAlive\n", data2);
break;
default:
- data = fdata(data, "Unknown Netbios Command ", data2);
+ data = smb_fdata(data, "Unknown Netbios Command ", data2);
break;
}
if (data == NULL)
@@ -1194,14 +1194,14 @@ out:
* print IPX-Netbios frames
*/
void
-ipx_netbios_print(const uchar *data, u_int length)
+ipx_netbios_print(const u_char *data, u_int length)
{
/*
* this is a hack till I work out how to parse the rest of the
* NetBIOS-over-IPX stuff
*/
int i;
- const uchar *maxbuf;
+ const u_char *maxbuf;
maxbuf = data + length;
/* Don't go past the end of the captured data in the packet. */
@@ -1212,7 +1212,7 @@ ipx_netbios_print(const uchar *data, u_int length)
if (&data[i + 4] > maxbuf)
break;
if (memcmp(&data[i], "\377SMB", 4) == 0) {
- fdata(data, "\n>>> IPX transport ", &data[i]);
+ smb_fdata(data, "\n>>> IPX transport ", &data[i]);
if (data != NULL)
print_smb(&data[i], maxbuf);
printf("\n");
@@ -1221,5 +1221,5 @@ ipx_netbios_print(const uchar *data, u_int length)
}
}
if (i == 128)
- fdata(data, "\n>>> Unknown IPX ", maxbuf);
+ smb_fdata(data, "\n>>> Unknown IPX ", maxbuf);
}
diff --git a/smb.h b/smb.h
index a8ee2c20..446fb738 100644
--- a/smb.h
+++ b/smb.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.5 2001-06-25 18:58:08 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.6 2001-09-17 21:58:05 fenner Exp $ (LBL) */
/*
* Copyright (C) Andrew Tridgell 1995-1999
*
@@ -15,12 +15,12 @@
#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
-#define SVALS(buf,pos) ((int16)SVAL(buf,pos))
-#define IVALS(buf,pos) ((int32)IVAL(buf,pos))
-#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
-#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
-#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
-#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
+#define SVALS(buf,pos) ((int16_t)SVAL(buf,pos))
+#define IVALS(buf,pos) ((int32_t)IVAL(buf,pos))
+#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((u_int16_t)(val)))
+#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((u_int32_t)(val)))
+#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16_t)(val)))
+#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32_t)(val)))
/* now the reverse routines - these are used in nmb packets (mostly) */
#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
@@ -31,12 +31,6 @@
#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
-#define uint16 unsigned short
-#define uint32 unsigned int
-#ifndef uchar
-#define uchar unsigned char
-#endif
-
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
@@ -151,4 +145,4 @@
#define PTR_DIFF(p1, p2) ((size_t)(((char *)(p1)) - (char *)(p2)))
/* some protos */
-const uchar *fdata(const uchar *, const char *, const uchar *);
+const u_char *smb_fdata(const u_char *, const char *, const u_char *);
diff --git a/smbutil.c b/smbutil.c
index 92ae88ec..69744423 100644
--- a/smbutil.c
+++ b/smbutil.c
@@ -12,7 +12,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.16 2001-06-25 21:04:01 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.17 2001-09-17 21:58:05 fenner Exp $";
#endif
#include <sys/param.h>
@@ -31,15 +31,15 @@ static const char rcsid[] =
#include "interface.h"
#include "smb.h"
-extern const uchar *startbuf;
+extern const u_char *startbuf;
/*
* interpret a 32 bit dos packed date/time to some parameters
*/
static void
-interpret_dos_date(uint32 date, struct tm *tp)
+interpret_dos_date(u_int32_t date, struct tm *tp)
{
- uint32 p0, p1, p2, p3;
+ u_int32_t p0, p1, p2, p3;
p0 = date & 0xFF;
p1 = ((date & 0xFF00) >> 8) & 0xFF;
@@ -58,9 +58,9 @@ interpret_dos_date(uint32 date, struct tm *tp)
* create a unix date from a dos date
*/
static time_t
-make_unix_date(const void *date_ptr)
+make_unix_date(const u_char *date_ptr)
{
- uint32 dos_date = 0;
+ u_int32_t dos_date = 0;
struct tm t;
dos_date = IVAL(date_ptr, 0);
@@ -80,9 +80,9 @@ make_unix_date(const void *date_ptr)
* create a unix date from a dos date
*/
static time_t
-make_unix_date2(const void *date_ptr)
+make_unix_date2(const u_char *date_ptr)
{
- uint32 x, x2;
+ u_int32_t x, x2;
x = IVAL(date_ptr, 0);
x2 = ((x & 0xFFFF) << 16) | ((x & 0xFFFF0000) >> 16);
@@ -123,7 +123,7 @@ interpret_long_date(const char *p)
* we run past the end of the buffer
*/
static int
-name_interpret(const uchar *in, const uchar *maxbuf, char *out)
+name_interpret(const u_char *in, const u_char *maxbuf, char *out)
{
int ret;
int len;
@@ -162,11 +162,11 @@ trunc:
/*
* find a pointer to a netbios name
*/
-static const uchar *
-name_ptr(const uchar *buf, int ofs, const uchar *maxbuf)
+static const u_char *
+name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
{
- const uchar *p;
- uchar c;
+ const u_char *p;
+ u_char c;
p = buf + ofs;
if (p >= maxbuf)
@@ -177,7 +177,7 @@ name_ptr(const uchar *buf, int ofs, const uchar *maxbuf)
/* XXX - this should use the same code that the DNS dissector does */
if ((c & 0xC0) == 0xC0) {
- uint16 l = RSVAL(buf, ofs) & 0x3FFF;
+ u_int16_t l = RSVAL(buf, ofs) & 0x3FFF;
if (l == 0) {
/* We have a pointer that points to itself. */
return(NULL);
@@ -198,9 +198,9 @@ trunc:
* extract a netbios name from a buf
*/
static int
-name_extract(const uchar *buf, int ofs, const uchar *maxbuf, char *name)
+name_extract(const u_char *buf, int ofs, const u_char *maxbuf, char *name)
{
- const uchar *p = name_ptr(buf, ofs, maxbuf);
+ const u_char *p = name_ptr(buf, ofs, maxbuf);
if (p == NULL)
return(-1); /* error (probably name going past end of buffer) */
name[0] = '\0';
@@ -358,8 +358,8 @@ unistr(const char *s, int *len)
return buf;
}
-static const uchar *
-fdata1(const uchar *buf, const char *fmt, const uchar *maxbuf)
+static const u_char *
+smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf)
{
int reverse = 0;
char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
@@ -584,8 +584,8 @@ trunc:
return(NULL);
}
-const uchar *
-fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
+const u_char *
+smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf)
{
static int depth = 0;
char s[128];
@@ -596,9 +596,9 @@ fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
case '*':
fmt++;
while (buf < maxbuf) {
- const uchar *buf2;
+ const u_char *buf2;
depth++;
- buf2 = fdata(buf, fmt, maxbuf);
+ buf2 = smb_fdata(buf, fmt, maxbuf);
depth--;
if (buf2 == buf)
return(buf);
@@ -635,7 +635,7 @@ fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
strncpy(s, fmt, p - fmt);
s[p - fmt] = '\0';
fmt = p + 1;
- buf = fdata1(buf, s, maxbuf);
+ buf = smb_fdata1(buf, s, maxbuf);
if (buf == NULL)
return(NULL);
break;
@@ -657,9 +657,9 @@ fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
}
typedef struct {
- char *name;
+ const char *name;
int code;
- char *message;
+ const char *message;
} err_code_struct;
/* Dos Error Messages */
diff --git a/telnet.h b/telnet.h
index 1f15b72e..d712a7ee 100644
--- a/telnet.h
+++ b/telnet.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.2 2001-06-28 10:17:25 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.3 2001-09-17 21:58:06 fenner Exp $ (LBL) */
/* $NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp $ */
@@ -67,7 +67,7 @@
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
-char *telcmds[] = {
+const char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
@@ -128,7 +128,7 @@ extern char *telcmds[];
#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
#ifdef TELOPTS
-char *telopts[NTELOPTS+1] = {
+const char *telopts[NTELOPTS+1] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
@@ -228,7 +228,7 @@ char *telopts[NTELOPTS+1] = {
0,
#ifdef SLC_NAMES
-char *slc_names[] = {
+const char *slc_names[] = {
SLC_NAMELIST
};
#else
@@ -295,7 +295,7 @@ extern char *slc_names[];
#define AUTHTYPE_TEST 99
#ifdef AUTH_NAMES
-char *authtype_names[] = {
+const char *authtype_names[] = {
"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
};
#else
@@ -325,12 +325,12 @@ extern char *authtype_names[];
#define ENCTYPE_CNT 3
#ifdef ENCRYPT_NAMES
-char *encrypt_names[] = {
+const char *encrypt_names[] = {
"IS", "SUPPORT", "REPLY", "START", "END",
"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
0,
};
-char *enctype_names[] = {
+const char *enctype_names[] = {
"ANY", "DES_CFB64", "DES_OFB64", 0,
};
#else