|
|
|
@ -103,66 +103,54 @@ members and callbacks (which are different from the |
|
|
|
|
\fBares_socket_functions(3)\fP members and callbacks): |
|
|
|
|
|
|
|
|
|
.RS 4 |
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIversion\fP |
|
|
|
|
.TP 8 |
|
|
|
|
.B unsigned int \fIversion\fP |
|
|
|
|
.br |
|
|
|
|
ABI Version of structure. Must be set to a value of "1". |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIflags\fP |
|
|
|
|
.TP 8 |
|
|
|
|
.B unsigned int \fIflags\fP |
|
|
|
|
.br |
|
|
|
|
Flags available are specified in \fIares_sockfunc_flags_t\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIasocket\fP |
|
|
|
|
.B ares_socket_t(*)(int \fIdomain\fP, int \fItype\fP, int \fIprotocol\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B ares_socket_t (*\fIasocket\fP)(int \fIdomain\fP, int \fItype\fP, int \fIprotocol\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIREQUIRED\fP. Creates an endpoint for communication and returns a descriptor. \fIdomain\fP, |
|
|
|
|
\fItype\fP, and \fIprotocol\fP each correspond to the parameters of |
|
|
|
|
\fBsocket(2)\fP. Returns a handle to the newly created socket, or |
|
|
|
|
\fBARES_SOCKET_BAD\fP on error. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIaclose\fP |
|
|
|
|
.B int(*)(ares_socket_t \fIfd\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B int (*\fIaclose\fP)(ares_socket_t \fIfd\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIREQUIRED\fP. Closes the socket endpoint indicated by \fIfd\fP. See \fBclose(2)\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIasetsockopt\fP |
|
|
|
|
.B int(*)(ares_socket_t \fIfd\fP, ares_socket_opt_t \fIopt\fP, const void * \fIval\fP, ares_socklen_t \fIval_size\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B int (*\fIasetsockopt\fP)(ares_socket_t \fIfd\fP, ares_socket_opt_t \fIopt\fP, const void * \fIval\fP, ares_socklen_t \fIval_size\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIREQUIRED\fP. Set socket option. This shares a similar syntax to the BSD \fIsetsockopt(2)\fP |
|
|
|
|
call, however c-ares uses different options for portability. The value is |
|
|
|
|
a pointer to the desired value, and each option has its own data type listed |
|
|
|
|
in the options below defined in \fIares_socket_opt_t\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIaconnect\fP |
|
|
|
|
.B int(*)(ares_socket_t \fIfd\fP, const struct sockaddr * \fIaddr\fP, ares_socklen_t \fIaddr_len\fP, unsigned int \fIflags\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B int (*\fIaconnect\fP)(ares_socket_t \fIfd\fP, const struct sockaddr * \fIaddr\fP, ares_socklen_t \fIaddr_len\fP, unsigned int \fIflags\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIREQUIRED\fP. Initiate a connection to the address indicated by \fIaddr\fP on |
|
|
|
|
a socket. Additional flags controlling behavior are in |
|
|
|
|
\fIares_socket_connect_flags_t\fP. See \fBconnect(2)\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIarecvfrom\fP |
|
|
|
|
.B ares_ssize_t(*)(ares_socket_t \fIfd\fP, void * \fIbuffer\fP, size_t \fIbuf_size\fP, int \fIflags\fP, struct sockaddr * \fIaddr\fP, ares_socklen_t * \fIaddr_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B ares_ssize_t (*\fIarecvfrom\fP)(ares_socket_t \fIfd\fP, void * \fIbuffer\fP, size_t \fIbuf_size\fP, int \fIflags\fP, struct sockaddr * \fIaddr\fP, ares_socklen_t * \fIaddr_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIREQUIRED\fP. Receives data from remote socket endpoint, if available. If the |
|
|
|
|
\fIaddr\fP parameter is not NULL and the connection protocol provides the source |
|
|
|
|
address, the callback should fill this in. The \fIflags\fP parameter is |
|
|
|
|
currently unused. See \fBrecvfrom(2)\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIasendto\fP |
|
|
|
|
.B ares_ssize_t(*)(ares_socket_t \fIfd\fP, const void * \fIbuffer\fP, size_t \fIlength\fP, int \fIflags\fP, const struct sockaddr * \fIaddress\fP, ares_socklen_t \fIaddress_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B ares_ssize_t (*\fIasendto\fP)(ares_socket_t \fIfd\fP, const void * \fIbuffer\fP, size_t \fIlength\fP, int \fIflags\fP, const struct sockaddr * \fIaddress\fP, ares_socklen_t \fIaddress_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIREQUIRED\fP. Send data, as provided by the \fIbuffer\fP, to the socket |
|
|
|
|
endpoint. The \fIflags\fP member may be used on systems that have |
|
|
|
@ -170,19 +158,15 @@ endpoint. The \fIflags\fP member may be used on systems that have |
|
|
|
|
provided primarily to support TCP FastOpen scenarios, which will be NULL in |
|
|
|
|
other circumstances. See \fBsendto(2)\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIagetsockname\fP |
|
|
|
|
.B int(*)(ares_socket_t \fIfd\fP, struct sockaddr * \fIaddress\fP, ares_socklen_t * \fIaddress_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B int (*\fIagetsockname\fP)(ares_socket_t \fIfd\fP, struct sockaddr * \fIaddress\fP, ares_socklen_t * \fIaddress_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIOptional\fP. Retrieve the local address of a socket and store it into the provided |
|
|
|
|
\fIaddress\fP buffer. May impact DNS Cookies if not provided. See |
|
|
|
|
\fBgetsockname(2)\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIabind\fP |
|
|
|
|
.B int(*)(ares_socket_t \fIfd\fP, unsigned int \fIflags\fP, const struct sockaddr * \fIaddress\fP, ares_socklen_t \fIaddress_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B int (*\fIabind\fP)(ares_socket_t \fIfd\fP, unsigned int \fIflags\fP, const struct sockaddr * \fIaddress\fP, ares_socklen_t \fIaddress_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIOptional\fP. Bind the socket to an address. This can be used for client |
|
|
|
|
connections to bind the source address for packets before connect, or |
|
|
|
@ -190,19 +174,15 @@ for server connections to bind to an address and port before listening. |
|
|
|
|
Currently c-ares only supports client connections. \fIflags\fP from |
|
|
|
|
\fIares_socket_bind_flags_t\fP can be specified. See \fBbind(2)\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIaif_nametoindex\fP |
|
|
|
|
.B unsigned int(*)(const char * \fIifname\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B unsigned int (*\fIaif_nametoindex\fP)(const char * \fIifname\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIOptional\fP. Convert an interface name into the interface index. If this |
|
|
|
|
callback is not specified, then IPv6 Link-Local DNS servers cannot be used. |
|
|
|
|
See \fBif_nametoindex(2)\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIaif_indextoname\fP |
|
|
|
|
.B const char *(*)(unsigned int \fIifindex\fP, char * \fIifname_buf\fP, size_t \fIifname_buf_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B const char * (*\fIaif_indextoname\fP)(unsigned int \fIifindex\fP, char * \fIifname_buf\fP, size_t \fIifname_buf_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
\fIOptional\fP. Convert an interface index into the interface name. If this |
|
|
|
|
callback is not specified, then IPv6 Link-Local DNS servers cannot be used. |
|
|
|
@ -214,7 +194,7 @@ See \fBif_indextoname(2)\fP. |
|
|
|
|
\fBares_sockfunc_flags_t\fP values: |
|
|
|
|
|
|
|
|
|
.RS 4 |
|
|
|
|
.TP 31 |
|
|
|
|
.TP 8 |
|
|
|
|
.B \fIARES_SOCKFUNC_FLAG_NONBLOCKING\fP |
|
|
|
|
.br |
|
|
|
|
Used to indicate the implementation of the io functions are asynchronous. |
|
|
|
@ -224,23 +204,23 @@ Used to indicate the implementation of the io functions are asynchronous. |
|
|
|
|
\fBares_socket_opt_t\fP values: |
|
|
|
|
|
|
|
|
|
.RS 4 |
|
|
|
|
.TP 31 |
|
|
|
|
.TP 8 |
|
|
|
|
.B \fIARES_SOCKET_OPT_SENDBUF_SIZE\fP |
|
|
|
|
.br |
|
|
|
|
Set the Send Buffer size. Value is a pointer to an int. (SO_SNDBUF). |
|
|
|
|
|
|
|
|
|
.TP 31 |
|
|
|
|
.TP 8 |
|
|
|
|
.B \fIARES_SOCKET_OPT_RECVBUF_SIZE\fP |
|
|
|
|
.br |
|
|
|
|
Set the Receive Buffer size. Value is a pointer to an int. (SO_RCVBUF). |
|
|
|
|
|
|
|
|
|
.TP 31 |
|
|
|
|
.TP 8 |
|
|
|
|
.B \fIARES_SOCKET_OPT_BIND_DEVICE\fP |
|
|
|
|
.br |
|
|
|
|
Set the network interface to use as the source for communication. Value is a C |
|
|
|
|
string. (SO_BINDTODEVICE) |
|
|
|
|
|
|
|
|
|
.TP 31 |
|
|
|
|
.TP 8 |
|
|
|
|
.B \fIARES_SOCKET_OPT_TCP_FASTOPEN\fP |
|
|
|
|
.br |
|
|
|
|
Enable TCP Fast Open. Value is a pointer to an \fIares_bool_t\fP. On some |
|
|
|
@ -253,20 +233,22 @@ not support the feature and returns failure with errno set to \fBENOSYS\fP or |
|
|
|
|
.PP |
|
|
|
|
\fBares_socket_connect_flags_t\fP values: |
|
|
|
|
.RS 4 |
|
|
|
|
.TP 31 |
|
|
|
|
.TP 8 |
|
|
|
|
.B \fIARES_SOCKET_CONN_TCP_FASTOPEN\fP |
|
|
|
|
.br |
|
|
|
|
Connect using TCP Fast Open. |
|
|
|
|
.RE |
|
|
|
|
|
|
|
|
|
.PP |
|
|
|
|
\fBares_socket_bind_flags_t\fP values: |
|
|
|
|
|
|
|
|
|
.TP 31 |
|
|
|
|
.RS 4 |
|
|
|
|
.TP 8 |
|
|
|
|
.B \fIARES_SOCKET_BIND_TCP\fP |
|
|
|
|
.br |
|
|
|
|
Bind is for a TCP connection. |
|
|
|
|
|
|
|
|
|
.TP 31 |
|
|
|
|
.TP 19 |
|
|
|
|
.B \fIARES_SOCKET_BIND_CLIENT\fP |
|
|
|
|
.br |
|
|
|
|
Bind is for a client connection, not server. |
|
|
|
@ -298,43 +280,34 @@ The \fBares_socket_functions(3)\fP must provide the following callbacks (which |
|
|
|
|
are different from the \fBares_socket_functions_ex(3)\fP callbacks): |
|
|
|
|
|
|
|
|
|
.RS 4 |
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIasocket\fP |
|
|
|
|
.B ares_socket_t(*)(int \fIdomain\fP, int \fItype\fP, int \fIprotocol\fP, void * \fIuser_data\fP) |
|
|
|
|
.TP 8 |
|
|
|
|
.B ares_socket_t (* \fIasocket\fP)(int \fIdomain\fP, int \fItype\fP, int \fIprotocol\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.br |
|
|
|
|
Creates an endpoint for communication and returns a descriptor. \fIdomain\fP, \fItype\fP, and \fIprotocol\fP |
|
|
|
|
each correspond to the parameters of \fBsocket(2)\fP. Returns ahandle to the |
|
|
|
|
newly created socket, or -1 on error. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIaclose\fP |
|
|
|
|
.B int(*)(ares_socket_t \fIfd\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B int (*\fIaclose\fP)(ares_socket_t \fIfd\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
Closes the socket endpoint indicated by \fIfd\fP. See \fBclose(2)\fP. |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIaconnect\fP |
|
|
|
|
.B int(*)(ares_socket_t \fIfd\fP, const struct sockaddr * \fIaddr\fP, ares_socklen_t \fIaddr_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B int (*\fIaconnect\fP)(ares_socket_t \fIfd\fP, const struct sockaddr * \fIaddr\fP, ares_socklen_t \fIaddr_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
Initiate a connection to the address indicated by \fIaddr\fP on a socket. See |
|
|
|
|
\fBconnect(2)\fP |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIarecvfrom\fP |
|
|
|
|
.B ares_ssize_t(*)(ares_socket_t \fIfd\fP, void * \fIbuffer\fP, size_t \fIbuf_size\fP, int \fIflags\fP, struct sockaddr * \fIaddr\fP, ares_socklen_t * \fIaddr_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B ares_ssize_t (*\fIarecvfrom\fP)(ares_socket_t \fIfd\fP, void * \fIbuffer\fP, size_t \fIbuf_size\fP, int \fIflags\fP, struct sockaddr * \fIaddr\fP, ares_socklen_t * \fIaddr_len\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
Receives data from remote socket endpoint, if available. If the \fIaddr\fP |
|
|
|
|
parameter is not NULL and the connection protocol provides the source address, |
|
|
|
|
the callback should fill this in. See \fBrecvfrom(2)\fP |
|
|
|
|
|
|
|
|
|
.TP 18 |
|
|
|
|
.B \fIasendv\fP |
|
|
|
|
.B ares_ssize_t(*)(ares_socket_t \fIfd\fP, const struct iovec * \fIdata\fP, int \fIlen\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
.TP 8 |
|
|
|
|
.B ares_ssize_t (*\fIasendv\fP)(ares_socket_t \fIfd\fP, const struct iovec * \fIdata\fP, int \fIlen\fP, void * \fIuser_data\fP) |
|
|
|
|
.br |
|
|
|
|
Send data, as provided by the iovec array \fIdata\fP, to the socket endpoint. |
|
|
|
|
See \fBwritev(2)\fP |
|
|
|
|