diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-10-07 00:14:20 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-10-07 00:14:20 -0700 |
commit | bfe9582ec625704c427b441dfa3a57d7a99604b8 (patch) | |
tree | 8eeb76ef1e57f5f8b8d645388a8c85cef1cf0b12 /ip.h | |
parent | 6f1c171a6aac53ad3db8f6f8b74a98a6a76580a1 (diff) | |
download | tcpdump-bfe9582ec625704c427b441dfa3a57d7a99604b8.tar.gz |
Use the nd_uintN_t types more.
Define them in netdissect.h.
Use them in ip.h, and *don't* mark the structures as UNALIGNED; that
should no longer be necessary.
Add a new nd_ipv4 type to use as an IPv4 address; it represents the 4
bytes of IPv4 address as an array of unsigned chars, so that its natural
alignment is only on a byte boundary.
Those changes found some places where we weren't using
UNALIGNED_MEMCPY() to extract IPv4 addresses from packets; use it.
Diffstat (limited to 'ip.h')
-rw-r--r-- | ip.h | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -50,21 +50,21 @@ * against negative integers quite easily, and fail in subtle ways. */ struct ip { - uint8_t ip_vhl; /* header length, version */ + nd_uint8_t ip_vhl; /* header length, version */ #define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4) #define IP_HL(ip) ((ip)->ip_vhl & 0x0f) - uint8_t ip_tos; /* type of service */ - uint16_t ip_len; /* total length */ - uint16_t ip_id; /* identification */ - uint16_t ip_off; /* fragment offset field */ + nd_uint8_t ip_tos; /* type of service */ + nd_uint16_t ip_len; /* total length */ + nd_uint16_t ip_id; /* identification */ + nd_uint16_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 */ - uint8_t ip_ttl; /* time to live */ - uint8_t ip_p; /* protocol */ - uint16_t ip_sum; /* checksum */ - struct in_addr ip_src,ip_dst; /* source and dest address */ -} UNALIGNED; + nd_uint8_t ip_ttl; /* time to live */ + nd_uint8_t ip_p; /* protocol */ + nd_uint16_t ip_sum; /* checksum */ + nd_ipv4 ip_src,ip_dst; /* source and dest address */ +}; #define IP_MAXPACKET 65535 /* maximum packet size */ @@ -123,20 +123,20 @@ struct ip { * Time stamp option structure. */ struct ip_timestamp { - uint8_t ipt_code; /* IPOPT_TS */ - uint8_t ipt_len; /* size of structure (variable) */ - uint8_t ipt_ptr; /* index of current entry */ - uint8_t ipt_oflwflg; /* flags, overflow counter */ + nd_uint8_t ipt_code; /* IPOPT_TS */ + nd_uint8_t ipt_len; /* size of structure (variable) */ + nd_uint8_t ipt_ptr; /* index of current entry */ + nd_uint8_t ipt_oflwflg; /* flags, overflow counter */ #define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4) #define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f) union ipt_timestamp { - uint32_t ipt_time[1]; + nd_uint32_t ipt_time[1]; struct ipt_ta { - struct in_addr ipt_addr; - uint32_t ipt_time; + nd_ipv4 ipt_addr; + nd_uint32_t ipt_time; } ipt_ta[1]; } ipt_timestamp; -} UNALIGNED; +}; /* flag bits for ipt_flg */ #define IPOPT_TS_TSONLY 0 /* timestamps only */ |