Add option -N. -N is just the opposite of option -n in netstat(8)

or route(8): it tells ifconfig(8) to try to resolve numbers to
hosts and service names.

This default ifconfig behavior stays the same as it always was.
This commit is contained in:
dyoung 2009-08-07 18:53:37 +00:00
parent 0ebb0c6cda
commit ab7c5957a9
5 changed files with 21 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: af_inet6.c,v 1.23 2008/07/15 20:56:13 dyoung Exp $ */
/* $NetBSD: af_inet6.c,v 1.24 2009/08/07 18:53:37 dyoung Exp $ */
/*
* Copyright (c) 1983, 1993
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: af_inet6.c,v 1.23 2008/07/15 20:56:13 dyoung Exp $");
__RCSID("$NetBSD: af_inet6.c,v 1.24 2009/08/07 18:53:37 dyoung Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -278,7 +278,7 @@ in6_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv,
char hbuf[NI_MAXHOST];
u_int32_t scopeid;
int s;
const int niflag = NI_NUMERICHOST;
const int niflag = Nflag ? 0 : NI_NUMERICHOST;
unsigned short flags;
/* Get the non-alias address for this interface. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.13 2008/07/15 20:56:13 dyoung Exp $ */
/* $NetBSD: extern.h,v 1.14 2009/08/07 18:53:37 dyoung Exp $ */
/*
* Copyright (c) 1983, 1993
@ -88,6 +88,6 @@ int register_usage(usage_func_t *);
int register_flag(int);
bool get_flag(int);
extern bool lflag, vflag, zflag;
extern bool lflag, Nflag, vflag, zflag;
#endif /* _IFCONFIG_EXTERN_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ifconfig.c,v 1.219 2009/05/26 16:03:24 pooka Exp $ */
/* $NetBSD: ifconfig.c,v 1.220 2009/08/07 18:53:37 dyoung 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.219 2009/05/26 16:03:24 pooka Exp $");
__RCSID("$NetBSD: ifconfig.c,v 1.220 2009/08/07 18:53:37 dyoung Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -102,9 +102,9 @@ __RCSID("$NetBSD: ifconfig.c,v 1.219 2009/05/26 16:03:24 pooka Exp $");
#include "env.h"
static bool bflag, dflag, hflag, sflag, uflag;
bool lflag, vflag, zflag;
bool lflag, Nflag, vflag, zflag;
static char gflags[10 + 26 * 2 + 1] = "AabCdhlsuvz";
static char gflags[10 + 26 * 2 + 1] = "AabCdhlNsuvz";
bool gflagset[10 + 26 * 2];
static int carrier(prop_dictionary_t);
@ -550,7 +550,7 @@ main(int argc, char **argv)
start = init_parser();
/* Parse command-line options */
aflag = vflag = zflag = false;
aflag = Nflag = vflag = zflag = false;
while ((ch = getopt(argc, argv, gflags)) != -1) {
switch (ch) {
case 'A':
@ -578,6 +578,9 @@ main(int argc, char **argv)
case 'l':
lflag = true;
break;
case 'N':
Nflag = true;
break;
case 's':
sflag = true;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tunnel.c,v 1.16 2008/07/15 21:27:58 dyoung Exp $ */
/* $NetBSD: tunnel.c,v 1.17 2009/08/07 18:53:37 dyoung Exp $ */
/*
* Copyright (c) 1983, 1993
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: tunnel.c,v 1.16 2008/07/15 21:27:58 dyoung Exp $");
__RCSID("$NetBSD: tunnel.c,v 1.17 2009/08/07 18:53:37 dyoung Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -157,7 +157,7 @@ tunnel_status(prop_dictionary_t env, prop_dictionary_t oenv)
char srcserv[sizeof(",65535")];
char psrcaddr[NI_MAXHOST];
char pdstaddr[NI_MAXHOST];
const int niflag = NI_NUMERICHOST|NI_NUMERICSERV;
const int niflag = Nflag ? 0 : (NI_NUMERICHOST|NI_NUMERICSERV);
struct if_laddrreq req;
const struct afswtch *afp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.11 2009/04/27 20:10:49 dyoung Exp $ */
/* $NetBSD: util.c,v 1.12 2009/08/07 18:53:37 dyoung 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.11 2009/04/27 20:10:49 dyoung Exp $");
__RCSID("$NetBSD: util.c,v 1.12 2009/08/07 18:53:37 dyoung Exp $");
#endif /* not lint */
#include <ctype.h>
@ -52,6 +52,7 @@ __RCSID("$NetBSD: util.c,v 1.11 2009/04/27 20:10:49 dyoung Exp $");
#include <netinet/in.h> /* XXX */
#include "env.h"
#include "extern.h"
#include "util.h"
int
@ -279,7 +280,8 @@ print_link_addresses(prop_dictionary_t env, bool print_active_only)
continue;
if (getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len,
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) == 0 &&
hbuf, sizeof(hbuf), NULL, 0,
Nflag ? 0 : NI_NUMERICHOST) == 0 &&
hbuf[0] != '\0') {
printf("\t%s %s\n",
print_active_only ? "address:" : "link", hbuf);