summaryrefslogtreecommitdiff
path: root/ip.h
diff options
context:
space:
mode:
authoritojun <itojun>2000-10-03 02:54:54 +0000
committeritojun <itojun>2000-10-03 02:54:54 +0000
commitfb75d3cd5ad603bd255d9cdc20aeca674c6f3720 (patch)
treef7216518bb3fe268e2512bce0b8d68448d0aa976 /ip.h
parentcdaba7de64aab0672383804b7c80cc3678936b4f (diff)
downloadtcpdump-fb75d3cd5ad603bd255d9cdc20aeca674c6f3720.tar.gz
always use u_intXX_t for protocol format declaration. char/short/int may not
come with exact size. while at it, correct signedness of ip/udp header field. nuke most of the use of bitfield. TODO: bitfield in namser.h
Diffstat (limited to 'ip.h')
-rw-r--r--ip.h44
1 files changed, 17 insertions, 27 deletions
diff --git a/ip.h b/ip.h
index 9be7544a..f76cff80 100644
--- a/ip.h
+++ b/ip.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.4 2000-09-29 05:05:47 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.5 2000-10-03 02:54:56 itojun Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -71,24 +71,19 @@
* against negative integers quite easily, and fail in subtle ways.
*/
struct ip {
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_int ip_hl:4, /* header length */
- ip_v:4; /* version */
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int ip_v:4, /* version */
- ip_hl:4; /* header length */
-#endif
- u_char ip_tos; /* type of service */
- short ip_len; /* total length */
- u_short ip_id; /* identification */
- short ip_off; /* fragment offset field */
+ u_int8_t ip_vhl; /* header length, version */
+#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
+#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
+ u_int8_t ip_tos; /* type of service */
+ u_int16_t ip_len; /* total length */
+ u_int16_t ip_id; /* identification */
+ u_int16_t ip_off; /* fragment offset field */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
- u_char ip_ttl; /* time to live */
- u_char ip_p; /* protocol */
- u_short ip_sum; /* checksum */
+ u_int8_t ip_ttl; /* time to live */
+ u_int8_t ip_p; /* protocol */
+ u_int16_t ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
};
@@ -147,17 +142,12 @@ struct ip {
* Time stamp option structure.
*/
struct ip_timestamp {
- u_char ipt_code; /* IPOPT_TS */
- u_char ipt_len; /* size of structure (variable) */
- u_char ipt_ptr; /* index of current entry */
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_int ipt_flg:4, /* flags, see below */
- ipt_oflw:4; /* overflow counter */
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int ipt_oflw:4, /* overflow counter */
- ipt_flg:4; /* flags, see below */
-#endif
+ u_int8_t ipt_code; /* IPOPT_TS */
+ u_int8_t ipt_len; /* size of structure (variable) */
+ u_int8_t ipt_ptr; /* index of current entry */
+ u_int8_t ipt_flgoflw; /* flags, overflow counter */
+#define IPTS_FLG(ip) (((ipt)->ipt_flgoflw & 0xf0) >> 4)
+#define IPTS_OFLW(ip) ((ipt)->ipt_flgoflw & 0x0f)
union ipt_timestamp {
u_int32_t ipt_time[1];
struct ipt_ta {