netaddr.c revision dafcb997e390efa4423883dafd100c975c4095d6
/*
* Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2002 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 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: netaddr.c,v 1.27 2004/03/05 05:10:47 marka Exp $ */
#include <config.h>
#include <stdio.h>
#include <isc/sockaddr.h>
return (ISC_FALSE);
return (ISC_FALSE);
switch (a->family) {
case AF_INET:
return (ISC_FALSE);
break;
case AF_INET6:
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);
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);
}
char abuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")];
char zbuf[sizeof("%4294967295")];
unsigned int alen;
int zlen;
const char *r;
const void *type;
case AF_INET:
break;
case AF_INET6:
break;
default:
return (ISC_R_FAILURE);
}
if (r == NULL)
return (ISC_R_FAILURE);
zlen = 0;
if (zlen < 0)
return (ISC_R_FAILURE);
}
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
void
/*
* Null terminate.
*/
if (result == ISC_R_SUCCESS) {
isc_buffer_putuint8(&buf, 0);
else
}
if (result != ISC_R_SUCCESS) {
"<unknown address, family %u>"),
}
}
const 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
/* we currently only support AF_INET6. */
}
}
void
switch (family) {
case AF_INET:
t->zone = 0;
break;
case AF_INET6:
#ifdef ISC_PLATFORM_HAVESCOPEID
#else
t->zone = 0;
#endif
break;
default:
INSIST(0);
}
}
void
}
void
}
case AF_INET:
case AF_INET6:
default:
return (ISC_FALSE); /* XXXMLG ? */
}
}
case AF_INET:
default:
return (ISC_FALSE); /* XXXMLG ? */
}
}
case AF_INET:
return (ISC_FALSE);
case AF_INET6:
default:
return (ISC_FALSE);
}
}
case AF_INET:
return (ISC_FALSE);
case AF_INET6:
default:
return (ISC_FALSE);
}
}
void
memset(t, 0, sizeof(*t));
return;
}