ip_var.h revision 55205
19313Ssos/*
29313Ssos * Copyright (c) 1982, 1986, 1993
39313Ssos *	The Regents of the University of California.  All rights reserved.
49313Ssos *
59313Ssos * Redistribution and use in source and binary forms, with or without
69313Ssos * modification, are permitted provided that the following conditions
79313Ssos * are met:
89313Ssos * 1. Redistributions of source code must retain the above copyright
99313Ssos *    notice, this list of conditions and the following disclaimer.
109313Ssos * 2. Redistributions in binary form must reproduce the above copyright
119313Ssos *    notice, this list of conditions and the following disclaimer in the
129313Ssos *    documentation and/or other materials provided with the distribution.
139313Ssos * 3. All advertising materials mentioning features or use of this software
149313Ssos *    must display the following acknowledgement:
159313Ssos *	This product includes software developed by the University of
169313Ssos *	California, Berkeley and its contributors.
179313Ssos * 4. Neither the name of the University nor the names of its contributors
189313Ssos *    may be used to endorse or promote products derived from this software
199313Ssos *    without specific prior written permission.
209313Ssos *
219313Ssos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
229313Ssos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
239313Ssos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
249313Ssos * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
259313Ssos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
269313Ssos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
279313Ssos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2842499Seivind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
299313Ssos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
309313Ssos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3131784Seivind * SUCH DAMAGE.
3231784Seivind *
339313Ssos *	@(#)ip_var.h	8.2 (Berkeley) 1/9/95
349313Ssos * $FreeBSD: head/sys/netinet/ip_var.h 55205 1999-12-29 04:46:21Z peter $
3512458Sbde */
369313Ssos
379313Ssos#ifndef _NETINET_IP_VAR_H_
389313Ssos#define	_NETINET_IP_VAR_H_
3931561Sbde
409313Ssos/*
419313Ssos * Overlay for ip header used by other protocols (tcp, udp).
429313Ssos */
439313Ssosstruct ipovly {
4414331Speter	u_char	ih_x1[9];		/* (unused) */
4514331Speter	u_char	ih_pr;			/* protocol */
4612458Sbde	u_short	ih_len;			/* protocol length */
4712458Sbde	struct	in_addr ih_src;		/* source internet address */
4814331Speter	struct	in_addr ih_dst;		/* destination internet address */
4914331Speter};
509313Ssos
519313Ssos/*
5230994Sphk * Ip reassembly queue structure.  Each fragment
539313Ssos * being reassembled is attached to one of these structures.
5412858Speter * They are timed out after ipq_ttl drops to 0, and may also
559313Ssos * be reclaimed if memory becomes tight.
569313Ssos */
579313Ssosstruct ipq {
5812858Speter	struct	ipq *next,*prev;	/* to other reass headers */
5914331Speter	u_char	ipq_ttl;		/* time for reass q to live */
609313Ssos	u_char	ipq_p;			/* protocol of this fragment */
6114331Speter	u_short	ipq_id;			/* sequence id for reassembly */
6214331Speter	struct mbuf *ipq_frags;		/* to ip headers of fragments */
6314331Speter	struct	in_addr ipq_src,ipq_dst;
649313Ssos#ifdef IPDIVERT
659313Ssos	u_int32_t ipq_div_info;		/* ipfw divert port & flags */
669313Ssos	u_int16_t ipq_div_cookie;	/* ipfw divert cookie */
679313Ssos#endif
689313Ssos};
699313Ssos
709313Ssos/*
7130994Sphk * Structure stored in mbuf in inpcb.ip_options
729313Ssos * and passed to ip_output when ip options are in use.
739313Ssos * The actual length of the options (including ipopt_dst)
749313Ssos * is in m_len.
7530994Sphk */
769313Ssos#define MAX_IPOPTLEN	40
7712858Speter
789313Ssosstruct ipoption {
799313Ssos	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
809313Ssos	char	ipopt_list[MAX_IPOPTLEN];	/* options proper */
8112858Speter};
829313Ssos
8314331Speter/*
8414331Speter * Structure attached to inpcb.ip_moptions and
8514331Speter * passed to ip_output when IP multicast options are in use.
869313Ssos */
8714331Speterstruct ip_moptions {
8814331Speter	struct	ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
8914331Speter	u_char	imo_multicast_ttl;	/* TTL for outgoing multicasts */
9014331Speter	u_char	imo_multicast_loop;	/* 1 => hear sends if a member */
9114331Speter	u_short	imo_num_memberships;	/* no. memberships this socket */
929313Ssos	struct	in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
939313Ssos	u_long	imo_multicast_vif;	/* vif num outgoing multicasts */
949313Ssos};
959313Ssos
969313Ssosstruct	ipstat {
979313Ssos	u_long	ips_total;		/* total packets received */
989313Ssos	u_long	ips_badsum;		/* checksum bad */
999313Ssos	u_long	ips_tooshort;		/* packet too short */
1009313Ssos	u_long	ips_toosmall;		/* not enough data */
1019313Ssos	u_long	ips_badhlen;		/* ip header length < data size */
1029313Ssos	u_long	ips_badlen;		/* ip length < ip header length */
1039313Ssos	u_long	ips_fragments;		/* fragments received */
1049313Ssos	u_long	ips_fragdropped;	/* frags dropped (dups, out of space) */
1059313Ssos	u_long	ips_fragtimeout;	/* fragments timed out */
1069313Ssos	u_long	ips_forward;		/* packets forwarded */
1079313Ssos	u_long	ips_fastforward;	/* packets fast forwarded */
1089313Ssos	u_long	ips_cantforward;	/* packets rcvd for unreachable dest */
1099313Ssos	u_long	ips_redirectsent;	/* packets forwarded on same net */
1109313Ssos	u_long	ips_noproto;		/* unknown or unsupported protocol */
1119313Ssos	u_long	ips_delivered;		/* datagrams delivered to upper level*/
1129313Ssos	u_long	ips_localout;		/* total ip packets generated here */
1139313Ssos	u_long	ips_odropped;		/* lost packets due to nobufs, etc. */
1149313Ssos	u_long	ips_reassembled;	/* total packets reassembled ok */
1159313Ssos	u_long	ips_fragmented;		/* datagrams successfully fragmented */
1169313Ssos	u_long	ips_ofragments;		/* output fragments created */
1179313Ssos	u_long	ips_cantfrag;		/* don't fragment flag was set, etc. */
1189313Ssos	u_long	ips_badoptions;		/* error in option processing */
1199313Ssos	u_long	ips_noroute;		/* packets discarded due to no route */
1209313Ssos	u_long	ips_badvers;		/* ip version != 4 */
1219313Ssos	u_long	ips_rawout;		/* total raw ip packets generated */
1229313Ssos	u_long	ips_toolong;		/* ip length > max ip packet size */
1239313Ssos	u_long	ips_notmember;		/* multicasts for unregistered grps */
12430994Sphk	u_long	ips_nogif;		/* no match gif found */
1259313Ssos};
1269313Ssos
1279313Ssos#ifdef _KERNEL
12830994Sphk
1299313Ssos/* flags passed to ip_output as last parameter */
1309313Ssos#define	IP_FORWARDING		0x1		/* most of ip header exists */
1319313Ssos#define	IP_RAWOUTPUT		0x2		/* raw ip header exists */
1329313Ssos#define	IP_ROUTETOIF		SO_DONTROUTE	/* bypass routing tables */
13314331Speter#define	IP_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
13414331Speter#define	IP_SOCKINMRCVIF		0x100		/* IPSEC hack;
13514331Speter						 * socket pointer in sending
13614331Speter						 * packet's m_pkthdr.rcvif */
1379313Ssos
1389313Ssosstruct ip;
1399313Ssosstruct inpcb;
1409313Ssosstruct route;
1419313Ssosstruct sockopt;
1429313Ssos
1439313Ssosextern struct	ipstat	ipstat;
1449313Ssosextern u_short	ip_id;				/* ip packet ctr, for ids */
1459313Ssosextern int	ip_defttl;			/* default IP ttl */
1469313Ssosextern int	ipforwarding;			/* ip forwarding */
1479313Ssosextern u_char	ip_protox[];
1489313Ssosextern struct socket *ip_rsvpd;	/* reservation protocol daemon */
1499313Ssosextern struct socket *ip_mrouter; /* multicast routing daemon */
1509313Ssosextern int	(*legal_vif_num) __P((int));
1519313Ssosextern u_long	(*ip_mcast_src) __P((int));
1529313Ssosextern int rsvp_on;
1539313Ssosextern struct	pr_usrreqs rip_usrreqs;
1549313Ssos
1559313Ssosint	 ip_ctloutput __P((struct socket *, struct sockopt *sopt));
1569313Ssosvoid	 ip_drain __P((void));
1579313Ssosvoid	 ip_freemoptions __P((struct ip_moptions *));
1589313Ssosvoid	 ip_init __P((void));
1599313Ssosextern int	 (*ip_mforward) __P((struct ip *, struct ifnet *, struct mbuf *,
1609313Ssos			  struct ip_moptions *));
1619313Ssosint	 ip_output __P((struct mbuf *,
1629313Ssos	    struct mbuf *, struct route *, int, struct ip_moptions *));
1639313Ssosvoid	 ip_savecontrol __P((struct inpcb *, struct mbuf **, struct ip *,
1649313Ssos		struct mbuf *));
1659313Ssosvoid	 ip_slowtimo __P((void));
1669313Ssosstruct mbuf *
1679313Ssos	 ip_srcroute __P((void));
1689313Ssosvoid	 ip_stripoptions __P((struct mbuf *, struct mbuf *));
1699313Ssosint	 rip_ctloutput __P((struct socket *, struct sockopt *));
1709313Ssosvoid	 rip_ctlinput __P((int, struct sockaddr *, void *));
1719313Ssosvoid	 rip_init __P((void));
1729313Ssosvoid	 rip_input __P((struct mbuf *, int, int));
1739313Ssosint	 rip_output __P((struct mbuf *, struct socket *, u_long));
1749313Ssosvoid	ipip_input __P((struct mbuf *, int, int));
1759313Ssosvoid	rsvp_input __P((struct mbuf *, int, int));
1769313Ssosint	ip_rsvp_init __P((struct socket *));
1779313Ssosint	ip_rsvp_done __P((void));
1789313Ssosint	ip_rsvp_vif_init __P((struct socket *, struct sockopt *));
1799313Ssosint	ip_rsvp_vif_done __P((struct socket *, struct sockopt *));
1809313Ssosvoid	ip_rsvp_force_done __P((struct socket *));
1819313Ssos
1829313Ssos#ifdef IPDIVERT
1839313Ssosvoid	div_init __P((void));
1849313Ssosvoid	div_input __P((struct mbuf *, int, int));
1859313Ssosvoid	divert_packet __P((struct mbuf *, int, int));
1869313Ssosextern struct pr_usrreqs div_usrreqs;
1879313Ssosextern u_int16_t ip_divert_cookie;
1889313Ssos#endif
18930994Sphk
1909313Ssosextern struct sockaddr_in *ip_fw_fwd_addr;
1919313Ssos
19212858Speter#endif /* _KERNEL */
1939313Ssos
1949313Ssos#endif /* !_NETINET_IP_VAR_H_ */
1959313Ssos