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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [include/] [netinet6/] [ip6.h] - Blame information for rev 307

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      include/netinet6_ipv6.h
4
//
5
//      
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
 
33
/*      $OpenBSD: ip6.h,v 1.1 1999/12/08 06:50:21 itojun Exp $  */
34
 
35
/*
36
 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
37
 * All rights reserved.
38
 *
39
 * Redistribution and use in source and binary forms, with or without
40
 * modification, are permitted provided that the following conditions
41
 * are met:
42
 * 1. Redistributions of source code must retain the above copyright
43
 *    notice, this list of conditions and the following disclaimer.
44
 * 2. Redistributions in binary form must reproduce the above copyright
45
 *    notice, this list of conditions and the following disclaimer in the
46
 *    documentation and/or other materials provided with the distribution.
47
 * 3. Neither the name of the project nor the names of its contributors
48
 *    may be used to endorse or promote products derived from this software
49
 *    without specific prior written permission.
50
 *
51
 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
52
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
55
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61
 * SUCH DAMAGE.
62
 */
63
 
64
/*
65
 * Copyright (c) 1982, 1986, 1993
66
 *      The Regents of the University of California.  All rights reserved.
67
 *
68
 * Redistribution and use in source and binary forms, with or without
69
 * modification, are permitted provided that the following conditions
70
 * are met:
71
 * 1. Redistributions of source code must retain the above copyright
72
 *    notice, this list of conditions and the following disclaimer.
73
 * 2. Redistributions in binary form must reproduce the above copyright
74
 *    notice, this list of conditions and the following disclaimer in the
75
 *    documentation and/or other materials provided with the distribution.
76
 * 3. All advertising materials mentioning features or use of this software
77
 *    must display the following acknowledgement:
78
 *      This product includes software developed by the University of
79
 *      California, Berkeley and its contributors.
80
 * 4. Neither the name of the University nor the names of its contributors
81
 *    may be used to endorse or promote products derived from this software
82
 *    without specific prior written permission.
83
 *
84
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
85
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
88
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94
 * SUCH DAMAGE.
95
 *
96
 *      @(#)ip.h        8.1 (Berkeley) 6/10/93
97
 */
98
 
99
#ifndef _NETINET6_IPV6_H_
100
#define _NETINET6_IPV6_H_
101
 
102
/*
103
 * Definition for internet protocol version 6.
104
 * RFC 2460
105
 */
106
 
107
struct ip6_hdr {
108
        union {
109
                struct ip6_hdrctl {
110
                        u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */
111
                        u_int16_t ip6_un1_plen; /* payload length */
112
                        u_int8_t  ip6_un1_nxt;  /* next header */
113
                        u_int8_t  ip6_un1_hlim; /* hop limit */
114
                } ip6_un1;
115
                u_int8_t ip6_un2_vfc;   /* 4 bits version, 4 bits class */
116
        } ip6_ctlun;
117
        struct in6_addr ip6_src;        /* source address */
118
        struct in6_addr ip6_dst;        /* destination address */
119
};
120
 
121
#define ip6_vfc         ip6_ctlun.ip6_un2_vfc
122
#define ip6_flow        ip6_ctlun.ip6_un1.ip6_un1_flow
123
#define ip6_plen        ip6_ctlun.ip6_un1.ip6_un1_plen
124
#define ip6_nxt         ip6_ctlun.ip6_un1.ip6_un1_nxt
125
#define ip6_hlim        ip6_ctlun.ip6_un1.ip6_un1_hlim
126
#define ip6_hops        ip6_ctlun.ip6_un1.ip6_un1_hlim
127
 
128
#define IPV6_VERSION            0x60
129
#define IPV6_VERSION_MASK       0xf0
130
 
131
#if BYTE_ORDER == BIG_ENDIAN
132
#define IPV6_FLOWINFO_MASK      0x0fffffff      /* flow info (28 bits) */
133
#define IPV6_FLOWLABEL_MASK     0x000fffff      /* flow label (20 bits) */
134
#else
135
#if BYTE_ORDER == LITTLE_ENDIAN
136
#define IPV6_FLOWINFO_MASK      0xffffff0f      /* flow info (28 bits) */
137
#define IPV6_FLOWLABEL_MASK     0xffff0f00      /* flow label (20 bits) */
138
#endif /* LITTLE_ENDIAN */
139
#endif
140
#if 1
141
/* ECN bits proposed by Sally Floyd */
142
#define IP6TOS_CE               0x01    /* congestion experienced */
143
#define IP6TOS_ECT              0x02    /* ECN-capable transport */
144
#endif
145
 
146
/*
147
 * Extension Headers
148
 */
149
 
150
struct  ip6_ext {
151
        u_char  ip6e_nxt;
152
        u_char  ip6e_len;
153
};
154
 
155
/* Hop-by-Hop options header */
156
/* XXX should we pad it to force alignment on an 8-byte boundary? */
157
struct ip6_hbh {
158
        u_int8_t ip6h_nxt;      /* next header */
159
        u_int8_t ip6h_len;      /* length in units of 8 octets */
160
        /* followed by options */
161
};
162
 
163
/* Destination options header */
164
/* XXX should we pad it to force alignment on an 8-byte boundary? */
165
struct ip6_dest {
166
        u_int8_t ip6d_nxt;      /* next header */
167
        u_int8_t ip6d_len;      /* length in units of 8 octets */
168
        /* followed by options */
169
};
170
 
171
/* Option types and related macros */
172
#define IP6OPT_PAD1             0x00    /* 00 0 00000 */
173
#define IP6OPT_PADN             0x01    /* 00 0 00001 */
174
#define IP6OPT_JUMBO            0xC2    /* 11 0 00010 = 194 */
175
#define IP6OPT_JUMBO_LEN        6
176
#define IP6OPT_RTALERT          0x05    /* 00 0 00101 */
177
#define IP6OPT_RTALERT_LEN      4
178
#define IP6OPT_RTALERT_MLD      0        /* Datagram contains an MLD message */
179
#define IP6OPT_RTALERT_RSVP     1       /* Datagram contains an RSVP message */
180
#define IP6OPT_RTALERT_ACTNET   2       /* contains an Active Networks msg */
181
#define IP6OPT_MINLEN           2
182
 
183
#define IP6OPT_TYPE(o)          ((o) & 0xC0)
184
#define IP6OPT_TYPE_SKIP        0x00
185
#define IP6OPT_TYPE_DISCARD     0x40
186
#define IP6OPT_TYPE_FORCEICMP   0x80
187
#define IP6OPT_TYPE_ICMP        0xC0
188
 
189
#define IP6OPT_MUTABLE          0x20
190
 
191
/* Routing header */
192
struct ip6_rthdr {
193
        u_int8_t  ip6r_nxt;     /* next header */
194
        u_int8_t  ip6r_len;     /* length in units of 8 octets */
195
        u_int8_t  ip6r_type;    /* routing type */
196
        u_int8_t  ip6r_segleft; /* segments left */
197
        /* followed by routing type specific data */
198
};
199
 
200
/* Type 0 Routing header */
201
struct ip6_rthdr0 {
202
        u_int8_t  ip6r0_nxt;            /* next header */
203
        u_int8_t  ip6r0_len;            /* length in units of 8 octets */
204
        u_int8_t  ip6r0_type;           /* always zero */
205
        u_int8_t  ip6r0_segleft;        /* segments left */
206
        u_int8_t  ip6r0_reserved;       /* reserved field */
207
        u_int8_t  ip6r0_slmap[3];       /* strict/loose bit map */
208
        struct in6_addr  ip6r0_addr[1]; /* up to 23 addresses */
209
};
210
 
211
/* Fragment header */
212
struct ip6_frag {
213
        u_int8_t  ip6f_nxt;             /* next header */
214
        u_int8_t  ip6f_reserved;        /* reserved field */
215
        u_int16_t ip6f_offlg;           /* offset, reserved, and flag */
216
        u_int32_t ip6f_ident;           /* identification */
217
};
218
 
219
#if BYTE_ORDER == BIG_ENDIAN
220
#define IP6F_OFF_MASK           0xfff8  /* mask out offset from _offlg */
221
#define IP6F_RESERVED_MASK      0x0006  /* reserved bits in ip6f_offlg */
222
#define IP6F_MORE_FRAG          0x0001  /* more-fragments flag */
223
#else /* BYTE_ORDER == LITTLE_ENDIAN */
224
#define IP6F_OFF_MASK           0xf8ff  /* mask out offset from _offlg */
225
#define IP6F_RESERVED_MASK      0x0600  /* reserved bits in ip6f_offlg */
226
#define IP6F_MORE_FRAG          0x0100  /* more-fragments flag */
227
#endif /* BYTE_ORDER == LITTLE_ENDIAN */
228
 
229
/*
230
 * Internet implementation parameters.
231
 */
232
#define IPV6_MAXHLIM    255     /* maximun hoplimit */
233
#define IPV6_DEFHLIM    64      /* default hlim */
234
#define IPV6_FRAGTTL    120     /* ttl for fragment packets, in slowtimo tick */
235
#define IPV6_HLIMDEC    1       /* subtracted when forwaeding */
236
 
237
#define IPV6_MMTU       1280    /* minimal MTU and reassembly. 1024 + 256 */
238
#define IPV6_MAXPACKET  65535   /* ip6 max packet size without Jumbo payload*/
239
 
240
/*
241
 * IP6_EXTHDR_CHECK ensures that region between the IP6 header and the
242
 * target header (including IPv6 itself, extension headers and
243
 * TCP/UDP/ICMP6 headers) are continuous. KAME requires drivers
244
 * to store incoming data into one internal mbuf or one or more external
245
 * mbufs(never into two or more internal mbufs). Thus, the third case is
246
 * supposed to never be matched but is prepared just in case.
247
 */
248
 
249
#define IP6_EXTHDR_CHECK(m, off, hlen, ret)                             \
250
do {                                                                    \
251
    if ((m)->m_next != NULL) {                                          \
252
        if (((m)->m_flags & M_LOOP) &&                                  \
253
            ((m)->m_len < (off) + (hlen)) &&                            \
254
            (((m) = m_pullup((m), (off) + (hlen))) == NULL)) {          \
255
                ip6stat.ip6s_exthdrtoolong++;                           \
256
                return ret;                                             \
257
        } else if ((m)->m_flags & M_EXT) {                              \
258
                if ((m)->m_len < (off) + (hlen)) {                      \
259
                        ip6stat.ip6s_exthdrtoolong++;                   \
260
                        m_freem(m);                                     \
261
                        return ret;                                     \
262
                }                                                       \
263
        } else {                                                        \
264
                if ((m)->m_len < (off) + (hlen)) {                      \
265
                        ip6stat.ip6s_exthdrtoolong++;                   \
266
                        m_freem(m);                                     \
267
                        return ret;                                     \
268
                }                                                       \
269
        }                                                               \
270
    }                                                                   \
271
    else {                                                              \
272
        if ((m)->m_len < (off) + (hlen)) {                              \
273
                ip6stat.ip6s_tooshort++;                                \
274
                in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);   \
275
                m_freem(m);                                             \
276
                return ret;                                             \
277
        }                                                               \
278
    }                                                                   \
279
} while (0)
280
 
281
#ifdef __NetBSD__
282
/*
283
 * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
284
 * "len") is located in single mbuf, on contiguous memory region.
285
 * The pointer to the region will be returned to pointer variable "val",
286
 * with type "typ".
287
 * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
288
 * very top of mbuf.  GET0 is likely to make memory copy than GET.
289
 *
290
 * XXX we're now testing this, needs m_pulldown()
291
 */
292
#define IP6_EXTHDR_GET(val, typ, m, off, len) \
293
do {                                                                    \
294
        struct mbuf *t;                                                 \
295
        int tmp;                                                        \
296
        t = m_pulldown((m), (off), (len), &tmp);                        \
297
        if (t) {                                                        \
298
                if (t->m_len < tmp + (len))                             \
299
                        panic("m_pulldown malfunction");                \
300
                (val) = (typ)(mtod(t, caddr_t) + tmp);                  \
301
        } else                                                          \
302
                (val) = (typ)NULL;                                      \
303
} while (0)
304
 
305
#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
306
do {                                                                    \
307
        struct mbuf *t;                                                 \
308
        t = m_pulldown((m), (off), (len), NULL);                        \
309
        if (t) {                                                        \
310
                if (t->m_len < (len))                                   \
311
                        panic("m_pulldown malfunction");                \
312
                (val) = (typ)mtod(t, caddr_t);                          \
313
        } else                                                          \
314
                (val) = (typ)NULL;                                      \
315
} while (0)
316
 
317
#endif /*NetBSD*/
318
 
319
#endif /* not _NETINET_IPV6_H_ */

powered by: WebSVN 2.1.0

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