sockaddr.c revision 33cc94f04cb44dc247f605a954e45e5adc699977
/*
* Copyright (C) 2004-2007, 2010 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* 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: sockaddr.c,v 1.73 2010/11/17 23:47:09 tbox Exp $ */
/*! \file */
#include <config.h>
#include <stdio.h>
#include <isc/sockaddr.h>
return (isc_sockaddr_compare(a, b, ISC_SOCKADDR_CMPADDR|
}
return (isc_sockaddr_compare(a, b, ISC_SOCKADDR_CMPADDR|
}
unsigned int flags)
{
return (ISC_FALSE);
/*
* We don't just memcmp because the sin_zero field isn't always
* zero.
*/
return (ISC_FALSE);
case AF_INET:
if ((flags & ISC_SOCKADDR_CMPADDR) != 0 &&
return (ISC_FALSE);
if ((flags & ISC_SOCKADDR_CMPPORT) != 0 &&
return (ISC_FALSE);
break;
case AF_INET6:
if ((flags & ISC_SOCKADDR_CMPADDR) != 0 &&
return (ISC_FALSE);
#ifdef ISC_PLATFORM_HAVESCOPEID
/*
* If ISC_SOCKADDR_CMPSCOPEZERO is set then don't return
* ISC_FALSE if one of the scopes in zero.
*/
if ((flags & ISC_SOCKADDR_CMPSCOPE) != 0 &&
((flags & ISC_SOCKADDR_CMPSCOPEZERO) == 0 ||
return (ISC_FALSE);
#endif
if ((flags & ISC_SOCKADDR_CMPPORT) != 0 &&
return (ISC_FALSE);
break;
default:
return (ISC_FALSE);
}
return (ISC_TRUE);
}
unsigned int prefixlen)
{
isc_netaddr_fromsockaddr(&na, a);
isc_netaddr_fromsockaddr(&nb, b);
}
char pbuf[sizeof("65000")];
unsigned int plen;
/*
* Do the port first, giving us the opportunity to check for
* unsupported address families before calling
* isc_netaddr_fromsockaddr().
*/
case AF_INET:
break;
case AF_INET6:
break;
#ifdef ISC_PLAFORM_HAVESYSUNH
case AF_UNIX:
return (ISC_R_NOSPACE);
/*
* Null terminate after used region.
*/
return (ISC_R_SUCCESS);
#endif
default:
return (ISC_R_FAILURE);
}
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_NOSPACE);
/*
* Null terminate after used region.
*/
return (ISC_R_SUCCESS);
}
void
if (result != ISC_R_SUCCESS) {
/*
* The message is the same as in netaddr.c.
*/
"<unknown address, family %u>"),
}
}
unsigned int
unsigned int length = 0;
const unsigned char *s = NULL;
unsigned int h = 0;
unsigned int g;
unsigned int p = 0;
case AF_INET:
break;
case AF_INET6:
if (IN6_IS_ADDR_V4MAPPED(in6)) {
s = (const unsigned char *)&in6[12];
} else {
s = (const unsigned char *)in6;
}
break;
default:
"unknown address family: %d"),
p = 0;
}
if (!address_only) {
g = isc_hash_calc((const unsigned char *)&p, sizeof(p),
ISC_TRUE);
h = h ^ g; /* XXX: we should concatenate h and p first */
}
return (h);
}
void
{
#ifdef ISC_PLATFORM_HAVESALEN
#endif
}
void
{
#ifdef ISC_PLATFORM_HAVESALEN
#endif
}
void
{
#ifdef ISC_PLATFORM_HAVESALEN
#endif
}
void
switch (pf) {
case AF_INET:
break;
case AF_INET6:
break;
default:
INSIST(0);
}
}
void
{
#ifdef ISC_PLATFORM_HAVESALEN
#endif
}
void
{
#ifdef ISC_PLATFORM_HAVESALEN
#endif
}
int
/*
* Get the protocol family of 'sockaddr'.
*/
/*
* Assume that PF_xxx == AF_xxx for all AF and PF.
*/
#else
case AF_INET:
return (PF_INET);
case AF_INET6:
return (PF_INET6);
default:
"unknown address family: %d"),
}
#endif
}
void
{
case AF_INET:
#ifdef ISC_PLATFORM_HAVESALEN
#endif
break;
case AF_INET6:
#ifdef ISC_PLATFORM_HAVESALEN
#endif
#ifdef ISC_PLATFORM_HAVESCOPEID
#endif
break;
default:
INSIST(0);
}
}
void
case AF_INET:
break;
case AF_INET6:
break;
default:
"unknown address family: %d"),
}
}
case AF_INET:
break;
case AF_INET6:
break;
default:
"unknown address family: %d"),
}
return (port);
}
return (isc_netaddr_ismulticast(&netaddr));
}
return (ISC_FALSE);
}
return (isc_netaddr_isexperimental(&netaddr));
}
return (ISC_FALSE);
}
return (isc_netaddr_issitelocal(&netaddr));
}
return (ISC_FALSE);
}
return (isc_netaddr_islinklocal(&netaddr));
}
return (ISC_FALSE);
}
#ifdef ISC_PLATFORM_HAVESYSUNH
return (ISC_R_NOSPACE);
#ifdef ISC_PLATFORM_HAVESALEN
#endif
return (ISC_R_SUCCESS);
#else
return (ISC_R_NOTIMPLEMENTED);
#endif
}