Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin use new scopeid functions
details: https://anonhg.NetBSD.org/src/rev/5bbdce4ecfd8
branches: trunk
changeset: 790657:5bbdce4ecfd8
user: christos <christos%NetBSD.org@localhost>
date: Sat Oct 19 00:28:38 2013 +0000
description:
use new scopeid functions
diffstat:
usr.bin/fstat/fstat.c | 14 ++++----------
usr.bin/netstat/if.c | 30 ++++++------------------------
usr.bin/netstat/inet6.c | 16 +++-------------
usr.bin/netstat/show.c | 27 ++++-----------------------
4 files changed, 17 insertions(+), 70 deletions(-)
diffs (198 lines):
diff -r 4e290331bbcd -r 5bbdce4ecfd8 usr.bin/fstat/fstat.c
--- a/usr.bin/fstat/fstat.c Sat Oct 19 00:09:03 2013 +0000
+++ b/usr.bin/fstat/fstat.c Sat Oct 19 00:28:38 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fstat.c,v 1.101 2013/10/18 20:18:42 christos Exp $ */
+/* $NetBSD: fstat.c,v 1.102 2013/10/19 00:28:38 christos Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95";
#else
-__RCSID("$NetBSD: fstat.c,v 1.101 2013/10/18 20:18:42 christos Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.102 2013/10/19 00:28:38 christos Exp $");
#endif
#endif /* not lint */
@@ -88,6 +88,7 @@
#ifdef INET6
#include <netinet/ip6.h>
+#include <netinet6/in6.h>
#include <netinet6/ip6_var.h>
#include <netinet6/in6_pcb.h>
#endif
@@ -895,7 +896,6 @@
{
char addr[256], serv[256];
struct sockaddr_in6 sin6;
- uint16_t ad2;
const int niflags = nflg ? (NI_NUMERICHOST|NI_NUMERICSERV) : 0;
(void)memset(&sin6, 0, sizeof(sin6));
@@ -904,13 +904,7 @@
sin6.sin6_addr = *a;
sin6.sin6_port = htons(p);
- memcpy(&ad2, &sin6.sin6_addr.s6_addr[2], sizeof(ad2));
- if (IN6_IS_ADDR_LINKLOCAL(a) && ad2 != 0) {
- sin6.sin6_scope_id = ntohs(ad2);
- sin6.sin6_addr.s6_addr[2] = 0;
- sin6.sin6_addr.s6_addr[3] = 0;
- }
-
+ inet6_putscopeid(&sin6, 1);
serv[0] = '\0';
if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len,
diff -r 4e290331bbcd -r 5bbdce4ecfd8 usr.bin/netstat/if.c
--- a/usr.bin/netstat/if.c Sat Oct 19 00:09:03 2013 +0000
+++ b/usr.bin/netstat/if.c Sat Oct 19 00:28:38 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.77 2013/10/18 20:26:45 christos Exp $ */
+/* $NetBSD: if.c,v 1.78 2013/10/19 00:28:38 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
#else
-__RCSID("$NetBSD: if.c,v 1.77 2013/10/18 20:26:45 christos Exp $");
+__RCSID("$NetBSD: if.c,v 1.78 2013/10/19 00:28:38 christos Exp $");
#endif
#endif /* not lint */
@@ -399,18 +399,10 @@
#ifdef INET6
case AF_INET6:
sin6 = (struct sockaddr_in6 *)sa;
+ inet6_putscopeid(sin6, 1);
#ifdef __KAME__
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- uint16_t scope;
- memcpy(&scope, &sin6->sin6_addr.s6_addr[2],
- sizeof(scope));
- sin6->sin6_scope_id = ntohs(scope);
- /* too little width */
- if (!vflag)
- sin6->sin6_scope_id = 0;
- sin6->sin6_addr.s6_addr[2] = 0;
- sin6->sin6_addr.s6_addr[3] = 0;
- }
+ if (!vflag)
+ sin6->sin6_scope_id = 0;
#endif
if (use_sysctl) {
@@ -454,17 +446,7 @@
as6.sin6_len = sizeof(struct sockaddr_in6);
as6.sin6_family = AF_INET6;
as6.sin6_addr = inm.in6m_addr;
-#ifdef __KAME__
- if (IN6_IS_ADDR_MC_LINKLOCAL(&as6.sin6_addr)) {
- uint16_t scope;
- memcpy(&scope,
- &sin6->sin6_addr.s6_addr[2],
- sizeof(scope));
- as6.sin6_scope_id = ntohs(scope);
- as6.sin6_addr.s6_addr[2] = 0;
- as6.sin6_addr.s6_addr[3] = 0;
- }
-#endif
+ inet6_putscopeid(&as6, 2);
if (getnameinfo((struct sockaddr *)&as6,
as6.sin6_len, hbuf,
sizeof(hbuf), NULL, 0,
diff -r 4e290331bbcd -r 5bbdce4ecfd8 usr.bin/netstat/inet6.c
--- a/usr.bin/netstat/inet6.c Sat Oct 19 00:09:03 2013 +0000
+++ b/usr.bin/netstat/inet6.c Sat Oct 19 00:28:38 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inet6.c,v 1.63 2013/10/18 20:26:45 christos Exp $ */
+/* $NetBSD: inet6.c,v 1.64 2013/10/19 00:28:38 christos Exp $ */
/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
/*
@@ -64,7 +64,7 @@
#if 0
static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-__RCSID("$NetBSD: inet6.c,v 1.63 2013/10/18 20:26:45 christos Exp $");
+__RCSID("$NetBSD: inet6.c,v 1.64 2013/10/19 00:28:38 christos Exp $");
#endif
#endif /* not lint */
@@ -1420,17 +1420,7 @@
sin6.sin6_len = sizeof(sin6);
sin6.sin6_family = AF_INET6;
sin6.sin6_addr = *in6p;
-#ifdef __KAME__
- if (IN6_IS_ADDR_LINKLOCAL(in6p) ||
- IN6_IS_ADDR_MC_LINKLOCAL(in6p)) {
- uint16_t scope;
- memcpy(&scope, &sin6.sin6_addr.s6_addr[2],
- sizeof(scope));
- sin6.sin6_scope_id = ntohs(scope);
- sin6.sin6_addr.s6_addr[2] = 0;
- sin6.sin6_addr.s6_addr[3] = 0;
- }
-#endif
+ inet6_putscopeid(&sin6, 3);
if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len,
hbuf, sizeof(hbuf), NULL, 0, niflag) != 0)
strlcpy(hbuf, "?", sizeof(hbuf));
diff -r 4e290331bbcd -r 5bbdce4ecfd8 usr.bin/netstat/show.c
--- a/usr.bin/netstat/show.c Sat Oct 19 00:09:03 2013 +0000
+++ b/usr.bin/netstat/show.c Sat Oct 19 00:28:38 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: show.c,v 1.16 2013/10/18 20:26:45 christos Exp $ */
+/* $NetBSD: show.c,v 1.17 2013/10/19 00:28:38 christos Exp $ */
/* $OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $ */
/*
@@ -330,22 +330,12 @@
case AF_INET6:
{
struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa;
- struct in6_addr *in6 = &sa6->sin6_addr;
/*
* XXX: This is a special workaround for KAME kernels.
* sin6_scope_id field of SA should be set in the future.
*/
- if (IN6_IS_ADDR_LINKLOCAL(in6) ||
- IN6_IS_ADDR_MC_LINKLOCAL(in6)) {
- /* XXX: override is ok? */
- uint16_t scope;
- memcpy(&scope, &sa6->sin6_addr.s6_addr[2],
- sizeof(scope));
- sa6->sin6_scope_id = ntohs(scope);
- in6->s6_addr[2] = 0;
- in6->s6_addr[3] = 0;
- }
+ inet6_putscopeid(sa6, 3);
if (flags & RTF_HOST)
cp = routename((struct sockaddr *)sa6);
else
@@ -435,17 +425,8 @@
memcpy(&sin6, sa, sa->sa_len);
sin6.sin6_len = sizeof(struct sockaddr_in6);
sin6.sin6_family = AF_INET6;
- if (sa->sa_len == sizeof(struct sockaddr_in6) &&
- (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr) ||
- IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) &&
- sin6.sin6_scope_id == 0) {
- uint16_t scope;
- memcpy(&scope, &sin6.sin6_addr.s6_addr[2],
- sizeof(scope));
- sin6.sin6_scope_id = ntohs(scope);
- sin6.sin6_addr.s6_addr[2] = 0;
- sin6.sin6_addr.s6_addr[3] = 0;
- }
+ if (sa->sa_len == sizeof(struct sockaddr_in6))
+ inet6_putscopeid(&sin6, 3);
return (routename6(&sin6));
}
Home |
Main Index |
Thread Index |
Old Index