xref: /csrg-svn/sys/netinet/ip_var.h (revision 57433)
123185Smckusick /*
229145Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
332787Sbostic  * All rights reserved.
423185Smckusick  *
544482Sbostic  * %sccs.include.redist.c%
632787Sbostic  *
7*57433Sandrew  *	@(#)ip_var.h	7.9 (Berkeley) 01/08/93
823185Smckusick  */
94893Swnj 
104893Swnj /*
114893Swnj  * Overlay for ip header used by other protocols (tcp, udp).
124893Swnj  */
134893Swnj struct ipovly {
144899Swnj 	caddr_t	ih_next, ih_prev;	/* for protocol sequence q's */
154899Swnj 	u_char	ih_x1;			/* (unused) */
164899Swnj 	u_char	ih_pr;			/* protocol */
174924Swnj 	short	ih_len;			/* protocol length */
184924Swnj 	struct	in_addr ih_src;		/* source internet address */
194924Swnj 	struct	in_addr ih_dst;		/* destination internet address */
204893Swnj };
214893Swnj 
224893Swnj /*
234893Swnj  * Ip reassembly queue structure.  Each fragment
244893Swnj  * being reassembled is attached to one of these structures.
254893Swnj  * They are timed out after ipq_ttl drops to 0, and may also
264893Swnj  * be reclaimed if memory becomes tight.
274893Swnj  */
284893Swnj struct ipq {
294893Swnj 	struct	ipq *next,*prev;	/* to other reass headers */
304893Swnj 	u_char	ipq_ttl;		/* time for reass q to live */
314893Swnj 	u_char	ipq_p;			/* protocol of this fragment */
324893Swnj 	u_short	ipq_id;			/* sequence id for reassembly */
334893Swnj 	struct	ipasfrag *ipq_next,*ipq_prev;
344893Swnj 					/* to ip headers of fragments */
354924Swnj 	struct	in_addr ipq_src,ipq_dst;
364893Swnj };
374893Swnj 
384893Swnj /*
394893Swnj  * Ip header, when holding a fragment.
409185Ssam  *
419185Ssam  * Note: ipf_next must be at same offset as ipq_next above
424893Swnj  */
434893Swnj struct	ipasfrag {
4433283Skarels #if BYTE_ORDER == LITTLE_ENDIAN
454893Swnj 	u_char	ip_hl:4,
464893Swnj 		ip_v:4;
479992Ssam #endif
4833283Skarels #if BYTE_ORDER == BIG_ENDIAN
4929923Skarels 	u_char	ip_v:4,
5029923Skarels 		ip_hl:4;
5129923Skarels #endif
524893Swnj 	u_char	ipf_mff;		/* copied from (ip_off&IP_MF) */
534893Swnj 	short	ip_len;
544893Swnj 	u_short	ip_id;
554893Swnj 	short	ip_off;
564893Swnj 	u_char	ip_ttl;
574893Swnj 	u_char	ip_p;
584893Swnj 	u_short	ip_sum;
594899Swnj 	struct	ipasfrag *ipf_next;	/* next fragment */
604899Swnj 	struct	ipasfrag *ipf_prev;	/* previous fragment */
614893Swnj };
624893Swnj 
6324815Skarels /*
6424815Skarels  * Structure stored in mbuf in inpcb.ip_options
6524815Skarels  * and passed to ip_output when ip options are in use.
6624815Skarels  * The actual length of the options (including ipopt_dst)
6724815Skarels  * is in m_len.
6824815Skarels  */
6924815Skarels #define MAX_IPOPTLEN	40
7024815Skarels 
7124815Skarels struct ipoption {
7224815Skarels 	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
7324815Skarels 	char	ipopt_list[MAX_IPOPTLEN];	/* options proper */
7424815Skarels };
7524815Skarels 
7654716Ssklower /*
7754716Ssklower  * Structure attached to inpcb.ip_moptions and
7854716Ssklower  * passed to ip_output when IP multicast options are in use.
7954716Ssklower  */
8054716Ssklower struct ip_moptions {
8154716Ssklower 	struct	ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
8254716Ssklower 	u_char	imo_multicast_ttl;	/* TTL for outgoing multicasts */
8354716Ssklower 	u_char	imo_multicast_loop;	/* 1 => hear sends if a member */
8454716Ssklower 	u_short	imo_num_memberships;	/* no. memberships this socket */
8554716Ssklower 	struct	in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
8654716Ssklower };
8754716Ssklower 
884924Swnj struct	ipstat {
89*57433Sandrew 	u_long	ips_total;		/* total packets received */
90*57433Sandrew 	u_long	ips_badsum;		/* checksum bad */
91*57433Sandrew 	u_long	ips_tooshort;		/* packet too short */
92*57433Sandrew 	u_long	ips_toosmall;		/* not enough data */
93*57433Sandrew 	u_long	ips_badhlen;		/* ip header length < data size */
94*57433Sandrew 	u_long	ips_badlen;		/* ip length < ip header length */
95*57433Sandrew 	u_long	ips_fragments;		/* fragments received */
96*57433Sandrew 	u_long	ips_fragdropped;	/* frags dropped (dups, out of space) */
97*57433Sandrew 	u_long	ips_fragtimeout;	/* fragments timed out */
98*57433Sandrew 	u_long	ips_forward;		/* packets forwarded */
99*57433Sandrew 	u_long	ips_cantforward;	/* packets rcvd for unreachable dest */
100*57433Sandrew 	u_long	ips_redirectsent;	/* packets forwarded on same net */
101*57433Sandrew 	u_long	ips_noproto;		/* unknown or unsupported protocol */
102*57433Sandrew 	u_long	ips_delivered;		/* datagrams delivered to upper level*/
103*57433Sandrew 	u_long	ips_localout;		/* total ip packets generated here */
104*57433Sandrew 	u_long	ips_odropped;		/* lost packets due to nobufs, etc. */
105*57433Sandrew 	u_long	ips_reassembled;	/* total packets reassembled ok */
106*57433Sandrew 	u_long	ips_fragmented;		/* datagrams sucessfully fragmented */
107*57433Sandrew 	u_long	ips_ofragments;		/* output fragments created */
108*57433Sandrew 	u_long	ips_cantfrag;		/* don't fragment flag was set, etc. */
109*57433Sandrew 	u_long	ips_badoptions;		/* error in option processing */
110*57433Sandrew 	u_long	ips_noroute;		/* packtes discarded due to no route */
1114924Swnj };
1124924Swnj 
1134893Swnj #ifdef KERNEL
11412418Ssam /* flags passed to ip_output as last parameter */
11517051Skarels #define	IP_FORWARDING		0x1		/* most of ip header exists */
11617051Skarels #define	IP_ROUTETOIF		SO_DONTROUTE	/* bypass routing tables */
11717051Skarels #define	IP_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
11812418Ssam 
1194924Swnj struct	ipstat	ipstat;
1204893Swnj struct	ipq	ipq;			/* ip reass. queue */
1214893Swnj u_short	ip_id;				/* ip packet ctr, for ids */
12224815Skarels 
12324815Skarels struct	mbuf *ip_srcroute();
1244893Swnj #endif
125