version 1.7.2.1, 2008/06/23 04:29:57 |
version 1.7.2.2, 2008/09/18 04:28:24 |
Line 56 __RCSID("$NetBSD$"); |
|
Line 56 __RCSID("$NetBSD$"); |
|
|
|
#include "env.h" |
#include "env.h" |
#include "extern.h" |
#include "extern.h" |
#include "af_inet.h" |
|
#include "af_inetany.h" |
#include "af_inetany.h" |
|
|
|
static void in_constructor(void) __attribute__((constructor)); |
|
static void in_status(prop_dictionary_t, prop_dictionary_t, bool); |
|
static void in_commit_address(prop_dictionary_t, prop_dictionary_t); |
static void in_alias(const char *, prop_dictionary_t, prop_dictionary_t, |
static void in_alias(const char *, prop_dictionary_t, prop_dictionary_t, |
struct in_aliasreq *); |
struct in_aliasreq *); |
static void in_preference(const char *, const struct sockaddr *); |
static void in_preference(const char *, const struct sockaddr *); |
|
|
|
static struct afswtch af = { |
|
.af_name = "inet", .af_af = AF_INET, .af_status = in_status, |
|
.af_addr_commit = in_commit_address |
|
}; |
|
|
static void |
static void |
in_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv, |
in_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv, |
struct in_aliasreq *creq) |
struct in_aliasreq *creq) |
{ |
{ |
struct ifreq ifr; |
struct ifreq ifr; |
int alias, s; |
bool alias; |
|
int s; |
unsigned short flags; |
unsigned short flags; |
struct in_aliasreq in_addreq; |
struct in_aliasreq in_addreq; |
|
|
if (lflag) |
if (lflag) |
return; |
return; |
|
|
alias = 1; |
alias = true; |
|
|
/* Get the non-alias address for this interface. */ |
/* Get the non-alias address for this interface. */ |
if ((s = getsock(AF_INET)) == -1) { |
if ((s = getsock(AF_INET)) == -1) { |
Line 92 in_alias(const char *ifname, prop_dictio |
|
Line 100 in_alias(const char *ifname, prop_dictio |
|
} |
} |
/* If creq and ifr are the same address, this is not an alias. */ |
/* If creq and ifr are the same address, this is not an alias. */ |
if (memcmp(&ifr.ifr_addr, &creq->ifra_addr, sizeof(ifr.ifr_addr)) == 0) |
if (memcmp(&ifr.ifr_addr, &creq->ifra_addr, sizeof(ifr.ifr_addr)) == 0) |
alias = 0; |
alias = false; |
in_addreq = *creq; |
in_addreq = *creq; |
if (ioctl(s, SIOCGIFALIAS, &in_addreq) == -1) { |
if (ioctl(s, SIOCGIFALIAS, &in_addreq) == -1) { |
if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) { |
if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) { |
Line 152 in_preference(const char *ifname, const |
|
Line 160 in_preference(const char *ifname, const |
|
printf(" preference %" PRId16, preference); |
printf(" preference %" PRId16, preference); |
} |
} |
|
|
void |
static void |
in_status(prop_dictionary_t env, prop_dictionary_t oenv, bool force) |
in_status(prop_dictionary_t env, prop_dictionary_t oenv, bool force) |
{ |
{ |
struct ifaddrs *ifap, *ifa; |
struct ifaddrs *ifap, *ifa; |
Line 198 in_status(prop_dictionary_t env, prop_di |
|
Line 206 in_status(prop_dictionary_t env, prop_di |
|
freeifaddrs(ifap); |
freeifaddrs(ifap); |
} |
} |
|
|
void |
static void |
in_commit_address(prop_dictionary_t env, prop_dictionary_t oenv) |
in_commit_address(prop_dictionary_t env, prop_dictionary_t oenv) |
{ |
{ |
struct ifreq in_ifr; |
struct ifreq in_ifr; |
Line 226 in_commit_address(prop_dictionary_t env, |
|
Line 234 in_commit_address(prop_dictionary_t env, |
|
memset(&in_ifra, 0, sizeof(in_ifra)); |
memset(&in_ifra, 0, sizeof(in_ifra)); |
commit_address(env, oenv, &inparam); |
commit_address(env, oenv, &inparam); |
} |
} |
|
|
|
static void |
|
in_constructor(void) |
|
{ |
|
register_family(&af); |
|
} |