xref: /csrg-svn/sys/netinet/ip_var.h (revision 39185)
123185Smckusick /*
229145Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
332787Sbostic  * All rights reserved.
423185Smckusick  *
532787Sbostic  * Redistribution and use in source and binary forms are permitted
634854Sbostic  * provided that the above copyright notice and this paragraph are
734854Sbostic  * duplicated in all such forms and that any documentation,
834854Sbostic  * advertising materials, and other materials related to such
934854Sbostic  * distribution and use acknowledge that the software was developed
1034854Sbostic  * by the University of California, Berkeley.  The name of the
1134854Sbostic  * University may not be used to endorse or promote products derived
1234854Sbostic  * from this software without specific prior written permission.
1334854Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434854Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534854Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1632787Sbostic  *
17*39185Ssklower  *	@(#)ip_var.h	7.6 (Berkeley) 09/20/89
1823185Smckusick  */
194893Swnj 
204893Swnj /*
214893Swnj  * Overlay for ip header used by other protocols (tcp, udp).
224893Swnj  */
234893Swnj struct ipovly {
244899Swnj 	caddr_t	ih_next, ih_prev;	/* for protocol sequence q's */
254899Swnj 	u_char	ih_x1;			/* (unused) */
264899Swnj 	u_char	ih_pr;			/* protocol */
274924Swnj 	short	ih_len;			/* protocol length */
284924Swnj 	struct	in_addr ih_src;		/* source internet address */
294924Swnj 	struct	in_addr ih_dst;		/* destination internet address */
304893Swnj };
314893Swnj 
324893Swnj /*
334893Swnj  * Ip reassembly queue structure.  Each fragment
344893Swnj  * being reassembled is attached to one of these structures.
354893Swnj  * They are timed out after ipq_ttl drops to 0, and may also
364893Swnj  * be reclaimed if memory becomes tight.
374893Swnj  */
384893Swnj struct ipq {
394893Swnj 	struct	ipq *next,*prev;	/* to other reass headers */
404893Swnj 	u_char	ipq_ttl;		/* time for reass q to live */
414893Swnj 	u_char	ipq_p;			/* protocol of this fragment */
424893Swnj 	u_short	ipq_id;			/* sequence id for reassembly */
434893Swnj 	struct	ipasfrag *ipq_next,*ipq_prev;
444893Swnj 					/* to ip headers of fragments */
454924Swnj 	struct	in_addr ipq_src,ipq_dst;
464893Swnj };
474893Swnj 
484893Swnj /*
494893Swnj  * Ip header, when holding a fragment.
509185Ssam  *
519185Ssam  * Note: ipf_next must be at same offset as ipq_next above
524893Swnj  */
534893Swnj struct	ipasfrag {
5433283Skarels #if BYTE_ORDER == LITTLE_ENDIAN
554893Swnj 	u_char	ip_hl:4,
564893Swnj 		ip_v:4;
579992Ssam #endif
5833283Skarels #if BYTE_ORDER == BIG_ENDIAN
5929923Skarels 	u_char	ip_v:4,
6029923Skarels 		ip_hl:4;
6129923Skarels #endif
624893Swnj 	u_char	ipf_mff;		/* copied from (ip_off&IP_MF) */
634893Swnj 	short	ip_len;
644893Swnj 	u_short	ip_id;
654893Swnj 	short	ip_off;
664893Swnj 	u_char	ip_ttl;
674893Swnj 	u_char	ip_p;
684893Swnj 	u_short	ip_sum;
694899Swnj 	struct	ipasfrag *ipf_next;	/* next fragment */
704899Swnj 	struct	ipasfrag *ipf_prev;	/* previous fragment */
714893Swnj };
724893Swnj 
7324815Skarels /*
7424815Skarels  * Structure stored in mbuf in inpcb.ip_options
7524815Skarels  * and passed to ip_output when ip options are in use.
7624815Skarels  * The actual length of the options (including ipopt_dst)
7724815Skarels  * is in m_len.
7824815Skarels  */
7924815Skarels #define MAX_IPOPTLEN	40
8024815Skarels 
8124815Skarels struct ipoption {
8224815Skarels 	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
8324815Skarels 	char	ipopt_list[MAX_IPOPTLEN];	/* options proper */
8424815Skarels };
8524815Skarels 
864924Swnj struct	ipstat {
8724815Skarels 	long	ips_total;		/* total packets received */
8824815Skarels 	long	ips_badsum;		/* checksum bad */
8924815Skarels 	long	ips_tooshort;		/* packet too short */
9024815Skarels 	long	ips_toosmall;		/* not enough data */
9124815Skarels 	long	ips_badhlen;		/* ip header length < data size */
9224815Skarels 	long	ips_badlen;		/* ip length < ip header length */
9324815Skarels 	long	ips_fragments;		/* fragments received */
9424815Skarels 	long	ips_fragdropped;	/* frags dropped (dups, out of space) */
9524815Skarels 	long	ips_fragtimeout;	/* fragments timed out */
9621022Skarels 	long	ips_forward;		/* packets forwarded */
9721022Skarels 	long	ips_cantforward;	/* packets rcvd for unreachable dest */
9824815Skarels 	long	ips_redirectsent;	/* packets forwarded on same net */
99*39185Ssklower 	long	ips_noproto;		/* unknown or unsupported protocol */
100*39185Ssklower 	long	ips_delivered;		/* packets consumed here */
101*39185Ssklower 	long	ips_localout;		/* total ip packets generated here */
102*39185Ssklower 	long	ips_odropped;		/* lost packets due to nobufs, etc. */
103*39185Ssklower 	long	ips_reassembled;	/* total packets reassembled ok */
104*39185Ssklower 	long	ips_fragmented;		/* output packets fragmented ok */
105*39185Ssklower 	long	ips_ofragments;		/* output fragments created */
106*39185Ssklower 	long	ips_cantfrag;		/* don't fragment flag was set, etc. */
1074924Swnj };
1084924Swnj 
1094893Swnj #ifdef KERNEL
11012418Ssam /* flags passed to ip_output as last parameter */
11117051Skarels #define	IP_FORWARDING		0x1		/* most of ip header exists */
11217051Skarels #define	IP_ROUTETOIF		SO_DONTROUTE	/* bypass routing tables */
11317051Skarels #define	IP_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
11412418Ssam 
1154924Swnj struct	ipstat	ipstat;
1164893Swnj struct	ipq	ipq;			/* ip reass. queue */
1174893Swnj u_short	ip_id;				/* ip packet ctr, for ids */
11824815Skarels 
11924815Skarels struct	mbuf *ip_srcroute();
1204893Swnj #endif
121