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