mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
turn isc_socket_dup into a method
This commit is contained in:
parent
16f3aeab3c
commit
ea30861fe5
3 changed files with 22 additions and 7 deletions
|
|
@ -15,7 +15,7 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: socket.h,v 1.95 2011/07/28 04:04:37 each Exp $ */
|
||||
/* $Id: socket.h,v 1.96 2011/07/28 11:42:41 marka Exp $ */
|
||||
|
||||
#ifndef ISC_SOCKET_H
|
||||
#define ISC_SOCKET_H 1
|
||||
|
|
@ -296,6 +296,8 @@ typedef struct isc_socketmethods {
|
|||
isc_sockettype_t (*gettype)(isc_socket_t *sock);
|
||||
void (*ipv6only)(isc_socket_t *sock, isc_boolean_t yes);
|
||||
isc_result_t (*fdwatchpoke)(isc_socket_t *sock, int flags);
|
||||
isc_result_t (*dup)(isc_socket_t *socket,
|
||||
isc_socket_t **socketp);
|
||||
} isc_socketmethods_t;
|
||||
|
||||
/*%
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: socket_api.c,v 1.5 2009/10/01 01:30:01 sar Exp $ */
|
||||
/* $Id: socket_api.c,v 1.6 2011/07/28 11:42:41 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -214,3 +214,11 @@ isc_socket_fdwatchpoke(isc_socket_t *sock, int flags)
|
|||
|
||||
return(sock->methods->fdwatchpoke(sock, flags));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_dup(isc_socket_t *sock, isc_socket_t **socketp) {
|
||||
REQUIRE(ISCAPI_SOCKET_VALID(sock));
|
||||
REQUIRE(socketp != NULL && *socketp == NULL);
|
||||
|
||||
return(sock->methods->dup(sock, socketp));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: socket.c,v 1.342 2011/07/28 04:27:26 marka Exp $ */
|
||||
/* $Id: socket.c,v 1.343 2011/07/28 11:42:41 marka Exp $ */
|
||||
|
||||
/*! \file */
|
||||
|
||||
|
|
@ -551,6 +551,8 @@ isc__socket_fdwatchcreate(isc_socketmgr_t *manager, int fd, int flags,
|
|||
isc_task_t *task, isc_socket_t **socketp);
|
||||
ISC_SOCKETFUNC_SCOPE isc_result_t
|
||||
isc__socket_fdwatchpoke(isc_socket_t *sock, int flags);
|
||||
ISC_SOCKETFUNC_SCOPE isc_result_t
|
||||
isc__socket_dup(isc_socket_t *sock, isc_socket_t **socketp);
|
||||
|
||||
static struct {
|
||||
isc_socketmethods_t methods;
|
||||
|
|
@ -574,7 +576,8 @@ static struct {
|
|||
isc__socket_getsockname,
|
||||
isc__socket_gettype,
|
||||
isc__socket_ipv6only,
|
||||
isc__socket_fdwatchpoke
|
||||
isc__socket_fdwatchpoke,
|
||||
isc__socket_dup
|
||||
}
|
||||
#ifndef BIND9
|
||||
,
|
||||
|
|
@ -769,6 +772,7 @@ FIX_IPV6_RECVPKTINFO(isc__socket_t *sock)
|
|||
if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO,
|
||||
(void *)&on, sizeof(on)) < 0) {
|
||||
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_RECVPKTINFO) "
|
||||
"%s: %s", sock->fd,
|
||||
|
|
@ -2474,8 +2478,9 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
|
|||
*/
|
||||
if (sock->pf == AF_INET6) {
|
||||
int action = IPV6_PMTUDISC_DONT;
|
||||
(void)setsockopt(sock->fd, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
|
||||
&action, sizeof(action));
|
||||
(void)setsockopt(sock->fd, IPPROTO_IPV6,
|
||||
IPV6_MTU_DISCOVER, &action,
|
||||
sizeof(action));
|
||||
}
|
||||
#endif
|
||||
#endif /* ISC_PLATFORM_HAVEIPV6 */
|
||||
|
|
@ -5714,7 +5719,7 @@ isc__socket_ipv6only(isc_socket_t *sock0, isc_boolean_t yes) {
|
|||
if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(void *)&onoff, sizeof(int)) < 0) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d, IPV6_V6ONLY) "
|
||||
"%s: %s", sock->fd,
|
||||
|
|
|
|||
Loading…
Reference in a new issue