posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
netdb.h File Reference

POSIX network database operations (<netdb.h>) More...

#include <stdint.h>
#include <zephyr/net/socket.h>
#include <zephyr/net/dns_resolve.h>
Include dependency graph for netdb.h:

Go to the source code of this file.

Data Structures

struct  hostent
 Host database entry. More...
 
struct  netent
 Network database entry. More...
 
struct  protoent
 Protocol database entry. More...
 
struct  servent
 Service database entry. More...
 
struct  sockaddr
 Generic socket address. More...
 
struct  addrinfo
 Address info structure returned by getaddrinfo. More...
 

Macros

#define IPPORT_RESERVED   1024
 Highest reserved Internet port number.
 
#define AI_PASSIVE   ZSOCK_AI_PASSIVE
 Return an address suitable for bind() (a passive open).
 
#define AI_CANONNAME   ZSOCK_AI_CANONNAME
 Request the canonical host name in addrinfo.ai_canonname.
 
#define AI_NUMERICHOST   ZSOCK_AI_NUMERICHOST
 Treat the host name as a numeric address string.
 
#define AI_NUMERICSERV   ZSOCK_AI_NUMERICSERV
 Treat the service name as a numeric port string.
 
#define AI_V4MAPPED   ZSOCK_AI_V4MAPPED
 Return IPv4-mapped IPv6 addresses when no IPv6 addresses are found.
 
#define AI_ALL   ZSOCK_AI_ALL
 With AI_V4MAPPED, return both IPv6 and IPv4-mapped addresses.
 
#define AI_ADDRCONFIG   ZSOCK_AI_ADDRCONFIG
 Return addresses only for locally configured address families.
 
#define NI_NOFQDN   ZSOCK_NI_NOFQDN
 Do not return the fully qualified domain name.
 
#define NI_NUMERICHOST   ZSOCK_NI_NUMERICHOST
 Return the host address in numeric form.
 
#define NI_NAMEREQD   ZSOCK_NI_NAMEREQD
 Return an error if the host name cannot be located.
 
#define NI_NUMERICSERV   ZSOCK_NI_NUMERICSERV
 Return the service in numeric (port number) form.
 
#define NI_NUMERICSCOPE   32
 Return the numeric form of the scope identifier.
 
#define NI_DGRAM   ZSOCK_NI_DGRAM
 Look up the service name for a datagram socket.
 
#define EAI_AGAIN   DNS_EAI_AGAIN
 Temporary failure in name resolution.
 
#define EAI_BADFLAGS   DNS_EAI_BADFLAGS
 Flags argument to getaddrinfo contained an invalid value.
 
#define EAI_FAIL   DNS_EAI_FAIL
 Non-recoverable failure in name resolution.
 
#define EAI_FAMILY   DNS_EAI_FAMILY
 Address family not supported.
 
#define EAI_MEMORY   DNS_EAI_MEMORY
 Memory allocation failure.
 
#define EAI_NONAME   DNS_EAI_NONAME
 The name does not resolve for the supplied parameters.
 
#define EAI_SERVICE   DNS_EAI_SERVICE
 Requested service not available for the given socket type.
 
#define EAI_SOCKTYPE   DNS_EAI_SOCKTYPE
 Socket type not supported.
 
#define EAI_SYSTEM   DNS_EAI_SYSTEM
 A system error occurred; errno is set.
 
#define EAI_OVERFLOW   DNS_EAI_OVERFLOW
 Output buffer overflow.
 
#define NI_MAXHOST   64
 Reasonable buffer size for getnameinfo host names (extension).
 
#define NI_MAXSERV   32
 Reasonable buffer size for getnameinfo service names (extension).
 
#define EAI_NODATA   DNS_EAI_NODATA
 The requested name is valid but has no address data (obsolescent extension).
 

Typedefs

typedef net_socklen_t socklen_t
 
typedef net_sa_family_t sa_family_t
 

Functions

void endhostent (void)
 Close the hosts database.
 
void endnetent (void)
 Close the networks database.
 
void endprotoent (void)
 Close the protocols database.
 
void endservent (void)
 Close the services database.
 
void freeaddrinfo (struct addrinfo *ai)
 Free addrinfo list returned by getaddrinfo.
 
const char * gai_strerror (int errcode)
 Return a string describing a getaddrinfo error code.
 
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 hostentgethostent (void)
 Get the next entry from the hosts database.
 
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.
 
struct netentgetnetbyaddr (uint32_t net, int type)
 Look up a network by address.
 
struct netentgetnetbyname (const char *name)
 Look up a network by name.
 
struct netentgetnetent (void)
 Get the next entry from the networks database.
 
struct protoentgetprotobyname (const char *name)
 Look up a protocol by name.
 
struct protoentgetprotobynumber (int proto)
 Look up a protocol by number.
 
struct protoentgetprotoent (void)
 Get the next entry from the protocols database.
 
struct serventgetservbyname (const char *name, const char *proto)
 Look up a service by name and protocol.
 
struct serventgetservbyport (int port, const char *proto)
 Look up a service by port number and protocol.
 
struct serventgetservent (void)
 Get the next entry from the services database.
 
void sethostent (int stayopen)
 Open the hosts database.
 
void setnetent (int stayopen)
 Open the networks database.
 
void setprotoent (int stayopen)
 Open the protocols database.
 
void setservent (int stayopen)
 Open the services database.
 

Detailed Description

POSIX network database operations (<netdb.h>)

Provides hostname and service resolution (getaddrinfo/getnameinfo) and the host/network/protocol/service database functions.

See also
POSIX.1-2017 <netdb.h>

Definition in file netdb.h.

Macro Definition Documentation

◆ AI_ADDRCONFIG

#define AI_ADDRCONFIG   ZSOCK_AI_ADDRCONFIG

Return addresses only for locally configured address families.

Definition at line 145 of file netdb.h.

◆ AI_ALL

#define AI_ALL   ZSOCK_AI_ALL

With AI_V4MAPPED, return both IPv6 and IPv4-mapped addresses.

Definition at line 143 of file netdb.h.

◆ AI_CANONNAME

#define AI_CANONNAME   ZSOCK_AI_CANONNAME

Request the canonical host name in addrinfo.ai_canonname.

Definition at line 135 of file netdb.h.

◆ AI_NUMERICHOST

#define AI_NUMERICHOST   ZSOCK_AI_NUMERICHOST

Treat the host name as a numeric address string.

Definition at line 137 of file netdb.h.

◆ AI_NUMERICSERV

#define AI_NUMERICSERV   ZSOCK_AI_NUMERICSERV

Treat the service name as a numeric port string.

Definition at line 139 of file netdb.h.

◆ AI_PASSIVE

#define AI_PASSIVE   ZSOCK_AI_PASSIVE

Return an address suitable for bind() (a passive open).

Definition at line 133 of file netdb.h.

◆ AI_V4MAPPED

#define AI_V4MAPPED   ZSOCK_AI_V4MAPPED

Return IPv4-mapped IPv6 addresses when no IPv6 addresses are found.

Definition at line 141 of file netdb.h.

◆ EAI_AGAIN

#define EAI_AGAIN   DNS_EAI_AGAIN

Temporary failure in name resolution.

Definition at line 163 of file netdb.h.

◆ EAI_BADFLAGS

#define EAI_BADFLAGS   DNS_EAI_BADFLAGS

Flags argument to getaddrinfo contained an invalid value.

Definition at line 165 of file netdb.h.

◆ EAI_FAIL

#define EAI_FAIL   DNS_EAI_FAIL

Non-recoverable failure in name resolution.

Definition at line 167 of file netdb.h.

◆ EAI_FAMILY

#define EAI_FAMILY   DNS_EAI_FAMILY

Address family not supported.

Definition at line 169 of file netdb.h.

◆ EAI_MEMORY

#define EAI_MEMORY   DNS_EAI_MEMORY

Memory allocation failure.

Definition at line 171 of file netdb.h.

◆ EAI_NODATA

#define EAI_NODATA   DNS_EAI_NODATA

The requested name is valid but has no address data (obsolescent extension).

Definition at line 193 of file netdb.h.

◆ EAI_NONAME

#define EAI_NONAME   DNS_EAI_NONAME

The name does not resolve for the supplied parameters.

Definition at line 173 of file netdb.h.

◆ EAI_OVERFLOW

#define EAI_OVERFLOW   DNS_EAI_OVERFLOW

Output buffer overflow.

Definition at line 181 of file netdb.h.

◆ EAI_SERVICE

#define EAI_SERVICE   DNS_EAI_SERVICE

Requested service not available for the given socket type.

Definition at line 175 of file netdb.h.

◆ EAI_SOCKTYPE

#define EAI_SOCKTYPE   DNS_EAI_SOCKTYPE

Socket type not supported.

Definition at line 177 of file netdb.h.

◆ EAI_SYSTEM

#define EAI_SYSTEM   DNS_EAI_SYSTEM

A system error occurred; errno is set.

Definition at line 179 of file netdb.h.

◆ IPPORT_RESERVED

#define IPPORT_RESERVED   1024

Highest reserved Internet port number.

Definition at line 81 of file netdb.h.

◆ NI_DGRAM

#define NI_DGRAM   ZSOCK_NI_DGRAM

Look up the service name for a datagram socket.

Definition at line 159 of file netdb.h.

◆ NI_MAXHOST

#define NI_MAXHOST   64

Reasonable buffer size for getnameinfo host names (extension).

Definition at line 186 of file netdb.h.

◆ NI_MAXSERV

#define NI_MAXSERV   32

Reasonable buffer size for getnameinfo service names (extension).

Definition at line 190 of file netdb.h.

◆ NI_NAMEREQD

#define NI_NAMEREQD   ZSOCK_NI_NAMEREQD

Return an error if the host name cannot be located.

Definition at line 153 of file netdb.h.

◆ NI_NOFQDN

#define NI_NOFQDN   ZSOCK_NI_NOFQDN

Do not return the fully qualified domain name.

Definition at line 149 of file netdb.h.

◆ NI_NUMERICHOST

#define NI_NUMERICHOST   ZSOCK_NI_NUMERICHOST

Return the host address in numeric form.

Definition at line 151 of file netdb.h.

◆ NI_NUMERICSCOPE

#define NI_NUMERICSCOPE   32

Return the numeric form of the scope identifier.

Definition at line 157 of file netdb.h.

◆ NI_NUMERICSERV

#define NI_NUMERICSERV   ZSOCK_NI_NUMERICSERV

Return the service in numeric (port number) form.

Definition at line 155 of file netdb.h.

Typedef Documentation

◆ sa_family_t

typedef net_sa_family_t sa_family_t

Definition at line 94 of file netdb.h.

◆ socklen_t

typedef net_socklen_t socklen_t

Definition at line 88 of file netdb.h.