netaddr.c revision ed019cabc1cc75d4412010c331876e4ae5080a4d
/*
* Copyright (C) 1999, 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <isc/sockaddr.h>
return (ISC_FALSE);
switch (a->family) {
case AF_INET:
return (ISC_FALSE);
break;
case AF_INET6:
!= 0)
return (ISC_FALSE);
break;
default:
return (ISC_FALSE);
}
return (ISC_TRUE);
}
unsigned int prefixlen)
{
unsigned int ipabytes; /* Length of whole IP address in bytes */
unsigned int nbytes; /* Number of significant whole bytes */
unsigned int nbits; /* Number of significant leftover bits */
return (ISC_FALSE);
switch (a->family) {
case AF_INET:
ipabytes = 4;
break;
case AF_INET6:
ipabytes = 16;
break;
default:
ipabytes = 0; /* Ditto. */
return (ISC_FALSE);
}
/* Don't crash if we get a pattern like 10.0.0.1/9999999. */
if (nbytes > 0) {
return (ISC_FALSE);
}
if (nbits > 0) {
return (ISC_FALSE);
}
return (ISC_TRUE);
}
{
unsigned char *p;
switch (s->family) {
case AF_INET:
ipbytes = 4;
break;
case AF_INET6:
ipbytes = 16;
break;
default:
ipbytes = 0;
return (ISC_R_NOTIMPLEMENTED);
}
for (i = 0; i < ipbytes; i++) {
if (p[i] != 0xFF)
break;
}
nbytes = i;
if (i < ipbytes) {
unsigned int c = p[nbytes];
c <<= 1; nbits++;
}
if ((c & 0xFF) != 0)
return (ISC_R_MASKNONCONTIG);
i++;
}
for (; i < ipbytes; i++) {
if (p[i] != 0)
return (ISC_R_MASKNONCONTIG);
i++;
}
return (ISC_R_SUCCESS);
}
void
{
}
void
{
}
void
{
switch (family) {
case AF_INET:
break;
case AF_INET6:
break;
default:
INSIST(0);
}
}