TCPIP_STACK_NetConfigSet Function
C
TCPIP_NETWORK_CONFIG* TCPIP_STACK_NetConfigSet(
void* configStoreBuff,
void* netConfigBuff,
size_t buffSize,
size_t* pNeededSize
);
Description
This function restores data from a previous dump buffer and updates the supplied interface configuration. All the data is recovered and constructed into the netConfigBuff (supposing this buffer is large enough). If this operation succeeded, the netConfigBuff can be safely cast to a (TCPIP_NETWORK_CONFIG*).
The structure of the netConfigBuff is as follows:
A TCPIP_NETWORK_CONFIG structure is created at the very beginning of the buffer.
All of the necessary fields that are part of the TCPIP_NETWORK_CONFIG will be placed in the buffer itself.
Preconditions
The TCP/IP stack should have been initialized by TCPIP_STACK_Initialize() and the TCPIP_STACK_Status() returned SYS_STATUS_READY.
Parameters
Parameters | Description |
---|---|
configStoreBuff | Pointer to a buffer that received configuration data from a TCPIP_STACK_NetConfigGet() call. |
netConfigBuff | Pointer to a buffer that will receive the TCPIP_NETWORK_CONFIG data. |
buffSize | Size of the supplied netConfigBugg buffer. |
pNeededSize | Pointer to store the size needed for storage. Can be NULL if not needed. If supplied, the pNeededSize will be updated with the actual size that's needed for the netConfigBuff. |
Returns
TValid TCPIP_NETWORK_CONFIG pointer (netConfigBuff) if netConfigBuff was successfully updated.
0 if the netConfigBuff is not supplied or is not large enough.
Remarks
The function is a helper for being able to restore the configuration data. Its companion function, TCPIP_STACK_NetConfigGet(), saves the TCPIP_NETWORK_CNFIG to a dump buffer.
Example
uint8_t currConfig[200];
uint8_t restoreBuff[200];
size_t neededSize, result;
TCPIP_NET_HANDLE hNet = TCPIP_STACK_NetHandleGet("PIC32INT");
result = TCPIP_STACK_NetConfigGet(hNet, currConfig, sizeof(currConfig), &neededSize);
if(result > 0)
{
// store the currConfig buffer to some external storage (neededSize bytes needed)
// later on restore the configuration
TCPIP_NETWORK_CONFIG* netConfig;
// extract the network configuration from the previously saved buffer
netConfig = TCPIP_STACK_NetConfigSet(currConfig, restoreBuff, sizeof(restoreBuff), &neededSize);
if(netConfig)
{
// use this netConfig to initialize a network interface
TCPIP_STACK_NetUp(hNet, netConfig);
}
}