Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
netdb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Linaro Limited
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_POSIX_NETDB_H_
7#define ZEPHYR_INCLUDE_POSIX_NETDB_H_
8
9#include <zephyr/net/socket.h>
10
11#ifndef NI_MAXSERV
13#define NI_MAXSERV 32
14#endif
15
16#define EAI_BADFLAGS DNS_EAI_BADFLAGS
17#define EAI_NONAME DNS_EAI_NONAME
18#define EAI_AGAIN DNS_EAI_AGAIN
19#define EAI_FAIL DNS_EAI_FAIL
20#define EAI_NODATA DNS_EAI_NODATA
21#define EAI_MEMORY DNS_EAI_MEMORY
22#define EAI_SYSTEM DNS_EAI_SYSTEM
23#define EAI_SERVICE DNS_EAI_SERVICE
24#define EAI_SOCKTYPE DNS_EAI_SOCKTYPE
25#define EAI_FAMILY DNS_EAI_FAMILY
26#define EAI_OVERFLOW DNS_EAI_OVERFLOW
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#ifndef CONFIG_NET_SOCKETS_POSIX_NAMES
33
34#define addrinfo zsock_addrinfo
35
36static inline int getaddrinfo(const char *host, const char *service,
37 const struct zsock_addrinfo *hints,
38 struct zsock_addrinfo **res)
39{
40 return zsock_getaddrinfo(host, service, hints, res);
41}
42
43static inline void freeaddrinfo(struct zsock_addrinfo *ai)
44{
46}
47
48static inline const char *gai_strerror(int errcode)
49{
50 return zsock_gai_strerror(errcode);
51}
52
53static inline int getnameinfo(const struct sockaddr *addr, socklen_t addrlen,
54 char *host, socklen_t hostlen,
55 char *serv, socklen_t servlen, int flags)
56{
57 return zsock_getnameinfo(addr, addrlen, host, hostlen,
58 serv, servlen, flags);
59}
60
61#endif /* CONFIG_NET_SOCKETS_POSIX_NAMES */
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif /* ZEPHYR_INCLUDE_POSIX_NETDB_H_ */
static int getaddrinfo(const char *host, const char *service, const struct zsock_addrinfo *hints, struct zsock_addrinfo **res)
POSIX wrapper for zsock_getaddrinfo.
Definition: socket.h:900
static int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
POSIX wrapper for zsock_getnameinfo.
Definition: socket.h:920
void zsock_freeaddrinfo(struct zsock_addrinfo *ai)
Free results returned by zsock_getaddrinfo()
const char * zsock_gai_strerror(int errcode)
Convert zsock_getaddrinfo() error code to textual message.
static const char * gai_strerror(int errcode)
POSIX wrapper for zsock_gai_strerror.
Definition: socket.h:914
int zsock_getnameinfo(const struct sockaddr *addr, socklen_t addrlen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
Resolve a network address to a domain name or ASCII address.
int zsock_getaddrinfo(const char *host, const char *service, const struct zsock_addrinfo *hints, struct zsock_addrinfo **res)
Resolve a domain name to one or more network addresses.
static void freeaddrinfo(struct zsock_addrinfo *ai)
POSIX wrapper for zsock_freeaddrinfo.
Definition: socket.h:908
size_t socklen_t
Length of a socket address.
Definition: net_ip.h:168
BSD Sockets compatible API definitions.
flags
Definition: parser.h:96
Generic sockaddr struct.
Definition: net_ip.h:347
Definition: socket.h:233