ReactOS 0.4.16-dev-258-g81860b4
ip6.h
Go to the documentation of this file.
1
6/*
7 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 * OF SUCH DAMAGE.
31 *
32 * This file is part of the lwIP TCP/IP stack.
33 *
34 * Author: Adam Dunkels <adam@sics.se>
35 *
36 */
37#ifndef LWIP_HDR_PROT_IP6_H
38#define LWIP_HDR_PROT_IP6_H
39
40#include "lwip/arch.h"
41#include "lwip/ip6_addr.h"
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#define IP6_MIN_MTU_LENGTH 1280
48
51#ifdef PACK_STRUCT_USE_INCLUDES
52# include "arch/bpstruct.h"
53#endif
59#ifdef PACK_STRUCT_USE_INCLUDES
60# include "arch/epstruct.h"
61#endif
63
64#define IP6_HLEN 40
65
66#define IP6_NEXTH_HOPBYHOP 0
67#define IP6_NEXTH_TCP 6
68#define IP6_NEXTH_UDP 17
69#define IP6_NEXTH_ENCAPS 41
70#define IP6_NEXTH_ROUTING 43
71#define IP6_NEXTH_FRAGMENT 44
72#define IP6_NEXTH_ICMP6 58
73#define IP6_NEXTH_NONE 59
74#define IP6_NEXTH_DESTOPTS 60
75#define IP6_NEXTH_UDPLITE 136
76
78#ifdef PACK_STRUCT_USE_INCLUDES
79# include "arch/bpstruct.h"
80#endif
82struct ip6_hdr {
96#ifdef PACK_STRUCT_USE_INCLUDES
97# include "arch/epstruct.h"
98#endif
99#define IP6H_V(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f)
100#define IP6H_TC(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 20) & 0xff)
101#define IP6H_FL(hdr) (lwip_ntohl((hdr)->_v_tc_fl) & 0x000fffff)
102#define IP6H_PLEN(hdr) (lwip_ntohs((hdr)->_plen))
103#define IP6H_NEXTH(hdr) ((hdr)->_nexth)
104#define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6)
105#define IP6H_HOPLIM(hdr) ((hdr)->_hoplim)
106#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (lwip_htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl)))
107#define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = lwip_htons(plen)
108#define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth)
109#define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl)
110
111/* ipv6 extended options header */
112#define IP6_PAD1_OPTION 0
113#define IP6_PADN_OPTION 1
114#define IP6_ROUTER_ALERT_OPTION 5
115#define IP6_JUMBO_OPTION 194
116#define IP6_HOME_ADDRESS_OPTION 201
117#define IP6_ROUTER_ALERT_DLEN 2
118#define IP6_ROUTER_ALERT_VALUE_MLD 0
119
120#ifdef PACK_STRUCT_USE_INCLUDES
121# include "arch/bpstruct.h"
122#endif
125 /* router alert option type */
127 /* router alert option data len */
131#ifdef PACK_STRUCT_USE_INCLUDES
132# include "arch/epstruct.h"
133#endif
134#define IP6_OPT_HLEN 2
135#define IP6_OPT_TYPE_ACTION(hdr) ((((hdr)->_opt_type) >> 6) & 0x3)
136#define IP6_OPT_TYPE_CHANGE(hdr) ((((hdr)->_opt_type) >> 5) & 0x1)
137#define IP6_OPT_TYPE(hdr) ((hdr)->_opt_type)
138#define IP6_OPT_DLEN(hdr) ((hdr)->_opt_dlen)
139
140/* Hop-by-Hop header. */
141#define IP6_HBH_HLEN 2
142
143#ifdef PACK_STRUCT_USE_INCLUDES
144# include "arch/bpstruct.h"
145#endif
148 /* next header */
150 /* header length in 8-octet units */
154#ifdef PACK_STRUCT_USE_INCLUDES
155# include "arch/epstruct.h"
156#endif
157#define IP6_HBH_NEXTH(hdr) ((hdr)->_nexth)
158
159/* Destination header. */
160#define IP6_DEST_HLEN 2
161
162#ifdef PACK_STRUCT_USE_INCLUDES
163# include "arch/bpstruct.h"
164#endif
167 /* next header */
169 /* header length in 8-octet units */
173#ifdef PACK_STRUCT_USE_INCLUDES
174# include "arch/epstruct.h"
175#endif
176#define IP6_DEST_NEXTH(hdr) ((hdr)->_nexth)
177
178/* Routing header */
179#define IP6_ROUT_TYPE2 2
180#define IP6_ROUT_RPL 3
181
182#ifdef PACK_STRUCT_USE_INCLUDES
183# include "arch/bpstruct.h"
184#endif
187 /* next header */
189 /* reserved */
191 /* fragment offset */
192 PACK_STRUCT_FIELD(u8_t _routing_type);
193 /* fragmented packet identification */
194 PACK_STRUCT_FIELD(u8_t _segments_left);
197#ifdef PACK_STRUCT_USE_INCLUDES
198# include "arch/epstruct.h"
199#endif
200#define IP6_ROUT_NEXTH(hdr) ((hdr)->_nexth)
201#define IP6_ROUT_TYPE(hdr) ((hdr)->_routing_type)
202#define IP6_ROUT_SEG_LEFT(hdr) ((hdr)->_segments_left)
203
204/* Fragment header. */
205#define IP6_FRAG_HLEN 8
206#define IP6_FRAG_OFFSET_MASK 0xfff8
207#define IP6_FRAG_MORE_FLAG 0x0001
208
209#ifdef PACK_STRUCT_USE_INCLUDES
210# include "arch/bpstruct.h"
211#endif
214 /* next header */
216 /* reserved */
218 /* fragment offset */
219 PACK_STRUCT_FIELD(u16_t _fragment_offset);
220 /* fragmented packet identification */
221 PACK_STRUCT_FIELD(u32_t _identification);
224#ifdef PACK_STRUCT_USE_INCLUDES
225# include "arch/epstruct.h"
226#endif
227#define IP6_FRAG_NEXTH(hdr) ((hdr)->_nexth)
228#define IP6_FRAG_MBIT(hdr) (lwip_ntohs((hdr)->_fragment_offset) & 0x1)
229#define IP6_FRAG_ID(hdr) (lwip_ntohl((hdr)->_identification))
230
231#ifdef __cplusplus
232}
233#endif
234
235#endif /* LWIP_HDR_PROT_IP6_H */
r reserved
Definition: btrfs.c:3006
GLenum src
Definition: glext.h:6340
GLenum const GLvoid * addr
Definition: glext.h:9621
#define PACK_STRUCT_END
Definition: arch.h:316
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
#define PACK_STRUCT_BEGIN
Definition: arch.h:307
uint16_t u16_t
Definition: arch.h:127
static char * dest
Definition: rtl.c:135
typedefPACK_STRUCT_END struct ip6_addr_packed ip6_addr_p_t
Definition: ip6.h:62
PACK_STRUCT_BEGIN struct ip6_addr_packed PACK_STRUCT_STRUCT
PACK_STRUCT_FIELD(u32_t addr[4])
PACK_STRUCT_FLD_8(u8_t _hlen)
PACK_STRUCT_FLD_8(u8_t _nexth)
PACK_STRUCT_FIELD(u32_t _identification)
PACK_STRUCT_FIELD(u16_t _fragment_offset)
PACK_STRUCT_FLD_8(u8_t _nexth)
PACK_STRUCT_FLD_8(u8_t reserved)
PACK_STRUCT_FLD_8(u8_t _hlen)
PACK_STRUCT_FLD_8(u8_t _nexth)
Definition: ip6.h:82
PACK_STRUCT_FIELD(u16_t _plen)
PACK_STRUCT_FLD_S(ip6_addr_p_t src)
PACK_STRUCT_FLD_8(u8_t _nexth)
PACK_STRUCT_FLD_S(ip6_addr_p_t dest)
PACK_STRUCT_FIELD(u32_t _v_tc_fl)
PACK_STRUCT_FLD_8(u8_t _hoplim)
PACK_STRUCT_FLD_8(u8_t _opt_dlen)
PACK_STRUCT_FLD_8(u8_t _opt_type)
PACK_STRUCT_FIELD(u8_t _segments_left)
PACK_STRUCT_FLD_8(u8_t _hlen)
PACK_STRUCT_FLD_8(u8_t _nexth)
PACK_STRUCT_FIELD(u8_t _routing_type)