4 * IPv6 fragmentation and reassembly.
8 * Copyright (c) 2010 Inico Technologies Ltd.
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
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.
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
33 * This file is part of the lwIP TCP/IP stack.
35 * Author: Ivan Delamer <delamer@inicotech.com>
38 * Please coordinate changes and requests with Ivan Delamer
39 * <delamer@inicotech.com>
41 #ifndef LWIP_HDR_IP6_FRAG_H
42 #define LWIP_HDR_IP6_FRAG_H
45 #include "lwip/pbuf.h"
46 #include "lwip/ip6_addr.h"
48 #include "lwip/netif.h"
55 #if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */
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
64 /** The IPv6 reassembly timer interval in milliseconds. */
65 #define IP6_REASS_TMR_INTERVAL 1000
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 */
77 /** IPv6 reassembly helper struct.
78 * This is exported because memp needs to know the size.
80 struct ip6_reassdata {
81 struct ip6_reassdata *next;
83 struct ip6_hdr IPV6_FRAG_HDRPTR iphdr;
90 #define ip6_reass_init() /* Compatibility define */
91 void ip6_reass_tmr(void);
92 struct pbuf *ip6_reass(struct pbuf *p);
94 #endif /* LWIP_IPV6 && LWIP_IPV6_REASS */
96 #if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */
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 {
105 struct pbuf_custom pc;
106 /** pointer to the original pbuf that is referenced */
107 struct pbuf *original;
109 #endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */
111 err_t ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest);
113 #endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */
120 #endif /* LWIP_HDR_IP6_FRAG_H */