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