xref: /csrg-svn/sys/netinet/ip_var.h (revision 29923)
123185Smckusick /*
229145Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
323185Smckusick  * All rights reserved.  The Berkeley software License Agreement
423185Smckusick  * specifies the terms and conditions for redistribution.
523185Smckusick  *
6*29923Skarels  *	@(#)ip_var.h	7.2 (Berkeley) 10/28/86
723185Smckusick  */
84893Swnj 
94893Swnj /*
104893Swnj  * Overlay for ip header used by other protocols (tcp, udp).
114893Swnj  */
124893Swnj struct ipovly {
134899Swnj 	caddr_t	ih_next, ih_prev;	/* for protocol sequence q's */
144899Swnj 	u_char	ih_x1;			/* (unused) */
154899Swnj 	u_char	ih_pr;			/* protocol */
164924Swnj 	short	ih_len;			/* protocol length */
174924Swnj 	struct	in_addr ih_src;		/* source internet address */
184924Swnj 	struct	in_addr ih_dst;		/* destination internet address */
194893Swnj };
204893Swnj 
214893Swnj /*
224893Swnj  * Ip reassembly queue structure.  Each fragment
234893Swnj  * being reassembled is attached to one of these structures.
244893Swnj  * They are timed out after ipq_ttl drops to 0, and may also
254893Swnj  * be reclaimed if memory becomes tight.
264893Swnj  */
274893Swnj struct ipq {
284893Swnj 	struct	ipq *next,*prev;	/* to other reass headers */
294893Swnj 	u_char	ipq_ttl;		/* time for reass q to live */
304893Swnj 	u_char	ipq_p;			/* protocol of this fragment */
314893Swnj 	u_short	ipq_id;			/* sequence id for reassembly */
324893Swnj 	struct	ipasfrag *ipq_next,*ipq_prev;
334893Swnj 					/* to ip headers of fragments */
344924Swnj 	struct	in_addr ipq_src,ipq_dst;
354893Swnj };
364893Swnj 
374893Swnj /*
384893Swnj  * Ip header, when holding a fragment.
399185Ssam  *
409185Ssam  * Note: ipf_next must be at same offset as ipq_next above
414893Swnj  */
424893Swnj struct	ipasfrag {
43*29923Skarels #if ENDIAN == LITTLE
444893Swnj 	u_char	ip_hl:4,
454893Swnj 		ip_v:4;
469992Ssam #endif
47*29923Skarels #if ENDIAN == BIG
48*29923Skarels 	u_char	ip_v:4,
49*29923Skarels 		ip_hl:4;
50*29923Skarels #endif
514893Swnj 	u_char	ipf_mff;		/* copied from (ip_off&IP_MF) */
524893Swnj 	short	ip_len;
534893Swnj 	u_short	ip_id;
544893Swnj 	short	ip_off;
554893Swnj 	u_char	ip_ttl;
564893Swnj 	u_char	ip_p;
574893Swnj 	u_short	ip_sum;
584899Swnj 	struct	ipasfrag *ipf_next;	/* next fragment */
594899Swnj 	struct	ipasfrag *ipf_prev;	/* previous fragment */
604893Swnj };
614893Swnj 
6224815Skarels /*
6324815Skarels  * Structure stored in mbuf in inpcb.ip_options
6424815Skarels  * and passed to ip_output when ip options are in use.
6524815Skarels  * The actual length of the options (including ipopt_dst)
6624815Skarels  * is in m_len.
6724815Skarels  */
6824815Skarels #define MAX_IPOPTLEN	40
6924815Skarels 
7024815Skarels struct ipoption {
7124815Skarels 	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
7224815Skarels 	char	ipopt_list[MAX_IPOPTLEN];	/* options proper */
7324815Skarels };
7424815Skarels 
754924Swnj struct	ipstat {
7624815Skarels 	long	ips_total;		/* total packets received */
7724815Skarels 	long	ips_badsum;		/* checksum bad */
7824815Skarels 	long	ips_tooshort;		/* packet too short */
7924815Skarels 	long	ips_toosmall;		/* not enough data */
8024815Skarels 	long	ips_badhlen;		/* ip header length < data size */
8124815Skarels 	long	ips_badlen;		/* ip length < ip header length */
8224815Skarels 	long	ips_fragments;		/* fragments received */
8324815Skarels 	long	ips_fragdropped;	/* frags dropped (dups, out of space) */
8424815Skarels 	long	ips_fragtimeout;	/* fragments timed out */
8521022Skarels 	long	ips_forward;		/* packets forwarded */
8621022Skarels 	long	ips_cantforward;	/* packets rcvd for unreachable dest */
8724815Skarels 	long	ips_redirectsent;	/* packets forwarded on same net */
884924Swnj };
894924Swnj 
904893Swnj #ifdef KERNEL
9112418Ssam /* flags passed to ip_output as last parameter */
9217051Skarels #define	IP_FORWARDING		0x1		/* most of ip header exists */
9317051Skarels #define	IP_ROUTETOIF		SO_DONTROUTE	/* bypass routing tables */
9417051Skarels #define	IP_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
9512418Ssam 
964924Swnj struct	ipstat	ipstat;
974893Swnj struct	ipq	ipq;			/* ip reass. queue */
984893Swnj u_short	ip_id;				/* ip packet ctr, for ids */
9924815Skarels 
10024815Skarels struct	mbuf *ip_srcroute();
1014893Swnj #endif
102