mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
conform to revised socket api
This commit is contained in:
@@ -127,8 +127,7 @@ ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(iresult == ISC_R_SUCCESS);
|
||||
iresult = isc_socket_bind(ifp->udpsocket, &ifp->addr,
|
||||
sizeof(ifp->addr));
|
||||
iresult = isc_socket_bind(ifp->udpsocket, &ifp->addr);
|
||||
if (iresult != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"binding udp socket: %s",
|
||||
@@ -157,8 +156,7 @@ ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
|
||||
goto tcp_socket_failure;
|
||||
}
|
||||
|
||||
iresult = isc_socket_bind(ifp->tcpsocket, &ifp->addr,
|
||||
sizeof(ifp->addr));
|
||||
iresult = isc_socket_bind(ifp->tcpsocket, &ifp->addr);
|
||||
if (iresult != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"binding tcpp socket: %s",
|
||||
@@ -217,20 +215,6 @@ ns_interface_destroy(ns_interface_t **ifpret) {
|
||||
return (DNS_R_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine whether two socket addresses of type isc_sockaddr_t have
|
||||
* the same address and port.
|
||||
*/
|
||||
|
||||
static isc_boolean_t
|
||||
sockaddr_same(isc_sockaddr_t *a, isc_sockaddr_t *b) {
|
||||
INSIST(a->type.sin.sin_family == AF_INET); /* XXX IPv6 */
|
||||
INSIST(b->type.sin.sin_family == AF_INET); /* XXX IPv6 */
|
||||
return ((a->type.sin.sin_addr.s_addr == b->type.sin.sin_addr.s_addr &&
|
||||
a->type.sin.sin_port == b->type.sin.sin_port) ?
|
||||
ISC_TRUE : ISC_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Search the interface list for an interface whose address and port
|
||||
* both match those of 'addr'. Return a pointer to it, or NULL if not found.
|
||||
@@ -240,7 +224,7 @@ find_matching_interface(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr) {
|
||||
ns_interface_t *ifp;
|
||||
for (ifp = ISC_LIST_HEAD(mgr->interfaces); ifp != NULL;
|
||||
ifp = ISC_LIST_NEXT(ifp, link)) {
|
||||
if (sockaddr_same(&ifp->addr, addr))
|
||||
if (isc_sockaddr_equal(&ifp->addr, addr))
|
||||
break;
|
||||
}
|
||||
return (ifp);
|
||||
@@ -291,6 +275,7 @@ ns_interfacemgr_scan(ns_interfacemgr_t *mgr) {
|
||||
listen_addr.type.sin.sin_family = AF_INET;
|
||||
listen_addr.type.sin.sin_addr = interface.address.type.in;
|
||||
listen_addr.type.sin.sin_port = htons(listen_port);
|
||||
listen_addr.length = sizeof listen_addr.type.sin;
|
||||
|
||||
ifp = find_matching_interface(mgr, &listen_addr);
|
||||
if (ifp) {
|
||||
|
@@ -174,7 +174,7 @@ udp_recv(isc_task_t *task, isc_event_t *event)
|
||||
if (result == DNS_R_SUCCESS) {
|
||||
/* Send a reply as soon as the socket is ready to do so. */
|
||||
isc_socket_sendto(sock, ®ion, task, udp_send, ctx,
|
||||
&dev->address, dev->addrlength);
|
||||
&dev->address);
|
||||
} else {
|
||||
/* Send no reply, just wait for the next request. */
|
||||
isc_socket_recv(sock, ®ion, ISC_FALSE, task, udp_recv, ctx);
|
||||
|
@@ -265,11 +265,10 @@ main(int argc, char *argv[])
|
||||
isc_socketmgr_t *socketmgr;
|
||||
isc_socket_t *so1, *so2;
|
||||
isc_sockaddr_t sockaddr;
|
||||
unsigned int addrlen;
|
||||
|
||||
memset(&sockaddr, 0, sizeof(sockaddr));
|
||||
sockaddr.type.sin.sin_port = htons(5544);
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
sockaddr.length = sizeof (struct sockaddr_in);
|
||||
|
||||
if (argc > 1)
|
||||
workers = atoi(argv[1]);
|
||||
@@ -318,11 +317,10 @@ main(int argc, char *argv[])
|
||||
memset(&sockaddr, 0, sizeof(sockaddr));
|
||||
sockaddr.type.sin.sin_family = AF_INET;
|
||||
sockaddr.type.sin.sin_port = htons(5544);
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
sockaddr.length = sizeof (struct sockaddr_in);
|
||||
RUNTIME_CHECK(isc_socket_create(socketmgr, isc_socket_tcp, &so1) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_socket_bind(so1, &sockaddr,
|
||||
(int)addrlen) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_socket_bind(so1, &sockaddr) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_socket_listen(so1, 0) == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
@@ -346,10 +344,10 @@ main(int argc, char *argv[])
|
||||
sockaddr.type.sin.sin_port = htons(80);
|
||||
sockaddr.type.sin.sin_family = AF_INET;
|
||||
sockaddr.type.sin.sin_addr.s_addr = inet_addr("204.152.186.34");
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
sockaddr.length = sizeof (struct sockaddr_in);
|
||||
RUNTIME_CHECK(isc_socket_create(socketmgr, isc_socket_tcp,
|
||||
&so2) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_socket_connect(so2, &sockaddr, (int)addrlen, t2,
|
||||
RUNTIME_CHECK(isc_socket_connect(so2, &sockaddr, t2,
|
||||
my_connect, "so2") == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user