xref: /haiku/headers/posix/netinet/ip_var.h (revision 42415555d395fa902b738d6f16313f2097622750)
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 
404fc67516SDavid Reid #include <sys/socket.h>
4152a38012Sejakowatz 
4252a38012Sejakowatz /*
4352a38012Sejakowatz  * Overlay for ip header used by other protocols (tcp, udp).
4452a38012Sejakowatz  */
4552a38012Sejakowatz struct ipovly {
464fc67516SDavid Reid 	char *   ih_next;
474fc67516SDavid Reid 	char *   ih_prev;
4852a38012Sejakowatz 	uint8     ih_x1;        /* (unused) */
4952a38012Sejakowatz 	uint8     ih_pr;           /* protocol */
5052a38012Sejakowatz 	uint16    ih_len;          /* protocol length */
5152a38012Sejakowatz 	struct    in_addr ih_src;  /* source internet address */
5252a38012Sejakowatz 	struct    in_addr ih_dst;  /* destination internet address */
5352a38012Sejakowatz };
5452a38012Sejakowatz 
5552a38012Sejakowatz /*
5652a38012Sejakowatz  * Structure stored in mbuf in inpcb.ip_options
5752a38012Sejakowatz  * and passed to ip_output when ip options are in use.
5852a38012Sejakowatz  * The actual length of the options (including ipopt_dst)
5952a38012Sejakowatz  * is in m_len.
6052a38012Sejakowatz  */
6152a38012Sejakowatz #define MAX_IPOPTLEN    40
6252a38012Sejakowatz 
6352a38012Sejakowatz struct ipoption {
6452a38012Sejakowatz 	struct  in_addr ipopt_dst;         /* first-hop dst if source routed */
6552a38012Sejakowatz 	int8    ipopt_list[MAX_IPOPTLEN];  /* options proper */
6652a38012Sejakowatz };
6752a38012Sejakowatz 
6852a38012Sejakowatz /*
6952a38012Sejakowatz  * Structure attached to inpcb.ip_moptions and
7052a38012Sejakowatz  * passed to ip_output when IP multicast options are in use.
7152a38012Sejakowatz  */
7252a38012Sejakowatz struct ip_moptions {
7352a38012Sejakowatz 	struct    ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
7452a38012Sejakowatz 	uint8  imo_multicast_ttl;           /* TTL for outgoing multicasts */
7552a38012Sejakowatz 	uint8  imo_multicast_loop;          /* 1 => here sends if a member */
7652a38012Sejakowatz 	uint16 imo_num_memberships;         /* no. memberships this socket */
7752a38012Sejakowatz 	struct    in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
7852a38012Sejakowatz };
7952a38012Sejakowatz 
8052a38012Sejakowatz struct ipasfrag {
8152a38012Sejakowatz #if B_HOST_IS_BENDIAN
8252a38012Sejakowatz 	uint8  ip_v:4;
8352a38012Sejakowatz 	uint8  ip_hl:4;
8452a38012Sejakowatz #else
8552a38012Sejakowatz 	uint8  ip_hl:4;
8652a38012Sejakowatz 	uint8  ip_v:4;
8752a38012Sejakowatz #endif
8852a38012Sejakowatz 	uint8  ipf_mff;
8952a38012Sejakowatz 	int16  ip_len;
9052a38012Sejakowatz 	uint16 ip_id;
9152a38012Sejakowatz 	int16  ip_off;
9252a38012Sejakowatz 	uint8  ip_ttl;
9352a38012Sejakowatz 	uint8  ip_p;
9452a38012Sejakowatz 	struct ipasfrag *ipf_next;
9552a38012Sejakowatz 	struct ipasfrag *ipf_prev;
9652a38012Sejakowatz };
9752a38012Sejakowatz 
9852a38012Sejakowatz struct ipq {
9952a38012Sejakowatz 	struct ipq *next, *prev;
10052a38012Sejakowatz 	uint8  ipq_ttl;
10152a38012Sejakowatz 	uint8  ipq_p;
10252a38012Sejakowatz 	uint16 ipq_id;
10352a38012Sejakowatz 	struct ipasfrag *ipq_next, *ipq_prev;
10452a38012Sejakowatz 	struct in_addr ipq_src, ipq_dst;
10552a38012Sejakowatz };
10652a38012Sejakowatz 
10752a38012Sejakowatz struct  ipstat {
10852a38012Sejakowatz         int32  ips_total;              /* total packets received */
10952a38012Sejakowatz         int32  ips_badsum;             /* checksum bad */
11052a38012Sejakowatz         int32  ips_tooshort;           /* packet too short */
11152a38012Sejakowatz         int32  ips_toosmall;           /* not enough data */
11252a38012Sejakowatz         int32  ips_badhlen;            /* ip header length < data size */
11352a38012Sejakowatz         int32  ips_badlen;             /* ip length < ip header length */
11452a38012Sejakowatz         int32  ips_fragments;          /* fragments received */
11552a38012Sejakowatz         int32  ips_fragdropped;        /* frags dropped (dups, out of space) */
11652a38012Sejakowatz         int32  ips_fragtimeout;        /* fragments timed out */
11752a38012Sejakowatz         int32  ips_forward;            /* packets forwarded */
11852a38012Sejakowatz         int32  ips_cantforward;        /* packets rcvd for unreachable dest */
11952a38012Sejakowatz         int32  ips_redirectsent;       /* packets forwarded on same net */
12052a38012Sejakowatz         int32  ips_noproto;            /* unknown or unsupported protocol */
12152a38012Sejakowatz         int32  ips_delivered;          /* datagrams delivered to upper level*/
12252a38012Sejakowatz         int32  ips_localout;           /* total ip packets generated here */
12352a38012Sejakowatz         int32  ips_odropped;           /* lost packets due to nobufs, etc. */
12452a38012Sejakowatz         int32  ips_reassembled;        /* total packets reassembled ok */
12552a38012Sejakowatz         int32  ips_fragmented;         /* datagrams sucessfully fragmented */
12652a38012Sejakowatz         int32  ips_ofragments;         /* output fragments created */
12752a38012Sejakowatz         int32  ips_cantfrag;           /* don't fragment flag was set, etc. */
12852a38012Sejakowatz         int32  ips_badoptions;         /* error in option processing */
12952a38012Sejakowatz         int32  ips_noroute;            /* packets discarded due to no route */
13052a38012Sejakowatz         int32  ips_badvers;            /* ip version != 4 */
13152a38012Sejakowatz         int32  ips_rawout;             /* total raw ip packets generated */
13252a38012Sejakowatz         int32  ips_badfrags;           /* malformed fragments (bad length) */
13352a38012Sejakowatz         int32  ips_rcvmemdrop;         /* frags dropped for lack of memory */
13452a38012Sejakowatz         int32  ips_toolong;            /* ip length > max ip packet size */
13552a38012Sejakowatz         int32  ips_nogif;              /* no match gif found */
13652a38012Sejakowatz         int32  ips_badaddr;            /* invalid address on header */
13752a38012Sejakowatz         int32  ips_inhwcsum;           /* hardware checksummed on input */
13852a38012Sejakowatz         int32  ips_outhwcsum;          /* hardware checksummed on output */
13952a38012Sejakowatz };
14052a38012Sejakowatz 
141*42415555Sbeveloper //#ifdef _KERNEL_MODE
14252a38012Sejakowatz 
14352a38012Sejakowatz #define IP_FORWARDING           0x1             /* most of ip header exists */
14452a38012Sejakowatz #define IP_RAWOUTPUT            0x2             /* raw ip header exists */
14552a38012Sejakowatz #define IP_ROUTETOIF            SO_DONTROUTE    /* bypass routing tables */
14652a38012Sejakowatz #define IP_ALLOWBROADCAST       SO_BROADCAST    /* can send broadcast packets */
14752a38012Sejakowatz #define IP_MTUDISC              0x0400          /* pmtu discovery, set DF */
14852a38012Sejakowatz 
149*42415555Sbeveloper #if 0
150*42415555Sbeveloper //struct ipstat ipstat;
15152a38012Sejakowatz 
1524fc67516SDavid Reid void  ipv4_input(struct mbuf *, int);
1534fc67516SDavid Reid int   ipv4_output(struct mbuf *, struct mbuf *, struct route *, int, void *);
1544fc67516SDavid Reid int   ipv4_ctloutput(int, struct socket *, int, int, struct mbuf **);
15552a38012Sejakowatz 
1564fc67516SDavid Reid int   ip_dooptions(struct mbuf *);
1574fc67516SDavid Reid void  ip_stripoptions (struct mbuf *, struct mbuf *);
1584fc67516SDavid Reid struct mbuf *ip_srcroute(void);
1594fc67516SDavid Reid 
1604fc67516SDavid Reid 
1614fc67516SDavid Reid #endif /* _KERNEL_MODE */
16252a38012Sejakowatz 
16352a38012Sejakowatz #endif /* NETINET_IP_VAR_H */
164