20#ifndef ZEPHYR_INCLUDE_POSIX_NETDB_H_
21#define ZEPHYR_INCLUDE_POSIX_NETDB_H_
25#include <zephyr/net/socket.h>
26#include <zephyr/net/dns_resolve.h>
32#if !(defined(_HOSTENT_DECLARED) || defined(__hostent_defined)) || defined(__DOXYGEN__)
41#define _HOSTENT_DECLARED
42#define __hostent_defined
45#if !(defined(_NETENT_DECLARED) || defined(__netent_defined)) || defined(__DOXYGEN__)
53#define _NETENT_DECLARED
54#define __netent_defined
57#if !(defined(_PROTOENT_DECLARED) || defined(__protoent_defined)) || defined(__DOXYGEN__)
64#define _PROTOENT_DECLARED
65#define __protoent_defined
68#if !(defined(_SERVENT_DECLARED) || defined(__servent_defined)) || defined(__DOXYGEN__)
76#define _SERVENT_DECLARED
77#define __servent_defined
81#define IPPORT_RESERVED 1024
87#if !defined(_SOCKLEN_T_DECLARED) && !defined(__socklen_t_defined)
88typedef net_socklen_t socklen_t;
89#define _SOCKLEN_T_DECLARED
90#define __socklen_t_defined
93#if !defined(_SA_FAMILY_T_DECLARED) && !defined(__sa_family_t_defined)
94typedef net_sa_family_t sa_family_t;
95#define _SA_FAMILY_T_DECLARED
96#define __sa_family_t_defined
99#if !defined(_SOCKADDR_DECLARED) && !defined(__sockaddr_defined)
104#define _SOCKADDR_DECLARED
105#define __sockaddr_defined
108#if !(defined(_ADDRINFO_DECLARED) || defined(__addrinfo_defined)) || defined(__DOXYGEN__)
123 struct net_sockaddr_storage _ai_addr;
124 char _ai_canonname[DNS_MAX_NAME_SIZE + 1];
127#define _ADDRINFO_DECLARED
128#define __addrinfo_defined
133#define AI_PASSIVE ZSOCK_AI_PASSIVE
135#define AI_CANONNAME ZSOCK_AI_CANONNAME
137#define AI_NUMERICHOST ZSOCK_AI_NUMERICHOST
139#define AI_NUMERICSERV ZSOCK_AI_NUMERICSERV
141#define AI_V4MAPPED ZSOCK_AI_V4MAPPED
143#define AI_ALL ZSOCK_AI_ALL
145#define AI_ADDRCONFIG ZSOCK_AI_ADDRCONFIG
149#define NI_NOFQDN ZSOCK_NI_NOFQDN
151#define NI_NUMERICHOST ZSOCK_NI_NUMERICHOST
153#define NI_NAMEREQD ZSOCK_NI_NAMEREQD
155#define NI_NUMERICSERV ZSOCK_NI_NUMERICSERV
157#define NI_NUMERICSCOPE 32
159#define NI_DGRAM ZSOCK_NI_DGRAM
163#define EAI_AGAIN DNS_EAI_AGAIN
165#define EAI_BADFLAGS DNS_EAI_BADFLAGS
167#define EAI_FAIL DNS_EAI_FAIL
169#define EAI_FAMILY DNS_EAI_FAMILY
171#define EAI_MEMORY DNS_EAI_MEMORY
173#define EAI_NONAME DNS_EAI_NONAME
175#define EAI_SERVICE DNS_EAI_SERVICE
177#define EAI_SOCKTYPE DNS_EAI_SOCKTYPE
179#define EAI_SYSTEM DNS_EAI_SYSTEM
181#define EAI_OVERFLOW DNS_EAI_OVERFLOW
193#define EAI_NODATA DNS_EAI_NODATA
275 char *serv, socklen_t servlen,
int flags);
struct servent * getservbyport(int port, const char *proto)
Look up a service by port number and protocol.
void setnetent(int stayopen)
Open the networks database.
struct netent * getnetbyaddr(uint32_t net, int type)
Look up a network by address.
struct netent * getnetent(void)
Get the next entry from the networks database.
struct protoent * getprotobyname(const char *name)
Look up a protocol by name.
struct netent * getnetbyname(const char *name)
Look up a network by name.
void endprotoent(void)
Close the protocols database.
int getaddrinfo(const char *host, const char *service, const struct addrinfo *hints, struct addrinfo **res)
Translate a hostname and service to a list of socket addresses.
struct hostent * gethostent(void)
Get the next entry from the hosts database.
void freeaddrinfo(struct addrinfo *ai)
Free addrinfo list returned by getaddrinfo.
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.
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.
void endnetent(void)
Close the networks database.
struct servent * getservbyname(const char *name, const char *proto)
Look up a service by name and protocol.
struct servent * getservent(void)
Get the next entry from the services database.
void setservent(int stayopen)
Open the services database.
struct protoent * getprotobynumber(int proto)
Look up a protocol by number.
void endhostent(void)
Close the hosts database.
void sethostent(int stayopen)
Open the hosts database.
void endservent(void)
Close the services database.
net_sa_family_t sa_family_t
Socket address family type.
Address info structure returned by getaddrinfo.
struct sockaddr * ai_addr
Socket address for this entry.
char * ai_canonname
Canonical host name, or NULL.
int ai_socktype
Socket type (SOCK_STREAM, SOCK_DGRAM, ...).
int ai_protocol
Protocol (IPPROTO_*), or 0 for any.
socklen_t ai_addrlen
Length of addrinfo.ai_addr in bytes.
struct addrinfo * ai_next
Next entry in the linked list, or NULL.
int ai_flags
Input AI_* flags.
int ai_family
Address family (AF_INET, AF_INET6, AF_UNSPEC).
int h_addrtype
Address type (AF_INET, etc.).
char * h_name
Official name of the host.
char ** h_addr_list
NULL-terminated list of addresses.
int h_length
Length of each address in bytes.
char ** h_aliases
NULL-terminated list of alternate names.
uint32_t n_net
Network number (host byte order).
char ** n_aliases
NULL-terminated list of alternate names.
char * n_name
Official network name.
int n_addrtype
Address type (AF_INET).
int p_proto
Protocol number.
char ** p_aliases
NULL-terminated list of alternate names.
char * p_name
Official protocol name.
char * s_name
Official service name.
char * s_proto
Protocol to use ("tcp" or "udp").
char ** s_aliases
NULL-terminated list of alternate names.
int s_port
Port number (network byte order).
char sa_data[14]
Address payload.
sa_family_t sa_family
Address family.