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; 4862b4effaSIthamar R. Adema uint8_t ih_x1; /* (unused) */ 4962b4effaSIthamar R. Adema uint8_t ih_pr; /* protocol */ 5062b4effaSIthamar R. Adema uint16_t 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 */ 6562b4effaSIthamar R. Adema int8_t 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 */ 7462b4effaSIthamar R. Adema uint8_t imo_multicast_ttl; /* TTL for outgoing multicasts */ 7562b4effaSIthamar R. Adema uint8_t imo_multicast_loop; /* 1 => here sends if a member */ 7662b4effaSIthamar R. Adema uint16_t 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 8262b4effaSIthamar R. Adema uint8_t ip_v:4; 8362b4effaSIthamar R. Adema uint8_t ip_hl:4; 8452a38012Sejakowatz #else 8562b4effaSIthamar R. Adema uint8_t ip_hl:4; 8662b4effaSIthamar R. Adema uint8_t ip_v:4; 8752a38012Sejakowatz #endif 8862b4effaSIthamar R. Adema uint8_t ipf_mff; 8962b4effaSIthamar R. Adema int16_t ip_len; 9062b4effaSIthamar R. Adema uint16_t ip_id; 9162b4effaSIthamar R. Adema int16_t ip_off; 9262b4effaSIthamar R. Adema uint8_t ip_ttl; 9362b4effaSIthamar R. Adema uint8_t ip_p; 9452a38012Sejakowatz struct ipasfrag *ipf_next; 9552a38012Sejakowatz struct ipasfrag *ipf_prev; 9652a38012Sejakowatz }; 9752a38012Sejakowatz 9852a38012Sejakowatz struct ipq { 9952a38012Sejakowatz struct ipq *next, *prev; 10062b4effaSIthamar R. Adema uint8_t ipq_ttl; 10162b4effaSIthamar R. Adema uint8_t ipq_p; 10262b4effaSIthamar R. Adema uint16_t ipq_id; 10352a38012Sejakowatz struct ipasfrag *ipq_next, *ipq_prev; 10452a38012Sejakowatz struct in_addr ipq_src, ipq_dst; 10552a38012Sejakowatz }; 10652a38012Sejakowatz 10752a38012Sejakowatz struct ipstat { 10862b4effaSIthamar R. Adema int32_t ips_total; /* total packets received */ 10962b4effaSIthamar R. Adema int32_t ips_badsum; /* checksum bad */ 11062b4effaSIthamar R. Adema int32_t ips_tooshort; /* packet too short */ 11162b4effaSIthamar R. Adema int32_t ips_toosmall; /* not enough data */ 11262b4effaSIthamar R. Adema int32_t ips_badhlen; /* ip header length < data size */ 11362b4effaSIthamar R. Adema int32_t ips_badlen; /* ip length < ip header length */ 11462b4effaSIthamar R. Adema int32_t ips_fragments; /* fragments received */ 11562b4effaSIthamar R. Adema int32_t ips_fragdropped; /* frags dropped (dups, out of space) */ 11662b4effaSIthamar R. Adema int32_t ips_fragtimeout; /* fragments timed out */ 11762b4effaSIthamar R. Adema int32_t ips_forward; /* packets forwarded */ 11862b4effaSIthamar R. Adema int32_t ips_cantforward; /* packets rcvd for unreachable dest */ 11962b4effaSIthamar R. Adema int32_t ips_redirectsent; /* packets forwarded on same net */ 12062b4effaSIthamar R. Adema int32_t ips_noproto; /* unknown or unsupported protocol */ 12162b4effaSIthamar R. Adema int32_t ips_delivered; /* datagrams delivered to upper level*/ 12262b4effaSIthamar R. Adema int32_t ips_localout; /* total ip packets generated here */ 12362b4effaSIthamar R. Adema int32_t ips_odropped; /* lost packets due to nobufs, etc. */ 12462b4effaSIthamar R. Adema int32_t ips_reassembled; /* total packets reassembled ok */ 12562b4effaSIthamar R. Adema int32_t ips_fragmented; /* datagrams sucessfully fragmented */ 12662b4effaSIthamar R. Adema int32_t ips_ofragments; /* output fragments created */ 12762b4effaSIthamar R. Adema int32_t ips_cantfrag; /* don't fragment flag was set, etc. */ 12862b4effaSIthamar R. Adema int32_t ips_badoptions; /* error in option processing */ 12962b4effaSIthamar R. Adema int32_t ips_noroute; /* packets discarded due to no route */ 13062b4effaSIthamar R. Adema int32_t ips_badvers; /* ip version != 4 */ 13162b4effaSIthamar R. Adema int32_t ips_rawout; /* total raw ip packets generated */ 13262b4effaSIthamar R. Adema int32_t ips_badfrags; /* malformed fragments (bad length) */ 13362b4effaSIthamar R. Adema int32_t ips_rcvmemdrop; /* frags dropped for lack of memory */ 13462b4effaSIthamar R. Adema int32_t ips_toolong; /* ip length > max ip packet size */ 13562b4effaSIthamar R. Adema int32_t ips_nogif; /* no match gif found */ 13662b4effaSIthamar R. Adema int32_t ips_badaddr; /* invalid address on header */ 13762b4effaSIthamar R. Adema int32_t ips_inhwcsum; /* hardware checksummed on input */ 13862b4effaSIthamar R. Adema int32_t ips_outhwcsum; /* hardware checksummed on output */ 13952a38012Sejakowatz }; 14052a38012Sejakowatz 141*b9320128SIngo Weinhold /* #ifdef _KERNEL_MODE */ 14252a38012Sejakowatz 14352a38012Sejakowatz #define IP_FORWARDING 0x1 /* most of ip header exists */ 14452a38012Sejakowatz #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ 145f1730f62SWaldemar Kornewald #define IP_RAWOUTPUT 0x4 /* raw ip header exists */ 146f1730f62SWaldemar Kornewald #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ 147f1730f62SWaldemar Kornewald #define IP_MTUDISC 0x10 /* pmtu discovery, set DF */ 14852a38012Sejakowatz 14942415555Sbeveloper #if 0 150*b9320128SIngo Weinhold /* 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