mikroSDK Reference Manual
ipv4_frag.h
Go to the documentation of this file.
1
31#ifndef _IPV4_FRAG_H
32#define _IPV4_FRAG_H
33
34//Dependencies
35#include "core/net.h"
36#include "ipv4/ipv4.h"
37
38//IPv4 fragmentation support
39#ifndef IPV4_FRAG_SUPPORT
40 #define IPV4_FRAG_SUPPORT ENABLED
41#elif (IPV4_FRAG_SUPPORT != ENABLED && IPV4_FRAG_SUPPORT != DISABLED)
42 #error IPV4_FRAG_SUPPORT parameter is not valid
43#endif
44
45//Support for overlapping fragments
46#ifndef IPV4_OVERLAPPING_FRAG_SUPPORT
47 #define IPV4_OVERLAPPING_FRAG_SUPPORT ENABLED
48#elif (IPV4_OVERLAPPING_FRAG_SUPPORT != ENABLED && IPV4_OVERLAPPING_FRAG_SUPPORT != DISABLED)
49 #error IPV4_OVERLAPPING_FRAG_SUPPORT parameter is not valid
50#endif
51
52//Reassembly algorithm tick interval
53#ifndef IPV4_FRAG_TICK_INTERVAL
54 #define IPV4_FRAG_TICK_INTERVAL 1000
55#elif (IPV4_FRAG_TICK_INTERVAL < 10)
56 #error IPV4_FRAG_TICK_INTERVAL parameter is not valid
57#endif
58
59//Maximum number of fragmented packets the host will accept
60//and hold in the reassembly queue simultaneously
61#ifndef IPV4_MAX_FRAG_DATAGRAMS
62 #define IPV4_MAX_FRAG_DATAGRAMS 4
63#elif (IPV4_MAX_FRAG_DATAGRAMS < 1)
64 #error IPV4_MAX_FRAG_DATAGRAMS parameter is not valid
65#endif
66
67//Maximum datagram size the host will accept when reassembling fragments
68#ifndef IPV4_MAX_FRAG_DATAGRAM_SIZE
69 #define IPV4_MAX_FRAG_DATAGRAM_SIZE 8192
70#elif (IPV4_MAX_FRAG_DATAGRAM_SIZE < 576)
71 #error IPV4_MAX_FRAG_DATAGRAM_SIZE parameter is not valid
72#endif
73
74//Maximum time an IPv4 fragment can spend waiting to be reassembled
75#ifndef IPV4_FRAG_TIME_TO_LIVE
76 #define IPV4_FRAG_TIME_TO_LIVE 15000
77#elif (IPV4_FRAG_TIME_TO_LIVE < 1000)
78 #error IPV4_FRAG_TIME_TO_LIVE parameter is not valid
79#endif
80
81//Infinity is implemented by a very large integer
82#define IPV4_INFINITY 0xFFFF
83
84//C++ guard
85#ifdef __cplusplus
86extern "C" {
87#endif
88
89
90//CodeWarrior or Win32 compiler?
91#if defined(__CWCC__) || defined(_WIN32)
92 #pragma pack(push, 1)
93#endif
94
95
101{
102 uint16_t first;
103 uint16_t last;
104 uint16_t next;
105} Ipv4HoleDesc;
106
107
108//CodeWarrior or Win32 compiler?
109#if defined(__CWCC__) || defined(_WIN32)
110 #pragma pack(pop)
111#endif
112
113
118typedef struct
119{
120 uint_t chunkCount;
121 uint_t maxChunkCount;
122 ChunkDesc chunk[N(IPV4_MAX_FRAG_DATAGRAM_SIZE) + 1];
124
125
138
139
140//Tick counter to handle periodic operations
141extern systime_t ipv4FragTickCounter;
142
143//IPv4 datagram fragmentation and reassembly
144error_t ipv4FragmentDatagram(NetInterface *interface,
145 const Ipv4PseudoHeader *pseudoHeader, uint16_t id, const NetBuffer *payload,
146 size_t payloadOffset, NetTxAncillary *ancillary);
147
148void ipv4ReassembleDatagram(NetInterface *interface, const Ipv4Header *packet,
149 size_t length, NetRxAncillary *ancillary);
150
151void ipv4FragTick(NetInterface *interface);
152
153Ipv4FragDesc *ipv4SearchFragQueue(NetInterface *interface,
154 const Ipv4Header *packet);
155
156void ipv4FlushFragQueue(NetInterface *interface);
157
158Ipv4HoleDesc *ipv4FindHole(Ipv4FragDesc *frag, uint16_t offset);
159void ipv4DumpHoleList(Ipv4FragDesc *frag);
160
161//C++ guard
162#ifdef __cplusplus
163}
164#endif
165
166#endif
error_t
Error codes.
Definition error.h:43
IPv4 (Internet Protocol Version 4)
typedef __packed_struct
Hole descriptor.
Definition ipv4_frag.h:101
TCP/IP stack core.
uint32_t systime_t
System time.
Definition os_port_none.h:90
Structure describing a chunk of data.
Definition net_mem.h:77
Fragmented packet descriptor.
Definition ipv4_frag.h:131
systime_t timestamp
Time at which the first fragment was received.
Definition ipv4_frag.h:132
size_t headerLength
Length of the header.
Definition ipv4_frag.h:133
Ipv4ReassemblyBuffer buffer
Buffer containing the reassembled datagram.
Definition ipv4_frag.h:136
size_t dataLen
Length of the payload.
Definition ipv4_frag.h:134
uint16_t firstHole
Index of the first hole.
Definition ipv4_frag.h:135
Reassembly buffer.
Definition ipv4_frag.h:119
Structure describing a buffer that spans multiple chunks.
Definition net_mem.h:89