xref: /illumos-gate/usr/src/uts/common/netinet/ip_var.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1997-2001 by Sun Microsystems, Inc.
3*7c478bd9Sstevel@tonic-gate  * All rights reserved.
4*7c478bd9Sstevel@tonic-gate  */
6*7c478bd9Sstevel@tonic-gate /*
7*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1982, 1986 Regents of the University of California.
8*7c478bd9Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
9*7c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
10*7c478bd9Sstevel@tonic-gate  */
12*7c478bd9Sstevel@tonic-gate /*
13*7c478bd9Sstevel@tonic-gate  * Overlay for ip header used by other protocols (tcp, udp).
14*7c478bd9Sstevel@tonic-gate  */
16*7c478bd9Sstevel@tonic-gate #ifndef	_NETINET_IP_VAR_H
17*7c478bd9Sstevel@tonic-gate #define	_NETINET_IP_VAR_H
19*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
20*7c478bd9Sstevel@tonic-gate /* ip_var.h 1.11 88/08/19 SMI; from UCB 7.1 6/5/86	*/
22*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
24*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
25*7c478bd9Sstevel@tonic-gate extern "C" {
26*7c478bd9Sstevel@tonic-gate #endif
28*7c478bd9Sstevel@tonic-gate struct ipovly {
29*7c478bd9Sstevel@tonic-gate #ifdef _LP64
30*7c478bd9Sstevel@tonic-gate 	uint32_t	ih_next, ih_prev;
31*7c478bd9Sstevel@tonic-gate #else
32*7c478bd9Sstevel@tonic-gate 	caddr_t	ih_next, ih_prev;	/* for protocol sequence q's */
33*7c478bd9Sstevel@tonic-gate #endif
34*7c478bd9Sstevel@tonic-gate 	uchar_t	ih_x1;			/* (unused) */
35*7c478bd9Sstevel@tonic-gate 	uchar_t	ih_pr;			/* protocol */
36*7c478bd9Sstevel@tonic-gate 	short	ih_len;			/* protocol length */
37*7c478bd9Sstevel@tonic-gate 	struct	in_addr ih_src;		/* source internet address */
38*7c478bd9Sstevel@tonic-gate 	struct	in_addr ih_dst;		/* destination internet address */
39*7c478bd9Sstevel@tonic-gate };
41*7c478bd9Sstevel@tonic-gate /*
42*7c478bd9Sstevel@tonic-gate  * Ip reassembly queue structure.  Each fragment
43*7c478bd9Sstevel@tonic-gate  * being reassembled is attached to one of these structures.
44*7c478bd9Sstevel@tonic-gate  * They are timed out after ipq_ttl drops to 0, and may also
45*7c478bd9Sstevel@tonic-gate  * be reclaimed if memory becomes tight.
46*7c478bd9Sstevel@tonic-gate  */
47*7c478bd9Sstevel@tonic-gate struct ipq {
48*7c478bd9Sstevel@tonic-gate 	struct	ipq *next, *prev;	/* to other reass headers */
49*7c478bd9Sstevel@tonic-gate 	uchar_t	ipq_ttl;		/* time for reass q to live */
50*7c478bd9Sstevel@tonic-gate 	uchar_t	ipq_p;			/* protocol of this fragment */
51*7c478bd9Sstevel@tonic-gate 	ushort_t ipq_id;		/* sequence id for reassembly */
52*7c478bd9Sstevel@tonic-gate 	struct	ipasfrag *ipq_next, *ipq_prev;
53*7c478bd9Sstevel@tonic-gate 					/* to ip headers of fragments */
54*7c478bd9Sstevel@tonic-gate 	struct	in_addr ipq_src, ipq_dst;
55*7c478bd9Sstevel@tonic-gate };
57*7c478bd9Sstevel@tonic-gate /*
58*7c478bd9Sstevel@tonic-gate  * Ip header, when holding a fragment.
59*7c478bd9Sstevel@tonic-gate  *
60*7c478bd9Sstevel@tonic-gate  * Note: ipf_next must be at same offset as ipq_next above
61*7c478bd9Sstevel@tonic-gate  */
62*7c478bd9Sstevel@tonic-gate struct	ipasfrag {
63*7c478bd9Sstevel@tonic-gate #ifdef _BIT_FIELDS_LTOH
64*7c478bd9Sstevel@tonic-gate 	uchar_t	ip_hl:4,
65*7c478bd9Sstevel@tonic-gate 		ip_v:4;
66*7c478bd9Sstevel@tonic-gate #else
67*7c478bd9Sstevel@tonic-gate 	uchar_t	ip_v:4,
68*7c478bd9Sstevel@tonic-gate 		ip_hl:4;
69*7c478bd9Sstevel@tonic-gate #endif
70*7c478bd9Sstevel@tonic-gate 	uchar_t	ipf_mff;		/* copied from (ip_off&IP_MF) */
71*7c478bd9Sstevel@tonic-gate 	short	ip_len;
72*7c478bd9Sstevel@tonic-gate 	ushort_t ip_id;
73*7c478bd9Sstevel@tonic-gate 	short	ip_off;
74*7c478bd9Sstevel@tonic-gate 	uchar_t	ip_ttl;
75*7c478bd9Sstevel@tonic-gate 	uchar_t	ip_p;
76*7c478bd9Sstevel@tonic-gate 	ushort_t ip_sum;
77*7c478bd9Sstevel@tonic-gate 	struct	ipasfrag *ipf_next;	/* next fragment */
78*7c478bd9Sstevel@tonic-gate 	struct	ipasfrag *ipf_prev;	/* previous fragment */
79*7c478bd9Sstevel@tonic-gate };
81*7c478bd9Sstevel@tonic-gate /*
82*7c478bd9Sstevel@tonic-gate  * Structure stored in mbuf in inpcb.ip_options
83*7c478bd9Sstevel@tonic-gate  * and passed to ip_output when ip options are in use.
84*7c478bd9Sstevel@tonic-gate  * The actual length of the options (including ipopt_dst)
85*7c478bd9Sstevel@tonic-gate  * is in m_len.
86*7c478bd9Sstevel@tonic-gate  */
87*7c478bd9Sstevel@tonic-gate #define	MAX_IPOPTLEN	40
89*7c478bd9Sstevel@tonic-gate struct ipoption {
90*7c478bd9Sstevel@tonic-gate 	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
91*7c478bd9Sstevel@tonic-gate 	char	ipopt_list[MAX_IPOPTLEN];	/* options proper */
92*7c478bd9Sstevel@tonic-gate };
94*7c478bd9Sstevel@tonic-gate struct	ipstat {
95*7c478bd9Sstevel@tonic-gate 	long	ips_total;		/* total packets received */
96*7c478bd9Sstevel@tonic-gate 	long	ips_badsum;		/* checksum bad */
97*7c478bd9Sstevel@tonic-gate 	long	ips_tooshort;		/* packet too short */
98*7c478bd9Sstevel@tonic-gate 	long	ips_toosmall;		/* not enough data */
99*7c478bd9Sstevel@tonic-gate 	long	ips_badhlen;		/* ip header length < data size */
100*7c478bd9Sstevel@tonic-gate 	long	ips_badlen;		/* ip length < ip header length */
101*7c478bd9Sstevel@tonic-gate 	long	ips_fragments;		/* fragments received */
102*7c478bd9Sstevel@tonic-gate 	long	ips_fragdropped;	/* frags dropped (dups, out of space) */
103*7c478bd9Sstevel@tonic-gate 	long	ips_fragtimeout;	/* fragments timed out */
104*7c478bd9Sstevel@tonic-gate 	long	ips_forward;		/* packets forwarded */
105*7c478bd9Sstevel@tonic-gate 	long	ips_cantforward;	/* packets rcvd for unreachable dest */
106*7c478bd9Sstevel@tonic-gate 	long	ips_redirectsent;	/* packets forwarded on same net */
107*7c478bd9Sstevel@tonic-gate };
109*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
110*7c478bd9Sstevel@tonic-gate /* flags passed to ip_output as last parameter */
111*7c478bd9Sstevel@tonic-gate #define	IP_FORWARDING		0x1		/* most of ip header exists */
112*7c478bd9Sstevel@tonic-gate #define	IP_ROUTETOIF		SO_DONTROUTE	/* bypass routing tables */
113*7c478bd9Sstevel@tonic-gate #define	IP_ALLOWBROADCAST	SO_BROADCAST	/* can send broadcast packets */
114*7c478bd9Sstevel@tonic-gate #endif
116*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
117*7c478bd9Sstevel@tonic-gate }
118*7c478bd9Sstevel@tonic-gate #endif
120*7c478bd9Sstevel@tonic-gate #endif	/* _NETINET_IP_VAR_H */