Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig make ifconfig IPv6-ready.
details: https://anonhg.NetBSD.org/src/rev/fdb8a08c5782
branches: trunk
changeset: 474203:fdb8a08c5782
user: itojun <itojun%NetBSD.org@localhost>
date: Thu Jul 01 13:19:20 1999 +0000
description:
make ifconfig IPv6-ready.
TODO: update manpage for new options.
diffstat:
sbin/ifconfig/Makefile | 4 +-
sbin/ifconfig/ifconfig.8 | 10 +-
sbin/ifconfig/ifconfig.c | 413 +++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 406 insertions(+), 21 deletions(-)
diffs (truncated from 643 to 300 lines):
diff -r d2ede5aaaa3d -r fdb8a08c5782 sbin/ifconfig/Makefile
--- a/sbin/ifconfig/Makefile Thu Jul 01 11:18:20 1999 +0000
+++ b/sbin/ifconfig/Makefile Thu Jul 01 13:19:20 1999 +0000
@@ -1,7 +1,9 @@
-# $NetBSD: Makefile,v 1.7 1995/03/18 14:56:21 cgd Exp $
+# $NetBSD: Makefile,v 1.8 1999/07/01 13:19:20 itojun Exp $
# @(#)Makefile 8.1 (Berkeley) 6/5/93
PROG= ifconfig
MAN= ifconfig.8
+CFLAGS+= -DINET6
+
.include <bsd.prog.mk>
diff -r d2ede5aaaa3d -r fdb8a08c5782 sbin/ifconfig/ifconfig.8
--- a/sbin/ifconfig/ifconfig.8 Thu Jul 01 11:18:20 1999 +0000
+++ b/sbin/ifconfig/ifconfig.8 Thu Jul 01 13:19:20 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ifconfig.8,v 1.24 1998/09/06 17:51:32 christos Exp $
+.\" $NetBSD: ifconfig.8,v 1.25 1999/07/01 13:19:20 itojun Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -49,13 +49,13 @@
.Op Ar parameters
.Nm ""
.Op Fl A
-.Op Fl m
+.Op Fl mL
.Ar interface
.Op Ar protocol_family
.Nm ""
.Fl a
.Op Fl A
-.Op Fl m
+.Op Fl mL
.Op Fl d
.Op Fl u
.Op Ar protocol_family
@@ -318,6 +318,10 @@
flag is passed before an interface name,
.Nm
will display all of the supported media for the specified interface.
+If the
+.Fl L
+flag is supplied, address lifetime is dislayed for IPv6 addresses,
+as time offset string.
.Pp
Optionally, the
.Fl a
diff -r d2ede5aaaa3d -r fdb8a08c5782 sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c Thu Jul 01 11:18:20 1999 +0000
+++ b/sbin/ifconfig/ifconfig.c Thu Jul 01 13:19:20 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ifconfig.c,v 1.52 1999/05/18 18:01:08 thorpej Exp $ */
+/* $NetBSD: ifconfig.c,v 1.53 1999/07/01 13:19:20 itojun Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
#if 0
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#else
-__RCSID("$NetBSD: ifconfig.c,v 1.52 1999/05/18 18:01:08 thorpej Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.53 1999/07/01 13:19:20 itojun Exp $");
#endif
#endif /* not lint */
@@ -92,6 +92,8 @@
#include <net/if_dl.h>
#include <net/if_media.h>
#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet6/nd6.h>
#include <arpa/inet.h>
#include <netatalk/at.h>
@@ -117,6 +119,11 @@
struct ifreq ifr, ridreq;
struct ifaliasreq addreq __attribute__((aligned(4)));
+#ifdef INET6
+struct in6_ifreq ifr6;
+struct in6_ifreq in6_ridreq;
+struct in6_aliasreq in6_addreq __attribute__((aligned(4)));
+#endif
struct iso_ifreq iso_ridreq;
struct iso_aliasreq iso_addreq;
struct sockaddr_in netmask;
@@ -129,7 +136,14 @@
int nsellength = 1;
int af;
int Aflag, aflag, dflag, mflag, lflag, uflag;
+#ifdef INET6
+int Lflag;
+#endif
int reset_if_flags;
+int explicit_prefix = 0;
+#ifndef INET_ONLY
+char ntop_buf[INET6_ADDRSTRLEN]; /*inet_ntop()*/
+#endif /* INET_ONLY */
void notealias __P((char *, int));
void notrailers __P((char *, int));
@@ -141,10 +155,17 @@
void setifmetric __P((char *, int));
void setifmtu __P((char *, int));
void setifnetmask __P((char *, int));
+void setifprefixlen __P((char *, int));
void setnsellength __P((char *, int));
void setsnpaoffset __P((char *, int));
void setatrange __P((char *, int));
void setatphase __P((char *, int));
+#ifdef INET6
+void setia6flags __P((char *, int));
+void setia6pltime __P((char *, int));
+void setia6vltime __P((char *, int));
+void setia6lifetime __P((char *, char *));
+#endif
void checkatrange __P ((struct sockaddr_at *));
void setmedia __P((char *, int));
void setmediaopt __P((char *, int));
@@ -201,6 +222,15 @@
{ "mtu", NEXTARG, 0, setifmtu },
{ "broadcast", NEXTARG, 0, setifbroadaddr },
{ "ipdst", NEXTARG, 0, setifipdst },
+ { "prefixlen", NEXTARG, 0, setifprefixlen},
+#ifdef INET6
+ { "anycast", IN6_IFF_ANYCAST, 0, setia6flags },
+ { "-anycast", -IN6_IFF_ANYCAST, 0, setia6flags },
+ { "tentative", IN6_IFF_TENTATIVE, 0, setia6flags },
+ { "-tentative", -IN6_IFF_TENTATIVE, 0, setia6flags },
+ { "pltime", NEXTARG, 0, setia6pltime },
+ { "vltime", NEXTARG, 0, setia6vltime },
+#endif /*INET6*/
#ifndef INET_ONLY
{ "range", NEXTARG, 0, setatrange },
{ "phase", NEXTARG, 0, setatphase },
@@ -226,10 +256,12 @@
int getinfo __P((struct ifreq *));
void getsock __P((int));
void printall __P((void));
-void printalias __P((const char *));
+void printalias __P((const char *, int));
void printb __P((char *, unsigned short, char *));
+int prefix __P((void *, int));
void status __P((const u_int8_t *, int));
void usage __P((void));
+char *sec2str __P((time_t));
const char *get_media_type_string __P((int));
const char *get_media_subtype_string __P((int));
@@ -248,6 +280,12 @@
void in_alias __P((struct ifreq *));
void in_status __P((int));
void in_getaddr __P((char *, int));
+#ifdef INET6
+void in6_alias __P((struct in6_ifreq *));
+void in6_status __P((int));
+void in6_getaddr __P((char *, int));
+void in6_getprefix __P((char *, int));
+#endif
void at_status __P((int));
void at_getaddr __P((char *, int));
void xns_status __P((int));
@@ -261,20 +299,25 @@
short af_af;
void (*af_status) __P((int));
void (*af_getaddr) __P((char *, int));
+ void (*af_getprefix) __P((char *, int));
u_long af_difaddr;
u_long af_aifaddr;
caddr_t af_ridreq;
caddr_t af_addreq;
} afs[] = {
#define C(x) ((caddr_t) &x)
- { "inet", AF_INET, in_status, in_getaddr,
+ { "inet", AF_INET, in_status, in_getaddr, NULL,
SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
+#ifdef INET6
+ { "inet6", AF_INET6, in6_status, in6_getaddr, in6_getprefix,
+ SIOCDIFADDR_IN6, SIOCAIFADDR_IN6, C(in6_ridreq), C(in6_addreq) },
+#endif
#ifndef INET_ONLY /* small version, for boot media */
- { "atalk", AF_APPLETALK, at_status, at_getaddr,
+ { "atalk", AF_APPLETALK, at_status, at_getaddr, NULL,
SIOCDIFADDR, SIOCAIFADDR, C(addreq), C(addreq) },
- { "ns", AF_NS, xns_status, xns_getaddr,
+ { "ns", AF_NS, xns_status, xns_getaddr, NULL,
SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
- { "iso", AF_ISO, iso_status, iso_getaddr,
+ { "iso", AF_ISO, iso_status, iso_getaddr, NULL,
SIOCDIFADDR_ISO, SIOCAIFADDR_ISO, C(iso_ridreq), C(iso_addreq) },
#endif /* INET_ONLY */
{ 0, 0, 0, 0 }
@@ -293,7 +336,11 @@
/* Parse command-line options */
aflag = mflag = 0;
- while ((ch = getopt(argc, argv, "Aadlmu")) != -1) {
+ while ((ch = getopt(argc, argv, "Aadlmu"
+#ifdef INET6
+ "L"
+#endif
+ )) != -1) {
switch (ch) {
case 'A':
Aflag = 1;
@@ -307,6 +354,12 @@
dflag = 1;
break;
+#ifdef INET6
+ case 'L':
+ Lflag = 1;
+ break;
+#endif
+
case 'l':
lflag = 1;
break;
@@ -384,11 +437,17 @@
exit(0);
}
- /* The following operations assume inet family as the default. */
+ /* following operations assume inet familiy as default */
if (afp == NULL)
afp = afs;
af = ifr.ifr_addr.sa_family = afp->af_af;
+#ifdef INET6
+ /* initialization */
+ in6_addreq.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME;
+ in6_addreq.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME;
+#endif
+
/* Process commands. */
while (argc > 0) {
struct cmd *p;
@@ -415,8 +474,17 @@
/* Process any media commands that may have been issued. */
process_media_commands();
+ if (af == AF_INET6 && explicit_prefix == 0) {
+ /*
+ * Aggregatable address architecture defines all prefixes
+ * are 64. So, it is convenient to set prefixlen to 64 if
+ * it is not specified.
+ */
+ setifprefixlen("64", 0);
+ /* in6_getprefix("64", MASK) if MASK is available here... */
+ }
+
#ifndef INET_ONLY
-
if (af == AF_ISO)
adjust_nsellength();
@@ -511,8 +579,9 @@
}
void
-printalias(iname)
+printalias(iname, af)
const char *iname;
+ int af;
{
char inbuf[8192];
struct ifconf ifc;
@@ -534,8 +603,14 @@
? ifr->ifr_addr.sa_len
: sizeof(struct sockaddr));
if (!strncmp(iname, ifr->ifr_name, sizeof(ifr->ifr_name))) {
- if (ifr->ifr_addr.sa_family == AF_INET)
- in_alias(ifr);
+ if (ifr->ifr_addr.sa_family == af)
+ switch (af) {
+ case AF_INET:
+ in_alias(ifr);
+ break;
+ default:
+ /*none*/
+ }
continue;
}
}
@@ -714,6 +789,59 @@
reset_if_flags = 1;
}
+#ifdef INET6
+void
+setia6flags(vname, value)
+ char *vname;
+ int value;
+{
+ if (value < 0) {
+ value = -value;
+ in6_addreq.ifra_flags &= ~value;
Home |
Main Index |
Thread Index |
Old Index