![]() |
posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
|
POSIX Networking option group. More...
Files | |
| file | inet.h |
| Internet address conversion functions (<arpa/inet.h>) | |
| file | if.h |
| Network interface names and indices (<net/if.h>) | |
| file | netdb.h |
| POSIX network database operations (<netdb.h>) | |
| file | in.h |
| Internet address types (<netinet/in.h>) | |
| file | tcp.h |
| TCP definitions (<netinet/tcp.h>) | |
| file | socket.h |
| POSIX socket API (<sys/socket.h>) | |
Macros | |
| #define | NI_MAXSERV 32 |
| Reasonable buffer size for getnameinfo() service names. | |
| #define | EAI_BADFLAGS DNS_EAI_BADFLAGS |
| Flags argument to getaddrinfo() contained an invalid value. | |
| #define | EAI_NONAME DNS_EAI_NONAME |
| The name does not resolve for the supplied parameters. | |
| #define | EAI_AGAIN DNS_EAI_AGAIN |
| Temporary failure in name resolution. | |
| #define | EAI_FAIL DNS_EAI_FAIL |
| Non-recoverable failure in name resolution. | |
| #define | EAI_NODATA DNS_EAI_NODATA |
| The requested name is valid but has no address data. | |
| #define | EAI_MEMORY DNS_EAI_MEMORY |
| Memory allocation failure. | |
| #define | EAI_SYSTEM DNS_EAI_SYSTEM |
| A system error occurred; errno is set. | |
| #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_FAMILY DNS_EAI_FAMILY |
| Address family not supported. | |
| #define | EAI_OVERFLOW DNS_EAI_OVERFLOW |
| Output buffer overflow. | |
| #define | addrinfo zsock_addrinfo |
| Address info structure (alias for zsock_addrinfo). | |
| #define | SHUT_RD ZSOCK_SHUT_RD |
| Shut down the read half of the connection. | |
| #define | SHUT_WR ZSOCK_SHUT_WR |
| Shut down the write half of the connection. | |
| #define | SHUT_RDWR ZSOCK_SHUT_RDWR |
| Shut down both halves of the connection. | |
| #define | MSG_PEEK ZSOCK_MSG_PEEK |
| Peek at incoming data without removing it from the queue. | |
| #define | MSG_TRUNC ZSOCK_MSG_TRUNC |
| Return the real length of the datagram even if it was truncated. | |
| #define | MSG_DONTWAIT ZSOCK_MSG_DONTWAIT |
| Enable non-blocking operation for this call only. | |
| #define | MSG_WAITALL ZSOCK_MSG_WAITALL |
| Block until all requested data has been received. | |
Typedefs | |
| typedef uint32_t | in_addr_t |
| Unsigned 32-bit IPv4 address (alias for in_addr_t). | |
| typedef uint16_t | in_port_t |
| Unsigned 16-bit Internet port number. | |
| typedef uint32_t | in_addr_t |
| Unsigned 32-bit IPv4 address. | |
| typedef uint32_t | socklen_t |
| Type for socket address length values. | |
Functions | |
| in_addr_t | inet_addr (const char *cp) |
| Convert an IPv4 address from dotted-decimal text to binary. | |
| char * | inet_ntoa (struct in_addr in) |
| Convert an IPv4 address from binary to dotted-decimal text. | |
| char * | inet_ntop (sa_family_t family, const void *src, char *dst, size_t size) |
| Convert an IPv4 or IPv6 address from binary to text form. | |
| int | inet_pton (sa_family_t family, const char *src, void *dst) |
| Convert an IPv4 or IPv6 address from text form to binary. | |
| char * | if_indextoname (unsigned int ifindex, char *ifname) |
| Map a network interface index to its name. | |
| void | if_freenameindex (struct if_nameindex *ptr) |
| Free a list returned by if_nameindex(). | |
| struct if_nameindex * | if_nameindex (void) |
| Return all network interfaces as a name-index array. | |
| unsigned int | if_nametoindex (const char *ifname) |
| Map a network interface name to its index. | |
| void | endhostent (void) |
| Close the hosts database (legacy, no-op on most systems). | |
| void | endnetent (void) |
| Close the networks database (legacy, no-op on most systems). | |
| void | endprotoent (void) |
| Close the protocols database (legacy). | |
| void | endservent (void) |
| Close the services database (legacy). | |
| void | freeaddrinfo (struct zsock_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 zsock_addrinfo *hints, struct zsock_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 (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. | |
| struct netent * | getnetbyaddr (uint32_t net, int type) |
| Look up a network by address (legacy). | |
| struct netent * | getnetbyname (const char *name) |
| Look up a network by name (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 protoent * | getprotobynumber (int proto) |
| Look up a protocol by number (legacy). | |
| struct protoent * | getprotoent (void) |
| Get the next entry from the protocols database (legacy, sequential). | |
| struct servent * | getservbyname (const char *name, const char *proto) |
| Look up a service by name and protocol (legacy). | |
| struct servent * | getservbyport (int port, const char *proto) |
| Look up a service by port number and protocol (legacy). | |
| struct servent * | getservent (void) |
| Get the next entry from the services database (legacy, sequential). | |
| void | sethostent (int stayopen) |
| Open the hosts database (legacy). | |
| void | setnetent (int stayopen) |
| Open the networks database (legacy). | |
| void | setprotoent (int stayopen) |
| Open the protocols database (legacy). | |
| void | setservent (int stayopen) |
| Open the services database (legacy). | |
| int | accept (int sock, struct sockaddr *addr, socklen_t *addrlen) |
| Accept a new connection on a listening socket. | |
| int | bind (int sock, const struct sockaddr *addr, socklen_t addrlen) |
| Assign a local address to a socket. | |
| int | connect (int sock, const struct sockaddr *addr, socklen_t addrlen) |
| Initiate a connection on a socket. | |
| int | getpeername (int sock, struct sockaddr *addr, socklen_t *addrlen) |
| Get the address of the peer connected to a socket. | |
| int | getsockname (int sock, struct sockaddr *addr, socklen_t *addrlen) |
| Get the local address bound to a socket. | |
| int | getsockopt (int sock, int level, int optname, void *optval, socklen_t *optlen) |
| Get socket options. | |
| int | listen (int sock, int backlog) |
| Mark a socket as passive (ready to accept connections). | |
| ssize_t | recv (int sock, void *buf, size_t max_len, int flags) |
| Receive data from a connected socket. | |
| ssize_t | recvfrom (int sock, void *buf, size_t max_len, int flags, struct sockaddr *src_addr, socklen_t *addrlen) |
| Receive data and the sender's address from a socket. | |
| ssize_t | recvmsg (int sock, struct msghdr *msg, int flags) |
| Receive a message (with scatter-gather I/O and ancillary data). | |
| ssize_t | send (int sock, const void *buf, size_t len, int flags) |
| Send data on a connected socket. | |
| ssize_t | sendmsg (int sock, const struct msghdr *message, int flags) |
| Send a message (with scatter-gather I/O and ancillary data). | |
| ssize_t | sendto (int sock, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen) |
| Send data to a specific destination address. | |
| int | setsockopt (int sock, int level, int optname, const void *optval, socklen_t optlen) |
| Set socket options. | |
| int | shutdown (int sock, int how) |
| Shut down part or all of a full-duplex connection. | |
| int | sockatmark (int s) |
| Determine whether a socket is at the out-of-band mark. | |
| int | socket (int family, int type, int proto) |
| Create a new socket. | |
| int | socketpair (int family, int type, int proto, int sv[2]) |
| Create a pair of connected sockets. | |
POSIX Networking option group.
| #define addrinfo zsock_addrinfo |
| #define EAI_AGAIN DNS_EAI_AGAIN |
| #define EAI_BADFLAGS DNS_EAI_BADFLAGS |
Flags argument to getaddrinfo() contained an invalid value.
| #define EAI_FAIL DNS_EAI_FAIL |
| #define EAI_FAMILY DNS_EAI_FAMILY |
| #define EAI_NODATA DNS_EAI_NODATA |
| #define EAI_NONAME DNS_EAI_NONAME |
| #define EAI_OVERFLOW DNS_EAI_OVERFLOW |
| #define EAI_SERVICE DNS_EAI_SERVICE |
| #define EAI_SOCKTYPE DNS_EAI_SOCKTYPE |
| #define EAI_SYSTEM DNS_EAI_SYSTEM |
| #define MSG_DONTWAIT ZSOCK_MSG_DONTWAIT |
| #define MSG_PEEK ZSOCK_MSG_PEEK |
| #define MSG_TRUNC ZSOCK_MSG_TRUNC |
| #define MSG_WAITALL ZSOCK_MSG_WAITALL |
| #define NI_MAXSERV 32 |
Reasonable buffer size for getnameinfo() service names.
| #define SHUT_RD ZSOCK_SHUT_RD |
| #define SHUT_RDWR ZSOCK_SHUT_RDWR |
| #define SHUT_WR ZSOCK_SHUT_WR |
| typedef uint32_t in_addr_t |
| typedef uint16_t in_port_t |
| typedef uint32_t socklen_t |
| int accept | ( | int | sock, |
| struct sockaddr * | addr, | ||
| socklen_t * | addrlen | ||
| ) |
Accept a new connection on a listening socket.
| sock | Listening socket file descriptor. |
| addr | Output: address of the connecting peer, or NULL. |
| addrlen | Input: size of addr; output: actual address size. |
| int bind | ( | int | sock, |
| const struct sockaddr * | addr, | ||
| socklen_t | addrlen | ||
| ) |
Assign a local address to a socket.
| sock | Socket file descriptor. |
| addr | Local address to bind. |
| addrlen | Size of addr in bytes. |
| int connect | ( | int | sock, |
| const struct sockaddr * | addr, | ||
| socklen_t | addrlen | ||
| ) |
Initiate a connection on a socket.
| sock | Socket file descriptor. |
| addr | Remote address to connect to. |
| addrlen | Size of addr in bytes. |
| void endhostent | ( | void | ) |
Close the hosts database (legacy, no-op on most systems).
| void endnetent | ( | void | ) |
Close the networks database (legacy, no-op on most systems).
| void endprotoent | ( | void | ) |
Close the protocols database (legacy).
| void endservent | ( | void | ) |
Close the services database (legacy).
| void freeaddrinfo | ( | struct zsock_addrinfo * | ai | ) |
Free addrinfo list returned by getaddrinfo().
| ai | Linked list to free. |
| const char * gai_strerror | ( | int | errcode | ) |
Return a string describing a getaddrinfo() error code.
| errcode | Error code returned by getaddrinfo(). |
| 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.
| host | Hostname or numeric address string, or NULL. |
| service | Service name or numeric port string, or NULL. |
| hints | Criteria for address selection, or NULL for defaults. |
| res | Output: linked list of matching addresses. |
| 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.
| addr | Socket address to look up. |
| addrlen | Size of addr. |
| host | Output buffer for the hostname, or NULL. |
| hostlen | Size of host. |
| serv | Output buffer for the service name, or NULL. |
| servlen | Size of serv. |
| flags | NI_* flags controlling the conversion. |
| struct netent * getnetbyaddr | ( | uint32_t | net, |
| int | type | ||
| ) |
Look up a network by address (legacy).
| net | Network number (host byte order). |
| type | Address type (AF_INET). |
| struct netent * getnetbyname | ( | const char * | name | ) |
Look up a network by name (legacy).
| name | Network name. |
| struct netent * getnetent | ( | void | ) |
Get the next entry from the networks database (legacy, sequential).
| int getpeername | ( | int | sock, |
| struct sockaddr * | addr, | ||
| socklen_t * | addrlen | ||
| ) |
Get the address of the peer connected to a socket.
| sock | Socket file descriptor. |
| addr | Output: peer address. |
| addrlen | Input: size of addr; output: actual size. |
| struct protoent * getprotobyname | ( | const char * | name | ) |
Look up a protocol by name (legacy).
| name | Protocol name (e.g. "tcp"). |
| struct protoent * getprotobynumber | ( | int | proto | ) |
Look up a protocol by number (legacy).
| proto | Protocol number. |
| struct protoent * getprotoent | ( | void | ) |
Get the next entry from the protocols database (legacy, sequential).
| struct servent * getservbyname | ( | const char * | name, |
| const char * | proto | ||
| ) |
Look up a service by name and protocol (legacy).
| name | Service name (e.g. "http"). |
| proto | Protocol ("tcp", "udp", or NULL for any). |
| struct servent * getservbyport | ( | int | port, |
| const char * | proto | ||
| ) |
Look up a service by port number and protocol (legacy).
| port | Port number (network byte order). |
| proto | Protocol ("tcp", "udp", or NULL for any). |
| struct servent * getservent | ( | void | ) |
Get the next entry from the services database (legacy, sequential).
| int getsockname | ( | int | sock, |
| struct sockaddr * | addr, | ||
| socklen_t * | addrlen | ||
| ) |
Get the local address bound to a socket.
| sock | Socket file descriptor. |
| addr | Output: local address. |
| addrlen | Input: size of addr; output: actual size. |
| int getsockopt | ( | int | sock, |
| int | level, | ||
| int | optname, | ||
| void * | optval, | ||
| socklen_t * | optlen | ||
| ) |
Get socket options.
| sock | Socket file descriptor. |
| level | Protocol level (SOL_SOCKET, IPPROTO_TCP, etc.). |
| optname | Option name (SO_REUSEADDR, SO_KEEPALIVE, etc.). |
| optval | Output: option value. |
| optlen | Input: size of optval; output: actual size. |
| void if_freenameindex | ( | struct if_nameindex * | ptr | ) |
Free a list returned by if_nameindex().
| ptr | List to free (must have been returned by if_nameindex()). |
| char * if_indextoname | ( | unsigned int | ifindex, |
| char * | ifname | ||
| ) |
Map a network interface index to its name.
| ifindex | Numeric interface index. |
| ifname | Output buffer of at least IF_NAMESIZE bytes. |
ifname on success, or NULL with errno set on failure. | struct if_nameindex * if_nameindex | ( | void | ) |
Return all network interfaces as a name-index array.
The returned array is terminated by an entry with if_index == 0 and if_name == NULL. Free with if_freenameindex().
| unsigned int if_nametoindex | ( | const char * | ifname | ) |
Map a network interface name to its index.
| ifname | Interface name string. |
| in_addr_t inet_addr | ( | const char * | cp | ) |
Convert an IPv4 address from dotted-decimal text to binary.
| cp | Dotted-decimal IPv4 address string (e.g. "192.0.2.1"). |
| char * inet_ntoa | ( | struct in_addr | in | ) |
Convert an IPv4 address from binary to dotted-decimal text.
| in | IPv4 address in network byte order. |
| char * inet_ntop | ( | sa_family_t | family, |
| const void * | src, | ||
| char * | dst, | ||
| size_t | size | ||
| ) |
Convert an IPv4 or IPv6 address from binary to text form.
| family | Address family: AF_INET or AF_INET6. |
| src | Source address in network byte order. |
| dst | Output buffer for the text form. |
| size | Size of dst in bytes (INET_ADDRSTRLEN / INET6_ADDRSTRLEN). |
dst on success, or NULL with errno set on failure. | int inet_pton | ( | sa_family_t | family, |
| const char * | src, | ||
| void * | dst | ||
| ) |
Convert an IPv4 or IPv6 address from text form to binary.
| family | Address family: AF_INET or AF_INET6. |
| src | Text form of the address. |
| dst | Output buffer for the binary address. |
src is not a valid address, -1 on error. | int listen | ( | int | sock, |
| int | backlog | ||
| ) |
Mark a socket as passive (ready to accept connections).
| sock | Socket file descriptor. |
| backlog | Maximum number of pending connections to queue. |
| ssize_t recv | ( | int | sock, |
| void * | buf, | ||
| size_t | max_len, | ||
| int | flags | ||
| ) |
Receive data from a connected socket.
| sock | Socket file descriptor. |
| buf | Buffer to receive data into. |
| max_len | Maximum number of bytes to receive. |
| flags | MSG_* flags (MSG_PEEK, MSG_DONTWAIT, etc.). |
| ssize_t recvfrom | ( | int | sock, |
| void * | buf, | ||
| size_t | max_len, | ||
| int | flags, | ||
| struct sockaddr * | src_addr, | ||
| socklen_t * | addrlen | ||
| ) |
Receive data and the sender's address from a socket.
| sock | Socket file descriptor. |
| buf | Buffer to receive data into. |
| max_len | Maximum number of bytes to receive. |
| flags | MSG_* flags. |
| src_addr | Output: sender's address, or NULL. |
| addrlen | Input: size of src_addr; output: actual size. |
| ssize_t recvmsg | ( | int | sock, |
| struct msghdr * | msg, | ||
| int | flags | ||
| ) |
Receive a message (with scatter-gather I/O and ancillary data).
| sock | Socket file descriptor. |
| msg | Message header specifying I/O vectors and address buffer. |
| flags | MSG_* flags. |
| ssize_t send | ( | int | sock, |
| const void * | buf, | ||
| size_t | len, | ||
| int | flags | ||
| ) |
Send data on a connected socket.
| sock | Socket file descriptor. |
| buf | Data to send. |
| len | Number of bytes to send. |
| flags | MSG_* flags (MSG_DONTWAIT, MSG_NOSIGNAL, etc.). |
| ssize_t sendmsg | ( | int | sock, |
| const struct msghdr * | message, | ||
| int | flags | ||
| ) |
Send a message (with scatter-gather I/O and ancillary data).
| sock | Socket file descriptor. |
| message | Message header specifying I/O vectors and destination. |
| flags | MSG_* flags. |
| ssize_t sendto | ( | int | sock, |
| const void * | buf, | ||
| size_t | len, | ||
| int | flags, | ||
| const struct sockaddr * | dest_addr, | ||
| socklen_t | addrlen | ||
| ) |
Send data to a specific destination address.
| sock | Socket file descriptor. |
| buf | Data to send. |
| len | Number of bytes to send. |
| flags | MSG_* flags. |
| dest_addr | Destination address. |
| addrlen | Size of dest_addr in bytes. |
| void sethostent | ( | int | stayopen | ) |
Open the hosts database (legacy).
| stayopen | Non-zero to keep the database connection open. |
| void setnetent | ( | int | stayopen | ) |
Open the networks database (legacy).
| stayopen | Non-zero to keep the database connection open. |
| void setprotoent | ( | int | stayopen | ) |
Open the protocols database (legacy).
| stayopen | Non-zero to keep the database connection open. |
| void setservent | ( | int | stayopen | ) |
Open the services database (legacy).
| stayopen | Non-zero to keep the database connection open. |
| int setsockopt | ( | int | sock, |
| int | level, | ||
| int | optname, | ||
| const void * | optval, | ||
| socklen_t | optlen | ||
| ) |
Set socket options.
| sock | Socket file descriptor. |
| level | Protocol level (SOL_SOCKET, IPPROTO_TCP, etc.). |
| optname | Option name. |
| optval | Pointer to the new option value. |
| optlen | Size of optval in bytes. |
| int shutdown | ( | int | sock, |
| int | how | ||
| ) |
Shut down part or all of a full-duplex connection.
| sock | Socket file descriptor. |
| how | SHUT_RD, SHUT_WR, or SHUT_RDWR. |
| int sockatmark | ( | int | s | ) |
Determine whether a socket is at the out-of-band mark.
| s | Socket file descriptor. |
| int socket | ( | int | family, |
| int | type, | ||
| int | proto | ||
| ) |
Create a new socket.
| family | Protocol family (AF_INET, AF_INET6, AF_UNIX, etc.). |
| type | Socket type (SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, etc.). |
| proto | Protocol number (IPPROTO_TCP, IPPROTO_UDP, 0 for default). |
| int socketpair | ( | int | family, |
| int | type, | ||
| int | proto, | ||
| int | sv[2] | ||
| ) |
Create a pair of connected sockets.
| family | Protocol family (typically AF_UNIX). |
| type | Socket type. |
| proto | Protocol. |
| sv | Output: two-element array receiving the socket descriptors. |