Go to the documentation of this file.
36 #define Ipv4Header struct _Ipv4Header
39 #define Ipv4PseudoHeader struct _Ipv4PseudoHeader
48 #define IPV4_SUPPORT ENABLED
49 #elif (IPV4_SUPPORT != ENABLED && IPV4_SUPPORT != DISABLED)
50 #error IPV4_SUPPORT parameter is not valid
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
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
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
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
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
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
96 #define IPV4_VERSION 4
98 #define IPV4_MINIMUM_MTU 68
100 #define IPV4_DEFAULT_MTU 576
102 #define IPV4_MIN_HEADER_LENGTH 20
104 #define IPV4_MAX_HEADER_LENGTH 60
107 #define IPV4_DATA(packet) ((uint8_t *) packet + packet->headerLength * 4)
110 #ifdef _CPU_BIG_ENDIAN
111 #define IPV4_ADDR(a, b, c, d) (((uint32_t) (a) << 24) | ((b) << 16) | ((c) << 8) | (d))
113 #define IPV4_ADDR(a, b, c, d) ((a) | ((b) << 8) | ((c) << 16) | ((uint32_t) (d) << 24))
117 #define IPV4_UNSPECIFIED_ADDR IPV4_ADDR(0, 0, 0, 0)
119 #define IPV4_BROADCAST_ADDR IPV4_ADDR(255, 255, 255, 255)
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)
127 #define IPV4_LINK_LOCAL_PREFIX IPV4_ADDR(169, 254, 0, 0)
128 #define IPV4_LINK_LOCAL_MASK IPV4_ADDR(255, 255, 0, 0)
131 #define IPV4_MULTICAST_PREFIX IPV4_ADDR(224, 0, 0, 0)
132 #define IPV4_MULTICAST_MASK IPV4_ADDR(240, 0, 0, 0)
135 #define IPV4_MULTICAST_LNCB_PREFIX IPV4_ADDR(224, 0, 0, 0)
136 #define IPV4_MULTICAST_LNCB_MASK IPV4_ADDR(255, 255, 255, 0)
139 #define IPV4_MULTICAST_INCB_PREFIX IPV4_ADDR(224, 0, 1, 0)
140 #define IPV4_MULTICAST_INCB_MASK IPV4_ADDR(255, 255, 255, 0)
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)
155 #define ipv4CopyAddr(destIpAddr, srcIpAddr) \
156 osMemcpy(destIpAddr, srcIpAddr, sizeof(Ipv4Addr))
159 #define ipv4CompAddr(ipAddr1, ipAddr2) \
160 (!osMemcmp(ipAddr1, ipAddr2, sizeof(Ipv4Addr)))
163 #define ipv4IsOnSubnet(entry, ipAddr) \
164 (((ipAddr) & (entry)->subnetMask) == ((entry)->addr & (entry)->subnetMask))
167 #define ipv4IsLoopbackAddr(ipAddr) \
168 (((ipAddr) & IPV4_LOOPBACK_MASK) == IPV4_LOOPBACK_PREFIX)
171 #define ipv4IsLinkLocalAddr(ipAddr) \
172 (((ipAddr) & IPV4_LINK_LOCAL_MASK) == IPV4_LINK_LOCAL_PREFIX)
175 #define ipv4IsMulticastAddr(ipAddr) \
176 (((ipAddr) & IPV4_MULTICAST_MASK) == IPV4_MULTICAST_PREFIX)
301 #if defined(__CCRX__)
303 #elif defined(__CWCC__) || defined(_WIN32)
304 #pragma pack(push, 1)
314 #if defined(_CPU_BIG_ENDIAN) && !defined(__ICCRX__)
316 uint8_t headerLength : 4;
318 uint8_t headerLength : 4;
373 #if defined(__CCRX__)
375 #elif defined(__CWCC__) || defined(_WIN32)
401 #if (IPV4_MAX_MULTICAST_SOURCES > 0)
436 #if (IPV4_FRAG_SUPPORT == ENABLED)
Ipv4Addr addr
IPv4 address.
@ IPV4_OPTION_SDB
Selective Directed Broadcast.
@ IPV4_TOS_PRECEDENCE_PRIORITY
@ IPV4_ADDR_SCOPE_LINK_LOCAL
error_t ipv4Init(NetInterface *interface)
IPv4 related initialization.
@ IPV4_OPTION_FINN
Experimental Flow Control.
__packed_struct _Ipv4PseudoHeader
IPv4 pseudo header.
void ipv4DumpHeader(const Ipv4Header *ipHeader)
Dump IPv4 header for debugging purpose.
@ IPV4_OPTION_SID
Stream ID.
@ IPV4_TOS_PRECEDENCE_IMMEDIATE
void ipv4ProcessDatagram(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetRxAncillary *ancillary)
Incoming IPv4 datagram processing.
Structure describing a buffer that spans multiple chunks.
@ IPV4_OPTION_RR
Record Route.
void ipv4LinkChangeEvent(NetInterface *interface)
Callback function for link change event.
@ IPV4_OPTION_ADDEXT
Address Extension.
error_t ipv4SetDefaultGateway(NetInterface *interface, Ipv4Addr addr)
Configure default gateway.
Ipv4AddrState
IPv4 address state.
@ IPV4_TOS_HIGH_RELIBILITY
@ IPV4_TOS_PRECEDENCE_NETWORK_CTRL
@ IPV4_OPTION_VISA
Experimental Access Control.
uint8_t defaultTtl
Default time-to-live value.
error_t ipv4SetDefaultTtl(NetInterface *interface, uint8_t ttl)
Set default TTL value for outgoing IPv4 packets.
bool_t macFilterConfigured
MAC address filter is configured.
@ IPV4_OPTION_ESEC
Extended Security.
#define IPV4_MAX_MULTICAST_SOURCES
Ipv4AddrState state
IPv4 address state.
@ IPV4_OPTION_TR
Traceroute.
@ IPV4_TOS_PRECEDENCE_ROUTINE
error_t ipv4GetHostAddr(NetInterface *interface, Ipv4Addr *addr)
Retrieve host address.
@ IPV4_OPTION_NOP
No Operation.
uint32_t Ipv4Addr
IPv4 network address.
error_t ipv4GetDnsServer(NetInterface *interface, uint_t index, Ipv4Addr *addr)
Retrieve DNS server.
@ IPV4_OPTION_EIP
Extended Internet Protocol.
bool_t isRouter
A flag indicating whether routing is enabled on this interface.
error_t ipv4GetSubnetMaskEx(NetInterface *interface, uint_t index, Ipv4Addr *mask)
Retrieve subnet mask.
error_t ipv4GetDefaultGateway(NetInterface *interface, Ipv4Addr *addr)
Retrieve default gateway.
error_t ipv4SetHostAddrEx(NetInterface *interface, uint_t index, Ipv4Addr addr)
Assign host address.
Ipv4FragmentOffset
IPv4 fragment offset field.
@ IPV4_OPTION_LSR
Loose Source Route.
Ipv4Addr defaultGateway
Default gateway.
Ipv4AddrScope
IPv4 address scopes.
@ IPV4_OPTION_MTUP
MTU Probe.
size_t linkMtu
Maximum transmission unit.
@ IPV4_ADDR_STATE_TENTATIVE
An address whose uniqueness on a link is being verified.
bool_t enableEchoReq
Support for ICMP Echo Request messages.
@ IPV4_OPTION_UMP
Upstream Multicast Packet.
@ IPV4_OPTION_ZSU
Experimental Measurement.
Ipv4OptionType
IPv4 option types.
#define IPV4_DNS_SERVER_LIST_SIZE
@ IPV4_OPTION_DPS
Dynamic Packet State.
uint_t numSources
Number of source addresses.
uint16_t identification
IPv4 fragment identification field.
IPv4 multicast filter entry.
__packed_struct _Ipv4Header
IPv4 header.
@ IPV4_OPTION_TS
Time Stamp.
Ipv4TypeOfService
IPv4 type-of-service.
error_t ipv4GetDefaultGatewayEx(NetInterface *interface, uint_t index, Ipv4Addr *addr)
Retrieve default gateway.
#define IPV4_ADDR_LIST_SIZE
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.
void ipv4ProcessPacket(NetInterface *interface, Ipv4Header *packet, size_t length, NetRxAncillary *ancillary)
Incoming IPv4 packet processing.
@ IPV4_TOS_PRECEDENCE_FLASH_OVERRIDE
@ IPV4_OPTION_IMITD
IMI Traffic Descriptor.
@ IPV4_TOS_PRECEDENCE_INTERNETWORK_CTRL
uint_t anySourceRefCount
Reference count for the current entry.
@ IPV4_OPTION_MTUR
MTU Reply.
@ IPV4_TOS_NORMAL_RELIBILITY
@ IPV4_ADDR_SCOPE_INTERFACE_LOCAL
@ IPV4_TOS_PRECEDENCE_FLASH
Fragmented packet descriptor.
@ IPV4_OPTION_ENCODE
Experimental IP encryption.
#define IPV4_MAX_FRAG_DATAGRAMS
@ IPV4_OPTION_SSR
Strict Source Route.
Ipv4Addr addr
Multicast address.
@ IPV4_OPTION_EEOL
End of Options List.
Ipv4Addr subnetMask
Subnet mask.
@ IPV4_TOS_PRECEDENCE_CRITIC_ECP
@ IPV4_TOS_NORMAL_THROUGHPUT
IPv4 fragmentation and reassembly.
error_t ipv4GetHostAddrEx(NetInterface *interface, uint_t index, Ipv4Addr *addr)
Retrieve host address.
uint_t srcFilterMode
Source filter mode.
@ IPV4_ADDR_STATE_INVALID
An address that is not assigned to any interface.
Ipv4SrcAddrList srcFilter
Source filter.
error_t ipv4GetSubnetMask(NetInterface *interface, Ipv4Addr *mask)
Retrieve subnet mask.
error_t ipv4SetHostAddr(NetInterface *interface, Ipv4Addr addr)
Assign host address.
@ IPV4_TOS_HIGH_THROUGHPUT
typedef __packed_struct
IPv4 option.
@ IPV4_OPTION_RTRALT
Router Alert.
Ipv4Protocol
IPv4 protocol field.
@ IPV4_OPTION_SEC
Security.
@ IPV4_ADDR_STATE_VALID
An address assigned to an interface whose use is unrestricted.
bool_t conflict
Address conflict detected.
error_t ipv4SetDnsServer(NetInterface *interface, uint_t index, Ipv4Addr addr)
Configure DNS server.
char_t * ipv4AddrToString(Ipv4Addr ipAddr, char_t *str)
Convert a binary IPv4 address to dot-decimal notation.
error_t ipv4StringToAddr(const char_t *str, Ipv4Addr *ipAddr)
Convert a dot-decimal string to a binary IPv4 address.
@ IPV4_OPTION_CIPSO
Commercial Security.
error_t ipv4SendDatagram(NetInterface *interface, const Ipv4PseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send an IPv4 datagram.
bool_t enableBroadcastEchoReq
Support for broadcast ICMP Echo Request messages.
error_t ipv4SetDefaultGatewayEx(NetInterface *interface, uint_t index, Ipv4Addr addr)
Configure default gateway.
@ IPV4_OPTION_QS
Quick-Start.
error_t ipv4SetSubnetMaskEx(NetInterface *interface, uint_t index, Ipv4Addr mask)
Configure subnet mask.
error_t ipv4SetSubnetMask(NetInterface *interface, Ipv4Addr mask)
Configure subnet mask.
#define IPV4_MULTICAST_FILTER_SIZE