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: BLE_file_test BLE_Blink ExternalEncoder
ip6.h
00001 /** 00002 * @file 00003 * 00004 * IPv6 layer. 00005 */ 00006 00007 /* 00008 * Copyright (c) 2010 Inico Technologies Ltd. 00009 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 00014 * 1. Redistributions of source code must retain the above copyright notice, 00015 * this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright notice, 00017 * this list of conditions and the following disclaimer in the documentation 00018 * and/or other materials provided with the distribution. 00019 * 3. The name of the author may not be used to endorse or promote products 00020 * derived from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00023 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00025 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00026 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00027 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00030 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00031 * OF SUCH DAMAGE. 00032 * 00033 * This file is part of the lwIP TCP/IP stack. 00034 * 00035 * Author: Ivan Delamer <delamer@inicotech.com> 00036 * 00037 * 00038 * Please coordinate changes and requests with Ivan Delamer 00039 * <delamer@inicotech.com> 00040 */ 00041 #ifndef LWIP_HDR_IP6_H 00042 #define LWIP_HDR_IP6_H 00043 00044 #include "lwip/opt.h" 00045 00046 #if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ 00047 00048 #include "lwip/ip6_addr.h" 00049 #include "lwip/def.h" 00050 #include "lwip/pbuf.h" 00051 #include "lwip/netif.h" 00052 00053 #include "lwip/err.h" 00054 00055 #ifdef __cplusplus 00056 extern "C" { 00057 #endif 00058 00059 #define IP6_HLEN 40 00060 00061 #define IP6_NEXTH_HOPBYHOP 0 00062 #define IP6_NEXTH_TCP 6 00063 #define IP6_NEXTH_UDP 17 00064 #define IP6_NEXTH_ENCAPS 41 00065 #define IP6_NEXTH_ROUTING 43 00066 #define IP6_NEXTH_FRAGMENT 44 00067 #define IP6_NEXTH_ICMP6 58 00068 #define IP6_NEXTH_NONE 59 00069 #define IP6_NEXTH_DESTOPTS 60 00070 #define IP6_NEXTH_UDPLITE 136 00071 00072 00073 /** The IPv6 header. */ 00074 #ifdef PACK_STRUCT_USE_INCLUDES 00075 # include "arch/bpstruct.h" 00076 #endif 00077 PACK_STRUCT_BEGIN 00078 struct ip6_hdr { 00079 /** version / traffic class / flow label */ 00080 PACK_STRUCT_FIELD(u32_t _v_tc_fl); 00081 /** payload length */ 00082 PACK_STRUCT_FIELD(u16_t _plen); 00083 /** next header */ 00084 PACK_STRUCT_FLD_8(u8_t _nexth); 00085 /** hop limit */ 00086 PACK_STRUCT_FLD_8(u8_t _hoplim); 00087 /** source and destination IP addresses */ 00088 PACK_STRUCT_FLD_S(ip6_addr_p_t src); 00089 PACK_STRUCT_FLD_S(ip6_addr_p_t dest); 00090 } PACK_STRUCT_STRUCT; 00091 PACK_STRUCT_END 00092 #ifdef PACK_STRUCT_USE_INCLUDES 00093 # include "arch/epstruct.h" 00094 #endif 00095 00096 /* Hop-by-hop router alert option. */ 00097 #define IP6_HBH_HLEN 8 00098 #define IP6_PAD1_OPTION 0 00099 #define IP6_PADN_ALERT_OPTION 1 00100 #define IP6_ROUTER_ALERT_OPTION 5 00101 #define IP6_ROUTER_ALERT_VALUE_MLD 0 00102 #ifdef PACK_STRUCT_USE_INCLUDES 00103 # include "arch/bpstruct.h" 00104 #endif 00105 PACK_STRUCT_BEGIN 00106 struct ip6_hbh_hdr { 00107 /* next header */ 00108 PACK_STRUCT_FLD_8(u8_t _nexth); 00109 /* header length */ 00110 PACK_STRUCT_FLD_8(u8_t _hlen); 00111 /* router alert option type */ 00112 PACK_STRUCT_FLD_8(u8_t _ra_opt_type); 00113 /* router alert option data len */ 00114 PACK_STRUCT_FLD_8(u8_t _ra_opt_dlen); 00115 /* router alert option data */ 00116 PACK_STRUCT_FIELD(u16_t _ra_opt_data); 00117 /* PadN option type */ 00118 PACK_STRUCT_FLD_8(u8_t _padn_opt_type); 00119 /* PadN option data len */ 00120 PACK_STRUCT_FLD_8(u8_t _padn_opt_dlen); 00121 } PACK_STRUCT_STRUCT; 00122 PACK_STRUCT_END 00123 #ifdef PACK_STRUCT_USE_INCLUDES 00124 # include "arch/epstruct.h" 00125 #endif 00126 00127 /* Fragment header. */ 00128 #define IP6_FRAG_HLEN 8 00129 #define IP6_FRAG_OFFSET_MASK 0xfff8 00130 #define IP6_FRAG_MORE_FLAG 0x0001 00131 #ifdef PACK_STRUCT_USE_INCLUDES 00132 # include "arch/bpstruct.h" 00133 #endif 00134 PACK_STRUCT_BEGIN 00135 struct ip6_frag_hdr { 00136 /* next header */ 00137 PACK_STRUCT_FLD_8(u8_t _nexth); 00138 /* reserved */ 00139 PACK_STRUCT_FLD_8(u8_t reserved); 00140 /* fragment offset */ 00141 PACK_STRUCT_FIELD(u16_t _fragment_offset); 00142 /* fragmented packet identification */ 00143 PACK_STRUCT_FIELD(u32_t _identification); 00144 } PACK_STRUCT_STRUCT; 00145 PACK_STRUCT_END 00146 #ifdef PACK_STRUCT_USE_INCLUDES 00147 # include "arch/epstruct.h" 00148 #endif 00149 00150 #define IP6H_V(hdr) ((ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f) 00151 #define IP6H_TC(hdr) ((ntohl((hdr)->_v_tc_fl) >> 20) & 0xff) 00152 #define IP6H_FL(hdr) (ntohl((hdr)->_v_tc_fl) & 0x000fffff) 00153 #define IP6H_PLEN(hdr) (ntohs((hdr)->_plen)) 00154 #define IP6H_NEXTH(hdr) ((hdr)->_nexth) 00155 #define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6) 00156 #define IP6H_HOPLIM(hdr) ((hdr)->_hoplim) 00157 00158 #define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (htonl((((u32_t)(v)) << 28) | (((u32_t)(tc)) << 20) | (fl))) 00159 #define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = htons(plen) 00160 #define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth) 00161 #define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl) 00162 00163 00164 struct netif *ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest); 00165 const ip_addr_t *ip6_select_source_address(struct netif *netif, const ip6_addr_t * dest); 00166 err_t ip6_input(struct pbuf *p, struct netif *inp); 00167 err_t ip6_output(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 00168 u8_t hl, u8_t tc, u8_t nexth); 00169 err_t ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 00170 u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); 00171 err_t ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 00172 u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); 00173 #if LWIP_NETIF_HWADDRHINT 00174 err_t ip6_output_hinted(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest, 00175 u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint); 00176 #endif /* LWIP_NETIF_HWADDRHINT */ 00177 #if LWIP_IPV6_MLD 00178 err_t ip6_options_add_hbh_ra(struct pbuf * p, u8_t nexth, u8_t value); 00179 #endif /* LWIP_IPV6_MLD */ 00180 00181 #define ip6_netif_get_local_ip(netif, dest) (((netif) != NULL) ? \ 00182 ip6_select_source_address(netif, dest) : NULL) 00183 00184 #if IP6_DEBUG 00185 void ip6_debug_print(struct pbuf *p); 00186 #else 00187 #define ip6_debug_print(p) 00188 #endif /* IP6_DEBUG */ 00189 00190 00191 #ifdef __cplusplus 00192 } 00193 #endif 00194 00195 #endif /* LWIP_IPV6 */ 00196 00197 #endif /* LWIP_HDR_IP6_H */
Generated on Tue Jul 12 2022 15:19:31 by
1.7.2