xref: /csrg-svn/sys/netinet/ip_var.h (revision 32787)
123185Smckusick /*
229145Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
3*32787Sbostic  * All rights reserved.
423185Smckusick  *
5*32787Sbostic  * Redistribution and use in source and binary forms are permitted
6*32787Sbostic  * provided that this notice is preserved and that due credit is given
7*32787Sbostic  * to the University of California at Berkeley. The name of the University
8*32787Sbostic  * may not be used to endorse or promote products derived from this
9*32787Sbostic  * software without specific prior written permission. This software
10*32787Sbostic  * is provided ``as is'' without express or implied warranty.
11*32787Sbostic  *
12*32787Sbostic  *	@(#)ip_var.h	7.3 (Berkeley) 12/07/87
1323185Smckusick  */
144893Swnj 
154893Swnj /*
164893Swnj  * Overlay for ip header used by other protocols (tcp, udp).
174893Swnj  */
184893Swnj struct ipovly {
194899Swnj 	caddr_t	ih_next, ih_prev;	/* for protocol sequence q's */
204899Swnj 	u_char	ih_x1;			/* (unused) */
214899Swnj 	u_char	ih_pr;			/* protocol */
224924Swnj 	short	ih_len;			/* protocol length */
234924Swnj 	struct	in_addr ih_src;		/* source internet address */
244924Swnj 	struct	in_addr ih_dst;		/* destination internet address */
254893Swnj };
264893Swnj 
274893Swnj /*
284893Swnj  * Ip reassembly queue structure.  Each fragment
294893Swnj  * being reassembled is attached to one of these structures.
304893Swnj  * They are timed out after ipq_ttl drops to 0, and may also
314893Swnj  * be reclaimed if memory becomes tight.
324893Swnj  */
334893Swnj struct ipq {
344893Swnj 	struct	ipq *next,*prev;	/* to other reass headers */
354893Swnj 	u_char	ipq_ttl;		/* time for reass q to live */
364893Swnj 	u_char	ipq_p;			/* protocol of this fragment */
374893Swnj 	u_short	ipq_id;			/* sequence id for reassembly */
384893Swnj 	struct	ipasfrag *ipq_next,*ipq_prev;
394893Swnj 					/* to ip headers of fragments */
404924Swnj 	struct	in_addr ipq_src,ipq_dst;
414893Swnj };
424893Swnj 
434893Swnj /*
444893Swnj  * Ip header, when holding a fragment.
459185Ssam  *
469185Ssam  * Note: ipf_next must be at same offset as ipq_next above
474893Swnj  */
484893Swnj struct	ipasfrag {
4929923Skarels #if ENDIAN == LITTLE
504893Swnj 	u_char	ip_hl:4,
514893Swnj 		ip_v:4;
529992Ssam #endif
5329923Skarels #if ENDIAN == BIG
5429923Skarels 	u_char	ip_v:4,
5529923Skarels 		ip_hl:4;
5629923Skarels #endif
574893Swnj 	u_char	ipf_mff;		/* copied from (ip_off&IP_MF) */
584893Swnj 	short	ip_len;
594893Swnj 	u_short	ip_id;
604893Swnj 	short	ip_off;
614893Swnj 	u_char	ip_ttl;
624893Swnj 	u_char	ip_p;
634893Swnj 	u_short	ip_sum;
644899Swnj 	struct	ipasfrag *ipf_next;	/* next fragment */
654899Swnj 	struct	ipasfrag *ipf_prev;	/* previous fragment */
664893Swnj };
674893Swnj 
6824815Skarels /*
6924815Skarels  * Structure stored in mbuf in inpcb.ip_options
7024815Skarels  * and passed to ip_output when ip options are in use.
7124815Skarels  * The actual length of the options (including ipopt_dst)
7224815Skarels  * is in m_len.
7324815Skarels  */
7424815Skarels #define MAX_IPOPTLEN	40
7524815Skarels 
7624815Skarels struct ipoption {
7724815Skarels 	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
7824815Skarels 	char	ipopt_list[MAX_IPOPTLEN];	/* options proper */
7924815Skarels };
8024815Skarels 
814924Swnj struct	ipstat {
8224815Skarels 	long	ips_total;		/* total packets received */
8324815Skarels 	long	ips_badsum;		/* checksum bad */
8424815Skarels 	long	ips_tooshort;		/* packet too short */
8524815Skarels 	long	ips_toosmall;		/* not enough data */
8624815Skarels 	long	ips_badhlen;		/* ip header length < data size */
8724815Skarels 	long	ips_badlen;		/* ip length < ip header length */
8824815Skarels 	long	ips_fragments;		/* fragments received */
8924815Skarels 	long	ips_fragdropped;	/* frags dropped (dups, out of space) */
9024815Skarels 	long	ips_fragtimeout;	/* fragments timed out */
9121022Skarels 	long	ips_forward;		/* packets forwarded */
9221022Skarels 	long	ips_cantforward;	/* packets rcvd for unreachable dest */
9324815Skarels 	long	ips_redirectsent;	/* packets forwarded on same net */
944924Swnj };
954924Swnj 
964893Swnj #ifdef KERNEL
9712418Ssam /* flags passed to ip_output as last parameter */
9817051Skarels #define	IP_FORWARDING		0x1		/* most of ip header exists */
9917051Skarels #define	IP_ROUTETOIF		SO_DONTROUTE	/* bypass routing tables */
10017051Skarels #define	IP_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
10112418Ssam 
1024924Swnj struct	ipstat	ipstat;
1034893Swnj struct	ipq	ipq;			/* ip reass. queue */
1044893Swnj u_short	ip_id;				/* ip packet ctr, for ids */
10524815Skarels 
10624815Skarels struct	mbuf *ip_srcroute();
1074893Swnj #endif
108