Network Services API  2.00.00.16
Macros | Functions
SlNetUtils group

Sockets related commands and configuration. More...

Macros

#define SLNETUTIL_IPV4_VAL(add_3, add_2, add_1, add_0)   ((((uint32_t)add_3 << 24) & 0xFF000000) | (((uint32_t)add_2 << 16) & 0xFF0000) | (((uint32_t)add_1 << 8) & 0xFF00) | ((uint32_t)add_0 & 0xFF) )
 

Functions

int32_t SlNetutil_init (int32_t flags)
 Initialize the slnetutil module. More...
 
int32_t SlNetUtil_getHostByName (uint32_t ifBitmap, char *name, const uint16_t nameLen, uint32_t **ipAddr, uint16_t *ipAddrLen, const uint8_t family)
 Get host IP by name
Obtain the IP Address of machine on network, by machine name. More...
 
uint32_t SlNetUtil_htonl (uint32_t val)
 Reorder the bytes of a 32-bit unsigned value. More...
 
uint32_t SlNetUtil_ntohl (uint32_t val)
 Reorder the bytes of a 32-bit unsigned value. More...
 
uint16_t SlNetUtil_htons (uint16_t val)
 Reorder the bytes of a 16-bit unsigned value. More...
 
uint16_t SlNetUtil_ntohs (uint16_t val)
 Reorder the bytes of a 16-bit unsigned value. More...
 
const char * SlNetUtil_inetNtop (int16_t addrFamily, const void *binaryAddr, char *strAddr, SlNetSocklen_t strAddrLen)
 Converts IP address in binary representation to string representation. More...
 
int32_t SlNetUtil_inetPton (int16_t addrFamily, const char *strAddr, void *binaryAddr)
 Converts IP address in string representation to binary representation. More...
 

Detailed Description

Sockets related commands and configuration.

Macro Definition Documentation

§ SLNETUTIL_IPV4_VAL

#define SLNETUTIL_IPV4_VAL (   add_3,
  add_2,
  add_1,
  add_0 
)    ((((uint32_t)add_3 << 24) & 0xFF000000) | (((uint32_t)add_2 << 16) & 0xFF0000) | (((uint32_t)add_1 << 8) & 0xFF00) | ((uint32_t)add_0 & 0xFF) )

Function Documentation

§ SlNetutil_init()

int32_t SlNetutil_init ( int32_t  flags)

Initialize the slnetutil module.

The SlNetutil_init function Initialize the slnetutil 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

§ SlNetUtil_getHostByName()

int32_t SlNetUtil_getHostByName ( uint32_t  ifBitmap,
char *  name,
const uint16_t  nameLen,
uint32_t **  ipAddr,
uint16_t *  ipAddrLen,
const uint8_t  family 
)

Get host IP by name
Obtain the IP Address of machine on network, by machine name.

Parameters
[in]ifBitmapSpecifies the interfaces which the the host ip needs to be retrieved from according tothe priority until one of them will return an answer.
Value 0 is used in order to choose automatic interfaces selection according to the priority interface list. Value can be combination of interfaces by OR'ing multiple interfaces bit identifiers (SLNETIFC_IDENT_ defined in slnetif.h) Note: interface identifier bit must be configured prior to this socket creation using SlNetIf_add function.
[in]nameHost name
[in]nameLenName length
[out]ipAddrThis parameter is filled in with an array of host IP addresses. In case that host name is not resolved, out_ip_addr is zero.
[in,out]ipAddrLenHolds the size of the ipAddr array, when function successful, the ipAddrLen parameter will be updated with the number of the IP addresses found.
[in]familyProtocol family
Returns
Zero on success, or negative on failure.
SLNETUTIL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS Possible DNS error codes:
  • SLNETUTIL_DNS_QUERY_NO_RESPONSE
  • SLNETUTIL_DNS_NO_SERVER
  • SLNETUTIL_DNS_QUERY_FAILED
  • SLNETUTIL_DNS_MALFORMED_PACKET
  • SLNETUTIL_DNS_MISMATCHED_RESPONSE
See also
Note
Only one SlNetUtil_getHostByName can be handled at a time.
Calling this API while the same command is called from another thread, may result in one of the two scenarios:
  1. The command will wait (internal) until the previous command finish, and then be executed.
  2. There are not enough resources and POOL_IS_EMPTY error will return.
    In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try again later to issue the command.
Warning
In case an IP address in a string format is set as input, without any prefix (e.g. "1.2.3.4") the device will not try to access the DNS and it will return the input address on the 'out_ip_addr' field
Example

§ SlNetUtil_htonl()

uint32_t SlNetUtil_htonl ( uint32_t  val)

Reorder the bytes of a 32-bit unsigned value.

This function is used to reorder the bytes of a 32-bit unsigned value from host order to network order.

Parameters
[in]valVariable in host order
Returns
Return the variable in network order
See also
SlNetSock_bind SlNetSock_connect SlNetSock_recvFrom SlNetSock_accept
Note
Warning

§ SlNetUtil_ntohl()

uint32_t SlNetUtil_ntohl ( uint32_t  val)

Reorder the bytes of a 32-bit unsigned value.

This function is used to reorder the bytes of a 32-bit unsigned value from network order to host order.

Parameters
[in]valVariable in network order
Returns
Return the variable in host order
See also
SlNetSock_bind SlNetSock_connect SlNetSock_recvFrom SlNetSock_accept
Note
Warning

§ SlNetUtil_htons()

uint16_t SlNetUtil_htons ( uint16_t  val)

Reorder the bytes of a 16-bit unsigned value.

This functions is used to reorder the bytes of a 16-bit unsigned value from host order to network order.

Parameters
[in]valVariable in host order
Returns
Return the variable in network order
See also
SlNetSock_bind SlNetSock_connect SlNetSock_recvFrom SlNetSock_accept
Note
Warning

§ SlNetUtil_ntohs()

uint16_t SlNetUtil_ntohs ( uint16_t  val)

Reorder the bytes of a 16-bit unsigned value.

This functions is used to reorder the bytes of a 16-bit unsigned value from network order to host order.

Parameters
[in]valVariable in network order
Returns
Return the variable in host order
See also
SlNetSock_bind SlNetSock_connect SlNetSock_recvFrom SlNetSock_accept
Note
Warning

§ SlNetUtil_inetNtop()

const char* SlNetUtil_inetNtop ( int16_t  addrFamily,
const void *  binaryAddr,
char *  strAddr,
SlNetSocklen_t  strAddrLen 
)

Converts IP address in binary representation to string representation.

This functions is used to converts IP address in binary representation to IP address in string representation.

Parameters
[in]addrFamilySpecifies the address family of the created socket For example:
  • SLNETSOCK_AF_INET for network address IPv4
  • SLNETSOCK_AF_INET6 for network address IPv6
[in]binaryAddrPointer to an IP address structure indicating the address in binary representation
[out]strAddrPointer to the address string representation for IPv4 or IPv6 according to the address family
[in]strAddrLenSpecifies the length of the StrAddress_dst, the maximum length of the address in string representation for IPv4 or IPv6 according to the address family
Returns
strAddr on success, or NULL on failure
See also
Note
Warning
Example

§ SlNetUtil_inetPton()

int32_t SlNetUtil_inetPton ( int16_t  addrFamily,
const char *  strAddr,
void *  binaryAddr 
)

Converts IP address in string representation to binary representation.

This functions is used to converts IP address in string representation to IP address in binary representation.

Parameters
[in]addrFamilySpecifies the address family of the created socket For example:
  • SLNETSOCK_AF_INET for network address IPv4
  • SLNETSOCK_AF_INET6 for network address IPv6
[out]strAddrSpecifies the IP address in string representation for IPv4 or IPv6 according to the address family
[in]binaryAddrPointer to an address structure that will be filled by the IP address in Binary representation
Returns
1 on success, -1 on failure, or 0 if the input isn't a valid IP address
See also
Note
Warning
Example
Copyright 2017, Texas Instruments Incorporated