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