OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [net/] [ipv6.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *      Linux INET6 implementation
3
 *
4
 *      Authors:
5
 *      Pedro Roque             <roque@di.fc.ul.pt>
6
 *
7
 *      $Id: ipv6.h,v 1.1.1.1 2004-04-15 02:34:20 phoenix Exp $
8
 *
9
 *      This program is free software; you can redistribute it and/or
10
 *      modify it under the terms of the GNU General Public License
11
 *      as published by the Free Software Foundation; either version
12
 *      2 of the License, or (at your option) any later version.
13
 */
14
 
15
#ifndef _NET_IPV6_H
16
#define _NET_IPV6_H
17
 
18
#include <linux/ipv6.h>
19
#include <asm/hardirq.h>
20
#include <net/ndisc.h>
21
#include <net/flow.h>
22
 
23
#define SIN6_LEN_RFC2133        24
24
 
25
/*
26
 *      NextHeader field of IPv6 header
27
 */
28
 
29
#define NEXTHDR_HOP             0        /* Hop-by-hop option header. */
30
#define NEXTHDR_TCP             6       /* TCP segment. */
31
#define NEXTHDR_UDP             17      /* UDP message. */
32
#define NEXTHDR_IPV6            41      /* IPv6 in IPv6 */
33
#define NEXTHDR_ROUTING         43      /* Routing header. */
34
#define NEXTHDR_FRAGMENT        44      /* Fragmentation/reassembly header. */
35
#define NEXTHDR_ESP             50      /* Encapsulating security payload. */
36
#define NEXTHDR_AUTH            51      /* Authentication header. */
37
#define NEXTHDR_ICMP            58      /* ICMP for IPv6. */
38
#define NEXTHDR_NONE            59      /* No next header */
39
#define NEXTHDR_DEST            60      /* Destination options header. */
40
 
41
#define NEXTHDR_MAX             255
42
 
43
 
44
 
45
#define IPV6_DEFAULT_HOPLIMIT   64
46
#define IPV6_DEFAULT_MCASTHOPS  1
47
 
48
/*
49
 *      Addr type
50
 *
51
 *      type    -       unicast | multicast | anycast
52
 *      scope   -       local   | site      | global
53
 *      v4      -       compat
54
 *      v4mapped
55
 *      any
56
 *      loopback
57
 */
58
 
59
#define IPV6_ADDR_ANY           0x0000U
60
 
61
#define IPV6_ADDR_UNICAST       0x0001U 
62
#define IPV6_ADDR_MULTICAST     0x0002U 
63
#define IPV6_ADDR_ANYCAST       0x0004U
64
 
65
#define IPV6_ADDR_LOOPBACK      0x0010U
66
#define IPV6_ADDR_LINKLOCAL     0x0020U
67
#define IPV6_ADDR_SITELOCAL     0x0040U
68
 
69
#define IPV6_ADDR_COMPATv4      0x0080U
70
 
71
#define IPV6_ADDR_SCOPE_MASK    0x00f0U
72
 
73
#define IPV6_ADDR_MAPPED        0x1000U
74
#define IPV6_ADDR_RESERVED      0x2000U /* reserved address space */
75
 
76
/*
77
 *      Addr scopes
78
 */
79
#ifdef __KERNEL__
80
#define IPV6_ADDR_MC_SCOPE(a)   \
81
        ((a)->s6_addr[1] & 0x0f)        /* nonstandard */
82
#define __IPV6_ADDR_SCOPE_INVALID       -1
83
#endif
84
#define IPV6_ADDR_SCOPE_NODELOCAL       0x01
85
#define IPV6_ADDR_SCOPE_LINKLOCAL       0x02
86
#define IPV6_ADDR_SCOPE_SITELOCAL       0x05
87
#define IPV6_ADDR_SCOPE_ORGLOCAL        0x08
88
#define IPV6_ADDR_SCOPE_GLOBAL          0x0e
89
 
90
/*
91
 *      fragmentation header
92
 */
93
 
94
struct frag_hdr {
95
        unsigned char   nexthdr;
96
        unsigned char   reserved;
97
        unsigned short  frag_off;
98
        __u32           identification;
99
};
100
 
101
#ifdef __KERNEL__
102
 
103
#include <net/sock.h>
104
 
105
/* sysctls */
106
extern int sysctl_ipv6_bindv6only;
107
extern int sysctl_mld_max_msf;
108
 
109
extern struct ipv6_mib          ipv6_statistics[NR_CPUS*2];
110
#define IP6_INC_STATS(field)            SNMP_INC_STATS(ipv6_statistics, field)
111
#define IP6_INC_STATS_BH(field)         SNMP_INC_STATS_BH(ipv6_statistics, field)
112
#define IP6_INC_STATS_USER(field)       SNMP_INC_STATS_USER(ipv6_statistics, field)
113
extern struct icmpv6_mib        icmpv6_statistics[NR_CPUS*2];
114
#define ICMP6_INC_STATS(field)          SNMP_INC_STATS(icmpv6_statistics, field)
115
#define ICMP6_INC_STATS_BH(field)       SNMP_INC_STATS_BH(icmpv6_statistics, field)
116
#define ICMP6_INC_STATS_USER(field)     SNMP_INC_STATS_USER(icmpv6_statistics, field)
117
extern struct udp_mib           udp_stats_in6[NR_CPUS*2];
118
#define UDP6_INC_STATS(field)           SNMP_INC_STATS(udp_stats_in6, field)
119
#define UDP6_INC_STATS_BH(field)        SNMP_INC_STATS_BH(udp_stats_in6, field)
120
#define UDP6_INC_STATS_USER(field)      SNMP_INC_STATS_USER(udp_stats_in6, field)
121
extern atomic_t                 inet6_sock_nr;
122
 
123
struct ip6_ra_chain
124
{
125
        struct ip6_ra_chain     *next;
126
        struct sock             *sk;
127
        int                     sel;
128
        void                    (*destructor)(struct sock *);
129
};
130
 
131
extern struct ip6_ra_chain      *ip6_ra_chain;
132
extern rwlock_t ip6_ra_lock;
133
 
134
/*
135
   This structure is prepared by protocol, when parsing
136
   ancillary data and passed to IPv6.
137
 */
138
 
139
struct ipv6_txoptions
140
{
141
        /* Length of this structure */
142
        int                     tot_len;
143
 
144
        /* length of extension headers   */
145
 
146
        __u16                   opt_flen;       /* after fragment hdr */
147
        __u16                   opt_nflen;      /* before fragment hdr */
148
 
149
        struct ipv6_opt_hdr     *hopopt;
150
        struct ipv6_opt_hdr     *dst0opt;
151
        struct ipv6_rt_hdr      *srcrt; /* Routing Header */
152
        struct ipv6_opt_hdr     *auth;
153
        struct ipv6_opt_hdr     *dst1opt;
154
 
155
        /* Option buffer, as read by IPV6_PKTOPTIONS, starts here. */
156
};
157
 
158
struct ip6_flowlabel
159
{
160
        struct ip6_flowlabel    *next;
161
        u32                     label;
162
        struct in6_addr         dst;
163
        struct ipv6_txoptions   *opt;
164
        atomic_t                users;
165
        u32                     linger;
166
        u8                      share;
167
        u32                     owner;
168
        unsigned long           lastuse;
169
        unsigned long           expires;
170
};
171
 
172
#define IPV6_FLOWINFO_MASK      __constant_htonl(0x0FFFFFFF)
173
#define IPV6_FLOWLABEL_MASK     __constant_htonl(0x000FFFFF)
174
 
175
struct ipv6_fl_socklist
176
{
177
        struct ipv6_fl_socklist *next;
178
        struct ip6_flowlabel    *fl;
179
};
180
 
181
extern struct ip6_flowlabel     *fl6_sock_lookup(struct sock *sk, u32 label);
182
extern struct ipv6_txoptions    *fl6_merge_options(struct ipv6_txoptions * opt_space,
183
                                                   struct ip6_flowlabel * fl,
184
                                                   struct ipv6_txoptions * fopt);
185
extern void                     fl6_free_socklist(struct sock *sk);
186
extern int                      ipv6_flowlabel_opt(struct sock *sk, char *optval, int optlen);
187
extern void                     ip6_flowlabel_init(void);
188
extern void                     ip6_flowlabel_cleanup(void);
189
 
190
static inline void fl6_sock_release(struct ip6_flowlabel *fl)
191
{
192
        if (fl)
193
                atomic_dec(&fl->users);
194
}
195
 
196
extern int                      ip6_ra_control(struct sock *sk, int sel,
197
                                               void (*destructor)(struct sock *));
198
 
199
 
200
extern int                      ip6_call_ra_chain(struct sk_buff *skb, int sel);
201
 
202
extern int                      ipv6_reassembly(struct sk_buff **skb, int);
203
 
204
extern int                      ipv6_parse_hopopts(struct sk_buff *skb, int);
205
 
206
extern int                      ipv6_parse_exthdrs(struct sk_buff **skb, int);
207
 
208
extern struct ipv6_txoptions *  ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt);
209
 
210
extern int ip6_frag_nqueues;
211
extern atomic_t ip6_frag_mem;
212
 
213
#define IPV6_FRAG_TIMEOUT       (60*HZ)         /* 60 seconds */
214
 
215
/*
216
 *      Function prototype for build_xmit
217
 */
218
 
219
typedef int             (*inet_getfrag_t) (const void *data,
220
                                           struct in6_addr *addr,
221
                                           char *,
222
                                           unsigned int, unsigned int);
223
 
224
 
225
extern int              ipv6_addr_type(const struct in6_addr *addr);
226
 
227
static inline int ipv6_addr_scope(const struct in6_addr *addr)
228
{
229
        return ipv6_addr_type(addr) & IPV6_ADDR_SCOPE_MASK;
230
}
231
 
232
static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2)
233
{
234
        return memcmp((const void *) a1, (const void *) a2, sizeof(struct in6_addr));
235
}
236
 
237
static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2)
238
{
239
        memcpy((void *) a1, (const void *) a2, sizeof(struct in6_addr));
240
}
241
 
242
#ifndef __HAVE_ARCH_ADDR_SET
243
static inline void ipv6_addr_set(struct in6_addr *addr,
244
                                     __u32 w1, __u32 w2,
245
                                     __u32 w3, __u32 w4)
246
{
247
        addr->s6_addr32[0] = w1;
248
        addr->s6_addr32[1] = w2;
249
        addr->s6_addr32[2] = w3;
250
        addr->s6_addr32[3] = w4;
251
}
252
#endif
253
 
254
static inline int ipv6_addr_any(const struct in6_addr *a)
255
{
256
        return ((a->s6_addr32[0] | a->s6_addr32[1] |
257
                 a->s6_addr32[2] | a->s6_addr32[3] ) == 0);
258
}
259
 
260
/*
261
 *      Prototypes exported by ipv6
262
 */
263
 
264
/*
265
 *      rcv function (called from netdevice level)
266
 */
267
 
268
extern int                      ipv6_rcv(struct sk_buff *skb,
269
                                         struct net_device *dev,
270
                                         struct packet_type *pt);
271
 
272
/*
273
 *      upper-layer output functions
274
 */
275
extern int                      ip6_xmit(struct sock *sk,
276
                                         struct sk_buff *skb,
277
                                         struct flowi *fl,
278
                                         struct ipv6_txoptions *opt);
279
 
280
extern int                      ip6_nd_hdr(struct sock *sk,
281
                                           struct sk_buff *skb,
282
                                           struct net_device *dev,
283
                                           struct in6_addr *saddr,
284
                                           struct in6_addr *daddr,
285
                                           int proto, int len);
286
 
287
extern int                      ip6_build_xmit(struct sock *sk,
288
                                               inet_getfrag_t getfrag,
289
                                               const void *data,
290
                                               struct flowi *fl,
291
                                               unsigned length,
292
                                               struct ipv6_txoptions *opt,
293
                                               int hlimit, int flags);
294
 
295
/*
296
 *      skb processing functions
297
 */
298
 
299
extern int                      ip6_output(struct sk_buff *skb);
300
extern int                      ip6_forward(struct sk_buff *skb);
301
extern int                      ip6_input(struct sk_buff *skb);
302
extern int                      ip6_mc_input(struct sk_buff *skb);
303
 
304
/*
305
 *      Extension header (options) processing
306
 */
307
 
308
extern u8 *                     ipv6_build_nfrag_opts(struct sk_buff *skb,
309
                                                      u8 *prev_hdr,
310
                                                      struct ipv6_txoptions *opt,
311
                                                      struct in6_addr *daddr,
312
                                                      u32 jumbolen);
313
extern u8 *                     ipv6_build_frag_opts(struct sk_buff *skb,
314
                                                     u8 *prev_hdr,
315
                                                     struct ipv6_txoptions *opt);
316
extern void                     ipv6_push_nfrag_opts(struct sk_buff *skb,
317
                                                     struct ipv6_txoptions *opt,
318
                                                     u8 *proto,
319
                                                     struct in6_addr **daddr_p);
320
extern void                     ipv6_push_frag_opts(struct sk_buff *skb,
321
                                                    struct ipv6_txoptions *opt,
322
                                                    u8 *proto);
323
 
324
extern int                      ipv6_skip_exthdr(const struct sk_buff *, int start,
325
                                                 u8 *nexthdrp, int len);
326
 
327
extern int                      ipv6_ext_hdr(u8 nexthdr);
328
 
329
extern struct ipv6_txoptions *  ipv6_invert_rthdr(struct sock *sk,
330
                                                  struct ipv6_rt_hdr *hdr);
331
 
332
 
333
/*
334
 *      socket options (ipv6_sockglue.c)
335
 */
336
 
337
extern int                      ipv6_setsockopt(struct sock *sk, int level,
338
                                                int optname, char *optval,
339
                                                int optlen);
340
extern int                      ipv6_getsockopt(struct sock *sk, int level,
341
                                                int optname, char *optval,
342
                                                int *optlen);
343
 
344
extern void                     ipv6_packet_init(void);
345
 
346
extern void                     ipv6_netdev_notif_init(void);
347
 
348
extern void                     ipv6_packet_cleanup(void);
349
 
350
extern void                     ipv6_netdev_notif_cleanup(void);
351
 
352
extern int                      ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len);
353
extern void                     ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port,
354
                                                u32 info, u8 *payload);
355
extern void                     ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info);
356
 
357
extern int inet6_release(struct socket *sock);
358
extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr,
359
                      int addr_len);
360
extern int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
361
                         int *uaddr_len, int peer);
362
extern int inet6_ioctl(struct socket *sock, unsigned int cmd,
363
                       unsigned long arg);
364
 
365
#endif /* __KERNEL__ */
366
#endif /* _NET_IPV6_H */
367
 
368
 
369
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.