xref: /minix3/minix/lib/liblwip/dist/src/include/lwip/ip4_frag.h (revision 5d5fbe79c1b60734f34c69330aec5496644e8651)
1*5d5fbe79SDavid van Moolenbroek /**
2*5d5fbe79SDavid van Moolenbroek  * @file
3*5d5fbe79SDavid van Moolenbroek  * IP fragmentation/reassembly
4*5d5fbe79SDavid van Moolenbroek  */
5*5d5fbe79SDavid van Moolenbroek 
6*5d5fbe79SDavid van Moolenbroek /*
7*5d5fbe79SDavid van Moolenbroek  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
8*5d5fbe79SDavid van Moolenbroek  * All rights reserved.
9*5d5fbe79SDavid van Moolenbroek  *
10*5d5fbe79SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without modification,
11*5d5fbe79SDavid van Moolenbroek  * are permitted provided that the following conditions are met:
12*5d5fbe79SDavid van Moolenbroek  *
13*5d5fbe79SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright notice,
14*5d5fbe79SDavid van Moolenbroek  *    this list of conditions and the following disclaimer.
15*5d5fbe79SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce the above copyright notice,
16*5d5fbe79SDavid van Moolenbroek  *    this list of conditions and the following disclaimer in the documentation
17*5d5fbe79SDavid van Moolenbroek  *    and/or other materials provided with the distribution.
18*5d5fbe79SDavid van Moolenbroek  * 3. The name of the author may not be used to endorse or promote products
19*5d5fbe79SDavid van Moolenbroek  *    derived from this software without specific prior written permission.
20*5d5fbe79SDavid van Moolenbroek  *
21*5d5fbe79SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22*5d5fbe79SDavid van Moolenbroek  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23*5d5fbe79SDavid van Moolenbroek  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24*5d5fbe79SDavid van Moolenbroek  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25*5d5fbe79SDavid van Moolenbroek  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26*5d5fbe79SDavid van Moolenbroek  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27*5d5fbe79SDavid van Moolenbroek  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28*5d5fbe79SDavid van Moolenbroek  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29*5d5fbe79SDavid van Moolenbroek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30*5d5fbe79SDavid van Moolenbroek  * OF SUCH DAMAGE.
31*5d5fbe79SDavid van Moolenbroek  *
32*5d5fbe79SDavid van Moolenbroek  * This file is part of the lwIP TCP/IP stack.
33*5d5fbe79SDavid van Moolenbroek  *
34*5d5fbe79SDavid van Moolenbroek  * Author: Jani Monoses <jani@iv.ro>
35*5d5fbe79SDavid van Moolenbroek  *
36*5d5fbe79SDavid van Moolenbroek  */
37*5d5fbe79SDavid van Moolenbroek 
38*5d5fbe79SDavid van Moolenbroek #ifndef LWIP_HDR_IP4_FRAG_H
39*5d5fbe79SDavid van Moolenbroek #define LWIP_HDR_IP4_FRAG_H
40*5d5fbe79SDavid van Moolenbroek 
41*5d5fbe79SDavid van Moolenbroek #include "lwip/opt.h"
42*5d5fbe79SDavid van Moolenbroek #include "lwip/err.h"
43*5d5fbe79SDavid van Moolenbroek #include "lwip/pbuf.h"
44*5d5fbe79SDavid van Moolenbroek #include "lwip/netif.h"
45*5d5fbe79SDavid van Moolenbroek #include "lwip/ip_addr.h"
46*5d5fbe79SDavid van Moolenbroek #include "lwip/ip.h"
47*5d5fbe79SDavid van Moolenbroek 
48*5d5fbe79SDavid van Moolenbroek #if LWIP_IPV4
49*5d5fbe79SDavid van Moolenbroek 
50*5d5fbe79SDavid van Moolenbroek #ifdef __cplusplus
51*5d5fbe79SDavid van Moolenbroek extern "C" {
52*5d5fbe79SDavid van Moolenbroek #endif
53*5d5fbe79SDavid van Moolenbroek 
54*5d5fbe79SDavid van Moolenbroek #if IP_REASSEMBLY
55*5d5fbe79SDavid van Moolenbroek /* The IP reassembly timer interval in milliseconds. */
56*5d5fbe79SDavid van Moolenbroek #define IP_TMR_INTERVAL 1000
57*5d5fbe79SDavid van Moolenbroek 
58*5d5fbe79SDavid van Moolenbroek /** IP reassembly helper struct.
59*5d5fbe79SDavid van Moolenbroek  * This is exported because memp needs to know the size.
60*5d5fbe79SDavid van Moolenbroek  */
61*5d5fbe79SDavid van Moolenbroek struct ip_reassdata {
62*5d5fbe79SDavid van Moolenbroek   struct ip_reassdata *next;
63*5d5fbe79SDavid van Moolenbroek   struct pbuf *p;
64*5d5fbe79SDavid van Moolenbroek   struct ip_hdr iphdr;
65*5d5fbe79SDavid van Moolenbroek   u16_t datagram_len;
66*5d5fbe79SDavid van Moolenbroek   u8_t flags;
67*5d5fbe79SDavid van Moolenbroek   u8_t timer;
68*5d5fbe79SDavid van Moolenbroek };
69*5d5fbe79SDavid van Moolenbroek 
70*5d5fbe79SDavid van Moolenbroek void ip_reass_init(void);
71*5d5fbe79SDavid van Moolenbroek void ip_reass_tmr(void);
72*5d5fbe79SDavid van Moolenbroek struct pbuf * ip4_reass(struct pbuf *p);
73*5d5fbe79SDavid van Moolenbroek #endif /* IP_REASSEMBLY */
74*5d5fbe79SDavid van Moolenbroek 
75*5d5fbe79SDavid van Moolenbroek #if IP_FRAG
76*5d5fbe79SDavid van Moolenbroek #if !LWIP_NETIF_TX_SINGLE_PBUF
77*5d5fbe79SDavid van Moolenbroek #ifndef LWIP_PBUF_CUSTOM_REF_DEFINED
78*5d5fbe79SDavid van Moolenbroek #define LWIP_PBUF_CUSTOM_REF_DEFINED
79*5d5fbe79SDavid van Moolenbroek /** A custom pbuf that holds a reference to another pbuf, which is freed
80*5d5fbe79SDavid van Moolenbroek  * when this custom pbuf is freed. This is used to create a custom PBUF_REF
81*5d5fbe79SDavid van Moolenbroek  * that points into the original pbuf. */
82*5d5fbe79SDavid van Moolenbroek struct pbuf_custom_ref {
83*5d5fbe79SDavid van Moolenbroek   /** 'base class' */
84*5d5fbe79SDavid van Moolenbroek   struct pbuf_custom pc;
85*5d5fbe79SDavid van Moolenbroek   /** pointer to the original pbuf that is referenced */
86*5d5fbe79SDavid van Moolenbroek   struct pbuf *original;
87*5d5fbe79SDavid van Moolenbroek };
88*5d5fbe79SDavid van Moolenbroek #endif /* LWIP_PBUF_CUSTOM_REF_DEFINED */
89*5d5fbe79SDavid van Moolenbroek #endif /* !LWIP_NETIF_TX_SINGLE_PBUF */
90*5d5fbe79SDavid van Moolenbroek 
91*5d5fbe79SDavid van Moolenbroek err_t ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest);
92*5d5fbe79SDavid van Moolenbroek #endif /* IP_FRAG */
93*5d5fbe79SDavid van Moolenbroek 
94*5d5fbe79SDavid van Moolenbroek #ifdef __cplusplus
95*5d5fbe79SDavid van Moolenbroek }
96*5d5fbe79SDavid van Moolenbroek #endif
97*5d5fbe79SDavid van Moolenbroek 
98*5d5fbe79SDavid van Moolenbroek #endif /* LWIP_IPV4 */
99*5d5fbe79SDavid van Moolenbroek 
100*5d5fbe79SDavid van Moolenbroek #endif /* LWIP_HDR_IP4_FRAG_H */
101