mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
add ISC_R_NOTBOUND and ISC_R_NOTCONNECTED and return them where appropriate.
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
#define ISC_R_EXISTS 18
|
||||
#define ISC_R_NOSPACE 19 /* ran out of space */
|
||||
#define ISC_R_CANCELED 20
|
||||
/* AVAILABLE CODE 21 */
|
||||
#define ISC_R_NOTBOUND 21 /* socket is not bound */
|
||||
#define ISC_R_SHUTTINGDOWN 22 /* shutting down */
|
||||
#define ISC_R_NOTFOUND 23
|
||||
#define ISC_R_UNEXPECTEDEND 24 /* unexpected end of input */
|
||||
@@ -61,8 +61,9 @@
|
||||
#define ISC_R_MASKNONCONTIG 37
|
||||
#define ISC_R_FILENOTFOUND 38
|
||||
#define ISC_R_FILEEXISTS 39
|
||||
#define ISC_R_NOTCONNECTED 40 /* socket is not connected */
|
||||
|
||||
#define ISC_R_NRESULTS 40 /* Number of results */
|
||||
#define ISC_R_NRESULTS 41 /* Number of results */
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
|
@@ -57,7 +57,7 @@ static char *text[ISC_R_NRESULTS] = {
|
||||
"already exists", /* 18 */
|
||||
"ran out of space", /* 19 */
|
||||
"operation canceled", /* 20 */
|
||||
"<available code 21>", /* 21 */
|
||||
"socket is not bound", /* 21 */
|
||||
"shutting down", /* 22 */
|
||||
"not found", /* 23 */
|
||||
"unexpected end of input", /* 24 */
|
||||
@@ -75,7 +75,8 @@ static char *text[ISC_R_NRESULTS] = {
|
||||
"ignore", /* 36 */
|
||||
"address mask not contiguous", /* 37 */
|
||||
"file not found", /* 38 */
|
||||
"file already exists" /* 39 */
|
||||
"file already exists", /* 39 */
|
||||
"socket is not connected" /* 40 */
|
||||
};
|
||||
|
||||
#define ISC_RESULT_RESULTSET 2
|
||||
|
@@ -2887,38 +2887,55 @@ internal_connect(isc_task_t *me, isc_event_t *ev)
|
||||
isc_result_t
|
||||
isc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp)
|
||||
{
|
||||
isc_result_t ret;
|
||||
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
REQUIRE(addressp != NULL);
|
||||
|
||||
LOCK(&sock->lock);
|
||||
|
||||
*addressp = sock->address;
|
||||
if (sock->connected) {
|
||||
*addressp = sock->address;
|
||||
ret = ISC_R_SUCCESS;
|
||||
} else {
|
||||
ret = ISC_R_NOTCONNECTED;
|
||||
}
|
||||
|
||||
UNLOCK(&sock->lock);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp)
|
||||
{
|
||||
ISC_SOCKADDR_LEN_T len;
|
||||
isc_result_t ret;
|
||||
|
||||
REQUIRE(VALID_SOCKET(sock));
|
||||
REQUIRE(addressp != NULL);
|
||||
|
||||
LOCK(&sock->lock);
|
||||
|
||||
if (!sock->bound) {
|
||||
ret = ISC_R_NOTBOUND;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ISC_R_SUCCESS;
|
||||
|
||||
len = sizeof addressp->type;
|
||||
if (getsockname(sock->fd, &addressp->type.sa, (void *)&len) < 0) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"getsockname: %s", strerror(errno));
|
||||
UNLOCK(&sock->lock);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
ret = ISC_R_UNEXPECTED;
|
||||
goto out;
|
||||
}
|
||||
addressp->length = (unsigned int)len;
|
||||
|
||||
out:
|
||||
UNLOCK(&sock->lock);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user