[PATCH] some more av7110 dvb-driver updates
[linux-2.6/history.git] / include / linux / ip.h
blobac117b884331a0a21d4fd8e6998299c06619d0ce
1 /*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * Definitions for the IP protocol.
8 * Version: @(#)ip.h 1.0.2 04/28/93
10 * Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
17 #ifndef _LINUX_IP_H
18 #define _LINUX_IP_H
19 #include <asm/byteorder.h>
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
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
40 /* IP options */
41 #define IPOPT_COPY 0x80
42 #define IPOPT_CLASS_MASK 0x60
43 #define IPOPT_NUMBER_MASK 0x1f
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)
49 #define IPOPT_CONTROL 0x00
50 #define IPOPT_RESERVED1 0x20
51 #define IPOPT_MEASUREMENT 0x40
52 #define IPOPT_RESERVED2 0x60
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)
64 #define IPVERSION 4
65 #define MAXTTL 255
66 #define IPDEFTTL 64
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
77 #define IPOPT_TS_TSONLY 0 /* timestamps only */
78 #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
79 #define IPOPT_TS_PRESPEC 3 /* specified modules only */
81 #ifdef __KERNEL__
82 #include <linux/config.h>
83 #include <linux/types.h>
84 #include <net/sock.h>
85 #include <linux/igmp.h>
87 struct ip_options {
88 __u32 faddr; /* Saved first hop address */
89 unsigned char optlen;
90 unsigned char srr;
91 unsigned char rr;
92 unsigned char ts;
93 unsigned char is_setbyuser:1, /* Set by setsockopt? */
94 is_data:1, /* Options in __data, rather than skb */
95 is_strictroute:1, /* Strict source route */
96 srr_is_hit:1, /* Packet destination addr was our one */
97 is_changed:1, /* IP checksum more not valid */
98 rr_needaddr:1, /* Need to record addr of outgoing dev */
99 ts_needtime:1, /* Need to record timestamp */
100 ts_needaddr:1; /* Need to record addr of outgoing dev */
101 unsigned char router_alert;
102 unsigned char __pad1;
103 unsigned char __pad2;
104 unsigned char __data[0];
107 #define optlength(opt) (sizeof(struct ip_options) + opt->optlen)
109 struct inet_opt {
110 /* Socket demultiplex comparisons on incoming packets. */
111 __u32 daddr; /* Foreign IPv4 addr */
112 __u32 rcv_saddr; /* Bound local IPv4 addr */
113 __u16 dport; /* Destination port */
114 __u16 num; /* Local port */
115 __u32 saddr; /* Sending source */
116 int uc_ttl; /* Unicast TTL */
117 int tos; /* TOS */
118 unsigned cmsg_flags;
119 struct ip_options *opt;
120 __u16 sport; /* Source port */
121 unsigned char hdrincl; /* Include headers ? */
122 __u8 mc_ttl; /* Multicasting TTL */
123 __u8 mc_loop; /* Loopback */
124 __u8 pmtudisc;
125 __u16 id; /* ID counter for DF pkts */
126 unsigned recverr : 1,
127 freebind : 1;
128 int mc_index; /* Multicast device index */
129 __u32 mc_addr;
130 struct ip_mc_socklist *mc_list; /* Group array */
131 struct page *sndmsg_page; /* Cached page for sendmsg */
132 u32 sndmsg_off; /* Cached offset for sendmsg */
134 * Following members are used to retain the infomation to build
135 * an ip header on each ip fragmentation while the socket is corked.
137 struct {
138 unsigned int flags;
139 unsigned int fragsize;
140 struct ip_options *opt;
141 struct rtable *rt;
142 int length; /* Total length of all frames */
143 u32 addr;
144 } cork;
147 #define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */
149 struct ipv6_pinfo;
151 /* WARNING: don't change the layout of the members in inet_sock! */
152 struct inet_sock {
153 struct sock sk;
154 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
155 struct ipv6_pinfo *pinet6;
156 #endif
157 struct inet_opt inet;
160 #define inet_sk(__sk) (&((struct inet_sock *)__sk)->inet)
162 #endif
164 struct iphdr {
165 #if defined(__LITTLE_ENDIAN_BITFIELD)
166 __u8 ihl:4,
167 version:4;
168 #elif defined (__BIG_ENDIAN_BITFIELD)
169 __u8 version:4,
170 ihl:4;
171 #else
172 #error "Please fix <asm/byteorder.h>"
173 #endif
174 __u8 tos;
175 __u16 tot_len;
176 __u16 id;
177 __u16 frag_off;
178 __u8 ttl;
179 __u8 protocol;
180 __u16 check;
181 __u32 saddr;
182 __u32 daddr;
183 /*The options start here. */
186 struct ip_auth_hdr {
187 __u8 nexthdr;
188 __u8 hdrlen; /* This one is measured in 32 bit units! */
189 __u16 reserved;
190 __u32 spi;
191 __u32 seq_no; /* Sequence number */
192 __u8 auth_data[0]; /* Variable len but >=4. Mind the 64 bit alignment! */
195 struct ip_esp_hdr {
196 __u32 spi;
197 __u32 seq_no; /* Sequence number */
198 __u8 enc_data[0]; /* Variable len but >=8. Mind the 64 bit alignment! */
201 struct ip_comp_hdr {
202 __u8 nexthdr;
203 __u8 flags;
204 __u16 cpi;
207 #endif /* _LINUX_IP_H */