Network Services API
2.75.00.17
|
Sockets related commands and configuration. More...
Data Structures | |
struct | SlNetUtil_addrInfo_t |
Macros | |
#define | SLNETUTIL_AI_PASSIVE 0x00000001 |
#define | SLNETUTIL_AI_NUMERICHOST 0x00000004 |
#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) ) |
Typedefs | |
typedef struct SlNetUtil_addrInfo_t | SlNetUtil_addrInfo_t |
Functions | |
int32_t | SlNetUtil_init (int32_t flags) |
Initialize the SlNetUtil module. More... | |
const char * | SlNetUtil_gaiStrErr (int32_t errorCode) |
Return text descriptions of getAddrInfo error codes. 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... | |
int32_t | SlNetUtil_getAddrInfo (uint16_t ifID, const char *node, const char *service, const struct SlNetUtil_addrInfo_t *hints, struct SlNetUtil_addrInfo_t **res) |
Network address and service translation. More... | |
void | SlNetUtil_freeAddrInfo (struct SlNetUtil_addrInfo_t *res) |
Free the results returned from SlNetUtil_getAddrInfo. 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... | |
int | SlNetUtil_inetAton (const char *str, struct SlNetSock_InAddr_t *addr) |
Convert an IPv4 address in string format to binary format. 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... | |
Sockets related commands and configuration.
#define SLNETUTIL_AI_PASSIVE 0x00000001 |
#define SLNETUTIL_AI_NUMERICHOST 0x00000004 |
#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) ) |
typedef struct SlNetUtil_addrInfo_t SlNetUtil_addrInfo_t |
int32_t SlNetUtil_init | ( | int32_t | flags | ) |
Initialize the SlNetUtil module.
[in] | flags | Reserved |
const char* SlNetUtil_gaiStrErr | ( | int32_t | errorCode | ) |
Return text descriptions of getAddrInfo error codes.
[in] | errorCode | A getAddrInfo error code |
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.
[in] | ifBitmap | Specifies the interfaces which the host ip needs to be retrieved from according to the 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(). |
[in] | name | Host name |
[in] | nameLen | Name length |
[out] | ipAddr | A buffer used to store the IP address(es) from the resulting DNS resolution. The caller is responsible for allocating this buffer. Upon return, this buffer can be accessed as an array of IPv4 or IPv6 addresses, depending on the protocol passed in for the family parameter. Addresses are stored in host byte order. |
[in,out] | ipAddrLen | Initially holds the number of IP addresses that the ipAddr buffer parameter is capable of storing. Upon successful return, the ipAddrLen parameter contains the number of IP addresses that were actually written into the ipAddr buffer, as a result of successful DNS resolution, or zero if DNS resolution failed. |
[in] | family | Protocol family |
ipAddr
field int32_t SlNetUtil_getAddrInfo | ( | uint16_t | ifID, |
const char * | node, | ||
const char * | service, | ||
const struct SlNetUtil_addrInfo_t * | hints, | ||
struct SlNetUtil_addrInfo_t ** | res | ||
) |
Network address and service translation.
Create an IPv4 or IPv6 socket address structure, to be used with bind() and/or connect() to create a client or server socket
This is a "minimal" version for support on embedded devices. Supports a host name or an IPv4 or IPv6 address string passed in via the 'node' parameter for creating a client socket. A value of NULL should be passed for 'node' with AI_PASSIVE flag set to create a (non-loopback) server socket.
The caller is responsible for freeing the allocated results by calling SlNetUtil_freeAddrInfo().
[in] | ifID | Specifies the interface which needs to used for socket operations. The values of the interface identifier is defined with the prefix SLNETIF_ID_ which defined in slnetif.h |
[in] | node | An IP address or a host name. |
[in] | service | The port number of the service to bind or connect to. |
[in] | hints | An SlNetUtil_addrInfo_t struct used to filter the results returned. |
[out] | res | one or more SlNetUtil_addrInfo_t structs, each of which can be used to bind or connect a socket. |
void SlNetUtil_freeAddrInfo | ( | struct SlNetUtil_addrInfo_t * | res | ) |
Free the results returned from SlNetUtil_getAddrInfo.
Free the chain of SlNetUtil_addrInfo_t structs allocated and returned by SlNetUtil_getAddrInfo
[in] | res | linked list of results returned from SlNetUtil_getAddrInfo |
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.
[in] | val | Variable in host order |
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.
[in] | val | Variable in network order |
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.
[in] | val | Variable in host order |
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.
[in] | val | Variable in network order |
int SlNetUtil_inetAton | ( | const char * | str, |
struct SlNetSock_InAddr_t * | addr | ||
) |
Convert an IPv4 address in string format to binary format.
This function converts an IPv4 address stored as a character string to a 32-bit binary value in network byte order. Note that a leading zero or a "0x" in the address string are interpreted as octal or hexadecimal, respectively. The function stores the IPv4 address in the address structure pointed to by the addr parameter.
[in] | str | IPv4 address string in dotted decimal format |
[out] | addr | pointer to an IPv4 address structure. The converted binary address is stored in this structure upon return (in network byte order) |
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.
[in] | addrFamily | Specifies the address family of the created socket For example:
|
[in] | binaryAddr | Pointer to an IP address structure indicating the address in binary representation. The address is assumed to be in network-byte order |
[out] | strAddr | Pointer to the address string representation for IPv4 or IPv6 according to the address family |
[in] | strAddrLen | Specifies the length of the StrAddress_dst, the maximum length of the address in string representation for IPv4 or IPv6 according to the address family |
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.
[in] | addrFamily | Specifies the address family of the created socket For example:
|
[in] | strAddr | Specifies the IP address in string representation for IPv4 or IPv6 according to the address family |
[out] | binaryAddr | Pointer to an address structure that will be filled by the IP address in Binary representation. The address is returned in network-byte order |