Module Name: src
Committed By: christos
Date: Sat Oct 19 00:35:30 UTC 2013
Modified Files:
src/sbin/ifconfig: af_atalk.c af_inet6.c ifconfig.c tunnel.c util.c
util.h
Log Message:
use the new scopeid functions
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/ifconfig/af_atalk.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/ifconfig/af_inet6.c
cvs rdiff -u -r1.230 -r1.231 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.17 -r1.18 src/sbin/ifconfig/tunnel.c
cvs rdiff -u -r1.16 -r1.17 src/sbin/ifconfig/util.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/ifconfig/util.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/ifconfig/af_atalk.c
diff -u src/sbin/ifconfig/af_atalk.c:1.18 src/sbin/ifconfig/af_atalk.c:1.19
--- src/sbin/ifconfig/af_atalk.c:1.18 Sun Aug 14 08:15:15 2011
+++ src/sbin/ifconfig/af_atalk.c Fri Oct 18 20:35:30 2013
@@ -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);
}
Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.27 src/sbin/ifconfig/af_inet6.c:1.28
--- src/sbin/ifconfig/af_inet6.c:1.27 Mon Dec 13 12:35:08 2010
+++ src/sbin/ifconfig/af_inet6.c Fri Oct 18 20:35:30 2013
@@ -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_dictio
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,
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_dicti
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_dicti
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, c
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;
}
Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.230 src/sbin/ifconfig/ifconfig.c:1.231
--- src/sbin/ifconfig/ifconfig.c:1.230 Wed Jul 17 11:40:42 2013
+++ src/sbin/ifconfig/ifconfig.c Fri Oct 18 20:35:30 2013
@@ -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_di
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
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, pr
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, pr
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);
Index: src/sbin/ifconfig/tunnel.c
diff -u src/sbin/ifconfig/tunnel.c:1.17 src/sbin/ifconfig/tunnel.c:1.18
--- src/sbin/ifconfig/tunnel.c:1.17 Fri Aug 7 14:53:37 2009
+++ src/sbin/ifconfig/tunnel.c Fri Oct 18 20:35:30 2013
@@ -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_di
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, pro
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, pro
#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,
Index: src/sbin/ifconfig/util.c
diff -u src/sbin/ifconfig/util.c:1.16 src/sbin/ifconfig/util.c:1.17
--- src/sbin/ifconfig/util.c:1.16 Mon Dec 13 12:35:08 2010
+++ src/sbin/ifconfig/util.c Fri Oct 18 20:35:30 2013
@@ -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,
}
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 */
Index: src/sbin/ifconfig/util.h
diff -u src/sbin/ifconfig/util.h:1.9 src/sbin/ifconfig/util.h:1.10
--- src/sbin/ifconfig/util.h:1.9 Thu Jul 1 12:44:05 2010
+++ src/sbin/ifconfig/util.h Fri Oct 18 20:35:30 2013
@@ -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 *);