xref: /haiku/headers/posix/netinet/ip_var.h (revision 6996e5b271b2ac592db6b7da2bdc25057b174af0)
152a38012Sejakowatz /*
252a38012Sejakowatz  * Copyright (c) 1982, 1986, 1993
352a38012Sejakowatz  *      The Regents of the University of California.  All rights reserved.
452a38012Sejakowatz  *
552a38012Sejakowatz  * Redistribution and use in source and binary forms, with or without
652a38012Sejakowatz  * modification, are permitted provided that the following conditions
752a38012Sejakowatz  * are met:
852a38012Sejakowatz  * 1. Redistributions of source code must retain the above copyright
952a38012Sejakowatz  *    notice, this list of conditions and the following disclaimer.
1052a38012Sejakowatz  * 2. Redistributions in binary form must reproduce the above copyright
1152a38012Sejakowatz  *    notice, this list of conditions and the following disclaimer in the
1252a38012Sejakowatz  *    documentation and/or other materials provided with the distribution.
13*6996e5b2SAugustin Cavalier  * 3. Neither the name of the University nor the names of its contributors
1452a38012Sejakowatz  *    may be used to endorse or promote products derived from this software
1552a38012Sejakowatz  *    without specific prior written permission.
1652a38012Sejakowatz  *
1752a38012Sejakowatz  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1852a38012Sejakowatz  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1952a38012Sejakowatz  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2052a38012Sejakowatz  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2152a38012Sejakowatz  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2252a38012Sejakowatz  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2352a38012Sejakowatz  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2452a38012Sejakowatz  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2552a38012Sejakowatz  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2652a38012Sejakowatz  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2752a38012Sejakowatz  * SUCH DAMAGE.
2852a38012Sejakowatz  */
2952a38012Sejakowatz 
3052a38012Sejakowatz #ifndef NETINET_IP_VAR_H
3152a38012Sejakowatz #define NETINET_IP_VAR_H
3252a38012Sejakowatz 
33f8009f7bSAxel Dörfler #include <netinet/in.h>
344fc67516SDavid Reid #include <sys/socket.h>
3552a38012Sejakowatz 
3652a38012Sejakowatz /*
3752a38012Sejakowatz  * Overlay for ip header used by other protocols (tcp, udp).
3852a38012Sejakowatz  */
3952a38012Sejakowatz struct ipovly {
404fc67516SDavid Reid 	char *   ih_next;
414fc67516SDavid Reid 	char *   ih_prev;
4262b4effaSIthamar R. Adema 	uint8_t   ih_x1;        /* (unused) */
4362b4effaSIthamar R. Adema 	uint8_t   ih_pr;           /* protocol */
4462b4effaSIthamar R. Adema 	uint16_t  ih_len;          /* protocol length */
4552a38012Sejakowatz 	struct    in_addr ih_src;  /* source internet address */
4652a38012Sejakowatz 	struct    in_addr ih_dst;  /* destination internet address */
4752a38012Sejakowatz };
4852a38012Sejakowatz 
4952a38012Sejakowatz /*
5052a38012Sejakowatz  * Structure stored in mbuf in inpcb.ip_options
5152a38012Sejakowatz  * and passed to ip_output when ip options are in use.
5252a38012Sejakowatz  * The actual length of the options (including ipopt_dst)
5352a38012Sejakowatz  * is in m_len.
5452a38012Sejakowatz  */
5552a38012Sejakowatz #define MAX_IPOPTLEN    40
5652a38012Sejakowatz 
5752a38012Sejakowatz struct ipoption {
5852a38012Sejakowatz 	struct  in_addr ipopt_dst;         /* first-hop dst if source routed */
5962b4effaSIthamar R. Adema 	int8_t  ipopt_list[MAX_IPOPTLEN];  /* options proper */
6052a38012Sejakowatz };
6152a38012Sejakowatz 
6252a38012Sejakowatz /*
6352a38012Sejakowatz  * Structure attached to inpcb.ip_moptions and
6452a38012Sejakowatz  * passed to ip_output when IP multicast options are in use.
6552a38012Sejakowatz  */
6652a38012Sejakowatz struct ip_moptions {
6752a38012Sejakowatz 	struct    ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
6862b4effaSIthamar R. Adema 	uint8_t  imo_multicast_ttl;           /* TTL for outgoing multicasts */
6962b4effaSIthamar R. Adema 	uint8_t  imo_multicast_loop;          /* 1 => here sends if a member */
7062b4effaSIthamar R. Adema 	uint16_t imo_num_memberships;         /* no. memberships this socket */
7152a38012Sejakowatz 	struct    in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
7252a38012Sejakowatz };
7352a38012Sejakowatz 
7452a38012Sejakowatz struct ipasfrag {
7552a38012Sejakowatz #if B_HOST_IS_BENDIAN
7662b4effaSIthamar R. Adema 	uint8_t  ip_v:4;
7762b4effaSIthamar R. Adema 	uint8_t  ip_hl:4;
7852a38012Sejakowatz #else
7962b4effaSIthamar R. Adema 	uint8_t  ip_hl:4;
8062b4effaSIthamar R. Adema 	uint8_t  ip_v:4;
8152a38012Sejakowatz #endif
8262b4effaSIthamar R. Adema 	uint8_t  ipf_mff;
8362b4effaSIthamar R. Adema 	int16_t  ip_len;
8462b4effaSIthamar R. Adema 	uint16_t ip_id;
8562b4effaSIthamar R. Adema 	int16_t  ip_off;
8662b4effaSIthamar R. Adema 	uint8_t  ip_ttl;
8762b4effaSIthamar R. Adema 	uint8_t  ip_p;
8852a38012Sejakowatz 	struct ipasfrag *ipf_next;
8952a38012Sejakowatz 	struct ipasfrag *ipf_prev;
9052a38012Sejakowatz };
9152a38012Sejakowatz 
9252a38012Sejakowatz struct ipq {
9352a38012Sejakowatz 	struct ipq *next, *prev;
9462b4effaSIthamar R. Adema 	uint8_t  ipq_ttl;
9562b4effaSIthamar R. Adema 	uint8_t  ipq_p;
9662b4effaSIthamar R. Adema 	uint16_t ipq_id;
9752a38012Sejakowatz 	struct ipasfrag *ipq_next, *ipq_prev;
9852a38012Sejakowatz 	struct in_addr ipq_src, ipq_dst;
9952a38012Sejakowatz };
10052a38012Sejakowatz 
10152a38012Sejakowatz struct  ipstat {
10262b4effaSIthamar R. Adema 	int32_t  ips_total;              /* total packets received */
10362b4effaSIthamar R. Adema 	int32_t  ips_badsum;             /* checksum bad */
10462b4effaSIthamar R. Adema 	int32_t  ips_tooshort;           /* packet too short */
10562b4effaSIthamar R. Adema 	int32_t  ips_toosmall;           /* not enough data */
10662b4effaSIthamar R. Adema 	int32_t  ips_badhlen;            /* ip header length < data size */
10762b4effaSIthamar R. Adema 	int32_t  ips_badlen;             /* ip length < ip header length */
10862b4effaSIthamar R. Adema 	int32_t  ips_fragments;          /* fragments received */
10962b4effaSIthamar R. Adema 	int32_t  ips_fragdropped;        /* frags dropped (dups, out of space) */
11062b4effaSIthamar R. Adema 	int32_t  ips_fragtimeout;        /* fragments timed out */
11162b4effaSIthamar R. Adema 	int32_t  ips_forward;            /* packets forwarded */
11262b4effaSIthamar R. Adema 	int32_t  ips_cantforward;        /* packets rcvd for unreachable dest */
11362b4effaSIthamar R. Adema 	int32_t  ips_redirectsent;       /* packets forwarded on same net */
11462b4effaSIthamar R. Adema 	int32_t  ips_noproto;            /* unknown or unsupported protocol */
11562b4effaSIthamar R. Adema 	int32_t  ips_delivered;          /* datagrams delivered to upper level*/
11662b4effaSIthamar R. Adema 	int32_t  ips_localout;           /* total ip packets generated here */
11762b4effaSIthamar R. Adema 	int32_t  ips_odropped;           /* lost packets due to nobufs, etc. */
11862b4effaSIthamar R. Adema 	int32_t  ips_reassembled;        /* total packets reassembled ok */
11962b4effaSIthamar R. Adema 	int32_t  ips_fragmented;         /* datagrams sucessfully fragmented */
12062b4effaSIthamar R. Adema 	int32_t  ips_ofragments;         /* output fragments created */
12162b4effaSIthamar R. Adema 	int32_t  ips_cantfrag;           /* don't fragment flag was set, etc. */
12262b4effaSIthamar R. Adema 	int32_t  ips_badoptions;         /* error in option processing */
12362b4effaSIthamar R. Adema 	int32_t  ips_noroute;            /* packets discarded due to no route */
12462b4effaSIthamar R. Adema 	int32_t  ips_badvers;            /* ip version != 4 */
12562b4effaSIthamar R. Adema 	int32_t  ips_rawout;             /* total raw ip packets generated */
12662b4effaSIthamar R. Adema 	int32_t  ips_badfrags;           /* malformed fragments (bad length) */
12762b4effaSIthamar R. Adema 	int32_t  ips_rcvmemdrop;         /* frags dropped for lack of memory */
12862b4effaSIthamar R. Adema 	int32_t  ips_toolong;            /* ip length > max ip packet size */
12962b4effaSIthamar R. Adema 	int32_t  ips_nogif;              /* no match gif found */
13062b4effaSIthamar R. Adema 	int32_t  ips_badaddr;            /* invalid address on header */
13162b4effaSIthamar R. Adema 	int32_t  ips_inhwcsum;           /* hardware checksummed on input */
13262b4effaSIthamar R. Adema 	int32_t  ips_outhwcsum;          /* hardware checksummed on output */
13352a38012Sejakowatz };
13452a38012Sejakowatz 
13552a38012Sejakowatz #endif /* NETINET_IP_VAR_H */
136