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