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