UbixOS V2 2.0

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
44 extern "C" {
45 #endif
46
49 #ifdef PACK_STRUCT_USE_INCLUDES
50 # include "arch/bpstruct.h"
51 #endif
52 PACK_STRUCT_BEGIN
53 struct ip6_addr_packed {
54 PACK_STRUCT_FIELD(u32_t addr[4]);
55 } PACK_STRUCT_STRUCT;
56 PACK_STRUCT_END
57 #ifdef PACK_STRUCT_USE_INCLUDES
58 # include "arch/epstruct.h"
59 #endif
60 typedef struct ip6_addr_packed ip6_addr_p_t;
61
62 #define IP6_HLEN 40
63
64 #define IP6_NEXTH_HOPBYHOP 0
65 #define IP6_NEXTH_TCP 6
66 #define IP6_NEXTH_UDP 17
67 #define IP6_NEXTH_ENCAPS 41
68 #define IP6_NEXTH_ROUTING 43
69 #define IP6_NEXTH_FRAGMENT 44
70 #define IP6_NEXTH_ICMP6 58
71 #define IP6_NEXTH_NONE 59
72 #define IP6_NEXTH_DESTOPTS 60
73 #define IP6_NEXTH_UDPLITE 136
74
76 #ifdef PACK_STRUCT_USE_INCLUDES
77 # include "arch/bpstruct.h"
78 #endif
79 PACK_STRUCT_BEGIN
80 struct ip6_hdr {
82 PACK_STRUCT_FIELD(u32_t _v_tc_fl);
84 PACK_STRUCT_FIELD(u16_t _plen);
86 PACK_STRUCT_FLD_8(u8_t _nexth);
88 PACK_STRUCT_FLD_8(u8_t _hoplim);
90 PACK_STRUCT_FLD_S(ip6_addr_p_t src);
91 PACK_STRUCT_FLD_S(ip6_addr_p_t dest);
92 } PACK_STRUCT_STRUCT;
93 PACK_STRUCT_END
94 #ifdef PACK_STRUCT_USE_INCLUDES
95 # include "arch/epstruct.h"
96 #endif
97
98 /* Hop-by-hop router alert option. */
99 #define IP6_HBH_HLEN 8
100 #define IP6_PAD1_OPTION 0
101 #define IP6_PADN_ALERT_OPTION 1
102 #define IP6_ROUTER_ALERT_OPTION 5
103 #define IP6_ROUTER_ALERT_VALUE_MLD 0
104 #ifdef PACK_STRUCT_USE_INCLUDES
105 # include "arch/bpstruct.h"
106 #endif
107 PACK_STRUCT_BEGIN
108 struct ip6_hbh_hdr {
109 /* next header */
110 PACK_STRUCT_FLD_8(u8_t _nexth);
111 /* header length */
112 PACK_STRUCT_FLD_8(u8_t _hlen);
113 /* router alert option type */
114 PACK_STRUCT_FLD_8(u8_t _ra_opt_type);
115 /* router alert option data len */
116 PACK_STRUCT_FLD_8(u8_t _ra_opt_dlen);
117 /* router alert option data */
118 PACK_STRUCT_FIELD(u16_t _ra_opt_data);
119 /* PadN option type */
120 PACK_STRUCT_FLD_8(u8_t _padn_opt_type);
121 /* PadN option data len */
122 PACK_STRUCT_FLD_8(u8_t _padn_opt_dlen);
123 } PACK_STRUCT_STRUCT;
124 PACK_STRUCT_END
125 #ifdef PACK_STRUCT_USE_INCLUDES
126 # include "arch/epstruct.h"
127 #endif
128
129 /* Fragment header. */
130 #define IP6_FRAG_HLEN 8
131 #define IP6_FRAG_OFFSET_MASK 0xfff8
132 #define IP6_FRAG_MORE_FLAG 0x0001
133 #ifdef PACK_STRUCT_USE_INCLUDES
134 # include "arch/bpstruct.h"
135 #endif
136 PACK_STRUCT_BEGIN
137 struct ip6_frag_hdr {
138 /* next header */
139 PACK_STRUCT_FLD_8(u8_t _nexth);
140 /* reserved */
141 PACK_STRUCT_FLD_8(u8_t reserved);
142 /* fragment offset */
143 PACK_STRUCT_FIELD(u16_t _fragment_offset);
144 /* fragmented packet identification */
145 PACK_STRUCT_FIELD(u32_t _identification);
146 } PACK_STRUCT_STRUCT;
147 PACK_STRUCT_END
148 #ifdef PACK_STRUCT_USE_INCLUDES
149 # include "arch/epstruct.h"
150 #endif
151
152 #define IP6H_V(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f)
153 #define IP6H_TC(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 20) & 0xff)
154 #define IP6H_FL(hdr) (lwip_ntohl((hdr)->_v_tc_fl) & 0x000fffff)
155 #define IP6H_PLEN(hdr) (lwip_ntohs((hdr)->_plen))
156 #define IP6H_NEXTH(hdr) ((hdr)->_nexth)
157 #define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6)
158 #define IP6H_HOPLIM(hdr) ((hdr)->_hoplim)
159
160 #define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (lwip_htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl)))
161 #define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = lwip_htons(plen)
162 #define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth)
163 #define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl)
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif /* LWIP_HDR_PROT_IP6_H */
ip6_hdr::PACK_STRUCT_FLD_8
PACK_STRUCT_FLD_8(u8_t _nexth)
ip6_frag_hdr::PACK_STRUCT_FLD_8
PACK_STRUCT_FLD_8(u8_t _nexth)
u16_t
uint16_t u16_t
Definition: arch.h:124
PACK_STRUCT_STRUCT
PACK_STRUCT_BEGIN struct ip6_addr_packed PACK_STRUCT_STRUCT
u32_t
uint32_t u32_t
Definition: arch.h:126
ip6_addr_packed
Definition: ip6.h:53
ip6_hbh_hdr::PACK_STRUCT_FLD_8
PACK_STRUCT_FLD_8(u8_t _nexth)
ip6_hbh_hdr::PACK_STRUCT_FIELD
PACK_STRUCT_FIELD(u16_t _ra_opt_data)
u8_t
uint8_t u8_t
Definition: arch.h:122
ip6_addr_p_t
typedefPACK_STRUCT_END struct ip6_addr_packed ip6_addr_p_t
Definition: ip6.h:60
PACK_STRUCT_BEGIN
#define PACK_STRUCT_BEGIN
Definition: cc.h:8
ip6_hdr::PACK_STRUCT_FIELD
PACK_STRUCT_FIELD(u32_t _v_tc_fl)
ip6_hdr::PACK_STRUCT_FLD_S
PACK_STRUCT_FLD_S(ip6_addr_p_t src)
ip6_addr_packed::PACK_STRUCT_FIELD
PACK_STRUCT_FIELD(u32_t addr[4])
ip6_hbh_hdr
Definition: ip6.h:108
ip6_frag_hdr
Definition: ip6.h:137
ip6_hdr
Definition: ip6.h:80
PACK_STRUCT_END
#define PACK_STRUCT_END
Definition: cc.h:9
ip6_frag_hdr::PACK_STRUCT_FIELD
PACK_STRUCT_FIELD(u16_t _fragment_offset)