use the new scopeid functions
This commit is contained in:
parent
35be7e66a7
commit
0dd81edd01
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: af_atalk.c,v 1.18 2011/08/14 12:15:15 christos Exp $ */
|
||||
/* $NetBSD: af_atalk.c,v 1.19 2013/10/19 00:35:30 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: af_atalk.c,v 1.18 2011/08/14 12:15:15 christos Exp $");
|
||||
__RCSID("$NetBSD: af_atalk.c,v 1.19 2013/10/19 00:35:30 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -183,9 +183,8 @@ static void
|
|||
sat_print1(const char *prefix, const struct sockaddr *sa)
|
||||
{
|
||||
char buf[40];
|
||||
int rc;
|
||||
|
||||
rc = getnameinfo(sa, sa->sa_len, buf, sizeof(buf), NULL, 0, 0);
|
||||
(void)getnameinfo(sa, sa->sa_len, buf, sizeof(buf), NULL, 0, 0);
|
||||
|
||||
printf("%s%s", prefix, buf);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: af_inet6.c,v 1.27 2010/12/13 17:35:08 pooka Exp $ */
|
||||
/* $NetBSD: af_inet6.c,v 1.28 2013/10/19 00:35:30 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: af_inet6.c,v 1.27 2010/12/13 17:35:08 pooka Exp $");
|
||||
__RCSID("$NetBSD: af_inet6.c,v 1.28 2013/10/19 00:35:30 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -71,7 +71,6 @@ static int setia6vltime_impl(prop_dictionary_t, struct in6_aliasreq *);
|
|||
|
||||
static int setia6lifetime(prop_dictionary_t, int64_t, time_t *, uint32_t *);
|
||||
|
||||
static void in6_delscopeid(struct sockaddr_in6 *sin6);
|
||||
static void in6_status(prop_dictionary_t, prop_dictionary_t, bool);
|
||||
|
||||
static struct usage_func usage;
|
||||
|
@ -257,18 +256,6 @@ setia6eui64_impl(prop_dictionary_t env, struct in6_aliasreq *ifra)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* KAME idiosyncrasy */
|
||||
static void
|
||||
in6_delscopeid(struct sockaddr_in6 *sin6)
|
||||
{
|
||||
if (!IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||
|
||||
sin6->sin6_scope_id == 0)
|
||||
return;
|
||||
|
||||
*(u_int16_t *)&sin6->sin6_addr.s6_addr[2] = htons(sin6->sin6_scope_id);
|
||||
sin6->sin6_scope_id = 0;
|
||||
}
|
||||
|
||||
/* XXX not really an alias */
|
||||
void
|
||||
in6_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv,
|
||||
|
@ -291,7 +278,7 @@ in6_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv,
|
|||
|
||||
sin6 = &creq->ifr_addr;
|
||||
|
||||
in6_fillscopeid(sin6);
|
||||
inet6_getscopeid(sin6, 1);
|
||||
scopeid = sin6->sin6_scope_id;
|
||||
if (getnameinfo((const struct sockaddr *)sin6, sin6->sin6_len,
|
||||
hbuf, sizeof(hbuf), NULL, 0, niflag))
|
||||
|
@ -311,7 +298,7 @@ in6_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv,
|
|||
ifr6.ifr_addr.sin6_len = sizeof(struct sockaddr_in6);
|
||||
}
|
||||
sin6 = &ifr6.ifr_addr;
|
||||
in6_fillscopeid(sin6);
|
||||
inet6_getscopeid(sin6, 1);
|
||||
hbuf[0] = '\0';
|
||||
if (getnameinfo((struct sockaddr *)sin6, sin6->sin6_len,
|
||||
hbuf, sizeof(hbuf), NULL, 0, niflag))
|
||||
|
@ -419,8 +406,8 @@ in6_pre_aifaddr(prop_dictionary_t env, const struct afparam *param)
|
|||
setia6vltime_impl(env, ifra);
|
||||
setia6pltime_impl(env, ifra);
|
||||
setia6flags_impl(env, ifra);
|
||||
in6_delscopeid(&ifra->ifra_addr);
|
||||
in6_delscopeid(&ifra->ifra_dstaddr);
|
||||
inet6_putscopeid(&ifra->ifra_addr, 1);
|
||||
inet6_putscopeid(&ifra->ifra_dstaddr, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ifconfig.c,v 1.230 2013/07/17 15:40:42 christos Exp $ */
|
||||
/* $NetBSD: ifconfig.c,v 1.231 2013/10/19 00:35:30 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -63,7 +63,7 @@
|
|||
#ifndef lint
|
||||
__COPYRIGHT("@(#) Copyright (c) 1983, 1993\
|
||||
The Regents of the University of California. All rights reserved.");
|
||||
__RCSID("$NetBSD: ifconfig.c,v 1.230 2013/07/17 15:40:42 christos Exp $");
|
||||
__RCSID("$NetBSD: ifconfig.c,v 1.231 2013/10/19 00:35:30 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -901,12 +901,10 @@ setifaddr(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
static int
|
||||
setifnetmask(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
{
|
||||
const struct paddr_prefix *pfx;
|
||||
prop_data_t d;
|
||||
|
||||
d = (prop_data_t)prop_dictionary_get(env, "dstormask");
|
||||
assert(d != NULL);
|
||||
pfx = prop_data_data_nocopy(d);
|
||||
|
||||
if (!prop_dictionary_set(oenv, "netmask", (prop_object_t)d))
|
||||
return -1;
|
||||
|
@ -917,7 +915,6 @@ setifnetmask(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
static int
|
||||
setifbroadaddr(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
{
|
||||
const struct paddr_prefix *pfx;
|
||||
prop_data_t d;
|
||||
unsigned short flags;
|
||||
|
||||
|
@ -929,7 +926,6 @@ setifbroadaddr(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
|
||||
d = (prop_data_t)prop_dictionary_get(env, "broadcast");
|
||||
assert(d != NULL);
|
||||
pfx = prop_data_data_nocopy(d);
|
||||
|
||||
if (!prop_dictionary_set(oenv, "broadcast", (prop_object_t)d))
|
||||
return -1;
|
||||
|
@ -950,7 +946,6 @@ static int
|
|||
setifdstormask(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
{
|
||||
const char *key;
|
||||
const struct paddr_prefix *pfx;
|
||||
prop_data_t d;
|
||||
unsigned short flags;
|
||||
|
||||
|
@ -959,7 +954,6 @@ setifdstormask(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
|
||||
d = (prop_data_t)prop_dictionary_get(env, "dstormask");
|
||||
assert(d != NULL);
|
||||
pfx = prop_data_data_nocopy(d);
|
||||
|
||||
if ((flags & IFF_BROADCAST) == 0) {
|
||||
key = "dst";
|
||||
|
@ -1030,13 +1024,10 @@ static int
|
|||
setifcaps(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
{
|
||||
int64_t ifcap;
|
||||
int s;
|
||||
bool rc;
|
||||
prop_data_t capdata;
|
||||
struct ifcapreq ifcr;
|
||||
|
||||
s = getsock(AF_INET);
|
||||
|
||||
rc = prop_dictionary_get_int64(env, "ifcap", &ifcap);
|
||||
assert(rc);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tunnel.c,v 1.17 2009/08/07 18:53:37 dyoung Exp $ */
|
||||
/* $NetBSD: tunnel.c,v 1.18 2013/10/19 00:35:30 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: tunnel.c,v 1.17 2009/08/07 18:53:37 dyoung Exp $");
|
||||
__RCSID("$NetBSD: tunnel.c,v 1.18 2013/10/19 00:35:30 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -125,15 +125,8 @@ settunnel(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
IN6_IS_ADDR_MULTICAST(&s6->sin6_addr))
|
||||
errx(EXIT_FAILURE, "tunnel src/dst is multicast");
|
||||
/* embed scopeid */
|
||||
if (s6->sin6_scope_id &&
|
||||
IN6_IS_ADDR_LINKLOCAL(&s6->sin6_addr)) {
|
||||
*(u_int16_t *)&s6->sin6_addr.s6_addr[2] =
|
||||
htons(s6->sin6_scope_id);
|
||||
}
|
||||
if (d->sin6_scope_id && IN6_IS_ADDR_LINKLOCAL(&d->sin6_addr)) {
|
||||
*(u_int16_t *)&d->sin6_addr.s6_addr[2] =
|
||||
htons(d->sin6_scope_id);
|
||||
}
|
||||
inet6_putscopeid(s6, 1);
|
||||
inet6_getscopeid(d, 1);
|
||||
}
|
||||
#endif /* INET6 */
|
||||
|
||||
|
@ -169,7 +162,7 @@ tunnel_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
afp = lookup_af_bynum(req.addr.ss_family);
|
||||
#ifdef INET6
|
||||
if (req.addr.ss_family == AF_INET6)
|
||||
in6_fillscopeid((struct sockaddr_in6 *)&req.addr);
|
||||
inet6_getscopeid((struct sockaddr_in6 *)&req.addr, 1);
|
||||
#endif /* INET6 */
|
||||
getnameinfo((struct sockaddr *)&req.addr, req.addr.ss_len,
|
||||
psrcaddr, sizeof(psrcaddr), &srcserv[1], sizeof(srcserv) - 1,
|
||||
|
@ -177,7 +170,7 @@ tunnel_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
|
||||
#ifdef INET6
|
||||
if (req.dstaddr.ss_family == AF_INET6)
|
||||
in6_fillscopeid((struct sockaddr_in6 *)&req.dstaddr);
|
||||
inet6_getscopeid((struct sockaddr_in6 *)&req.dstaddr, 1);
|
||||
#endif
|
||||
getnameinfo((struct sockaddr *)&req.dstaddr, req.dstaddr.ss_len,
|
||||
pdstaddr, sizeof(pdstaddr), &dstserv[1], sizeof(dstserv) - 1,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: util.c,v 1.16 2010/12/13 17:35:08 pooka Exp $ */
|
||||
/* $NetBSD: util.c,v 1.17 2013/10/19 00:35:30 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 David Young. All rights reserved.
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: util.c,v 1.16 2010/12/13 17:35:08 pooka Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.17 2013/10/19 00:35:30 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -344,17 +344,3 @@ ifa_any_preferences(const char *ifname, struct ifaddrs *ifap, int family)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#ifdef INET6
|
||||
/* KAME idiosyncrasy */
|
||||
void
|
||||
in6_fillscopeid(struct sockaddr_in6 *sin6)
|
||||
{
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
|
||||
sin6->sin6_scope_id =
|
||||
ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
|
||||
sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
|
||||
}
|
||||
}
|
||||
#endif /* INET6 */
|
||||
|
|
|
@ -25,9 +25,6 @@ int getsock(int);
|
|||
struct paddr_prefix *prefixlen_to_mask(int, int);
|
||||
int direct_ioctl(prop_dictionary_t, unsigned long, void *);
|
||||
int indirect_ioctl(prop_dictionary_t, unsigned long, void *);
|
||||
#ifdef INET6
|
||||
void in6_fillscopeid(struct sockaddr_in6 *sin6);
|
||||
#endif /* INET6 */
|
||||
bool ifa_any_preferences(const char *, struct ifaddrs *, int);
|
||||
void ifa_print_preference(const char *, const struct sockaddr *);
|
||||
int16_t ifa_get_preference(const char *, const struct sockaddr *);
|
||||
|
|
Loading…
Reference in New Issue