1 /** 2 * @file 3 * 4 * IPv6 fragmentation and reassembly. 5 */ 6 7 /* 8 * Copyright (c) 2010 Inico Technologies Ltd. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without modification, 12 * are permitted provided that the following conditions are met: 13 * 14 * 1. Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright notice, 17 * this list of conditions and the following disclaimer in the documentation 18 * and/or other materials provided with the distribution. 19 * 3. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 * OF SUCH DAMAGE. 32 * 33 * This file is part of the lwIP TCP/IP stack. 34 * 35 * Author: Ivan Delamer <[email protected]> 36 * 37 * 38 * Please coordinate changes and requests with Ivan Delamer 39 * <[email protected]> 40 */ 41 #ifndef LWIP_HDR_IP6_FRAG_H 42 #define LWIP_HDR_IP6_FRAG_H 43 44 #include "lwip/opt.h" 45 #include "lwip/pbuf.h" 46 #include "lwip/ip6_addr.h" 47 #include "lwip/ip6.h" 48 #include "lwip/netif.h" 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 55 #if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */ 56 57 /** IP6_FRAG_COPYHEADER==1: for platforms where sizeof(void*) > 4, this needs to 58 * be enabled (to not overwrite part of the data). When enabled, the IPv6 header 59 * is copied instead of referencing it, which gives more room for struct ip6_reass_helper */ 60 #ifndef IPV6_FRAG_COPYHEADER 61 #define IPV6_FRAG_COPYHEADER 0 62 #endif 63 64 /** The IPv6 reassembly timer interval in milliseconds. */ 65 #define IP6_REASS_TMR_INTERVAL 1000 66 67 /* Copy the complete header of the first fragment to struct ip6_reassdata 68 or just point to its original location in the first pbuf? */ 69 #if IPV6_FRAG_COPYHEADER 70 #define IPV6_FRAG_HDRPTR 71 #define IPV6_FRAG_HDRREF(hdr) (&(hdr)) 72 #else /* IPV6_FRAG_COPYHEADER */ 73 #define IPV6_FRAG_HDRPTR * 74 #define IPV6_FRAG_HDRREF(hdr) (hdr) 75 #endif /* IPV6_FRAG_COPYHEADER */ 76 77 /** IPv6 reassembly helper struct. 78 * This is exported because memp needs to know the size. 79 */ 80 struct ip6_reassdata { 81 struct ip6_reassdata *next; 82 struct pbuf *p; 83 struct ip6_hdr IPV6_FRAG_HDRPTR iphdr; 84 u32_t identification; 85 u16_t datagram_len; 86 u8_t nexth; 87 u8_t timer; 88 }; 89 90 #define ip6_reass_init() /* Compatibility define */ 91 void ip6_reass_tmr(void); 92 struct pbuf *ip6_reass(struct pbuf *p); 93 94 #endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ 95 96 #if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */ 97 98 #ifndef LWIP_PBUF_CUSTOM_REF_DEFINED 99 #define LWIP_PBUF_CUSTOM_REF_DEFINED 100 /** A custom pbuf that holds a reference to another pbuf, which is freed 101 * when this custom pbuf is freed. This is used to create a custom PBUF_REF 102 * that points into the original pbuf. */ 103 struct pbuf_custom_ref { 104 /** 'base class' */ 105 struct pbuf_custom pc; 106 /** pointer to the original pbuf that is referenced */ 107 struct pbuf *original; 108 }; 109 #endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */ 110 111 err_t ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest); 112 113 #endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */ 114 115 116 #ifdef __cplusplus 117 } 118 #endif 119 120 #endif /* LWIP_HDR_IP6_FRAG_H */ 121