2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

added isc_sockaddr_getport

This commit is contained in:
David Lawrence
2000-01-31 21:52:17 +00:00
parent 7ce7f319b5
commit c5f33ba0f0
2 changed files with 24 additions and 0 deletions

View File

@@ -337,3 +337,21 @@ isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port) {
FATAL_ERROR(__FILE__, __LINE__, "unknown address family");
}
}
in_port_t
isc_sockaddr_getport(isc_sockaddr_t *sockaddr) {
in_port_t port = 0;
switch (sockaddr->type.sa.sa_family) {
case AF_INET:
port = ntohs(sockaddr->type.sin.sin_port);
break;
case AF_INET6:
port = ntohs(sockaddr->type.sin6.sin6_port);
break;
default:
FATAL_ERROR(__FILE__, __LINE__, "unknown address family");
}
return (port);
}