2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-23 10:39:16 +00:00
bind/lib/isc/sockaddr.c

514 lines
13 KiB
C
Raw Normal View History

1999-06-25 22:09:35 +00:00
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
1999-06-25 22:09:35 +00:00
*/
/*! \file */
2000-06-22 22:00:42 +00:00
#include <stdbool.h>
1999-09-02 12:07:00 +00:00
#include <stdio.h>
#if defined(WIN32) || defined(WIN64)
#include <malloc.h>
#endif /* if defined(WIN32) || defined(WIN64) */
1999-06-25 22:09:35 +00:00
#include <isc/buffer.h>
#include <isc/hash.h>
#include <isc/netaddr.h>
#include <isc/print.h>
#include <isc/region.h>
#include <isc/sockaddr.h>
#include <isc/string.h>
2000-04-28 01:12:23 +00:00
#include <isc/util.h>
1999-06-25 22:09:35 +00:00
bool
2020-02-13 14:44:37 -08:00
isc_sockaddr_equal(const isc_sockaddr_t *a, const isc_sockaddr_t *b) {
return (isc_sockaddr_compare(a, b,
ISC_SOCKADDR_CMPADDR |
ISC_SOCKADDR_CMPPORT |
ISC_SOCKADDR_CMPSCOPE));
}
bool
2020-02-13 14:44:37 -08:00
isc_sockaddr_eqaddr(const isc_sockaddr_t *a, const isc_sockaddr_t *b) {
return (isc_sockaddr_compare(
a, b, ISC_SOCKADDR_CMPADDR | ISC_SOCKADDR_CMPSCOPE));
}
bool
isc_sockaddr_compare(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
2020-02-13 14:44:37 -08:00
unsigned int flags) {
1999-07-08 00:04:44 +00:00
REQUIRE(a != NULL && b != NULL);
1999-06-25 22:09:35 +00:00
if (a->length != b->length) {
return (false);
}
1999-06-25 22:09:35 +00:00
/*
* We don't just memcmp because the sin_zero field isn't always
* zero.
*/
if (a->type.sa.sa_family != b->type.sa.sa_family) {
return (false);
}
switch (a->type.sa.sa_family) {
case AF_INET:
if ((flags & ISC_SOCKADDR_CMPADDR) != 0 &&
memcmp(&a->type.sin.sin_addr, &b->type.sin.sin_addr,
2020-02-13 14:44:37 -08:00
sizeof(a->type.sin.sin_addr)) != 0)
{
return (false);
}
if ((flags & ISC_SOCKADDR_CMPPORT) != 0 &&
2020-02-13 14:44:37 -08:00
a->type.sin.sin_port != b->type.sin.sin_port)
{
return (false);
}
break;
case AF_INET6:
if ((flags & ISC_SOCKADDR_CMPADDR) != 0 &&
memcmp(&a->type.sin6.sin6_addr, &b->type.sin6.sin6_addr,
2020-02-13 14:44:37 -08:00
sizeof(a->type.sin6.sin6_addr)) != 0)
{
return (false);
}
/*
* If ISC_SOCKADDR_CMPSCOPEZERO is set then don't return
* false if one of the scopes in zero.
*/
if ((flags & ISC_SOCKADDR_CMPSCOPE) != 0 &&
a->type.sin6.sin6_scope_id != b->type.sin6.sin6_scope_id &&
((flags & ISC_SOCKADDR_CMPSCOPEZERO) == 0 ||
(a->type.sin6.sin6_scope_id != 0 &&
2020-02-13 14:44:37 -08:00
b->type.sin6.sin6_scope_id != 0)))
{
return (false);
}
if ((flags & ISC_SOCKADDR_CMPPORT) != 0 &&
2020-02-13 14:44:37 -08:00
a->type.sin6.sin6_port != b->type.sin6.sin6_port)
{
return (false);
}
break;
default:
if (memcmp(&a->type, &b->type, a->length) != 0) {
return (false);
}
}
return (true);
}
bool
1999-11-29 20:00:19 +00:00
isc_sockaddr_eqaddrprefix(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
2020-02-13 14:44:37 -08:00
unsigned int prefixlen) {
isc_netaddr_t na, nb;
isc_netaddr_fromsockaddr(&na, a);
isc_netaddr_fromsockaddr(&nb, b);
return (isc_netaddr_eqprefix(&na, &nb, prefixlen));
1999-11-29 20:00:19 +00:00
}
isc_result_t
2020-02-13 14:44:37 -08:00
isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target) {
isc_result_t result;
isc_netaddr_t netaddr;
2020-02-13 14:44:37 -08:00
char pbuf[sizeof("65000")];
unsigned int plen;
isc_region_t avail;
1999-09-02 12:07:00 +00:00
REQUIRE(sockaddr != NULL);
/*
* Do the port first, giving us the opportunity to check for
* unsupported address families before calling
* isc_netaddr_fromsockaddr().
*/
switch (sockaddr->type.sa.sa_family) {
1999-09-02 12:07:00 +00:00
case AF_INET:
snprintf(pbuf, sizeof(pbuf), "%u",
ntohs(sockaddr->type.sin.sin_port));
1999-09-02 12:07:00 +00:00
break;
case AF_INET6:
snprintf(pbuf, sizeof(pbuf), "%u",
ntohs(sockaddr->type.sin6.sin6_port));
1999-09-02 12:07:00 +00:00
break;
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 16:46:53 +02:00
#ifndef _WIN32
case AF_UNIX:
2005-03-16 23:39:06 +00:00
plen = strlen(sockaddr->type.sunix.sun_path);
if (plen >= isc_buffer_availablelength(target)) {
return (ISC_R_NOSPACE);
}
isc_buffer_putmem(
target,
(const unsigned char *)sockaddr->type.sunix.sun_path,
plen);
/*
* Null terminate after used region.
*/
isc_buffer_availableregion(target, &avail);
INSIST(avail.length >= 1);
avail.base[0] = '\0';
return (ISC_R_SUCCESS);
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 16:46:53 +02:00
#endif /* ifndef _WIN32 */
1999-09-02 12:07:00 +00:00
default:
return (ISC_R_FAILURE);
1999-09-02 12:07:00 +00:00
}
plen = strlen(pbuf);
INSIST(plen < sizeof(pbuf));
isc_netaddr_fromsockaddr(&netaddr, sockaddr);
result = isc_netaddr_totext(&netaddr, target);
if (result != ISC_R_SUCCESS) {
return (result);
}
if (1 + plen + 1 > isc_buffer_availablelength(target)) {
return (ISC_R_NOSPACE);
}
isc_buffer_putmem(target, (const unsigned char *)"#", 1);
isc_buffer_putmem(target, (const unsigned char *)pbuf, plen);
/*
* Null terminate after used region.
*/
isc_buffer_availableregion(target, &avail);
INSIST(avail.length >= 1);
avail.base[0] = '\0';
return (ISC_R_SUCCESS);
1999-09-02 12:07:00 +00:00
}
void
2020-02-13 14:44:37 -08:00
isc_sockaddr_format(const isc_sockaddr_t *sa, char *array, unsigned int size) {
isc_result_t result;
isc_buffer_t buf;
if (size == 0U) {
2011-02-21 06:18:03 +00:00
return;
}
2011-02-21 06:18:03 +00:00
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
/*
* The message is the same as in netaddr.c.
*/
snprintf(array, size, "<unknown address, family %u>",
sa->type.sa.sa_family);
array[size - 1] = '\0';
}
}
1999-07-08 00:04:44 +00:00
unsigned int
2020-02-13 14:44:37 -08:00
isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, bool address_only) {
unsigned int length = 0;
const unsigned char *s = NULL;
unsigned int h = 0;
unsigned int p = 0;
const struct in6_addr *in6;
1999-07-08 00:04:44 +00:00
REQUIRE(sockaddr != NULL);
switch (sockaddr->type.sa.sa_family) {
case AF_INET:
s = (const unsigned char *)&sockaddr->type.sin.sin_addr;
p = ntohs(sockaddr->type.sin.sin_port);
length = sizeof(sockaddr->type.sin.sin_addr.s_addr);
break;
case AF_INET6:
in6 = &sockaddr->type.sin6.sin6_addr;
s = (const unsigned char *)in6;
if (IN6_IS_ADDR_V4MAPPED(in6)) {
s += 12;
length = sizeof(sockaddr->type.sin.sin_addr.s_addr);
} else {
2001-11-27 01:56:32 +00:00
length = sizeof(sockaddr->type.sin6.sin6_addr);
}
p = ntohs(sockaddr->type.sin6.sin6_port);
break;
default:
UNEXPECTED_ERROR(__FILE__, __LINE__,
2018-11-23 21:35:01 +01:00
"unknown address family: %d",
(int)sockaddr->type.sa.sa_family);
s = (const unsigned char *)&sockaddr->type;
1999-07-08 00:04:44 +00:00
length = sockaddr->length;
p = 0;
1999-06-25 22:09:35 +00:00
}
uint8_t buf[sizeof(struct sockaddr_storage) + sizeof(p)];
memmove(buf, s, length);
if (!address_only) {
memmove(buf + length, &p, sizeof(p));
h = isc_hash_function(buf, length + sizeof(p), true);
} else {
h = isc_hash_function(buf, length, true);
}
1999-07-08 00:04:44 +00:00
return (h);
1999-06-25 22:09:35 +00:00
}
1999-07-13 01:46:15 +00:00
void
2020-02-13 14:44:37 -08:00
isc_sockaddr_any(isc_sockaddr_t *sockaddr) {
2001-11-27 01:56:32 +00:00
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin.sin_family = AF_INET;
sockaddr->type.sin.sin_addr.s_addr = INADDR_ANY;
sockaddr->type.sin.sin_port = 0;
2001-11-27 01:56:32 +00:00
sockaddr->length = sizeof(sockaddr->type.sin);
ISC_LINK_INIT(sockaddr, link);
}
void
2020-02-13 14:44:37 -08:00
isc_sockaddr_any6(isc_sockaddr_t *sockaddr) {
2001-11-27 01:56:32 +00:00
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin6.sin6_family = AF_INET6;
sockaddr->type.sin6.sin6_addr = in6addr_any;
sockaddr->type.sin6.sin6_port = 0;
2001-11-27 01:56:32 +00:00
sockaddr->length = sizeof(sockaddr->type.sin6);
ISC_LINK_INIT(sockaddr, link);
}
1999-07-13 01:46:15 +00:00
void
1999-10-25 14:37:04 +00:00
isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
2020-02-13 14:44:37 -08:00
in_port_t port) {
2001-11-27 01:56:32 +00:00
memset(sockaddr, 0, sizeof(*sockaddr));
1999-07-13 01:46:15 +00:00
sockaddr->type.sin.sin_family = AF_INET;
sockaddr->type.sin.sin_addr = *ina;
sockaddr->type.sin.sin_port = htons(port);
2001-11-27 01:56:32 +00:00
sockaddr->length = sizeof(sockaddr->type.sin);
1999-07-13 01:46:15 +00:00
ISC_LINK_INIT(sockaddr, link);
}
2000-08-09 18:57:16 +00:00
void
2020-02-13 14:44:37 -08:00
isc_sockaddr_anyofpf(isc_sockaddr_t *sockaddr, int pf) {
switch (pf) {
case AF_INET:
isc_sockaddr_any(sockaddr);
break;
case AF_INET6:
isc_sockaddr_any6(sockaddr);
break;
default:
INSIST(0);
ISC_UNREACHABLE();
}
2000-08-09 18:57:16 +00:00
}
1999-07-13 01:46:15 +00:00
void
1999-10-25 14:37:04 +00:00
isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6,
2020-02-13 14:44:37 -08:00
in_port_t port) {
2001-11-27 01:56:32 +00:00
memset(sockaddr, 0, sizeof(*sockaddr));
1999-07-13 01:46:15 +00:00
sockaddr->type.sin6.sin6_family = AF_INET6;
sockaddr->type.sin6.sin6_addr = *ina6;
sockaddr->type.sin6.sin6_port = htons(port);
2001-11-27 01:56:32 +00:00
sockaddr->length = sizeof(sockaddr->type.sin6);
1999-07-13 01:46:15 +00:00
ISC_LINK_INIT(sockaddr, link);
}
void
1999-10-25 14:37:04 +00:00
isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
2020-02-13 14:44:37 -08:00
in_port_t port) {
2001-11-27 01:56:32 +00:00
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin6.sin6_family = AF_INET6;
sockaddr->type.sin6.sin6_addr.s6_addr[10] = 0xff;
sockaddr->type.sin6.sin6_addr.s6_addr[11] = 0xff;
memmove(&sockaddr->type.sin6.sin6_addr.s6_addr[12], ina, 4);
sockaddr->type.sin6.sin6_port = htons(port);
2001-11-27 01:56:32 +00:00
sockaddr->length = sizeof(sockaddr->type.sin6);
ISC_LINK_INIT(sockaddr, link);
}
int
2020-02-13 14:44:37 -08:00
isc_sockaddr_pf(const isc_sockaddr_t *sockaddr) {
/*
* Get the protocol family of 'sockaddr'.
*/
#if (AF_INET == PF_INET && AF_INET6 == PF_INET6)
/*
* Assume that PF_xxx == AF_xxx for all AF and PF.
*/
return (sockaddr->type.sa.sa_family);
#else /* if (AF_INET == PF_INET && AF_INET6 == PF_INET6) */
switch (sockaddr->type.sa.sa_family) {
case AF_INET:
return (PF_INET);
case AF_INET6:
return (PF_INET6);
default:
FATAL_ERROR(__FILE__, __LINE__, "unknown address family: %d",
(int)sockaddr->type.sa.sa_family);
}
#endif /* if (AF_INET == PF_INET && AF_INET6 == PF_INET6) */
}
2000-01-26 19:22:41 +00:00
void
isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na,
2020-02-13 14:44:37 -08:00
in_port_t port) {
2001-11-27 01:56:32 +00:00
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin.sin_family = na->family;
switch (na->family) {
case AF_INET:
2001-11-27 01:56:32 +00:00
sockaddr->length = sizeof(sockaddr->type.sin);
sockaddr->type.sin.sin_addr = na->type.in;
sockaddr->type.sin.sin_port = htons(port);
break;
case AF_INET6:
2001-11-27 01:56:32 +00:00
sockaddr->length = sizeof(sockaddr->type.sin6);
memmove(&sockaddr->type.sin6.sin6_addr, &na->type.in6, 16);
sockaddr->type.sin6.sin6_scope_id = isc_netaddr_getzone(na);
sockaddr->type.sin6.sin6_port = htons(port);
break;
2010-11-17 23:47:09 +00:00
default:
INSIST(0);
ISC_UNREACHABLE();
}
ISC_LINK_INIT(sockaddr, link);
}
2000-01-26 19:22:41 +00:00
void
2020-02-13 14:44:37 -08:00
isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port) {
2000-01-26 19:22:41 +00:00
switch (sockaddr->type.sa.sa_family) {
case AF_INET:
sockaddr->type.sin.sin_port = htons(port);
break;
case AF_INET6:
sockaddr->type.sin6.sin6_port = htons(port);
break;
default:
FATAL_ERROR(__FILE__, __LINE__, "unknown address family: %d",
(int)sockaddr->type.sa.sa_family);
2000-01-26 19:22:41 +00:00
}
}
2000-01-31 21:52:17 +00:00
in_port_t
2020-02-13 14:44:37 -08:00
isc_sockaddr_getport(const isc_sockaddr_t *sockaddr) {
2000-01-31 21:52:17 +00:00
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: %d",
(int)sockaddr->type.sa.sa_family);
2000-01-31 21:52:17 +00:00
}
return (port);
}
bool
2020-02-13 14:44:37 -08:00
isc_sockaddr_ismulticast(const isc_sockaddr_t *sockaddr) {
isc_netaddr_t netaddr;
if (sockaddr->type.sa.sa_family == AF_INET ||
2020-02-13 14:44:37 -08:00
sockaddr->type.sa.sa_family == AF_INET6)
{
isc_netaddr_fromsockaddr(&netaddr, sockaddr);
return (isc_netaddr_ismulticast(&netaddr));
}
return (false);
}
bool
2020-02-13 14:44:37 -08:00
isc_sockaddr_isexperimental(const isc_sockaddr_t *sockaddr) {
isc_netaddr_t netaddr;
if (sockaddr->type.sa.sa_family == AF_INET) {
isc_netaddr_fromsockaddr(&netaddr, sockaddr);
return (isc_netaddr_isexperimental(&netaddr));
}
return (false);
}
bool
2020-02-13 14:44:37 -08:00
isc_sockaddr_issitelocal(const isc_sockaddr_t *sockaddr) {
isc_netaddr_t netaddr;
if (sockaddr->type.sa.sa_family == AF_INET6) {
isc_netaddr_fromsockaddr(&netaddr, sockaddr);
return (isc_netaddr_issitelocal(&netaddr));
}
return (false);
}
bool
2020-02-13 14:44:37 -08:00
isc_sockaddr_islinklocal(const isc_sockaddr_t *sockaddr) {
isc_netaddr_t netaddr;
if (sockaddr->type.sa.sa_family == AF_INET6) {
isc_netaddr_fromsockaddr(&netaddr, sockaddr);
return (isc_netaddr_islinklocal(&netaddr));
}
return (false);
}
bool
2020-02-13 14:44:37 -08:00
isc_sockaddr_isnetzero(const isc_sockaddr_t *sockaddr) {
isc_netaddr_t netaddr;
if (sockaddr->type.sa.sa_family == AF_INET) {
isc_netaddr_fromsockaddr(&netaddr, sockaddr);
return (isc_netaddr_isnetzero(&netaddr));
}
return (false);
}
isc_result_t
2020-02-13 14:44:37 -08:00
isc_sockaddr_frompath(isc_sockaddr_t *sockaddr, const char *path) {
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 16:46:53 +02:00
#ifndef _WIN32
if (strlen(path) >= sizeof(sockaddr->type.sunix.sun_path)) {
return (ISC_R_NOSPACE);
}
memset(sockaddr, 0, sizeof(*sockaddr));
2005-03-16 23:39:06 +00:00
sockaddr->length = sizeof(sockaddr->type.sunix);
sockaddr->type.sunix.sun_family = AF_UNIX;
strlcpy(sockaddr->type.sunix.sun_path, path,
sizeof(sockaddr->type.sunix.sun_path));
return (ISC_R_SUCCESS);
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 16:46:53 +02:00
#else /* ifndef _WIN32 */
UNUSED(sockaddr);
UNUSED(path);
return (ISC_R_NOTIMPLEMENTED);
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 16:46:53 +02:00
#endif /* ifndef _WIN32 */
}
isc_result_t
2020-02-13 14:44:37 -08:00
isc_sockaddr_fromsockaddr(isc_sockaddr_t *isa, const struct sockaddr *sa) {
unsigned int length = 0;
switch (sa->sa_family) {
case AF_INET:
length = sizeof(isa->type.sin);
break;
case AF_INET6:
length = sizeof(isa->type.sin6);
break;
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 16:46:53 +02:00
#ifndef _WIN32
case AF_UNIX:
length = sizeof(isa->type.sunix);
break;
Complete rewrite the BIND 9 build system The rewrite of BIND 9 build system is a large work and cannot be reasonable split into separate merge requests. Addition of the automake has a positive effect on the readability and maintainability of the build system as it is more declarative, it allows conditional and we are able to drop all of the custom make code that BIND 9 developed over the years to overcome the deficiencies of autoconf + custom Makefile.in files. This squashed commit contains following changes: - conversion (or rather fresh rewrite) of all Makefile.in files to Makefile.am by using automake - the libtool is now properly integrated with automake (the way we used it was rather hackish as the only official way how to use libtool is via automake - the dynamic module loading was rewritten from a custom patchwork to libtool's libltdl (which includes the patchwork to support module loading on different systems internally) - conversion of the unit test executor from kyua to automake parallel driver - conversion of the system test executor from custom make/shell to automake parallel driver - The GSSAPI has been refactored, the custom SPNEGO on the basis that all major KRB5/GSSAPI (mit-krb5, heimdal and Windows) implementations support SPNEGO mechanism. - The various defunct tests from bin/tests have been removed: bin/tests/optional and bin/tests/pkcs11 - The text files generated from the MD files have been removed, the MarkDown has been designed to be readable by both humans and computers - The xsl header is now generated by a simple sed command instead of perl helper - The <irs/platform.h> header has been removed - cleanups of configure.ac script to make it more simpler, addition of multiple macros (there's still work to be done though) - the tarball can now be prepared with `make dist` - the system tests are partially able to run in oot build Here's a list of unfinished work that needs to be completed in subsequent merge requests: - `make distcheck` doesn't yet work (because of system tests oot run is not yet finished) - documentation is not yet built, there's a different merge request with docbook to sphinx-build rst conversion that needs to be rebased and adapted on top of the automake - msvc build is non functional yet and we need to decide whether we will just cross-compile bind9 using mingw-w64 or fix the msvc build - contributed dlz modules are not included neither in the autoconf nor automake
2018-08-07 16:46:53 +02:00
#endif /* ifndef _WIN32 */
default:
return (ISC_R_NOTIMPLEMENTED);
}
memset(isa, 0, sizeof(isc_sockaddr_t));
memcpy(isa, sa, length);
isa->length = length;
return (ISC_R_SUCCESS);
}