Mistake on this page?
Report an issue in GitHub or email us
ip6_frag.h
Go to the documentation of this file.
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 <delamer@inicotech.com>
36  *
37  *
38  * Please coordinate changes and requests with Ivan Delamer
39  * <delamer@inicotech.com>
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 /** The IPv6 reassembly timer interval in milliseconds. */
58 #define IP6_REASS_TMR_INTERVAL 1000
59 
60 /** IP6_FRAG_COPYHEADER==1: for platforms where sizeof(void*) > 4, "struct
61  * ip6_reass_helper" is too large to be stored in the IPv6 fragment header, and
62  * will bleed into the header before it, which may be the IPv6 header or an
63  * extension header. This means that for each first fragment packet, we need to
64  * 1) make a copy of some IPv6 header fields (src+dest) that we need later on,
65  * just in case we do overwrite part of the IPv6 header, and 2) make a copy of
66  * the header data that we overwrote, so that we can restore it before either
67  * completing reassembly or sending an ICMPv6 reply. The last part is true even
68  * if this setting is disabled, but if it is enabled, we need to save a bit
69  * more data (up to the size of a pointer) because we overwrite more. */
70 #ifndef IPV6_FRAG_COPYHEADER
71 #define IPV6_FRAG_COPYHEADER 0
72 #endif
73 
74 /* With IPV6_FRAG_COPYHEADER==1, a helper structure may (or, depending on the
75  * presence of extensions, may not) overwrite part of the IP header. Therefore,
76  * we copy the fields that we need from the IP header for as long as the helper
77  * structure may still be in place. This is easier than temporarily restoring
78  * those fields in the IP header each time we need to perform checks on them. */
79 #if IPV6_FRAG_COPYHEADER
80 #define IPV6_FRAG_SRC(ipr) ((ipr)->src)
81 #define IPV6_FRAG_DEST(ipr) ((ipr)->dest)
82 #else /* IPV6_FRAG_COPYHEADER */
83 #define IPV6_FRAG_SRC(ipr) ((ipr)->iphdr->src)
84 #define IPV6_FRAG_DEST(ipr) ((ipr)->iphdr->dest)
85 #endif /* IPV6_FRAG_COPYHEADER */
86 
87 /** IPv6 reassembly helper struct.
88  * This is exported because memp needs to know the size.
89  */
90 struct ip6_reassdata {
91  struct ip6_reassdata *next;
92  struct pbuf *p;
93  struct ip6_hdr *iphdr; /* pointer to the first (original) IPv6 header */
94 #if IPV6_FRAG_COPYHEADER
95  ip6_addr_p_t src; /* copy of the source address in the IP header */
96  ip6_addr_p_t dest; /* copy of the destination address in the IP header */
97  /* This buffer (for the part of the original header that we overwrite) will
98  * be slightly oversized, but we cannot compute the exact size from here. */
99  u8_t orig_hdr[sizeof(struct ip6_frag_hdr) + sizeof(void*)];
100 #else /* IPV6_FRAG_COPYHEADER */
101  /* In this case we still need the buffer, for sending ICMPv6 replies. */
102  u8_t orig_hdr[sizeof(struct ip6_frag_hdr)];
103 #endif /* IPV6_FRAG_COPYHEADER */
104  u32_t identification;
105  u16_t datagram_len;
106  u8_t nexth;
107  u8_t timer;
108 #if LWIP_IPV6_SCOPES
109  u8_t src_zone; /* zone of original packet's source address */
110  u8_t dest_zone; /* zone of original packet's destination address */
111 #endif /* LWIP_IPV6_SCOPES */
112 };
113 
114 #define ip6_reass_init() /* Compatibility define */
115 void ip6_reass_tmr(void);
116 struct pbuf *ip6_reass(struct pbuf *p);
117 
118 #endif /* LWIP_IPV6 && LWIP_IPV6_REASS */
119 
120 #if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */
121 
122 #ifndef LWIP_PBUF_CUSTOM_REF_DEFINED
123 #define LWIP_PBUF_CUSTOM_REF_DEFINED
124 /** A custom pbuf that holds a reference to another pbuf, which is freed
125  * when this custom pbuf is freed. This is used to create a custom PBUF_REF
126  * that points into the original pbuf. */
127 struct pbuf_custom_ref {
128  /** 'base class' */
129  struct pbuf_custom pc;
130  /** pointer to the original pbuf that is referenced */
131  struct pbuf *original;
132 };
133 #endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */
134 
135 err_t ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest);
136 
137 #endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */
138 
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* LWIP_HDR_IP6_FRAG_H */
IPv6 layer.
lwIP Options Configuration
IPv6 addresses.
netif API (to be used from TCPIP thread)
Main packet buffer struct.
Generic data structure used for all lwIP network interfaces.
pbuf API
IP address structure for passing IP addresses by value.
Definition: nsapi_types.h:190
The IPv6 header.
Definition: prot/ip6.h:80
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.