TCPIP_STACK_NetAddressSet Function

C

bool TCPIP_STACK_NetAddressSet(
    TCPIP_NET_HANDLE netH, 
    IPV4_ADDR* ipAddress, 
    IPV4_ADDR* mask, 
    bool setDefault
);

Description

This function sets the associated network IP address and/or mask. If you're chaning the network then it is preferred that you set both of these values simultaneously to avoid having the stack running with a mismatch between its IP address and mask.

Preconditions

The TCPIP_STACK_Initialize() function must have been called before calling this function. The network interface should be up and running.

Parameters

ParametersDescription
netHInterface handle to set the address of.
ipAddressIP address to set (could be NULL to set only the mask).
maskCorresponding network mask to set (could be NULL to set only the IP address).
setDefaultIf true, the interface default address/mask is also set.

Returns

  • True - If success.

  • False - If no such interface or interface is not enabled.

Remarks

Exercise extreme caution when using these functions to change the settings of a running network interface. Chaning these parameters at runtime can lead to unexpected behavior or loss of network connectivity. The preferred way to change the parameters for a running interface is to do so as part of the network configuration passed at the stack initialization.

Example

TCPIP_NET_HANDLE netH = TCPIP_STACK_NetHandleGet("PIC32INT");
TCPIP_STACK_NetAddressSet(netH, &myIPAddress, &myIPMask, false);