Commit 1ece2b41 authored by Bob Halley's avatar Bob Halley
Browse files

add isc_sockaddr_from{in,in6}

parent 9c43547b
......@@ -19,6 +19,7 @@
#define ISC_SOCKADDR_H 1
#include <isc/net.h>
#include <isc/list.h>
#include <isc/lang.h>
ISC_LANG_BEGINDECLS
......@@ -30,6 +31,7 @@ typedef struct isc_sockaddr {
struct sockaddr_in6 sin6;
} type;
unsigned int length; /* XXXRTH beginning? */
ISC_LINK(struct isc_sockaddr) link;
} isc_sockaddr_t;
isc_boolean_t
......@@ -38,6 +40,14 @@ isc_sockaddr_equal(isc_sockaddr_t *a, isc_sockaddr_t *b);
unsigned int
isc_sockaddr_hash(isc_sockaddr_t *sockaddr, isc_boolean_t address_only);
void
isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, struct in_addr *ina,
unsigned int port);
void
isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, struct in6_addr *ina6,
unsigned int port);
ISC_LANG_ENDDECLS
#endif /* ISC_SOCKADDR_H */
......@@ -110,3 +110,31 @@ isc_sockaddr_hash(isc_sockaddr_t *sockaddr, isc_boolean_t address_only) {
return (h);
}
void
isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, struct in_addr *ina,
unsigned int port)
{
sockaddr->type.sin.sin_family = AF_INET;
#ifdef ISC_NET_HAVESALEN
sockaddr->type.sin.sin_len = sizeof sockaddr->type.sin;
#endif
sockaddr->type.sin.sin_addr = *ina;
sockaddr->type.sin.sin_port = htons(port);
sockaddr->length = sizeof sockaddr->type.sin;
ISC_LINK_INIT(sockaddr, link);
}
void
isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, struct in6_addr *ina6,
unsigned int port)
{
sockaddr->type.sin6.sin6_family = AF_INET6;
#ifdef ISC_NET_HAVESALEN
sockaddr->type.sin6.sin6_len = sizeof sockaddr->type.sin6;
#endif
sockaddr->type.sin6.sin6_addr = *ina6;
sockaddr->type.sin6.sin6_port = htons(port);
sockaddr->length = sizeof sockaddr->type.sin6;
ISC_LINK_INIT(sockaddr, link);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment