1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef _LINUX_IP_H
18#define _LINUX_IP_H
19#include <asm/byteorder.h>
20
21#define IPTOS_TOS_MASK 0x1E
22#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
23#define IPTOS_LOWDELAY 0x10
24#define IPTOS_THROUGHPUT 0x08
25#define IPTOS_RELIABILITY 0x04
26#define IPTOS_MINCOST 0x02
27
28#define IPTOS_PREC_MASK 0xE0
29#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
30#define IPTOS_PREC_NETCONTROL 0xe0
31#define IPTOS_PREC_INTERNETCONTROL 0xc0
32#define IPTOS_PREC_CRITIC_ECP 0xa0
33#define IPTOS_PREC_FLASHOVERRIDE 0x80
34#define IPTOS_PREC_FLASH 0x60
35#define IPTOS_PREC_IMMEDIATE 0x40
36#define IPTOS_PREC_PRIORITY 0x20
37#define IPTOS_PREC_ROUTINE 0x00
38
39
40
41#define IPOPT_COPY 0x80
42#define IPOPT_CLASS_MASK 0x60
43#define IPOPT_NUMBER_MASK 0x1f
44
45#define IPOPT_COPIED(o) ((o)&IPOPT_COPY)
46#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK)
47#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK)
48
49#define IPOPT_CONTROL 0x00
50#define IPOPT_RESERVED1 0x20
51#define IPOPT_MEASUREMENT 0x40
52#define IPOPT_RESERVED2 0x60
53
54#define IPOPT_END (0 |IPOPT_CONTROL)
55#define IPOPT_NOOP (1 |IPOPT_CONTROL)
56#define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY)
57#define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY)
58#define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT)
59#define IPOPT_RR (7 |IPOPT_CONTROL)
60#define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY)
61#define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY)
62#define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY)
63
64#define IPVERSION 4
65#define MAXTTL 255
66#define IPDEFTTL 64
67
68#define IPOPT_OPTVAL 0
69#define IPOPT_OLEN 1
70#define IPOPT_OFFSET 2
71#define IPOPT_MINOFF 4
72#define MAX_IPOPTLEN 40
73#define IPOPT_NOP IPOPT_NOOP
74#define IPOPT_EOL IPOPT_END
75#define IPOPT_TS IPOPT_TIMESTAMP
76
77#define IPOPT_TS_TSONLY 0
78#define IPOPT_TS_TSANDADDR 1
79#define IPOPT_TS_PRESPEC 3
80
81#ifdef __KERNEL__
82#include <linux/config.h>
83#include <linux/types.h>
84#include <net/sock.h>
85#include <linux/igmp.h>
86#include <net/flow.h>
87
88struct ip_options {
89 __u32 faddr;
90 unsigned char optlen;
91 unsigned char srr;
92 unsigned char rr;
93 unsigned char ts;
94 unsigned char is_setbyuser:1,
95 is_data:1,
96 is_strictroute:1,
97 srr_is_hit:1,
98 is_changed:1,
99 rr_needaddr:1,
100 ts_needtime:1,
101 ts_needaddr:1;
102 unsigned char router_alert;
103 unsigned char __pad1;
104 unsigned char __pad2;
105 unsigned char __data[0];
106};
107
108#define optlength(opt) (sizeof(struct ip_options) + opt->optlen)
109
110struct inet_opt {
111
112 __u32 daddr;
113 __u32 rcv_saddr;
114 __u16 dport;
115 __u16 num;
116 __u32 saddr;
117 int uc_ttl;
118 int tos;
119 unsigned cmsg_flags;
120 struct ip_options *opt;
121 __u16 sport;
122 unsigned char hdrincl;
123 __u8 mc_ttl;
124 __u8 mc_loop;
125 __u8 pmtudisc;
126 __u16 id;
127 unsigned recverr : 1,
128 freebind : 1;
129 int mc_index;
130 __u32 mc_addr;
131 struct ip_mc_socklist *mc_list;
132 struct page *sndmsg_page;
133 u32 sndmsg_off;
134
135
136
137
138 struct {
139 unsigned int flags;
140 unsigned int fragsize;
141 struct ip_options *opt;
142 struct rtable *rt;
143 int length;
144 u32 addr;
145 struct flowi fl;
146 } cork;
147};
148
149#define IPCORK_OPT 1
150
151struct ipv6_pinfo;
152
153
154struct inet_sock {
155 struct sock sk;
156#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
157 struct ipv6_pinfo *pinet6;
158#endif
159 struct inet_opt inet;
160};
161
162static inline struct inet_opt * inet_sk(const struct sock *__sk)
163{
164 return &((struct inet_sock *)__sk)->inet;
165}
166
167#endif
168
169struct iphdr {
170#if defined(__LITTLE_ENDIAN_BITFIELD)
171 __u8 ihl:4,
172 version:4;
173#elif defined (__BIG_ENDIAN_BITFIELD)
174 __u8 version:4,
175 ihl:4;
176#else
177#error "Please fix <asm/byteorder.h>"
178#endif
179 __u8 tos;
180 __u16 tot_len;
181 __u16 id;
182 __u16 frag_off;
183 __u8 ttl;
184 __u8 protocol;
185 __u16 check;
186 __u32 saddr;
187 __u32 daddr;
188
189};
190
191struct ip_auth_hdr {
192 __u8 nexthdr;
193 __u8 hdrlen;
194 __u16 reserved;
195 __u32 spi;
196 __u32 seq_no;
197 __u8 auth_data[0];
198};
199
200struct ip_esp_hdr {
201 __u32 spi;
202 __u32 seq_no;
203 __u8 enc_data[0];
204};
205
206struct ip_comp_hdr {
207 __u8 nexthdr;
208 __u8 flags;
209 __u16 cpi;
210};
211
212#endif
213