]> git.proxmox.com Git - qemu.git/blobdiff - slirp/ip.h
slirp: call socket_set_fast_reuse instead of setting SO_REUSEADDR
[qemu.git] / slirp / ip.h
index 3079f90f9b158af62de6844798d4d44fd854c2b8..e2ee5e304cc520b795fc8195b0c029a13a6f5aee 100644 (file)
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
 #ifndef _IP_H_
 #define _IP_H_
 
-#ifdef WORDS_BIGENDIAN
-# ifndef NTOHL
-#  define NTOHL(d)
-# endif
-# ifndef NTOHS
-#  define NTOHS(d)
-# endif
-# ifndef HTONL
-#  define HTONL(d)
-# endif
-# ifndef HTONS
-#  define HTONS(d)
-# endif
+#ifdef HOST_WORDS_BIGENDIAN
+# undef NTOHL
+# undef NTOHS
+# undef HTONL
+# undef HTONS
+# define NTOHL(d)
+# define NTOHS(d)
+# define HTONL(d)
+# define HTONS(d)
 #else
 # ifndef NTOHL
 #  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.
@@ -77,25 +69,25 @@ typedef u_int32_t n_long;                 /* long as received from the net */
  * Structure of an internet header, naked of options.
  */
 struct ip {
-#ifdef WORDS_BIGENDIAN
-       u_int ip_v:4,                   /* version */
+#ifdef HOST_WORDS_BIGENDIAN
+       uint8_t ip_v:4,                 /* version */
                ip_hl:4;                /* header length */
 #else
-       u_int ip_hl:4,          /* header length */
+       uint8_t 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 */
-};
+} QEMU_PACKED;
 
 #define        IP_MAXPACKET    65535           /* maximum packet size */
 
@@ -140,14 +132,14 @@ struct ip {
  * 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
-       u_int   ipt_oflw:4,             /* overflow counter */
+       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
+       uint8_t ipt_oflw:4,             /* overflow counter */
                ipt_flg:4;              /* flags, see below */
 #else
-       u_int   ipt_flg:4,              /* flags, see below */
+       uint8_t ipt_flg:4,              /* flags, see below */
                ipt_oflw:4;             /* overflow counter */
 #endif
        union ipt_timestamp {
@@ -157,7 +149,7 @@ struct      ip_timestamp {
                        n_long ipt_time;
                } ipt_ta[1];
        } ipt_timestamp;
-};
+} QEMU_PACKED;
 
 /* flag bits for ipt_flg */
 #define        IPOPT_TS_TSONLY         0               /* timestamps only */
@@ -187,11 +179,11 @@ struct    ip_timestamp {
 struct mbuf_ptr {
        struct mbuf *mptr;
        uint32_t dummy;
-};
+} QEMU_PACKED;
 #else
 struct mbuf_ptr {
        struct mbuf *mptr;
-};
+} QEMU_PACKED;
 #endif
 struct qlink {
        void *next, *prev;
@@ -202,12 +194,12 @@ struct qlink {
  */
 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));
+} QEMU_PACKED;
 
 /*
  * Ip reassembly queue structure.  Each fragment
@@ -219,11 +211,11 @@ struct ipovly {
 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;
-};
+} QEMU_PACKED;
 
 /*
  * Ip header, when holding a fragment.
@@ -233,13 +225,13 @@ struct ipq {
 struct ipasfrag {
        struct qlink ipf_link;
        struct ip ipf_ip;
-};
+} QEMU_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
@@ -252,46 +244,6 @@ struct     ipasfrag {
 struct ipoption {
        struct  in_addr ipopt_dst;      /* first-hop dst if source routed */
        int8_t  ipopt_list[MAX_IPOPTLEN];       /* options proper */
-};
-
-#ifdef LOG_ENABLED
-/*
- * Structure attached to inpcb.ip_moptions and
- * passed to ip_output when IP multicast options are in use.
- */
-
-struct ipstat {
-       u_long  ips_total;              /* total packets received */
-       u_long  ips_badsum;             /* checksum bad */
-       u_long  ips_tooshort;           /* packet too short */
-       u_long  ips_toosmall;           /* not enough data */
-       u_long  ips_badhlen;            /* ip header length < data size */
-       u_long  ips_badlen;             /* ip length < ip header length */
-       u_long  ips_fragments;          /* fragments received */
-       u_long  ips_fragdropped;        /* frags dropped (dups, out of space) */
-       u_long  ips_fragtimeout;        /* fragments timed out */
-       u_long  ips_forward;            /* packets forwarded */
-       u_long  ips_cantforward;        /* packets rcvd for unreachable dest */
-       u_long  ips_redirectsent;       /* packets forwarded on same net */
-       u_long  ips_noproto;            /* unknown or unsupported protocol */
-       u_long  ips_delivered;          /* datagrams delivered to upper level*/
-       u_long  ips_localout;           /* total ip packets generated here */
-       u_long  ips_odropped;           /* lost packets due to nobufs, etc. */
-       u_long  ips_reassembled;        /* total packets reassembled ok */
-       u_long  ips_fragmented;         /* datagrams successfully fragmented */
-       u_long  ips_ofragments;         /* output fragments created */
-       u_long  ips_cantfrag;           /* don't fragment flag was set, etc. */
-       u_long  ips_badoptions;         /* error in option processing */
-       u_long  ips_noroute;            /* packets discarded due to no route */
-       u_long  ips_badvers;            /* ip version != 4 */
-       u_long  ips_rawout;             /* total raw ip packets generated */
-       u_long  ips_unaligned;          /* times the ip packet was not aligned */
-};
-
-extern struct  ipstat  ipstat;
-#endif
-
-extern struct  ipq     ipq;                    /* ip reass. queue */
-extern u_int16_t       ip_id;                          /* ip packet ctr, for ids */
+} QEMU_PACKED;
 
 #endif