Helper functions for IPv4. More...
Go to the source code of this file.
Functions | |
error_t | ipv4AddRouterAlertOption (NetBuffer *buffer, size_t *offset) |
Append a Router Alert option to an IPv4 packet. More... | |
error_t | ipv4CheckSourceAddr (NetInterface *interface, Ipv4Addr ipAddr) |
Source IPv4 address filtering. More... | |
error_t | ipv4CheckDestAddr (NetInterface *interface, Ipv4Addr ipAddr) |
Destination IPv4 address filtering. More... | |
error_t | ipv4SelectSourceAddr (NetInterface **interface, Ipv4Addr destAddr, Ipv4Addr *srcAddr) |
IPv4 source address selection. More... | |
error_t | ipv4SelectDefaultGateway (NetInterface *interface, Ipv4Addr srcAddr, Ipv4Addr *defaultGatewayAddr) |
Default gateway selection. More... | |
bool_t | ipv4IsHostAddrValid (NetInterface *interface) |
Check whether a valid IPv4 address has been assigned to the interface. More... | |
bool_t | ipv4IsOnLink (NetInterface *interface, Ipv4Addr ipAddr) |
Check whether an IPv4 address is on-link. More... | |
bool_t | ipv4IsBroadcastAddr (NetInterface *interface, Ipv4Addr ipAddr) |
Check whether an IPv4 address is a broadcast address. More... | |
bool_t | ipv4IsTentativeAddr (NetInterface *interface, Ipv4Addr ipAddr) |
Check whether an IPv4 address is a tentative address. More... | |
bool_t | ipv4IsLocalHostAddr (Ipv4Addr ipAddr) |
Check whether the specified IPv4 is assigned to the host. More... | |
bool_t | ipv4CompPrefix (Ipv4Addr ipAddr1, Ipv4Addr ipAddr2, size_t length) |
Compare IPv4 address prefixes. More... | |
uint_t | ipv4GetAddrScope (Ipv4Addr ipAddr) |
Retrieve the scope of an IPv4 address. More... | |
uint_t | ipv4GetPrefixLength (Ipv4Addr mask) |
Calculate prefix length for a given subnet mask. More... | |
error_t | ipv4GetBroadcastAddr (NetInterface *interface, Ipv4Addr *addr) |
Get IPv4 broadcast address. More... | |
bool_t | ipv4TrapIgmpPacket (Ipv4Header *header) |
Trap IGMP packets. More... | |
void | ipv4UpdateInStats (NetInterface *interface, Ipv4Addr destIpAddr, size_t length) |
Update IPv4 input statistics. More... | |
void | ipv4UpdateOutStats (NetInterface *interface, Ipv4Addr destIpAddr, size_t length) |
Update IPv4 output statistics. More... | |
void | ipv4UpdateErrorStats (NetInterface *interface, error_t error) |
Update Ethernet error statistics. More... | |
Detailed Description
Helper functions for IPv4.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 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.
- Version
- 2.4.4
Definition in file ipv4_misc.h.
Function Documentation
◆ ipv4AddRouterAlertOption()
Append a Router Alert option to an IPv4 packet.
- Parameters
-
[in] buffer Multi-part buffer containing the payload [in,out] offset Offset to the first payload byte
- Returns
- Error code
Definition at line 53 of file ipv4_misc.c.
◆ ipv4CheckDestAddr()
error_t ipv4CheckDestAddr | ( | NetInterface * | interface, |
Ipv4Addr | ipAddr | ||
) |
Destination IPv4 address filtering.
- Parameters
-
[in] interface Underlying network interface [in] ipAddr Destination IPv4 address to be checked
- Returns
- Error code
Definition at line 116 of file ipv4_misc.c.
◆ ipv4CheckSourceAddr()
error_t ipv4CheckSourceAddr | ( | NetInterface * | interface, |
Ipv4Addr | ipAddr | ||
) |
Source IPv4 address filtering.
- Parameters
-
[in] interface Underlying network interface [in] ipAddr Source IPv4 address to be checked
- Returns
- Error code
Definition at line 92 of file ipv4_misc.c.
◆ ipv4CompPrefix()
Compare IPv4 address prefixes.
- Parameters
-
[in] ipAddr1 First IPv4 address [in] ipAddr2 Second IPv4 address [in] length Prefix length
- Returns
- TRUE if the prefixes match each other, else FALSE
Definition at line 626 of file ipv4_misc.c.
◆ ipv4GetAddrScope()
Retrieve the scope of an IPv4 address.
- Parameters
-
[in] ipAddr IPv4 address
- Returns
- IPv4 address scope
Definition at line 662 of file ipv4_misc.c.
◆ ipv4GetBroadcastAddr()
error_t ipv4GetBroadcastAddr | ( | NetInterface * | interface, |
Ipv4Addr * | addr | ||
) |
Get IPv4 broadcast address.
- Parameters
-
[in] interface Pointer to the desired network interface [out] addr IPv4 broadcast address
Definition at line 754 of file ipv4_misc.c.
◆ ipv4GetPrefixLength()
Calculate prefix length for a given subnet mask.
- Parameters
-
[in] mask Subnet mask
- Returns
- Prefix length
Definition at line 726 of file ipv4_misc.c.
◆ ipv4IsBroadcastAddr()
bool_t ipv4IsBroadcastAddr | ( | NetInterface * | interface, |
Ipv4Addr | ipAddr | ||
) |
Check whether an IPv4 address is a broadcast address.
- Parameters
-
[in] interface Underlying network interface [in] ipAddr IPv4 address to be checked
- Returns
- TRUE if the IPv4 address is a broadcast address, else FALSE
Definition at line 476 of file ipv4_misc.c.
◆ ipv4IsHostAddrValid()
bool_t ipv4IsHostAddrValid | ( | NetInterface * | interface | ) |
Check whether a valid IPv4 address has been assigned to the interface.
- Parameters
-
[in] interface Underlying network interface
- Returns
- TRUE if a valid IPv4 address has been assigned, else FALSE
Definition at line 404 of file ipv4_misc.c.
◆ ipv4IsLocalHostAddr()
Check whether the specified IPv4 is assigned to the host.
- Parameters
-
[in] ipAddr IPv4 address to be checked
- Returns
- TRUE if the IPv4 address matches any address assigned to the host, else FALSE
Definition at line 569 of file ipv4_misc.c.
◆ ipv4IsOnLink()
bool_t ipv4IsOnLink | ( | NetInterface * | interface, |
Ipv4Addr | ipAddr | ||
) |
Check whether an IPv4 address is on-link.
- Parameters
-
[in] interface Underlying network interface [in] ipAddr IPv4 address to be checked
- Returns
- TRUE if the IPv4 address is on-link, else FALSE
Definition at line 438 of file ipv4_misc.c.
◆ ipv4IsTentativeAddr()
bool_t ipv4IsTentativeAddr | ( | NetInterface * | interface, |
Ipv4Addr | ipAddr | ||
) |
Check whether an IPv4 address is a tentative address.
- Parameters
-
[in] interface Underlying network interface [in] ipAddr IPv4 address to be checked
- Returns
- TRUE if the IPv4 address is a tentative address, else FALSE
Definition at line 530 of file ipv4_misc.c.
◆ ipv4SelectDefaultGateway()
error_t ipv4SelectDefaultGateway | ( | NetInterface * | interface, |
Ipv4Addr | srcAddr, | ||
Ipv4Addr * | defaultGatewayAddr | ||
) |
Default gateway selection.
- Parameters
-
[in] interface Underlying network interface [in] srcAddr Source IPv4 address [out] defaultGatewayAddr IPv4 address of the gateway
- Returns
- Error code
Definition at line 363 of file ipv4_misc.c.
◆ ipv4SelectSourceAddr()
error_t ipv4SelectSourceAddr | ( | NetInterface ** | interface, |
Ipv4Addr | destAddr, | ||
Ipv4Addr * | srcAddr | ||
) |
IPv4 source address selection.
This function selects the source address and the relevant network interface to be used in order to join the specified destination address
- Parameters
-
[in,out] interface A pointer to a valid network interface may be provided as a hint. The function returns a pointer identifying the interface to be used [in] destAddr Destination IPv4 address [out] srcAddr Local IPv4 address to be used
- Returns
- Error code
Definition at line 174 of file ipv4_misc.c.
◆ ipv4TrapIgmpPacket()
bool_t ipv4TrapIgmpPacket | ( | Ipv4Header * | header | ) |
Trap IGMP packets.
- Parameters
-
[in] header Pointer to the IPv4 header
- Returns
- TRUE if the IPv4 packet contains an IGMP message, else FALSE
Definition at line 804 of file ipv4_misc.c.
◆ ipv4UpdateErrorStats()
void ipv4UpdateErrorStats | ( | NetInterface * | interface, |
error_t | error | ||
) |
Update Ethernet error statistics.
- Parameters
-
[in] interface Underlying network interface [in] error Status code describing the error
Definition at line 929 of file ipv4_misc.c.
◆ ipv4UpdateInStats()
void ipv4UpdateInStats | ( | NetInterface * | interface, |
Ipv4Addr | destIpAddr, | ||
size_t | length | ||
) |
Update IPv4 input statistics.
- Parameters
-
[in] interface Underlying network interface [in] destIpAddr Destination IP address [in] length Length of the incoming IP packet
Definition at line 834 of file ipv4_misc.c.
◆ ipv4UpdateOutStats()
void ipv4UpdateOutStats | ( | NetInterface * | interface, |
Ipv4Addr | destIpAddr, | ||
size_t | length | ||
) |
Update IPv4 output statistics.
- Parameters
-
[in] interface Underlying network interface [in] destIpAddr Destination IP address [in] length Length of the outgoing IP packet
Definition at line 875 of file ipv4_misc.c.