Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Add a dynamically-configured IP IPv4 host address, subnet mask, and default gateway to an interface.

Files

net_ipipv4.h/net_ipipv4.c

Prototype

Code Block
          CPU_BOOLEAN NetIPv4_CfgAddrAddDynamic(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 IP IPv4 address to add to this interface.

addr_subnet_mask

Desired IP IPv4 address subnet mask.

addr_dflt_gateway

Desired IP IPv4 default gateway address.

perrp_err

Pointer to variable that will receive the return error code from this function:

NET_IPIPv4_ERR_NONE
NET_IPIPv4_ERR_INVALID_ADDR_HOST
NET_IPIPv4_ERR_INVALID_ADDR_GATEWAY
NET_IPIPv4_ERR_ADDR_CFG_STATE
NET_IPIPv4_ERR_ADDR_CFG_IN_USE
NET_IF_ERR_INVALID_IF
NET_ERR_INIT_INCOMPLETE
NET_OSERR_ERRFAULT_LOCK_ACQUIRE

Returned Value

DEF_OK,

if valid IP IPv4 address, subnet mask, and default gateway dynamically configured;

DEF_FAIL,

otherwise.

Required Configuration

None.

Notes / Warnings

IP IPv4 addresses must be configured in host-order.

...

This function should only be called by appropriate network application function(s) [e.g., DHCP initialization functions]. However, if the application attempts to dynamically configure IP IPv4 address(es), it must call NetIPNetIPv4_CfgAddrAddDynamicStart() before calling NetIPNetIPv4_CfgAddrAddDynamic(). Note that on the default interface, the first IP IPv4 address added will be the default address used for all default communication. See also section C-9-1function 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 IP IPv4 address (i.e., the network portion of the configured IP IPv4 address and the configured gateway addresses must be identical).