kernel: fix sanity check
[minix.git] / sys / netinet / ip_var.h
blob8ef9f6ed0acda8ca050ae891262d25cd5f4001ea
1 /* $NetBSD: ip_var.h,v 1.97 2011/05/03 17:44:31 dyoung Exp $ */
3 /*
4 * Copyright (c) 1982, 1986, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
31 * @(#)ip_var.h 8.2 (Berkeley) 1/9/95
34 #ifndef _NETINET_IP_VAR_H_
35 #define _NETINET_IP_VAR_H_
37 #include <sys/queue.h>
38 #include <net/route.h>
41 * Overlay for ip header used by other protocols (tcp, udp).
43 struct ipovly {
44 u_int8_t ih_x1[9]; /* (unused) */
45 u_int8_t ih_pr; /* protocol */
46 u_int16_t ih_len; /* protocol length */
47 struct in_addr ih_src; /* source internet address */
48 struct in_addr ih_dst; /* destination internet address */
49 } __packed;
52 * IP sequence queue structure.
54 * XXX -- The following explains why the ipqe_m field is here, for TCP's use:
55 * We want to avoid doing m_pullup on incoming packets but that
56 * means avoiding dtom on the tcp reassembly code. That in turn means
57 * keeping an mbuf pointer in the reassembly queue (since we might
58 * have a cluster). As a quick hack, the source & destination
59 * port numbers (which are no longer needed once we've located the
60 * tcpcb) are overlayed with an mbuf pointer.
62 TAILQ_HEAD(ipqehead, ipqent);
63 struct ipqent {
64 TAILQ_ENTRY(ipqent) ipqe_q;
65 union {
66 struct ip *_ip;
67 struct tcpiphdr *_tcp;
68 } _ipqe_u1;
69 struct mbuf *ipqe_m; /* point to first mbuf */
70 struct mbuf *ipre_mlast; /* point to last mbuf */
71 u_int8_t ipqe_mff; /* for IP fragmentation */
73 * The following are used in TCP reassembly
75 TAILQ_ENTRY(ipqent) ipqe_timeq;
76 u_int32_t ipqe_seq;
77 u_int32_t ipqe_len;
78 u_int32_t ipqe_flags;
80 #define ipqe_tcp _ipqe_u1._tcp
83 * Structure stored in mbuf in inpcb.ip_options
84 * and passed to ip_output when ip options are in use.
85 * The actual length of the options (including ipopt_dst)
86 * is in m_len.
88 #define MAX_IPOPTLEN 40
90 struct ipoption {
91 struct in_addr ipopt_dst; /* first-hop dst if source routed */
92 int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */
96 * Structure attached to inpcb.ip_moptions and
97 * passed to ip_output when IP multicast options are in use.
99 struct ip_moptions {
100 struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
101 struct in_addr imo_multicast_addr; /* ifindex/addr on MULTICAST_IF */
102 u_int8_t imo_multicast_ttl; /* TTL for outgoing multicasts */
103 u_int8_t imo_multicast_loop; /* 1 => hear sends if a member */
104 u_int16_t imo_num_memberships; /* no. memberships this socket */
105 struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
109 * IP statistics.
110 * Each counter is an unsigned 64-bit value.
112 #define IP_STAT_TOTAL 0 /* total packets received */
113 #define IP_STAT_BADSUM 1 /* checksum bad */
114 #define IP_STAT_TOOSHORT 2 /* packet too short */
115 #define IP_STAT_TOOSMALL 3 /* not enough data */
116 #define IP_STAT_BADHLEN 4 /* ip header length < data size */
117 #define IP_STAT_BADLEN 5 /* ip length < ip header length */
118 #define IP_STAT_FRAGMENTS 6 /* fragments received */
119 #define IP_STAT_FRAGDROPPED 7 /* frags dropped (dups, out of space) */
120 #define IP_STAT_FRAGTIMEOUT 8 /* fragments timed out */
121 #define IP_STAT_FORWARD 9 /* packets forwarded */
122 #define IP_STAT_FASTFORWARD 10 /* packets fast forwarded */
123 #define IP_STAT_CANTFORWARD 11 /* packets rcvd for unreachable dest */
124 #define IP_STAT_REDIRECTSENT 12 /* packets forwareded on same net */
125 #define IP_STAT_NOPROTO 13 /* unknown or unsupported protocol */
126 #define IP_STAT_DELIVERED 14 /* datagrams delivered to upper level */
127 #define IP_STAT_LOCALOUT 15 /* total ip packets generated here */
128 #define IP_STAT_ODROPPED 16 /* lost packets due to nobufs, etc. */
129 #define IP_STAT_REASSEMBLED 17 /* total packets reassembled ok */
130 #define IP_STAT_FRAGMENTED 18 /* datagrams successfully fragmented */
131 #define IP_STAT_OFRAGMENTS 19 /* output fragments created */
132 #define IP_STAT_CANTFRAG 20 /* don't fragment flag was set, etc. */
133 #define IP_STAT_BADOPTIONS 21 /* error in option processing */
134 #define IP_STAT_NOROUTE 22 /* packets discarded due to no route */
135 #define IP_STAT_BADVERS 23 /* ip version != 4 */
136 #define IP_STAT_RAWOUT 24 /* total raw ip packets generated */
137 #define IP_STAT_BADFRAGS 25 /* malformed fragments (bad length) */
138 #define IP_STAT_RCVMEMDROP 26 /* frags dropped for lack of memory */
139 #define IP_STAT_TOOLONG 27 /* ip length > max ip packet size */
140 #define IP_STAT_NOGIF 28 /* no match gif found */
141 #define IP_STAT_BADADDR 29 /* invalid address on header */
143 #define IP_NSTATS 30
145 #ifdef _KERNEL
147 #ifdef _KERNEL_OPT
148 #include "opt_gateway.h"
149 #include "opt_mbuftrace.h"
150 #endif
152 /* flags passed to ip_output as last parameter */
153 #define IP_FORWARDING 0x1 /* most of ip header exists */
154 #define IP_RAWOUTPUT 0x2 /* raw ip header exists */
155 #define IP_RETURNMTU 0x4 /* pass back mtu on EMSGSIZE */
156 #define IP_NOIPNEWID 0x8 /* don't fill in ip_id */
157 #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */
158 #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
159 #define IP_MTUDISC 0x0400 /* Path MTU Discovery; set DF */
161 extern struct domain inetdomain;
163 extern int ip_defttl; /* default IP ttl */
164 extern int ipforwarding; /* ip forwarding */
165 extern int ip_mtudisc; /* mtu discovery */
166 extern int ip_mtudisc_timeout; /* seconds to timeout mtu discovery */
167 extern int anonportmin; /* minimum ephemeral port */
168 extern int anonportmax; /* maximum ephemeral port */
169 extern int lowportmin; /* minimum reserved port */
170 extern int lowportmax; /* maximum reserved port */
171 extern int ip_do_loopback_cksum; /* do IP checksum on loopback? */
172 extern struct rttimer_queue *ip_mtudisc_timeout_q;
173 #ifdef MBUFTRACE
174 extern struct mowner ip_rx_mowner;
175 extern struct mowner ip_tx_mowner;
176 #endif
177 #ifdef GATEWAY
178 extern int ip_maxflows;
179 extern int ip_hashsize;
180 #endif
181 extern struct pool inmulti_pool;
182 struct inpcb;
183 struct sockopt;
185 int ip_ctloutput(int, struct socket *, struct sockopt *);
186 int ip_dooptions(struct mbuf *);
187 void ip_drain(void);
188 void ip_drainstub(void);
189 void ip_forward(struct mbuf *, int);
190 void ip_freemoptions(struct ip_moptions *);
191 int ip_getmoptions(struct ip_moptions *, struct sockopt *);
192 void ip_init(void);
193 int ip_optcopy(struct ip *, struct ip *);
194 u_int ip_optlen(struct inpcb *);
195 int ip_output(struct mbuf *, ...);
196 int ip_fragment(struct mbuf *, struct ifnet *, u_long);
197 int ip_pcbopts(struct mbuf **, const struct sockopt *);
199 void ip_reass_init(void);
200 int ip_reass_packet(struct mbuf **, struct ip *);
201 void ip_reass_slowtimo(void);
202 void ip_reass_drain(void);
204 struct in_ifaddr *
205 ip_rtaddr(struct in_addr);
206 void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *,
207 struct mbuf *);
208 int ip_setmoptions(struct ip_moptions **, const struct sockopt *);
209 void ip_slowtimo(void);
210 void ip_fasttimo(void);
211 struct mbuf *
212 ip_srcroute(void);
213 int ip_sysctl(int *, u_int, void *, size_t *, void *, size_t);
214 void ip_statinc(u_int);
215 void ipintr(void);
216 void * rip_ctlinput(int, const struct sockaddr *, void *);
217 int rip_ctloutput(int, struct socket *, struct sockopt *);
218 void rip_init(void);
219 void rip_input(struct mbuf *, ...);
220 int rip_output(struct mbuf *, ...);
221 int rip_usrreq(struct socket *,
222 int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *);
223 int ipflow_init(int);
224 void ipflow_poolinit(void);
225 void ipflow_prune(void);
226 void ipflow_create(const struct route *, struct mbuf *);
227 void ipflow_slowtimo(void);
228 int ipflow_invalidate_all(int);
230 #endif /* _KERNEL */
232 #endif /* !_NETINET_IP_VAR_H_ */