ipv4.h
Go to the documentation of this file.
1 /**
2  * @file ipv4.h
3  * @brief IPv4 (Internet Protocol Version 4)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _IPV4_H
32 #define _IPV4_H
33 
34 //Forward declaration of structures
35 struct _Ipv4Header;
36 #define Ipv4Header struct _Ipv4Header
37 
38 struct _Ipv4PseudoHeader;
39 #define Ipv4PseudoHeader struct _Ipv4PseudoHeader
40 
41 //Dependencies
42 #include "core/net.h"
43 #include "core/ethernet.h"
44 #include "ipv4/ipv4_frag.h"
45 
46 //IPv4 support
47 #ifndef IPV4_SUPPORT
48  #define IPV4_SUPPORT ENABLED
49 #elif (IPV4_SUPPORT != ENABLED && IPV4_SUPPORT != DISABLED)
50  #error IPV4_SUPPORT parameter is not valid
51 #endif
52 
53 //IPsec support
54 #ifndef IPV4_IPSEC_SUPPORT
55  #define IPV4_IPSEC_SUPPORT DISABLED
56 #elif (IPV4_IPSEC_SUPPORT != ENABLED && IPV4_IPSEC_SUPPORT != DISABLED)
57  #error IPV4_IPSEC_SUPPORT parameter is not valid
58 #endif
59 
60 //Default IPv4 time-to-live value
61 #ifndef IPV4_DEFAULT_TTL
62  #define IPV4_DEFAULT_TTL 64
63 #elif (IPV4_DEFAULT_TTL < 1)
64  #error IPV4_DEFAULT_TTL parameter is not valid
65 #endif
66 
67 //Maximum number of IPv4 addresses
68 #ifndef IPV4_ADDR_LIST_SIZE
69  #define IPV4_ADDR_LIST_SIZE 1
70 #elif (IPV4_ADDR_LIST_SIZE < 1)
71  #error IPV4_ADDR_LIST_SIZE parameter is not valid
72 #endif
73 
74 //Maximum number of DNS servers
75 #ifndef IPV4_DNS_SERVER_LIST_SIZE
76  #define IPV4_DNS_SERVER_LIST_SIZE 2
77 #elif (IPV4_DNS_SERVER_LIST_SIZE < 1)
78  #error IPV4_DNS_SERVER_LIST_SIZE parameter is not valid
79 #endif
80 
81 //Size of the IPv4 multicast filter
82 #ifndef IPV4_MULTICAST_FILTER_SIZE
83  #define IPV4_MULTICAST_FILTER_SIZE 4
84 #elif (IPV4_MULTICAST_FILTER_SIZE < 1)
85  #error IPV4_MULTICAST_FILTER_SIZE parameter is not valid
86 #endif
87 
88 //Maximum number of multicast sources
89 #ifndef IPV4_MAX_MULTICAST_SOURCES
90  #define IPV4_MAX_MULTICAST_SOURCES 0
91 #elif (IPV4_MAX_MULTICAST_SOURCES < 0)
92  #error IPV4_MAX_MULTICAST_SOURCES parameter is not valid
93 #endif
94 
95 //Version number for IPv4
96 #define IPV4_VERSION 4
97 //Minimum MTU
98 #define IPV4_MINIMUM_MTU 68
99 //Default MTU
100 #define IPV4_DEFAULT_MTU 576
101 //Minimum header length
102 #define IPV4_MIN_HEADER_LENGTH 20
103 //Maximum header length
104 #define IPV4_MAX_HEADER_LENGTH 60
105 
106 //Shortcut to data field
107 #define IPV4_DATA(packet) ((uint8_t *) packet + packet->headerLength * 4)
108 
109 //Macro used for defining an IPv4 address
110 #ifdef _CPU_BIG_ENDIAN
111  #define IPV4_ADDR(a, b, c, d) (((uint32_t) (a) << 24) | ((b) << 16) | ((c) << 8) | (d))
112 #else
113  #define IPV4_ADDR(a, b, c, d) ((a) | ((b) << 8) | ((c) << 16) | ((uint32_t) (d) << 24))
114 #endif
115 
116 //Unspecified IPv4 address
117 #define IPV4_UNSPECIFIED_ADDR IPV4_ADDR(0, 0, 0, 0)
118 //Broadcast IPV4 address
119 #define IPV4_BROADCAST_ADDR IPV4_ADDR(255, 255, 255, 255)
120 
121 //Loopback IPv4 address
122 #define IPV4_LOOPBACK_ADDR IPV4_ADDR(127, 0, 0, 1)
123 #define IPV4_LOOPBACK_PREFIX IPV4_ADDR(127, 0, 0, 0)
124 #define IPV4_LOOPBACK_MASK IPV4_ADDR(255, 0, 0, 0)
125 
126 //Link-local addresses
127 #define IPV4_LINK_LOCAL_PREFIX IPV4_ADDR(169, 254, 0, 0)
128 #define IPV4_LINK_LOCAL_MASK IPV4_ADDR(255, 255, 0, 0)
129 
130 //Multicast addresses
131 #define IPV4_MULTICAST_PREFIX IPV4_ADDR(224, 0, 0, 0)
132 #define IPV4_MULTICAST_MASK IPV4_ADDR(240, 0, 0, 0)
133 
134 //Local Network Control Block (RFC 5771)
135 #define IPV4_MULTICAST_LNCB_PREFIX IPV4_ADDR(224, 0, 0, 0)
136 #define IPV4_MULTICAST_LNCB_MASK IPV4_ADDR(255, 255, 255, 0)
137 
138 //Internetwork Control Block (RFC 5771)
139 #define IPV4_MULTICAST_INCB_PREFIX IPV4_ADDR(224, 0, 1, 0)
140 #define IPV4_MULTICAST_INCB_MASK IPV4_ADDR(255, 255, 255, 0)
141 
142 //IPv4 address classes
143 #define IPV4_CLASS_A_ADDR IPV4_ADDR(0, 0, 0, 0)
144 #define IPV4_CLASS_A_MASK IPV4_ADDR(128, 0, 0, 0)
145 #define IPV4_CLASS_B_ADDR IPV4_ADDR(128, 0, 0, 0)
146 #define IPV4_CLASS_B_MASK IPV4_ADDR(192, 0, 0, 0)
147 #define IPV4_CLASS_C_ADDR IPV4_ADDR(192, 0, 0, 0)
148 #define IPV4_CLASS_C_MASK IPV4_ADDR(224, 0, 0, 0)
149 #define IPV4_CLASS_D_ADDR IPV4_ADDR(224, 0, 0, 0)
150 #define IPV4_CLASS_D_MASK IPV4_ADDR(240, 0, 0, 0)
151 #define IPV4_CLASS_E_ADDR IPV4_ADDR(240, 0, 0, 0)
152 #define IPV4_CLASS_E_MASK IPV4_ADDR(240, 0, 0, 0)
153 
154 //Copy IPv4 address
155 #define ipv4CopyAddr(destIpAddr, srcIpAddr) \
156  osMemcpy(destIpAddr, srcIpAddr, sizeof(Ipv4Addr))
157 
158 //Compare IPv4 addresses
159 #define ipv4CompAddr(ipAddr1, ipAddr2) \
160  (!osMemcmp(ipAddr1, ipAddr2, sizeof(Ipv4Addr)))
161 
162 //Determine whether an IPv4 address belongs to the subnet
163 #define ipv4IsOnSubnet(entry, ipAddr) \
164  (((ipAddr) & (entry)->subnetMask) == ((entry)->addr & (entry)->subnetMask))
165 
166 //Determine whether an IPv4 address is a loopback address
167 #define ipv4IsLoopbackAddr(ipAddr) \
168  (((ipAddr) & IPV4_LOOPBACK_MASK) == IPV4_LOOPBACK_PREFIX)
169 
170 //Determine whether an IPv4 address is a link-local address
171 #define ipv4IsLinkLocalAddr(ipAddr) \
172  (((ipAddr) & IPV4_LINK_LOCAL_MASK) == IPV4_LINK_LOCAL_PREFIX)
173 
174 //Determine whether an IPv4 address is a multicast address
175 #define ipv4IsMulticastAddr(ipAddr) \
176  (((ipAddr) & IPV4_MULTICAST_MASK) == IPV4_MULTICAST_PREFIX)
177 
178 //C++ guard
179 #ifdef __cplusplus
180 extern "C" {
181 #endif
182 
183 
184 /**
185  * @brief IPv4 address scopes
186  **/
187 
188 typedef enum
189 {
194 
195 
196 /**
197  * @brief IPv4 address state
198  **/
199 
200 typedef enum
201 {
202  IPV4_ADDR_STATE_INVALID = 0, ///<An address that is not assigned to any interface
203  IPV4_ADDR_STATE_TENTATIVE = 1, ///<An address whose uniqueness on a link is being verified
204  IPV4_ADDR_STATE_VALID = 2 ///<An address assigned to an interface whose use is unrestricted
206 
207 
208 /**
209  * @brief IPv4 type-of-service
210  **/
211 
212 typedef enum
213 {
229 
230 
231 /**
232  * @brief IPv4 fragment offset field
233  **/
234 
235 typedef enum
236 {
237  IPV4_FLAG_RES = 0x8000,
238  IPV4_FLAG_DF = 0x4000,
239  IPV4_FLAG_MF = 0x2000,
240  IPV4_OFFSET_MASK = 0x1FFF
242 
243 
244 /**
245  * @brief IPv4 protocol field
246  **/
247 
248 typedef enum
249 {
255  IPV4_PROTOCOL_AH = 51
257 
258 
259 /**
260  * @brief IPv4 option types
261  **/
262 
263 typedef enum
264 {
265  IPV4_OPTION_EEOL = 0, ///<End of Options List
266  IPV4_OPTION_NOP = 1, ///<No Operation
267  IPV4_OPTION_RR = 7, ///<Record Route
268  IPV4_OPTION_ZSU = 10, ///<Experimental Measurement
269  IPV4_OPTION_MTUP = 11, ///<MTU Probe
270  IPV4_OPTION_MTUR = 12, ///<MTU Reply
271  IPV4_OPTION_ENCODE = 15, ///<Experimental IP encryption
272  IPV4_OPTION_QS = 25, ///<Quick-Start
273  IPV4_OPTION_TS = 68, ///<Time Stamp
274  IPV4_OPTION_TR = 82, ///<Traceroute
275  IPV4_OPTION_SEC = 130, ///<Security
276  IPV4_OPTION_LSR = 131, ///<Loose Source Route
277  IPV4_OPTION_ESEC = 133, ///<Extended Security
278  IPV4_OPTION_CIPSO = 134, ///<Commercial Security
279  IPV4_OPTION_SID = 136, ///<Stream ID
280  IPV4_OPTION_SSR = 137, ///<Strict Source Route
281  IPV4_OPTION_VISA = 142, ///<Experimental Access Control
282  IPV4_OPTION_IMITD = 144, ///<IMI Traffic Descriptor
283  IPV4_OPTION_EIP = 145, ///<Extended Internet Protocol
284  IPV4_OPTION_ADDEXT = 147, ///<Address Extension
285  IPV4_OPTION_RTRALT = 148, ///<Router Alert
286  IPV4_OPTION_SDB = 149, ///<Selective Directed Broadcast
287  IPV4_OPTION_DPS = 151, ///<Dynamic Packet State
288  IPV4_OPTION_UMP = 152, ///<Upstream Multicast Packet
289  IPV4_OPTION_FINN = 205 ///<Experimental Flow Control
291 
292 
293 /**
294  * @brief IPv4 network address
295  **/
296 
297 typedef uint32_t Ipv4Addr;
298 
299 
300 //CC-RX, CodeWarrior or Win32 compiler?
301 #if defined(__CCRX__)
302  #pragma pack
303 #elif defined(__CWCC__) || defined(_WIN32)
304  #pragma pack(push, 1)
305 #endif
306 
307 
308 /**
309  * @brief IPv4 header
310  **/
311 
313 {
314 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
315  uint8_t version : 4; //0
316  uint8_t headerLength : 4;
317 #else
318  uint8_t headerLength : 4; //0
319  uint8_t version : 4;
320 #endif
321  uint8_t typeOfService; //1
322  uint16_t totalLength; //2-3
323  uint16_t identification; //4-5
324  uint16_t fragmentOffset; //6-7
325  uint8_t timeToLive; //8
326  uint8_t protocol; //9
327  uint16_t headerChecksum; //10-11
328  Ipv4Addr srcAddr; //12-15
330  uint8_t options[]; //20
331 };
332 
333 
334 /**
335  * @brief IPv4 pseudo header
336  **/
337 
339 {
340  Ipv4Addr srcAddr; //0-3
341  Ipv4Addr destAddr; //4-7
342  uint8_t reserved; //8
343  uint8_t protocol; //9
344  uint16_t length; //10-11
345 };
346 
347 
348 /**
349  * @brief IPv4 option
350  **/
351 
353 {
354  uint8_t type; //0
355  uint8_t length; //1
356  uint8_t value[]; //2
358 
359 
360 /**
361  * @brief IPv4 Router Alert option
362  **/
363 
364 typedef __packed_struct
365 {
366  uint8_t type; //0
367  uint8_t length; //1
368  uint16_t value; //2-3
370 
371 
372 //CC-RX, CodeWarrior or Win32 compiler?
373 #if defined(__CCRX__)
374  #pragma unpack
375 #elif defined(__CWCC__) || defined(_WIN32)
376  #pragma pack(pop)
377 #endif
378 
379 
380 /**
381  * @brief IPv4 address entry
382  **/
383 
384 typedef struct
385 {
386  Ipv4Addr addr; ///<IPv4 address
387  Ipv4AddrState state; ///<IPv4 address state
388  bool_t conflict; ///<Address conflict detected
389  Ipv4Addr subnetMask; ///<Subnet mask
390  Ipv4Addr defaultGateway; ///<Default gateway
391 } Ipv4AddrEntry;
392 
393 
394 /**
395  * @brief Source address list
396  **/
397 
398 typedef struct
399 {
400  uint_t numSources; ///<Number of source addresses
401 #if (IPV4_MAX_MULTICAST_SOURCES > 0)
402  Ipv4Addr sources[IPV4_MAX_MULTICAST_SOURCES]; ///<Source addresses
403 #endif
405 
406 
407 /**
408  * @brief IPv4 multicast filter entry
409  **/
410 
411 typedef struct
412 {
413  Ipv4Addr addr; ///<Multicast address
414  uint_t anySourceRefCount; ///<Reference count for the current entry
415  bool_t macFilterConfigured; ///<MAC address filter is configured
416  uint_t srcFilterMode; ///<Source filter mode
417  Ipv4SrcAddrList srcFilter; ///<Source filter
419 
420 
421 /**
422  * @brief IPv4 context
423  **/
424 
425 typedef struct
426 {
427  size_t linkMtu; ///<Maximum transmission unit
428  bool_t isRouter; ///<A flag indicating whether routing is enabled on this interface
429  uint8_t defaultTtl; ///<Default time-to-live value
430  bool_t enableEchoReq; ///<Support for ICMP Echo Request messages
431  bool_t enableBroadcastEchoReq; ///<Support for broadcast ICMP Echo Request messages
432  uint16_t identification; ///<IPv4 fragment identification field
433  Ipv4AddrEntry addrList[IPV4_ADDR_LIST_SIZE]; ///<IPv4 address list
434  Ipv4Addr dnsServerList[IPV4_DNS_SERVER_LIST_SIZE]; ///<DNS servers
435  Ipv4FilterEntry multicastFilter[IPV4_MULTICAST_FILTER_SIZE]; ///<Multicast filter table
436 #if (IPV4_FRAG_SUPPORT == ENABLED)
437  Ipv4FragDesc fragQueue[IPV4_MAX_FRAG_DATAGRAMS]; ///<IPv4 fragment reassembly queue
438 #endif
439 } Ipv4Context;
440 
441 
442 //IPv4 related functions
443 error_t ipv4Init(NetInterface *interface);
444 
445 error_t ipv4SetDefaultTtl(NetInterface *interface, uint8_t ttl);
446 
450 
451 error_t ipv4GetHostAddrEx(NetInterface *interface, uint_t index,
452  Ipv4Addr *addr);
453 
455 
457  Ipv4Addr mask);
458 
460 
462  Ipv4Addr *mask);
463 
465 
467  Ipv4Addr addr);
468 
470 
472  Ipv4Addr *addr);
473 
476 
477 void ipv4LinkChangeEvent(NetInterface *interface);
478 
479 void ipv4ProcessPacket(NetInterface *interface, Ipv4Header *packet,
480  size_t length, NetRxAncillary *ancillary);
481 
482 void ipv4ProcessDatagram(NetInterface *interface, const NetBuffer *buffer,
483  size_t offset, NetRxAncillary *ancillary);
484 
486  const Ipv4PseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset,
487  NetTxAncillary *ancillary);
488 
490  const Ipv4PseudoHeader *pseudoHeader, uint16_t fragId, size_t fragOffset,
491  NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary);
492 
495 
496 void ipv4DumpHeader(const Ipv4Header *ipHeader);
497 
498 //C++ guard
499 #ifdef __cplusplus
500 }
501 #endif
502 
503 #endif
uint16_t headerChecksum
Definition: ipv4.h:327
int bool_t
Definition: compiler_port.h:53
Source address list.
Definition: ipv4.h:399
#define Ipv4Header
Definition: ipv4.h:36
Ipv4Addr destAddr
Definition: ipv4.h:329
Ipv4Addr addr
IPv4 address.
Definition: ipv4.h:386
@ IPV4_PROTOCOL_ICMP
Definition: ipv4.h:250
@ IPV4_OFFSET_MASK
Definition: ipv4.h:240
@ IPV4_OPTION_SDB
Selective Directed Broadcast.
Definition: ipv4.h:286
@ IPV4_TOS_PRECEDENCE_PRIORITY
Definition: ipv4.h:215
uint8_t value[]
Definition: ipv4.h:356
uint8_t protocol
Definition: ipv4.h:326
@ IPV4_ADDR_SCOPE_LINK_LOCAL
Definition: ipv4.h:191
error_t ipv4Init(NetInterface *interface)
IPv4 related initialization.
Definition: ipv4.c:80
@ IPV4_OPTION_FINN
Experimental Flow Control.
Definition: ipv4.h:289
__packed_struct _Ipv4PseudoHeader
IPv4 pseudo header.
Definition: ipv4.h:339
Ipv4Addr srcAddr
Definition: ipv4.h:328
void ipv4DumpHeader(const Ipv4Header *ipHeader)
Dump IPv4 header for debugging purpose.
Definition: ipv4.c:1481
@ IPV4_OPTION_SID
Stream ID.
Definition: ipv4.h:279
@ IPV4_TOS_PRECEDENCE_IMMEDIATE
Definition: ipv4.h:216
void ipv4ProcessDatagram(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetRxAncillary *ancillary)
Incoming IPv4 datagram processing.
Definition: ipv4.c:825
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
@ IPV4_OPTION_RR
Record Route.
Definition: ipv4.h:267
void ipv4LinkChangeEvent(NetInterface *interface)
Callback function for link change event.
Definition: ipv4.c:555
@ IPV4_OPTION_ADDEXT
Address Extension.
Definition: ipv4.h:284
error_t ipv4SetDefaultGateway(NetInterface *interface, Ipv4Addr addr)
Configure default gateway.
Definition: ipv4.c:389
Ipv4AddrState
IPv4 address state.
Definition: ipv4.h:201
@ IPV4_TOS_HIGH_RELIBILITY
Definition: ipv4.h:227
@ IPV4_TOS_NORMAL_DELAY
Definition: ipv4.h:222
@ IPV4_TOS_PRECEDENCE_NETWORK_CTRL
Definition: ipv4.h:221
@ IPV4_OPTION_VISA
Experimental Access Control.
Definition: ipv4.h:281
uint8_t defaultTtl
Default time-to-live value.
Definition: ipv4.h:429
uint8_t typeOfService
Definition: ipv4.h:321
uint8_t type
Definition: coap_common.h:176
error_t ipv4SetDefaultTtl(NetInterface *interface, uint8_t ttl)
Set default TTL value for outgoing IPv4 packets.
Definition: ipv4.c:129
bool_t macFilterConfigured
MAC address filter is configured.
Definition: ipv4.h:415
@ IPV4_OPTION_ESEC
Extended Security.
Definition: ipv4.h:277
#define IPV4_MAX_MULTICAST_SOURCES
Definition: ipv4.h:90
Ipv4AddrState state
IPv4 address state.
Definition: ipv4.h:387
uint16_t totalLength
Definition: ipv4.h:322
@ IPV4_OPTION_TR
Traceroute.
Definition: ipv4.h:274
Ipv4RouterAlertOption
Definition: ipv4.h:369
@ IPV4_TOS_PRECEDENCE_ROUTINE
Definition: ipv4.h:214
error_t ipv4GetHostAddr(NetInterface *interface, Ipv4Addr *addr)
Retrieve host address.
Definition: ipv4.c:228
@ IPV4_OPTION_NOP
No Operation.
Definition: ipv4.h:266
uint8_t reserved
Definition: ipv4.h:342
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:297
error_t ipv4GetDnsServer(NetInterface *interface, uint_t index, Ipv4Addr *addr)
Retrieve DNS server.
Definition: ipv4.c:523
IPv4 context.
Definition: ipv4.h:426
@ IPV4_OPTION_EIP
Extended Internet Protocol.
Definition: ipv4.h:283
Ethernet.
bool_t isRouter
A flag indicating whether routing is enabled on this interface.
Definition: ipv4.h:428
error_t ipv4GetSubnetMaskEx(NetInterface *interface, uint_t index, Ipv4Addr *mask)
Retrieve subnet mask.
Definition: ipv4.c:354
error_t ipv4GetDefaultGateway(NetInterface *interface, Ipv4Addr *addr)
Retrieve default gateway.
Definition: ipv4.c:438
@ IPV4_PROTOCOL_TCP
Definition: ipv4.h:252
error_t ipv4SetHostAddrEx(NetInterface *interface, uint_t index, Ipv4Addr addr)
Assign host address.
Definition: ipv4.c:169
Ipv4FragmentOffset
IPv4 fragment offset field.
Definition: ipv4.h:236
@ IPV4_OPTION_LSR
Loose Source Route.
Definition: ipv4.h:276
@ IPV4_PROTOCOL_AH
Definition: ipv4.h:255
Ipv4Addr defaultGateway
Default gateway.
Definition: ipv4.h:390
Ipv4AddrScope
IPv4 address scopes.
Definition: ipv4.h:189
@ IPV4_OPTION_MTUP
MTU Probe.
Definition: ipv4.h:269
size_t linkMtu
Maximum transmission unit.
Definition: ipv4.h:427
error_t
Error codes.
Definition: error.h:43
@ IPV4_ADDR_STATE_TENTATIVE
An address whose uniqueness on a link is being verified.
Definition: ipv4.h:203
bool_t enableEchoReq
Support for ICMP Echo Request messages.
Definition: ipv4.h:430
@ IPV4_OPTION_UMP
Upstream Multicast Packet.
Definition: ipv4.h:288
@ IPV4_OPTION_ZSU
Experimental Measurement.
Definition: ipv4.h:268
@ IPV4_FLAG_MF
Definition: ipv4.h:239
Ipv4OptionType
IPv4 option types.
Definition: ipv4.h:264
#define IPV4_DNS_SERVER_LIST_SIZE
Definition: ipv4.h:76
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
@ IPV4_OPTION_DPS
Dynamic Packet State.
Definition: ipv4.h:287
uint_t numSources
Number of source addresses.
Definition: ipv4.h:400
uint16_t identification
IPv4 fragment identification field.
Definition: ipv4.h:432
@ IPV4_FLAG_DF
Definition: ipv4.h:238
IPv4 multicast filter entry.
Definition: ipv4.h:412
__packed_struct _Ipv4Header
IPv4 header.
Definition: ipv4.h:313
#define NetTxAncillary
Definition: net_misc.h:36
@ IPV4_OPTION_TS
Time Stamp.
Definition: ipv4.h:273
uint8_t mask
Definition: web_socket.h:319
Ipv4TypeOfService
IPv4 type-of-service.
Definition: ipv4.h:213
uint8_t fragOffset[3]
Definition: dtls_misc.h:192
error_t ipv4GetDefaultGatewayEx(NetInterface *interface, uint_t index, Ipv4Addr *addr)
Retrieve default gateway.
Definition: ipv4.c:453
#define Ipv4PseudoHeader
Definition: ipv4.h:39
#define IPV4_ADDR_LIST_SIZE
Definition: ipv4.h:69
error_t ipv4SendPacket(NetInterface *interface, const Ipv4PseudoHeader *pseudoHeader, uint16_t fragId, size_t fragOffset, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send an IPv4 packet.
Definition: ipv4.c:1096
void ipv4ProcessPacket(NetInterface *interface, Ipv4Header *packet, size_t length, NetRxAncillary *ancillary)
Incoming IPv4 packet processing.
Definition: ipv4.c:606
uint16_t length
Definition: ipv4.h:344
@ IPV4_TOS_PRECEDENCE_FLASH_OVERRIDE
Definition: ipv4.h:218
IPv4 address entry.
Definition: ipv4.h:385
@ IPV4_FLAG_RES
Definition: ipv4.h:237
@ IPV4_OPTION_IMITD
IMI Traffic Descriptor.
Definition: ipv4.h:282
@ IPV4_TOS_PRECEDENCE_INTERNETWORK_CTRL
Definition: ipv4.h:220
uint_t anySourceRefCount
Reference count for the current entry.
Definition: ipv4.h:414
@ IPV4_OPTION_MTUR
MTU Reply.
Definition: ipv4.h:270
@ IPV4_TOS_NORMAL_RELIBILITY
Definition: ipv4.h:226
@ IPV4_PROTOCOL_IGMP
Definition: ipv4.h:251
@ IPV4_ADDR_SCOPE_INTERFACE_LOCAL
Definition: ipv4.h:190
@ IPV4_TOS_PRECEDENCE_FLASH
Definition: ipv4.h:217
Fragmented packet descriptor.
Definition: ipv4_frag.h:135
@ IPV4_OPTION_ENCODE
Experimental IP encryption.
Definition: ipv4.h:271
#define IPV4_MAX_FRAG_DATAGRAMS
Definition: ipv4_frag.h:62
char char_t
Definition: compiler_port.h:48
@ IPV4_OPTION_SSR
Strict Source Route.
Definition: ipv4.h:280
Ipv4Addr addr
Multicast address.
Definition: ipv4.h:413
@ IPV4_OPTION_EEOL
End of Options List.
Definition: ipv4.h:265
Ipv4Addr subnetMask
Subnet mask.
Definition: ipv4.h:389
uint16_t identification
Definition: ipv4.h:323
@ IPV4_TOS_PRECEDENCE_CRITIC_ECP
Definition: ipv4.h:219
@ IPV4_TOS_NORMAL_THROUGHPUT
Definition: ipv4.h:224
IPv4 fragmentation and reassembly.
@ IPV4_PROTOCOL_UDP
Definition: ipv4.h:253
error_t ipv4GetHostAddrEx(NetInterface *interface, uint_t index, Ipv4Addr *addr)
Retrieve host address.
Definition: ipv4.c:243
uint_t srcFilterMode
Source filter mode.
Definition: ipv4.h:416
@ IPV4_ADDR_STATE_INVALID
An address that is not assigned to any interface.
Definition: ipv4.h:202
@ IPV4_PROTOCOL_ESP
Definition: ipv4.h:254
Ipv4Option
Definition: ipv4.h:357
Ipv4SrcAddrList srcFilter
Source filter.
Definition: ipv4.h:417
error_t ipv4GetSubnetMask(NetInterface *interface, Ipv4Addr *mask)
Retrieve subnet mask.
Definition: ipv4.c:339
error_t ipv4SetHostAddr(NetInterface *interface, Ipv4Addr addr)
Assign host address.
Definition: ipv4.c:154
@ IPV4_TOS_HIGH_THROUGHPUT
Definition: ipv4.h:225
typedef __packed_struct
IPv4 option.
Definition: ipv4.h:353
@ IPV4_OPTION_RTRALT
Router Alert.
Definition: ipv4.h:285
Ipv4Addr ipAddr
Definition: ipcp.h:105
Ipv4Protocol
IPv4 protocol field.
Definition: ipv4.h:249
@ IPV4_OPTION_SEC
Security.
Definition: ipv4.h:275
@ IPV4_ADDR_STATE_VALID
An address assigned to an interface whose use is unrestricted.
Definition: ipv4.h:204
Ipv4Addr addr
Definition: nbns_common.h:123
bool_t conflict
Address conflict detected.
Definition: ipv4.h:388
error_t ipv4SetDnsServer(NetInterface *interface, uint_t index, Ipv4Addr addr)
Configure DNS server.
Definition: ipv4.c:489
char_t * ipv4AddrToString(Ipv4Addr ipAddr, char_t *str)
Convert a binary IPv4 address to dot-decimal notation.
Definition: ipv4.c:1457
uint32_t ttl
Definition: dns_common.h:221
uint8_t options[]
Definition: ipv4.h:330
error_t ipv4StringToAddr(const char_t *str, Ipv4Addr *ipAddr)
Convert a dot-decimal string to a binary IPv4 address.
Definition: ipv4.c:1368
@ IPV4_OPTION_CIPSO
Commercial Security.
Definition: ipv4.h:278
uint8_t timeToLive
Definition: ipv4.h:325
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
error_t ipv4SendDatagram(NetInterface *interface, const Ipv4PseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send an IPv4 datagram.
Definition: ipv4.c:1010
@ IPV4_TOS_LOW_DELAY
Definition: ipv4.h:223
bool_t enableBroadcastEchoReq
Support for broadcast ICMP Echo Request messages.
Definition: ipv4.h:431
error_t ipv4SetDefaultGatewayEx(NetInterface *interface, uint_t index, Ipv4Addr addr)
Configure default gateway.
Definition: ipv4.c:404
@ IPV4_OPTION_QS
Quick-Start.
Definition: ipv4.h:272
uint16_t fragmentOffset
Definition: ipv4.h:324
error_t ipv4SetSubnetMaskEx(NetInterface *interface, uint_t index, Ipv4Addr mask)
Configure subnet mask.
Definition: ipv4.c:309
error_t ipv4SetSubnetMask(NetInterface *interface, Ipv4Addr mask)
Configure subnet mask.
Definition: ipv4.c:294
@ IPV4_ADDR_SCOPE_GLOBAL
Definition: ipv4.h:192
uint8_t version
Definition: ipv4.h:319
#define IPV4_MULTICAST_FILTER_SIZE
Definition: ipv4.h:83