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