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_frag.h
00001 /** 00002 * @file 00003 * 00004 * IPv6 fragmentation and reassembly. 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_FRAG_H 00042 #define LWIP_HDR_IP6_FRAG_H 00043 00044 #include "lwip/opt.h" 00045 #include "lwip/pbuf.h" 00046 #include "lwip/ip6_addr.h" 00047 #include "lwip/ip6.h" 00048 #include "lwip/netif.h" 00049 00050 #ifdef __cplusplus 00051 extern "C" { 00052 #endif 00053 00054 00055 #if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */ 00056 00057 /** The IPv6 reassembly timer interval in milliseconds. */ 00058 #define IP6_REASS_TMR_INTERVAL 1000 00059 00060 /** IP6_FRAG_COPYHEADER==1: for platforms where sizeof(void*) > 4, "struct 00061 * ip6_reass_helper" is too large to be stored in the IPv6 fragment header, and 00062 * will bleed into the header before it, which may be the IPv6 header or an 00063 * extension header. This means that for each first fragment packet, we need to 00064 * 1) make a copy of some IPv6 header fields (src+dest) that we need later on, 00065 * just in case we do overwrite part of the IPv6 header, and 2) make a copy of 00066 * the header data that we overwrote, so that we can restore it before either 00067 * completing reassembly or sending an ICMPv6 reply. The last part is true even 00068 * if this setting is disabled, but if it is enabled, we need to save a bit 00069 * more data (up to the size of a pointer) because we overwrite more. */ 00070 #ifndef IPV6_FRAG_COPYHEADER 00071 #define IPV6_FRAG_COPYHEADER 0 00072 #endif 00073 00074 /* With IPV6_FRAG_COPYHEADER==1, a helper structure may (or, depending on the 00075 * presence of extensions, may not) overwrite part of the IP header. Therefore, 00076 * we copy the fields that we need from the IP header for as long as the helper 00077 * structure may still be in place. This is easier than temporarily restoring 00078 * those fields in the IP header each time we need to perform checks on them. */ 00079 #if IPV6_FRAG_COPYHEADER 00080 #define IPV6_FRAG_SRC(ipr) ((ipr)->src) 00081 #define IPV6_FRAG_DEST(ipr) ((ipr)->dest) 00082 #else /* IPV6_FRAG_COPYHEADER */ 00083 #define IPV6_FRAG_SRC(ipr) ((ipr)->iphdr->src) 00084 #define IPV6_FRAG_DEST(ipr) ((ipr)->iphdr->dest) 00085 #endif /* IPV6_FRAG_COPYHEADER */ 00086 00087 /** IPv6 reassembly helper struct. 00088 * This is exported because memp needs to know the size. 00089 */ 00090 struct ip6_reassdata { 00091 struct ip6_reassdata *next; 00092 struct pbuf *p; 00093 struct ip6_hdr *iphdr; /* pointer to the first (original) IPv6 header */ 00094 #if IPV6_FRAG_COPYHEADER 00095 ip6_addr_p_t src; /* copy of the source address in the IP header */ 00096 ip6_addr_p_t dest; /* copy of the destination address in the IP header */ 00097 /* This buffer (for the part of the original header that we overwrite) will 00098 * be slightly oversized, but we cannot compute the exact size from here. */ 00099 u8_t orig_hdr[sizeof(struct ip6_frag_hdr) + sizeof(void*)]; 00100 #else /* IPV6_FRAG_COPYHEADER */ 00101 /* In this case we still need the buffer, for sending ICMPv6 replies. */ 00102 u8_t orig_hdr[sizeof(struct ip6_frag_hdr)]; 00103 #endif /* IPV6_FRAG_COPYHEADER */ 00104 u32_t identification; 00105 u16_t datagram_len; 00106 u8_t nexth; 00107 u8_t timer; 00108 #if LWIP_IPV6_SCOPES 00109 u8_t src_zone; /* zone of original packet's source address */ 00110 u8_t dest_zone; /* zone of original packet's destination address */ 00111 #endif /* LWIP_IPV6_SCOPES */ 00112 }; 00113 00114 #define ip6_reass_init() /* Compatibility define */ 00115 void ip6_reass_tmr(void); 00116 struct pbuf *ip6_reass(struct pbuf *p); 00117 00118 #endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ 00119 00120 #if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */ 00121 00122 #ifndef LWIP_PBUF_CUSTOM_REF_DEFINED 00123 #define LWIP_PBUF_CUSTOM_REF_DEFINED 00124 /** A custom pbuf that holds a reference to another pbuf, which is freed 00125 * when this custom pbuf is freed. This is used to create a custom PBUF_REF 00126 * that points into the original pbuf. */ 00127 struct pbuf_custom_ref { 00128 /** 'base class' */ 00129 struct pbuf_custom pc; 00130 /** pointer to the original pbuf that is referenced */ 00131 struct pbuf *original; 00132 }; 00133 #endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */ 00134 00135 err_t ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest); 00136 00137 #endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */ 00138 00139 00140 #ifdef __cplusplus 00141 } 00142 #endif 00143 00144 #endif /* LWIP_HDR_IP6_FRAG_H */
Generated on Tue Jul 12 2022 13:54:25 by
