Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig use the new scopeid functions
details: https://anonhg.NetBSD.org/src/rev/5108be593b0d
branches: trunk
changeset: 790658:5108be593b0d
user: christos <christos%NetBSD.org@localhost>
date: Sat Oct 19 00:35:30 2013 +0000
description:
use the new scopeid functions
diffstat:
sbin/ifconfig/af_atalk.c | 7 +++----
sbin/ifconfig/af_inet6.c | 25 ++++++-------------------
sbin/ifconfig/ifconfig.c | 13 ++-----------
sbin/ifconfig/tunnel.c | 19 ++++++-------------
sbin/ifconfig/util.c | 18 ++----------------
sbin/ifconfig/util.h | 3 ---
6 files changed, 19 insertions(+), 66 deletions(-)
diffs (283 lines):
diff -r 5bbdce4ecfd8 -r 5108be593b0d sbin/ifconfig/af_atalk.c
--- a/sbin/ifconfig/af_atalk.c Sat Oct 19 00:28:38 2013 +0000
+++ b/sbin/ifconfig/af_atalk.c Sat Oct 19 00:35:30 2013 +0000
@@ -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 @@
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);
}
diff -r 5bbdce4ecfd8 -r 5108be593b0d sbin/ifconfig/af_inet6.c
--- a/sbin/ifconfig/af_inet6.c Sat Oct 19 00:28:38 2013 +0000
+++ b/sbin/ifconfig/af_inet6.c Sat Oct 19 00:35:30 2013 +0000
@@ -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 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 @@
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 @@
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 @@
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 @@
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;
}
diff -r 5bbdce4ecfd8 -r 5108be593b0d sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c Sat Oct 19 00:28:38 2013 +0000
+++ b/sbin/ifconfig/ifconfig.c Sat Oct 19 00:35:30 2013 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
diff -r 5bbdce4ecfd8 -r 5108be593b0d sbin/ifconfig/tunnel.c
--- a/sbin/ifconfig/tunnel.c Sat Oct 19 00:28:38 2013 +0000
+++ b/sbin/ifconfig/tunnel.c Sat Oct 19 00:35:30 2013 +0000
@@ -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 @@
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 @@
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 @@
#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,
diff -r 5bbdce4ecfd8 -r 5108be593b0d sbin/ifconfig/util.c
--- a/sbin/ifconfig/util.c Sat Oct 19 00:28:38 2013 +0000
+++ b/sbin/ifconfig/util.c Sat Oct 19 00:35:30 2013 +0000
@@ -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 @@
}
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 */
diff -r 5bbdce4ecfd8 -r 5108be593b0d sbin/ifconfig/util.h
--- a/sbin/ifconfig/util.h Sat Oct 19 00:28:38 2013 +0000
+++ b/sbin/ifconfig/util.h Sat Oct 19 00:35:30 2013 +0000
@@ -25,9 +25,6 @@
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 *);
Home |
Main Index |
Thread Index |
Old Index