SimpleLink CC31xx/CC32xx Host Driver  Version 3.0.1.65
Simplifies the implementation of Internet connectivity
NetCfg

Controls the configuration of the device addresses (i.e. IP and MAC addresses) More...

Functions

_i16 sl_NetCfgSet (const _u16 ConfigId, const _u16 ConfigOpt, const _u16 ConfigLen, const _u8 *pValues)
 Setting network configurations. More...
 
_i16 sl_NetCfgGet (const _u16 ConfigId, _u16 *pConfigOpt, _u16 *pConfigLen, _u8 *pValues)
 Getting network configurations. More...
 

Enumerations

enum  SlNetCfg_e {
  SL_NETCFG_MAC_ADDRESS_SET = 1,
  SL_NETCFG_MAC_ADDRESS_GET = 2,
  SL_NETCFG_AP_STATIONS_NUM_CONNECTED = 3,
  SL_NETCFG_AP_STATIONS_INFO_LIST = 4,
  SL_NETCFG_AP_STATION_DISCONNECT = 5,
  SL_NETCFG_IF = 6,
  SL_NETCFG_IPV4_STA_ADDR_MODE = 7,
  SL_NETCFG_IPV4_AP_ADDR_MODE = 8,
  SL_NETCFG_IPV6_ADDR_LOCAL = 9,
  SL_NETCFG_IPV6_ADDR_GLOBAL = 10,
  SL_NETCFG_IPV4_DHCP_CLIENT = 11,
  SL_NETCFG_IPV4_DNS_CLIENT = 12,
  SL_NETCFG_IPV6_DNS_CLIENT = 13,
  MAX_SETTINGS = 0xFF
}
 
enum  SlNetCfgIpv4DhcpClientState_e {
  SL_NETCFG_DHCP_CLIENT_UNKNOWN = 0,
  SL_NETCFG_DHCP_CLIENT_DISABLED,
  SL_NETCFG_DHCP_CLIENT_ENABLED,
  SL_NETCFG_DHCP_CLIENT_BOUND,
  SL_NETCFG_DHCP_CLIENT_RENEW,
  SL_NETCFG_DHCP_CLIENT_REBIND
}
 
enum  SlNetCfgDhcpOption_e {
  SL_NETCFG_DHCP_OPT_DISABLE_LLA = 0x2,
  SL_NETCFG_DHCP_OPT_RELEASE_IP_BEFORE_DISCONNECT = 0x4,
  MAX_SL_NETCFG_DHCP_OPT = 0xFF
}
 

Detailed Description

Controls the configuration of the device addresses (i.e. IP and MAC addresses)

Function Documentation

§ sl_NetCfgGet()

_i16 sl_NetCfgGet ( const _u16  ConfigId,
_u16 *  pConfigOpt,
_u16 *  pConfigLen,
_u8 *  pValues 
)

Getting network configurations.

Parameters
[in]ConfigIdConfiguration id
[out]pConfigOptGet configurations option
[out]pConfigLenThe length of the allocated memory as input, when the function complete, the value of this parameter would be the len that actually read from the device.
If the device return length that is longer from the input value, the function will cut the end of the returned structure and will return ESMALLBUF
[out]pValues- get configurations values
Returns
Zero on success, or -1 on failure
See also
sl_NetCfgSet
Note
Warning
Examples
  • SL_NETCFG_MAC_ADDRESS_GET:
    Get the device MAC address. The returned MAC address is taken from FileSystem first. If the MAC address was not set by SL_MAC_ADDRESS_SET, the default MAC address is retrieved from HW.
    _u8 macAddressVal[SL_MAC_ADDR_LEN];
    _u16 macAddressLen = SL_MAC_ADDR_LEN;
    _u16 ConfigOpt = 0;
    sl_NetCfgGet(SL_NETCFG_MAC_ADDRESS_GET,&ConfigOpt,&macAddressLen,(_u8 *)macAddressVal);

  • SL_NETCFG_IPV4_STA_ADDR_MODE:
    Get IP address from WLAN station or P2P client. A DHCP flag is returned to indicate if the IP address is static or from DHCP.
    _u16 len = sizeof(SlNetCfgIpV4Args_t);
    _u16 ConfigOpt = 0; //return value could be one of the following: SL_NETCFG_ADDR_DHCP / SL_NETCFG_ADDR_DHCP_LLA / SL_NETCFG_ADDR_STATIC
    SlNetCfgIpV4Args_t ipV4 = {0};
    sl_NetCfgGet(SL_NETCFG_IPV4_STA_ADDR_MODE,&ConfigOpt,&len,(_u8 *)&ipV4);
    printf("DHCP is %s IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
    (ConfigOpt == SL_NETCFG_ADDR_DHCP) ? "ON" : "OFF",
    SL_IPV4_BYTE(ipV4.Ip,3),SL_IPV4_BYTE(ipV4.Ip,2),SL_IPV4_BYTE(ipV4.Ip,1),SL_IPV4_BYTE(ipV4.Ip,0),
    SL_IPV4_BYTE(ipV4.IpMask,3),SL_IPV4_BYTE(ipV4.IpMask,2),SL_IPV4_BYTE(ipV4.IpMask,1),SL_IPV4_BYTE(ipV4.IpMask,0),
    SL_IPV4_BYTE(ipV4.IpGateway,3),SL_IPV4_BYTE(ipV4.IpGateway,2),SL_IPV4_BYTE(ipV4.IpGateway,1),SL_IPV4_BYTE(ipV4.IpGateway,0),
    SL_IPV4_BYTE(ipV4.IpDnsServer,3),SL_IPV4_BYTE(ipV4.IpDnsServer,2),SL_IPV4_BYTE(ipV4.IpDnsServer,1),SL_IPV4_BYTE(ipV4.IpDnsServer,0));

  • SL_NETCFG_IPV4_AP_ADDR_MODE:
    Get static IP address for AP or P2P go.
    _u16 len = sizeof(SlNetCfgIpV4Args_t);
    _u16 ConfigOpt = 0; //return value could be one of the following: SL_NETCFG_ADDR_DHCP / SL_NETCFG_ADDR_DHCP_LLA / SL_NETCFG_ADDR_STATIC
    SlNetCfgIpV4Args_t ipV4 = {0};
    sl_NetCfgGet(SL_NETCFG_IPV4_AP_ADDR_MODE,&ConfigOpt,&len,(_u8 *)&ipV4);
    printf("DHCP is %s IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
    (ConfigOpt == SL_NETCFG_ADDR_DHCP) ? "ON" : "OFF",
    SL_IPV4_BYTE(ipV4.Ip,3),SL_IPV4_BYTE(ipV4.Ip,2),SL_IPV4_BYTE(ipV4.Ip,1),SL_IPV4_BYTE(ipV4.Ip,0),
    SL_IPV4_BYTE(ipV4.IpMask,3),SL_IPV4_BYTE(ipV4.IpMask,2),SL_IPV4_BYTE(ipV4.IpMask,1),SL_IPV4_BYTE(ipV4.IpMask,0),
    SL_IPV4_BYTE(ipV4.IpGateway,3),SL_IPV4_BYTE(ipV4.IpGateway,2),SL_IPV4_BYTE(ipV4.IpGateway,1),SL_IPV4_BYTE(ipV4.IpGateway,0),
    SL_IPV4_BYTE(ipV4.IpDnsServer,3),SL_IPV4_BYTE(ipV4.IpDnsServer,2),SL_IPV4_BYTE(ipV4.IpDnsServer,1),SL_IPV4_BYTE(ipV4.IpDnsServer,0));

  • SL_NETCFG_IF:
    Get interface bitmap
    _u16 len;
    _u32 IfBitmap;
    len = sizeof(IfBitmap);
    sl_NetCfgGet(SL_NETCFG_IF,NULL,&len,(_u8 *)&IfBitmap);

  • SL_NETCFG_IPV6_ADDR_LOCAL:
    Get IPV6 Local address (ipV6.ipV6IsValid holds the address status. 1=Valid, ipv6 DAD completed and address is valid for use)
    _u16 len = sizeof(SlNetCfgIpV6Args_t);
    _u16 ConfigOpt = 0; //return value could be one of the following: SL_NETCFG_ADDR_STATIC / SL_NETCFG_ADDR_STATELESS / SL_NETCFG_ADDR_STATEFUL
    sl_NetCfgGet(SL_NETCFG_IPV6_ADDR_LOCAL,&ConfigOpt,&len,(_u8 *)&ipV6);
    if (SL_IS_IPV6_ADDR_VALID(ipV6.IpV6Flags))
    {
    printf("Ipv6 Local Address is valid: %8x:%8x:%8x:%8x\n", ipV6.Ip[0],ipV6.Ip[0],ipV6.Ip[0],ipV6.Ip[0]);
    }
    else
    {
    printf("Ipv6 Local Address is not valid, wait for DAD to complete or configure a different address");
    }

  • SL_NETCFG_IPV6_ADDR_GLOBAL:
    Get IPV6 Global address (ipV6.ipV6IsValid holds the address status. 1=Valid, ipv6 DAD completed and address is valid for use)
    _u16 len = sizeof(SlNetCfgIpV6Args_t);
    _u16 ConfigOpt = 0; //return value could be one of the following: SL_NETCFG_ADDR_STATIC / SL_NETCFG_ADDR_STATEFUL
    if (SL_IS_IPV6_ADDR_VALID(ipV6.IpV6Flags))
    {
    printf("Ipv6 Global Address is valid: %8x:%8x:%8x:%8x\n", ipV6.Ip[0],ipV6.Ip[0],ipV6.Ip[0],ipV6.Ip[0]);
    }
    else
    {
    printf("Ipv6 Global Address is not valid, wait for DAD to complete or configure a different address");
    }

  • SL_NETCFG_AP_STATIONS_NUM_CONNECTED:
    Get AP number of connected stations.
    _u8 num_ap_connected_sta;
    _u16 len = sizeof(num_ap_connected_sta);
    sl_NetCfgGet(SL_NETCFG_AP_STATIONS_NUM_CONNECTED, NULL, &len, &num_ap_connected_sta);
    printf("AP number of connected stations = %d\n", num_ap_connected_sta);

  • SL_NETCFG_AP_STATIONS_INFO_LIST:
    Get AP full list of connected stationss.
    SlNetCfgStaInfo_t ApStaList[4];
    _u16 sta_info_len;
    _u16 start_sta_index = 0;
    int actual_num_sta;
    int i;
    start_sta_index = 0;
    sta_info_len = sizeof(ApStaList);
    sl_NetCfgGet(SL_NETCFG_AP_STATIONS_INFO_LIST, &start_sta_index, &sta_info_len, (_u8 *)ApStaList);
    actual_num_sta = sta_info_len / sizeof(SlNetCfgStaInfo_t);
    printf("-Print SL_NETCFG_AP_STATIONS_INFO_LIST actual num_stations = %d (upon sta_info_len = %d)\n", actual_num_sta, sta_info_len);
    for (i=0; i<actual_num_sta; i++)
    {
    SlNetCfgStaInfo_t *staInfo = &ApStaList[i];
    printf(" Ap Station %d is connected\n", i);
    printf(" NAME: %s\n", staInfo->Name);
    printf(" MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", staInfo->MacAddr[0], staInfo->MacAddr[1], staInfo->MacAddr[2], staInfo->MacAddr[3], staInfo->MacAddr[4], staInfo->MacAddr[5]);
    printf(" IP: %d.%d.%d.%d\n", SL_IPV4_BYTE(staInfo->Ip,3), SL_IPV4_BYTE(staInfo->Ip,2), SL_IPV4_BYTE(staInfo->Ip,1), SL_IPV4_BYTE(staInfo->Ip,0));
    }

  • SL_NETCFG_IPV4_DNS_CLIENT:
    Get secondary DNS address (DHCP and static configuration)
    _u16 ConfigOpt = 0;
    _i32 Status;
    _u16 pConfigLen = sizeof(SlNetCfgIpV4DnsClientArgs_t);
    Status = sl_NetCfgGet(SL_NETCFG_IPV4_DNS_CLIENT,&ConfigOpt,&pConfigLen,&DnsOpt);
    if( Status )
    {
    // error
    }

  • SL_NETCFG_IPV6_DNS_CLIENT:
    Get secondary DNS address (DHCP and static configuration)
    _u16 ConfigOpt = 0;
    _i32 Status;
    _u16 pConfigLen = sizeof(SlNetCfgIpV6DnsClientArgs_t);
    Status = sl_NetCfgGet(SL_NETCFG_IPV6_DNS_CLIENT,&ConfigOpt,&pConfigLen,&DnsOpt);
    if( Status )
    {
    // error
    }
  • SL_NETCFG_IPV4_DHCP_CLIENT:
    Get DHCP Client info
    _u16 ConfigOpt = 0;
    _u16 pConfigLen = sizeof(SlNetCfgIpv4DhcpClient_t);
    SlNetCfgIpV4Args_t ipV4 = {0};
    ret = sl_NetCfgGet(SL_NETCFG_IPV4_DHCP_CLIENT, &ConfigOpt, &pConfigLen, (_u8 *)&dhcpCl);
    if(ret < 0)
    {
    printf("Error = %d\n", ret);
    }

Definition at line 104 of file netcfg.c.

105 {
106  _SlNetCfgMsgGet_u Msg;
107  _SlCmdExt_t CmdExt;
108 
109  /* verify that this api is allowed. if not allowed then
110  ignore the API execution and return immediately with an error */
111  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETCFG);
112 
113  if (*pConfigLen == 0)
114  {
115  return SL_EZEROLEN;
116  }
117 
118  _SlDrvResetCmdExt(&CmdExt);
119  CmdExt.RxPayloadLen = (_i16)(*pConfigLen);
120  CmdExt.pRxPayload = (_u8 *)pValues;
121 
122  _SlDrvMemZero((void*) &Msg, sizeof(Msg));
123 
124  Msg.Cmd.ConfigLen = *pConfigLen;
125  Msg.Cmd.ConfigId = ConfigId;
126 
127  if( pConfigOpt )
128  {
129  Msg.Cmd.ConfigOpt = (_u16)*pConfigOpt;
130  }
131 
132  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetCfgGetCmdCtrl, &Msg, &CmdExt));
133 
134  if( pConfigOpt )
135  {
136  *pConfigOpt = (_u8)Msg.Rsp.ConfigOpt;
137  }
138  if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
139  {
140  *pConfigLen = (_u8)CmdExt.RxPayloadLen;
141  return SL_ESMALLBUF;
142  }
143  else
144  {
145  *pConfigLen = (_u8)CmdExt.ActualRxPayloadLen;
146  }
147 
148  return Msg.Rsp.Status;
149 }

§ sl_NetCfgSet()

_i16 sl_NetCfgSet ( const _u16  ConfigId,
const _u16  ConfigOpt,
const _u16  ConfigLen,
const _u8 *  pValues 
)

Setting network configurations.

Parameters
[in]ConfigIdConfiguration id:
  • SL_NETCFG_IF
  • SL_NETCFG_IPV4_STA_ADDR_MODE
  • SL_NETCFG_IPV6_ADDR_LOCAL
  • SL_NETCFG_IPV6_ADDR_GLOBAL
  • SL_NETCFG_IPV4_AP_ADDR_MODE
  • SL_NETCFG_MAC_ADDRESS_SET
  • SL_NETCFG_AP_STATION_DISCONNECT
[in]ConfigOptConfigurations option:
  • SL_NETCFG_IF_STATE
  • SL_NETCFG_ADDR_DHCP
  • SL_NETCFG_ADDR_DHCP_LLA
  • SL_NETCFG_ADDR_STATIC
  • SL_NETCFG_ADDR_STATELESS
  • SL_NETCFG_ADDR_STATEFUL
  • SL_NETCFG_ADDR_RELEASE_IP_SET
  • SL_NETCFG_ADDR_RELEASE_IP_OFF
[in]ConfigLenConfigurations len
[in]pValuesConfigurations values
Persistent
Reset:
  • SL_NETCFG_MAC_ADDRESS_SET
  • SL_NETCFG_IPV4_AP_ADDR_MODE
Non- Persistent:
  • SL_NETCFG_AP_STATION_DISCONNECT
System Persistent:
  • SL_NETCFG_IPV4_STA_ADDR_MODE
  • SL_NETCFG_IF
  • SL_NETCFG_IPV6_ADDR_LOCAL
  • SL_NETCFG_IPV6_ADDR_GLOBAL
  • SL_NETCFG_IPV6_DNS_CLIENT
Returns
Non-negative value on success, or -1 for failure
See also
sl_NetCfgGet
Note
Warning
Examples
  • SL_NETCFG_MAC_ADDRESS_SET:
    Setting MAC address to the Device. The new MAC address will override the default MAC address and it be saved in the FileSystem. Requires restarting the device for updating this setting.
    _u8 MAC_Address[6];
    MAC_Address[0] = 0x8;
    MAC_Address[1] = 0x0;
    MAC_Address[2] = 0x28;
    MAC_Address[3] = 0x22;
    MAC_Address[4] = 0x69;
    MAC_Address[5] = 0x31;
    sl_NetCfgSet(SL_NETCFG_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(_u8 *)MAC_Address);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_IPV4_STA_ADDR_MODE
    : Setting/Releasing a DHCP/DHCP LLA /STATIC STA IP address
  • SL_NETCFG_ADDR_STATIC:
    Setting a static IP address to the device working in STA mode or P2P client. The IP address will be stored in the FileSystem.
    ipV4.Ip = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
    ipV4.IpMask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2P
    ipV4.IpGateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
    ipV4.IpDnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
    sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,SL_NETCFG_ADDR_STATIC,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_ADDR_DHCP:
    Setting IP address by DHCP to FileSystem using WLAN sta mode or P2P client. This should be done once if using Serial Flash. This is the system's default mode for acquiring an IP address after WLAN connection.
    sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,SL_NETCFG_ADDR_DHCP,0,0);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_ADDR_DHCP_LLA:
    Setting DHCP LLA will runs LLA mechanism in case DHCP fails to acquire an address. It is optional to set the LLA timeout, default is 25 seconds. SL_NETCFG_DHCP_OPT_RELEASE_IP_BEFORE_DISCONNECT - If set, enables sending a DHCP release frame to the server if user issues a WLAN disconnect command.
    _u32 LLATimeout;
    LLATimeout = 60;
    sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,SL_NETCFG_ADDR_DHCP_LLA,sizeof(_u32),&LLATimeout);
    sl_Start(NULL,NULL,NULL);

    sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,SL_NETCFG_ADDR_DHCP_LLA,0,0);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_ADDR_RELEASE_IP_SET:
    Setting release ip before disconnect enables sending a DHCP release frame to the server if user issues a WLAN disconnect command.
    sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,SL_NETCFG_ADDR_RELEASE_IP_SET,0,0);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_ADDR_RELEASE_IP_OFF:
    Setting release ip before disconnect disables sending a DHCP release frame to the server if user issues a WLAN disconnect command.
    sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,SL_NETCFG_ADDR_RELEASE_IP_OFF,0,0);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_IPV4_AP_ADDR_MODE:
    Setting a static IP address to the device working in AP mode or P2P go. The IP address will be stored in the FileSystem. Requires restart.
    ipV4.Ip = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
    ipV4.IpMask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this AP/P2P
    ipV4.IpGateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
    ipV4.IpDnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
    sl_NetCfgSet(SL_NETCFG_IPV4_AP_ADDR_MODE,SL_NETCFG_ADDR_STATIC,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_IF:
    Enable IPV6 interface - Local or/and Global address (Global could not be enabled without Local)
    _u32 IfBitmap = 0;
    IfBitmap = SL_NETCFG_IF_IPV6_STA_LOCAL | SL_NETCFG_IF_IPV6_STA_GLOBAL;
    sl_NetCfgSet(SL_NETCFG_IF,SL_NETCFG_IF_STATE,sizeof(IfBitmap),&IfBitmap);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_IPV6_ADDR_LOCAL:
    Setting a IPv6 Local static address to the device working in STA mode. The IP address will be stored in the FileSystem. Requires restart.
    _u32 IfBitmap = 0;
    IfBitmap = SL_NETCFG_IF_IPV6_STA_LOCAL;
    sl_NetCfgSet(SL_NETCFG_IF,SL_NETCFG_IF_STATE,sizeof(IfBitmap),&IfBitmap);
    ipV6.Ip[0] = 0xfe800000;
    ipV6.Ip[1] = 0x00000000;
    ipV6.Ip[2] = 0x00004040;
    ipV6.Ip[3] = 0x0000ce65;
    sl_NetCfgSet(SL_NETCFG_IPV6_ADDR_LOCAL,SL_NETCFG_ADDR_STATIC,sizeof(SlNetCfgIpV6Args_t),(_u8 *)&ipV6);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_IPV6_ADDR_LOCAL:
    Setting a IPv6 Local stateless address to the device working in STA mode. The IP address will be stored in the FileSystem. Requires restart.
    _u32 IfBitmap = 0;
    IfBitmap = SL_NETCFG_IF_IPV6_STA_LOCAL;
    sl_NetCfgSet(SL_NETCFG_IF,SL_NETCFG_IF_STATE,sizeof(IfBitmap),&IfBitmap);
    sl_NetCfgSet(SL_NETCFG_IPV6_ADDR_LOCAL,SL_NETCFG_ADDR_STATELESS,0,0);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_IPV6_ADDR_LOCAL:
    Setting a IPv6 Local statefull address to the device working in STA mode. The IP address will be stored in the FileSystem. Requires restart.
    _u32 IfBitmap = 0;
    IfBitmap = SL_NETCFG_IF_IPV6_STA_LOCAL;
    sl_NetCfgSet(SL_NETCFG_IF,SL_NETCFG_IF_STATE,sizeof(IfBitmap),&IfBitmap);
    sl_NetCfgSet(SL_NETCFG_IPV6_ADDR_LOCAL,SL_NETCFG_ADDR_STATEFUL,0,0);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_IPV6_ADDR_GLOBAL:
    Setting a IPv6 Global static address to the device working in STA mode. The IP address will be stored in the FileSystem. Requires restart.
    _u32 IfBitmap = 0;
    ipV6.Ip[0] = 0xfe80;
    ipV6.Ip[1] = 0x03a;
    ipV6.Ip[2] = 0x4040;
    ipV6.Ip[3] = 0xce65;
    ipV6.IpDnsServer[0] = 0xa780;
    ipV6.IpDnsServer[1] = 0x65e;
    ipV6.IpDnsServer[2] = 0x8;
    ipV6.IpDnsServer[3] = 0xce00;
    IfBitmap = SL_NETCFG_IF_IPV6_STA_GLOBAL;
    sl_NetCfgSet(SL_NETCFG_IF,SL_NETCFG_IF_STATE,sizeof(IfBitmap),&IfBitmap);
    sl_NetCfgSet(SL_NETCFG_IPV6_ADDR_GLOBAL,SL_NETCFG_ADDR_STATIC,sizeof(SlNetCfgIpV6Args_t),(_u8 *)&ipV6);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_IPV6_ADDR_GLOBAL:
    Setting a IPv6 Global statefull address to the device working in STA mode. The IP address will be stored in the FileSystem. Requires restart.
    _u32 IfBitmap = 0;
    IfBitmap = SL_NETCFG_IF_IPV6_STA_GLOBAL;
    sl_NetCfgSet(SL_NETCFG_IF,SL_NETCFG_IF_STATE,sizeof(IfBitmap),&IfBitmap);
    sl_NetCfgSet(SL_NETCFG_IPV6_ADDR_GLOBAL,SL_NETCFG_ADDR_STATEFUL,0,0);
    sl_Start(NULL,NULL,NULL);

  • SL_NETCFG_AP_STATION_DISCONNECT:
    Disconnect AP station by mac address. The AP connected stations list can be read by sl_NetCfgGet with options: SL_AP_STATIONS_NUM_CONNECTED, SL_AP_STATIONS_INFO_LIST
    _u8 ap_sta_mac[6] = { 0x00, 0x22, 0x33, 0x44, 0x55, 0x66 };
    sl_NetCfgSet(SL_NETCFG_AP_STATION_DISCONNECT,1,SL_MAC_ADDR_LEN,(_u8 *)ap_sta_mac);

  • SL_NETCFG_IPV4_DNS_CLIENT:
    Set additional IPv4 DNS address
    _i32 Status;
    DnsOpt.DnsSecondServerAddr = SL_IPV4_VAL(8,8,8,8); ;
    Status = sl_NetCfgSet(SL_NETCFG_IPV4_DNS_CLIENT,0,sizeof(SlNetCfgIpV4DnsClientArgs_t),(unsigned char *)&DnsOpt);
    if( Status )
    {
    // error
    }

  • SL_NETCFG_IPV6_DNS_CLIENT:
    Set additional IPv6 DNS address
    _i32 Status;
    DnsOpt.DnsSecondServerAddr[0] = SL_IPV6_VAL(0x2001, 0x4860);
    DnsOpt.DnsSecondServerAddr[1] = SL_IPV6_VAL(0x4860, 0x0);
    DnsOpt.DnsSecondServerAddr[2] = SL_IPV6_VAL(0x0, 0x0);
    DnsOpt.DnsSecondServerAddr[3] = SL_IPV6_VAL(0x0, 0x8844);
    Status = sl_NetCfgSet(SL_NETCFG_IPV6_DNS_CLIENT,0,sizeof(SlNetCfgIpV6DnsClientArgs_t),(unsigned char *)&DnsOpt);
    if( Status )
    {
    // error
    }

Definition at line 63 of file netcfg.c.

64 {
65  _SlNetCfgMsgSet_u Msg;
66  _SlCmdExt_t CmdExt;
67 
68  /* verify that this api is allowed. if not allowed then
69  ignore the API execution and return immediately with an error */
70  VERIFY_API_ALLOWED(SL_OPCODE_SILO_NETCFG);
71 
72  _SlDrvResetCmdExt(&CmdExt);
73  CmdExt.TxPayload1Len = (ConfigLen+3) & (~3);
74  CmdExt.pTxPayload1 = (_u8 *)pValues;
75 
76  Msg.Cmd.ConfigId = ConfigId;
77  Msg.Cmd.ConfigLen = ConfigLen;
78  Msg.Cmd.ConfigOpt = ConfigOpt;
79 
80  VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetCfgSetCmdCtrl, &Msg, &CmdExt));
81 
82  return (_i16)Msg.Rsp.status;
83 }

Data Structure Documentation

§ SlNetCfgIpV4DnsClientArgs_t

struct SlNetCfgIpV4DnsClientArgs_t

Definition at line 127 of file netcfg.h.

Data Fields
_u32 DnsSecondServerAddr

§ SlNetCfgIpV6DnsClientArgs_t

struct SlNetCfgIpV6DnsClientArgs_t

Definition at line 132 of file netcfg.h.

Data Fields
_u32 DnsSecondServerAddr[4]

§ SlNetCfgIpv4DhcpClient_t

struct SlNetCfgIpv4DhcpClient_t

Definition at line 138 of file netcfg.h.

Data Fields
_u32 DhcpServer
_u8 DhcpState
_u32 Dns[2]
_u32 Gateway
_u32 Ip
_u32 LeaseTime
_u32 Mask
_u8 Reserved[3]
_u32 TimeToRenew

§ SlNetCfgIpV4Args_t

struct SlNetCfgIpV4Args_t

Definition at line 169 of file netcfg.h.

Data Fields
_u32 Ip
_u32 IpDnsServer
_u32 IpGateway
_u32 IpMask

§ SlNetCfgIpV6Args_t

struct SlNetCfgIpV6Args_t

Definition at line 177 of file netcfg.h.

Data Fields
_u32 Ip[4]
_u32 IpDnsServer[4]
_u32 IpV6Flags

§ SlNetCfgStaInfo_t

struct SlNetCfgStaInfo_t

Definition at line 189 of file netcfg.h.

Data Fields
_u32 Ip
_u8 MacAddr[6]
_u8 Name[32]
_u16 Status