summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguy <guy>2002-12-11 07:13:49 +0000
committerguy <guy>2002-12-11 07:13:49 +0000
commitfcc82f451d3e51fdf636abbf927edb287bada0e0 (patch)
tree938119171c0d1eb45c66c2f576b95293f04f468b
parent3a4254f5c662637cf669ff66b941240d7e456d6d (diff)
downloadtcpdump-fcc82f451d3e51fdf636abbf927edb287bada0e0.tar.gz
The "__attribute__((packed))" tag on structures causes some files not to
compile with Sun C, as "interface.h" isn't being included before the structures are being declared. Furthermore, in the files that Sun C *can* compile, it doesn't cause Sun C to generate code that's safe with unaligned accesses, as "__attribute__" is defined as a do-nothing macro with compilers that don't support it. Therefore, we get rid of that tag on the structures to which it was added, and instead use "EXTRACT_16BIT()" and "EXTRACT_32BIT()" to fetch 16-bit and 32-bit big-endian quantities from packets. We also fix some other references to multi-byte quantities to get rid of code that tries to do unaligned loads on platforms that don't support them. We also throw in a hack that makes those macros use "__attribute__((packed))" on structures containing only one 16-bit or 32-bit integer to get the compiler to generate unaligned-safe code rather than doing it by hand. (GCC on SPARC produces the same code that doing it by hand does; I don't know if GCC on any other big-endian strict-alignment processor generates better code for that case. On little-endian processors, as "ntohs()" and "ntohl()" might be functions, that might actually produce worse code.) Fix some places to use "%u" rather than "%d" to print unsigned quantities.
-rw-r--r--ah.h4
-rw-r--r--appletalk.h18
-rw-r--r--arcnet.h4
-rw-r--r--bootp.h6
-rw-r--r--decnet.h54
-rw-r--r--esp.h6
-rw-r--r--ether.h4
-rw-r--r--extract.h47
-rw-r--r--fddi.h4
-rw-r--r--icmp6.h44
-rw-r--r--ieee802_11.h32
-rw-r--r--igrp.h6
-rw-r--r--ip.h6
-rw-r--r--ip6.h16
-rw-r--r--ipfc.h4
-rw-r--r--ipsec_doi.h8
-rw-r--r--ipx.h4
-rw-r--r--isakmp.h36
-rw-r--r--lane.h6
-rw-r--r--llc.h4
-rw-r--r--nameser.h4
-rw-r--r--netbios.h4
-rw-r--r--nfs.h26
-rw-r--r--ntp.h8
-rw-r--r--oakley.h4
-rw-r--r--ospf.h10
-rw-r--r--ospf6.h12
-rw-r--r--print-ah.c7
-rw-r--r--print-arp.c30
-rw-r--r--print-atalk.c13
-rw-r--r--print-bgp.c16
-rw-r--r--print-bootp.c8
-rw-r--r--print-chdlc.c17
-rw-r--r--print-cnfp.c60
-rw-r--r--print-dhcp6.c23
-rw-r--r--print-domain.c22
-rw-r--r--print-egp.c17
-rw-r--r--print-esp.c15
-rw-r--r--print-fr.c6
-rw-r--r--print-frag6.c15
-rw-r--r--print-hsrp.c4
-rw-r--r--print-icmp.c36
-rw-r--r--print-icmp6.c65
-rw-r--r--print-igmp.c20
-rw-r--r--print-ip.c16
-rw-r--r--print-ip6.c7
-rw-r--r--print-ip6opts.c21
-rw-r--r--print-ipcomp.c7
-rw-r--r--print-isakmp.c20
-rw-r--r--print-isoclns.c26
-rw-r--r--print-krb.c4
-rw-r--r--print-lane.c13
-rw-r--r--print-lwres.c124
-rw-r--r--print-mobile.c4
-rw-r--r--print-mobility.c4
-rw-r--r--print-nfs.c244
-rw-r--r--print-ntp.c17
-rw-r--r--print-ospf.c51
-rw-r--r--print-ospf6.c66
-rw-r--r--print-pim.c4
-rw-r--r--print-pptp.c108
-rw-r--r--print-radius.c8
-rw-r--r--print-rip.c16
-rw-r--r--print-ripng.c5
-rw-r--r--print-rsvp.c6
-rw-r--r--print-rt6.c5
-rw-r--r--print-sctp.c56
-rw-r--r--print-sunrpc.c17
-rw-r--r--print-tcp.c86
-rw-r--r--print-tftp.c9
-rw-r--r--print-timed.c7
-rw-r--r--print-udp.c71
-rw-r--r--print-wb.c78
-rw-r--r--route6d.h6
-rw-r--r--rx.h6
-rw-r--r--sctpHeader.h70
-rw-r--r--sll.h4
-rw-r--r--tcp.h4
-rw-r--r--timed.h4
-rw-r--r--token.h4
-rw-r--r--udp.h4
81 files changed, 1025 insertions, 932 deletions
diff --git a/ah.h b/ah.h
index ca3969a9..c22806af 100644
--- a/ah.h
+++ b/ah.h
@@ -43,7 +43,7 @@ struct ah {
u_int16_t ah_reserve; /* Reserved for future use */
u_int32_t ah_spi; /* Security parameter index */
/* variable size, 32bit bound*/ /* Authentication data */
-} __attribute__((packed));
+};
struct newah {
u_int8_t ah_nxt; /* Next Header */
@@ -52,6 +52,6 @@ struct newah {
u_int32_t ah_spi; /* Security parameter index */
u_int32_t ah_seq; /* Sequence number field */
/* variable size, 32bit bound*/ /* Authentication data */
-} __attribute__((packed));
+};
#endif /*_NETINET6_AH_H_*/
diff --git a/appletalk.h b/appletalk.h
index 056be22f..552f3d13 100644
--- a/appletalk.h
+++ b/appletalk.h
@@ -20,14 +20,14 @@
*
* AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
*
- * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.14 2002-11-09 17:19:17 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.15 2002-12-11 07:13:49 guy Exp $ (LBL)
*/
struct LAP {
u_int8_t dst;
u_int8_t src;
u_int8_t type;
-} __attribute__((packed));
+};
#define lapShortDDP 1 /* short DDP type */
#define lapDDP 2 /* DDP type */
#define lapKLAP 'K' /* Kinetics KLAP type */
@@ -44,14 +44,14 @@ struct atDDP {
u_int8_t dstSkt;
u_int8_t srcSkt;
u_int8_t type;
-} __attribute__((packed));
+};
struct atShortDDP {
u_int16_t length;
u_int8_t dstSkt;
u_int8_t srcSkt;
u_int8_t type;
-} __attribute__((packed));
+};
#define ddpMaxWKS 0x7F
#define ddpMaxData 586
@@ -77,7 +77,7 @@ struct atATP {
u_int8_t bitmap;
u_int16_t transID;
int32_t userData;
-} __attribute__((packed));
+};
#define atpReqCode 0x40
#define atpRspCode 0x80
@@ -96,7 +96,7 @@ struct atATP {
struct atEcho {
u_int8_t echoFunction;
u_int8_t *echoData;
-} __attribute__((packed));
+};
#define echoSkt 4 /* the echoer socket */
#define echoSize 1 /* size of echo header */
@@ -109,14 +109,14 @@ struct atEcho {
struct atNBP {
u_int8_t control;
u_int8_t id;
-} __attribute__((packed));
+};
struct atNBPtuple {
u_int16_t net;
u_int8_t node;
u_int8_t skt;
u_int8_t enumerator;
-} __attribute__((packed));
+};
#define nbpBrRq 0x10
#define nbpLkUp 0x20
@@ -143,7 +143,7 @@ struct atNBPtuple {
struct zipHeader {
u_int8_t command;
u_int8_t netcount;
-} __attribute__((packed));
+};
#define zipHeaderSize 2
#define zipQuery 1
diff --git a/arcnet.h b/arcnet.h
index 89774004..144e99b6 100644
--- a/arcnet.h
+++ b/arcnet.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Id: arcnet.h,v 1.1 2001-04-17 08:39:18 guy Exp $ (LBL)
+ * @(#) $Id: arcnet.h,v 1.2 2002-12-11 07:13:50 guy Exp $ (LBL)
*
* from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
*/
@@ -56,7 +56,7 @@ struct arc_header {
u_int8_t arc_type2; /* same as arc_type */
u_int8_t arc_flag2; /* real flag value */
u_int16_t arc_seqid2; /* real seqid value */
-} __attribute__((__packed__));
+};
#define ARC_HDRLEN 3
#define ARC_HDRNEWLEN 6
diff --git a/bootp.h b/bootp.h
index c8bc49a5..a27e358d 100644
--- a/bootp.h
+++ b/bootp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.12 2002-11-09 17:19:17 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.13 2002-12-11 07:13:50 guy Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
@@ -36,7 +36,7 @@ struct bootp {
u_int8_t bp_sname[64]; /* server host name */
u_int8_t bp_file[128]; /* boot file name */
u_int8_t bp_vend[64]; /* vendor-specific area */
-} __attribute__((packed));
+};
/*
* UDP port numbers, server and client.
@@ -214,7 +214,7 @@ struct cmu_vend {
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
struct in_addr v_ts1, v_ts2; /* Time servers */
u_int8_t v_unused[24]; /* currently unused */
-} __attribute__((packed));
+};
/* v_flags values */
diff --git a/decnet.h b/decnet.h
index df6f5dc7..d25d157d 100644
--- a/decnet.h
+++ b/decnet.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.10 2002-11-09 17:19:17 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.11 2002-12-11 07:13:50 guy Exp $ (LBL)
*/
#ifndef WIN32
@@ -42,7 +42,7 @@ union etheraddress {
u_int8_t dne_hiord[4]; /* DECnet HIORD prefix */
u_int8_t dne_nodeaddr[2]; /* DECnet node address */
} dne_remote;
-} __attribute__((packed));
+};
typedef union etheraddress etheraddr; /* Ethernet address */
@@ -56,7 +56,7 @@ typedef union etheraddress etheraddr; /* Ethernet address */
struct dn_naddr {
u_int16_t a_len; /* length of address */
u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */
-} __attribute__((packed));
+};
/*
* Define long and short header formats.
@@ -67,7 +67,7 @@ struct shorthdr
word sh_dst; /* destination node address */
word sh_src; /* source node address */
byte sh_visits; /* visit count */
- } __attribute__((packed));
+ };
struct longhdr
{
@@ -82,13 +82,13 @@ struct longhdr
byte lg_visits; /* visit count */
byte lg_service; /* service class (reserved) */
byte lg_pt; /* protocol type (reserved) */
- } __attribute__((packed));
+ };
union routehdr
{
struct shorthdr rh_short; /* short route header */
struct longhdr rh_long; /* long route header */
- } __attribute__((packed));
+ };
/*
* Define the values of various fields in the protocol messages.
@@ -160,7 +160,7 @@ struct initmsgIII /* phase III initialization message */
byte inIII_eco; /* ECO number */
byte inIII_ueco; /* user ECO number */
byte inIII_rsvd; /* reserved image field */
- } __attribute__((packed));
+ };
struct initmsg /* initialization message */
{
@@ -173,35 +173,35 @@ struct initmsg /* initialization message */
byte in_ueco; /* user ECO number */
word in_hello; /* hello timer */
byte in_rsvd; /* reserved image field */
- } __attribute__((packed));
+ };
struct verifmsg /* verification message */
{
byte ve_flags; /* route flags */
word ve_src; /* source node address */
byte ve_fcnval; /* function value image field */
- } __attribute__((packed));
+ };
struct testmsg /* hello and test message */
{
byte te_flags; /* route flags */
word te_src; /* source node address */
byte te_data; /* test data image field */
- } __attribute__((packed));
+ };
struct l1rout /* level 1 routing message */
{
byte r1_flags; /* route flags */
word r1_src; /* source node address */
byte r1_rsvd; /* reserved field */
- } __attribute__((packed));
+ };
struct l2rout /* level 2 routing message */
{
byte r2_flags; /* route flags */
word r2_src; /* source node address */
byte r2_rsvd; /* reserved field */
- } __attribute__((packed));
+ };
struct rhellomsg /* router hello message */
{
@@ -216,7 +216,7 @@ struct rhellomsg /* router hello message */
byte rh_area; /* reserved */
word rh_hello; /* hello timer */
byte rh_mpd; /* reserved */
- } __attribute__((packed));
+ };
struct ehellomsg /* endnode hello message */
{
@@ -233,7 +233,7 @@ struct ehellomsg /* endnode hello message */
word eh_hello; /* hello timer */
byte eh_mpd; /* (reserved) */
byte eh_data; /* test data image field */
- } __attribute__((packed));
+ };
union controlmsg
{
@@ -244,7 +244,7 @@ union controlmsg
struct l2rout cm_l2rout; /* level 2 routing message */
struct rhellomsg cm_rhello; /* router hello message */
struct ehellomsg cm_ehello; /* endnode hello message */
- } __attribute__((packed));
+ };
/* Macros for decoding routing-info fields */
#define RI_COST(x) ((x)&0777)
@@ -366,7 +366,7 @@ struct nsphdr /* general nsp header */
byte nh_flags; /* message flags */
word nh_dst; /* destination link address */
word nh_src; /* source link address */
- } __attribute__((packed));
+ };
struct seghdr /* data segment header */
{
@@ -374,7 +374,7 @@ struct seghdr /* data segment header */
word sh_dst; /* destination link address */
word sh_src; /* source link address */
word sh_seq[3]; /* sequence numbers */
- } __attribute__((packed));
+ };
struct minseghdr /* minimum data segment header */
{
@@ -382,13 +382,13 @@ struct minseghdr /* minimum data segment header */
word ms_dst; /* destination link address */
word ms_src; /* source link address */
word ms_seq; /* sequence number */
- } __attribute__((packed));
+ };
struct lsmsg /* link service message (after hdr) */
{
byte ls_lsflags; /* link service flags */
byte ls_fcval; /* flow control value */
- } __attribute__((packed));
+ };
struct ackmsg /* acknowledgement message */
{
@@ -396,7 +396,7 @@ struct ackmsg /* acknowledgement message */
word ak_dst; /* destination link address */
word ak_src; /* source link address */
word ak_acknum[2]; /* acknowledgement numbers */
- } __attribute__((packed));
+ };
struct minackmsg /* minimum acknowledgement message */
{
@@ -404,13 +404,13 @@ struct minackmsg /* minimum acknowledgement message */
word mk_dst; /* destination link address */
word mk_src; /* source link address */
word mk_acknum; /* acknowledgement number */
- } __attribute__((packed));
+ };
struct ciackmsg /* connect acknowledgement message */
{
byte ck_flags; /* message flags */
word ck_dst; /* destination link address */
- } __attribute__((packed));
+ };
struct cimsg /* connect initiate message */
{
@@ -420,7 +420,7 @@ struct cimsg /* connect initiate message */
byte ci_services; /* requested services */
byte ci_info; /* information */
word ci_segsize; /* maximum segment size */
- } __attribute__((packed));
+ };
struct ccmsg /* connect confirm message */
{
@@ -431,7 +431,7 @@ struct ccmsg /* connect confirm message */
byte cc_info; /* information */
word cc_segsize; /* maximum segment size */
byte cc_optlen; /* optional data length */
- } __attribute__((packed));
+ };
struct cnmsg /* generic connect message */
{
@@ -441,7 +441,7 @@ struct cnmsg /* generic connect message */
byte cn_services; /* requested services */
byte cn_info; /* information */
word cn_segsize; /* maximum segment size */
- } __attribute__((packed));
+ };
struct dimsg /* disconnect initiate message */
{
@@ -450,7 +450,7 @@ struct dimsg /* disconnect initiate message */
word di_src; /* source link address */
word di_reason; /* reason code */
byte di_optlen; /* optional data length */
- } __attribute__((packed));
+ };
struct dcmsg /* disconnect confirm message */
{
@@ -458,4 +458,4 @@ struct dcmsg /* disconnect confirm message */
word dc_dst; /* destination link address */
word dc_src; /* source link address */
word dc_reason; /* reason code */
- } __attribute__((packed));
+ };
diff --git a/esp.h b/esp.h
index 16175760..56cdada0 100644
--- a/esp.h
+++ b/esp.h
@@ -46,7 +46,7 @@ struct esp {
/*8bit*/ /* next header */
/*8bit*/ /* next header */
/*variable size, 32bit bound*/ /* Authentication data (new IPsec) */
-} __attribute__((packed));
+};
struct newesp {
u_int32_t esp_spi; /* ESP */
@@ -57,12 +57,12 @@ struct newesp {
/*8bit*/ /* next header */
/*8bit*/ /* next header */
/*variable size, 32bit bound*/ /* Authentication data */
-} __attribute__((packed));
+};
struct esptail {
u_int8_t esp_padlen; /* pad length */
u_int8_t esp_nxt; /* Next header */
/*variable size, 32bit bound*/ /* Authentication data (new IPsec)*/
-} __attribute__((packed));
+};
#endif /*_NETINET6_ESP_H_*/
diff --git a/ether.h b/ether.h
index 3e0ebb19..e8b3a713 100644
--- a/ether.h
+++ b/ether.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.7 2002-11-09 17:19:18 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.8 2002-12-11 07:13:51 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -48,7 +48,7 @@ struct ether_header {
u_int8_t ether_dhost[ETHER_ADDR_LEN];
u_int8_t ether_shost[ETHER_ADDR_LEN];
u_int16_t ether_type;
-} __attribute__((packed));
+};
/*
* Length of a DEC/Intel/Xerox or 802.3 Ethernet header; note that some
diff --git a/extract.h b/extract.h
index 5e72d2e5..df5684f4 100644
--- a/extract.h
+++ b/extract.h
@@ -18,12 +18,48 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.18 2002-09-05 00:00:09 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.19 2002-12-11 07:13:51 guy Exp $ (LBL)
*/
/* Network to host order macros */
#ifdef LBL_ALIGN
+/*
+ * The processor doesn't natively handle unaligned loads.
+ */
+#ifdef HAVE___ATTRIBUTE__
+/*
+ * We have __attribute__; we assume that means we have __attribute__((packed)).
+ * Declare packed structures containing a u_int16_t and a u_int32_t,
+ * cast the pointer to point to one of those, and fetch through it;
+ * the GCC manual doesn't appear to explicitly say that
+ * __attribute__((packed)) causes the compiler to generate unaligned-safe
+ * code, but it apppears to do so.
+ *
+ * We do this in case the compiler can generate, for this instruction set,
+ * better code to do an unaligned load and pass stuff to "ntohs()" or
+ * "ntohl()" than the code to fetch the bytes one at a time and
+ * assemble them. (That might not be the case on a little-endian platform,
+ * where "ntohs()" and "ntohl()" might not be done inline.)
+ */
+typedef struct {
+ u_int16_t val;
+} __attribute__((packed)) unaligned_u_int16_t;
+
+typedef struct {
+ u_int32_t val;
+} __attribute__((packed)) unaligned_u_int32_t;
+
+#define EXTRACT_16BITS(p) \
+ ((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val))
+#define EXTRACT_32BITS(p) \
+ ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val))
+#else /* HAVE___ATTRIBUTE__ */
+/*
+ * We don't have __attribute__, so do unaligned loads of big-endian
+ * quantities the hard way - fetch the bytes one at a time and
+ * assemble them.
+ */
#define EXTRACT_16BITS(p) \
((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
(u_int16_t)*((const u_int8_t *)(p) + 1)))
@@ -32,12 +68,17 @@
(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
+#endif /* HAVE___ATTRIBUTE__ */
+#else /* LBL_ALIGN */
+/*
+ * The processor natively handles unaligned loads, so we can just
+ * cast the pointer and fetch through it.
+ */
#define EXTRACT_16BITS(p) \
((u_int16_t)ntohs(*(const u_int16_t *)(p)))
#define EXTRACT_32BITS(p) \
((u_int32_t)ntohl(*(const u_int32_t *)(p)))
-#endif
+#endif /* LBL_ALIGN */
#define EXTRACT_24BITS(p) \
((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
diff --git a/fddi.h b/fddi.h
index cbf6b2e0..df38c8e9 100644
--- a/fddi.h
+++ b/fddi.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.10 2002-11-09 17:19:18 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.11 2002-12-11 07:13:51 guy Exp $ (LBL)
*/
/*
@@ -35,7 +35,7 @@ struct fddi_header {
u_char fddi_fc; /* frame control */
u_char fddi_dhost[6];
u_char fddi_shost[6];
-} __attribute__((packed));
+};
/*
* Length of an FDDI header; note that some compilers may pad
diff --git a/icmp6.h b/icmp6.h
index e5c62d26..b51c9ed2 100644
--- a/icmp6.h
+++ b/icmp6.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.13 2002-11-09 17:19:18 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.14 2002-12-11 07:13:52 guy Exp $ (LBL) */
/* $NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp $ */
/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
@@ -78,7 +78,7 @@ struct icmp6_hdr {
u_int16_t icmp6_un_data16[2]; /* type-specific field */
u_int8_t icmp6_un_data8[4]; /* type-specific field */
} icmp6_dataun;
-} __attribute__((packed));
+};
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
#define icmp6_data16 icmp6_dataun.icmp6_un_data16
@@ -168,7 +168,7 @@ struct icmp6_hdr {
struct mld6_hdr {
struct icmp6_hdr mld6_hdr;
struct in6_addr mld6_addr; /* multicast address */
-} __attribute__((packed));
+};
#define mld6_type mld6_hdr.icmp6_type
#define mld6_code mld6_hdr.icmp6_code
@@ -183,7 +183,7 @@ struct mld6_hdr {
struct nd_router_solicit { /* router solicitation */
struct icmp6_hdr nd_rs_hdr;
/* could be followed by options */
-} __attribute__((packed));
+};
#define nd_rs_type nd_rs_hdr.icmp6_type
#define nd_rs_code nd_rs_hdr.icmp6_code
@@ -195,7 +195,7 @@ struct nd_router_advert { /* router advertisement */
u_int32_t nd_ra_reachable; /* reachable time */
u_int32_t nd_ra_retransmit; /* retransmit timer */
/* could be followed by options */
-} __attribute__((packed));
+};
#define nd_ra_type nd_ra_hdr.icmp6_type
#define nd_ra_code nd_ra_hdr.icmp6_code
@@ -223,7 +223,7 @@ struct nd_neighbor_solicit { /* neighbor solicitation */
struct icmp6_hdr nd_ns_hdr;
struct in6_addr nd_ns_target; /*target address */
/* could be followed by options */
-} __attribute__((packed));
+};
#define nd_ns_type nd_ns_hdr.icmp6_type
#define nd_ns_code nd_ns_hdr.icmp6_code
@@ -234,7 +234,7 @@ struct nd_neighbor_advert { /* neighbor advertisement */
struct icmp6_hdr nd_na_hdr;
struct in6_addr nd_na_target; /* target address */
/* could be followed by options */
-} __attribute__((packed));
+};
#define nd_na_type nd_na_hdr.icmp6_type
#define nd_na_code nd_na_hdr.icmp6_code
@@ -250,7 +250,7 @@ struct nd_redirect { /* redirect */
struct in6_addr nd_rd_target; /* target address */
struct in6_addr nd_rd_dst; /* destination address */
/* could be followed by options */
-} __attribute__((packed));
+};
#define nd_rd_type nd_rd_hdr.icmp6_type
#define nd_rd_code nd_rd_hdr.icmp6_code
@@ -261,7 +261,7 @@ struct nd_opt_hdr { /* Neighbor discovery option header */
u_int8_t nd_opt_type;
u_int8_t nd_opt_len;
/* followed by option specific data*/
-} __attribute__((packed));
+};
#define ND_OPT_SOURCE_LINKADDR 1
#define ND_OPT_TARGET_LINKADDR 2
@@ -282,7 +282,7 @@ struct nd_opt_prefix_info { /* prefix information */
u_int32_t nd_opt_pi_preferred_time;
u_int32_t nd_opt_pi_reserved2;
struct in6_addr nd_opt_pi_prefix;
-} __attribute__((packed));
+};
#define ND_OPT_PI_FLAG_ONLINK 0x80
#define ND_OPT_PI_FLAG_AUTO 0x40
@@ -294,21 +294,21 @@ struct nd_opt_rd_hdr { /* redirected header */
u_int16_t nd_opt_rh_reserved1;
u_int32_t nd_opt_rh_reserved2;
/* followed by IP header and data */
-} __attribute__((packed));
+};
struct nd_opt_mtu { /* MTU option */
u_int8_t nd_opt_mtu_type;
u_int8_t nd_opt_mtu_len;
u_int16_t nd_opt_mtu_reserved;
u_int32_t nd_opt_mtu_mtu;
-} __attribute__((packed));
+};
struct nd_opt_advinterval { /* Advertisement interval option */
u_int8_t nd_opt_adv_type;
u_int8_t nd_opt_adv_len;
u_int16_t nd_opt_adv_reserved;
u_int32_t nd_opt_adv_interval;
-} __attribute__((packed));
+};
struct nd_opt_homeagent_info { /* Home Agent info */
u_int8_t nd_opt_hai_type;
@@ -316,7 +316,7 @@ struct nd_opt_homeagent_info { /* Home Agent info */
u_int16_t nd_opt_hai_reserved;
int16_t nd_opt_hai_preference;
u_int16_t nd_opt_hai_lifetime;
-} __attribute__((packed));
+};
struct nd_opt_route_info { /* route info */
u_int8_t nd_opt_rti_type;
@@ -325,7 +325,7 @@ struct nd_opt_route_info { /* route info */
u_int8_t nd_opt_rti_flags;
u_int32_t nd_opt_rti_lifetime;
/* prefix follows */
-} __attribute__((packed));
+};
/*
* icmp6 namelookup
@@ -340,7 +340,7 @@ struct icmp6_namelookup {
u_int8_t icmp6_nl_name[3];
#endif
/* could be followed by options */
-} __attribute__((packed));
+};
/*
* icmp6 node information
@@ -349,7 +349,7 @@ struct icmp6_nodeinfo {
struct icmp6_hdr icmp6_ni_hdr;
u_int8_t icmp6_ni_nonce[8];
/* could be followed by reply data */
-} __attribute__((packed));
+};
#define ni_type icmp6_ni_hdr.icmp6_type
#define ni_code icmp6_ni_hdr.icmp6_code
@@ -381,7 +381,7 @@ struct ni_reply_fqdn {
u_int32_t ni_fqdn_ttl; /* TTL */
u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
-} __attribute__((packed));
+};
/*
* Router Renumbering. as router-renum-08.txt
@@ -392,7 +392,7 @@ struct icmp6_router_renum { /* router renumbering header */
u_int8_t rr_flags;
u_int16_t rr_maxdelay;
u_int32_t rr_reserved;
-} __attribute__((packed));
+};
#define ICMP6_RR_FLAGS_TEST 0x80
#define ICMP6_RR_FLAGS_REQRESULT 0x40
#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
@@ -413,7 +413,7 @@ struct rr_pco_match { /* match prefix part */
u_int8_t rpm_maxlen;
u_int16_t rpm_reserved;
struct in6_addr rpm_prefix;
-} __attribute__((packed));
+};
#define RPM_PCO_ADD 1
#define RPM_PCO_CHANGE 2
@@ -429,7 +429,7 @@ struct rr_pco_use { /* use prefix part */
u_int32_t rpu_pltime;
u_int32_t rpu_flags;
struct in6_addr rpu_prefix;
-} __attribute__((packed));
+};
#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
@@ -443,7 +443,7 @@ struct rr_result { /* router renumbering result message */
u_int8_t rrr_matchedlen;
u_int32_t rrr_ifid;
struct in6_addr rrr_prefix;
-} __attribute__((packed));
+};
/* network endian */
#define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002))
#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001))
diff --git a/ieee802_11.h b/ieee802_11.h
index 903d4e3d..f91ba757 100644
--- a/ieee802_11.h
+++ b/ieee802_11.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.5 2002-11-09 17:19:18 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.6 2002-12-11 07:13:52 guy Exp $ (LBL) */
/*
* Copyright (c) 2001
* Fortress Technologies
@@ -75,7 +75,7 @@ struct mgmt_header_t {
u_int8_t sa[6];
u_int8_t bssid[6];
u_int16_t seq_ctrl;
-} __attribute__((packed));
+};
#define MGMT_HEADER_LEN (2+2+6+6+6+2)
@@ -89,19 +89,19 @@ struct ssid_t {
u_int8_t element_id;
u_int8_t length;
u_char ssid[33]; /* 32 + 1 for null */
-} __attribute__((packed));
+};
struct rates_t {
u_int8_t element_id;
u_int8_t length;
u_int8_t rate[8];
-} __attribute__((packed));
+};
struct challenge_t {
u_int8_t element_id;
u_int8_t length;
u_int8_t text[254]; /* 1-253 + 1 for null */
-} __attribute__((packed));
+};
struct fh_t {
u_int8_t element_id;
u_int8_t length;
@@ -109,13 +109,13 @@ struct fh_t {
u_int8_t hop_set;
u_int8_t hop_pattern;
u_int8_t hop_index;
-} __attribute__((packed));
+};
struct ds_t {
u_int8_t element_id;
u_int8_t length;
u_int8_t channel;
-} __attribute__((packed));
+};
struct cf_t {
u_int8_t element_id;
@@ -124,7 +124,7 @@ struct cf_t {
u_int8_t period;
u_int16_t max_duration;
u_int16_t dur_remaing;
-} __attribute__((packed));
+};
struct tim_t {
u_int8_t element_id;
@@ -133,7 +133,7 @@ struct tim_t {
u_int8_t period;
u_int8_t bitmap_control;
u_int8_t bitmap[251];
-} __attribute__((packed));
+};
#define E_SSID 0
#define E_RATES 1
@@ -179,7 +179,7 @@ struct mgmt_body_t {
struct cf_t cf;
struct fh_t fh;
struct tim_t tim;
-} __attribute__((packed));
+};
struct ctrl_rts_t {
u_int16_t fc;
@@ -187,7 +187,7 @@ struct ctrl_rts_t {
u_int8_t ra[6];
u_int8_t ta[6];
u_int8_t fcs[4];
-} __attribute__((packed));
+};
#define CTRL_RTS_LEN (2+2+6+6+4)
@@ -196,7 +196,7 @@ struct ctrl_cts_t {
u_int16_t duration;
u_int8_t ra[6];
u_int8_t fcs[4];
-} __attribute__((packed));
+};
#define CTRL_CTS_LEN (2+2+6+4)
@@ -205,7 +205,7 @@ struct ctrl_ack_t {
u_int16_t duration;
u_int8_t ra[6];
u_int8_t fcs[4];
-} __attribute__((packed));
+};
#define CTRL_ACK_LEN (2+2+6+4)
@@ -215,7 +215,7 @@ struct ctrl_ps_poll_t {
u_int8_t bssid[6];
u_int8_t ta[6];
u_int8_t fcs[4];
-} __attribute__((packed));
+};
#define CTRL_PS_POLL_LEN (2+2+6+6+4)
@@ -225,7 +225,7 @@ struct ctrl_end_t {
u_int8_t ra[6];
u_int8_t bssid[6];
u_int8_t fcs[4];
-} __attribute__((packed));
+};
#define CTRL_END_LEN (2+2+6+6+4)
@@ -235,7 +235,7 @@ struct ctrl_end_ack_t {
u_int8_t ra[6];
u_int8_t bssid[6];
u_int8_t fcs[4];
-} __attribute__((packed));
+};
#define CTRL_END_ACK_LEN (2+2+6+6+4)
diff --git a/igrp.h b/igrp.h
index 882f7738..b5f133bc 100644
--- a/igrp.h
+++ b/igrp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.5 2002-11-09 17:19:19 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.6 2002-12-11 07:13:52 guy Exp $ (LBL) */
/* Cisco IGRP definitions */
/* IGRP Header */
@@ -13,7 +13,7 @@ struct igrphdr {
u_int16_t ig_ns; /* number of networks in AS */
u_int16_t ig_nx; /* number of networks ouside AS */
u_int16_t ig_sum; /* checksum of IGRP header & data */
-} __attribute__((packed));
+};
#define IGRP_UPDATE 1
#define IGRP_REQUEST 2
@@ -28,6 +28,6 @@ struct igrprte {
u_int8_t igr_rel; /* percent packets successfully tx/rx */
u_int8_t igr_ld; /* percent of channel occupied */
u_int8_t igr_hct; /* hop count */
-} __attribute__((packed));
+};
#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */
diff --git a/ip.h b/ip.h
index 5ebcbb33..eba63668 100644
--- a/ip.h
+++ b/ip.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.9 2002-11-09 17:19:19 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.10 2002-12-11 07:13:53 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -62,7 +62,7 @@ struct ip {
u_int8_t ip_p; /* protocol */
u_int16_t ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
-} __attribute__((packed));
+};
#define IP_MAXPACKET 65535 /* maximum packet size */
@@ -132,7 +132,7 @@ struct ip_timestamp {
u_int32_t ipt_time;
} ipt_ta[1];
} ipt_timestamp;
-} __attribute__((packed));
+};
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
diff --git a/ip6.h b/ip6.h
index 212f58c4..78b17a35 100644
--- a/ip6.h
+++ b/ip6.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.4 2002-11-09 17:19:19 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.5 2002-12-11 07:13:53 guy Exp $ (LBL) */
/* $NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp $ */
/* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */
@@ -86,7 +86,7 @@ struct ip6_hdr {
} ip6_ctlun;
struct in6_addr ip6_src; /* source address */
struct in6_addr ip6_dst; /* destination address */
-} __attribute__((packed));
+};
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
@@ -114,7 +114,7 @@ struct ip6_hdr {
struct ip6_ext {
u_char ip6e_nxt;
u_char ip6e_len;
-} __attribute__((packed));
+};
/* Hop-by-Hop options header */
/* XXX should we pad it to force alignment on an 8-byte boundary? */
@@ -122,7 +122,7 @@ struct ip6_hbh {
u_int8_t ip6h_nxt; /* next header */
u_int8_t ip6h_len; /* length in units of 8 octets */
/* followed by options */
-} __attribute__((packed));
+};
/* Destination options header */
/* XXX should we pad it to force alignment on an 8-byte boundary? */
@@ -130,7 +130,7 @@ struct ip6_dest {
u_int8_t ip6d_nxt; /* next header */
u_int8_t ip6d_len; /* length in units of 8 octets */
/* followed by options */
-} __attribute__((packed));
+};
/* Option types and related macros */
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
@@ -166,7 +166,7 @@ struct ip6_rthdr {
u_int8_t ip6r_type; /* routing type */
u_int8_t ip6r_segleft; /* segments left */
/* followed by routing type specific data */
-} __attribute__((packed));
+};
/* Type 0 Routing header */
struct ip6_rthdr0 {
@@ -177,7 +177,7 @@ struct ip6_rthdr0 {
u_int8_t ip6r0_reserved; /* reserved field */
u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */
struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
-} __attribute__((packed));
+};
/* Fragment header */
struct ip6_frag {
@@ -185,7 +185,7 @@ struct ip6_frag {
u_int8_t ip6f_reserved; /* reserved field */
u_int16_t ip6f_offlg; /* offset, reserved, and flag */
u_int32_t ip6f_ident; /* identification */
-} __attribute__((packed));
+};
/* network endian */
#define IP6F_OFF_MASK ((u_int16_t)htons(0xfff8)) /* mask out offset from _offlg */
diff --git a/ipfc.h b/ipfc.h
index 7c481faa..438d1156 100644
--- a/ipfc.h
+++ b/ipfc.h
@@ -18,12 +18,12 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/ipfc.h,v 1.3 2002-12-11 07:05:21 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/ipfc.h,v 1.4 2002-12-11 07:13:53 guy Exp $ (LBL)
*/
struct ipfc_header {
u_char ipfc_dhost[8];
u_char ipfc_shost[8];
-} __attribute__((packed));
+};
#define IPFC_HDRLEN 16
diff --git a/ipsec_doi.h b/ipsec_doi.h
index 151ed739..554a2586 100644
--- a/ipsec_doi.h
+++ b/ipsec_doi.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* YIPS @(#)$Id: ipsec_doi.h,v 1.6 2002-11-09 17:19:20 itojun Exp $ */
+/* YIPS @(#)$Id: ipsec_doi.h,v 1.7 2002-12-11 07:13:53 guy Exp $ */
/* refer to RFC 2407 */
@@ -114,12 +114,12 @@ struct ipsecdoi_sa {
struct isakmp_gen h;
u_int32_t doi; /* Domain of Interpretation */
u_int32_t sit; /* Situation */
-} __attribute__((packed));
+};
struct ipsecdoi_secrecy_h {
u_int16_t len;
u_int16_t reserved;
-} __attribute__((packed));
+};
/* 4.6.2.1 Identification Type Values */
struct ipsecdoi_id {
@@ -128,7 +128,7 @@ struct ipsecdoi_id {
u_int8_t proto_id; /* Protocol ID */
u_int16_t port; /* Port */
/* Identification Data */
-} __attribute__((packed));
+};
#define IPSECDOI_ID_IPV4_ADDR 1
#define IPSECDOI_ID_FQDN 2
diff --git a/ipx.h b/ipx.h
index f32d6160..bfc30198 100644
--- a/ipx.h
+++ b/ipx.h
@@ -1,7 +1,7 @@
/*
* IPX protocol formats
*
- * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.7 2002-11-09 17:19:20 itojun Exp $
+ * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.8 2002-12-11 07:13:54 guy Exp $
*/
/* well-known sockets */
@@ -25,7 +25,7 @@ struct ipxHdr {
u_int16_t srcNet[2]; /* source net */
u_int8_t srcNode[6]; /* source node */
u_int16_t srcSkt; /* source socket */
-} __attribute__((packed));
+};
#define ipxSize 30
diff --git a/isakmp.h b/isakmp.h
index 1fa4b60d..da46503f 100644
--- a/isakmp.h
+++ b/isakmp.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* YIPS @(#)$Id: isakmp.h,v 1.9 2002-11-09 17:19:21 itojun Exp $ */
+/* YIPS @(#)$Id: isakmp.h,v 1.10 2002-12-11 07:13:54 guy Exp $ */
/* refer to RFC 2408 */
@@ -110,7 +110,7 @@ struct isakmp {
u_int8_t flags; /* Flags */
msgid_t msgid;
u_int32_t len; /* Length */
-} __attribute__((packed));
+};
/* Next Payload Type */
#define ISAKMP_NPTYPE_NONE 0 /* NONE*/
@@ -153,7 +153,7 @@ struct isakmp_gen {
u_int8_t np; /* Next Payload */
u_int8_t reserved; /* RESERVED, unused, must set to 0 */
u_int16_t len; /* Payload Length */
-} __attribute__((packed));
+};
/* 3.3 Data Attributes
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -170,7 +170,7 @@ struct isakmp_data {
u_int16_t lorv; /* if f equal 1, Attribute Length */
/* if f equal 0, Attribute Value */
/* if f equal 1, Attribute Value */
-} __attribute__((packed));
+};
#define ISAKMP_GEN_TLV 0x0000
#define ISAKMP_GEN_TV 0x8000
/* mask for type of attribute format */
@@ -192,7 +192,7 @@ struct isakmp_pl_sa {
struct isakmp_gen h;
u_int32_t doi; /* Domain of Interpretation */
u_int32_t sit; /* Situation */
-} __attribute__((packed));
+};
/* 3.5 Proposal Payload */
/*
@@ -209,7 +209,7 @@ struct isakmp_pl_p {
u_int8_t spi_size; /* SPI Size */
u_int8_t num_t; /* Number of Transforms */
/* SPI */
-} __attribute__((packed));
+};
/* 3.6 Transform Payload */
/*
@@ -224,13 +224,13 @@ struct isakmp_pl_t {
u_int8_t t_id; /* Transform-Id */
u_int16_t reserved; /* RESERVED2 */
/* SA Attributes */
-} __attribute__((packed));
+};
/* 3.7 Key Exchange Payload */
struct isakmp_pl_ke {
struct isakmp_gen h;
/* Key Exchange Data */
-} __attribute__((packed));
+};
/* 3.8 Identification Payload */
/* MUST NOT to be used, because of being defined in ipsec-doi. */
@@ -241,7 +241,7 @@ struct isakmp_pl_id {
u_int32_t doi_data; /* DOI Specific ID Data */
} d;
/* Identification Data */
-} __attribute__((packed));
+};
/* 3.9 Certificate Payload */
struct isakmp_pl_cert {
@@ -253,7 +253,7 @@ struct isakmp_pl_cert {
certificate or certificate-related information contained in the
Certificate Data field.
*/
-} __attribute__((packed));
+};
/* Certificate Type */
#define ISAKMP_CERT_NONE 0
@@ -279,28 +279,28 @@ struct isakmp_pl_cr {
*/
/* # Certificate Authorities (1 octet) */
/* Certificate Authorities (variable length) */
-} __attribute__((packed));
+};
/* 3.11 Hash Payload */
/* may not be used, because of having only data. */
struct isakmp_pl_hash {
struct isakmp_gen h;
/* Hash Data */
-} __attribute__((packed));
+};
/* 3.12 Signature Payload */
/* may not be used, because of having only data. */
struct isakmp_pl_sig {
struct isakmp_gen h;
/* Signature Data */
-} __attribute__((packed));
+};
/* 3.13 Nonce Payload */
/* may not be used, because of having only data. */
struct isakmp_pl_nonce {
struct isakmp_gen h;
/* Nonce Data */
-} __attribute__((packed));
+};
/* 3.14 Notification Payload */
struct isakmp_pl_n {
@@ -311,7 +311,7 @@ struct isakmp_pl_n {
u_int16_t type; /* Notify Message Type */
/* SPI */
/* Notification Data */
-} __attribute__((packed));
+};
/* 3.14.1 Notify Message Types */
/* NOTIFY MESSAGES - ERROR TYPES */
@@ -354,20 +354,20 @@ struct isakmp_pl_d {
u_int8_t spi_size; /* SPI Size */
u_int16_t num_spi; /* # of SPIs */
/* SPI(es) */
-} __attribute__((packed));
+};
struct isakmp_ph1tab {
struct isakmp_ph1 *head;
struct isakmp_ph1 *tail;
int len;
-} __attribute__((packed));
+};
struct isakmp_ph2tab {
struct isakmp_ph2 *head;
struct isakmp_ph2 *tail;
int len;
-} __attribute__((packed));
+};
#define EXCHANGE_PROXY 1
#define EXCHANGE_MYSELF 0
diff --git a/lane.h b/lane.h
index 8ab5a2e9..76cc020e 100644
--- a/lane.h
+++ b/lane.h
@@ -20,7 +20,7 @@
*
*/
-/* $Id: lane.h,v 1.6 2002-11-09 17:19:21 itojun Exp $ */
+/* $Id: lane.h,v 1.7 2002-12-11 07:13:54 guy Exp $ */
#ifndef ETHER_ADDR_LEN
#define ETHER_ADDR_LEN 6
@@ -31,11 +31,11 @@ struct lecdatahdr_8023 {
u_int8_t h_dest[ETHER_ADDR_LEN];
u_int8_t h_source[ETHER_ADDR_LEN];
u_int16_t h_type;
-} __attribute__((packed));
+};
struct lane_controlhdr {
u_int16_t lec_header;
u_int8_t lec_proto;
u_int8_t lec_vers;
u_int16_t lec_opcode;
-} __attribute__((packed));
+};
diff --git a/llc.h b/llc.h
index 2861ec8f..5e6c74c3 100644
--- a/llc.h
+++ b/llc.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.15 2002-11-09 17:19:21 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.16 2002-12-11 07:13:54 guy Exp $ (LBL)
*/
/*
@@ -47,7 +47,7 @@ struct llc {
u_int8_t snap_ethertype[2];
} snap_ether;
} ctl;
-} __attribute__((packed));
+};
#define llcui ctl.snap.snap_ui
#define llcpi ctl.snap.snap_pi
diff --git a/nameser.h b/nameser.h
index 2638dab8..a1d504a8 100644
--- a/nameser.h
+++ b/nameser.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.12 2002-11-09 17:19:21 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.13 2002-12-11 07:13:55 guy Exp $ (LBL) */
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -211,7 +211,7 @@ typedef struct {
u_int16_t ancount; /* number of answer entries */
u_int16_t nscount; /* number of authority entries */
u_int16_t arcount; /* number of resource entries */
-} HEADER __attribute__((packed));
+} HEADER;
/*
* Macros for subfields of flag fields.
diff --git a/netbios.h b/netbios.h
index 0aaad32e..d3e2725f 100644
--- a/netbios.h
+++ b/netbios.h
@@ -1,14 +1,14 @@
/*
* NETBIOS protocol formats
*
- * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.2 2002-11-09 17:19:22 itojun Exp $
+ * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.3 2002-12-11 07:13:55 guy Exp $
*/
struct p8022Hdr {
u_char dsap;
u_char ssap;
u_char flags;
-} __attribute__((packed));
+};
#define p8022Size 3 /* min 802.2 header size */
diff --git a/nfs.h b/nfs.h
index f8956f0d..a63ee94e 100644
--- a/nfs.h
+++ b/nfs.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.6 2002-12-11 05:04:12 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.7 2002-12-11 07:13:55 guy Exp $ (LBL) */
/* $NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp $ */
/*
@@ -262,19 +262,19 @@ typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
union nfsfh {
/* fhandle_t fh_generic; */
u_char fh_bytes[NFS_SMALLFH];
-} __attribute__((packed));
+};
typedef union nfsfh nfsfh_t;
struct nfsv2_time {
u_int32_t nfsv2_sec;
u_int32_t nfsv2_usec;
-} __attribute__((packed));
+};
typedef struct nfsv2_time nfstime2;
struct nfsv3_time {
u_int32_t nfsv3_sec;
u_int32_t nfsv3_nsec;
-} __attribute__((packed));
+};
typedef struct nfsv3_time nfstime3;
/*
@@ -283,7 +283,7 @@ typedef struct nfsv3_time nfstime3;
*/
struct nfs_uquad {
u_int32_t nfsuquad[2];
-} __attribute__((packed));
+};
typedef struct nfs_uquad nfsuint64;
#if 0 /* XXX - this doesn't seemed to be used and it doesn't work
@@ -296,7 +296,7 @@ typedef struct nfs_uquad nfsuint64;
union nfs_quadconvert {
u_int32_t lval[2];
u_int64_t qval;
-} __attribute__((packed));
+};
typedef union nfs_quadconvert nfsquad_t;
#endif
@@ -307,7 +307,7 @@ typedef union nfs_quadconvert nfsquad_t;
struct nfsv3_spec {
u_int32_t specdata1;
u_int32_t specdata2;
-} __attribute__((packed));
+};
typedef struct nfsv3_spec nfsv3spec;
/*
@@ -348,7 +348,7 @@ struct nfs_fattr {
nfstime3 nfsv3fa_ctime;
} fa_nfsv3;
} fa_un;
-} __attribute__((packed));
+};
/* and some ugly defines for accessing union components */
#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size
@@ -376,7 +376,7 @@ struct nfsv2_sattr {
u_int32_t sa_size;
nfstime2 sa_atime;
nfstime2 sa_mtime;
-} __attribute__((packed));
+};
/*
* NFS Version 3 sattr structure for the new node creation case.
@@ -394,7 +394,7 @@ struct nfsv3_sattr {
nfstime3 sa_atime;
u_int32_t sa_mtimetype;
nfstime3 sa_mtime;
-} __attribute__((packed));
+};
struct nfs_statfs {
union {
@@ -415,7 +415,7 @@ struct nfs_statfs {
u_int32_t nfsv3sf_invarsec;
} sf_nfsv3;
} sf_un;
-} __attribute__((packed));
+};
#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize
#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize
@@ -441,7 +441,7 @@ struct nfsv3_fsinfo {
nfsuint64 fs_maxfilesize;
nfstime3 fs_timedelta;
u_int32_t fs_properties;
-} __attribute__((packed));
+};
struct nfsv3_pathconf {
u_int32_t pc_linkmax;
@@ -450,4 +450,4 @@ struct nfsv3_pathconf {
u_int32_t pc_chownrestricted;
u_int32_t pc_caseinsensitive;
u_int32_t pc_casepreserving;
-} __attribute__((packed));
+};
diff --git a/ntp.h b/ntp.h
index afdc0a8c..70695763 100644
--- a/ntp.h
+++ b/ntp.h
@@ -1,4 +1,4 @@
-/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.5 2002-11-09 17:19:22 itojun Exp $ */
+/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.6 2002-12-11 07:13:56 guy Exp $ */
/*
* Based on ntp.h from the U of MD implementation
@@ -30,12 +30,12 @@
struct l_fixedpt {
u_int32_t int_part;
u_int32_t fraction;
-} __attribute__((packed));
+};
struct s_fixedpt {
u_int16_t int_part;
u_int16_t fraction;
-} __attribute__((packed));
+};
/* ================= Table 3.3. Packet Variables ================= */
/*
@@ -79,7 +79,7 @@ struct ntpdata {
struct l_fixedpt org;
struct l_fixedpt rec;
struct l_fixedpt xmt;
-} __attribute__((packed));
+};
/*
* Leap Second Codes (high order two bits)
*/
diff --git a/oakley.h b/oakley.h
index b94f032c..ad328171 100644
--- a/oakley.h
+++ b/oakley.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* YIPS @(#)$Id: oakley.h,v 1.3 2002-11-09 17:19:22 itojun Exp $ */
+/* YIPS @(#)$Id: oakley.h,v 1.4 2002-12-11 07:13:56 guy Exp $ */
/* refer to RFC 2409 */
@@ -120,7 +120,7 @@ struct oakley_sa {
u_int8_t enc_t; /* type of cipher */
u_int8_t life_t; /* type of duration of lifetime */
u_int32_t ldur; /* life duration */
-} __attribute__((packed));
+};
#endif
#endif /* !defined(_ISAKMP_OAKLEY_H_) */
diff --git a/ospf.h b/ospf.h
index 7652cec2..8307f1cc 100644
--- a/ospf.h
+++ b/ospf.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.6 2002-12-11 07:07:25 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.7 2002-12-11 07:13:56 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -112,7 +112,7 @@ struct lsa_hdr {
u_int32_t ls_seq;
u_int16_t ls_chksum;
u_int16_t ls_length;
-} __attribute__((packed));
+};
/* link state advertisement */
struct lsa {
@@ -173,7 +173,7 @@ struct lsa {
} un_opaque[1];
} lsa_un;
-} __attribute__((packed));
+};
/*
@@ -183,7 +183,7 @@ struct tos_metric {
u_int8_t tos_type;
u_int8_t tos_zero;
u_int16_t tos_metric;
-} __attribute__((packed));
+};
#define OSPF_AUTH_SIZE 8
@@ -240,7 +240,7 @@ struct ospfhdr {
struct lsa_hdr lsa_lshdr[1]; /* may repeat */
} un_lsa ;
} ospf_un ;
-} __attribute__((packed));
+};
#define ospf_hello ospf_un.un_hello
#define ospf_db ospf_un.un_db
diff --git a/ospf6.h b/ospf6.h
index 363ed5fa..2fbbfa0c 100644
--- a/ospf6.h
+++ b/ospf6.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.5 2002-11-09 17:19:23 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.6 2002-12-11 07:13:56 guy Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -105,14 +105,14 @@ struct lsa_hdr {
u_int32_t ls_seq;
u_int16_t ls_chksum;
u_int16_t ls_length;
-} __attribute__((packed));
+};
struct lsa_prefix {
u_int8_t lsa_p_len;
u_int8_t lsa_p_opt;
u_int16_t lsa_p_mbz;
u_int8_t lsa_p_prefix[4];
-} __attribute__((packed));
+};
/* link state advertisement */
struct lsa {
@@ -195,7 +195,7 @@ struct lsa {
struct lsa_prefix intra_ap_prefix[1];
} un_intra_ap;
} lsa_un;
-} __attribute__((packed));
+};
/*
@@ -205,7 +205,7 @@ struct tos_metric {
u_int8_t tos_type;
u_int8_t tos_zero;
u_int16_t tos_metric;
-} __attribute__((packed));
+};
#define OSPF_AUTH_SIZE 8
@@ -268,7 +268,7 @@ struct ospf6hdr {
struct lsa_hdr lsa_lshdr[1]; /* may repeat */
} un_lsa ;
} ospf6_un ;
-} __attribute__((packed));
+};
#define ospf6_hello ospf6_un.un_hello
#define ospf6_db ospf6_un.un_db
diff --git a/print-ah.c b/print-ah.c
index aab57578..e106d467 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.18 2002-09-05 21:25:36 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.19 2002-12-11 07:13:57 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -38,6 +38,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
int
ah_print(register const u_char *bp)
@@ -53,12 +54,12 @@ ah_print(register const u_char *bp)
TCHECK(*ah);
sumlen = ah->ah_len << 2;
- spi = (u_int32_t)ntohl(ah->ah_spi);
+ spi = EXTRACT_32BITS(&ah->ah_spi);
printf("AH(spi=0x%08x", spi);
if (vflag)
printf(",sumlen=%d", sumlen);
- printf(",seq=0x%x", (u_int32_t)ntohl(*(const u_int32_t *)(ah + 1)));
+ printf(",seq=0x%x", EXTRACT_32BITS(ah + 1));
if (bp + sizeof(struct ah) + sumlen > ep)
fputs("[truncated]", stdout);
fputs("): ", stdout);
diff --git a/print-arp.c b/print-arp.c
index c5a05a94..dcfa13f1 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.59 2002-11-09 17:19:23 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.60 2002-12-11 07:13:57 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -81,15 +81,15 @@ struct arp_pkthdr {
#define ar_spa(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln)
#define ar_tha(ap) (((const u_char *)((ap)+1))+ (ap)->ar_hln+(ap)->ar_pln)
#define ar_tpa(ap) (((const u_char *)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
-} __attribute__((packed));
+};
#define ARP_HDRLEN 8
-#define HRD(ap) ((ap)->ar_hrd)
+#define HRD(ap) EXTRACT_16BITS(&(ap)->ar_hrd)
#define HLN(ap) ((ap)->ar_hln)
#define PLN(ap) ((ap)->ar_pln)
-#define OP(ap) ((ap)->ar_op)
-#define PRO(ap) ((ap)->ar_pro)
+#define OP(ap) EXTRACT_16BITS(&(ap)->ar_op)
+#define PRO(ap) EXTRACT_16BITS(&(ap)->ar_pro)
#define SHA(ap) (ar_sha(ap))
#define SPA(ap) (ar_spa(ap))
#define THA(ap) (ar_tha(ap))
@@ -131,12 +131,12 @@ struct atmarp_pkthdr {
u_char aar_tpa[]; /* target protocol address */
#endif
-#define ATMHRD(ap) ((ap)->aar_hrd)
+#define ATMHRD(ap) EXTRACT_16BITS(&(ap)->aar_hrd)
#define ATMSHLN(ap) ((ap)->aar_shtl & ATMARP_LEN_MASK)
#define ATMSSLN(ap) ((ap)->aar_sstl & ATMARP_LEN_MASK)
#define ATMSPLN(ap) ((ap)->aar_spln)
-#define ATMOP(ap) ((ap)->aar_op)
-#define ATMPRO(ap) ((ap)->aar_pro)
+#define ATMOP(ap) EXTRACT_16BITS(&(ap)->aar_op)
+#define ATMPRO(ap) EXTRACT_16BITS(&(ap)->aar_pro)
#define ATMTHLN(ap) ((ap)->aar_thtl & ATMARP_LEN_MASK)
#define ATMTSLN(ap) ((ap)->aar_tstl & ATMARP_LEN_MASK)
#define ATMTPLN(ap) ((ap)->aar_tpln)
@@ -146,7 +146,7 @@ struct atmarp_pkthdr {
#define aar_tha(ap) (aar_spa(ap) + ATMSPLN(ap))
#define aar_tsa(ap) (aar_tha(ap) + ATMTHLN(ap))
#define aar_tpa(ap) (aar_tsa(ap) + ATMTSLN(ap))
-} __attribute__((packed));
+};
#define ATMSHA(ap) (aar_sha(ap))
#define ATMSSA(ap) (aar_ssa(ap))
@@ -179,9 +179,9 @@ atmarp_print(const u_char *bp, u_int length, u_int caplen)
ap = (const struct atmarp_pkthdr *)bp;
TCHECK(*ap);
- hrd = EXTRACT_16BITS(&ATMHRD(ap));
- pro = EXTRACT_16BITS(&ATMPRO(ap));
- op = EXTRACT_16BITS(&ATMOP(ap));
+ hrd = ATMHRD(ap);
+ pro = ATMPRO(ap);
+ op = ATMOP(ap);
if (!TTEST2(*aar_tpa(ap), ATMTPLN(ap))) {
(void)printf("truncated-atmarp");
@@ -256,13 +256,13 @@ arp_print(const u_char *bp, u_int length, u_int caplen)
ap = (const struct arp_pkthdr *)bp;
TCHECK(*ap);
- hrd = EXTRACT_16BITS(&HRD(ap));
+ hrd = HRD(ap);
if (hrd == ARPHRD_ATM2225) {
atmarp_print(bp, length, caplen);
return;
}
- pro = EXTRACT_16BITS(&PRO(ap));
- op = EXTRACT_16BITS(&OP(ap));
+ pro = PRO(ap);
+ op = OP(ap);
if (!TTEST2(*ar_tpa(ap), PLN(ap))) {
(void)printf("truncated-arp");
diff --git a/print-atalk.c b/print-atalk.c
index df94bf6b..e415f9a7 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.76 2002-11-09 17:19:24 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.77 2002-12-11 07:13:57 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -61,7 +61,7 @@ struct aarp {
u_int8_t psaddr[4];
u_int8_t hdaddr[6];
u_int8_t pdaddr[4];
-} __attribute__((packed));
+};
static char tstr[] = "[|atalk]";
@@ -202,9 +202,10 @@ aarp_print(register const u_char *bp, u_int length)
printf("aarp ");
ap = (const struct aarp *)bp;
- if (ntohs(ap->htype) == 1 && ntohs(ap->ptype) == ETHERTYPE_ATALK &&
+ if (EXTRACT_16BITS(&ap->htype) == 1 &&
+ EXTRACT_16BITS(&ap->ptype) == ETHERTYPE_ATALK &&
ap->halen == 6 && ap->palen == 4 )
- switch (ntohs(ap->op)) {
+ switch (EXTRACT_16BITS(&ap->op)) {
case 1: /* request */
(void)printf("who-has %s tell %s",
@@ -222,8 +223,8 @@ aarp_print(register const u_char *bp, u_int length)
return;
}
(void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
- length, ntohs(ap->op), ntohs(ap->htype), ntohs(ap->ptype),
- ap->halen, ap->palen);
+ length, EXTRACT_16BITS(&ap->op), EXTRACT_16BITS(&ap->htype),
+ EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen);
}
/*
diff --git a/print-bgp.c b/print-bgp.c
index 94f458ae..e8bdcbb6 100644
--- a/print-bgp.c
+++ b/print-bgp.c
@@ -36,7 +36,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.55 2002-11-09 17:19:24 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.56 2002-12-11 07:13:58 guy Exp $";
#endif
#include <tcpdump-stdinc.h>
@@ -52,7 +52,7 @@ struct bgp {
u_int8_t bgp_marker[16];
u_int16_t bgp_len;
u_int8_t bgp_type;
-} __attribute__((packed));
+};
#define BGP_SIZE 19 /* unaligned */
#define BGP_OPEN 1
@@ -80,14 +80,14 @@ struct bgp_open {
u_int32_t bgpo_id;
u_int8_t bgpo_optlen;
/* options should follow */
-} __attribute__((packed));
+};
#define BGP_OPEN_SIZE 29 /* unaligned */
struct bgp_opt {
u_int8_t bgpopt_type;
u_int8_t bgpopt_len;
/* variable length */
-} __attribute__((packed));
+};
#define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */
struct bgp_notification {
@@ -97,7 +97,7 @@ struct bgp_notification {
u_int8_t bgpn_major;
u_int8_t bgpn_minor;
/* data should follow */
-} __attribute__((packed));
+};
#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
struct bgp_route_refresh {
@@ -107,7 +107,7 @@ struct bgp_route_refresh {
u_int8_t afi[2]; /* the compiler messes this structure up */
u_int8_t res; /* when doing misaligned sequences of int8 and int16 */
u_int8_t safi; /* afi should be int16 - so we have to access it using */
-} __attribute__((packed)); /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */
+}; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */
#define BGP_ROUTE_REFRESH_SIZE 23
struct bgp_attr {
@@ -119,10 +119,10 @@ struct bgp_attr {
} bgpa_len;
#define bgp_attr_len(p) \
(((p)->bgpa_flags & 0x10) ? \
- ntohs((p)->bgpa_len.elen) : (p)->bgpa_len.len)
+ EXTRACT_16BITS(&(p)->bgpa_len.elen) : (p)->bgpa_len.len)
#define bgp_attr_off(p) \
(((p)->bgpa_flags & 0x10) ? 4 : 3)
-} __attribute__((packed));
+};
#define BGPTYPE_ORIGIN 1
#define BGPTYPE_AS_PATH 2
diff --git a/print-bootp.c b/print-bootp.c
index cf8bdc9c..ed7c76ab 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.67 2002-12-04 19:09:29 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.68 2002-12-11 07:13:58 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -95,11 +95,11 @@ bootp_print(register const u_char *cp, u_short sport, u_short dport, u_int lengt
if (bp->bp_hops)
printf(", hops:%d", bp->bp_hops);
if (bp->bp_xid)
- printf(", xid:0x%x", (u_int32_t)ntohl(bp->bp_xid));
+ printf(", xid:0x%x", EXTRACT_32BITS(&bp->bp_xid));
if (bp->bp_secs)
- printf(", secs:%d", ntohs(bp->bp_secs));
+ printf(", secs:%d", EXTRACT_16BITS(&bp->bp_secs));
if (bp->bp_flags)
- printf(", flags:0x%x", ntohs(bp->bp_flags));
+ printf(", flags:0x%x", EXTRACT_16BITS(&bp->bp_flags));
/* Client's ip address */
TCHECK(bp->bp_ciaddr);
diff --git a/print-chdlc.c b/print-chdlc.c
index 24b31ac8..f958ca4f 100644
--- a/print-chdlc.c
+++ b/print-chdlc.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.23 2002-12-04 19:06:50 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.24 2002-12-11 07:13:58 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -155,7 +155,7 @@ struct cisco_slarp {
u_int16_t t2;
} keep;
} un;
-} __attribute__((packed));
+};
#define SLARP_LEN 18
@@ -171,7 +171,7 @@ chdlc_slarp_print(const u_char *cp, u_int length)
slarp = (const struct cisco_slarp *)cp;
printf("SLARP (length: %u), ",length);
- switch (ntohl(slarp->code)) {
+ switch (EXTRACT_32BITS(&slarp->code)) {
case SLARP_REQUEST:
printf("request");
/* ok we do not know it - but lets at least dump it */
@@ -184,14 +184,15 @@ chdlc_slarp_print(const u_char *cp, u_int length)
break;
case SLARP_KEEPALIVE:
printf("keepalive: mineseen=0x%08x, yourseen=0x%08x",
- (u_int32_t)ntohl(slarp->un.keep.myseq),
- (u_int32_t)ntohl(slarp->un.keep.yourseq));
+ EXTRACT_32BITS(&slarp->un.keep.myseq),
+ EXTRACT_32BITS(&slarp->un.keep.yourseq));
printf(", reliability=0x%04x, t1=%d.%d",
- ntohs(slarp->un.keep.rel), ntohs(slarp->un.keep.t1),
- ntohs(slarp->un.keep.t2));
+ EXTRACT_16BITS(&slarp->un.keep.rel),
+ EXTRACT_16BITS(&slarp->un.keep.t1),
+ EXTRACT_16BITS(&slarp->un.keep.t2));
break;
default:
- printf("0x%02x unknown", (u_int32_t)ntohl(slarp->code));
+ printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code));
if (vflag <= 1)
print_unknown_data(cp+4,"\n\t",length-4);
break;
diff --git a/print-cnfp.c b/print-cnfp.c
index 94a05807..2fe76b62 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.12 2002-11-09 17:19:25 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.13 2002-12-11 07:13:58 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -47,8 +47,8 @@ static const char rcsid[] =
#include <string.h>
#include "interface.h"
-
#include "addrtoname.h"
+#include "extract.h"
#include "tcp.h"
@@ -59,7 +59,7 @@ struct nfhdr {
u_int32_t utc_nsec;
u_int32_t sequence; /* v5 flow sequence number */
u_int32_t reserved; /* v5 only */
-} __attribute__((packed));
+};
struct nfrec {
struct in_addr src_ina;
@@ -75,7 +75,7 @@ struct nfrec {
u_int32_t asses; /* v1: flags; v5: src,dst AS */
u_int32_t masks; /* src,dst addr prefix; v6: encaps */
struct in_addr peer_nexthop; /* v6: IP address of the nexthop within the peer (FIB)*/
-} __attribute__((packed));
+};
void
cnfp_print(const u_char *cp, const u_char *bp)
@@ -93,18 +93,18 @@ cnfp_print(const u_char *cp, const u_char *bp)
if ((const u_char *)(nh + 1) > snapend)
return;
- nrecs = ntohl(nh->ver_cnt) & 0xffff;
- ver = (ntohl(nh->ver_cnt) & 0xffff0000) >> 16;
- t = ntohl(nh->utc_sec);
+ nrecs = EXTRACT_32BITS(&nh->ver_cnt) & 0xffff;
+ ver = (EXTRACT_32BITS(&nh->ver_cnt) & 0xffff0000) >> 16;
+ t = EXTRACT_32BITS(&nh->utc_sec);
/* (p = ctime(&t))[24] = '\0'; */
printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
- (unsigned)ntohl(nh->msys_uptime)/1000,
- (unsigned)ntohl(nh->msys_uptime)%1000,
- (unsigned)ntohl(nh->utc_sec), (unsigned)ntohl(nh->utc_nsec));
+ EXTRACT_32BITS(&nh->msys_uptime)/1000,
+ EXTRACT_32BITS(&nh->msys_uptime)%1000,
+ EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec));
if (ver == 5 || ver == 6) {
- printf("#%u, ", (unsigned)htonl(nh->sequence));
+ printf("#%u, ", EXTRACT_32BITS(&nh->sequence));
nr = (const struct nfrec *)&nh[1];
snaplen -= 24;
} else {
@@ -119,36 +119,36 @@ cnfp_print(const u_char *cp, const u_char *bp)
char asbuf[20];
printf("\n started %u.%03u, last %u.%03u",
- (unsigned)ntohl(nr->start_time)/1000,
- (unsigned)ntohl(nr->start_time)%1000,
- (unsigned)ntohl(nr->last_time)/1000,
- (unsigned)ntohl(nr->last_time)%1000);
+ EXTRACT_32BITS(&nr->start_time)/1000,
+ EXTRACT_32BITS(&nr->start_time)%1000,
+ EXTRACT_32BITS(&nr->last_time)/1000,
+ EXTRACT_32BITS(&nr->last_time)%1000);
asbuf[0] = buf[0] = '\0';
if (ver == 5 || ver == 6) {
snprintf(buf, sizeof(buf), "/%u",
- (unsigned)(ntohl(nr->masks) >> 24) & 0xff);
+ (EXTRACT_32BITS(&nr->masks) >> 24) & 0xff);
snprintf(asbuf, sizeof(asbuf), ":%u",
- (unsigned)(ntohl(nr->asses) >> 16) & 0xffff);
+ (EXTRACT_32BITS(&nr->asses) >> 16) & 0xffff);
}
printf("\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
- (unsigned)ntohl(nr->ports) >> 16);
+ EXTRACT_32BITS(&nr->ports) >> 16);
if (ver == 5 || ver ==6) {
snprintf(buf, sizeof(buf), "/%d",
- (unsigned)(ntohl(nr->masks) >> 16) & 0xff);
+ (EXTRACT_32BITS(&nr->masks) >> 16) & 0xff);
snprintf(asbuf, sizeof(asbuf), ":%u",
- (unsigned)ntohl(nr->asses) & 0xffff);
+ EXTRACT_32BITS(&nr->asses) & 0xffff);
}
printf("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
- (unsigned)ntohl(nr->ports) & 0xffff);
+ EXTRACT_32BITS(&nr->ports) & 0xffff);
printf(">> %s\n ", intoa(nr->nhop_ina.s_addr));
- pent = getprotobynumber((ntohl(nr->proto_tos) >> 8) & 0xff);
+ pent = getprotobynumber((EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff);
if (!pent || nflag)
printf("%u ",
- (unsigned)(ntohl(nr->proto_tos) >> 8) & 0xff);
+ (EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff);
else
printf("%s ", pent->p_name);
@@ -156,9 +156,9 @@ cnfp_print(const u_char *cp, const u_char *bp)
if (pent && pent->p_proto == IPPROTO_TCP) {
int flags;
if (ver == 1)
- flags = (ntohl(nr->asses) >> 24) & 0xff;
+ flags = (EXTRACT_32BITS(&nr->asses) >> 24) & 0xff;
else
- flags = (ntohl(nr->proto_tos) >> 16) & 0xff;
+ flags = (EXTRACT_32BITS(&nr->proto_tos) >> 16) & 0xff;
if (flags & TH_FIN) putchar('F');
if (flags & TH_SYN) putchar('S');
if (flags & TH_RST) putchar('R');
@@ -172,12 +172,12 @@ cnfp_print(const u_char *cp, const u_char *bp)
buf[0]='\0';
if (ver == 6) {
snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
- (unsigned)(ntohl(nr->masks) >> 8) & 0xff,
- (unsigned)(ntohl(nr->masks)) & 0xff);
+ (EXTRACT_32BITS(&nr->masks) >> 8) & 0xff,
+ (EXTRACT_32BITS(&nr->masks)) & 0xff);
}
printf("tos %u, %u (%u octets) %s",
- (unsigned)ntohl(nr->proto_tos) & 0xff,
- (unsigned)ntohl(nr->packets),
- (unsigned)ntohl(nr->octets), buf);
+ EXTRACT_32BITS(&nr->proto_tos) & 0xff,
+ EXTRACT_32BITS(&nr->packets),
+ EXTRACT_32BITS(&nr->octets), buf);
}
}
diff --git a/print-dhcp6.c b/print-dhcp6.c
index 51fccaf4..9c045264 100644
--- a/print-dhcp6.c
+++ b/print-dhcp6.c
@@ -32,7 +32,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.22 2002-08-02 04:05:51 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.23 2002-12-11 07:13:59 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -46,6 +46,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
/* lease duration */
#define DHCP6_DURATITION_INFINITE 0xffffffff
@@ -74,7 +75,7 @@ struct dhcp6 {
u_int32_t x;
} dh6_msgtypexid;
/* options follow */
-} __attribute__ ((__packed__));
+};
#define dh6_msgtype dh6_msgtypexid.m
#define dh6_xid dh6_msgtypexid.x
#define DH6_XIDMASK 0x00ffffff
@@ -127,7 +128,7 @@ struct dhcp6opt {
u_int16_t dh6opt_type;
u_int16_t dh6opt_len;
/* type-dependent data follows */
-} __attribute__ ((__packed__));
+};
static char *
dhcp6opt_name(int type)
@@ -212,10 +213,10 @@ dhcp6opt_print(u_char *cp, u_char *ep)
if (ep - cp < sizeof(*dh6o))
goto trunc;
dh6o = (struct dhcp6opt *)cp;
- optlen = ntohs(dh6o->dh6opt_len);
+ optlen = EXTRACT_16BITS(&dh6o->dh6opt_len);
if (ep - cp < sizeof(*dh6o) + optlen)
goto trunc;
- opttype = ntohs(dh6o->dh6opt_type);
+ opttype = EXTRACT_16BITS(&dh6o->dh6opt_type);
printf(" (%s", dhcp6opt_name(opttype));
switch (opttype) {
case DH6OPT_CLIENTID:
@@ -226,12 +227,12 @@ dhcp6opt_print(u_char *cp, u_char *ep)
break;
}
tp = (u_char *)(dh6o + 1);
- switch (ntohs(*(u_int16_t *)tp)) {
+ switch (EXTRACT_16BITS(tp)) {
case 1:
if (optlen >= 2 + 6) {
printf(" hwaddr/time type %u time %u ",
- ntohs(*(u_int16_t *)&tp[2]),
- ntohl(*(u_int32_t *)&tp[4]));
+ EXTRACT_16BITS(&tp[2]),
+ EXTRACT_32BITS(&tp[4]));
for (i = 8; i < optlen; i++)
printf("%02x", tp[i]);
/*(*/
@@ -256,7 +257,7 @@ dhcp6opt_print(u_char *cp, u_char *ep)
case 3:
if (optlen >= 2 + 2) {
printf(" hwaddr type %u ",
- ntohs(*(u_int16_t *)&tp[2]));
+ EXTRACT_16BITS(&tp[2]));
for (i = 4; i < optlen; i++)
printf("%02x", tp[i]);
/*(*/
@@ -267,7 +268,7 @@ dhcp6opt_print(u_char *cp, u_char *ep)
}
break;
default:
- printf(" type %d)", ntohs(*(u_int16_t *)tp));
+ printf(" type %d)", EXTRACT_16BITS(tp));
break;
}
break;
@@ -406,7 +407,7 @@ dhcp6_print(register const u_char *cp, u_int length,
printf(" %s (", name); /*)*/
else
printf(" msgtype-%u (", dh6->dh6_msgtype); /*)*/
- printf("xid=%x", ntohl(dh6->dh6_xid) & DH6_XIDMASK);
+ printf("xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK);
extp = (u_char *)(dh6 + 1);
dhcp6opt_print(extp, ep);
/*(*/
diff --git a/print-domain.c b/print-domain.c
index 724c6497..16dfeed1 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.81 2002-09-05 21:25:39 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.82 2002-12-11 07:13:59 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -506,19 +506,20 @@ ns_print(register const u_char *bp, u_int length)
register const HEADER *np;
register int qdcount, ancount, nscount, arcount;
register const u_char *cp;
+ u_int16_t b2;
np = (const HEADER *)bp;
TCHECK(*np);
/* get the byte-order right */
- qdcount = ntohs(np->qdcount);
- ancount = ntohs(np->ancount);
- nscount = ntohs(np->nscount);
- arcount = ntohs(np->arcount);
+ qdcount = EXTRACT_16BITS(&np->qdcount);
+ ancount = EXTRACT_16BITS(&np->ancount);
+ nscount = EXTRACT_16BITS(&np->nscount);
+ arcount = EXTRACT_16BITS(&np->arcount);
if (DNS_QR(np)) {
/* this is a response */
printf(" %d%s%s%s%s%s%s",
- ntohs(np->id),
+ EXTRACT_16BITS(&np->id),
ns_ops[DNS_OPCODE(np)],
ns_resp[DNS_RCODE(np)],
DNS_AA(np)? "*" : "",
@@ -531,7 +532,7 @@ ns_print(register const u_char *bp, u_int length)
/* Print QUESTION section on -vv */
cp = (const u_char *)(np + 1);
while (qdcount--) {
- if (qdcount < ntohs(np->qdcount) - 1)
+ if (qdcount < EXTRACT_16BITS(&np->qdcount) - 1)
putchar(',');
if (vflag > 1) {
fputs(" q:", stdout);
@@ -585,13 +586,14 @@ ns_print(register const u_char *bp, u_int length)
}
else {
/* this is a request */
- printf(" %d%s%s%s", ntohs(np->id), ns_ops[DNS_OPCODE(np)],
+ printf(" %d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
DNS_RD(np) ? "+" : "",
DNS_AD(np) ? "$" : "");
/* any weirdness? */
- if (*(((u_short *)np)+1) & htons(0x6cf))
- printf(" [b2&3=0x%x]", ntohs(*(((u_short *)np)+1)));
+ b2 = EXTRACT_16BITS(((u_short *)np)+1);
+ if (b2 & 0x6cf)
+ printf(" [b2&3=0x%x]", b2);
if (DNS_OPCODE(np) == IQUERY) {
if (qdcount)
diff --git a/print-egp.c b/print-egp.c
index 2576c8ed..2f449a07 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.33 2002-11-09 17:19:25 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.34 2002-12-11 07:13:59 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,6 +33,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#include "ip.h"
@@ -91,7 +92,7 @@ struct egp_packet {
} egp_pands;
#define egp_poll egp_pands.egpu_poll
#define egp_sourcenet egp_pands.egpu_sourcenet
-} __attribute__((packed));
+};
const char *egp_acquire_codes[] = {
"request",
@@ -231,7 +232,7 @@ egp_print(register const u_int8_t *bp)
printf("[version %d]", egp->egp_version);
return;
}
- printf("as:%d seq:%d", ntohs(egp->egp_as), ntohs(egp->egp_sequence));
+ printf("as:%d seq:%d", EXTRACT_16BITS(&egp->egp_as), EXTRACT_16BITS(&egp->egp_sequence));
type = egp->egp_type;
code = egp->egp_code;
@@ -256,8 +257,8 @@ egp_print(register const u_int8_t *bp)
break;
}
printf(" hello:%d poll:%d",
- ntohs(egp->egp_hello),
- ntohs(egp->egp_poll));
+ EXTRACT_16BITS(&egp->egp_hello),
+ EXTRACT_16BITS(&egp->egp_poll));
break;
case EGPC_REFUSE:
@@ -338,10 +339,10 @@ egp_print(register const u_int8_t *bp)
else
printf(" [status %d]", status);
- if (ntohs(egp->egp_reason) <= EGPR_UVERSION)
- printf(" %s", egp_reasons[ntohs(egp->egp_reason)]);
+ if (EXTRACT_16BITS(&egp->egp_reason) <= EGPR_UVERSION)
+ printf(" %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]);
else
- printf(" [reason %d]", ntohs(egp->egp_reason));
+ printf(" [reason %d]", EXTRACT_16BITS(&egp->egp_reason));
break;
default:
diff --git a/print-esp.c b/print-esp.c
index eabddfa9..8eebc574 100644
--- a/print-esp.c
+++ b/print-esp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.30 2002-11-13 09:35:13 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.31 2002-12-11 07:13:59 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -58,6 +58,7 @@ static const char rcsid[] =
#define AVOID_CHURN 1
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
static struct esp_algorithm *espsecret_xform=NULL; /* cache of decoded alg. */
static char *espsecret_key=NULL;
@@ -215,8 +216,8 @@ esp_print(register const u_char *bp, register const u_char *bp2,
fputs("[|ESP]", stdout);
goto fail;
}
- printf("ESP(spi=0x%08x", (u_int32_t)ntohl(esp->esp_spi));
- printf(",seq=0x%x", (u_int32_t)ntohl(esp->esp_seq));
+ printf("ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi));
+ printf(",seq=0x%x", EXTRACT_32BITS(&esp->esp_seq));
printf(")");
/* if we don't have decryption key, we can't decrypt this packet. */
@@ -237,20 +238,20 @@ esp_print(register const u_char *bp, register const u_char *bp2,
ip6 = (struct ip6_hdr *)bp2;
ip = NULL;
/* we do not attempt to decrypt jumbograms */
- if (!ntohs(ip6->ip6_plen))
+ if (!EXTRACT_16BITS(&ip6->ip6_plen))
goto fail;
/* if we can't get nexthdr, we do not need to decrypt it */
- len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen);
+ len = sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen);
break;
#endif /*INET6*/
case 4:
/* nexthdr & padding are in the last fragment */
- if (ntohs(ip->ip_off) & IP_MF)
+ if (EXTRACT_16BITS(&ip->ip_off) & IP_MF)
goto fail;
#ifdef INET6
ip6 = NULL;
#endif
- len = ntohs(ip->ip_len);
+ len = EXTRACT_16BITS(&ip->ip_len);
break;
default:
goto fail;
diff --git a/print-fr.c b/print-fr.c
index 7f1b9d14..13dc8f9b 100644
--- a/print-fr.c
+++ b/print-fr.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.7 2002-11-09 17:19:25 itojun Exp $ (LBL)";
+ "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.8 2002-12-11 07:14:00 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -347,7 +347,7 @@ out:
struct q933_header {
u_int8_t call_ref; /* usually is 0 for framerelay PVC */
u_int8_t msg_type;
-} __attribute__((packed));
+};
#define REPORT_TYPE_IE 0x01
#define LINK_VERIFY_IE_91 0x19
@@ -359,7 +359,7 @@ struct q933_header {
struct common_ie_header {
u_int8_t ie_id;
u_int8_t ie_len;
-} __attribute__((packed));
+};
#define FULL_STATUS 0
#define LINK_VERIFY 1
diff --git a/print-frag6.c b/print-frag6.c
index 4e5309e1..c3cbe2f5 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.14 2002-08-01 08:53:07 risso Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.15 2002-12-11 07:14:00 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -38,6 +38,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
int
frag6_print(register const u_char *bp, register const u_char *bp2)
@@ -56,20 +57,20 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
if (vflag) {
printf("frag (0x%08x:%d|%ld)",
- (u_int32_t)ntohl(dp->ip6f_ident),
- ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
- sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
+ EXTRACT_32BITS(&dp->ip6f_ident),
+ EXTRACT_16BITS(&dp->ip6f_offlg & IP6F_OFF_MASK),
+ sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
(long)(bp - bp2) - sizeof(struct ip6_frag));
} else {
printf("frag (%d|%ld)",
- ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
- sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
+ EXTRACT_16BITS(&dp->ip6f_offlg & IP6F_OFF_MASK),
+ sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
(long)(bp - bp2) - sizeof(struct ip6_frag));
}
#if 1
/* it is meaningless to decode non-first fragment */
- if (ntohs(dp->ip6f_offlg & IP6F_OFF_MASK) != 0)
+ if (EXTRACT_16BITS(&dp->ip6f_offlg & IP6F_OFF_MASK) != 0)
return 65535;
else
#endif
diff --git a/print-hsrp.c b/print-hsrp.c
index 2dffa160..4db84f5a 100644
--- a/print-hsrp.c
+++ b/print-hsrp.c
@@ -31,7 +31,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.6 2002-11-09 17:19:25 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.7 2002-12-11 07:14:00 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -95,7 +95,7 @@ struct hsrp {
u_int8_t hsrp_reserved;
u_int8_t hsrp_authdata[HSRP_AUTH_SIZE];
struct in_addr hsrp_virtaddr;
-} __attribute__((packed));
+};
void
hsrp_print(register const u_int8_t *bp, register u_int len)
diff --git a/print-icmp.c b/print-icmp.c
index 81adf2cc..df0970c8 100644
--- a/print-icmp.c
+++ b/print-icmp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.70 2002-11-09 17:19:26 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.71 2002-12-11 07:14:01 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -93,7 +93,7 @@ struct icmp {
#define icmp_ip icmp_dun.id_ip.idi_ip
#define icmp_mask icmp_dun.id_mask
#define icmp_data icmp_dun.id_data
-} __attribute__((packed));
+};
/*
* Lower bounds on packet lengths for various types.
@@ -245,19 +245,19 @@ static struct tok type2str[] = {
struct mtu_discovery {
u_int16_t unused;
u_int16_t nexthopmtu;
-} __attribute__((packed));
+};
/* rfc1256 */
struct ih_rdiscovery {
u_int8_t ird_addrnum;
u_int8_t ird_addrsiz;
u_int16_t ird_lifetime;
-} __attribute__((packed));
+};
struct id_rdiscovery {
u_int32_t ird_addr;
u_int32_t ird_pref;
-} __attribute__((packed));
+};
void
icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
@@ -284,7 +284,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
(void)snprintf(buf, sizeof(buf), "echo %s seq %u",
dp->icmp_type == ICMP_ECHO ?
"request" : "reply",
- (unsigned)ntohs(dp->icmp_seq));
+ EXTRACT_16BITS(&dp->icmp_seq));
break;
case ICMP_UNREACH:
@@ -304,7 +304,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
oip = &dp->icmp_ip;
hlen = IP_HL(oip) * 4;
ouh = (struct udphdr *)(((u_char *)oip) + hlen);
- dport = ntohs(ouh->uh_dport);
+ dport = EXTRACT_16BITS(&ouh->uh_dport);
switch (oip->ip_p) {
case IPPROTO_TCP:
@@ -449,26 +449,26 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
case ICMP_MASKREPLY:
TCHECK(dp->icmp_mask);
(void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
- (unsigned)ntohl(dp->icmp_mask));
+ EXTRACT_32BITS(&dp->icmp_mask));
break;
case ICMP_TSTAMP:
TCHECK(dp->icmp_seq);
(void)snprintf(buf, sizeof(buf),
"time stamp query id %u seq %u",
- (unsigned)ntohs(dp->icmp_id),
- (unsigned)ntohs(dp->icmp_seq));
+ EXTRACT_16BITS(&dp->icmp_id),
+ EXTRACT_16BITS(&dp->icmp_seq));
break;
case ICMP_TSTAMPREPLY:
TCHECK(dp->icmp_ttime);
(void)snprintf(buf, sizeof(buf),
- "time stamp reply id %u seq %u : org 0x%lx recv 0x%lx xmit 0x%lx",
- (unsigned)ntohs(dp->icmp_id),
- (unsigned)ntohs(dp->icmp_seq),
- (unsigned long)ntohl(dp->icmp_otime),
- (unsigned long)ntohl(dp->icmp_rtime),
- (unsigned long)ntohl(dp->icmp_ttime));
+ "time stamp reply id %u seq %u : org 0x%x recv 0x%x xmit 0x%x",
+ EXTRACT_16BITS(&dp->icmp_id),
+ EXTRACT_16BITS(&dp->icmp_seq),
+ EXTRACT_32BITS(&dp->icmp_otime),
+ EXTRACT_32BITS(&dp->icmp_rtime),
+ EXTRACT_32BITS(&dp->icmp_ttime));
break;
default:
@@ -481,7 +481,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
if (TTEST2(*bp, plen)) {
sum = in_cksum((u_short*)dp, plen, 0);
if (sum != 0) {
- icmp_sum = ntohs(dp->icmp_cksum);
+ icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
(void)printf(" (wrong icmp cksum %x (->%x)!)",
icmp_sum,
in_cksum_shouldbe(icmp_sum, sum));
@@ -493,7 +493,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
(void)printf(" for ");
ip = (struct ip *)bp;
snaplen = snapend - bp;
- ip_print(bp, ntohs(ip->ip_len));
+ ip_print(bp, EXTRACT_16BITS(&ip->ip_len));
}
return;
trunc:
diff --git a/print-icmp6.c b/print-icmp6.c
index b3711b6c..7daaa906 100644
--- a/print-icmp6.c
+++ b/print-icmp6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.65 2002-09-05 00:52:30 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.66 2002-12-11 07:14:01 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -40,6 +40,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#include "udp.h"
#include "ah.h"
@@ -119,7 +120,7 @@ icmp6_print(const u_char *bp, const u_char *bp2)
/* 'ep' points to the end of available data. */
ep = snapend;
if (ip->ip6_plen)
- icmp6len = (ntohs(ip->ip6_plen) + sizeof(struct ip6_hdr) -
+ icmp6len = (EXTRACT_16BITS(&ip->ip6_plen) + sizeof(struct ip6_hdr) -
(bp - bp2));
else /* XXX: jumbo payload case... */
icmp6len = snapend - bp;
@@ -151,7 +152,7 @@ icmp6_print(const u_char *bp, const u_char *bp2)
== NULL)
goto trunc;
- dport = ntohs(ouh->uh_dport);
+ dport = EXTRACT_16BITS(&ouh->uh_dport);
switch (prot) {
case IPPROTO_TCP:
printf("icmp6: %s tcp port %s unreachable",
@@ -179,7 +180,7 @@ icmp6_print(const u_char *bp, const u_char *bp2)
break;
case ICMP6_PACKET_TOO_BIG:
TCHECK(dp->icmp6_mtu);
- printf("icmp6: too big %u", (u_int32_t)ntohl(dp->icmp6_mtu));
+ printf("icmp6: too big %u", EXTRACT_32BITS(&dp->icmp6_mtu));
break;
case ICMP6_TIME_EXCEEDED:
TCHECK(oip->ip6_dst);
@@ -202,15 +203,15 @@ icmp6_print(const u_char *bp, const u_char *bp2)
switch (dp->icmp6_code) {
case ICMP6_PARAMPROB_HEADER:
printf("icmp6: parameter problem errorneous - octet %u",
- (u_int32_t)ntohl(dp->icmp6_pptr));
+ EXTRACT_32BITS(&dp->icmp6_pptr));
break;
case ICMP6_PARAMPROB_NEXTHEADER:
printf("icmp6: parameter problem next header - octet %u",
- (u_int32_t)ntohl(dp->icmp6_pptr));
+ EXTRACT_32BITS(&dp->icmp6_pptr));
break;
case ICMP6_PARAMPROB_OPTION:
printf("icmp6: parameter problem option - octet %u",
- (u_int32_t)ntohl(dp->icmp6_pptr));
+ EXTRACT_32BITS(&dp->icmp6_pptr));
break;
default:
printf("icmp6: parameter problem code-#%d",
@@ -266,11 +267,11 @@ icmp6_print(const u_char *bp, const u_char *bp2)
printf("pref=%s, ",
get_rtpref(p->nd_ra_flags_reserved));
- printf("router_ltime=%d, ", ntohs(p->nd_ra_router_lifetime));
+ printf("router_ltime=%d, ", EXTRACT_16BITS(&p->nd_ra_router_lifetime));
printf("reachable_time=%u, ",
- (u_int32_t)ntohl(p->nd_ra_reachable));
+ EXTRACT_32BITS(&p->nd_ra_reachable));
printf("retrans_time=%u)",
- (u_int32_t)ntohl(p->nd_ra_retransmit));
+ EXTRACT_32BITS(&p->nd_ra_retransmit));
#define RTADVLEN 16
icmp6_opt_print((const u_char *)dp + RTADVLEN,
icmp6len - RTADVLEN);
@@ -349,7 +350,7 @@ icmp6_print(const u_char *bp, const u_char *bp2)
printf("icmp6: ha discovery request");
if (vflag) {
TCHECK(dp->icmp6_data16[0]);
- printf("(id=%d)", ntohs(dp->icmp6_data16[0]));
+ printf("(id=%d)", EXTRACT_16BITS(&dp->icmp6_data16[0]));
}
break;
case ICMP6_HADISCOV_REPLY:
@@ -360,7 +361,7 @@ icmp6_print(const u_char *bp, const u_char *bp2)
u_char *cp;
TCHECK(dp->icmp6_data16[0]);
- printf("(id=%d", ntohs(dp->icmp6_data16[0]));
+ printf("(id=%d", EXTRACT_16BITS(&dp->icmp6_data16[0]));
cp = (u_char *)dp + icmp6len;
res = (u_int32_t *)(dp + 1);
in6 = (struct in6_addr *)(res + 2);
@@ -375,14 +376,14 @@ icmp6_print(const u_char *bp, const u_char *bp2)
printf("icmp6: mobile router solicitation");
if (vflag) {
TCHECK(dp->icmp6_data16[0]);
- printf("(id=%d)", ntohs(dp->icmp6_data16[0]));
+ printf("(id=%d)", EXTRACT_16BITS(&dp->icmp6_data16[0]));
}
break;
case ICMP6_MOBILEPREFIX_ADVERT:
printf("icmp6: mobile router advertisement");
if (vflag) {
TCHECK(dp->icmp6_data16[0]);
- printf("(id=%d)", ntohs(dp->icmp6_data16[0]));
+ printf("(id=%d)", EXTRACT_16BITS(&dp->icmp6_data16[0]));
#define MPADVLEN 6
icmp6_opt_print((const u_char *)dp + MPADVLEN,
icmp6len - MPADVLEN);
@@ -538,9 +539,9 @@ icmp6_opt_print(const u_char *bp, int resid)
if (opp->nd_opt_pi_flags_reserved)
printf(" ");
printf("valid_ltime=%s,",
- get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_valid_time)));
+ get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time)));
printf("preferred_ltime=%s,",
- get_lifetime((u_int32_t)ntohl(opp->nd_opt_pi_preferred_time)));
+ get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time)));
printf("prefix=%s/%d",
ip6addr_string(&opp->nd_opt_pi_prefix),
opp->nd_opt_pi_prefix_len);
@@ -564,7 +565,7 @@ icmp6_opt_print(const u_char *bp, int resid)
printf(")");
break;
}
- printf(" mtu=%u", (u_int32_t)ntohl(opm->nd_opt_mtu_mtu));
+ printf(" mtu=%u", EXTRACT_32BITS(&opm->nd_opt_mtu_mtu));
if (opm->nd_opt_mtu_len != 1)
printf("!");
printf(")");
@@ -574,7 +575,7 @@ icmp6_opt_print(const u_char *bp, int resid)
TCHECK(opa->nd_opt_adv_interval);
printf("(advint:"); /*)*/
printf(" advint=%u",
- (u_int32_t)ntohl(opa->nd_opt_adv_interval));
+ EXTRACT_32BITS(&opa->nd_opt_adv_interval));
/*(*/
printf(")");
break;
@@ -582,8 +583,8 @@ icmp6_opt_print(const u_char *bp, int resid)
oph = (struct nd_opt_homeagent_info *)op;
TCHECK(oph->nd_opt_hai_lifetime);
printf("(ha info:"); /*)*/
- printf(" pref=%d", ntohs(oph->nd_opt_hai_preference));
- printf(", lifetime=%u", ntohs(oph->nd_opt_hai_lifetime));
+ printf(" pref=%d", EXTRACT_16BITS(&oph->nd_opt_hai_preference));
+ printf(", lifetime=%u", EXTRACT_16BITS(&oph->nd_opt_hai_lifetime));
printf(")");
break;
case ND_OPT_ROUTE_INFO:
@@ -610,7 +611,7 @@ icmp6_opt_print(const u_char *bp, int resid)
opri->nd_opt_rti_prefixlen);
printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags));
printf(", lifetime=%s",
- get_lifetime((u_int32_t)ntohl(opri->nd_opt_rti_lifetime)));
+ get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime)));
/*(*/
printf(")");
break;
@@ -643,7 +644,7 @@ mld6_print(const u_char *bp)
if ((u_char *)mp + sizeof(*mp) > ep)
return;
- printf("max resp delay: %d ", ntohs(mp->mld6_maxdelay));
+ printf("max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay));
printf("addr: %s", ip6addr_string(&mp->mld6_addr));
}
@@ -708,13 +709,13 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
TCHECK2(*dp, sizeof(*ni6));
ni6 = (struct icmp6_nodeinfo *)dp;
printf(" ("); /*)*/
- switch (ntohs(ni6->ni_qtype)) {
+ switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
printf("noop");
break;
case NI_QTYPE_SUPTYPES:
printf("supported qtypes");
- i = ntohs(ni6->ni_flags);
+ i = EXTRACT_16BITS(&ni6->ni_flags);
if (i)
printf(" [%s]", (i & 0x01) ? "C" : "");
break;
@@ -850,7 +851,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
break;
}
- switch (ntohs(ni6->ni_qtype)) {
+ switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
if (needcomma)
printf(", ");
@@ -863,7 +864,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
if (needcomma)
printf(", ");
printf("supported qtypes");
- i = ntohs(ni6->ni_flags);
+ i = EXTRACT_16BITS(&ni6->ni_flags);
if (i)
printf(" [%s]", (i & 0x01) ? "C" : "");
break;
@@ -885,7 +886,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
printf("\"");
} else
dnsname_print(cp, ep);
- if ((ntohs(ni6->ni_flags) & 0x01) != 0)
+ if ((EXTRACT_16BITS(&ni6->ni_flags) & 0x01) != 0)
printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1));
break;
case NI_QTYPE_NODEADDR:
@@ -898,7 +899,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
break;
printf(" %s", getname6(bp + i));
i += sizeof(struct in6_addr);
- printf("(%d)", (int32_t)ntohl(*(int32_t *)(bp + i)));
+ printf("(%d)", (int32_t)EXTRACT_32BITS(bp + i));
i += sizeof(int32_t);
}
i = ni6->ni_flags;
@@ -963,7 +964,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
break;
}
- printf(", seq=%u", (u_int32_t)ntohl(rr6->rr_seqnum));
+ printf(", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum));
if (vflag) {
#define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
@@ -978,7 +979,7 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
printf("seg=%u,", rr6->rr_segnum);
printf("maxdelay=%u", rr6->rr_maxdelay);
if (rr6->rr_reserved)
- printf("rsvd=0x%x", (u_int16_t)ntohs(rr6->rr_reserved));
+ printf("rsvd=0x%x", EXTRACT_16BITS(&rr6->rr_reserved));
/*[*/
printf("]");
#undef F
@@ -1043,12 +1044,12 @@ icmp6_rrenum_print(int icmp6len, const u_char *bp, const u_char *ep)
printf("vltime=infty,");
else
printf("vltime=%u,",
- (u_int32_t)ntohl(use->rpu_vltime));
+ EXTRACT_32BITS(&use->rpu_vltime));
if (~use->rpu_pltime == 0)
printf("pltime=infty,");
else
printf("pltime=%u,",
- (u_int32_t)ntohl(use->rpu_pltime));
+ EXTRACT_32BITS(&use->rpu_pltime));
}
if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf,
sizeof(hbuf)))
diff --git a/print-igmp.c b/print-igmp.c
index b1f3b493..84fc7621 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.10 2002-11-09 17:19:26 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.11 2002-12-11 07:14:02 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -51,7 +51,7 @@ struct tr_query {
u_int32_t tr_dst; /* traceroute destination */
u_int32_t tr_raddr; /* traceroute response address */
u_int32_t tr_rttlqid; /* response ttl and qid */
-} __attribute__((packed));
+};
#define TR_GETTTL(x) (int)(((x) >> 24) & 0xff)
#define TR_GETQID(x) ((x) & 0x00ffffff)
@@ -72,7 +72,7 @@ struct tr_resp {
u_int8_t tr_fttl; /* ttl required to forward on outvif */
u_int8_t tr_smask; /* subnet mask for src addr */
u_int8_t tr_rflags; /* forwarding error codes */
-} __attribute__((packed));
+};
/* defs within mtrace */
#define TR_QUERY 1
@@ -116,12 +116,12 @@ print_mtrace(register const u_char *bp, register u_int len)
(void)printf(" [invalid len %d]", len);
return;
}
- printf("mtrace %lu: %s to %s reply-to %s",
- (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
+ printf("mtrace %u: %s to %s reply-to %s",
+ TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
ipaddr_string(&tr->tr_raddr));
- if (IN_CLASSD(ntohl(tr->tr_raddr)))
- printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
+ if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
+ printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
return;
trunc:
(void)printf("[|igmp]");
@@ -139,11 +139,11 @@ print_mresp(register const u_char *bp, register u_int len)
return;
}
printf("mresp %lu: %s to %s reply-to %s",
- (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
+ (u_long)TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
ipaddr_string(&tr->tr_raddr));
- if (IN_CLASSD(ntohl(tr->tr_raddr)))
- printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
+ if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
+ printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
return;
trunc:
(void)printf("[|igmp]");
diff --git a/print-ip.c b/print-ip.c
index 621abccd..795b4b0a 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.116 2002-10-18 04:40:03 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.117 2002-12-11 07:14:02 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -367,7 +367,7 @@ ip_print(register const u_char *bp, register u_int length)
return;
}
- len = ntohs(ip->ip_len);
+ len = EXTRACT_16BITS(&ip->ip_len);
if (length < len)
(void)printf("truncated-ip - %d bytes missing! ",
len - length);
@@ -376,7 +376,7 @@ ip_print(register const u_char *bp, register u_int length)
printf("IP ");
- off = ntohs(ip->ip_off);
+ off = EXTRACT_16BITS(&ip->ip_off);
if (vflag) {
(void)printf("(tos 0x%x", (int)ip->ip_tos);
@@ -395,11 +395,11 @@ ip_print(register const u_char *bp, register u_int length)
}
if (ip->ip_ttl >= 1)
- (void)printf(", ttl %d", (int)ip->ip_ttl);
+ (void)printf(", ttl %u", ip->ip_ttl);
if ((off & 0x3fff) == 0)
- (void)printf(", id %d", (int)ntohs(ip->ip_id));
- (void)printf(", len %d) ", (int)ntohs(ip->ip_len));
+ (void)printf(", id %u", EXTRACT_16BITS(&ip->ip_id));
+ (void)printf(", len %u) ", EXTRACT_16BITS(&ip->ip_len));
}
/*
@@ -602,7 +602,7 @@ again:
#ifndef IP_DF
#define IP_DF 0x4000
#endif /* IP_DF */
- (void)printf(" (frag %d:%u@%d%s)", ntohs(ip->ip_id), len,
+ (void)printf(" (frag %u:%u@%u%s)", EXTRACT_16BITS(&ip->ip_id), len,
(off & 0x1fff) * 8,
(off & IP_MF)? "+" : "");
@@ -616,7 +616,7 @@ again:
if ((u_char *)ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ip, hlen, 0);
if (sum != 0) {
- ip_sum = ntohs(ip->ip_sum);
+ ip_sum = EXTRACT_16BITS(&ip->ip_sum);
(void)printf("%sbad cksum %x (->%x)!", sep,
ip_sum,
in_cksum_shouldbe(ip_sum, sum));
diff --git a/print-ip6.c b/print-ip6.c
index ac6f95f8..846071da 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.27 2002-10-18 04:40:03 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.28 2002-12-11 07:14:02 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -38,6 +38,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#include "ip6.h"
@@ -64,7 +65,7 @@ ip6_print(register const u_char *bp, register u_int length)
}
advance = sizeof(struct ip6_hdr);
- len = ntohs(ip6->ip6_plen);
+ len = EXTRACT_16BITS(&ip6->ip6_plen);
if (length < len + advance)
(void)printf("truncated-ip6 - %d bytes missing!",
len + advance - length);
@@ -182,7 +183,7 @@ ip6_print(register const u_char *bp, register u_int length)
end:
- flow = ntohl(ip6->ip6_flow);
+ flow = EXTRACT_32BITS(&ip6->ip6_flow);
#if 0
/* rfc1883 */
if (flow & 0x0f000000)
diff --git a/print-ip6opts.c b/print-ip6opts.c
index f0349a0f..bf410cd5 100644
--- a/print-ip6opts.c
+++ b/print-ip6opts.c
@@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.12 2002-08-01 08:53:11 risso Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.13 2002-12-11 07:14:03 guy Exp $";
#endif
#ifdef INET6
@@ -45,6 +45,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
/* items outside of rfc2292bis */
#ifndef IP6OPT_MINLEN
@@ -103,7 +104,7 @@ ip6_sopt_print(const u_char *bp, int len)
printf(", ui: trunc");
goto trunc;
}
- printf(", ui: 0x%04x ", ntohs(*(u_int16_t *)&bp[i + 2]));
+ printf(", ui: 0x%04x ", EXTRACT_16BITS(&bp[i + 2]));
break;
case IP6SOPT_ALTCOA:
if (len - i < IP6SOPT_ALTCOA_MINLEN) {
@@ -117,8 +118,7 @@ ip6_sopt_print(const u_char *bp, int len)
printf(", auth: trunc");
goto trunc;
}
- printf(", auth spi: 0x%08x",
- (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 2]));
+ printf(", auth spi: 0x%08x", EXTRACT_32BITS(&bp[i + 2]));
break;
default:
if (len - i < IP6OPT_MINLEN) {
@@ -173,7 +173,7 @@ ip6_opt_print(const u_char *bp, int len)
printf("(rtalert: invalid len %d)", bp[i + 1]);
goto trunc;
}
- printf("(rtalert: 0x%04x) ", ntohs(*(u_int16_t *)&bp[i + 2]));
+ printf("(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2]));
break;
case IP6OPT_JUMBO:
if (len - i < IP6OPT_JUMBO_LEN) {
@@ -184,7 +184,7 @@ ip6_opt_print(const u_char *bp, int len)
printf("(jumbo: invalid len %d)", bp[i + 1]);
goto trunc;
}
- printf("(jumbo: %u) ", (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 2]));
+ printf("(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2]));
break;
case IP6OPT_HOME_ADDRESS:
if (len - i < IP6OPT_HOMEADDR_MINLEN) {
@@ -223,8 +223,7 @@ ip6_opt_print(const u_char *bp, int len)
if ((bp[i + 2] & 0x0f) || bp[i + 3] || bp[i + 4])
printf("res");
printf(", sequence: %u", bp[i + 5]);
- printf(", lifetime: %u",
- (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 6]));
+ printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 6]));
if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN],
@@ -246,10 +245,8 @@ ip6_opt_print(const u_char *bp, int len)
if (bp[i + 3])
printf("res");
printf(", sequence: %u", bp[i + 4]);
- printf(", lifetime: %u",
- (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 5]));
- printf(", refresh: %u",
- (u_int32_t)ntohl(*(u_int32_t *)&bp[i + 9]));
+ printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 5]));
+ printf(", refresh: %u", EXTRACT_32BITS(&bp[i + 9]));
if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
diff --git a/print-ipcomp.c b/print-ipcomp.c
index 8cdb779d..bc76448f 100644
--- a/print-ipcomp.c
+++ b/print-ipcomp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.16 2002-11-09 17:19:26 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.17 2002-12-11 07:14:03 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -37,7 +37,7 @@ struct ipcomp {
u_int8_t comp_nxt; /* Next Header */
u_int8_t comp_flags; /* Length of data, in 32bit */
u_int16_t comp_cpi; /* Compression parameter index */
-} __attribute__((packed));
+};
#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
#include <zlib.h>
@@ -45,6 +45,7 @@ struct ipcomp {
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
int
ipcomp_print(register const u_char *bp, int *nhdr)
@@ -57,7 +58,7 @@ ipcomp_print(register const u_char *bp, int *nhdr)
#endif
ipcomp = (struct ipcomp *)bp;
- cpi = (u_int16_t)ntohs(ipcomp->comp_cpi);
+ cpi = EXTRACT_16BITS(&ipcomp->comp_cpi);
/* 'ep' points to the end of available data. */
ep = snapend;
diff --git a/print-isakmp.c b/print-isakmp.c
index 43e86fb0..bccfe6a0 100644
--- a/print-isakmp.c
+++ b/print-isakmp.c
@@ -30,7 +30,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.35 2002-09-05 21:25:42 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.36 2002-12-11 07:14:03 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -350,28 +350,28 @@ isakmp_attrmap_print(const u_char *p, const u_char *ep,
if (p[0] & 0x80)
totlen = 4;
else
- totlen = 4 + ntohs(q[1]);
+ totlen = 4 + EXTRACT_16BITS(&q[1]);
if (ep < p + totlen) {
printf("[|attr]");
return ep + 1;
}
printf("(");
- t = ntohs(q[0]) & 0x7fff;
+ t = EXTRACT_16BITS(&q[0]) & 0x7fff;
if (map && t < nmap && map[t].type)
printf("type=%s ", map[t].type);
else
printf("type=#%d ", t);
if (p[0] & 0x80) {
printf("value=");
- v = ntohs(q[1]);
+ v = EXTRACT_16BITS(&q[1]);
if (map && t < nmap && v < map[t].nvalue && map[t].value[v])
printf("%s", map[t].value[v]);
else
rawprint((caddr_t)&q[1], 2);
} else {
- printf("len=%d value=", ntohs(q[1]));
- rawprint((caddr_t)&p[4], ntohs(q[1]));
+ printf("len=%d value=", EXTRACT_16BITS(&q[1]));
+ rawprint((caddr_t)&p[4], EXTRACT_16BITS(&q[1]));
}
printf(")");
return p + totlen;
@@ -388,22 +388,22 @@ isakmp_attr_print(const u_char *p, const u_char *ep)
if (p[0] & 0x80)
totlen = 4;
else
- totlen = 4 + ntohs(q[1]);
+ totlen = 4 + EXTRACT_16BITS(&q[1]);
if (ep < p + totlen) {
printf("[|attr]");
return ep + 1;
}
printf("(");
- t = ntohs(q[0]) & 0x7fff;
+ t = EXTRACT_16BITS(&q[0]) & 0x7fff;
printf("type=#%d ", t);
if (p[0] & 0x80) {
printf("value=");
t = q[1];
rawprint((caddr_t)&q[1], 2);
} else {
- printf("len=%d value=", ntohs(q[1]));
- rawprint((caddr_t)&p[2], ntohs(q[1]));
+ printf("len=%d value=", EXTRACT_16BITS(&q[1]));
+ rawprint((caddr_t)&p[2], EXTRACT_16BITS(&q[1]));
}
printf(")");
return p + totlen;
diff --git a/print-isoclns.c b/print-isoclns.c
index eff45e3a..e223f585 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.72 2002-12-11 06:00:41 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.73 2002-12-11 07:14:04 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -346,7 +346,7 @@ struct isis_tlv_ptp_adj {
u_int8_t extd_local_circuit_id[4];
u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
u_int8_t neighbor_extd_local_circuit_id[4];
-} __attribute__((packed));
+};
static int osi_cksum(const u_int8_t *, u_int);
static void esis_print(const u_int8_t *, u_int);
@@ -357,23 +357,23 @@ struct isis_metric_block {
u_int8_t metric_delay;
u_int8_t metric_expense;
u_int8_t metric_error;
-} __attribute__((packed));
+};
struct isis_tlv_is_reach {
struct isis_metric_block isis_metric_block;
u_int8_t neighbor_nodeid[NODE_ID_LEN];
-} __attribute__((packed));
+};
struct isis_tlv_es_reach {
struct isis_metric_block isis_metric_block;
u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
-} __attribute__((packed));
+};
struct isis_tlv_ip_reach {
struct isis_metric_block isis_metric_block;
u_int8_t prefix[4];
u_int8_t mask[4];
-} __attribute__((packed));
+};
static struct tok isis_is_reach_virtual_values[] = {
{ 0, "IsNotVirtual"},
@@ -390,7 +390,7 @@ struct isis_common_header {
u_int8_t pdu_version; /* Packet format version? */
u_int8_t reserved;
u_int8_t max_area;
-} __attribute__((packed));
+};
struct isis_iih_lan_header {
u_int8_t circuit_type;
@@ -399,7 +399,7 @@ struct isis_iih_lan_header {
u_int8_t pdu_len[2];
u_int8_t priority;
u_int8_t lan_id[NODE_ID_LEN];
-} __attribute__((packed));
+};
struct isis_iih_ptp_header {
u_int8_t circuit_type;
@@ -407,7 +407,7 @@ struct isis_iih_ptp_header {
u_int8_t holding_time[2];
u_int8_t pdu_len[2];
u_int8_t circuit_id;
-} __attribute__((packed));
+};
struct isis_lsp_header {
u_int8_t pdu_len[2];
@@ -416,26 +416,26 @@ struct isis_lsp_header {
u_int8_t sequence_number[4];
u_int8_t checksum[2];
u_int8_t typeblock;
-} __attribute__((packed));
+};
struct isis_csnp_header {
u_int8_t pdu_len[2];
u_int8_t source_id[NODE_ID_LEN];
u_int8_t start_lsp_id[LSP_ID_LEN];
u_int8_t end_lsp_id[LSP_ID_LEN];
-} __attribute__((packed));
+};
struct isis_psnp_header {
u_int8_t pdu_len[2];
u_int8_t source_id[NODE_ID_LEN];
-} __attribute__((packed));
+};
struct isis_tlv_lsp {
u_int8_t remaining_lifetime[2];
u_int8_t lsp_id[LSP_ID_LEN];
u_int8_t sequence_number[4];
u_int8_t checksum[2];
-} __attribute__((packed));
+};
/* allocate space for the following string
diff --git a/print-krb.c b/print-krb.c
index 444474a9..2bb544b6 100644
--- a/print-krb.c
+++ b/print-krb.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.20 2002-12-11 05:40:09 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.21 2002-12-11 07:14:04 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -67,7 +67,7 @@ static void krb4_print(const u_char *);
struct krb {
u_int8_t pvno; /* Protocol Version */
u_int8_t type; /* Type+B */
-} __attribute__((packed));
+};
static char tstr[] = " [|kerberos]";
diff --git a/print-lane.c b/print-lane.c
index 41967da5..c319e30d 100644
--- a/print-lane.c
+++ b/print-lane.c
@@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.16 2002-09-05 21:25:43 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.17 2002-12-11 07:14:04 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,6 +36,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#include "ether.h"
#include "lane.h"
@@ -67,13 +68,13 @@ lane_hdr_print(register const u_char *bp, int length)
ep = (const struct lecdatahdr_8023 *)bp;
if (qflag)
(void)printf("lecid:%x %s %s %d: ",
- ntohs(ep->le_header),
+ EXTRACT_16BITS(&ep->le_header),
etheraddr_string(ep->h_source),
etheraddr_string(ep->h_dest),
length);
else
(void)printf("lecid:%x %s %s %s %d: ",
- ntohs(ep->le_header),
+ EXTRACT_16BITS(&ep->le_header),
etheraddr_string(ep->h_source),
etheraddr_string(ep->h_dest),
etherproto_string(ep->h_type),
@@ -102,13 +103,13 @@ lane_print(const u_char *p, u_int length, u_int caplen)
}
lec = (struct lane_controlhdr *)p;
- if (ntohs(lec->lec_header) == 0xff00) {
+ if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) {
/*
* LE Control.
*/
printf("lec: proto %x vers %x %s",
lec->lec_proto, lec->lec_vers,
- tok2str(lecop2str, "opcode-#%u", ntohs(lec->lec_opcode)));
+ tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode)));
return;
}
@@ -133,7 +134,7 @@ lane_print(const u_char *p, u_int length, u_int caplen)
ep = (struct lecdatahdr_8023 *)p;
p += sizeof(struct lecdatahdr_8023);
- ether_type = ntohs(ep->h_type);
+ ether_type = EXTRACT_16BITS(&ep->h_type);
/*
* Is it (gag) an 802.3 encapsulation?
diff --git a/print-lwres.c b/print-lwres.c
index 35c23049..507111e6 100644
--- a/print-lwres.c
+++ b/print-lwres.c
@@ -29,7 +29,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.8 2002-11-09 17:19:28 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.9 2002-12-11 07:14:04 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -62,7 +62,7 @@ struct lwres_lwpacket {
lwres_uint32_t recvlength;
lwres_uint16_t authtype;
lwres_uint16_t authlength;
-} __attribute__((packed));
+};
#define LWRES_LWPACKETFLAG_RESPONSE 0x0001U /* if set, pkt is a response */
@@ -80,13 +80,13 @@ typedef struct {
/* public */
lwres_uint16_t datalength;
/* data follows */
-} lwres_nooprequest_t __attribute__((packed));
+} lwres_nooprequest_t;
typedef struct {
/* public */
lwres_uint16_t datalength;
/* data follows */
-} lwres_noopresponse_t __attribute__((packed));
+} lwres_noopresponse_t;
/*
* get addresses by name
@@ -99,7 +99,7 @@ struct lwres_addr {
lwres_uint32_t family;
lwres_uint16_t length;
/* address folows */
-} __attribute__((packed));
+};
typedef struct {
/* public */
@@ -107,7 +107,7 @@ typedef struct {
lwres_uint32_t addrtypes;
lwres_uint16_t namelen;
/* name follows */
-} lwres_gabnrequest_t __attribute__((packed));
+} lwres_gabnrequest_t;
typedef struct {
/* public */
@@ -118,7 +118,7 @@ typedef struct {
/* aliases follows */
/* addrs follows */
/* realname follows */
-} lwres_gabnresponse_t __attribute__((packed));
+} lwres_gabnresponse_t;
/*
* get name by address
@@ -138,7 +138,7 @@ typedef struct {
lwres_uint16_t realnamelen;
/* aliases follows */
/* realname follows */
-} lwres_gnbaresponse_t __attribute__((packed));
+} lwres_gnbaresponse_t;
/*
* get rdata by name
@@ -152,7 +152,7 @@ typedef struct {
lwres_uint16_t rdtype;
lwres_uint16_t namelen;
/* name follows */
-} lwres_grbnrequest_t __attribute__((packed));
+} lwres_grbnrequest_t;
typedef struct {
/* public */
@@ -165,7 +165,7 @@ typedef struct {
/* realname here (len + name) */
/* rdata here (len + name) */
/* signatures here (len + name) */
-} lwres_grbnresponse_t __attribute__((packed));
+} lwres_grbnresponse_t;
#define LWRDATA_VALIDATED 0x00000001
@@ -262,13 +262,13 @@ lwres_printaddr(lwres_addr_t *ap)
int i;
TCHECK(ap->length);
- l = ntohs(ap->length);
+ l = EXTRACT_16BITS(&ap->length);
/* XXX ap points to packed struct */
p = (const char *)&ap->length + sizeof(ap->length);
if (p + l > (const char *)snapend)
goto trunc;
- switch (ntohl(ap->family)) {
+ switch (EXTRACT_32BITS(&ap->family)) {
case 1: /* IPv4 */
printf(" %s", ipaddr_string(p));
p += sizeof(struct in_addr);
@@ -280,7 +280,7 @@ lwres_printaddr(lwres_addr_t *ap)
break;
#endif
default:
- printf(" %lu/", (unsigned long)ntohl(ap->family));
+ printf(" %u/", EXTRACT_32BITS(&ap->family));
for (i = 0; i < l; i++)
printf("%02x", *p++);
}
@@ -305,35 +305,35 @@ lwres_print(register const u_char *bp, u_int length)
TCHECK(np->authlength);
printf(" lwres");
- v = ntohs(np->version);
+ v = EXTRACT_16BITS(&np->version);
if (vflag || v != LWRES_LWPACKETVERSION_0)
printf(" v%u", v);
if (v != LWRES_LWPACKETVERSION_0) {
- s = (const char *)np + ntohl(np->length);
+ s = (const char *)np + EXTRACT_32BITS(&np->length);
goto tail;
}
- response = ntohs(np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE;
+ response = EXTRACT_16BITS(&np->pktflags) & LWRES_LWPACKETFLAG_RESPONSE;
/* opcode and pktflags */
- v = (u_int32_t)ntohl(np->opcode);
+ v = EXTRACT_32BITS(&np->opcode);
s = tok2str(opcode, "#0x%x", v);
printf(" %s%s", s, response ? "" : "?");
/* pktflags */
- v = ntohs(np->pktflags);
+ v = EXTRACT_16BITS(&np->pktflags);
if (v & ~LWRES_LWPACKETFLAG_RESPONSE)
printf("[0x%x]", v);
if (vflag > 1) {
printf(" ("); /*)*/
- printf("serial:0x%lx", (unsigned long)ntohl(np->serial));
- printf(" result:0x%lx", (unsigned long)ntohl(np->result));
- printf(" recvlen:%lu", (unsigned long)ntohl(np->recvlength));
+ printf("serial:0x%x", EXTRACT_32BITS(&np->serial));
+ printf(" result:0x%x", EXTRACT_32BITS(&np->result));
+ printf(" recvlen:%u", EXTRACT_32BITS(&np->recvlength));
/* BIND910: not used */
if (vflag > 2) {
- printf(" authtype:0x%x", ntohs(np->authtype));
- printf(" authlen:%u", ntohs(np->authlength));
+ printf(" authtype:0x%x", EXTRACT_16BITS(&np->authtype));
+ printf(" authlen:%u", EXTRACT_16BITS(&np->authlength));
}
/*(*/
printf(")");
@@ -353,7 +353,7 @@ lwres_print(register const u_char *bp, u_int length)
gnba = NULL;
grbn = NULL;
- switch (ntohl(np->opcode)) {
+ switch (EXTRACT_32BITS(&np->opcode)) {
case LWRES_OPCODE_NOOP:
break;
case LWRES_OPCODE_GETADDRSBYNAME:
@@ -362,15 +362,15 @@ lwres_print(register const u_char *bp, u_int length)
/* XXX gabn points to packed struct */
s = (const char *)&gabn->namelen +
sizeof(gabn->namelen);
- l = ntohs(gabn->namelen);
+ l = EXTRACT_16BITS(&gabn->namelen);
/* BIND910: not used */
if (vflag > 2) {
- printf(" flags:0x%lx",
- (unsigned long)ntohl(gabn->flags));
+ printf(" flags:0x%x",
+ EXTRACT_32BITS(&gabn->flags));
}
- v = (u_int32_t)ntohl(gabn->addrtypes);
+ v = EXTRACT_32BITS(&gabn->addrtypes);
switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) {
case LWRES_ADDRTYPE_V4:
printf(" IPv4");
@@ -396,8 +396,8 @@ lwres_print(register const u_char *bp, u_int length)
/* BIND910: not used */
if (vflag > 2) {
- printf(" flags:0x%lx",
- (unsigned long)ntohl(gnba->flags));
+ printf(" flags:0x%x",
+ EXTRACT_32BITS(&gnba->flags));
}
s = (const char *)&gnba->addr;
@@ -414,21 +414,21 @@ lwres_print(register const u_char *bp, u_int length)
/* BIND910: not used */
if (vflag > 2) {
- printf(" flags:0x%lx",
- (unsigned long)ntohl(grbn->flags));
+ printf(" flags:0x%x",
+ EXTRACT_32BITS(&grbn->flags));
}
printf(" %s", tok2str(ns_type2str, "Type%d",
- ntohs(grbn->rdtype)));
- if (ntohs(grbn->rdclass) != C_IN) {
+ EXTRACT_16BITS(&grbn->rdtype)));
+ if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) {
printf(" %s", tok2str(ns_class2str, "Class%d",
- ntohs(grbn->rdclass)));
+ EXTRACT_16BITS(&grbn->rdclass)));
}
/* XXX grbn points to packed struct */
s = (const char *)&grbn->namelen +
sizeof(grbn->namelen);
- l = ntohs(gabn->namelen);
+ l = EXTRACT_16BITS(&gabn->namelen);
advance = lwres_printname(l, s);
if (advance < 0)
@@ -453,7 +453,7 @@ lwres_print(register const u_char *bp, u_int length)
gnba = NULL;
grbn = NULL;
- switch (ntohl(np->opcode)) {
+ switch (EXTRACT_32BITS(&np->opcode)) {
case LWRES_OPCODE_NOOP:
break;
case LWRES_OPCODE_GETADDRSBYNAME:
@@ -462,16 +462,16 @@ lwres_print(register const u_char *bp, u_int length)
/* XXX gabn points to packed struct */
s = (const char *)&gabn->realnamelen +
sizeof(gabn->realnamelen);
- l = ntohs(gabn->realnamelen);
+ l = EXTRACT_16BITS(&gabn->realnamelen);
/* BIND910: not used */
if (vflag > 2) {
- printf(" flags:0x%lx",
- (unsigned long)ntohl(gabn->flags));
+ printf(" flags:0x%x",
+ EXTRACT_32BITS(&gabn->flags));
}
- printf(" %u/%u", ntohs(gabn->naliases),
- ntohs(gabn->naddrs));
+ printf(" %u/%u", EXTRACT_16BITS(&gabn->naliases),
+ EXTRACT_16BITS(&gabn->naddrs));
advance = lwres_printname(l, s);
if (advance < 0)
@@ -479,7 +479,7 @@ lwres_print(register const u_char *bp, u_int length)
s += advance;
/* aliases */
- na = ntohs(gabn->naliases);
+ na = EXTRACT_16BITS(&gabn->naliases);
for (i = 0; i < na; i++) {
advance = lwres_printnamelen(s);
if (advance < 0)
@@ -488,7 +488,7 @@ lwres_print(register const u_char *bp, u_int length)
}
/* addrs */
- na = ntohs(gabn->naddrs);
+ na = EXTRACT_16BITS(&gabn->naddrs);
for (i = 0; i < na; i++) {
advance = lwres_printaddr((lwres_addr_t *)s);
if (advance < 0)
@@ -502,15 +502,15 @@ lwres_print(register const u_char *bp, u_int length)
/* XXX gnba points to packed struct */
s = (const char *)&gnba->realnamelen +
sizeof(gnba->realnamelen);
- l = ntohs(gnba->realnamelen);
+ l = EXTRACT_16BITS(&gnba->realnamelen);
/* BIND910: not used */
if (vflag > 2) {
- printf(" flags:0x%lx",
- (unsigned long)ntohl(gnba->flags));
+ printf(" flags:0x%x",
+ EXTRACT_32BITS(&gnba->flags));
}
- printf(" %u", ntohs(gnba->naliases));
+ printf(" %u", EXTRACT_16BITS(&gnba->naliases));
advance = lwres_printname(l, s);
if (advance < 0)
@@ -518,7 +518,7 @@ lwres_print(register const u_char *bp, u_int length)
s += advance;
/* aliases */
- na = ntohs(gnba->naliases);
+ na = EXTRACT_16BITS(&gnba->naliases);
for (i = 0; i < na; i++) {
advance = lwres_printnamelen(s);
if (advance < 0)
@@ -533,20 +533,20 @@ lwres_print(register const u_char *bp, u_int length)
/* BIND910: not used */
if (vflag > 2) {
- printf(" flags:0x%lx",
- (unsigned long)ntohl(grbn->flags));
+ printf(" flags:0x%x",
+ EXTRACT_32BITS(&grbn->flags));
}
printf(" %s", tok2str(ns_type2str, "Type%d",
- ntohs(grbn->rdtype)));
- if (ntohs(grbn->rdclass) != C_IN) {
+ EXTRACT_16BITS(&grbn->rdtype)));
+ if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) {
printf(" %s", tok2str(ns_class2str, "Class%d",
- ntohs(grbn->rdclass)));
+ EXTRACT_16BITS(&grbn->rdclass)));
}
printf(" TTL ");
- relts_print(ntohl(grbn->ttl));
- printf(" %u/%u", ntohs(grbn->nrdatas),
- ntohs(grbn->nsigs));
+ relts_print(EXTRACT_32BITS(&grbn->ttl));
+ printf(" %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
+ EXTRACT_16BITS(&grbn->nsigs));
/* XXX grbn points to packed struct */
s = (const char *)&grbn->nsigs+ sizeof(grbn->nsigs);
@@ -557,7 +557,7 @@ lwres_print(register const u_char *bp, u_int length)
s += advance;
/* rdatas */
- na = ntohs(grbn->nrdatas);
+ na = EXTRACT_16BITS(&grbn->nrdatas);
for (i = 0; i < na; i++) {
/* XXX should decode resource data */
advance = lwres_printbinlen(s);
@@ -567,7 +567,7 @@ lwres_print(register const u_char *bp, u_int length)
}
/* sigs */
- na = ntohs(grbn->nsigs);
+ na = EXTRACT_16BITS(&grbn->nsigs);
for (i = 0; i < na; i++) {
/* XXX how should we print it? */
advance = lwres_printbinlen(s);
@@ -584,11 +584,11 @@ lwres_print(register const u_char *bp, u_int length)
tail:
/* length mismatch */
- if (ntohl(np->length) != length) {
- printf(" [len: %lu != %u]", (unsigned long)ntohl(np->length),
+ if (EXTRACT_32BITS(&np->length) != length) {
+ printf(" [len: %u != %u]", EXTRACT_32BITS(&np->length),
length);
}
- if (!unsupported && s < (const char *)np + ntohl(np->length))
+ if (!unsupported && s < (const char *)np + EXTRACT_32BITS(&np->length))
printf("[extra]");
return;
diff --git a/print-mobile.c b/print-mobile.c
index 30a4d68a..b9f7e7a1 100644
--- a/print-mobile.c
+++ b/print-mobile.c
@@ -42,7 +42,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.11 2002-11-09 17:19:28 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.12 2002-12-11 07:14:05 guy Exp $";
#endif
#include <tcpdump-stdinc.h>
@@ -60,7 +60,7 @@ struct mobile_ip {
u_int16_t hcheck;
u_int32_t odst;
u_int32_t osrc;
-} __attribute__((packed));
+};
#define OSRC_PRES 0x0080 /* old source is present */
diff --git a/print-mobility.c b/print-mobility.c
index 93585d6d..de9f1531 100644
--- a/print-mobility.c
+++ b/print-mobility.c
@@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.7 2002-11-13 09:35:51 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.8 2002-12-11 07:14:05 guy Exp $";
#endif
#ifdef INET6
@@ -58,7 +58,7 @@ struct ip6_mobility {
u_int16_t ip6m_un_data16[1]; /* type-specific field */
u_int8_t ip6m_un_data8[2]; /* type-specific fiedl */
} ip6m_dataun;
-} __attribute__((packed));
+};
#define ip6m_data16 ip6m_dataun.ip6m_un_data16
#define ip6m_data8 ip6m_dataun.ip6m_un_data8
diff --git a/print-nfs.c b/print-nfs.c
index 7cff4c1e..a9ed4db2 100644
--- a/print-nfs.c
+++ b/print-nfs.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.97 2002-09-05 00:00:16 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.98 2002-12-11 07:14:05 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -38,6 +38,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#include "nfs.h"
#include "nfsfh.h"
@@ -174,7 +175,7 @@ static int print_int64(const u_int32_t *dp, int how)
#ifdef INT64_FORMAT
u_int64_t res;
- res = ((u_int64_t)ntohl(dp[0]) << 32) | (u_int64_t)ntohl(dp[1]);
+ res = ((u_int64_t)EXTRACT_32BITS(&dp[0]) << 32) | (u_int64_t)EXTRACT_32BITS(&dp[1]);
switch (how) {
case SIGNED:
printf(INT64_FORMAT, res);
@@ -191,16 +192,16 @@ static int print_int64(const u_int32_t *dp, int how)
#else
u_int32_t high;
- high = (u_int32_t)ntohl(dp[0]);
+ high = EXTRACT_32BITS(&dp[0]);
switch (how) {
case SIGNED:
case UNSIGNED:
case HEX:
if (high != 0)
- printf("0x%x%08x", high, (u_int32_t)ntohl(dp[1]));
+ printf("0x%x%08x", high, EXTRACT_32BITS(&dp[1]));
else
- printf("0x%x", (u_int32_t)ntohl(dp[1]));
+ printf("0x%x", EXTRACT_32BITS(&dp[1]));
break;
default:
return (0);
@@ -252,41 +253,61 @@ static const u_int32_t *
parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3)
{
TCHECK(dp[0]);
- if ((sa3->sa_modeset = ntohl(*dp++))) {
+ sa3->sa_modeset = EXTRACT_32BITS(dp);
+ dp++;
+ if (sa3->sa_modeset) {
TCHECK(dp[0]);
- sa3->sa_mode = ntohl(*dp++);
+ sa3->sa_mode = EXTRACT_32BITS(dp);
+ dp++;
}
TCHECK(dp[0]);
- if ((sa3->sa_uidset = ntohl(*dp++))) {
+ sa3->sa_uidset = EXTRACT_32BITS(dp);
+ dp++;
+ if (sa3->sa_uidset) {
TCHECK(dp[0]);
- sa3->sa_uid = ntohl(*dp++);
+ sa3->sa_uid = EXTRACT_32BITS(dp);
+ dp++;
}
TCHECK(dp[0]);
- if ((sa3->sa_gidset = ntohl(*dp++))) {
+ sa3->sa_gidset = EXTRACT_32BITS(dp);
+ dp++;
+ if (sa3->sa_gidset) {
TCHECK(dp[0]);
- sa3->sa_gid = ntohl(*dp++);
+ sa3->sa_gid = EXTRACT_32BITS(dp);
+ dp++;
}
TCHECK(dp[0]);
- if ((sa3->sa_sizeset = ntohl(*dp++))) {
+ sa3->sa_sizeset = EXTRACT_32BITS(dp);
+ dp++;
+ if (sa3->sa_sizeset) {
TCHECK(dp[0]);
- sa3->sa_size = ntohl(*dp++);
+ sa3->sa_size = EXTRACT_32BITS(dp);
+ dp++;
}
TCHECK(dp[0]);
- if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
+ sa3->sa_atimetype = EXTRACT_32BITS(dp);
+ dp++;
+ if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) {
TCHECK(dp[1]);
- sa3->sa_atime.nfsv3_sec = ntohl(*dp++);
- sa3->sa_atime.nfsv3_nsec = ntohl(*dp++);
+ sa3->sa_atime.nfsv3_sec = EXTRACT_32BITS(dp);
+ dp++;
+ sa3->sa_atime.nfsv3_nsec = EXTRACT_32BITS(dp);
+ dp++;
}
TCHECK(dp[0]);
- if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
+ sa3->sa_mtimetype = EXTRACT_32BITS(dp);
+ dp++;
+ if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) {
TCHECK(dp[1]);
- sa3->sa_mtime.nfsv3_sec = ntohl(*dp++);
- sa3->sa_mtime.nfsv3_nsec = ntohl(*dp++);
+ sa3->sa_mtime.nfsv3_sec = EXTRACT_32BITS(dp);
+ dp++;
+ sa3->sa_mtime.nfsv3_nsec = EXTRACT_32BITS(dp);
+ dp++;
}
return dp;
@@ -329,15 +350,15 @@ nfsreply_print(register const u_char *bp, u_int length,
if (!nflag) {
strlcpy(srcid, "nfs", sizeof(srcid));
snprintf(dstid, sizeof(dstid), "%u",
- (u_int32_t)ntohl(rp->rm_xid));
+ EXTRACT_32BITS(&rp->rm_xid));
} else {
snprintf(srcid, sizeof(srcid), "%u", NFS_PORT);
snprintf(dstid, sizeof(dstid), "%u",
- (u_int32_t)ntohl(rp->rm_xid));
+ EXTRACT_32BITS(&rp->rm_xid));
}
print_nfsaddr(bp2, srcid, dstid);
(void)printf("reply %s %d",
- ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
+ EXTRACT_32BITS(&rp->rm_reply.rp_stat) == MSG_ACCEPTED?
"ok":"ERR",
length);
@@ -360,11 +381,11 @@ parsereq(register const struct rpc_msg *rp, register u_int length)
*/
dp = (u_int32_t *)&rp->rm_call.cb_cred;
TCHECK(dp[1]);
- len = ntohl(dp[1]);
+ len = EXTRACT_32BITS(&dp[1]);
if (len < length) {
dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
TCHECK(dp[1]);
- len = ntohl(dp[1]);
+ len = EXTRACT_32BITS(&dp[1]);
if (len < length) {
dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
TCHECK2(dp[0], 0);
@@ -382,11 +403,11 @@ trunc:
static const u_int32_t *
parsefh(register const u_int32_t *dp, int v3)
{
- int len;
+ u_int len;
if (v3) {
TCHECK(dp[0]);
- len = (int)ntohl(*dp) / 4;
+ len = EXTRACT_32BITS(dp) / 4;
dp++;
} else
len = NFSX_V2FH / 4;
@@ -462,11 +483,11 @@ nfsreq_print(register const u_char *bp, u_int length,
rp = (const struct rpc_msg *)bp;
if (!nflag) {
snprintf(srcid, sizeof(srcid), "%u",
- (u_int32_t)ntohl(rp->rm_xid));
+ EXTRACT_32BITS(&rp->rm_xid));
strlcpy(dstid, "nfs", sizeof(dstid));
} else {
snprintf(srcid, sizeof(srcid), "%u",
- (u_int32_t)ntohl(rp->rm_xid));
+ EXTRACT_32BITS(&rp->rm_xid));
snprintf(dstid, sizeof(dstid), "%u", NFS_PORT);
}
print_nfsaddr(bp2, srcid, dstid);
@@ -474,8 +495,8 @@ nfsreq_print(register const u_char *bp, u_int length,
xid_map_enter(rp, bp2); /* record proc number for later on */
- v3 = (ntohl(rp->rm_call.cb_vers) == NFS_VER3);
- proc = ntohl(rp->rm_call.cb_proc);
+ v3 = (EXTRACT_32BITS(&rp->rm_call.cb_vers) == NFS_VER3);
+ proc = EXTRACT_32BITS(&rp->rm_call.cb_proc);
if (!v3 && proc < NFS_NPROCS)
proc = nfsv3_procid[proc];
@@ -514,7 +535,7 @@ nfsreq_print(register const u_char *bp, u_int length,
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
TCHECK(dp[0]);
- printf(" %04x", (u_int32_t)ntohl(dp[0]));
+ printf(" %04x", EXTRACT_32BITS(&dp[0]));
return;
}
break;
@@ -533,13 +554,13 @@ nfsreq_print(register const u_char *bp, u_int length,
if (v3) {
TCHECK(dp[2]);
printf(" %u bytes @ ",
- (u_int32_t) ntohl(dp[2]));
+ EXTRACT_32BITS(&dp[2]));
print_int64(dp, UNSIGNED);
} else {
TCHECK(dp[1]);
printf(" %u bytes @ %u",
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ EXTRACT_32BITS(&dp[1]),
+ EXTRACT_32BITS(&dp[0]));
}
return;
}
@@ -552,22 +573,22 @@ nfsreq_print(register const u_char *bp, u_int length,
if (v3) {
TCHECK(dp[4]);
printf(" %u bytes @ ",
- (u_int32_t) ntohl(dp[4]));
+ EXTRACT_32BITS(&dp[4]));
print_int64(dp, UNSIGNED);
if (vflag) {
dp += 3;
TCHECK(dp[0]);
printf(" <%s>",
tok2str(nfsv3_writemodes,
- NULL, ntohl(*dp)));
+ NULL, EXTRACT_32BITS(dp)));
}
} else {
TCHECK(dp[3]);
printf(" %u (%u) bytes @ %u (%u)",
- (u_int32_t)ntohl(dp[3]),
- (u_int32_t)ntohl(dp[2]),
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ EXTRACT_32BITS(&dp[3]),
+ EXTRACT_32BITS(&dp[2]),
+ EXTRACT_32BITS(&dp[1]),
+ EXTRACT_32BITS(&dp[0]));
}
return;
}
@@ -606,15 +627,16 @@ nfsreq_print(register const u_char *bp, u_int length,
if ((dp = parsereq(rp, length)) != 0 &&
(dp = parsefhn(dp, v3)) != 0) {
TCHECK(*dp);
- type = (nfs_type)ntohl(*dp++);
+ type = (nfs_type)EXTRACT_32BITS(dp);
+ dp++;
if ((dp = parse_sattr3(dp, &sa3)) == 0)
break;
printf(" %s", tok2str(type2str, "unk-ft %d", type));
if (vflag && (type == NFCHR || type == NFBLK)) {
TCHECK(dp[1]);
printf(" %u/%u",
- (u_int32_t)ntohl(dp[0]),
- (u_int32_t)ntohl(dp[1]));
+ EXTRACT_32BITS(&dp[0]),
+ EXTRACT_32BITS(&dp[1]));
dp += 2;
}
if (vflag)
@@ -668,7 +690,7 @@ nfsreq_print(register const u_char *bp, u_int length,
* offset cookie here.
*/
printf(" %u bytes @ ",
- (u_int32_t) ntohl(dp[4]));
+ EXTRACT_32BITS(&dp[4]));
print_int64(dp, SIGNED);
if (vflag)
printf(" verf %08x%08x", dp[2],
@@ -680,8 +702,8 @@ nfsreq_print(register const u_char *bp, u_int length,
* common, but offsets > 2^31 aren't.
*/
printf(" %u bytes @ %d",
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ EXTRACT_32BITS(&dp[1]),
+ EXTRACT_32BITS(&dp[0]));
}
return;
}
@@ -696,11 +718,11 @@ nfsreq_print(register const u_char *bp, u_int length,
* We don't try to interpret the offset
* cookie here.
*/
- printf(" %u bytes @ ", (u_int32_t) ntohl(dp[4]));
+ printf(" %u bytes @ ", EXTRACT_32BITS(&dp[4]));
print_int64(dp, SIGNED);
if (vflag)
printf(" max %u verf %08x%08x",
- (u_int32_t) ntohl(dp[5]), dp[2], dp[3]);
+ EXTRACT_32BITS(&dp[5]), dp[2], dp[3]);
return;
}
break;
@@ -730,14 +752,14 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" commit");
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
- printf(" %u bytes @ ", (u_int32_t) ntohl(dp[2]));
+ printf(" %u bytes @ ", EXTRACT_32BITS(&dp[2]));
print_int64(dp, UNSIGNED);
return;
}
break;
default:
- printf(" proc-%u", (u_int32_t)ntohl(rp->rm_call.cb_proc));
+ printf(" proc-%u", EXTRACT_32BITS(&rp->rm_call.cb_proc));
return;
}
@@ -876,8 +898,8 @@ xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
}
#endif
- xmep->proc = ntohl(rp->rm_call.cb_proc);
- xmep->vers = ntohl(rp->rm_call.cb_vers);
+ xmep->proc = EXTRACT_32BITS(&rp->rm_call.cb_proc);
+ xmep->vers = EXTRACT_32BITS(&rp->rm_call.cb_vers);
}
/*
@@ -975,7 +997,7 @@ parserep(register const struct rpc_msg *rp, register u_int length)
*/
dp = ((const u_int32_t *)&rp->rm_reply) + 1;
TCHECK(dp[1]);
- len = ntohl(dp[1]);
+ len = EXTRACT_32BITS(&dp[1]);
if (len >= length)
return (NULL);
/*
@@ -987,7 +1009,7 @@ parserep(register const struct rpc_msg *rp, register u_int length)
/*
* now we can check the ar_stat field
*/
- astat = ntohl(*(enum accept_stat *)dp);
+ astat = EXTRACT_32BITS(dp);
switch (astat) {
case SUCCESS:
@@ -1037,7 +1059,7 @@ parsestatus(const u_int32_t *dp, int *er)
TCHECK(dp[0]);
- errnum = ntohl(dp[0]);
+ errnum = EXTRACT_32BITS(&dp[0]);
if (er)
*er = errnum;
if (errnum != 0) {
@@ -1061,10 +1083,10 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
if (verbose) {
printf(" %s %o ids %d/%d",
tok2str(type2str, "unk-ft %d ",
- (u_int32_t)ntohl(fap->fa_type)),
- (u_int32_t)ntohl(fap->fa_mode),
- (u_int32_t)ntohl(fap->fa_uid),
- (u_int32_t) ntohl(fap->fa_gid));
+ EXTRACT_32BITS(&fap->fa_type)),
+ EXTRACT_32BITS(&fap->fa_mode),
+ EXTRACT_32BITS(&fap->fa_uid),
+ EXTRACT_32BITS(&fap->fa_gid));
if (v3) {
TCHECK(fap->fa3_size);
printf(" sz ");
@@ -1072,7 +1094,7 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
putchar(' ');
} else {
TCHECK(fap->fa2_size);
- printf(" sz %d ", (u_int32_t) ntohl(fap->fa2_size));
+ printf(" sz %d ", EXTRACT_32BITS(&fap->fa2_size));
}
}
/* print lots more stuff */
@@ -1080,38 +1102,38 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
if (v3) {
TCHECK(fap->fa3_ctime);
printf("nlink %d rdev %d/%d ",
- (u_int32_t)ntohl(fap->fa_nlink),
- (u_int32_t) ntohl(fap->fa3_rdev.specdata1),
- (u_int32_t) ntohl(fap->fa3_rdev.specdata2));
+ EXTRACT_32BITS(&fap->fa_nlink),
+ EXTRACT_32BITS(&fap->fa3_rdev.specdata1),
+ EXTRACT_32BITS(&fap->fa3_rdev.specdata2));
printf("fsid ");
print_int64((u_int32_t *)&fap->fa3_fsid, HEX);
printf(" nodeid ");
print_int64((u_int32_t *)&fap->fa3_fileid, HEX);
printf(" a/m/ctime %u.%06u ",
- (u_int32_t) ntohl(fap->fa3_atime.nfsv3_sec),
- (u_int32_t) ntohl(fap->fa3_atime.nfsv3_nsec));
+ EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec),
+ EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec));
printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_sec),
- (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_nsec));
+ EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_sec),
+ EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec));
printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_sec),
- (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_nsec));
+ EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_sec),
+ EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec));
} else {
TCHECK(fap->fa2_ctime);
printf("nlink %d rdev %x fsid %x nodeid %x a/m/ctime ",
- (u_int32_t) ntohl(fap->fa_nlink),
- (u_int32_t) ntohl(fap->fa2_rdev),
- (u_int32_t) ntohl(fap->fa2_fsid),
- (u_int32_t) ntohl(fap->fa2_fileid));
+ EXTRACT_32BITS(&fap->fa_nlink),
+ EXTRACT_32BITS(&fap->fa2_rdev),
+ EXTRACT_32BITS(&fap->fa2_fsid),
+ EXTRACT_32BITS(&fap->fa2_fileid));
printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa2_atime.nfsv2_sec),
- (u_int32_t) ntohl(fap->fa2_atime.nfsv2_usec));
+ EXTRACT_32BITS(&fap->fa2_atime.nfsv2_sec),
+ EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec));
printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_sec),
- (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_usec));
+ EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_sec),
+ EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec));
printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_sec),
- (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_usec));
+ EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_sec),
+ EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec));
}
}
return ((const u_int32_t *)((unsigned char *)dp +
@@ -1208,15 +1230,15 @@ parsestatfs(const u_int32_t *dp, int v3)
printf(" afiles ");
print_int64((u_int32_t *)&sfsp->sf_afiles, UNSIGNED);
printf(" invar %u",
- (u_int32_t) ntohl(sfsp->sf_invarsec));
+ EXTRACT_32BITS(&sfsp->sf_invarsec));
}
} else {
printf(" tsize %d bsize %d blocks %d bfree %d bavail %d",
- (u_int32_t)ntohl(sfsp->sf_tsize),
- (u_int32_t)ntohl(sfsp->sf_bsize),
- (u_int32_t)ntohl(sfsp->sf_blocks),
- (u_int32_t)ntohl(sfsp->sf_bfree),
- (u_int32_t)ntohl(sfsp->sf_bavail));
+ EXTRACT_32BITS(&sfsp->sf_tsize),
+ EXTRACT_32BITS(&sfsp->sf_bsize),
+ EXTRACT_32BITS(&sfsp->sf_blocks),
+ EXTRACT_32BITS(&sfsp->sf_bfree),
+ EXTRACT_32BITS(&sfsp->sf_bavail));
}
return (1);
@@ -1239,7 +1261,7 @@ parserddires(const u_int32_t *dp)
TCHECK(dp[2]);
printf(" offset %x size %d ",
- (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1]));
+ EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1]));
if (dp[2] != 0)
printf(" eof");
@@ -1254,8 +1276,8 @@ parse_wcc_attr(const u_int32_t *dp)
printf(" sz ");
print_int64(dp, UNSIGNED);
printf(" mtime %u.%06u ctime %u.%06u",
- (u_int32_t)ntohl(dp[2]), (u_int32_t)ntohl(dp[3]),
- (u_int32_t)ntohl(dp[4]), (u_int32_t)ntohl(dp[5]));
+ EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[3]),
+ EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5]));
return (dp + 6);
}
@@ -1266,7 +1288,7 @@ static const u_int32_t *
parse_pre_op_attr(const u_int32_t *dp, int verbose)
{
TCHECK(dp[0]);
- if (!ntohl(dp[0]))
+ if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
TCHECK2(*dp, 24);
@@ -1287,7 +1309,7 @@ static const u_int32_t *
parse_post_op_attr(const u_int32_t *dp, int verbose)
{
TCHECK(dp[0]);
- if (!ntohl(dp[0]))
+ if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
if (verbose) {
@@ -1322,7 +1344,7 @@ parsecreateopres(const u_int32_t *dp, int verbose)
dp = parse_wcc_data(dp, verbose);
else {
TCHECK(dp[0]);
- if (!ntohl(dp[0]))
+ if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
if (!(dp = parsefh(dp, 1)))
@@ -1392,19 +1414,19 @@ parsefsinfo(const u_int32_t *dp)
sfp = (struct nfsv3_fsinfo *)dp;
TCHECK(*sfp);
printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
- (u_int32_t) ntohl(sfp->fs_rtmax),
- (u_int32_t) ntohl(sfp->fs_rtpref),
- (u_int32_t) ntohl(sfp->fs_wtmax),
- (u_int32_t) ntohl(sfp->fs_wtpref),
- (u_int32_t) ntohl(sfp->fs_dtpref));
+ EXTRACT_32BITS(&sfp->fs_rtmax),
+ EXTRACT_32BITS(&sfp->fs_rtpref),
+ EXTRACT_32BITS(&sfp->fs_wtmax),
+ EXTRACT_32BITS(&sfp->fs_wtpref),
+ EXTRACT_32BITS(&sfp->fs_dtpref));
if (vflag) {
printf(" rtmult %u wtmult %u maxfsz ",
- (u_int32_t) ntohl(sfp->fs_rtmult),
- (u_int32_t) ntohl(sfp->fs_wtmult));
+ EXTRACT_32BITS(&sfp->fs_rtmult),
+ EXTRACT_32BITS(&sfp->fs_wtmult));
print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED);
printf(" delta %u.%06u ",
- (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_sec),
- (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_nsec));
+ EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_sec),
+ EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec));
}
return (1);
trunc:
@@ -1430,12 +1452,12 @@ parsepathconf(const u_int32_t *dp)
TCHECK(*spp);
printf(" linkmax %u namemax %u %s %s %s %s",
- (u_int32_t) ntohl(spp->pc_linkmax),
- (u_int32_t) ntohl(spp->pc_namemax),
- ntohl(spp->pc_notrunc) ? "notrunc" : "",
- ntohl(spp->pc_chownrestricted) ? "chownres" : "",
- ntohl(spp->pc_caseinsensitive) ? "igncase" : "",
- ntohl(spp->pc_casepreserving) ? "keepcase" : "");
+ EXTRACT_32BITS(&spp->pc_linkmax),
+ EXTRACT_32BITS(&spp->pc_namemax),
+ EXTRACT_32BITS(&spp->pc_notrunc) ? "notrunc" : "",
+ EXTRACT_32BITS(&spp->pc_chownrestricted) ? "chownres" : "",
+ EXTRACT_32BITS(&spp->pc_caseinsensitive) ? "igncase" : "",
+ EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : "");
return (1);
trunc:
return (0);
@@ -1523,7 +1545,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
if (!(dp = parse_post_op_attr(dp, vflag)))
break;
if (!er)
- printf(" c %04x", (u_int32_t)ntohl(dp[0]));
+ printf(" c %04x", EXTRACT_32BITS(&dp[0]));
return;
case NFSPROC_READLINK:
@@ -1546,8 +1568,8 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
return;
if (vflag) {
TCHECK(dp[1]);
- printf("%u bytes", (u_int32_t) ntohl(dp[0]));
- if (ntohl(dp[1]))
+ printf("%u bytes", EXTRACT_32BITS(&dp[0]));
+ if (EXTRACT_32BITS(&dp[1]))
printf(" EOF");
}
return;
@@ -1570,12 +1592,12 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
return;
if (vflag) {
TCHECK(dp[0]);
- printf("%u bytes", (u_int32_t) ntohl(dp[0]));
+ printf("%u bytes", EXTRACT_32BITS(&dp[0]));
if (vflag > 1) {
TCHECK(dp[1]);
printf(" <%s>",
tok2str(nfsv3_writemodes,
- NULL, ntohl(dp[1])));
+ NULL, EXTRACT_32BITS(&dp[1])));
}
return;
}
diff --git a/print-ntp.c b/print-ntp.c
index 1d860b01..ca31e0c2 100644
--- a/print-ntp.c
+++ b/print-ntp.c
@@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.34 2002-08-01 08:53:21 risso Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.35 2002-12-11 07:14:06 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -39,6 +39,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#ifdef MODEMASK
#undef MODEMASK /* Solaris sucks */
#endif
@@ -197,8 +198,8 @@ p_sfix(register const struct s_fixedpt *sfp)
register int f;
register float ff;
- i = ntohs(sfp->int_part);
- f = ntohs(sfp->fraction);
+ i = EXTRACT_16BITS(&sfp->int_part);
+ f = EXTRACT_16BITS(&sfp->fraction);
ff = f / 65536.0; /* shift radix point by 16 bits */
f = ff * 1000000.0; /* Treat fraction as parts per million */
printf("%d.%06d", i, f);
@@ -214,8 +215,8 @@ p_ntp_time(register const struct l_fixedpt *lfp)
register u_int32_t f;
register float ff;
- i = ntohl(lfp->int_part);
- uf = ntohl(lfp->fraction);
+ i = EXTRACT_32BITS(&lfp->int_part);
+ uf = EXTRACT_32BITS(&lfp->fraction);
ff = uf;
if (ff < 0.0) /* some compilers are buggy */
ff += FMAXINT;
@@ -236,10 +237,10 @@ p_ntp_delta(register const struct l_fixedpt *olfp,
register float ff;
int signbit;
- i = ntohl(lfp->int_part) - ntohl(olfp->int_part);
+ i = EXTRACT_32BITS(&lfp->int_part) - EXTRACT_32BITS(&olfp->int_part);
- uf = ntohl(lfp->fraction);
- ouf = ntohl(olfp->fraction);
+ uf = EXTRACT_32BITS(&lfp->fraction);
+ ouf = EXTRACT_32BITS(&olfp->fraction);
if (i > 0) { /* new is definitely greater than old */
signbit = 0;
diff --git a/print-ospf.c b/print-ospf.c
index 103c3bce..9e0c6994 100644
--- a/print-ospf.c
+++ b/print-ospf.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.34 2002-11-10 20:41:33 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.35 2002-12-11 07:14:06 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,6 +36,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#include "ospf.h"
@@ -112,8 +113,8 @@ ospf_print_lshdr(register const struct lsa_hdr *lshp) {
lshp->ls_type,
ipaddr_string(&lshp->ls_stateid),
ipaddr_string(&lshp->ls_router),
- (u_int32_t)ntohl(lshp->ls_seq),
- ntohs(lshp->ls_age));
+ EXTRACT_32BITS(&lshp->ls_seq),
+ EXTRACT_16BITS(&lshp->ls_age));
printf("\n\t Options: %s", bittok2str(ospf_option_values,"none",lshp->ls_options));
return (0);
@@ -141,12 +142,12 @@ ospf_print_lsa(register const struct lsa *lsap)
lsap->ls_hdr.ls_type,
ipaddr_string(&lsap->ls_hdr.ls_stateid),
ipaddr_string(&lsap->ls_hdr.ls_router),
- (u_int32_t)ntohl(lsap->ls_hdr.ls_seq),
- ntohs(lsap->ls_hdr.ls_age));
+ EXTRACT_32BITS(&lsap->ls_hdr.ls_seq),
+ EXTRACT_16BITS(&lsap->ls_hdr.ls_age));
printf("\n\t Options: %s", bittok2str(ospf_option_values,"none",lsap->ls_hdr.ls_options));
TCHECK(lsap->ls_hdr.ls_length);
- ls_end = (u_char *)lsap + ntohs(lsap->ls_hdr.ls_length);
+ ls_end = (u_char *)lsap + EXTRACT_16BITS(&lsap->ls_hdr.ls_length);
switch (lsap->ls_hdr.ls_type) {
case LS_TYPE_ROUTER:
@@ -154,7 +155,7 @@ ospf_print_lsa(register const struct lsa *lsap)
printf("\n\t Router LSA Options: %s", bittok2str(ospf_rla_flag_values,"unknown (%u)",lsap->lsa_un.un_rla.rla_flags));
TCHECK(lsap->lsa_un.un_rla.rla_count);
- j = ntohs(lsap->lsa_un.un_rla.rla_count);
+ j = EXTRACT_16BITS(&lsap->lsa_un.un_rla.rla_count);
TCHECK(lsap->lsa_un.un_rla.rla_link);
rlp = lsap->lsa_un.un_rla.rla_link;
while (j--) {
@@ -190,14 +191,14 @@ ospf_print_lsa(register const struct lsa *lsap)
rlp->link_type);
return (0);
}
- printf(", tos 0, metric: %d", ntohs(rlp->link_tos0metric));
+ printf(", tos 0, metric: %d", EXTRACT_16BITS(&rlp->link_tos0metric));
tosp = (struct tos_metric *)
((sizeof rlp->link_tos0metric) + (u_char *) rlp);
for (k = 0; k < (int) rlp->link_toscount; ++k, ++tosp) {
TCHECK(*tosp);
printf(", tos %d, metric: %d",
tosp->tos_type,
- ntohs(tosp->tos_metric));
+ EXTRACT_16BITS(&tosp->tos_metric));
}
rlp = (struct rlalink *)((u_char *)(rlp + 1) +
((rlp->link_toscount) * sizeof(*tosp)));
@@ -224,14 +225,14 @@ ospf_print_lsa(register const struct lsa *lsap)
lp = lsap->lsa_un.un_sla.sla_tosmetric;
/* suppress tos if its not supported */
if(!((lsap->ls_hdr.ls_options)&OSPF_OPTION_T)) {
- printf(", metric: %u", (u_int32_t)ntohl(*lp)&SLA_MASK_METRIC);
+ printf(", metric: %u", EXTRACT_32BITS(lp)&SLA_MASK_METRIC);
break;
}
while ((u_char *)lp < ls_end) {
register u_int32_t ul;
TCHECK(*lp);
- ul = ntohl(*lp);
+ ul = EXTRACT_32BITS(lp);
printf(", tos %d metric %d",
(ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS,
ul & SLA_MASK_METRIC);
@@ -244,14 +245,14 @@ ospf_print_lsa(register const struct lsa *lsap)
lp = lsap->lsa_un.un_sla.sla_tosmetric;
/* suppress tos if its not supported */
if(!((lsap->ls_hdr.ls_options)&OSPF_OPTION_T)) {
- printf(", metric: %u", (u_int32_t)ntohl(*lp)&SLA_MASK_METRIC);
+ printf(", metric: %u", EXTRACT_32BITS(lp)&SLA_MASK_METRIC);
break;
}
while ((u_char *)lp < ls_end) {
register u_int32_t ul;
TCHECK(*lp);
- ul = ntohl(*lp);
+ ul = EXTRACT_32BITS(lp);
printf(", tos %d metric %d",
(ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS,
ul & SLA_MASK_METRIC);
@@ -270,7 +271,7 @@ ospf_print_lsa(register const struct lsa *lsap)
register u_int32_t ul;
TCHECK(almp->asla_tosmetric);
- ul = ntohl(almp->asla_tosmetric);
+ ul = EXTRACT_32BITS(&almp->asla_tosmetric);
printf(", type %d, tos %d metric:",
(ul & ASLA_FLAG_EXTERNAL) ? 2 : 1,
(ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
@@ -298,7 +299,7 @@ ospf_print_lsa(register const struct lsa *lsap)
mcp = lsap->lsa_un.un_mcla;
while ((u_char *)mcp < ls_end) {
TCHECK(mcp->mcla_vid);
- switch (ntohl(mcp->mcla_vtype)) {
+ switch (EXTRACT_32BITS(&mcp->mcla_vtype)) {
case MCLA_VERTEX_ROUTER:
printf("\n\t Router Router-ID %s",
@@ -312,7 +313,7 @@ ospf_print_lsa(register const struct lsa *lsap)
default:
printf("\n\t unknown VertexType (%u)",
- (u_int32_t)ntohl(mcp->mcla_vtype));
+ EXTRACT_32BITS(&mcp->mcla_vtype));
break;
}
++mcp;
@@ -346,8 +347,8 @@ ospf_decode_v2(register const struct ospfhdr *op,
case OSPF_TYPE_HELLO:
TCHECK(op->ospf_hello.hello_deadint);
printf("\n\t Hello Timer: %us, Dead Timer %us, mask: %s, Priority: %u",
- ntohs(op->ospf_hello.hello_helloint),
- (u_int32_t)ntohl(op->ospf_hello.hello_deadint),
+ EXTRACT_16BITS(&op->ospf_hello.hello_helloint),
+ EXTRACT_32BITS(&op->ospf_hello.hello_deadint),
ipaddr_string(&op->ospf_hello.hello_mask),
op->ospf_hello.hello_priority);
@@ -408,13 +409,13 @@ ospf_decode_v2(register const struct ospfhdr *op,
case OSPF_TYPE_LS_UPDATE:
lsap = op->ospf_lsu.lsu_lsa;
TCHECK(op->ospf_lsu.lsu_count);
- lsa_count = ntohl(op->ospf_lsu.lsu_count);
+ lsa_count = EXTRACT_32BITS(&op->ospf_lsu.lsu_count);
printf(", %d LSA%s",lsa_count, lsa_count > 1 ? "s" : "");
while (lsa_count--) {
if (ospf_print_lsa(lsap))
goto trunc;
lsap = (struct lsa *)((u_char *)lsap +
- ntohs(lsap->ls_hdr.ls_length));
+ EXTRACT_16BITS(&lsap->ls_hdr.ls_length));
}
break;
@@ -448,7 +449,7 @@ ospf_print(register const u_char *bp, register u_int length,
/* XXX Before we do anything else, strip off the MD5 trailer */
TCHECK(op->ospf_authtype);
- if (ntohs(op->ospf_authtype) == OSPF_AUTH_MD5) {
+ if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
length -= OSPF_AUTH_MD5_LEN;
snapend -= OSPF_AUTH_MD5_LEN;
}
@@ -465,8 +466,8 @@ ospf_print(register const u_char *bp, register u_int length,
return;
TCHECK(op->ospf_len);
- if (length != ntohs(op->ospf_len)) {
- printf(" [len %d]", ntohs(op->ospf_len));
+ if (length != EXTRACT_16BITS(&op->ospf_len)) {
+ printf(" [len %d]", EXTRACT_16BITS(&op->ospf_len));
return;
}
dataend = bp + length;
@@ -485,7 +486,7 @@ ospf_print(register const u_char *bp, register u_int length,
if (vflag) {
/* Print authentication data (should we really do this?) */
TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata));
- switch (ntohs(op->ospf_authtype)) {
+ switch (EXTRACT_16BITS(&op->ospf_authtype)) {
case OSPF_AUTH_NONE:
break;
@@ -502,7 +503,7 @@ ospf_print(register const u_char *bp, register u_int length,
break;
default:
- printf(", unknown Authentication Type %d", ntohs(op->ospf_authtype));
+ printf(", unknown Authentication Type %d", EXTRACT_16BITS(&op->ospf_authtype));
return;
}
}
diff --git a/print-ospf6.c b/print-ospf6.c
index 82b8375a..fb61c3d7 100644
--- a/print-ospf6.c
+++ b/print-ospf6.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.9 2002-08-01 08:53:23 risso Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.10 2002-12-11 07:14:06 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -217,8 +217,8 @@ ospf6_print_lshdr(register const struct lsa_hdr *lshp)
printf(" {"); /* } (ctags) */
TCHECK(lshp->ls_seq);
- ospf6_print_seqage(ntohl(lshp->ls_seq), ntohs(lshp->ls_age));
- ospf6_print_ls_type(ntohs(lshp->ls_type), &lshp->ls_stateid,
+ ospf6_print_seqage(EXTRACT_32BITS(&lshp->ls_seq), EXTRACT_16BITS(&lshp->ls_age));
+ ospf6_print_ls_type(EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid,
&lshp->ls_router, "ls_type %d");
return (0);
@@ -245,7 +245,7 @@ ospf6_print_lsaprefix(register const struct lsa_prefix *lsapp)
if (lsapp->lsa_p_opt)
printf("(opt=%x)", lsapp->lsa_p_opt);
if (lsapp->lsa_p_mbz)
- printf("(mbz=%x)", ntohs(lsapp->lsa_p_mbz)); /* XXX */
+ printf("(mbz=%x)", EXTRACT_16BITS(&lsapp->lsa_p_mbz)); /* XXX */
return sizeof(*lsapp) - 4 + k * 4;
trunc:
@@ -280,15 +280,15 @@ ospf6_print_lsa(register const struct lsa *lsap)
if (ospf6_print_lshdr(&lsap->ls_hdr))
return (1);
TCHECK(lsap->ls_hdr.ls_length);
- ls_end = (u_char *)lsap + ntohs(lsap->ls_hdr.ls_length);
- switch (ntohs(lsap->ls_hdr.ls_type)) {
+ ls_end = (u_char *)lsap + EXTRACT_16BITS(&lsap->ls_hdr.ls_length);
+ switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) {
case LS_TYPE_ROUTER | LS_SCOPE_AREA:
TCHECK(lsap->lsa_un.un_rla.rla_flags);
ospf6_print_bits(ospf6_rla_flag_bits,
lsap->lsa_un.un_rla.rla_flags);
TCHECK(lsap->lsa_un.un_rla.rla_options);
ospf6_print_bits(ospf6_option_bits,
- ntohl(lsap->lsa_un.un_rla.rla_options));
+ EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options));
TCHECK(lsap->lsa_un.un_rla.rla_link);
rlp = lsap->lsa_un.un_rla.rla_link;
@@ -321,7 +321,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
rlp->link_type);
return (0);
}
- printf(" metric %d", ntohs(rlp->link_metric));
+ printf(" metric %d", EXTRACT_16BITS(&rlp->link_metric));
/* { (ctags) */
printf(" }");
rlp++;
@@ -331,7 +331,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
case LS_TYPE_NETWORK | LS_SCOPE_AREA:
TCHECK(lsap->lsa_un.un_nla.nla_options);
ospf6_print_bits(ospf6_option_bits,
- ntohl(lsap->lsa_un.un_nla.nla_options));
+ EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options));
printf(" rtrs");
ap = lsap->lsa_un.un_nla.nla_router;
while ((u_char *)ap < ls_end) {
@@ -344,7 +344,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
case LS_TYPE_INTER_AP | LS_SCOPE_AREA:
TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
printf(" metric %u",
- (u_int32_t)ntohl(lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
+ EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix;
while (lsapp + sizeof(lsapp) <= (struct lsa_prefix *)ls_end) {
k = ospf6_print_lsaprefix(lsapp);
@@ -355,10 +355,10 @@ ospf6_print_lsa(register const struct lsa *lsap)
break;
case LS_SCOPE_AS | LS_TYPE_ASE:
TCHECK(lsap->lsa_un.un_asla.asla_metric);
- flags32 = ntohl(lsap->lsa_un.un_asla.asla_metric);
+ flags32 = EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric);
ospf6_print_bits(ospf6_asla_flag_bits, flags32);
printf(" metric %u",
- (u_int32_t)ntohl(lsap->lsa_un.un_asla.asla_metric) &
+ EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) &
ASLA_MASK_METRIC);
lsapp = lsap->lsa_un.un_asla.asla_prefix;
k = ospf6_print_lsaprefix(lsapp);
@@ -401,7 +401,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
register u_int32_t ul;
TCHECK(*lp);
- ul = ntohl(*lp);
+ ul = EXTRACT_32BITS(lp);
printf(" tos %d metric %d",
(ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS,
ul & SLA_MASK_METRIC);
@@ -414,7 +414,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
mcp = lsap->lsa_un.un_mcla;
while ((u_char *)mcp < ls_end) {
TCHECK(mcp->mcla_vid);
- switch (ntohl(mcp->mcla_vtype)) {
+ switch (EXTRACT_32BITS(&mcp->mcla_vtype)) {
case MCLA_VERTEX_ROUTER:
printf(" rtr rtrid %s",
@@ -428,7 +428,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
default:
printf(" ??VertexType %u??",
- (u_int32_t)ntohl(mcp->mcla_vtype));
+ EXTRACT_32BITS(&mcp->mcla_vtype));
break;
}
++mcp;
@@ -439,13 +439,13 @@ ospf6_print_lsa(register const struct lsa *lsap)
/* Link LSA */
llsap = &lsap->lsa_un.un_llsa;
TCHECK(llsap->llsa_options);
- ospf6_print_bits(ospf6_option_bits, ntohl(llsap->llsa_options));
+ ospf6_print_bits(ospf6_option_bits, EXTRACT_32BITS(&llsap->llsa_options));
TCHECK(llsap->llsa_nprefix);
printf(" pri %d lladdr %s npref %d", llsap->llsa_priority,
ip6addr_string(&llsap->llsa_lladdr),
- (u_int32_t)ntohl(llsap->llsa_nprefix));
+ EXTRACT_32BITS(&llsap->llsa_nprefix));
lsapp = llsap->llsa_prefix;
- for (j = 0; j < ntohl(llsap->llsa_nprefix); j++) {
+ for (j = 0; j < EXTRACT_32BITS(&llsap->llsa_nprefix); j++) {
k = ospf6_print_lsaprefix(lsapp);
if (k)
goto trunc;
@@ -457,17 +457,17 @@ ospf6_print_lsa(register const struct lsa *lsap)
/* Intra-Area-Prefix LSA */
TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
ospf6_print_ls_type(
- ntohs(lsap->lsa_un.un_intra_ap.intra_ap_lstype),
+ EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_lstype),
&lsap->lsa_un.un_intra_ap.intra_ap_lsid,
&lsap->lsa_un.un_intra_ap.intra_ap_rtid,
"LinkStateType %d");
TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
printf(" npref %d",
- ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix));
+ EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix));
lsapp = lsap->lsa_un.un_intra_ap.intra_ap_prefix;
for (j = 0;
- j < ntohs(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
+ j < EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
j++) {
k = ospf6_print_lsaprefix(lsapp);
if (k)
@@ -478,7 +478,7 @@ ospf6_print_lsa(register const struct lsa *lsap)
default:
printf(" ??LinkStateType 0x%04x??",
- ntohs(lsap->ls_hdr.ls_type));
+ EXTRACT_16BITS(&lsap->ls_hdr.ls_type));
}
/* { (ctags) */
@@ -513,12 +513,12 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
if (vflag) {
TCHECK(op->ospf6_hello.hello_deadint);
ospf6_print_bits(ospf6_option_bits,
- ntohl(op->ospf6_hello.hello_options));
+ EXTRACT_32BITS(&op->ospf6_hello.hello_options));
printf(" ifid %s pri %d int %d dead %u",
ipaddr_string(&op->ospf6_hello.hello_ifid),
op->ospf6_hello.hello_priority,
- ntohs(op->ospf6_hello.hello_helloint),
- ntohs(op->ospf6_hello.hello_deadint));
+ EXTRACT_16BITS(&op->ospf6_hello.hello_helloint),
+ EXTRACT_16BITS(&op->ospf6_hello.hello_deadint));
}
TCHECK(op->ospf6_hello.hello_dr);
if (op->ospf6_hello.hello_dr != 0)
@@ -542,7 +542,7 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
case OSPF_TYPE_DB:
TCHECK(op->ospf6_db.db_options);
ospf6_print_bits(ospf6_option_bits,
- ntohl(op->ospf6_db.db_options));
+ EXTRACT_32BITS(&op->ospf6_db.db_options));
sep = ' ';
TCHECK(op->ospf6_db.db_flags);
if (op->ospf6_db.db_flags & OSPF6_DB_INIT) {
@@ -558,8 +558,8 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
sep = '/';
}
TCHECK(op->ospf6_db.db_seq);
- printf(" mtu %u S %X", ntohs(op->ospf6_db.db_mtu),
- (u_int32_t)ntohl(op->ospf6_db.db_seq));
+ printf(" mtu %u S %X", EXTRACT_16BITS(&op->ospf6_db.db_mtu),
+ EXTRACT_32BITS(&op->ospf6_db.db_seq));
if (vflag) {
/* Print all the LS adv's */
@@ -579,7 +579,7 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
while ((u_char *)lsrp < dataend) {
TCHECK(*lsrp);
printf(" {"); /* } (ctags) */
- ospf6_print_ls_type(ntohs(lsrp->ls_type),
+ ospf6_print_ls_type(EXTRACT_16BITS(&lsrp->ls_type),
&lsrp->ls_stateid,
&lsrp->ls_router,
"LinkStateType %d");
@@ -594,12 +594,12 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
if (vflag) {
lsap = op->ospf6_lsu.lsu_lsa;
TCHECK(op->ospf6_lsu.lsu_count);
- i = ntohl(op->ospf6_lsu.lsu_count);
+ i = EXTRACT_32BITS(&op->ospf6_lsu.lsu_count);
while (i--) {
if (ospf6_print_lsa(lsap))
goto trunc;
lsap = (struct lsa *)((u_char *)lsap +
- ntohs(lsap->ls_hdr.ls_length));
+ EXTRACT_16BITS(&lsap->ls_hdr.ls_length));
}
}
break;
@@ -644,8 +644,8 @@ ospf6_print(register const u_char *bp, register u_int length)
return;
TCHECK(op->ospf6_len);
- if (length != ntohs(op->ospf6_len)) {
- printf(" [len %d]", ntohs(op->ospf6_len));
+ if (length != EXTRACT_16BITS(&op->ospf6_len)) {
+ printf(" [len %d]", EXTRACT_16BITS(&op->ospf6_len));
return;
}
dataend = bp + length;
diff --git a/print-pim.c b/print-pim.c
index ac6891d5..87a611be 100644
--- a/print-pim.c
+++ b/print-pim.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.35 2002-11-09 17:19:28 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.36 2002-12-11 07:14:06 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -47,7 +47,7 @@ struct pim {
#define PIM_TYPE(x) ((x) & 0x0f)
u_char pim_rsv; /* Reserved */
u_short pim_cksum; /* IP style check sum */
-} __attribute__((packed));
+};
#include <stdio.h>
diff --git a/print-pptp.c b/print-pptp.c
index 00f5fe5a..8ab8fa59 100644
--- a/print-pptp.c
+++ b/print-pptp.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.8 2002-11-09 17:19:29 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.9 2002-12-11 07:14:07 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,6 +36,7 @@ static const char rcsid[] =
#include <stdio.h>
#include "interface.h"
+#include "extract.h"
static char tstr[] = " [|pptp]";
@@ -103,7 +104,7 @@ struct pptp_hdr {
u_int32_t magic_cookie;
u_int16_t ctrl_msg_type;
u_int16_t reserved0;
-} __attribute__((packed));
+};
struct pptp_msg_sccrq {
u_int16_t proto_ver;
@@ -114,7 +115,7 @@ struct pptp_msg_sccrq {
u_int16_t firm_rev;
u_char hostname[64];
u_char vendor[64];
-} __attribute__((packed));
+};
struct pptp_msg_sccrp {
u_int16_t proto_ver;
@@ -126,30 +127,30 @@ struct pptp_msg_sccrp {
u_int16_t firm_rev;
u_char hostname[64];
u_char vendor[64];
-} __attribute__((packed));
+};
struct pptp_msg_stopccrq {
u_int8_t reason;
u_int8_t reserved1;
u_int16_t reserved2;
-} __attribute__((packed));
+};
struct pptp_msg_stopccrp {
u_int8_t result_code;
u_int8_t err_code;
u_int16_t reserved1;
-} __attribute__((packed));
+};
struct pptp_msg_echorq {
u_int32_t id;
-} __attribute__((packed));
+};
struct pptp_msg_echorp {
u_int32_t id;
u_int8_t result_code;
u_int8_t err_code;
u_int16_t reserved1;
-} __attribute__((packed));
+};
struct pptp_msg_ocrq {
u_int16_t call_id;
@@ -164,7 +165,7 @@ struct pptp_msg_ocrq {
u_int16_t reserved1;
u_char phone_no[64];
u_char subaddr[64];
-} __attribute__((packed));
+};
struct pptp_msg_ocrp {
u_int16_t call_id;
@@ -176,7 +177,7 @@ struct pptp_msg_ocrp {
u_int16_t recv_winsiz;
u_int16_t pkt_proc_delay;
u_int32_t phy_chan_id;
-} __attribute__((packed));
+};
struct pptp_msg_icrq {
u_int16_t call_id;
@@ -188,7 +189,7 @@ struct pptp_msg_icrq {
u_char dialed_no[64]; /* DNIS */
u_char dialing_no[64]; /* CLID */
u_char subaddr[64];
-} __attribute__((packed));
+};
struct pptp_msg_icrp {
u_int16_t call_id;
@@ -198,7 +199,7 @@ struct pptp_msg_icrp {
u_int16_t recv_winsiz;
u_int16_t pkt_proc_delay;
u_int16_t reserved1;
-} __attribute__((packed));
+};
struct pptp_msg_iccn {
u_int16_t peer_call_id;
@@ -207,12 +208,12 @@ struct pptp_msg_iccn {
u_int16_t recv_winsiz;
u_int16_t pkt_proc_delay;
u_int32_t framing_type;
-} __attribute__((packed));
+};
struct pptp_msg_ccrq {
u_int16_t call_id;
u_int16_t reserved1;
-} __attribute__((packed));
+};
struct pptp_msg_cdn {
u_int16_t call_id;
@@ -221,7 +222,7 @@ struct pptp_msg_cdn {
u_int16_t cause_code;
u_int16_t reserved1;
u_char call_stats[128];
-} __attribute__((packed));
+};
struct pptp_msg_wen {
u_int16_t peer_call_id;
@@ -232,14 +233,14 @@ struct pptp_msg_wen {
u_int32_t buffer_overrun;
u_int32_t timeout_err;
u_int32_t align_err;
-} __attribute__((packed));
+};
struct pptp_msg_sli {
u_int16_t peer_call_id;
u_int16_t reserved1;
u_int32_t send_accm;
u_int32_t recv_accm;
-} __attribute__((packed));
+};
/* attributes that appear more than once in above messages:
@@ -286,10 +287,10 @@ static void
pptp_bearer_cap_print(const u_int32_t *bearer_cap)
{
printf(" BEARER_CAP(");
- if (ntohl(*bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) {
+ if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) {
printf("D");
}
- if (ntohl(*bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) {
+ if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) {
printf("A");
}
printf(")");
@@ -299,7 +300,7 @@ static void
pptp_bearer_type_print(const u_int32_t *bearer_type)
{
printf(" BEARER_TYPE(");
- switch (ntohl(*bearer_type)) {
+ switch (EXTRACT_32BITS(bearer_type)) {
case 1:
printf("A"); /* Analog */
break;
@@ -319,25 +320,25 @@ pptp_bearer_type_print(const u_int32_t *bearer_type)
static void
pptp_call_id_print(const u_int16_t *call_id)
{
- printf(" CALL_ID(%u)", ntohs(*call_id));
+ printf(" CALL_ID(%u)", EXTRACT_16BITS(call_id));
}
static void
pptp_call_ser_print(const u_int16_t *call_ser)
{
- printf(" CALL_SER_NUM(%u)", ntohs(*call_ser));
+ printf(" CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser));
}
static void
pptp_cause_code_print(const u_int16_t *cause_code)
{
- printf(" CAUSE_CODE(%u)", ntohs(*cause_code));
+ printf(" CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code));
}
static void
pptp_conn_speed_print(const u_int32_t *conn_speed)
{
- printf(" CONN_SPEED(%lu)", (unsigned long)ntohl(*conn_speed));
+ printf(" CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed));
}
static void
@@ -378,17 +379,17 @@ pptp_err_code_print(const u_int8_t *err_code)
static void
pptp_firm_rev_print(const u_int16_t *firm_rev)
{
- printf(" FIRM_REV(%u)", ntohs(*firm_rev));
+ printf(" FIRM_REV(%u)", EXTRACT_16BITS(firm_rev));
}
static void
pptp_framing_cap_print(const u_int32_t *framing_cap)
{
printf(" FRAME_CAP(");
- if (ntohl(*framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
+ if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
printf("A"); /* Async */
}
- if (ntohl(*framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
+ if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
printf("S"); /* Sync */
}
printf(")");
@@ -398,7 +399,7 @@ static void
pptp_framing_type_print(const u_int32_t *framing_type)
{
printf(" FRAME_TYPE(");
- switch (ntohl(*framing_type)) {
+ switch (EXTRACT_32BITS(framing_type)) {
case 1:
printf("A"); /* Async */
break;
@@ -424,44 +425,45 @@ pptp_hostname_print(const u_char *hostname)
static void
pptp_id_print(const u_int32_t *id)
{
- printf(" ID(%lu)", (unsigned long)ntohl(*id));
+ printf(" ID(%u)", EXTRACT_32BITS(id));
}
static void
pptp_max_channel_print(const u_int16_t *max_channel)
{
- printf(" MAX_CHAN(%u)", ntohs(*max_channel));
+ printf(" MAX_CHAN(%u)", EXTRACT_16BITS(max_channel));
}
static void
pptp_peer_call_id_print(const u_int16_t *peer_call_id)
{
- printf(" PEER_CALL_ID(%u)", ntohs(*peer_call_id));
+ printf(" PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id));
}
static void
pptp_phy_chan_id_print(const u_int32_t *phy_chan_id)
{
- printf(" PHY_CHAN_ID(%lu)", (unsigned long)ntohl(*phy_chan_id));
+ printf(" PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id));
}
static void
pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay)
{
- printf(" PROC_DELAY(%u)", ntohs(*pkt_proc_delay));
+ printf(" PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay));
}
static void
pptp_proto_ver_print(const u_int16_t *proto_ver)
{
printf(" PROTO_VER(%u.%u)", /* Version.Revision */
- ntohs(*proto_ver) >> 8, ntohs(*proto_ver) & 0xff);
+ EXTRACT_16BITS(proto_ver) >> 8,
+ EXTRACT_16BITS(proto_ver) & 0xff);
}
static void
pptp_recv_winsiz_print(const u_int16_t *recv_winsiz)
{
- printf(" RECV_WIN(%u)", ntohs(*recv_winsiz));
+ printf(" RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz));
}
static void
@@ -741,9 +743,9 @@ pptp_ocrq_print(const u_char *dat)
TCHECK(ptr->call_ser);
pptp_call_ser_print(&ptr->call_ser);
TCHECK(ptr->min_bps);
- printf(" MIN_BPS(%lu)", (unsigned long)ntohl(ptr->min_bps));
+ printf(" MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps));
TCHECK(ptr->max_bps);
- printf(" MAX_BPS(%lu)", (unsigned long)ntohl(ptr->max_bps));
+ printf(" MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps));
TCHECK(ptr->bearer_type);
pptp_bearer_type_print(&ptr->bearer_type);
TCHECK(ptr->framing_type);
@@ -753,7 +755,7 @@ pptp_ocrq_print(const u_char *dat)
TCHECK(ptr->pkt_proc_delay);
pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
TCHECK(ptr->phone_no_len);
- printf(" PHONE_NO_LEN(%u)", ntohs(ptr->phone_no_len));
+ printf(" PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len));
TCHECK(ptr->reserved1);
TCHECK(ptr->phone_no);
printf(" PHONE_NO(%.64s)", ptr->phone_no);
@@ -810,9 +812,9 @@ pptp_icrq_print(const u_char *dat)
TCHECK(ptr->phy_chan_id);
pptp_phy_chan_id_print(&ptr->phy_chan_id);
TCHECK(ptr->dialed_no_len);
- printf(" DIALED_NO_LEN(%u)", ntohs(ptr->dialed_no_len));
+ printf(" DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len));
TCHECK(ptr->dialing_no_len);
- printf(" DIALING_NO_LEN(%u)", ntohs(ptr->dialing_no_len));
+ printf(" DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len));
TCHECK(ptr->dialed_no);
printf(" DIALED_NO(%.64s)", ptr->dialed_no);
TCHECK(ptr->dialing_no);
@@ -921,19 +923,17 @@ pptp_wen_print(const u_char *dat)
pptp_peer_call_id_print(&ptr->peer_call_id);
TCHECK(ptr->reserved1);
TCHECK(ptr->crc_err);
- printf(" CRC_ERR(%lu)", (unsigned long)ntohl(ptr->crc_err));
+ printf(" CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err));
TCHECK(ptr->framing_err);
- printf(" FRAMING_ERR(%lu)", (unsigned long)ntohl(ptr->framing_err));
+ printf(" FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err));
TCHECK(ptr->hardware_overrun);
- printf(" HARDWARE_OVERRUN(%lu)",
- (unsigned long)ntohl(ptr->hardware_overrun));
+ printf(" HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun));
TCHECK(ptr->buffer_overrun);
- printf(" BUFFER_OVERRUN(%lu)",
- (unsigned long)ntohl(ptr->buffer_overrun));
+ printf(" BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun));
TCHECK(ptr->timeout_err);
- printf(" TIMEOUT_ERR(%lu)", (unsigned long)ntohl(ptr->timeout_err));
+ printf(" TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err));
TCHECK(ptr->align_err);
- printf(" ALIGN_ERR(%lu)", (unsigned long)ntohl(ptr->align_err));
+ printf(" ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err));
return;
@@ -950,9 +950,9 @@ pptp_sli_print(const u_char *dat)
pptp_peer_call_id_print(&ptr->peer_call_id);
TCHECK(ptr->reserved1);
TCHECK(ptr->send_accm);
- printf(" SEND_ACCM(0x%08lx)", (unsigned long)ntohl(ptr->send_accm));
+ printf(" SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm));
TCHECK(ptr->recv_accm);
- printf(" RECV_ACCM(0x%08lx)", (unsigned long)ntohl(ptr->recv_accm));
+ printf(" RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm));
return;
@@ -973,11 +973,11 @@ pptp_print(const u_char *dat)
TCHECK(hdr->length);
if (vflag) {
- printf(" Length=%u", ntohs(hdr->length));
+ printf(" Length=%u", EXTRACT_16BITS(&hdr->length));
}
TCHECK(hdr->msg_type);
if (vflag) {
- switch(ntohs(hdr->msg_type)) {
+ switch(EXTRACT_16BITS(&hdr->msg_type)) {
case PPTP_MSG_TYPE_CTRL:
printf(" CTRL-MSG");
break;
@@ -991,7 +991,7 @@ pptp_print(const u_char *dat)
}
TCHECK(hdr->magic_cookie);
- mc = ntohl(hdr->magic_cookie);
+ mc = EXTRACT_32BITS(&hdr->magic_cookie);
if (mc != PPTP_MAGIC_COOKIE) {
printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
}
@@ -999,7 +999,7 @@ pptp_print(const u_char *dat)
printf(" Magic-Cookie=%08x", mc);
}
TCHECK(hdr->ctrl_msg_type);
- ctrl_msg_type = ntohs(hdr->ctrl_msg_type);
+ ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
printf(" CTRL_MSGTYPE=%s",
pptp_message_type_string[ctrl_msg_type]);
diff --git a/print-radius.c b/print-radius.c
index cf620e86..ca3526bb 100644
--- a/print-radius.c
+++ b/print-radius.c
@@ -44,7 +44,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: print-radius.c,v 1.18 2002-11-10 20:37:31 guy Exp $";
+ "$Id: print-radius.c,v 1.19 2002-12-11 07:14:07 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -134,13 +134,13 @@ struct radius_hdr { u_int8_t code; /* Radius packet code */
u_int8_t id; /* Radius packet id */
u_int16_t len; /* Radius total length */
u_int8_t auth[16]; /* Authenticator */
- } __attribute__((packed));
+ };
#define MIN_RADIUS_LEN 20
struct radius_attr { u_int8_t type; /* Attribute type */
u_int8_t len; /* Attribute length */
- } __attribute__((packed));
+ };
/* Service-Type Attribute standard values */
@@ -823,7 +823,7 @@ radius_print(const u_char *dat, u_int length)
}
rad = (struct radius_hdr *)dat;
- len = ntohs(rad->len);
+ len = EXTRACT_16BITS(&rad->len);
if (len < MIN_RADIUS_LEN)
{
diff --git a/print-rip.c b/print-rip.c
index f8f523c5..ebee04b2 100644
--- a/print-rip.c
+++ b/print-rip.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.53 2002-11-09 17:19:30 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.54 2002-12-11 07:14:07 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -41,7 +41,7 @@ struct rip {
u_int8_t rip_cmd; /* request/response */
u_int8_t rip_vers; /* protocol version # */
u_int16_t rip_zero2; /* unused */
-} __attribute__((packed));
+};
#define RIPCMD_REQUEST 1 /* want info */
#define RIPCMD_RESPONSE 2 /* responding to request */
#define RIPCMD_TRACEON 3 /* turn tracing on */
@@ -58,7 +58,7 @@ struct rip_netinfo {
u_int32_t rip_dest_mask;
u_int32_t rip_router;
u_int32_t rip_metric; /* cost of route */
-} __attribute__((packed));
+};
static void
rip_printblk(const u_char *cp, const u_char *ep)
@@ -83,7 +83,9 @@ rip_entry_print_v1(register const struct rip_netinfo *ni)
printf("]");
return;
}
- if (ni->rip_tag || ni->rip_dest_mask || ni->rip_router) {
+ if (EXTRACT_16BITS(&ni->rip_tag) ||
+ EXTRACT_32BITS(&ni->rip_dest_mask) ||
+ EXTRACT_32BITS(&ni->rip_router)) {
/* MBZ fields not zero */
printf(" [");
rip_printblk((u_char *)&ni->rip_family,
@@ -139,11 +141,11 @@ rip_entry_print_v2(register const struct rip_netinfo *ni)
return;
} else { /* AF_INET */
printf(" {%s", ipaddr_string(&ni->rip_dest));
- if (ni->rip_dest_mask)
+ if (EXTRACT_32BITS(&ni->rip_dest_mask))
printf("/%s", ipaddr_string(&ni->rip_dest_mask));
- if (ni->rip_router)
+ if (EXTRACT_32BITS(&ni->rip_router))
printf("->%s", ipaddr_string(&ni->rip_router));
- if (ni->rip_tag)
+ if (EXTRACT_16BITS(&ni->rip_tag))
printf(" tag %04x", EXTRACT_16BITS(&ni->rip_tag));
printf("}(%d)", EXTRACT_32BITS(&ni->rip_metric));
}
diff --git a/print-ripng.c b/print-ripng.c
index 3bf0c846..128b31a6 100644
--- a/print-ripng.c
+++ b/print-ripng.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.13 2002-08-06 04:42:06 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.14 2002-12-11 07:14:08 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -52,6 +52,7 @@ IN6_ADDR_EQUAL(const struct in6_addr *a, const struct in6_addr *b)
#include "route6d.h"
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
static int
rip6_entry_print(register const struct netinfo6 *ni, int metric)
@@ -59,7 +60,7 @@ rip6_entry_print(register const struct netinfo6 *ni, int metric)
int l;
l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen);
if (ni->rip6_tag)
- l += printf(" [%d]", ntohs(ni->rip6_tag));
+ l += printf(" [%d]", EXTRACT_16BITS(&ni->rip6_tag));
if (metric)
l += printf(" (%d)", ni->rip6_metric);
return l;
diff --git a/print-rsvp.c b/print-rsvp.c
index 91c6c443..4f19fc37 100644
--- a/print-rsvp.c
+++ b/print-rsvp.c
@@ -15,7 +15,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.7 2002-12-10 08:16:22 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.8 2002-12-11 07:14:08 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -52,7 +52,7 @@ struct rsvp_common_header {
u_int8_t ttl;
u_int8_t reserved;
u_int8_t length[2];
-} __attribute__((packed));
+};
/*
* RFC2205 object header
@@ -72,7 +72,7 @@ struct rsvp_object_header {
u_int8_t length[2];
u_int8_t class_num;
u_int8_t ctype;
-} __attribute__((packed));
+};
#define RSVP_VERSION 1
#define RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
diff --git a/print-rt6.c b/print-rt6.c
index dd55d1fc..594f1ea1 100644
--- a/print-rt6.c
+++ b/print-rt6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.21 2002-08-01 08:53:26 risso Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.22 2002-12-11 07:14:08 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -38,6 +38,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
int
rt6_print(register const u_char *bp, register const u_char *bp2)
@@ -76,7 +77,7 @@ rt6_print(register const u_char *bp, register const u_char *bp2)
TCHECK(dp0->ip6r0_reserved);
if (dp0->ip6r0_reserved || vflag) {
printf(", rsv=0x%0x",
- (u_int32_t)ntohl(dp0->ip6r0_reserved));
+ EXTRACT_32BITS(&dp0->ip6r0_reserved));
}
if (len % 2 == 1)
diff --git a/print-sctp.c b/print-sctp.c
index dca31228..6606dbad 100644
--- a/print-sctp.c
+++ b/print-sctp.c
@@ -35,7 +35,7 @@
#ifndef lint
static const char rcsid[] =
-"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.10 2002-08-01 08:53:27 risso Exp $ (NETLAB/PEL)";
+"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.11 2002-12-11 07:14:08 guy Exp $ (NETLAB/PEL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -104,8 +104,8 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
/* sctpPacketLength -= sizeof(struct sctpHeader); packet length */
/* is now only as long as the payload */
- sourcePort = ntohs(sctpPktHdr->source);
- destPort = ntohs(sctpPktHdr->destination);
+ sourcePort = EXTRACT_16BITS(&sctpPktHdr->source);
+ destPort = EXTRACT_16BITS(&sctpPktHdr->destination);
#ifdef INET6
if (ip6) {
@@ -152,9 +152,9 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
u_short align;
const u_char *chunkEnd;
- chunkEnd = ((const u_char*)chunkDescPtr + ntohs(chunkDescPtr->chunkLength));
+ chunkEnd = ((const u_char*)chunkDescPtr + EXTRACT_16BITS(&chunkDescPtr->chunkLength));
- align=ntohs(chunkDescPtr->chunkLength) % 4;
+ align=EXTRACT_16BITS(&chunkDescPtr->chunkLength) % 4;
if (align != 0)
align = 4 - align;
@@ -193,10 +193,10 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
dataHdrPtr=(const struct sctpDataPart*)(chunkDescPtr+1);
- printf("[TSN: %u] ", (u_int32_t)ntohl(dataHdrPtr->TSN));
- printf("[SID: %u] ", ntohs(dataHdrPtr->streamId));
- printf("[SSEQ %u] ", ntohs(dataHdrPtr->sequence));
- printf("[PPID 0x%x] ", (u_int32_t)ntohl(dataHdrPtr->payloadtype));
+ printf("[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr->TSN));
+ printf("[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId));
+ printf("[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence));
+ printf("[PPID 0x%x] ", EXTRACT_32BITS(&dataHdrPtr->payloadtype));
fflush(stdout);
if (vflag) /* if verbose output is specified */
@@ -222,11 +222,11 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
printf("[INIT] ");
init=(const struct sctpInitiation*)(chunkDescPtr+1);
- printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag));
- printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit));
- printf("[OS: %u] ", ntohs(init->NumPreopenStreams));
- printf("[MIS: %u] ", ntohs(init->MaxInboundStreams));
- printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN));
+ printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag));
+ printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit));
+ printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams));
+ printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams));
+ printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN));
#if(0) /* ALC you can add code for optional params here */
if( (init+1) < chunkEnd )
@@ -241,11 +241,11 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
printf("[INIT ACK] ");
init=(const struct sctpInitiation*)(chunkDescPtr+1);
- printf("[init tag: %u] ", (u_int32_t)ntohl(init->initTag));
- printf("[rwnd: %u] ", (u_int32_t)ntohl(init->rcvWindowCredit));
- printf("[OS: %u] ", ntohs(init->NumPreopenStreams));
- printf("[MIS: %u] ", ntohs(init->MaxInboundStreams));
- printf("[init TSN: %u] ", (u_int32_t)ntohl(init->initialTSN));
+ printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag));
+ printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit));
+ printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams));
+ printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams));
+ printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN));
#if(0) /* ALC you can add code for optional params here */
if( (init+1) < chunkEnd )
@@ -263,30 +263,30 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
printf("[SACK] ");
sack=(const struct sctpSelectiveAck*)(chunkDescPtr+1);
- printf("[cum ack %u] ", (u_int32_t)ntohl(sack->highestConseqTSN));
- printf("[a_rwnd %u] ", (u_int32_t)ntohl(sack->updatedRwnd));
- printf("[#gap acks %u] ", ntohs(sack->numberOfdesc));
- printf("[#dup tsns %u] ", ntohs(sack->numDupTsns));
+ printf("[cum ack %u] ", EXTRACT_32BITS(&sack->highestConseqTSN));
+ printf("[a_rwnd %u] ", EXTRACT_32BITS(&sack->updatedRwnd));
+ printf("[#gap acks %u] ", EXTRACT_16BITS(&sack->numberOfdesc));
+ printf("[#dup tsns %u] ", EXTRACT_16BITS(&sack->numDupTsns));
/* print gaps */
for (frag = ( (const struct sctpSelectiveFrag *)
((const struct sctpSelectiveAck *) sack+1)),
fragNo=0;
- (const void *)frag < nextChunk && fragNo < ntohs(sack->numberOfdesc);
+ (const void *)frag < nextChunk && fragNo < EXTRACT_16BITS(&sack->numberOfdesc);
frag++, fragNo++)
printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ",
fragNo+1,
- (u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentStart)),
- (u_int32_t)(ntohl(sack->highestConseqTSN) + ntohs(frag->fragmentEnd)));
+ EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentStart),
+ EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentEnd));
/* print duplicate TSNs */
for (dupTSN = (const u_long*)frag, tsnNo=0;
- (const void *) dupTSN < nextChunk && tsnNo<ntohs(sack->numDupTsns);
+ (const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns);
dupTSN++, tsnNo++)
printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
- (u_int32_t)ntohl(*dupTSN));
+ EXTRACT_32BITS(dupTSN));
break;
}
diff --git a/print-sunrpc.c b/print-sunrpc.c
index b4257cfa..83a73f11 100644
--- a/print-sunrpc.c
+++ b/print-sunrpc.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.42 2002-09-05 00:00:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.43 2002-12-11 07:14:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -43,6 +43,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#include "ip.h"
#ifdef INET6
@@ -78,11 +79,11 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
if (!nflag) {
snprintf(srcid, sizeof(srcid), "0x%x",
- (u_int32_t)ntohl(rp->rm_xid));
+ EXTRACT_32BITS(&rp->rm_xid));
strlcpy(dstid, "sunrpc", sizeof(dstid));
} else {
snprintf(srcid, sizeof(srcid), "0x%x",
- (u_int32_t)ntohl(rp->rm_xid));
+ EXTRACT_32BITS(&rp->rm_xid));
snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT);
}
@@ -107,23 +108,23 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
}
printf(" %s", tok2str(proc2str, " proc #%u",
- (u_int32_t)ntohl(rp->rm_call.cb_proc)));
- x = ntohl(rp->rm_call.cb_rpcvers);
+ EXTRACT_32BITS(&rp->rm_call.cb_proc)));
+ x = EXTRACT_32BITS(&rp->rm_call.cb_rpcvers);
if (x != 2)
printf(" [rpcver %u]", x);
- switch (ntohl(rp->rm_call.cb_proc)) {
+ switch (EXTRACT_32BITS(&rp->rm_call.cb_proc)) {
case PMAPPROC_SET:
case PMAPPROC_UNSET:
case PMAPPROC_GETPORT:
case PMAPPROC_CALLIT:
- x = ntohl(rp->rm_call.cb_prog);
+ x = EXTRACT_32BITS(&rp->rm_call.cb_prog);
if (!nflag)
printf(" %s", progstr(x));
else
printf(" %u", x);
- printf(".%u", (u_int32_t)ntohl(rp->rm_call.cb_vers));
+ printf(".%u", EXTRACT_32BITS(&rp->rm_call.cb_vers));
break;
}
}
diff --git a/print-tcp.c b/print-tcp.c
index e423f8c3..1619a208 100644
--- a/print-tcp.c
+++ b/print-tcp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.103 2002-09-05 21:25:49 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.104 2002-12-11 07:14:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -146,7 +146,7 @@ static int tcp6_cksum(const struct ip6_hdr *ip6, const struct tcphdr *tp,
u_int16_t pa[20];
} phu;
- tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) -
+ tlen = EXTRACT_16BITS(&ip6->ip6_plen) + sizeof(struct ip6_hdr) -
((const char *)tp - (const char*)ip6);
/* pseudo-header */
@@ -208,8 +208,8 @@ tcp_print(register const u_char *bp, register u_int length,
return;
}
- sport = ntohs(tp->th_sport);
- dport = ntohs(tp->th_dport);
+ sport = EXTRACT_16BITS(&tp->th_sport);
+ dport = EXTRACT_16BITS(&tp->th_dport);
hlen = TH_OFF(tp) * 4;
@@ -261,10 +261,10 @@ tcp_print(register const u_char *bp, register u_int length,
TCHECK(*tp);
- seq = (u_int32_t)ntohl(tp->th_seq);
- ack = (u_int32_t)ntohl(tp->th_ack);
- win = ntohs(tp->th_win);
- urp = ntohs(tp->th_urp);
+ seq = EXTRACT_32BITS(&tp->th_seq);
+ ack = EXTRACT_32BITS(&tp->th_ack);
+ win = EXTRACT_16BITS(&tp->th_win);
+ urp = EXTRACT_16BITS(&tp->th_urp);
if (qflag) {
(void)printf("tcp %d", length - TH_OFF(tp) * 4);
@@ -289,6 +289,7 @@ tcp_print(register const u_char *bp, register u_int length,
if (!Sflag && (flags & TH_ACK)) {
register struct tcp_seq_hash *th;
+ const void *src, *dst;
register int rev;
struct tha tha;
/*
@@ -301,63 +302,68 @@ tcp_print(register const u_char *bp, register u_int length,
memset(&tha, 0, sizeof(tha));
rev = 0;
if (ip6) {
+ src = &ip6->ip6_src;
+ dst = &ip6->ip6_dst;
if (sport > dport)
rev = 1;
else if (sport == dport) {
- int i;
-
- for (i = 0; i < 4; i++) {
- if (((u_int32_t *)(&ip6->ip6_src))[i] >
- ((u_int32_t *)(&ip6->ip6_dst))[i]) {
- rev = 1;
- break;
- }
- }
+ if (memcmp(src, dst, sizeof ip6->ip6_dst) > 0)
+ rev = 1;
}
if (rev) {
- tha.src = ip6->ip6_dst;
- tha.dst = ip6->ip6_src;
+ memcpy(&tha.src, dst, sizeof ip6->ip6_dst);
+ memcpy(&tha.dst, src, sizeof ip6->ip6_src);
tha.port = dport << 16 | sport;
} else {
- tha.dst = ip6->ip6_dst;
- tha.src = ip6->ip6_src;
+ memcpy(&tha.dst, dst, sizeof ip6->ip6_dst);
+ memcpy(&tha.src, src, sizeof ip6->ip6_src);
tha.port = sport << 16 | dport;
}
} else {
- if (sport > dport ||
- (sport == dport &&
- ip->ip_src.s_addr > ip->ip_dst.s_addr)) {
+ src = &ip->ip_src;
+ dst = &ip->ip_dst;
+ if (sport > dport)
rev = 1;
+ else if (sport == dport) {
+ if (memcmp(src, dst, sizeof ip->ip_dst) > 0)
+ rev = 1;
}
if (rev) {
- *(struct in_addr *)&tha.src = ip->ip_dst;
- *(struct in_addr *)&tha.dst = ip->ip_src;
+ memcpy(&tha.src, dst, sizeof ip->ip_dst);
+ memcpy(&tha.dst, src, sizeof ip->ip_src);
tha.port = dport << 16 | sport;
} else {
- *(struct in_addr *)&tha.dst = ip->ip_dst;
- *(struct in_addr *)&tha.src = ip->ip_src;
+ memcpy(&tha.dst, dst, sizeof ip->ip_dst);
+ memcpy(&tha.src, src, sizeof ip->ip_src);
tha.port = sport << 16 | dport;
}
}
#else
- if (sport < dport ||
- (sport == dport &&
- ip->ip_src.s_addr < ip->ip_dst.s_addr)) {
- tha.src = ip->ip_src, tha.dst = ip->ip_dst;
- tha.port = sport << 16 | dport;
- rev = 0;
- } else {
- tha.src = ip->ip_dst, tha.dst = ip->ip_src;
- tha.port = dport << 16 | sport;
+ rev = 0;
+ src = &ip->ip_src;
+ dst = &ip->ip_dst;
+ if (sport > dport)
rev = 1;
+ else if (sport == dport) {
+ if (memcmp(src, dst, sizeof ip->ip_dst) > 0)
+ rev = 1;
+ }
+ if (rev) {
+ memcpy(&tha.src, dst, sizeof ip->ip_dst);
+ memcpy(&tha.dst, src, sizeof ip->ip_src);
+ tha.port = dport << 16 | sport;
+ } else {
+ memcpy(&tha.dst, dst, sizeof ip->ip_dst);
+ memcpy(&tha.src, src, sizeof ip->ip_src);
+ tha.port = sport << 16 | dport;
}
#endif
threv = rev;
for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE];
th->nxt; th = th->nxt)
- if (!memcmp((char *)&tha, (char *)&th->addr,
- sizeof(th->addr)))
+ if (memcmp((char *)&tha, (char *)&th->addr,
+ sizeof(th->addr)) == 0)
break;
if (!th->nxt || (flags & TH_SYN)) {
@@ -396,7 +402,7 @@ tcp_print(register const u_char *bp, register u_int length,
if (TTEST2(tp->th_sport, length)) {
sum = tcp_cksum(ip, tp, length);
if (sum != 0) {
- tcp_sum = ntohs(tp->th_sum);
+ tcp_sum = EXTRACT_16BITS(&tp->th_sum);
(void)printf(" [bad tcp cksum %x (->%x)!]",
tcp_sum, in_cksum_shouldbe(tcp_sum, sum));
} else
diff --git a/print-tftp.c b/print-tftp.c
index 2a09c4c2..d09a5ba6 100644
--- a/print-tftp.c
+++ b/print-tftp.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.32 2002-08-01 08:53:32 risso Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.33 2002-12-11 07:14:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -42,6 +42,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
/* op code to string mapping */
static struct tok op2str[] = {
@@ -85,7 +86,7 @@ tftp_print(register const u_char *bp, u_int length)
/* Print tftp request type */
TCHECK(tp->th_opcode);
- opcode = ntohs(tp->th_opcode);
+ opcode = EXTRACT_16BITS(&tp->th_opcode);
cp = tok2str(op2str, "tftp-#%d", opcode);
printf(" %s", cp);
/* Bail if bogus opcode */
@@ -115,14 +116,14 @@ tftp_print(register const u_char *bp, u_int length)
case ACK:
case DATA:
TCHECK(tp->th_block);
- printf(" block %d", ntohs(tp->th_block));
+ printf(" block %d", EXTRACT_16BITS(&tp->th_block));
break;
case ERROR:
/* Print error code string */
TCHECK(tp->th_code);
printf(" %s ", tok2str(err2str, "tftp-err-#%d \"",
- ntohs(tp->th_code)));
+ EXTRACT_16BITS(&tp->th_code)));
/* Print error message string */
i = fn_print((const u_char *)tp->th_data, snapend);
putchar('"');
diff --git a/print-timed.c b/print-timed.c
index 0396cee9..3448865c 100644
--- a/print-timed.c
+++ b/print-timed.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.6 2002-09-05 21:25:50 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.7 2002-12-11 07:14:10 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,6 +35,7 @@ static const char rcsid[] =
#include "timed.h"
#include "interface.h"
+#include "extract.h"
static const char *tsptype[TSPTYPENUMBER] =
{ "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
@@ -85,8 +86,8 @@ timed_print(register const u_char *bp)
fputs(" [|timed]", stdout);
return;
}
- sec = ntohl((long)tsp->tsp_time.tv_sec);
- usec = ntohl((long)tsp->tsp_time.tv_usec);
+ sec = EXTRACT_32BITS(&tsp->tsp_time.tv_sec);
+ usec = EXTRACT_32BITS(&tsp->tsp_time.tv_usec);
if (usec < 0)
/* corrupt, skip the rest of the packet */
return;
diff --git a/print-udp.c b/print-udp.c
index ffbe5d1e..67c36715 100644
--- a/print-udp.c
+++ b/print-udp.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.112 2002-12-04 19:09:30 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.113 2002-12-11 07:14:10 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -42,6 +42,7 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
#include "appletalk.h"
#include "udp.h"
@@ -59,12 +60,12 @@ struct rtcphdr {
u_int16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
u_int16_t rh_len; /* length of message (in words) */
u_int32_t rh_ssrc; /* synchronization src id */
-} __attribute__((packed));
+};
typedef struct {
u_int32_t upper; /* more significant 32 bits */
u_int32_t lower; /* less significant 32 bits */
-} ntp64 __attribute__((packed));
+} ntp64;
/*
* Sender report.
@@ -74,7 +75,7 @@ struct rtcp_sr {
u_int32_t sr_ts; /* reference media timestamp */
u_int32_t sr_np; /* no. packets sent */
u_int32_t sr_nb; /* no. bytes sent */
-} __attribute__((packed));
+};
/*
* Receiver report.
@@ -87,7 +88,7 @@ struct rtcp_rr {
u_int32_t rr_dv; /* jitter (delay variance) */
u_int32_t rr_lsr; /* orig. ts from last rr from this src */
u_int32_t rr_dlsr; /* time from recpt of last rr to xmit time */
-} __attribute__((packed));
+};
/*XXX*/
#define RTCP_PT_SR 200
@@ -112,14 +113,14 @@ vat_print(const void *hdr, register const struct udphdr *up)
if ((ts & 0xf060) != 0) {
/* probably vt */
(void)printf("udp/vt %u %d / %d",
- (u_int32_t)(ntohs(up->uh_ulen) - sizeof(*up)),
+ (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
ts & 0x3ff, ts >> 10);
} else {
/* probably vat */
- u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]);
- u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]);
+ u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
+ u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
printf("udp/vat %u c%d %u%s",
- (u_int32_t)(ntohs(up->uh_ulen) - sizeof(*up) - 8),
+ (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
i0 & 0xffff,
i1, i0 & 0x800000? "*" : "");
/* audio format */
@@ -136,9 +137,9 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
/* rtp v1 or v2 */
u_int *ip = (u_int *)hdr;
u_int hasopt, hasext, contype, hasmarker;
- u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]);
- u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]);
- u_int dlen = ntohs(up->uh_ulen) - sizeof(*up) - 8;
+ u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
+ u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
+ u_int dlen = EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8;
const char * ptype;
ip += 2;
@@ -171,7 +172,7 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
i0 & 0xffff,
i1);
if (vflag) {
- printf(" %u", (u_int32_t)ntohl(((u_int *)hdr)[2]));
+ printf(" %u", EXTRACT_32BITS(&((u_int *)hdr)[2]));
if (hasopt) {
u_int i2, optlen;
do {
@@ -215,8 +216,8 @@ rtcp_print(const u_char *hdr, const u_char *ep)
printf(" [|rtcp]");
return (ep);
}
- len = (ntohs(rh->rh_len) + 1) * 4;
- flags = ntohs(rh->rh_flags);
+ len = (EXTRACT_16BITS(&rh->rh_len) + 1) * 4;
+ flags = EXTRACT_16BITS(&rh->rh_flags);
cnt = (flags >> 8) & 0x1f;
switch (flags & 0xff) {
case RTCP_PT_SR:
@@ -225,16 +226,16 @@ rtcp_print(const u_char *hdr, const u_char *ep)
if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
printf(" [%d]", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
if ((u_char *)(sr + 1) > ep) {
printf(" [|rtcp]");
return (ep);
}
- ts = (double)((u_int32_t)ntohl(sr->sr_ntp.upper)) +
- ((double)((u_int32_t)ntohl(sr->sr_ntp.lower)) /
+ ts = (double)(EXTRACT_32BITS(&sr->sr_ntp.upper)) +
+ ((double)(EXTRACT_32BITS(&sr->sr_ntp.lower)) /
4294967296.0);
- printf(" @%.2f %u %up %ub", ts, (u_int32_t)ntohl(sr->sr_ts),
- (u_int32_t)ntohl(sr->sr_np), (u_int32_t)ntohl(sr->sr_nb));
+ printf(" @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts),
+ EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb));
rr = (struct rtcp_rr *)(sr + 1);
break;
case RTCP_PT_RR:
@@ -243,18 +244,18 @@ rtcp_print(const u_char *hdr, const u_char *ep)
printf(" [%d]", len);
rr = (struct rtcp_rr *)(rh + 1);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
break;
case RTCP_PT_SDES:
printf(" sdes %d", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
cnt = 0;
break;
case RTCP_PT_BYE:
printf(" bye %d", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
cnt = 0;
break;
default:
@@ -270,13 +271,13 @@ rtcp_print(const u_char *hdr, const u_char *ep)
return (ep);
}
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rr->rr_srcid));
- ts = (double)((u_int32_t)ntohl(rr->rr_lsr)) / 65536.;
- dts = (double)((u_int32_t)ntohl(rr->rr_dlsr)) / 65536.;
+ printf(" %u", EXTRACT_32BITS(&rr->rr_srcid));
+ ts = (double)(EXTRACT_32BITS(&rr->rr_lsr)) / 65536.;
+ dts = (double)(EXTRACT_32BITS(&rr->rr_dlsr)) / 65536.;
printf(" %ul %us %uj @%.2f+%.2f",
- (u_int32_t)ntohl(rr->rr_nl) & 0x00ffffff,
- (u_int32_t)ntohl(rr->rr_ls),
- (u_int32_t)ntohl(rr->rr_dv), ts, dts);
+ EXTRACT_32BITS(&rr->rr_nl) & 0x00ffffff,
+ EXTRACT_32BITS(&rr->rr_ls),
+ EXTRACT_32BITS(&rr->rr_dv), ts, dts);
}
return (hdr + len);
}
@@ -330,7 +331,7 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
u_int16_t pa[20];
} phu;
- tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) -
+ tlen = EXTRACT_16BITS(&ip6->ip6_plen) + sizeof(struct ip6_hdr) -
((const char *)up - (const char*)ip6);
/* pseudo-header */
@@ -471,9 +472,9 @@ udp_print(register const u_char *bp, u_int length,
}
length -= sizeof(struct udphdr);
- sport = ntohs(up->uh_sport);
- dport = ntohs(up->uh_dport);
- ulen = ntohs(up->uh_ulen);
+ sport = EXTRACT_16BITS(&up->uh_sport);
+ dport = EXTRACT_16BITS(&up->uh_dport);
+ ulen = EXTRACT_16BITS(&up->uh_ulen);
if (ulen < 8) {
(void)printf("%s > %s: truncated-udplength %d",
ipaddr_string(&ip->ip_src),
@@ -499,7 +500,7 @@ udp_print(register const u_char *bp, u_int length,
case PT_RPC:
rp = (struct rpc_msg *)(up + 1);
- direction = (enum msg_type)ntohl(rp->rm_direction);
+ direction = (enum msg_type)EXTRACT_32BITS(&rp->rm_direction);
if (direction == CALL)
sunrpcrequest_print((u_char *)rp, length,
(u_char *)ip);
@@ -538,7 +539,7 @@ udp_print(register const u_char *bp, u_int length,
rp = (struct rpc_msg *)(up + 1);
if (TTEST(rp->rm_direction)) {
- direction = (enum msg_type)ntohl(rp->rm_direction);
+ direction = (enum msg_type)EXTRACT_32BITS(&rp->rm_direction);
if (dport == NFS_PORT && direction == CALL) {
nfsreq_print((u_char *)rp, length,
(u_char *)ip);
diff --git a/print-wb.c b/print-wb.c
index 31e6bbd9..6ac4535c 100644
--- a/print-wb.c
+++ b/print-wb.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.29 2002-11-09 17:19:31 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.30 2002-12-11 07:14:10 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,8 +34,10 @@ static const char rcsid[] =
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h"
/* XXX need to add byte-swapping macros! */
+/* XXX - you mean like the ones in "extract.h"? */
/*
* Largest packet size. Everything should fit within this space.
@@ -51,7 +53,7 @@ static const char rcsid[] =
#define DOP_ROUNDUP(x) ((((int)(x)) + (DOP_ALIGN - 1)) & ~(DOP_ALIGN - 1))
#define DOP_NEXT(d)\
((struct dophdr *)((u_char *)(d) + \
- DOP_ROUNDUP(ntohs((d)->dh_len) + sizeof(*(d)))))
+ DOP_ROUNDUP(EXTRACT_16BITS(&(d)->dh_len) + sizeof(*(d)))))
/*
* Format of the whiteboard packet header.
@@ -63,7 +65,7 @@ struct pkt_hdr {
u_int16_t ph_version; /* version number */
u_char ph_type; /* message type */
u_char ph_flags; /* message flags */
-} __attribute__((packed));
+};
/* Packet types */
#define PT_DRAWOP 0 /* drawing operation */
@@ -85,7 +87,7 @@ struct pkt_hdr {
struct PageID {
u_int32_t p_sid; /* session id of initiator */
u_int32_t p_uid; /* page number */
-} __attribute__((packed));
+};
struct dophdr {
u_int32_t dh_ts; /* sender's timestamp */
@@ -93,7 +95,7 @@ struct dophdr {
u_char dh_flags;
u_char dh_type; /* body type */
/* body follows */
-} __attribute__((packed));
+};
/*
* Drawing op sub-types.
*/
@@ -121,7 +123,7 @@ struct pkt_dop {
u_int32_t pd_sseq; /* start sequence number */
u_int32_t pd_eseq; /* end sequence number */
/* drawing ops follow */
-} __attribute__((packed));
+};
/*
* A repair request.
@@ -131,7 +133,7 @@ struct pkt_rreq {
struct PageID pr_page; /* page of drawops */
u_int32_t pr_sseq; /* start seqno */
u_int32_t pr_eseq; /* end seqno */
-} __attribute__((packed));
+};
/*
* A repair reply.
@@ -140,12 +142,12 @@ struct pkt_rrep {
u_int32_t pr_id; /* original site id of ops */
struct pkt_dop pr_dop;
/* drawing ops follow */
-} __attribute__((packed));
+};
struct id_off {
u_int32_t id;
u_int32_t off;
-} __attribute__((packed));
+};
struct pgstate {
u_int32_t slot;
@@ -153,7 +155,7 @@ struct pgstate {
u_int16_t nid;
u_int16_t rsvd;
/* seqptr's */
-} __attribute__((packed));
+};
/*
* An announcement packet.
@@ -164,18 +166,18 @@ struct pkt_id {
struct pgstate pi_ps;
/* seqptr's */
/* null-terminated site name */
-} __attribute__((packed));
+};
struct pkt_preq {
struct PageID pp_page;
u_int32_t pp_low;
u_int32_t pp_high;
-} __attribute__((packed));
+};
struct pkt_prep {
u_int32_t pp_n; /* size of pageid array */
/* pgstate's follow */
-} __attribute__((packed));
+};
static int
wb_id(const struct pkt_id *id, u_int len)
@@ -192,14 +194,14 @@ wb_id(const struct pkt_id *id, u_int len)
len -= sizeof(*id);
printf(" %u/%s:%u (max %u/%s:%u) ",
- (u_int32_t)ntohl(id->pi_ps.slot),
+ EXTRACT_32BITS(&id->pi_ps.slot),
ipaddr_string(&id->pi_ps.page.p_sid),
- (u_int32_t)ntohl(id->pi_ps.page.p_uid),
- (u_int32_t)ntohl(id->pi_mslot),
+ EXTRACT_32BITS(&id->pi_ps.page.p_uid),
+ EXTRACT_32BITS(&id->pi_mslot),
ipaddr_string(&id->pi_mpage.p_sid),
- (u_int32_t)ntohl(id->pi_mpage.p_uid));
+ EXTRACT_32BITS(&id->pi_mpage.p_uid));
- nid = ntohs(id->pi_ps.nid);
+ nid = EXTRACT_16BITS(&id->pi_ps.nid);
len -= sizeof(*io) * nid;
io = (struct id_off *)(id + 1);
cp = (char *)(io + nid);
@@ -212,7 +214,7 @@ wb_id(const struct pkt_id *id, u_int len)
c = '<';
for (i = 0; i < nid && (u_char *)io < snapend; ++io, ++i) {
printf("%c%s:%u",
- c, ipaddr_string(&io->id), (u_int32_t)ntohl(io->off));
+ c, ipaddr_string(&io->id), EXTRACT_32BITS(&io->off));
c = ',';
}
if (i >= nid) {
@@ -232,9 +234,9 @@ wb_rreq(const struct pkt_rreq *rreq, u_int len)
printf(" please repair %s %s:%u<%u:%u>",
ipaddr_string(&rreq->pr_id),
ipaddr_string(&rreq->pr_page.p_sid),
- (u_int32_t)ntohl(rreq->pr_page.p_uid),
- (u_int32_t)ntohl(rreq->pr_sseq),
- (u_int32_t)ntohl(rreq->pr_eseq));
+ EXTRACT_32BITS(&rreq->pr_page.p_uid),
+ EXTRACT_32BITS(&rreq->pr_sseq),
+ EXTRACT_32BITS(&rreq->pr_eseq));
return (0);
}
@@ -246,9 +248,9 @@ wb_preq(const struct pkt_preq *preq, u_int len)
return (-1);
printf(" need %u/%s:%u",
- (u_int32_t)ntohl(preq->pp_low),
+ EXTRACT_32BITS(&preq->pp_low),
ipaddr_string(&preq->pp_page.p_sid),
- (u_int32_t)ntohl(preq->pp_page.p_uid));
+ EXTRACT_32BITS(&preq->pp_page.p_uid));
return (0);
}
@@ -263,20 +265,20 @@ wb_prep(const struct pkt_prep *prep, u_int len)
if (len < sizeof(*prep)) {
return (-1);
}
- n = ntohl(prep->pp_n);
+ n = EXTRACT_32BITS(&prep->pp_n);
ps = (const struct pgstate *)(prep + 1);
while (--n >= 0 && (u_char *)ps < ep) {
const struct id_off *io, *ie;
char c = '<';
printf(" %u/%s:%u",
- (u_int32_t)ntohl(ps->slot),
+ EXTRACT_32BITS(&ps->slot),
ipaddr_string(&ps->page.p_sid),
- (u_int32_t)ntohl(ps->page.p_uid));
+ EXTRACT_32BITS(&ps->page.p_uid));
io = (struct id_off *)(ps + 1);
for (ie = io + ps->nid; io < ie && (u_char *)io < ep; ++io) {
printf("%c%s:%u", c, ipaddr_string(&io->id),
- (u_int32_t)ntohl(io->off));
+ EXTRACT_32BITS(&io->off));
c = ',';
}
printf(">");
@@ -317,7 +319,7 @@ wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
else {
printf(" %s", dopstr[t]);
if (t == DT_SKIP || t == DT_HOLE) {
- u_int32_t ts = ntohl(dh->dh_ts);
+ u_int32_t ts = EXTRACT_32BITS(&dh->dh_ts);
printf("%d", ts - ss + 1);
if (ss > ts || ts > es) {
printf("[|]");
@@ -350,13 +352,14 @@ wb_rrep(const struct pkt_rrep *rrep, u_int len)
printf(" for %s %s:%u<%u:%u>",
ipaddr_string(&rrep->pr_id),
ipaddr_string(&dop->pd_page.p_sid),
- (u_int32_t)ntohl(dop->pd_page.p_uid),
- (u_int32_t)ntohl(dop->pd_sseq),
- (u_int32_t)ntohl(dop->pd_eseq));
+ EXTRACT_32BITS(&dop->pd_page.p_uid),
+ EXTRACT_32BITS(&dop->pd_sseq),
+ EXTRACT_32BITS(&dop->pd_eseq));
if (vflag)
return (wb_dops((const struct dophdr *)(dop + 1),
- ntohl(dop->pd_sseq), ntohl(dop->pd_eseq)));
+ EXTRACT_32BITS(&dop->pd_sseq),
+ EXTRACT_32BITS(&dop->pd_eseq)));
return (0);
}
@@ -370,13 +373,14 @@ wb_drawop(const struct pkt_dop *dop, u_int len)
printf(" %s:%u<%u:%u>",
ipaddr_string(&dop->pd_page.p_sid),
- (u_int32_t)ntohl(dop->pd_page.p_uid),
- (u_int32_t)ntohl(dop->pd_sseq),
- (u_int32_t)ntohl(dop->pd_eseq));
+ EXTRACT_32BITS(&dop->pd_page.p_uid),
+ EXTRACT_32BITS(&dop->pd_sseq),
+ EXTRACT_32BITS(&dop->pd_eseq));
if (vflag)
return (wb_dops((const struct dophdr *)(dop + 1),
- ntohl(dop->pd_sseq), ntohl(dop->pd_eseq)));
+ EXTRACT_32BITS(&dop->pd_sseq),
+ EXTRACT_32BITS(&dop->pd_eseq)));
return (0);
}
diff --git a/route6d.h b/route6d.h
index 85e66fb2..53953fdb 100644
--- a/route6d.h
+++ b/route6d.h
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
/*
- * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.4 2002-11-09 17:19:31 itojun Exp $
+ * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.5 2002-12-11 07:14:10 guy Exp $
*/
#define RIP6_VERSION 1
@@ -40,7 +40,7 @@ struct netinfo6 {
u_int16_t rip6_tag;
u_int8_t rip6_plen;
u_int8_t rip6_metric;
-} __attribute__((packed));
+};
struct rip6 {
u_int8_t rip6_cmd;
@@ -52,7 +52,7 @@ struct rip6 {
} rip6un;
#define rip6_nets rip6un.ru6_nets
#define rip6_tracefile rip6un.ru6_tracefile
-} __attribute__((packed));
+};
#define HOPCNT_INFINITY6 16
#define MAXRTE 24
diff --git a/rx.h b/rx.h
index 0bf0e77f..b79dd30c 100644
--- a/rx.h
+++ b/rx.h
@@ -23,7 +23,7 @@
/*
* Rx protocol format
*
- * $Id: rx.h,v 1.7 2002-11-09 17:19:31 itojun Exp $
+ * $Id: rx.h,v 1.8 2002-12-11 07:14:11 guy Exp $
*/
#define FS_RX_PORT 7000
@@ -85,7 +85,7 @@ struct rx_header {
u_int8_t securityIndex;
u_int16_t spare; /* How clever: even though the AFS */
u_int16_t serviceId; /* header files indicate that the */
-} __attribute__((packed)); /* serviceId is first, it's really */
+}; /* serviceId is first, it's really */
/* encoded _after_ the spare field */
/* I wasted a day figuring that out! */
@@ -103,7 +103,7 @@ struct rx_ackPacket {
u_int8_t reason; /* Reason for acknowledgement */
u_int8_t nAcks; /* Number of acknowledgements */
u_int8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
-} __attribute__((packed));
+};
/*
* Values for the acks array
diff --git a/sctpHeader.h b/sctpHeader.h
index a8b9bdd8..63f30b5d 100644
--- a/sctpHeader.h
+++ b/sctpHeader.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.5 2002-11-09 17:19:32 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002-12-11 07:14:11 guy Exp $ (LBL) */
/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
*
@@ -64,7 +64,7 @@ struct sctpHeader{
u_int16_t destination;
u_int32_t verificationTag;
u_int32_t adler32;
-} __attribute__((packed));
+};
/* various descriptor parsers */
@@ -72,25 +72,25 @@ struct sctpChunkDesc{
u_int8_t chunkID;
u_int8_t chunkFlg;
u_int16_t chunkLength;
-} __attribute__((packed));
+};
struct sctpParamDesc{
u_int16_t paramType;
u_int16_t paramLength;
-} __attribute__((packed));
+};
struct sctpRelChunkDesc{
struct sctpChunkDesc chk;
u_int32_t serialNumber;
-} __attribute__((packed));
+};
struct sctpVendorSpecificParam {
struct sctpParamDesc p; /* type must be 0xfffe */
u_int32_t vendorId; /* vendor ID from RFC 1700 */
u_int16_t vendorSpecificType;
u_int16_t vendorSpecificLen;
-} __attribute__((packed));
+};
/* Structures for the control parts */
@@ -107,35 +107,35 @@ struct sctpInitiation{
u_int16_t MaxInboundStreams; /* MIS */
u_int32_t initialTSN;
/* optional param's follow in sctpParamDesc form */
-} __attribute__((packed));
+};
struct sctpV4IpAddress{
struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
u_int32_t ipAddress;
-} __attribute__((packed));
+};
struct sctpV6IpAddress{
struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
u_int8_t ipAddress[16];
-} __attribute__((packed));
+};
struct sctpDNSName{
struct sctpParamDesc param;
u_int8_t name[1];
-} __attribute__((packed));
+};
struct sctpCookiePreserve{
struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */
u_int32_t extraTime;
-} __attribute__((packed));
+};
struct sctpTimeStamp{
u_int32_t ts_sec;
u_int32_t ts_usec;
-} __attribute__((packed));
+};
/* wire structure of my cookie */
struct cookieMessage{
@@ -152,7 +152,7 @@ struct cookieMessage{
* its entirety and of course our
* signature.
*/
-} __attribute__((packed));
+};
/* this guy is for use when
@@ -163,12 +163,12 @@ struct cookieMessage{
struct sctpUnifiedInit{
struct sctpChunkDesc uh;
struct sctpInitiation initm;
-} __attribute__((packed));
+};
struct sctpSendableInit{
struct sctpHeader mh;
struct sctpUnifiedInit msg;
-} __attribute__((packed));
+};
/* Selective Acknowledgement
@@ -183,18 +183,18 @@ struct sctpSelectiveAck{
u_int32_t updatedRwnd;
u_int16_t numberOfdesc;
u_int16_t numDupTsns;
-} __attribute__((packed));
+};
struct sctpSelectiveFrag{
u_int16_t fragmentStart;
u_int16_t fragmentEnd;
-} __attribute__((packed));
+};
struct sctpUnifiedSack{
struct sctpChunkDesc uh;
struct sctpSelectiveAck sack;
-} __attribute__((packed));
+};
/* for both RTT request/response the
* following is sent
@@ -203,13 +203,13 @@ struct sctpUnifiedSack{
struct sctpHBrequest {
u_int32_t time_value_1;
u_int32_t time_value_2;
-} __attribute__((packed));
+};
/* here is what I read and respond with to. */
struct sctpHBunified{
struct sctpChunkDesc hdr;
struct sctpParamDesc hb;
-} __attribute__((packed));
+};
/* here is what I send */
@@ -219,7 +219,7 @@ struct sctpHBsender{
struct sctpHBrequest rtt;
int8_t addrFmt[SCTP_ADDRMAX];
u_int16_t userreq;
-} __attribute__((packed));
+};
@@ -229,31 +229,31 @@ struct sctpHBsender{
*/
struct sctpUnifiedAbort{
struct sctpChunkDesc uh;
-} __attribute__((packed));
+};
struct sctpUnifiedAbortLight{
struct sctpHeader mh;
struct sctpChunkDesc uh;
-} __attribute__((packed));
+};
struct sctpUnifiedAbortHeavy{
struct sctpHeader mh;
struct sctpChunkDesc uh;
u_int16_t causeCode;
u_int16_t causeLen;
-} __attribute__((packed));
+};
/* For the graceful shutdown we must carry
* the tag (in common header) and the highest consequitive acking value
*/
struct sctpShutdown {
u_int32_t TSN_Seen;
-} __attribute__((packed));
+};
struct sctpUnifiedShutdown{
struct sctpChunkDesc uh;
struct sctpShutdown shut;
-} __attribute__((packed));
+};
/* in the unified message we add the trailing
* stream id since it is the only message
@@ -262,12 +262,12 @@ struct sctpUnifiedShutdown{
struct sctpOpErrorCause{
u_int16_t cause;
u_int16_t causeLen;
-} __attribute__((packed));
+};
struct sctpUnifiedOpError{
struct sctpChunkDesc uh;
struct sctpOpErrorCause c;
-} __attribute__((packed));
+};
struct sctpUnifiedStreamError{
struct sctpHeader mh;
@@ -275,14 +275,14 @@ struct sctpUnifiedStreamError{
struct sctpOpErrorCause c;
u_int16_t strmNum;
u_int16_t reserved;
-} __attribute__((packed));
+};
struct staleCookieMsg{
struct sctpHeader mh;
struct sctpChunkDesc uh;
struct sctpOpErrorCause c;
u_int32_t moretime;
-} __attribute__((packed));
+};
/* the following is used in all sends
* where nothing is needed except the
@@ -291,30 +291,30 @@ struct staleCookieMsg{
struct sctpUnifiedSingleMsg{
struct sctpHeader mh;
struct sctpChunkDesc uh;
-} __attribute__((packed));
+};
struct sctpDataPart{
u_int32_t TSN;
u_int16_t streamId;
u_int16_t sequence;
u_int32_t payloadtype;
-} __attribute__((packed));
+};
struct sctpUnifiedDatagram{
struct sctpChunkDesc uh;
struct sctpDataPart dp;
-} __attribute__((packed));
+};
struct sctpECN_echo{
struct sctpChunkDesc uh;
u_int32_t Lowest_TSN;
-} __attribute__((packed));
+};
struct sctpCWR{
struct sctpChunkDesc uh;
u_int32_t TSN_reduced_at;
-} __attribute__((packed));
+};
#ifdef __cplusplus
}
diff --git a/sll.h b/sll.h
index b2d7c779..ad0d7b59 100644
--- a/sll.h
+++ b/sll.h
@@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.6 2002-11-09 17:19:32 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.7 2002-12-11 07:14:11 guy Exp $ (LBL)
*/
/*
@@ -88,7 +88,7 @@ struct sll_header {
u_int16_t sll_halen; /* link-layer address length */
u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
u_int16_t sll_protocol; /* protocol */
-} __attribute__((packed));
+};
/*
* The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
diff --git a/tcp.h b/tcp.h
index 667948d9..43587ec4 100644
--- a/tcp.h
+++ b/tcp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.9 2002-11-09 17:19:32 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.10 2002-12-11 07:14:11 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -58,7 +58,7 @@ struct tcphdr {
u_int16_t th_win; /* window */
u_int16_t th_sum; /* checksum */
u_int16_t th_urp; /* urgent pointer */
-} __attribute__((packed));
+};
#define TCPOPT_EOL 0
#define TCPOPT_NOP 1
diff --git a/timed.h b/timed.h
index 1fa677f2..713f353a 100644
--- a/timed.h
+++ b/timed.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.4 2002-11-09 17:19:33 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.5 2002-12-11 07:14:12 guy Exp $ (LBL) */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -53,7 +53,7 @@ struct tsp {
int8_t tspu_hopcnt;
} tsp_u;
int8_t tsp_name[256];
-} __attribute__((packed));
+};
#define tsp_time tsp_u.tspu_time
#define tsp_hopcnt tsp_u.tspu_hopcnt
diff --git a/token.h b/token.h
index 76b7b638..b1d92a3f 100644
--- a/token.h
+++ b/token.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.5 2002-11-09 17:19:33 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.6 2002-12-11 07:14:12 guy Exp $ (LBL) */
/*
* Copyright (c) 1998, Larry Lile
* All rights reserved.
@@ -49,4 +49,4 @@ struct token_header {
u_int8_t token_shost[TOKEN_RING_MAC_LEN];
u_int16_t token_rcf;
u_int16_t token_rseg[ROUTING_SEGMENT_MAX];
-} __attribute__((packed));
+};
diff --git a/udp.h b/udp.h
index afc7b953..2e052cd8 100644
--- a/udp.h
+++ b/udp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.3 2002-11-09 17:19:33 itojun Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.4 2002-12-11 07:14:12 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -43,4 +43,4 @@ struct udphdr {
u_int16_t uh_dport; /* destination port */
u_int16_t uh_ulen; /* udp length */
u_int16_t uh_sum; /* udp checksum */
-} __attribute__((packed));
+};