IPv4 (Internet Protocol Version 4) More...

#include "core/net.h"
#include "core/ethernet.h"
#include "ipv4/ipv4_frag.h"

Go to the source code of this file.

Data Structures

struct  Ipv4AddrEntry
 IPv4 address entry. More...
 
struct  Ipv4SrcAddrList
 Source address list. More...
 
struct  Ipv4FilterEntry
 IPv4 multicast filter entry. More...
 
struct  Ipv4Context
 IPv4 context. More...
 

Macros

#define Ipv4Header   struct _Ipv4Header
 
#define Ipv4PseudoHeader   struct _Ipv4PseudoHeader
 
#define IPV4_SUPPORT   ENABLED
 
#define IPV4_STATS_SUPPORT   ENABLED
 
#define IPV4_IPSEC_SUPPORT   DISABLED
 
#define IPV4_DEFAULT_TTL   64
 
#define IPV4_ADDR_LIST_SIZE   1
 
#define IPV4_DNS_SERVER_LIST_SIZE   2
 
#define IPV4_MULTICAST_FILTER_SIZE   4
 
#define IPV4_MAX_MULTICAST_SOURCES   0
 
#define IPV4_VERSION   4
 
#define IPV4_MINIMUM_MTU   68
 
#define IPV4_DEFAULT_MTU   576
 
#define IPV4_MIN_HEADER_LENGTH   20
 
#define IPV4_MAX_HEADER_LENGTH   60
 
#define IPV4_DATA(packet)   ((uint8_t *) packet + packet->headerLength * 4)
 
#define IPV4_ADDR(a, b, c, d)   ((a) | ((b) << 8) | ((c) << 16) | ((uint32_t) (d) << 24))
 
#define IPV4_UNSPECIFIED_ADDR   IPV4_ADDR(0, 0, 0, 0)
 
#define IPV4_BROADCAST_ADDR   IPV4_ADDR(255, 255, 255, 255)
 
#define IPV4_LOOPBACK_ADDR   IPV4_ADDR(127, 0, 0, 1)
 
#define IPV4_LOOPBACK_PREFIX   IPV4_ADDR(127, 0, 0, 0)
 
#define IPV4_LOOPBACK_MASK   IPV4_ADDR(255, 0, 0, 0)
 
#define IPV4_LINK_LOCAL_PREFIX   IPV4_ADDR(169, 254, 0, 0)
 
#define IPV4_LINK_LOCAL_MASK   IPV4_ADDR(255, 255, 0, 0)
 
#define IPV4_MULTICAST_PREFIX   IPV4_ADDR(224, 0, 0, 0)
 
#define IPV4_MULTICAST_MASK   IPV4_ADDR(240, 0, 0, 0)
 
#define IPV4_MULTICAST_LNCB_PREFIX   IPV4_ADDR(224, 0, 0, 0)
 
#define IPV4_MULTICAST_LNCB_MASK   IPV4_ADDR(255, 255, 255, 0)
 
#define IPV4_MULTICAST_INCB_PREFIX   IPV4_ADDR(224, 0, 1, 0)
 
#define IPV4_MULTICAST_INCB_MASK   IPV4_ADDR(255, 255, 255, 0)
 
#define IPV4_CLASS_A_ADDR   IPV4_ADDR(0, 0, 0, 0)
 
#define IPV4_CLASS_A_MASK   IPV4_ADDR(128, 0, 0, 0)
 
#define IPV4_CLASS_B_ADDR   IPV4_ADDR(128, 0, 0, 0)
 
#define IPV4_CLASS_B_MASK   IPV4_ADDR(192, 0, 0, 0)
 
#define IPV4_CLASS_C_ADDR   IPV4_ADDR(192, 0, 0, 0)
 
#define IPV4_CLASS_C_MASK   IPV4_ADDR(224, 0, 0, 0)
 
#define IPV4_CLASS_D_ADDR   IPV4_ADDR(224, 0, 0, 0)
 
#define IPV4_CLASS_D_MASK   IPV4_ADDR(240, 0, 0, 0)
 
#define IPV4_CLASS_E_ADDR   IPV4_ADDR(240, 0, 0, 0)
 
#define IPV4_CLASS_E_MASK   IPV4_ADDR(240, 0, 0, 0)
 
#define ipv4CopyAddr(destIpAddr, srcIpAddr)    osMemcpy(destIpAddr, srcIpAddr, sizeof(Ipv4Addr))
 
#define ipv4CompAddr(ipAddr1, ipAddr2)    (!osMemcmp(ipAddr1, ipAddr2, sizeof(Ipv4Addr)))
 
#define ipv4IsOnSubnet(entry, ipAddr)    (((ipAddr) & (entry)->subnetMask) == ((entry)->addr & (entry)->subnetMask))
 
#define ipv4IsLoopbackAddr(ipAddr)    (((ipAddr) & IPV4_LOOPBACK_MASK) == IPV4_LOOPBACK_PREFIX)
 
#define ipv4IsLinkLocalAddr(ipAddr)    (((ipAddr) & IPV4_LINK_LOCAL_MASK) == IPV4_LINK_LOCAL_PREFIX)
 
#define ipv4IsMulticastAddr(ipAddr)    (((ipAddr) & IPV4_MULTICAST_MASK) == IPV4_MULTICAST_PREFIX)
 
#define IPV4_SYSTEM_STATS_INC_COUNTER32(name, value)   interface->netContext->ipv4SystemStats.name += value
 
#define IPV4_SYSTEM_STATS_INC_COUNTER64(name, value)   interface->netContext->ipv4SystemStats.name += value
 
#define IPV4_IF_STATS_INC_COUNTER32(name, value)   interface->ipv4IfStats.name += value
 
#define IPV4_IF_STATS_INC_COUNTER64(name, value)   interface->ipv4IfStats.name += value
 

Typedefs

typedef uint32_t Ipv4Addr
 IPv4 network address. More...
 

Enumerations

enum  Ipv4AddrScope { IPV4_ADDR_SCOPE_INTERFACE_LOCAL = 1, IPV4_ADDR_SCOPE_LINK_LOCAL = 2, IPV4_ADDR_SCOPE_GLOBAL = 3 }
 IPv4 address scopes. More...
 
enum  Ipv4AddrState { IPV4_ADDR_STATE_INVALID = 0, IPV4_ADDR_STATE_TENTATIVE = 1, IPV4_ADDR_STATE_VALID = 2 }
 IPv4 address state. More...
 
enum  Ipv4TypeOfService {
  IPV4_TOS_PRECEDENCE_ROUTINE = 0x00, IPV4_TOS_PRECEDENCE_PRIORITY = 0x20, IPV4_TOS_PRECEDENCE_IMMEDIATE = 0x40, IPV4_TOS_PRECEDENCE_FLASH = 0x60,
  IPV4_TOS_PRECEDENCE_FLASH_OVERRIDE = 0x80, IPV4_TOS_PRECEDENCE_CRITIC_ECP = 0xA0, IPV4_TOS_PRECEDENCE_INTERNETWORK_CTRL = 0xC0, IPV4_TOS_PRECEDENCE_NETWORK_CTRL = 0xE0,
  IPV4_TOS_NORMAL_DELAY = 0x00, IPV4_TOS_LOW_DELAY = 0x10, IPV4_TOS_NORMAL_THROUGHPUT = 0x00, IPV4_TOS_HIGH_THROUGHPUT = 0x08,
  IPV4_TOS_NORMAL_RELIBILITY = 0x00, IPV4_TOS_HIGH_RELIBILITY = 0x04
}
 IPv4 type-of-service. More...
 
enum  Ipv4FragmentOffset { IPV4_FLAG_RES = 0x8000, IPV4_FLAG_DF = 0x4000, IPV4_FLAG_MF = 0x2000, IPV4_OFFSET_MASK = 0x1FFF }
 IPv4 fragment offset field. More...
 
enum  Ipv4Protocol {
  IPV4_PROTOCOL_NONE = 0, IPV4_PROTOCOL_ICMP = 1, IPV4_PROTOCOL_IGMP = 2, IPV4_PROTOCOL_TCP = 6,
  IPV4_PROTOCOL_UDP = 17, IPV4_PROTOCOL_ESP = 50, IPV4_PROTOCOL_AH = 51
}
 IPv4 protocol field. More...
 
enum  Ipv4OptionType {
  IPV4_OPTION_EEOL = 0, IPV4_OPTION_NOP = 1, IPV4_OPTION_RR = 7, IPV4_OPTION_ZSU = 10,
  IPV4_OPTION_MTUP = 11, IPV4_OPTION_MTUR = 12, IPV4_OPTION_ENCODE = 15, IPV4_OPTION_QS = 25,
  IPV4_OPTION_TS = 68, IPV4_OPTION_TR = 82, IPV4_OPTION_SEC = 130, IPV4_OPTION_LSR = 131,
  IPV4_OPTION_ESEC = 133, IPV4_OPTION_CIPSO = 134, IPV4_OPTION_SID = 136, IPV4_OPTION_SSR = 137,
  IPV4_OPTION_VISA = 142, IPV4_OPTION_IMITD = 144, IPV4_OPTION_EIP = 145, IPV4_OPTION_ADDEXT = 147,
  IPV4_OPTION_RTRALT = 148, IPV4_OPTION_SDB = 149, IPV4_OPTION_DPS = 151, IPV4_OPTION_UMP = 152,
  IPV4_OPTION_FINN = 205
}
 IPv4 option types. More...
 

Functions

error_t ipv4Init (NetInterface *interface)
 IPv4 related initialization. More...
 
error_t ipv4SetDefaultTtl (NetInterface *interface, uint8_t ttl)
 Set default TTL value for outgoing IPv4 packets. More...
 
error_t ipv4SetHostAddr (NetInterface *interface, Ipv4Addr addr)
 Assign host address. More...
 
error_t ipv4SetHostAddrEx (NetInterface *interface, uint_t index, Ipv4Addr addr)
 Assign host address. More...
 
error_t ipv4GetHostAddr (NetInterface *interface, Ipv4Addr *addr)
 Retrieve host address. More...
 
error_t ipv4GetHostAddrEx (NetInterface *interface, uint_t index, Ipv4Addr *addr)
 Retrieve host address. More...
 
error_t ipv4SetSubnetMask (NetInterface *interface, Ipv4Addr mask)
 Configure subnet mask. More...
 
error_t ipv4SetSubnetMaskEx (NetInterface *interface, uint_t index, Ipv4Addr mask)
 Configure subnet mask. More...
 
error_t ipv4GetSubnetMask (NetInterface *interface, Ipv4Addr *mask)
 Retrieve subnet mask. More...
 
error_t ipv4GetSubnetMaskEx (NetInterface *interface, uint_t index, Ipv4Addr *mask)
 Retrieve subnet mask. More...
 
error_t ipv4SetDefaultGateway (NetInterface *interface, Ipv4Addr addr)
 Configure default gateway. More...
 
error_t ipv4SetDefaultGatewayEx (NetInterface *interface, uint_t index, Ipv4Addr addr)
 Configure default gateway. More...
 
error_t ipv4GetDefaultGateway (NetInterface *interface, Ipv4Addr *addr)
 Retrieve default gateway. More...
 
error_t ipv4GetDefaultGatewayEx (NetInterface *interface, uint_t index, Ipv4Addr *addr)
 Retrieve default gateway. More...
 
error_t ipv4SetDnsServer (NetInterface *interface, uint_t index, Ipv4Addr addr)
 Configure DNS server. More...
 
error_t ipv4GetDnsServer (NetInterface *interface, uint_t index, Ipv4Addr *addr)
 Retrieve DNS server. More...
 
void ipv4LinkChangeEvent (NetInterface *interface)
 Callback function for link change event. More...
 
void ipv4ProcessPacket (NetInterface *interface, Ipv4Header *packet, size_t length, NetRxAncillary *ancillary)
 Incoming IPv4 packet processing. More...
 
void ipv4ProcessDatagram (NetInterface *interface, const NetBuffer *buffer, size_t offset, NetRxAncillary *ancillary)
 Incoming IPv4 datagram processing. More...
 
error_t ipv4SendDatagram (NetInterface *interface, const Ipv4PseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
 Send an IPv4 datagram. More...
 
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. More...
 
error_t ipv4StringToAddr (const char_t *str, Ipv4Addr *ipAddr)
 Convert a dot-decimal string to a binary IPv4 address. More...
 
char_tipv4AddrToString (Ipv4Addr ipAddr, char_t *str)
 Convert a binary IPv4 address to dot-decimal notation. More...
 
void ipv4DumpHeader (const Ipv4Header *ipHeader)
 Dump IPv4 header for debugging purpose. More...
 

Variables

__packed_struct _Ipv4Header
 IPv4 header. More...
 
uint8_t version
 
uint8_t typeOfService
 
uint16_t totalLength
 
uint16_t identification
 
uint16_t fragmentOffset
 
uint8_t timeToLive
 
uint8_t protocol
 
uint16_t headerChecksum
 
Ipv4Addr srcAddr
 
Ipv4Addr destAddr
 
uint8_t options []
 
__packed_struct _Ipv4PseudoHeader
 IPv4 pseudo header. More...
 
uint8_t reserved
 
uint16_t length
 
typedef __packed_struct
 IPv4 option. More...
 
uint8_t value []
 
 Ipv4Option
 
 Ipv4RouterAlertOption
 

Detailed Description

IPv4 (Internet Protocol Version 4)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.6.0

Definition in file ipv4.h.

Macro Definition Documentation

◆ IPV4_ADDR

#define IPV4_ADDR (   a,
  b,
  c,
 
)    ((a) | ((b) << 8) | ((c) << 16) | ((uint32_t) (d) << 24))

Definition at line 124 of file ipv4.h.

◆ IPV4_ADDR_LIST_SIZE

#define IPV4_ADDR_LIST_SIZE   1

Definition at line 80 of file ipv4.h.

◆ IPV4_BROADCAST_ADDR

#define IPV4_BROADCAST_ADDR   IPV4_ADDR(255, 255, 255, 255)

Definition at line 130 of file ipv4.h.

◆ IPV4_CLASS_A_ADDR

#define IPV4_CLASS_A_ADDR   IPV4_ADDR(0, 0, 0, 0)

Definition at line 154 of file ipv4.h.

◆ IPV4_CLASS_A_MASK

#define IPV4_CLASS_A_MASK   IPV4_ADDR(128, 0, 0, 0)

Definition at line 155 of file ipv4.h.

◆ IPV4_CLASS_B_ADDR

#define IPV4_CLASS_B_ADDR   IPV4_ADDR(128, 0, 0, 0)

Definition at line 156 of file ipv4.h.

◆ IPV4_CLASS_B_MASK

#define IPV4_CLASS_B_MASK   IPV4_ADDR(192, 0, 0, 0)

Definition at line 157 of file ipv4.h.

◆ IPV4_CLASS_C_ADDR

#define IPV4_CLASS_C_ADDR   IPV4_ADDR(192, 0, 0, 0)

Definition at line 158 of file ipv4.h.

◆ IPV4_CLASS_C_MASK

#define IPV4_CLASS_C_MASK   IPV4_ADDR(224, 0, 0, 0)

Definition at line 159 of file ipv4.h.

◆ IPV4_CLASS_D_ADDR

#define IPV4_CLASS_D_ADDR   IPV4_ADDR(224, 0, 0, 0)

Definition at line 160 of file ipv4.h.

◆ IPV4_CLASS_D_MASK

#define IPV4_CLASS_D_MASK   IPV4_ADDR(240, 0, 0, 0)

Definition at line 161 of file ipv4.h.

◆ IPV4_CLASS_E_ADDR

#define IPV4_CLASS_E_ADDR   IPV4_ADDR(240, 0, 0, 0)

Definition at line 162 of file ipv4.h.

◆ IPV4_CLASS_E_MASK

#define IPV4_CLASS_E_MASK   IPV4_ADDR(240, 0, 0, 0)

Definition at line 163 of file ipv4.h.

◆ IPV4_DATA

#define IPV4_DATA (   packet)    ((uint8_t *) packet + packet->headerLength * 4)

Definition at line 118 of file ipv4.h.

◆ IPV4_DEFAULT_MTU

#define IPV4_DEFAULT_MTU   576

Definition at line 111 of file ipv4.h.

◆ IPV4_DEFAULT_TTL

#define IPV4_DEFAULT_TTL   64

Definition at line 73 of file ipv4.h.

◆ IPV4_DNS_SERVER_LIST_SIZE

#define IPV4_DNS_SERVER_LIST_SIZE   2

Definition at line 87 of file ipv4.h.

◆ IPV4_IF_STATS_INC_COUNTER32

#define IPV4_IF_STATS_INC_COUNTER32 (   name,
  value 
)    interface->ipv4IfStats.name += value

Definition at line 193 of file ipv4.h.

◆ IPV4_IF_STATS_INC_COUNTER64

#define IPV4_IF_STATS_INC_COUNTER64 (   name,
  value 
)    interface->ipv4IfStats.name += value

Definition at line 194 of file ipv4.h.

◆ IPV4_IPSEC_SUPPORT

#define IPV4_IPSEC_SUPPORT   DISABLED

Definition at line 66 of file ipv4.h.

◆ IPV4_LINK_LOCAL_MASK

#define IPV4_LINK_LOCAL_MASK   IPV4_ADDR(255, 255, 0, 0)

Definition at line 139 of file ipv4.h.

◆ IPV4_LINK_LOCAL_PREFIX

#define IPV4_LINK_LOCAL_PREFIX   IPV4_ADDR(169, 254, 0, 0)

Definition at line 138 of file ipv4.h.

◆ IPV4_LOOPBACK_ADDR

#define IPV4_LOOPBACK_ADDR   IPV4_ADDR(127, 0, 0, 1)

Definition at line 133 of file ipv4.h.

◆ IPV4_LOOPBACK_MASK

#define IPV4_LOOPBACK_MASK   IPV4_ADDR(255, 0, 0, 0)

Definition at line 135 of file ipv4.h.

◆ IPV4_LOOPBACK_PREFIX

#define IPV4_LOOPBACK_PREFIX   IPV4_ADDR(127, 0, 0, 0)

Definition at line 134 of file ipv4.h.

◆ IPV4_MAX_HEADER_LENGTH

#define IPV4_MAX_HEADER_LENGTH   60

Definition at line 115 of file ipv4.h.

◆ IPV4_MAX_MULTICAST_SOURCES

#define IPV4_MAX_MULTICAST_SOURCES   0

Definition at line 101 of file ipv4.h.

◆ IPV4_MIN_HEADER_LENGTH

#define IPV4_MIN_HEADER_LENGTH   20

Definition at line 113 of file ipv4.h.

◆ IPV4_MINIMUM_MTU

#define IPV4_MINIMUM_MTU   68

Definition at line 109 of file ipv4.h.

◆ IPV4_MULTICAST_FILTER_SIZE

#define IPV4_MULTICAST_FILTER_SIZE   4

Definition at line 94 of file ipv4.h.

◆ IPV4_MULTICAST_INCB_MASK

#define IPV4_MULTICAST_INCB_MASK   IPV4_ADDR(255, 255, 255, 0)

Definition at line 151 of file ipv4.h.

◆ IPV4_MULTICAST_INCB_PREFIX

#define IPV4_MULTICAST_INCB_PREFIX   IPV4_ADDR(224, 0, 1, 0)

Definition at line 150 of file ipv4.h.

◆ IPV4_MULTICAST_LNCB_MASK

#define IPV4_MULTICAST_LNCB_MASK   IPV4_ADDR(255, 255, 255, 0)

Definition at line 147 of file ipv4.h.

◆ IPV4_MULTICAST_LNCB_PREFIX

#define IPV4_MULTICAST_LNCB_PREFIX   IPV4_ADDR(224, 0, 0, 0)

Definition at line 146 of file ipv4.h.

◆ IPV4_MULTICAST_MASK

#define IPV4_MULTICAST_MASK   IPV4_ADDR(240, 0, 0, 0)

Definition at line 143 of file ipv4.h.

◆ IPV4_MULTICAST_PREFIX

#define IPV4_MULTICAST_PREFIX   IPV4_ADDR(224, 0, 0, 0)

Definition at line 142 of file ipv4.h.

◆ IPV4_STATS_SUPPORT

#define IPV4_STATS_SUPPORT   ENABLED

Definition at line 56 of file ipv4.h.

◆ IPV4_SUPPORT

#define IPV4_SUPPORT   ENABLED

Definition at line 48 of file ipv4.h.

◆ IPV4_SYSTEM_STATS_INC_COUNTER32

#define IPV4_SYSTEM_STATS_INC_COUNTER32 (   name,
  value 
)    interface->netContext->ipv4SystemStats.name += value

Definition at line 191 of file ipv4.h.

◆ IPV4_SYSTEM_STATS_INC_COUNTER64

#define IPV4_SYSTEM_STATS_INC_COUNTER64 (   name,
  value 
)    interface->netContext->ipv4SystemStats.name += value

Definition at line 192 of file ipv4.h.

◆ IPV4_UNSPECIFIED_ADDR

#define IPV4_UNSPECIFIED_ADDR   IPV4_ADDR(0, 0, 0, 0)

Definition at line 128 of file ipv4.h.

◆ IPV4_VERSION

#define IPV4_VERSION   4

Definition at line 107 of file ipv4.h.

◆ ipv4CompAddr

#define ipv4CompAddr (   ipAddr1,
  ipAddr2 
)     (!osMemcmp(ipAddr1, ipAddr2, sizeof(Ipv4Addr)))

Definition at line 170 of file ipv4.h.

◆ ipv4CopyAddr

#define ipv4CopyAddr (   destIpAddr,
  srcIpAddr 
)     osMemcpy(destIpAddr, srcIpAddr, sizeof(Ipv4Addr))

Definition at line 166 of file ipv4.h.

◆ Ipv4Header

#define Ipv4Header   struct _Ipv4Header

Definition at line 36 of file ipv4.h.

◆ ipv4IsLinkLocalAddr

#define ipv4IsLinkLocalAddr (   ipAddr)     (((ipAddr) & IPV4_LINK_LOCAL_MASK) == IPV4_LINK_LOCAL_PREFIX)

Definition at line 182 of file ipv4.h.

◆ ipv4IsLoopbackAddr

#define ipv4IsLoopbackAddr (   ipAddr)     (((ipAddr) & IPV4_LOOPBACK_MASK) == IPV4_LOOPBACK_PREFIX)

Definition at line 178 of file ipv4.h.

◆ ipv4IsMulticastAddr

#define ipv4IsMulticastAddr (   ipAddr)     (((ipAddr) & IPV4_MULTICAST_MASK) == IPV4_MULTICAST_PREFIX)

Definition at line 186 of file ipv4.h.

◆ ipv4IsOnSubnet

#define ipv4IsOnSubnet (   entry,
  ipAddr 
)     (((ipAddr) & (entry)->subnetMask) == ((entry)->addr & (entry)->subnetMask))

Definition at line 174 of file ipv4.h.

◆ Ipv4PseudoHeader

#define Ipv4PseudoHeader   struct _Ipv4PseudoHeader

Definition at line 39 of file ipv4.h.

Typedef Documentation

◆ Ipv4Addr

typedef uint32_t Ipv4Addr

IPv4 network address.

Definition at line 322 of file ipv4.h.

Enumeration Type Documentation

◆ Ipv4AddrScope

IPv4 address scopes.

Enumerator
IPV4_ADDR_SCOPE_INTERFACE_LOCAL 
IPV4_ADDR_SCOPE_LINK_LOCAL 
IPV4_ADDR_SCOPE_GLOBAL 

Definition at line 212 of file ipv4.h.

◆ Ipv4AddrState

IPv4 address state.

Enumerator
IPV4_ADDR_STATE_INVALID 

An address that is not assigned to any interface.

IPV4_ADDR_STATE_TENTATIVE 

An address whose uniqueness on a link is being verified.

IPV4_ADDR_STATE_VALID 

An address assigned to an interface whose use is unrestricted.

Definition at line 224 of file ipv4.h.

◆ Ipv4FragmentOffset

IPv4 fragment offset field.

Enumerator
IPV4_FLAG_RES 
IPV4_FLAG_DF 
IPV4_FLAG_MF 
IPV4_OFFSET_MASK 

Definition at line 259 of file ipv4.h.

◆ Ipv4OptionType

IPv4 option types.

Enumerator
IPV4_OPTION_EEOL 

End of Options List.

IPV4_OPTION_NOP 

No Operation.

IPV4_OPTION_RR 

Record Route.

IPV4_OPTION_ZSU 

Experimental Measurement.

IPV4_OPTION_MTUP 

MTU Probe.

IPV4_OPTION_MTUR 

MTU Reply.

IPV4_OPTION_ENCODE 

Experimental IP encryption.

IPV4_OPTION_QS 

Quick-Start.

IPV4_OPTION_TS 

Time Stamp.

IPV4_OPTION_TR 

Traceroute.

IPV4_OPTION_SEC 

Security.

IPV4_OPTION_LSR 

Loose Source Route.

IPV4_OPTION_ESEC 

Extended Security.

IPV4_OPTION_CIPSO 

Commercial Security.

IPV4_OPTION_SID 

Stream ID.

IPV4_OPTION_SSR 

Strict Source Route.

IPV4_OPTION_VISA 

Experimental Access Control.

IPV4_OPTION_IMITD 

IMI Traffic Descriptor.

IPV4_OPTION_EIP 

Extended Internet Protocol.

IPV4_OPTION_ADDEXT 

Address Extension.

IPV4_OPTION_RTRALT 

Router Alert.

IPV4_OPTION_SDB 

Selective Directed Broadcast.

IPV4_OPTION_DPS 

Dynamic Packet State.

IPV4_OPTION_UMP 

Upstream Multicast Packet.

IPV4_OPTION_FINN 

Experimental Flow Control.

Definition at line 288 of file ipv4.h.

◆ Ipv4Protocol

IPv4 protocol field.

Enumerator
IPV4_PROTOCOL_NONE 
IPV4_PROTOCOL_ICMP 
IPV4_PROTOCOL_IGMP 
IPV4_PROTOCOL_TCP 
IPV4_PROTOCOL_UDP 
IPV4_PROTOCOL_ESP 
IPV4_PROTOCOL_AH 

Definition at line 272 of file ipv4.h.

◆ Ipv4TypeOfService

IPv4 type-of-service.

Enumerator
IPV4_TOS_PRECEDENCE_ROUTINE 
IPV4_TOS_PRECEDENCE_PRIORITY 
IPV4_TOS_PRECEDENCE_IMMEDIATE 
IPV4_TOS_PRECEDENCE_FLASH 
IPV4_TOS_PRECEDENCE_FLASH_OVERRIDE 
IPV4_TOS_PRECEDENCE_CRITIC_ECP 
IPV4_TOS_PRECEDENCE_INTERNETWORK_CTRL 
IPV4_TOS_PRECEDENCE_NETWORK_CTRL 
IPV4_TOS_NORMAL_DELAY 
IPV4_TOS_LOW_DELAY 
IPV4_TOS_NORMAL_THROUGHPUT 
IPV4_TOS_HIGH_THROUGHPUT 
IPV4_TOS_NORMAL_RELIBILITY 
IPV4_TOS_HIGH_RELIBILITY 

Definition at line 236 of file ipv4.h.

Function Documentation

◆ ipv4AddrToString()

char_t* ipv4AddrToString ( Ipv4Addr  ipAddr,
char_t str 
)

Convert a binary IPv4 address to dot-decimal notation.

Parameters
[in]ipAddrBinary representation of the IPv4 address
[out]strNULL-terminated string representing the IPv4 address
Returns
Pointer to the formatted string

Definition at line 1468 of file ipv4.c.

◆ ipv4DumpHeader()

void ipv4DumpHeader ( const Ipv4Header ipHeader)

Dump IPv4 header for debugging purpose.

Parameters
[in]ipHeaderPointer to the IPv4 header

Definition at line 1492 of file ipv4.c.

◆ ipv4GetDefaultGateway()

error_t ipv4GetDefaultGateway ( NetInterface interface,
Ipv4Addr addr 
)

Retrieve default gateway.

Parameters
[in]interfacePointer to the desired network interface
[out]addrDefault gateway address
Returns
Error code

Definition at line 437 of file ipv4.c.

◆ ipv4GetDefaultGatewayEx()

error_t ipv4GetDefaultGatewayEx ( NetInterface interface,
uint_t  index,
Ipv4Addr addr 
)

Retrieve default gateway.

Parameters
[in]interfacePointer to the desired network interface
[in]indexZero-based index
[out]addrDefault gateway address
Returns
Error code

Definition at line 452 of file ipv4.c.

◆ ipv4GetDnsServer()

error_t ipv4GetDnsServer ( NetInterface interface,
uint_t  index,
Ipv4Addr addr 
)

Retrieve DNS server.

Parameters
[in]interfacePointer to the desired network interface
[in]indexThis parameter selects between the primary and secondary DNS server
[out]addrDNS server address
Returns
Error code

Definition at line 522 of file ipv4.c.

◆ ipv4GetHostAddr()

error_t ipv4GetHostAddr ( NetInterface interface,
Ipv4Addr addr 
)

Retrieve host address.

Parameters
[in]interfacePointer to the desired network interface
[out]addrIPv4 host address
Returns
Error code

Definition at line 227 of file ipv4.c.

◆ ipv4GetHostAddrEx()

error_t ipv4GetHostAddrEx ( NetInterface interface,
uint_t  index,
Ipv4Addr addr 
)

Retrieve host address.

Parameters
[in]interfacePointer to the desired network interface
[in]indexZero-based index
[out]addrIPv4 host address
Returns
Error code

Definition at line 242 of file ipv4.c.

◆ ipv4GetSubnetMask()

error_t ipv4GetSubnetMask ( NetInterface interface,
Ipv4Addr mask 
)

Retrieve subnet mask.

Parameters
[in]interfacePointer to the desired network interface
[out]maskSubnet mask
Returns
Error code

Definition at line 338 of file ipv4.c.

◆ ipv4GetSubnetMaskEx()

error_t ipv4GetSubnetMaskEx ( NetInterface interface,
uint_t  index,
Ipv4Addr mask 
)

Retrieve subnet mask.

Parameters
[in]interfacePointer to the desired network interface
[in]indexZero-based index
[out]maskSubnet mask
Returns
Error code

Definition at line 353 of file ipv4.c.

◆ ipv4Init()

error_t ipv4Init ( NetInterface interface)

IPv4 related initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 79 of file ipv4.c.

◆ ipv4LinkChangeEvent()

void ipv4LinkChangeEvent ( NetInterface interface)

Callback function for link change event.

Parameters
[in]interfaceUnderlying network interface

Definition at line 554 of file ipv4.c.

◆ ipv4ProcessDatagram()

void ipv4ProcessDatagram ( NetInterface interface,
const NetBuffer buffer,
size_t  offset,
NetRxAncillary ancillary 
)

Incoming IPv4 datagram processing.

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer that holds the incoming IPv4 datagram
[in]offsetOffset from the beginning of the buffer
[in]ancillaryAdditional options passed to the stack along with the packet

Definition at line 830 of file ipv4.c.

◆ ipv4ProcessPacket()

void ipv4ProcessPacket ( NetInterface interface,
Ipv4Header packet,
size_t  length,
NetRxAncillary ancillary 
)

Incoming IPv4 packet processing.

Parameters
[in]interfaceUnderlying network interface
[in]packetIncoming IPv4 packet
[in]lengthPacket length including header and payload
[in]ancillaryAdditional options passed to the stack along with the packet

Definition at line 605 of file ipv4.c.

◆ ipv4SendDatagram()

error_t ipv4SendDatagram ( NetInterface interface,
const Ipv4PseudoHeader pseudoHeader,
NetBuffer buffer,
size_t  offset,
NetTxAncillary ancillary 
)

Send an IPv4 datagram.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderIPv4 pseudo header
[in]bufferMulti-part buffer containing the payload
[in]offsetOffset to the first byte of the payload
[in]ancillaryAdditional options passed to the stack along with the packet
Returns
Error code

Definition at line 1021 of file ipv4.c.

◆ ipv4SendPacket()

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.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderIPv4 pseudo header
[in]fragIdFragment identification field
[in]fragOffsetFragment offset field
[in]bufferMulti-part buffer containing the payload
[in]offsetOffset to the first byte of the payload
[in]ancillaryAdditional options passed to the stack along with the packet
Returns
Error code

Definition at line 1104 of file ipv4.c.

◆ ipv4SetDefaultGateway()

error_t ipv4SetDefaultGateway ( NetInterface interface,
Ipv4Addr  addr 
)

Configure default gateway.

Parameters
[in]interfacePointer to the desired network interface
[in]addrDefault gateway address
Returns
Error code

Definition at line 388 of file ipv4.c.

◆ ipv4SetDefaultGatewayEx()

error_t ipv4SetDefaultGatewayEx ( NetInterface interface,
uint_t  index,
Ipv4Addr  addr 
)

Configure default gateway.

Parameters
[in]interfacePointer to the desired network interface
[in]indexZero-based index
[in]addrDefault gateway address
Returns
Error code

Definition at line 403 of file ipv4.c.

◆ ipv4SetDefaultTtl()

error_t ipv4SetDefaultTtl ( NetInterface interface,
uint8_t  ttl 
)

Set default TTL value for outgoing IPv4 packets.

Parameters
[in]interfaceUnderlying network interface
[in]ttlDefault time-to-live value
Returns
Error code

Definition at line 128 of file ipv4.c.

◆ ipv4SetDnsServer()

error_t ipv4SetDnsServer ( NetInterface interface,
uint_t  index,
Ipv4Addr  addr 
)

Configure DNS server.

Parameters
[in]interfacePointer to the desired network interface
[in]indexThis parameter selects between the primary and secondary DNS server
[in]addrDNS server address
Returns
Error code

Definition at line 488 of file ipv4.c.

◆ ipv4SetHostAddr()

error_t ipv4SetHostAddr ( NetInterface interface,
Ipv4Addr  addr 
)

Assign host address.

Parameters
[in]interfacePointer to the desired network interface
[in]addrIPv4 host address
Returns
Error code

Definition at line 153 of file ipv4.c.

◆ ipv4SetHostAddrEx()

error_t ipv4SetHostAddrEx ( NetInterface interface,
uint_t  index,
Ipv4Addr  addr 
)

Assign host address.

Parameters
[in]interfacePointer to the desired network interface
[in]indexZero-based index
[in]addrIPv4 host address
Returns
Error code

Definition at line 168 of file ipv4.c.

◆ ipv4SetSubnetMask()

error_t ipv4SetSubnetMask ( NetInterface interface,
Ipv4Addr  mask 
)

Configure subnet mask.

Parameters
[in]interfacePointer to the desired network interface
[in]maskSubnet mask
Returns
Error code

Definition at line 293 of file ipv4.c.

◆ ipv4SetSubnetMaskEx()

error_t ipv4SetSubnetMaskEx ( NetInterface interface,
uint_t  index,
Ipv4Addr  mask 
)

Configure subnet mask.

Parameters
[in]interfacePointer to the desired network interface
[in]indexZero-based index
[in]maskSubnet mask
Returns
Error code

Definition at line 308 of file ipv4.c.

◆ ipv4StringToAddr()

error_t ipv4StringToAddr ( const char_t str,
Ipv4Addr ipAddr 
)

Convert a dot-decimal string to a binary IPv4 address.

Parameters
[in]strNULL-terminated string representing the IPv4 address
[out]ipAddrBinary representation of the IPv4 address
Returns
Error code

Definition at line 1379 of file ipv4.c.

Variable Documentation

◆ __packed_struct

typedef __packed_struct
Initial value:
{
uint8_t type

IPv4 option.

IPv4 Router Alert option.

Definition at line 377 of file ipv4.h.

◆ _Ipv4Header

__packed_struct _Ipv4Header
Initial value:
{
uint8_t headerLength : 4

IPv4 header.

Definition at line 337 of file ipv4.h.

◆ _Ipv4PseudoHeader

__packed_struct _Ipv4PseudoHeader
Initial value:

IPv4 pseudo header.

Definition at line 363 of file ipv4.h.

◆ destAddr

Ipv6Addr destAddr

Definition at line 354 of file ipv4.h.

◆ fragmentOffset

uint16_t fragmentOffset

Definition at line 349 of file ipv4.h.

◆ headerChecksum

uint16_t headerChecksum

Definition at line 352 of file ipv4.h.

◆ identification

uint16_t identification

Definition at line 348 of file ipv4.h.

◆ Ipv4Option

Ipv4Option

Definition at line 382 of file ipv4.h.

◆ Ipv4RouterAlertOption

Ipv4RouterAlertOption

Definition at line 394 of file ipv4.h.

◆ length

uint8_t length

Definition at line 369 of file ipv4.h.

◆ options

uint8_t options[]

Definition at line 355 of file ipv4.h.

◆ protocol

uint16_t protocol

Definition at line 351 of file ipv4.h.

◆ reserved

uint8_t reserved

Definition at line 367 of file ipv4.h.

◆ srcAddr

Ipv4Addr srcAddr

Definition at line 353 of file ipv4.h.

◆ timeToLive

uint8_t timeToLive

Definition at line 350 of file ipv4.h.

◆ totalLength

uint16_t totalLength

Definition at line 347 of file ipv4.h.

◆ typeOfService

uint8_t typeOfService

Definition at line 346 of file ipv4.h.

◆ value

uint16_t value

Definition at line 381 of file ipv4.h.

◆ version

uint8_t version

Definition at line 344 of file ipv4.h.

Ipv4Addr srcAddr
Definition: ipv4.h:353
uint8_t type
Definition: coap_common.h:176
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:322