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.
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 00098 /* Hop-by-hop router alert option. */ 00099 #define IP6_HBH_HLEN 8 00100 #define IP6_PAD1_OPTION 0 00101 #define IP6_PADN_ALERT_OPTION 1 00102 #define IP6_ROUTER_ALERT_OPTION 5 00103 #define IP6_ROUTER_ALERT_VALUE_MLD 0 00104 #ifdef PACK_STRUCT_USE_INCLUDES 00105 # include "arch/bpstruct.h" 00106 #endif 00107 PACK_STRUCT_BEGIN 00108 struct ip6_hbh_hdr { 00109 /* next header */ 00110 PACK_STRUCT_FLD_8(u8_t _nexth); 00111 /* header length */ 00112 PACK_STRUCT_FLD_8(u8_t _hlen); 00113 /* router alert option type */ 00114 PACK_STRUCT_FLD_8(u8_t _ra_opt_type); 00115 /* router alert option data len */ 00116 PACK_STRUCT_FLD_8(u8_t _ra_opt_dlen); 00117 /* router alert option data */ 00118 PACK_STRUCT_FIELD(u16_t _ra_opt_data); 00119 /* PadN option type */ 00120 PACK_STRUCT_FLD_8(u8_t _padn_opt_type); 00121 /* PadN option data len */ 00122 PACK_STRUCT_FLD_8(u8_t _padn_opt_dlen); 00123 } PACK_STRUCT_STRUCT; 00124 PACK_STRUCT_END 00125 #ifdef PACK_STRUCT_USE_INCLUDES 00126 # include "arch/epstruct.h" 00127 #endif 00128 00129 /* Fragment header. */ 00130 #define IP6_FRAG_HLEN 8 00131 #define IP6_FRAG_OFFSET_MASK 0xfff8 00132 #define IP6_FRAG_MORE_FLAG 0x0001 00133 #ifdef PACK_STRUCT_USE_INCLUDES 00134 # include "arch/bpstruct.h" 00135 #endif 00136 PACK_STRUCT_BEGIN 00137 struct ip6_frag_hdr { 00138 /* next header */ 00139 PACK_STRUCT_FLD_8(u8_t _nexth); 00140 /* reserved */ 00141 PACK_STRUCT_FLD_8(u8_t reserved); 00142 /* fragment offset */ 00143 PACK_STRUCT_FIELD(u16_t _fragment_offset); 00144 /* fragmented packet identification */ 00145 PACK_STRUCT_FIELD(u32_t _identification); 00146 } PACK_STRUCT_STRUCT; 00147 PACK_STRUCT_END 00148 #ifdef PACK_STRUCT_USE_INCLUDES 00149 # include "arch/epstruct.h" 00150 #endif 00151 00152 #define IP6H_V(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f) 00153 #define IP6H_TC(hdr) ((lwip_ntohl((hdr)->_v_tc_fl) >> 20) & 0xff) 00154 #define IP6H_FL(hdr) (lwip_ntohl((hdr)->_v_tc_fl) & 0x000fffff) 00155 #define IP6H_PLEN(hdr) (lwip_ntohs((hdr)->_plen)) 00156 #define IP6H_NEXTH(hdr) ((hdr)->_nexth) 00157 #define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6) 00158 #define IP6H_HOPLIM(hdr) ((hdr)->_hoplim) 00159 00160 #define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (lwip_htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl))) 00161 #define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = lwip_htons(plen) 00162 #define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth) 00163 #define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl) 00164 00165 #ifdef __cplusplus 00166 } 00167 #endif 00168 00169 #endif /* LWIP_HDR_PROT_IP6_H */
Generated on Tue Jul 12 2022 12:44:25 by
