dns64.c revision 6fb9b25791778f69002eb72be6235e20d98ec452
/*
* Copyright (C) 2010, 2011, 2014, 2016, 2017 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 http://mozilla.org/MPL/2.0/.
*/
/* $Id: dns64.c,v 1.8 2011/03/12 04:59:47 tbox Exp $ */
#include <config.h>
#include <dns/rdataset.h>
struct dns_dns64 {
* Prefix + suffix bits.
*/
* Which clients get mapped
* addresses.
*/
* IPv4 addresses to be mapped.
*/
* IPv6 addresses that are
* treated as not existing.
*/
unsigned int prefixlen; /*
* Start of mapped address.
*/
unsigned int flags;
};
{
unsigned int nbytes = 16;
/* Legal prefix lengths from rfc6052.txt. */
static const unsigned char zeros[16];
/* Bits 64-71 are zeros. rfc6052.txt */
nbytes++;
}
return (ISC_R_NOMEMORY);
16 - nbytes);
return (ISC_R_SUCCESS);
}
void
}
{
unsigned int nbytes, i;
int match;
(flags & DNS_DNS64_RECURSIVE) == 0)
return (DNS_R_DISALLOWED);
(flags & DNS_DNS64_DNSSEC) != 0)
return (DNS_R_DISALLOWED);
if (result != ISC_R_SUCCESS)
return (result);
if (match <= 0)
return (DNS_R_DISALLOWED);
}
if (result != ISC_R_SUCCESS)
return (result);
if (match <= 0)
return (DNS_R_DISALLOWED);
}
/* Copy prefix. */
/* Bits 64-71 are zeros. rfc6052.txt */
if (nbytes == 8)
/* Copy mapped address. */
for (i = 0; i < 4U; i++) {
/* Bits 64-71 are zeros. rfc6052.txt */
if (nbytes == 8)
}
/* Copy suffix. */
return (ISC_R_SUCCESS);
}
return (dns64);
}
void
}
void
}
{
int match;
unsigned int i, ok;
(flags & DNS_DNS64_RECURSIVE) == 0)
continue;
(flags & DNS_DNS64_DNSSEC) != 0)
continue;
/*
* Work out if this dns64 structure applies to this client.
*/
if (result != ISC_R_SUCCESS)
continue;
if (match <= 0)
continue;
}
for (i = 0; i < aaaaoklen; i++)
}
/*
* If we are not excluding any addresses then any AAAA
* will do.
*/
goto done;
for (i = 0; i < aaaaoklen; i++)
goto done;
}
i = 0; ok = 0;
result == ISC_R_SUCCESS;
goto done;
ok++;
}
} else
ok++;
i++;
}
/*
* Are all addresses ok?
*/
goto done;
}
done:
for (i = 0; i < aaaaoklen; i++)
}
}