Network Services API  2.00.00.16
Data Structures | Macros | Typedefs | Enumerations | Functions
SlNetIf group

Controls standard stack/interface options and capabilities. More...

Data Structures

struct  _SlNetIf_Config_t
 SlNetIf_Config_t structure contains all the function callbacks that are expected to be filled by the relevant network stack interface
Each interface has different capabilities, so not all the API's must be supported therefore an API's can be defined as:
. More...
 
struct  _SlNetIf_t
 The SlNetIf_t structure holds the configuration of the interface Its ID, name, flags and the configuration list - SlNetIf_Config_t. More...
 

Macros

#define SLNETIF_ID_1   (1 << 0)
 
#define SLNETIF_ID_2   (1 << 1)
 
#define SLNETIF_ID_3   (1 << 2)
 
#define SLNETIF_ID_4   (1 << 3)
 
#define SLNETIF_ID_5   (1 << 4)
 
#define SLNETIF_ID_6   (1 << 5)
 
#define SLNETIF_ID_7   (1 << 6)
 
#define SLNETIF_ID_8   (1 << 7)
 
#define SLNETIF_ID_9   (1 << 8)
 
#define SLNETIF_ID_10   (1 << 9)
 
#define SLNETIF_ID_11   (1 << 10)
 
#define SLNETIF_ID_12   (1 << 11)
 
#define SLNETIF_ID_13   (1 << 12)
 
#define SLNETIF_ID_14   (1 << 13)
 
#define SLNETIF_ID_15   (1 << 14)
 
#define SLNETIF_ID_16   (1 << 15)
 
#define SLNETIF_MAX_IF   (16)
 
#define ONLY_ONE_BIT_IS_SET(x)   (((x > 0) && ((x & (x - 1)) == 0))?true:false)
 
#define SLNETIF_STATUS_DISCONNECTED   (0)
 
#define SLNETIF_STATUS_CONNECTED   (1)
 
#define SLNETIF_ADDR_CFG_UNKNOWN   (0)
 
#define SLNETIF_ADDR_CFG_DHCP   (1)
 
#define SLNETIF_ADDR_CFG_DHCP_LLA   (2)
 
#define SLNETIF_ADDR_CFG_STATIC   (4)
 
#define SLNETIF_ADDR_CFG_STATELESS   (5)
 
#define SLNETIF_ADDR_CFG_STATEFUL   (6)
 
#define SLNETIF_SEC_OBJ_TYPE_RSA_PRIVATE_KEY   (1)
 
#define SLNETIF_SEC_OBJ_TYPE_CERTIFICATE   (2)
 
#define SLNETIF_SEC_OBJ_TYPE_DH_KEY   (3)
 
#define SLNETIF_QUERY_IF_STATE_BIT   (1 << 0)
 
#define SLNETIF_QUERY_IF_CONNECTION_STATUS_BIT   (1 << 1)
 
#define SLNETIF_QUERY_IF_ALLOW_PARTIAL_MATCH_BIT   (1 << 2)
 

Typedefs

typedef struct _SlNetIf_Config_t SlNetIf_Config_t
 SlNetIf_Config_t structure contains all the function callbacks that are expected to be filled by the relevant network stack interface
Each interface has different capabilities, so not all the API's must be supported therefore an API's can be defined as:
. More...
 
typedef struct _SlNetIf_t SlNetIf_t
 The SlNetIf_t structure holds the configuration of the interface Its ID, name, flags and the configuration list - SlNetIf_Config_t. More...
 

Enumerations

enum  SlNetIfState_e {
  SLNETIF_STATE_DISABLE = 0,
  SLNETIF_STATE_ENABLE = 1
}
 Interface state bit pool to be used in set interface state function. More...
 
enum  SlNetIfAddressType_e {
  SLNETIF_IPV4_ADDR = 0,
  SLNETIF_IPV6_ADDR_LOCAL = 1,
  SLNETIF_IPV6_ADDR_GLOBAL = 2
}
 Address type enum to be used in get ip address function. More...
 

Functions

int32_t SlNetIf_init (int32_t flags)
 Initialize the SlNetIf module. More...
 
int32_t SlNetIf_add (uint16_t ifID, char *ifName, const SlNetIf_Config_t *ifConf, uint8_t priority)
 Adding new interface. More...
 
SlNetIf_tSlNetIf_getIfByID (uint16_t ifID)
 Get interface configuration from interface ID. More...
 
SlNetIf_tSlNetIf_queryIf (uint32_t ifBitmap, uint32_t queryBitmap)
 Get highest priority interface configuration using interface bitmap. More...
 
const char * SlNetIf_getNameByID (uint16_t ifID)
 Get interface Name from interface ID. More...
 
int32_t SlNetIf_getIDByName (char *ifName)
 Get interface ID from interface name. More...
 
int32_t SlNetIf_getPriority (uint16_t ifID)
 Get interface priority. More...
 
int32_t SlNetIf_setPriority (uint16_t ifID, uint8_t priority)
 Set interface priority. More...
 
int32_t SlNetIf_setState (uint16_t ifID, SlNetIfState_e ifState)
 Set interface state. More...
 
int32_t SlNetIf_getState (uint16_t ifID)
 Get interface state. More...
 
int32_t SlNetIf_getConnectionStatus (uint16_t ifID)
 Get interface connection status. More...
 
int32_t SlNetIf_getIPAddr (uint16_t ifID, SlNetIfAddressType_e addrType, uint16_t *addrConfig, uint32_t *ipAddr)
 Get IP Address of specific interface. More...
 
int32_t SlNetIf_loadSecObj (uint16_t objType, char *objName, int16_t objNameLen, uint8_t *objBuff, int16_t objBuffLen, uint32_t ifBitmap)
 Load secured buffer to the network stack. More...
 

Detailed Description

Controls standard stack/interface options and capabilities.

Macro Definition Documentation

§ SLNETIF_ID_1

#define SLNETIF_ID_1   (1 << 0)

§ SLNETIF_ID_2

#define SLNETIF_ID_2   (1 << 1)

§ SLNETIF_ID_3

#define SLNETIF_ID_3   (1 << 2)

§ SLNETIF_ID_4

#define SLNETIF_ID_4   (1 << 3)

§ SLNETIF_ID_5

#define SLNETIF_ID_5   (1 << 4)

§ SLNETIF_ID_6

#define SLNETIF_ID_6   (1 << 5)

§ SLNETIF_ID_7

#define SLNETIF_ID_7   (1 << 6)

§ SLNETIF_ID_8

#define SLNETIF_ID_8   (1 << 7)

§ SLNETIF_ID_9

#define SLNETIF_ID_9   (1 << 8)

§ SLNETIF_ID_10

#define SLNETIF_ID_10   (1 << 9)

§ SLNETIF_ID_11

#define SLNETIF_ID_11   (1 << 10)

§ SLNETIF_ID_12

#define SLNETIF_ID_12   (1 << 11)

§ SLNETIF_ID_13

#define SLNETIF_ID_13   (1 << 12)

§ SLNETIF_ID_14

#define SLNETIF_ID_14   (1 << 13)

§ SLNETIF_ID_15

#define SLNETIF_ID_15   (1 << 14)

§ SLNETIF_ID_16

#define SLNETIF_ID_16   (1 << 15)

§ SLNETIF_MAX_IF

#define SLNETIF_MAX_IF   (16)

§ ONLY_ONE_BIT_IS_SET

#define ONLY_ONE_BIT_IS_SET (   x)    (((x > 0) && ((x & (x - 1)) == 0))?true:false)

§ SLNETIF_STATUS_DISCONNECTED

#define SLNETIF_STATUS_DISCONNECTED   (0)

§ SLNETIF_STATUS_CONNECTED

#define SLNETIF_STATUS_CONNECTED   (1)

§ SLNETIF_ADDR_CFG_UNKNOWN

#define SLNETIF_ADDR_CFG_UNKNOWN   (0)

§ SLNETIF_ADDR_CFG_DHCP

#define SLNETIF_ADDR_CFG_DHCP   (1)

§ SLNETIF_ADDR_CFG_DHCP_LLA

#define SLNETIF_ADDR_CFG_DHCP_LLA   (2)

§ SLNETIF_ADDR_CFG_STATIC

#define SLNETIF_ADDR_CFG_STATIC   (4)

§ SLNETIF_ADDR_CFG_STATELESS

#define SLNETIF_ADDR_CFG_STATELESS   (5)

§ SLNETIF_ADDR_CFG_STATEFUL

#define SLNETIF_ADDR_CFG_STATEFUL   (6)

§ SLNETIF_SEC_OBJ_TYPE_RSA_PRIVATE_KEY

#define SLNETIF_SEC_OBJ_TYPE_RSA_PRIVATE_KEY   (1)

§ SLNETIF_SEC_OBJ_TYPE_CERTIFICATE

#define SLNETIF_SEC_OBJ_TYPE_CERTIFICATE   (2)

§ SLNETIF_SEC_OBJ_TYPE_DH_KEY

#define SLNETIF_SEC_OBJ_TYPE_DH_KEY   (3)

§ SLNETIF_QUERY_IF_STATE_BIT

#define SLNETIF_QUERY_IF_STATE_BIT   (1 << 0)

§ SLNETIF_QUERY_IF_CONNECTION_STATUS_BIT

#define SLNETIF_QUERY_IF_CONNECTION_STATUS_BIT   (1 << 1)

§ SLNETIF_QUERY_IF_ALLOW_PARTIAL_MATCH_BIT

#define SLNETIF_QUERY_IF_ALLOW_PARTIAL_MATCH_BIT   (1 << 2)

Typedef Documentation

§ SlNetIf_Config_t

SlNetIf_Config_t structure contains all the function callbacks that are expected to be filled by the relevant network stack interface
Each interface has different capabilities, so not all the API's must be supported therefore an API's can be defined as:
.

  • Mandatory API's - must be supported by the interface in order to be part of SlNetSock layer
  • Non-Mandatory API's - can be supported, but not mandatory for basic SlNetSock proper operation
    Note
    Interface that is not supporting a non-mandatory API should set it to NULL in its function list

§ SlNetIf_t

typedef struct _SlNetIf_t SlNetIf_t

The SlNetIf_t structure holds the configuration of the interface Its ID, name, flags and the configuration list - SlNetIf_Config_t.

Enumeration Type Documentation

§ SlNetIfState_e

Interface state bit pool to be used in set interface state function.

Enumerator
SLNETIF_STATE_DISABLE 
SLNETIF_STATE_ENABLE 

§ SlNetIfAddressType_e

Address type enum to be used in get ip address function.

Enumerator
SLNETIF_IPV4_ADDR 
SLNETIF_IPV6_ADDR_LOCAL 
SLNETIF_IPV6_ADDR_GLOBAL 

Function Documentation

§ SlNetIf_init()

int32_t SlNetIf_init ( int32_t  flags)

Initialize the SlNetIf module.

The SlNetIf_init function Initialize the SlNetIf module.

Parameters
[in]flagsFor future usage, The value 0 may be used in order to run the default flags
Returns
Zero on success, or negative error code on failure
See also
Note
Warning

§ SlNetIf_add()

int32_t SlNetIf_add ( uint16_t  ifID,
char *  ifName,
const SlNetIf_Config_t ifConf,
uint8_t  priority 
)

Adding new interface.

The SlNetIf_add function allows the application to add specific interfaces with their priorities and function list.
This function gives full control to the application on the interfaces.


Parameters
[in]ifIDSpecifies the interface which needs to be added.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
[in]ifNameSpecifies the name of the interface, Note: Can be set to NULL, but when set to NULL cannot be used with SlNetIf_getIDByName
[in]ifConfSpecifies the function list for the interface
[in]prioritySpecifies the priority needs to be set (In ascending order). Note: maximum priority is 15
Returns
Zero on success, or negative error code on failure
See also
Something here
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
uint8_t priority = 10;
SlNetIf_add(SLNETIF_ID_1, "WiFi_Interface", &SlNetIfConfigWifi, priority);


§ SlNetIf_getIfByID()

SlNetIf_t* SlNetIf_getIfByID ( uint16_t  ifID)

Get interface configuration from interface ID.

The SlNetIf_getIfByID function retrieves the configuration of the requested interface.

Parameters
[in]ifIDSpecifies the interface which its configuration needs to be retrieved.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
Returns
A pointer to the configuration of the interface on success, or NULL on failure
See also
SlNetIf_add
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
SlNetIf_t *InterfaceName;


§ SlNetIf_queryIf()

SlNetIf_t* SlNetIf_queryIf ( uint32_t  ifBitmap,
uint32_t  queryBitmap 
)

Get highest priority interface configuration using interface bitmap.

The SlNetIf_getIfByID function retrieves highest priority interface configuration that can be found in the interface bitmap, or the highest exists when ifBitmap is zero.

Parameters
[in,out]ifBitmapSpecifies the interface that needs to be checked according to the queryBitmap and return the interface with the highest priority.
The values of the interface Bitmap is a combination of the interface identifiers defined with the prefix SLNETIF_ID_ which defined in slnetif.h Note: Zero is not a valid parameter, an error will be returned
[in]queryBitmapSpecifies the additional criterias for the query that will be use along the interface priority and interface ID.
queryBitmap bits:
  • SLNETIF_QUERY_IF_STATE_BIT
  • SLNETIF_QUERY_IF_CONNECTION_STATUS_BIT
Returns
A pointer to the configuration of the interface on success, or NULL on failure
See also
SlNetIf_add
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples


§ SlNetIf_getNameByID()

const char* SlNetIf_getNameByID ( uint16_t  ifID)

Get interface Name from interface ID.

The SlNetIf_getNameByID function retrieves the name of the requested interface.

Parameters
[in]ifIDSpecifies the interface which its name needs to be retrieved.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
Returns
A pointer to the name of the interface on success, or NULL on failure
See also
SlNetIf_add SlNetIf_getIDByName
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
char *InterfaceName;


§ SlNetIf_getIDByName()

int32_t SlNetIf_getIDByName ( char *  ifName)

Get interface ID from interface name.

The SlNetIf_getIDByName function retrieves the interface identifier of the requested interface name.

Parameters
[in]ifNameSpecifies the interface which its interface identifier needs to be retrieved.
Returns
The interface identifier value of the interface on success, or negative error code on failure The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
See also
SlNetIf_add SlNetIf_getIDBySocket SlNetIf_getNameByID
Note
- Input NULL as ifName will return error code.
  • When using more than one interface with the same name, the ID of the highest priority interface will be returned
  • slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
int16_t InterfaceID;
InterfaceID = SlNetIf_getIDByName("WiFi_Interface");


§ SlNetIf_getPriority()

int32_t SlNetIf_getPriority ( uint16_t  ifID)

Get interface priority.

The SlNetIf_getPriority function retrieves the priority of the interface.

Parameters
[in]ifIDSpecifies the interface which its priority needs to be retrieved.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
Returns
The priority value of the interface on success, or negative error code on failure
See also
SlNetIf_add SlNetIf_setPriority
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
int16_t Priority;


§ SlNetIf_setPriority()

int32_t SlNetIf_setPriority ( uint16_t  ifID,
uint8_t  priority 
)

Set interface priority.

The SlNetIf_setPriority function sets new priority to the requested interface.

Parameters
[in]ifIDSpecifies the interface which its priority needs to be changed.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
[in]prioritySpecifies the priority needs to be set. (In ascending order) Note: maximum priority is 15
Returns
Zero on success, or negative error code on failure
See also
SlNetIf_add SlNetIf_getPriority
Note
slnetif functions are not thread safe due to the fact that if this function will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
uint8_t priority = 10;


§ SlNetIf_setState()

int32_t SlNetIf_setState ( uint16_t  ifID,
SlNetIfState_e  ifState 
)

Set interface state.

The SlNetIf_setState function sets the state of the interface (Enable or Disable).

Parameters
[in]ifIDSpecifies the interface which its state needs to be changed.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
[in]ifStateSpecifies the interface state.
The values of the interface state are defined with the prefix SLNETIF_INTERFACE_ which defined in slnetif.h
Returns
Zero on success, or negative error code on failure
See also
SlNetIf_add SlNetIf_getState
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples


§ SlNetIf_getState()

int32_t SlNetIf_getState ( uint16_t  ifID)

Get interface state.

The SlNetIf_getState function gets the state of the interface (Enable or Disable).

Parameters
[in]ifIDSpecifies the interface which its state needs to be retrieved.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
Returns
State of the interface on success, or negative error code on failure
See also
SlNetIf_add SlNetIf_setState
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
int16_t InterfaceState
InterfaceState = SlNetIf_getState(SLNETIF_ID_1);


§ SlNetIf_getConnectionStatus()

int32_t SlNetIf_getConnectionStatus ( uint16_t  ifID)

Get interface connection status.

The SlNetIf_getConnectionStatus function gets the connection status of the interface (connected Or disconnected).

Parameters
[in]ifIDSpecifies the interface which its connection status needs to be retrieved.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
Returns
Connection status of the interface on success, or negative error code on failure
See also
SlNetIf_add
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
int16_t connection_status


§ SlNetIf_getIPAddr()

int32_t SlNetIf_getIPAddr ( uint16_t  ifID,
SlNetIfAddressType_e  addrType,
uint16_t *  addrConfig,
uint32_t *  ipAddr 
)

Get IP Address of specific interface.

The SlNetIf_getIPAddr function retrieve the IP address of a specific interface according to the Address Type, IPv4, IPv6 LOCAL or IPv6 GLOBAL.

Parameters
[in]ifIDSpecifies the interface which its connection state needs to be retrieved.
The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
[in]addrTypeAddress type:
  • SLNETIF_IPV4_ADDR
  • SLNETIF_IPV6_ADDR_LOCAL
  • SLNETIF_IPV6_ADDR_GLOBAL
[out]addrConfigAddress config:
  • SLNETIF_ADDR_CFG_UNKNOWN
  • SLNETIF_ADDR_CFG_DHCP
  • SLNETIF_ADDR_CFG_DHCP_LLA
  • SLNETIF_ADDR_CFG_STATIC
  • SLNETIF_ADDR_CFG_STATELESS
  • SLNETIF_ADDR_CFG_STATEFUL
[out]ipAddrIP Address according to the Address Type
Returns
Zero on success, or negative error code on failure
See also
SlNetIfAddressType_e
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Examples
uint16_t addressConfig = 0;
SlNetIf_getIPAddr(SLNETIF_ID_1 ,SLNETIF_IPV6_ADDR_LOCAL ,&addressConfig ,(uint8_t *)ipAddr);


§ SlNetIf_loadSecObj()

int32_t SlNetIf_loadSecObj ( uint16_t  objType,
char *  objName,
int16_t  objNameLen,
uint8_t *  objBuff,
int16_t  objBuffLen,
uint32_t  ifBitmap 
)

Load secured buffer to the network stack.

The SlNetSock_secLoadObj function loads buffer/files into the inputted network stack for future usage of the socket SSL/TLS connection. This option is relevant for network stacks with file system and also for network stacks that lack file system that can store the secured files.

Parameters
[in]objTypeSpecifies the security object type which could be one of the following:
  • SLNETIF_SEC_OBJ_TYPE_RSA_PRIVATE_KEY
  • SLNETIF_SEC_OBJ_TYPE_CERTIFICATE
  • SLNETIF_SEC_OBJ_TYPE_DH_KEY
[in]objNameSpecifies the name/input identifier of the secured buffer loaded for file systems - this can be the file name for plain text buffer loading this can be the name of the object
[in]objNameLenSpecifies the buffer name length to be loaded.
[in]objBuffSpecifies the pointer to the secured buffer to be loaded.
[in]objBuffLenSpecifies the buffer length to be loaded.
[in]ifBitmapSpecifies the interfaces which the security objects needs to be added to.
The values of the interface identifiers is defined with the prefix SLNETIF_ID_ which defined in slnetif.h
Returns
On success, buffer type handler index to be used when attaching the secured buffer to a socket.
A successful return code should be a positive number (int16)
On error, a negative value will be returned specifying the error code.
  • SLNETERR_STATUS_ERROR - load operation failed
See also
SlNetSock_setOpt
Note
slnetif functions are not thread safe due to the fact that if SlNetIf_setPriority will be called in concurrent on another thread the interface list may be changed.
Warning
Copyright 2017, Texas Instruments Incorporated