xref: /haiku/headers/posix/netinet/ip_var.h (revision f8009f7ba41e29bc03350e8e54374b3e47b0ae17)
152a38012Sejakowatz /* Parts of this file are covered under the following copyright */
252a38012Sejakowatz /*
352a38012Sejakowatz  * Copyright (c) 1982, 1986, 1993
452a38012Sejakowatz  *      The Regents of the University of California.  All rights reserved.
552a38012Sejakowatz  *
652a38012Sejakowatz  * Redistribution and use in source and binary forms, with or without
752a38012Sejakowatz  * modification, are permitted provided that the following conditions
852a38012Sejakowatz  * are met:
952a38012Sejakowatz  * 1. Redistributions of source code must retain the above copyright
1052a38012Sejakowatz  *    notice, this list of conditions and the following disclaimer.
1152a38012Sejakowatz  * 2. Redistributions in binary form must reproduce the above copyright
1252a38012Sejakowatz  *    notice, this list of conditions and the following disclaimer in the
1352a38012Sejakowatz  *    documentation and/or other materials provided with the distribution.
1452a38012Sejakowatz  * 3. All advertising materials mentioning features or use of this software
1552a38012Sejakowatz  *    must display the following acknowledgement:
1652a38012Sejakowatz  *      This product includes software developed by the University of
1752a38012Sejakowatz  *      California, Berkeley and its contributors.
1852a38012Sejakowatz  * 4. Neither the name of the University nor the names of its contributors
1952a38012Sejakowatz  *    may be used to endorse or promote products derived from this software
2052a38012Sejakowatz  *    without specific prior written permission.
2152a38012Sejakowatz  *
2252a38012Sejakowatz  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2352a38012Sejakowatz  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2452a38012Sejakowatz  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2552a38012Sejakowatz  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2652a38012Sejakowatz  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2752a38012Sejakowatz  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2852a38012Sejakowatz  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2952a38012Sejakowatz  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3052a38012Sejakowatz  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3152a38012Sejakowatz  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3252a38012Sejakowatz  * SUCH DAMAGE.
3352a38012Sejakowatz  *
3452a38012Sejakowatz  *      @(#)ip_var.h    8.1 (Berkeley) 6/10/93
3552a38012Sejakowatz  */
3652a38012Sejakowatz 
3752a38012Sejakowatz #ifndef NETINET_IP_VAR_H
3852a38012Sejakowatz #define NETINET_IP_VAR_H
3952a38012Sejakowatz 
40*f8009f7bSAxel Dörfler #include <netinet/in.h>
414fc67516SDavid Reid #include <sys/socket.h>
4252a38012Sejakowatz 
4352a38012Sejakowatz /*
4452a38012Sejakowatz  * Overlay for ip header used by other protocols (tcp, udp).
4552a38012Sejakowatz  */
4652a38012Sejakowatz struct ipovly {
474fc67516SDavid Reid 	char *   ih_next;
484fc67516SDavid Reid 	char *   ih_prev;
4962b4effaSIthamar R. Adema 	uint8_t   ih_x1;        /* (unused) */
5062b4effaSIthamar R. Adema 	uint8_t   ih_pr;           /* protocol */
5162b4effaSIthamar R. Adema 	uint16_t  ih_len;          /* protocol length */
5252a38012Sejakowatz 	struct    in_addr ih_src;  /* source internet address */
5352a38012Sejakowatz 	struct    in_addr ih_dst;  /* destination internet address */
5452a38012Sejakowatz };
5552a38012Sejakowatz 
5652a38012Sejakowatz /*
5752a38012Sejakowatz  * Structure stored in mbuf in inpcb.ip_options
5852a38012Sejakowatz  * and passed to ip_output when ip options are in use.
5952a38012Sejakowatz  * The actual length of the options (including ipopt_dst)
6052a38012Sejakowatz  * is in m_len.
6152a38012Sejakowatz  */
6252a38012Sejakowatz #define MAX_IPOPTLEN    40
6352a38012Sejakowatz 
6452a38012Sejakowatz struct ipoption {
6552a38012Sejakowatz 	struct  in_addr ipopt_dst;         /* first-hop dst if source routed */
6662b4effaSIthamar R. Adema 	int8_t  ipopt_list[MAX_IPOPTLEN];  /* options proper */
6752a38012Sejakowatz };
6852a38012Sejakowatz 
6952a38012Sejakowatz /*
7052a38012Sejakowatz  * Structure attached to inpcb.ip_moptions and
7152a38012Sejakowatz  * passed to ip_output when IP multicast options are in use.
7252a38012Sejakowatz  */
7352a38012Sejakowatz struct ip_moptions {
7452a38012Sejakowatz 	struct    ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
7562b4effaSIthamar R. Adema 	uint8_t  imo_multicast_ttl;           /* TTL for outgoing multicasts */
7662b4effaSIthamar R. Adema 	uint8_t  imo_multicast_loop;          /* 1 => here sends if a member */
7762b4effaSIthamar R. Adema 	uint16_t imo_num_memberships;         /* no. memberships this socket */
7852a38012Sejakowatz 	struct    in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
7952a38012Sejakowatz };
8052a38012Sejakowatz 
8152a38012Sejakowatz struct ipasfrag {
8252a38012Sejakowatz #if B_HOST_IS_BENDIAN
8362b4effaSIthamar R. Adema 	uint8_t  ip_v:4;
8462b4effaSIthamar R. Adema 	uint8_t  ip_hl:4;
8552a38012Sejakowatz #else
8662b4effaSIthamar R. Adema 	uint8_t  ip_hl:4;
8762b4effaSIthamar R. Adema 	uint8_t  ip_v:4;
8852a38012Sejakowatz #endif
8962b4effaSIthamar R. Adema 	uint8_t  ipf_mff;
9062b4effaSIthamar R. Adema 	int16_t  ip_len;
9162b4effaSIthamar R. Adema 	uint16_t ip_id;
9262b4effaSIthamar R. Adema 	int16_t  ip_off;
9362b4effaSIthamar R. Adema 	uint8_t  ip_ttl;
9462b4effaSIthamar R. Adema 	uint8_t  ip_p;
9552a38012Sejakowatz 	struct ipasfrag *ipf_next;
9652a38012Sejakowatz 	struct ipasfrag *ipf_prev;
9752a38012Sejakowatz };
9852a38012Sejakowatz 
9952a38012Sejakowatz struct ipq {
10052a38012Sejakowatz 	struct ipq *next, *prev;
10162b4effaSIthamar R. Adema 	uint8_t  ipq_ttl;
10262b4effaSIthamar R. Adema 	uint8_t  ipq_p;
10362b4effaSIthamar R. Adema 	uint16_t ipq_id;
10452a38012Sejakowatz 	struct ipasfrag *ipq_next, *ipq_prev;
10552a38012Sejakowatz 	struct in_addr ipq_src, ipq_dst;
10652a38012Sejakowatz };
10752a38012Sejakowatz 
10852a38012Sejakowatz struct  ipstat {
10962b4effaSIthamar R. Adema         int32_t  ips_total;              /* total packets received */
11062b4effaSIthamar R. Adema         int32_t  ips_badsum;             /* checksum bad */
11162b4effaSIthamar R. Adema         int32_t  ips_tooshort;           /* packet too short */
11262b4effaSIthamar R. Adema         int32_t  ips_toosmall;           /* not enough data */
11362b4effaSIthamar R. Adema         int32_t  ips_badhlen;            /* ip header length < data size */
11462b4effaSIthamar R. Adema         int32_t  ips_badlen;             /* ip length < ip header length */
11562b4effaSIthamar R. Adema         int32_t  ips_fragments;          /* fragments received */
11662b4effaSIthamar R. Adema         int32_t  ips_fragdropped;        /* frags dropped (dups, out of space) */
11762b4effaSIthamar R. Adema         int32_t  ips_fragtimeout;        /* fragments timed out */
11862b4effaSIthamar R. Adema         int32_t  ips_forward;            /* packets forwarded */
11962b4effaSIthamar R. Adema         int32_t  ips_cantforward;        /* packets rcvd for unreachable dest */
12062b4effaSIthamar R. Adema         int32_t  ips_redirectsent;       /* packets forwarded on same net */
12162b4effaSIthamar R. Adema         int32_t  ips_noproto;            /* unknown or unsupported protocol */
12262b4effaSIthamar R. Adema         int32_t  ips_delivered;          /* datagrams delivered to upper level*/
12362b4effaSIthamar R. Adema         int32_t  ips_localout;           /* total ip packets generated here */
12462b4effaSIthamar R. Adema         int32_t  ips_odropped;           /* lost packets due to nobufs, etc. */
12562b4effaSIthamar R. Adema         int32_t  ips_reassembled;        /* total packets reassembled ok */
12662b4effaSIthamar R. Adema         int32_t  ips_fragmented;         /* datagrams sucessfully fragmented */
12762b4effaSIthamar R. Adema         int32_t  ips_ofragments;         /* output fragments created */
12862b4effaSIthamar R. Adema         int32_t  ips_cantfrag;           /* don't fragment flag was set, etc. */
12962b4effaSIthamar R. Adema         int32_t  ips_badoptions;         /* error in option processing */
13062b4effaSIthamar R. Adema         int32_t  ips_noroute;            /* packets discarded due to no route */
13162b4effaSIthamar R. Adema         int32_t  ips_badvers;            /* ip version != 4 */
13262b4effaSIthamar R. Adema         int32_t  ips_rawout;             /* total raw ip packets generated */
13362b4effaSIthamar R. Adema         int32_t  ips_badfrags;           /* malformed fragments (bad length) */
13462b4effaSIthamar R. Adema         int32_t  ips_rcvmemdrop;         /* frags dropped for lack of memory */
13562b4effaSIthamar R. Adema         int32_t  ips_toolong;            /* ip length > max ip packet size */
13662b4effaSIthamar R. Adema         int32_t  ips_nogif;              /* no match gif found */
13762b4effaSIthamar R. Adema         int32_t  ips_badaddr;            /* invalid address on header */
13862b4effaSIthamar R. Adema         int32_t  ips_inhwcsum;           /* hardware checksummed on input */
13962b4effaSIthamar R. Adema         int32_t  ips_outhwcsum;          /* hardware checksummed on output */
14052a38012Sejakowatz };
14152a38012Sejakowatz 
142b9320128SIngo Weinhold /* #ifdef _KERNEL_MODE */
14352a38012Sejakowatz 
14452a38012Sejakowatz #define IP_FORWARDING			0x1				/* most of ip header exists */
14552a38012Sejakowatz #define IP_ALLOWBROADCAST		SO_BROADCAST	/* can send broadcast packets */
146f1730f62SWaldemar Kornewald #define IP_RAWOUTPUT			0x4				/* raw ip header exists */
147f1730f62SWaldemar Kornewald #define IP_ROUTETOIF			SO_DONTROUTE	/* bypass routing tables */
148f1730f62SWaldemar Kornewald #define IP_MTUDISC				0x10			/* pmtu discovery, set DF */
14952a38012Sejakowatz 
15042415555Sbeveloper #if 0
151b9320128SIngo Weinhold /* struct ipstat ipstat; */
15252a38012Sejakowatz 
1534fc67516SDavid Reid void  ipv4_input(struct mbuf *, int);
1544fc67516SDavid Reid int   ipv4_output(struct mbuf *, struct mbuf *, struct route *, int, void *);
1554fc67516SDavid Reid int   ipv4_ctloutput(int, struct socket *, int, int, struct mbuf **);
15652a38012Sejakowatz 
1574fc67516SDavid Reid int   ip_dooptions(struct mbuf *);
1584fc67516SDavid Reid void  ip_stripoptions (struct mbuf *, struct mbuf *);
1594fc67516SDavid Reid struct mbuf *ip_srcroute(void);
1604fc67516SDavid Reid 
1614fc67516SDavid Reid 
1624fc67516SDavid Reid #endif /* _KERNEL_MODE */
16352a38012Sejakowatz 
16452a38012Sejakowatz #endif /* NETINET_IP_VAR_H */
165