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