Network Services API  2.75.00.17
slnetutils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*****************************************************************************/
34 /* Include files */
35 /*****************************************************************************/
36 
37 #ifndef __SL_NET_UTILS_H__
38 #define __SL_NET_UTILS_H__
39 
40 #include <stddef.h>
41 
42 #include "slnetsock.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
61 /*****************************************************************************/
62 /* Macro declarations */
63 /*****************************************************************************/
64 #define SLNETUTIL_AI_PASSIVE 0x00000001
65 #define SLNETUTIL_AI_NUMERICHOST 0x00000004
66 
67 /*****************************************************************************/
68 /* Structure/Enum declarations */
69 /*****************************************************************************/
70 
71 typedef struct SlNetUtil_addrInfo_t {
72  int ai_flags;
73  int ai_family;
76  size_t ai_addrlen;
78  char *ai_canonname;
81 
82 /* Creating one address parameter from 4 separate address parameters */
83 #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) )
84 
85 /*****************************************************************************/
86 /* Function prototypes */
87 /*****************************************************************************/
88 
97 int32_t SlNetUtil_init(int32_t flags);
98 
107 const char *SlNetUtil_gaiStrErr(int32_t errorCode);
108 
189 int32_t SlNetUtil_getHostByName(uint32_t ifBitmap, char *name, const uint16_t nameLen, uint32_t *ipAddr, uint16_t *ipAddrLen, const uint8_t family);
190 
191 
227 int32_t SlNetUtil_getAddrInfo(uint16_t ifID, const char *node,
228  const char *service, const struct SlNetUtil_addrInfo_t *hints,
229  struct SlNetUtil_addrInfo_t **res);
230 
244 
262 uint32_t SlNetUtil_htonl(uint32_t val);
263 
264 
282 uint32_t SlNetUtil_ntohl(uint32_t val);
283 
284 
302 uint16_t SlNetUtil_htons(uint16_t val);
303 
304 
322 uint16_t SlNetUtil_ntohs(uint16_t val);
323 
340 int SlNetUtil_inetAton(const char *str, struct SlNetSock_InAddr_t *addr);
341 
380 const char *SlNetUtil_inetNtop(int16_t addrFamily, const void *binaryAddr, char *strAddr, SlNetSocklen_t strAddrLen);
381 
382 
414 int32_t SlNetUtil_inetPton(int16_t addrFamily, const char *strAddr, void *binaryAddr);
415 
424 #ifdef __cplusplus
425 }
426 #endif /* __cplusplus */
427 
428 #endif /* __SL_NET_UTILS_H__ */
int ai_socktype
Definition: slnetutils.h:74
Definition: slnetutils.h:71
struct SlNetUtil_addrInfo_t SlNetUtil_addrInfo_t
char * ai_canonname
Definition: slnetutils.h:78
size_t ai_addrlen
Definition: slnetutils.h:76
const char * SlNetUtil_inetNtop(int16_t addrFamily, const void *binaryAddr, char *strAddr, SlNetSocklen_t strAddrLen)
Converts IP address in binary representation to string representation.
uint16_t SlNetSocklen_t
The SlNetSocklen_t is used for declaring the socket length parameter.
Definition: slnetsock.h:647
IpV4 socket address.
Definition: slnetsock.h:652
uint16_t SlNetUtil_htons(uint16_t val)
Reorder the bytes of a 16-bit unsigned value.
int ai_protocol
Definition: slnetutils.h:75
int ai_flags
Definition: slnetutils.h:72
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. ...
int32_t SlNetUtil_inetPton(int16_t addrFamily, const char *strAddr, void *binaryAddr)
Converts IP address in string representation to binary representation.
Internet address.
Definition: slnetsock.h:442
uint32_t SlNetUtil_ntohl(uint32_t val)
Reorder the bytes of a 32-bit unsigned value.
int SlNetUtil_inetAton(const char *str, struct SlNetSock_InAddr_t *addr)
Convert an IPv4 address in string format to binary format.
int ai_family
Definition: slnetutils.h:73
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.
struct SlNetUtil_addrInfo_t * ai_next
Definition: slnetutils.h:79
void SlNetUtil_freeAddrInfo(struct SlNetUtil_addrInfo_t *res)
Free the results returned from SlNetUtil_getAddrInfo.
int32_t SlNetUtil_init(int32_t flags)
Initialize the SlNetUtil module.
uint32_t SlNetUtil_htonl(uint32_t val)
Reorder the bytes of a 32-bit unsigned value.
const char * SlNetUtil_gaiStrErr(int32_t errorCode)
Return text descriptions of getAddrInfo error codes.
uint16_t SlNetUtil_ntohs(uint16_t val)
Reorder the bytes of a 16-bit unsigned value.
struct SlNetSock_Addr_t * ai_addr
Definition: slnetutils.h:77
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale