xref: /haiku/headers/posix/netinet/ip_var.h (revision a127b88ecbfab58f64944c98aa47722a18e363b2)
1 /*
2  * Copyright (c) 1982, 1986, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #ifndef NETINET_IP_VAR_H
31 #define NETINET_IP_VAR_H
32 
33 #include <netinet/in.h>
34 #include <sys/socket.h>
35 
36 /*
37  * Overlay for ip header used by other protocols (tcp, udp).
38  */
39 struct ipovly {
40 	char *   ih_next;
41 	char *   ih_prev;
42 	uint8_t   ih_x1;        /* (unused) */
43 	uint8_t   ih_pr;           /* protocol */
44 	uint16_t  ih_len;          /* protocol length */
45 	struct    in_addr ih_src;  /* source internet address */
46 	struct    in_addr ih_dst;  /* destination internet address */
47 };
48 
49 /*
50  * Structure stored in mbuf in inpcb.ip_options
51  * and passed to ip_output when ip options are in use.
52  * The actual length of the options (including ipopt_dst)
53  * is in m_len.
54  */
55 #define MAX_IPOPTLEN    40
56 
57 struct ipoption {
58 	struct  in_addr ipopt_dst;         /* first-hop dst if source routed */
59 	int8_t  ipopt_list[MAX_IPOPTLEN];  /* options proper */
60 };
61 
62 /*
63  * Structure attached to inpcb.ip_moptions and
64  * passed to ip_output when IP multicast options are in use.
65  */
66 struct ip_moptions {
67 	struct    ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
68 	uint8_t  imo_multicast_ttl;           /* TTL for outgoing multicasts */
69 	uint8_t  imo_multicast_loop;          /* 1 => here sends if a member */
70 	uint16_t imo_num_memberships;         /* no. memberships this socket */
71 	struct    in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
72 };
73 
74 struct ipasfrag {
75 #if B_HOST_IS_BENDIAN
76 	uint8_t  ip_v:4;
77 	uint8_t  ip_hl:4;
78 #else
79 	uint8_t  ip_hl:4;
80 	uint8_t  ip_v:4;
81 #endif
82 	uint8_t  ipf_mff;
83 	int16_t  ip_len;
84 	uint16_t ip_id;
85 	int16_t  ip_off;
86 	uint8_t  ip_ttl;
87 	uint8_t  ip_p;
88 	struct ipasfrag *ipf_next;
89 	struct ipasfrag *ipf_prev;
90 };
91 
92 struct ipq {
93 	struct ipq *next, *prev;
94 	uint8_t  ipq_ttl;
95 	uint8_t  ipq_p;
96 	uint16_t ipq_id;
97 	struct ipasfrag *ipq_next, *ipq_prev;
98 	struct in_addr ipq_src, ipq_dst;
99 };
100 
101 struct  ipstat {
102 	int32_t  ips_total;              /* total packets received */
103 	int32_t  ips_badsum;             /* checksum bad */
104 	int32_t  ips_tooshort;           /* packet too short */
105 	int32_t  ips_toosmall;           /* not enough data */
106 	int32_t  ips_badhlen;            /* ip header length < data size */
107 	int32_t  ips_badlen;             /* ip length < ip header length */
108 	int32_t  ips_fragments;          /* fragments received */
109 	int32_t  ips_fragdropped;        /* frags dropped (dups, out of space) */
110 	int32_t  ips_fragtimeout;        /* fragments timed out */
111 	int32_t  ips_forward;            /* packets forwarded */
112 	int32_t  ips_cantforward;        /* packets rcvd for unreachable dest */
113 	int32_t  ips_redirectsent;       /* packets forwarded on same net */
114 	int32_t  ips_noproto;            /* unknown or unsupported protocol */
115 	int32_t  ips_delivered;          /* datagrams delivered to upper level*/
116 	int32_t  ips_localout;           /* total ip packets generated here */
117 	int32_t  ips_odropped;           /* lost packets due to nobufs, etc. */
118 	int32_t  ips_reassembled;        /* total packets reassembled ok */
119 	int32_t  ips_fragmented;         /* datagrams sucessfully fragmented */
120 	int32_t  ips_ofragments;         /* output fragments created */
121 	int32_t  ips_cantfrag;           /* don't fragment flag was set, etc. */
122 	int32_t  ips_badoptions;         /* error in option processing */
123 	int32_t  ips_noroute;            /* packets discarded due to no route */
124 	int32_t  ips_badvers;            /* ip version != 4 */
125 	int32_t  ips_rawout;             /* total raw ip packets generated */
126 	int32_t  ips_badfrags;           /* malformed fragments (bad length) */
127 	int32_t  ips_rcvmemdrop;         /* frags dropped for lack of memory */
128 	int32_t  ips_toolong;            /* ip length > max ip packet size */
129 	int32_t  ips_nogif;              /* no match gif found */
130 	int32_t  ips_badaddr;            /* invalid address on header */
131 	int32_t  ips_inhwcsum;           /* hardware checksummed on input */
132 	int32_t  ips_outhwcsum;          /* hardware checksummed on output */
133 };
134 
135 #endif /* NETINET_IP_VAR_H */
136