Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
ip6.h
00001 /** 00002 * @file 00003 * IPv6 protocol definitions 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 */ 00037 #ifndef LWIP_HDR_PROT_IP6_H 00038 #define LWIP_HDR_PROT_IP6_H 00039 00040 #include "lwip/arch.h" 00041 #include "lwip/ip6_addr.h" 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 /** This is the packed version of ip6_addr_t, 00048 used in network headers that are itself packed */ 00049 #ifdef PACK_STRUCT_USE_INCLUDES 00050 # include "arch/bpstruct.h" 00051 #endif 00052 PACK_STRUCT_BEGIN 00053 struct ip6_addr_packed { 00054 PACK_STRUCT_FIELD(u32_t addr[4]); 00055 } PACK_STRUCT_STRUCT; 00056 PACK_STRUCT_END 00057 #ifdef PACK_STRUCT_USE_INCLUDES 00058 # include "arch/epstruct.h" 00059 #endif 00060 typedef struct ip6_addr_packed ip6_addr_p_t; 00061 00062 #define IP6_HLEN 40 00063 00064 #define IP6_NEXTH_HOPBYHOP 0 00065 #define IP6_NEXTH_TCP 6 00066 #define IP6_NEXTH_UDP 17 00067 #define IP6_NEXTH_ENCAPS 41 00068 #define IP6_NEXTH_ROUTING 43 00069 #define IP6_NEXTH_FRAGMENT 44 00070 #define IP6_NEXTH_ICMP6 58 00071 #define IP6_NEXTH_NONE 59 00072 #define IP6_NEXTH_DESTOPTS 60 00073 #define IP6_NEXTH_UDPLITE 136 00074 00075 /** The IPv6 header. */ 00076 #ifdef PACK_STRUCT_USE_INCLUDES 00077 # include "arch/bpstruct.h" 00078 #endif 00079 PACK_STRUCT_BEGIN 00080 struct ip6_hdr { 00081 /** version / traffic class / flow label */ 00082 PACK_STRUCT_FIELD(u32_t _v_tc_fl); 00083 /** payload length */ 00084 PACK_STRUCT_FIELD(u16_t _plen); 00085 /** next header */ 00086 PACK_STRUCT_FLD_8(u8_t _nexth); 00087 /** hop limit */ 00088 PACK_STRUCT_FLD_8(u8_t _hoplim); 00089 /** source and destination IP addresses */ 00090 PACK_STRUCT_FLD_S(ip6_addr_p_t src); 00091 PACK_STRUCT_FLD_S(ip6_addr_p_t dest); 00092 } PACK_STRUCT_STRUCT; 00093 PACK_STRUCT_END 00094 #ifdef PACK_STRUCT_USE_INCLUDES 00095 # include "arch/epstruct.h" 00096 #endif 00097 #define IP6H_V(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f) 00098 #define IP6H_TC(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 20) & 0xff) 00099 #define IP6H_FL(hdr) (lwip_ntohl((hdr)->_v_tc_fl) & 0x000fffff) 00100 #define IP6H_PLEN(hdr) (lwip_ntohs((hdr)->_plen)) 00101 #define IP6H_NEXTH(hdr) ((hdr)->_nexth) 00102 #define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6) 00103 #define IP6H_HOPLIM(hdr) ((hdr)->_hoplim) 00104 #define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (lwip_htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl))) 00105 #define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = lwip_htons(plen) 00106 #define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth) 00107 #define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl) 00108 00109 /* ipv6 extended options header */ 00110 #define IP6_PAD1_OPTION 0 00111 #define IP6_PADN_OPTION 1 00112 #define IP6_ROUTER_ALERT_OPTION 5 00113 #define IP6_JUMBO_OPTION 194 00114 #define IP6_HOME_ADDRESS_OPTION 201 00115 #define IP6_ROUTER_ALERT_DLEN 2 00116 #define IP6_ROUTER_ALERT_VALUE_MLD 0 00117 00118 #ifdef PACK_STRUCT_USE_INCLUDES 00119 # include "arch/bpstruct.h" 00120 #endif 00121 PACK_STRUCT_BEGIN 00122 struct ip6_opt_hdr { 00123 /* router alert option type */ 00124 PACK_STRUCT_FLD_8(u8_t _opt_type); 00125 /* router alert option data len */ 00126 PACK_STRUCT_FLD_8(u8_t _opt_dlen); 00127 } PACK_STRUCT_STRUCT; 00128 PACK_STRUCT_END 00129 #ifdef PACK_STRUCT_USE_INCLUDES 00130 # include "arch/epstruct.h" 00131 #endif 00132 #define IP6_OPT_HLEN 2 00133 #define IP6_OPT_TYPE_ACTION(hdr) ((((hdr)->_opt_type) >> 6) & 0x3) 00134 #define IP6_OPT_TYPE_CHANGE(hdr) ((((hdr)->_opt_type) >> 5) & 0x1) 00135 #define IP6_OPT_TYPE(hdr) ((hdr)->_opt_type) 00136 #define IP6_OPT_DLEN(hdr) ((hdr)->_opt_dlen) 00137 00138 /* Hop-by-Hop header. */ 00139 #define IP6_HBH_HLEN 2 00140 00141 #ifdef PACK_STRUCT_USE_INCLUDES 00142 # include "arch/bpstruct.h" 00143 #endif 00144 PACK_STRUCT_BEGIN 00145 struct ip6_hbh_hdr { 00146 /* next header */ 00147 PACK_STRUCT_FLD_8(u8_t _nexth); 00148 /* header length in 8-octet units */ 00149 PACK_STRUCT_FLD_8(u8_t _hlen); 00150 } PACK_STRUCT_STRUCT; 00151 PACK_STRUCT_END 00152 #ifdef PACK_STRUCT_USE_INCLUDES 00153 # include "arch/epstruct.h" 00154 #endif 00155 #define IP6_HBH_NEXTH(hdr) ((hdr)->_nexth) 00156 00157 /* Destination header. */ 00158 #define IP6_DEST_HLEN 2 00159 00160 #ifdef PACK_STRUCT_USE_INCLUDES 00161 # include "arch/bpstruct.h" 00162 #endif 00163 PACK_STRUCT_BEGIN 00164 struct ip6_dest_hdr { 00165 /* next header */ 00166 PACK_STRUCT_FLD_8(u8_t _nexth); 00167 /* header length in 8-octet units */ 00168 PACK_STRUCT_FLD_8(u8_t _hlen); 00169 } PACK_STRUCT_STRUCT; 00170 PACK_STRUCT_END 00171 #ifdef PACK_STRUCT_USE_INCLUDES 00172 # include "arch/epstruct.h" 00173 #endif 00174 #define IP6_DEST_NEXTH(hdr) ((hdr)->_nexth) 00175 00176 /* Routing header */ 00177 #define IP6_ROUT_TYPE2 2 00178 #define IP6_ROUT_RPL 3 00179 00180 #ifdef PACK_STRUCT_USE_INCLUDES 00181 # include "arch/bpstruct.h" 00182 #endif 00183 PACK_STRUCT_BEGIN 00184 struct ip6_rout_hdr { 00185 /* next header */ 00186 PACK_STRUCT_FLD_8(u8_t _nexth); 00187 /* reserved */ 00188 PACK_STRUCT_FLD_8(u8_t _hlen); 00189 /* fragment offset */ 00190 PACK_STRUCT_FIELD(u8_t _routing_type); 00191 /* fragmented packet identification */ 00192 PACK_STRUCT_FIELD(u8_t _segments_left); 00193 } PACK_STRUCT_STRUCT; 00194 PACK_STRUCT_END 00195 #ifdef PACK_STRUCT_USE_INCLUDES 00196 # include "arch/epstruct.h" 00197 #endif 00198 #define IP6_ROUT_NEXTH(hdr) ((hdr)->_nexth) 00199 #define IP6_ROUT_TYPE(hdr) ((hdr)->_routing_type) 00200 #define IP6_ROUT_SEG_LEFT(hdr) ((hdr)->_segments_left) 00201 00202 /* Fragment header. */ 00203 #define IP6_FRAG_HLEN 8 00204 #define IP6_FRAG_OFFSET_MASK 0xfff8 00205 #define IP6_FRAG_MORE_FLAG 0x0001 00206 00207 #ifdef PACK_STRUCT_USE_INCLUDES 00208 # include "arch/bpstruct.h" 00209 #endif 00210 PACK_STRUCT_BEGIN 00211 struct ip6_frag_hdr { 00212 /* next header */ 00213 PACK_STRUCT_FLD_8(u8_t _nexth); 00214 /* reserved */ 00215 PACK_STRUCT_FLD_8(u8_t reserved); 00216 /* fragment offset */ 00217 PACK_STRUCT_FIELD(u16_t _fragment_offset); 00218 /* fragmented packet identification */ 00219 PACK_STRUCT_FIELD(u32_t _identification); 00220 } PACK_STRUCT_STRUCT; 00221 PACK_STRUCT_END 00222 #ifdef PACK_STRUCT_USE_INCLUDES 00223 # include "arch/epstruct.h" 00224 #endif 00225 #define IP6_FRAG_NEXTH(hdr) ((hdr)->_nexth) 00226 #define IP6_FRAG_MBIT(hdr) (lwip_ntohs((hdr)->_fragment_offset) & 0x1) 00227 #define IP6_FRAG_ID(hdr) (lwip_ntohl((hdr)->_identification)) 00228 00229 #ifdef __cplusplus 00230 } 00231 #endif 00232 00233 #endif /* LWIP_HDR_PROT_IP6_H */
Generated on Tue Jul 12 2022 13:54:25 by
