xref: /csrg-svn/sys/netinet/ip_var.h (revision 24815)
123185Smckusick /*
223185Smckusick  * Copyright (c) 1982 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*24815Skarels  *	@(#)ip_var.h	6.5 (Berkeley) 09/16/85
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 {
439992Ssam #ifdef vax
444893Swnj 	u_char	ip_hl:4,
454893Swnj 		ip_v:4;
469992Ssam #endif
474893Swnj 	u_char	ipf_mff;		/* copied from (ip_off&IP_MF) */
484893Swnj 	short	ip_len;
494893Swnj 	u_short	ip_id;
504893Swnj 	short	ip_off;
514893Swnj 	u_char	ip_ttl;
524893Swnj 	u_char	ip_p;
534893Swnj 	u_short	ip_sum;
544899Swnj 	struct	ipasfrag *ipf_next;	/* next fragment */
554899Swnj 	struct	ipasfrag *ipf_prev;	/* previous fragment */
564893Swnj };
574893Swnj 
58*24815Skarels /*
59*24815Skarels  * Structure stored in mbuf in inpcb.ip_options
60*24815Skarels  * and passed to ip_output when ip options are in use.
61*24815Skarels  * The actual length of the options (including ipopt_dst)
62*24815Skarels  * is in m_len.
63*24815Skarels  */
64*24815Skarels #define MAX_IPOPTLEN	40
65*24815Skarels 
66*24815Skarels struct ipoption {
67*24815Skarels 	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
68*24815Skarels 	char	ipopt_list[MAX_IPOPTLEN];	/* options proper */
69*24815Skarels };
70*24815Skarels 
714924Swnj struct	ipstat {
72*24815Skarels 	long	ips_total;		/* total packets received */
73*24815Skarels 	long	ips_badsum;		/* checksum bad */
74*24815Skarels 	long	ips_tooshort;		/* packet too short */
75*24815Skarels 	long	ips_toosmall;		/* not enough data */
76*24815Skarels 	long	ips_badhlen;		/* ip header length < data size */
77*24815Skarels 	long	ips_badlen;		/* ip length < ip header length */
78*24815Skarels 	long	ips_fragments;		/* fragments received */
79*24815Skarels 	long	ips_fragdropped;	/* frags dropped (dups, out of space) */
80*24815Skarels 	long	ips_fragtimeout;	/* fragments timed out */
8121022Skarels 	long	ips_forward;		/* packets forwarded */
8221022Skarels 	long	ips_cantforward;	/* packets rcvd for unreachable dest */
83*24815Skarels 	long	ips_redirectsent;	/* packets forwarded on same net */
844924Swnj };
854924Swnj 
864893Swnj #ifdef KERNEL
8712418Ssam /* flags passed to ip_output as last parameter */
8817051Skarels #define	IP_FORWARDING		0x1		/* most of ip header exists */
8917051Skarels #define	IP_ROUTETOIF		SO_DONTROUTE	/* bypass routing tables */
9017051Skarels #define	IP_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
9112418Ssam 
924924Swnj struct	ipstat	ipstat;
934893Swnj struct	ipq	ipq;			/* ip reass. queue */
944893Swnj u_short	ip_id;				/* ip packet ctr, for ids */
95*24815Skarels 
96*24815Skarels struct	mbuf *ip_srcroute();
974893Swnj #endif
98