NetIPv4_CfgAddrAdd
Add a statically-configured IPv4 host address, subnet mask, and default gateway to an interface.
Files
net_ipv4.h/net_ipv4.c
Prototype
CPU_BOOLEAN NetIPv4_CfgAddrAdd(NET_IF_NBR if_nbr, NET_IPv4_ADDR addr_host, NET_IPv4_ADDR addr_subnet_mask, NET_IPv4_ADDR addr_dflt_gateway, NET_ERR *p_err);
Arguments
if_nbr
Interface number to configure.
addr_host
Desired IPv4 address to add to this interface.
addr_subnet_mask
Desired IPv4 address subnet mask.
addr_dflt_gateway
Desired IPv4 default gateway address.
p_err
Pointer to variable that will receive the error code from this function:
NET_IPv4_ERR_NONE
NET_IPv4_ERR_INVALID_ADDR_HOST
NET_IPv4_ERR_INVALID_ADDR_GATEWAY
NET_IPv4_ERR_ADDR_CFG_STATE
NET_IPv4_ERR_ADDR_TBL_FULL
NET_IPv4_ERR_ADDR_CFG_IN_USE
NET_IF_ERR_INVALID_IF
NET_ERR_FAULT_LOCK_ACQUIRE
Returned Value
DEF_OK
,
if valid IPv4 address, subnet mask, and default gateway statically-configured;
DEF_FAIL
,
otherwise.
Required Configuration
None.
Notes / Warnings
IPv4 addresses must be configured in host-order.
An interface may be configured with either:
- One or more statically- configured IPv4 addresses (default configuration) or
- Exactly one dynamically-configured IPv4 address (see function NetIPv4_CfgAddrAddDynamic).
If an interface’s address(es) are dynamically-configured, no statically-configured address(es) may be added until all dynamically-configured address(es) are removed.
The maximum number of IPv4 address(es) configured on any interface is limited to NET_IPv4_CFG_IF_MAX_NBR_ADDR
(see section IPv4 Layer Configuration).
Note that on the default interface, the first IPv4 address added will be the default address used for all default communication. See also function NetIF_Add.
A host may be configured without a gateway address to allow communication only with other hosts on its local network. However, any configured gateway address must be on the same network as the configured host IPv4 address (i.e., the network portion of the configured IPv4 address and the configured gateway addresses must be identical).