posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
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
20#ifndef ZEPHYR_INCLUDE_POSIX_NETDB_H_
21#define ZEPHYR_INCLUDE_POSIX_NETDB_H_
22
23#include <zephyr/net/socket.h>
24
25#ifndef NI_MAXSERV
27#define NI_MAXSERV 32
28#endif
29
31#define EAI_BADFLAGS DNS_EAI_BADFLAGS
33#define EAI_NONAME DNS_EAI_NONAME
35#define EAI_AGAIN DNS_EAI_AGAIN
37#define EAI_FAIL DNS_EAI_FAIL
39#define EAI_NODATA DNS_EAI_NODATA
41#define EAI_MEMORY DNS_EAI_MEMORY
43#define EAI_SYSTEM DNS_EAI_SYSTEM
45#define EAI_SERVICE DNS_EAI_SERVICE
47#define EAI_SOCKTYPE DNS_EAI_SOCKTYPE
49#define EAI_FAMILY DNS_EAI_FAMILY
51#define EAI_OVERFLOW DNS_EAI_OVERFLOW
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
58struct hostent {
59 char *h_name;
60 char **h_aliases;
63 char **h_addr_list;
64};
65
67struct netent {
68 char *n_name;
69 char **n_aliases;
71 uint32_t n_net;
72};
73
75struct protoent {
76 char *p_name;
77 char **p_aliases;
78 int p_proto;
79};
80
82struct servent {
83 char *s_name;
84 char **s_aliases;
85 int s_port;
86 char *s_proto;
87};
88
90#define addrinfo zsock_addrinfo
91
93void endhostent(void);
95void endnetent(void);
97void endprotoent(void);
99void endservent(void);
100
107void freeaddrinfo(struct zsock_addrinfo *ai);
108
116const char *gai_strerror(int errcode);
117
128int getaddrinfo(const char *host, const char *service, const struct zsock_addrinfo *hints,
129 struct zsock_addrinfo **res);
130
136struct hostent *gethostent(void);
137
151int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, char *host, socklen_t hostlen,
152 char *serv, socklen_t servlen, int flags);
153
161struct netent *getnetbyaddr(uint32_t net, int type);
162
169struct netent *getnetbyname(const char *name);
170
176struct netent *getnetent(void);
177
184struct protoent *getprotobyname(const char *name);
185
192struct protoent *getprotobynumber(int proto);
193
199struct protoent *getprotoent(void);
200
208struct servent *getservbyname(const char *name, const char *proto);
209
217struct servent *getservbyport(int port, const char *proto);
218
224struct servent *getservent(void);
225
232void sethostent(int stayopen);
233
240void setnetent(int stayopen);
241
248void setprotoent(int stayopen);
249
256void setservent(int stayopen);
257
258
259#ifdef __cplusplus
260}
261#endif
262
263#endif /* ZEPHYR_INCLUDE_POSIX_NETDB_H_ */
struct servent * getservbyport(int port, const char *proto)
Look up a service by port number and protocol (legacy).
void setnetent(int stayopen)
Open the networks database (legacy).
struct netent * getnetbyaddr(uint32_t net, int type)
Look up a network by address (legacy).
struct netent * getnetent(void)
Get the next entry from the networks database (legacy, sequential).
struct protoent * getprotobyname(const char *name)
Look up a protocol by name (legacy).
struct netent * getnetbyname(const char *name)
Look up a network by name (legacy).
void endprotoent(void)
Close the protocols database (legacy).
uint32_t socklen_t
Type for socket address length values.
Definition socket.h:48
struct hostent * gethostent(void)
Get the next entry from the hosts database (legacy, sequential).
int getnameinfo(const struct sockaddr *addr, socklen_t addrlen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
Translate a socket address to a hostname and service name.
void setprotoent(int stayopen)
Open the protocols database (legacy).
const char * gai_strerror(int errcode)
Return a string describing a getaddrinfo() error code.
struct protoent * getprotoent(void)
Get the next entry from the protocols database (legacy, sequential).
void endnetent(void)
Close the networks database (legacy, no-op on most systems).
struct servent * getservbyname(const char *name, const char *proto)
Look up a service by name and protocol (legacy).
struct servent * getservent(void)
Get the next entry from the services database (legacy, sequential).
void setservent(int stayopen)
Open the services database (legacy).
struct protoent * getprotobynumber(int proto)
Look up a protocol by number (legacy).
void endhostent(void)
Close the hosts database (legacy, no-op on most systems).
void sethostent(int stayopen)
Open the hosts database (legacy).
int getaddrinfo(const char *host, const char *service, const struct zsock_addrinfo *hints, struct zsock_addrinfo **res)
Translate a hostname and service to a list of socket addresses.
void endservent(void)
Close the services database (legacy).
void freeaddrinfo(struct zsock_addrinfo *ai)
Free addrinfo list returned by getaddrinfo().
Host entry returned by gethostbyname() (legacy).
Definition netdb.h:58
int h_addrtype
Address type (AF_INET, etc.).
Definition netdb.h:61
char * h_name
Official name of the host.
Definition netdb.h:59
char ** h_addr_list
NULL-terminated list of addresses.
Definition netdb.h:63
int h_length
Length of each address in bytes.
Definition netdb.h:62
char ** h_aliases
NULL-terminated list of alternate names.
Definition netdb.h:60
Network entry returned by getnetbyname() (legacy).
Definition netdb.h:67
uint32_t n_net
Network number (host byte order).
Definition netdb.h:71
char ** n_aliases
NULL-terminated list of alternate names.
Definition netdb.h:69
char * n_name
Official network name.
Definition netdb.h:68
int n_addrtype
Address type (AF_INET).
Definition netdb.h:70
Protocol entry returned by getprotobyname() (legacy).
Definition netdb.h:75
int p_proto
Protocol number.
Definition netdb.h:78
char ** p_aliases
NULL-terminated list of alternate names.
Definition netdb.h:77
char * p_name
Official protocol name.
Definition netdb.h:76
Service entry returned by getservbyname() (legacy).
Definition netdb.h:82
char * s_name
Official service name.
Definition netdb.h:83
char * s_proto
Protocol to use ("tcp" or "udp").
Definition netdb.h:86
char ** s_aliases
NULL-terminated list of alternate names.
Definition netdb.h:84
int s_port
Port number (network byte order).
Definition netdb.h:85