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