dns64.c revision c1aef54e14bb92518b1c062ba8c0292a7cb949cb
/*
* Copyright (C) 2010, 2011 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $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 draft-ietf-behave-address-format-04. */
static const unsigned char zeros[16];
/* Bits 64-71 are zeros. draft-ietf-behave-address-format-04 */
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. draft-ietf-behave-address-format-04 */
if (nbytes == 8)
/* Copy mapped address. */
for (i = 0; i < 4U; i++) {
/* Bits 64-71 are zeros. draft-ietf-behave-address-format-04 */
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++)
}
}