#ifndef _IP_H_
#define _IP_H_
-#ifdef WORDS_BIGENDIAN
+#ifdef HOST_WORDS_BIGENDIAN
# ifndef NTOHL
# define NTOHL(d)
# endif
# define NTOHL(d) ((d) = ntohl((d)))
# endif
# ifndef NTOHS
-# define NTOHS(d) ((d) = ntohs((u_int16_t)(d)))
+# define NTOHS(d) ((d) = ntohs((uint16_t)(d)))
# endif
# ifndef HTONL
# define HTONL(d) ((d) = htonl((d)))
# endif
# ifndef HTONS
-# define HTONS(d) ((d) = htons((u_int16_t)(d)))
+# define HTONS(d) ((d) = htons((uint16_t)(d)))
# endif
#endif
-typedef u_int32_t n_long; /* long as received from the net */
+typedef uint32_t n_long; /* long as received from the net */
/*
* Definitions for internet protocol version 4.
* Structure of an internet header, naked of options.
*/
struct ip {
-#ifdef WORDS_BIGENDIAN
+#ifdef HOST_WORDS_BIGENDIAN
u_int ip_v:4, /* version */
ip_hl:4; /* header length */
#else
u_int ip_hl:4, /* header length */
ip_v:4; /* version */
#endif
- 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 */
+ 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 */
#define IP_DF 0x4000 /* don't fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
- u_int8_t ip_ttl; /* time to live */
- u_int8_t ip_p; /* protocol */
- u_int16_t ip_sum; /* checksum */
+ 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 */
-};
+} __attribute__((packed));
#define IP_MAXPACKET 65535 /* maximum packet size */
* Time stamp option structure.
*/
struct ip_timestamp {
- 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 */
-#ifdef WORDS_BIGENDIAN
+ uint8_t ipt_code; /* IPOPT_TS */
+ uint8_t ipt_len; /* size of structure (variable) */
+ uint8_t ipt_ptr; /* index of current entry */
+#ifdef HOST_WORDS_BIGENDIAN
u_int ipt_oflw:4, /* overflow counter */
ipt_flg:4; /* flags, see below */
#else
n_long ipt_time;
} ipt_ta[1];
} ipt_timestamp;
-};
+} __attribute__((packed));
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
struct mbuf_ptr {
struct mbuf *mptr;
uint32_t dummy;
-};
+} __attribute__((packed));
#else
struct mbuf_ptr {
struct mbuf *mptr;
-};
+} __attribute__((packed));
#endif
struct qlink {
void *next, *prev;
*/
struct ipovly {
struct mbuf_ptr ih_mbuf; /* backpointer to mbuf */
- u_int8_t ih_x1; /* (unused) */
- u_int8_t ih_pr; /* protocol */
- u_int16_t ih_len; /* protocol length */
+ uint8_t ih_x1; /* (unused) */
+ uint8_t ih_pr; /* protocol */
+ uint16_t ih_len; /* protocol length */
struct in_addr ih_src; /* source internet address */
struct in_addr ih_dst; /* destination internet address */
} __attribute__((packed));
struct ipq {
struct qlink frag_link; /* to ip headers of fragments */
struct qlink ip_link; /* to other reass headers */
- u_int8_t ipq_ttl; /* time for reass q to live */
- u_int8_t ipq_p; /* protocol of this fragment */
- u_int16_t ipq_id; /* sequence id for reassembly */
+ uint8_t ipq_ttl; /* time for reass q to live */
+ uint8_t ipq_p; /* protocol of this fragment */
+ uint16_t ipq_id; /* sequence id for reassembly */
struct in_addr ipq_src,ipq_dst;
-};
+} __attribute__((packed));
/*
* Ip header, when holding a fragment.
struct ipasfrag {
struct qlink ipf_link;
struct ip ipf_ip;
-};
+} __attribute__((packed));
#define ipf_off ipf_ip.ip_off
#define ipf_tos ipf_ip.ip_tos
#define ipf_len ipf_ip.ip_len
#define ipf_next ipf_link.next
-#define ipf_prev ipf_link.prev
+#define ipf_prev ipf_link.prev
/*
* Structure stored in mbuf in inpcb.ip_options
struct ipoption {
struct in_addr ipopt_dst; /* first-hop dst if source routed */
int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */
-};
-
-extern struct ipq ipq; /* ip reass. queue */
-extern u_int16_t ip_id; /* ip packet ctr, for ids */
+} __attribute__((packed));
#endif