Fri Aug 7 18:53:37 2009 UTC ()
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.


(dyoung)
diff -r1.23 -r1.24 src/sbin/ifconfig/af_inet6.c
diff -r1.13 -r1.14 src/sbin/ifconfig/extern.h
diff -r1.219 -r1.220 src/sbin/ifconfig/ifconfig.c
diff -r1.16 -r1.17 src/sbin/ifconfig/tunnel.c
diff -r1.11 -r1.12 src/sbin/ifconfig/util.c

cvs diff -r1.23 -r1.24 src/sbin/ifconfig/af_inet6.c (expand / switch to unified diff)

--- src/sbin/ifconfig/af_inet6.c 2008/07/15 20:56:13 1.23
+++ src/sbin/ifconfig/af_inet6.c 2009/08/07 18:53:37 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: af_inet6.c,v 1.23 2008/07/15 20:56:13 dyoung Exp $ */ 1/* $NetBSD: af_inet6.c,v 1.24 2009/08/07 18:53:37 dyoung Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1983, 1993 4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF  28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__RCSID("$NetBSD: af_inet6.c,v 1.23 2008/07/15 20:56:13 dyoung Exp $"); 34__RCSID("$NetBSD: af_inet6.c,v 1.24 2009/08/07 18:53:37 dyoung Exp $");
35#endif /* not lint */ 35#endif /* not lint */
36 36
37#include <sys/param.h>  37#include <sys/param.h>
38#include <sys/ioctl.h>  38#include <sys/ioctl.h>
39#include <sys/socket.h> 39#include <sys/socket.h>
40 40
41#include <net/if.h>  41#include <net/if.h>
42#include <netinet/in.h> 42#include <netinet/in.h>
43#include <netinet/in_var.h> 43#include <netinet/in_var.h>
44#include <netinet6/nd6.h> 44#include <netinet6/nd6.h>
45 45
46#include <err.h> 46#include <err.h>
47#include <errno.h> 47#include <errno.h>
@@ -268,27 +268,27 @@ in6_delscopeid(struct sockaddr_in6 *sin6 @@ -268,27 +268,27 @@ in6_delscopeid(struct sockaddr_in6 *sin6
268 sin6->sin6_scope_id = 0; 268 sin6->sin6_scope_id = 0;
269} 269}
270 270
271/* XXX not really an alias */ 271/* XXX not really an alias */
272void 272void
273in6_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv, 273in6_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv,
274 struct in6_ifreq *creq) 274 struct in6_ifreq *creq)
275{ 275{
276 struct in6_ifreq ifr6; 276 struct in6_ifreq ifr6;
277 struct sockaddr_in6 *sin6; 277 struct sockaddr_in6 *sin6;
278 char hbuf[NI_MAXHOST]; 278 char hbuf[NI_MAXHOST];
279 u_int32_t scopeid; 279 u_int32_t scopeid;
280 int s; 280 int s;
281 const int niflag = NI_NUMERICHOST; 281 const int niflag = Nflag ? 0 : NI_NUMERICHOST;
282 unsigned short flags; 282 unsigned short flags;
283 283
284 /* Get the non-alias address for this interface. */ 284 /* Get the non-alias address for this interface. */
285 if ((s = getsock(AF_INET6)) == -1) { 285 if ((s = getsock(AF_INET6)) == -1) {
286 if (errno == EAFNOSUPPORT) 286 if (errno == EAFNOSUPPORT)
287 return; 287 return;
288 err(EXIT_FAILURE, "socket"); 288 err(EXIT_FAILURE, "socket");
289 } 289 }
290 290
291 sin6 = &creq->ifr_addr; 291 sin6 = &creq->ifr_addr;
292 292
293 in6_fillscopeid(sin6); 293 in6_fillscopeid(sin6);
294 scopeid = sin6->sin6_scope_id; 294 scopeid = sin6->sin6_scope_id;

cvs diff -r1.13 -r1.14 src/sbin/ifconfig/extern.h (expand / switch to unified diff)

--- src/sbin/ifconfig/extern.h 2008/07/15 20:56:13 1.13
+++ src/sbin/ifconfig/extern.h 2009/08/07 18:53:37 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: extern.h,v 1.13 2008/07/15 20:56:13 dyoung Exp $ */ 1/* $NetBSD: extern.h,v 1.14 2009/08/07 18:53:37 dyoung Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1983, 1993 4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -78,16 +78,16 @@ typedef struct cmdloop_branch cmdloop_br @@ -78,16 +78,16 @@ typedef struct cmdloop_branch cmdloop_br
78 78
79void cmdloop_branch_init(cmdloop_branch_t *, struct parser *); 79void cmdloop_branch_init(cmdloop_branch_t *, struct parser *);
80int register_family(struct afswtch *); 80int register_family(struct afswtch *);
81int register_cmdloop_branch(cmdloop_branch_t *); 81int register_cmdloop_branch(cmdloop_branch_t *);
82void statistics_func_init(statistics_func_t *, statistics_cb_t); 82void statistics_func_init(statistics_func_t *, statistics_cb_t);
83void status_func_init(status_func_t *, status_cb_t); 83void status_func_init(status_func_t *, status_cb_t);
84void usage_func_init(usage_func_t *, usage_cb_t); 84void usage_func_init(usage_func_t *, usage_cb_t);
85int register_statistics(statistics_func_t *); 85int register_statistics(statistics_func_t *);
86int register_status(status_func_t *); 86int register_status(status_func_t *);
87int register_usage(usage_func_t *); 87int register_usage(usage_func_t *);
88int register_flag(int); 88int register_flag(int);
89bool get_flag(int); 89bool get_flag(int);
90 90
91extern bool lflag, vflag, zflag; 91extern bool lflag, Nflag, vflag, zflag;
92 92
93#endif /* _IFCONFIG_EXTERN_H */ 93#endif /* _IFCONFIG_EXTERN_H */

cvs diff -r1.219 -r1.220 src/sbin/ifconfig/ifconfig.c (expand / switch to unified diff)

--- src/sbin/ifconfig/ifconfig.c 2009/05/26 16:03:24 1.219
+++ src/sbin/ifconfig/ifconfig.c 2009/08/07 18:53:37 1.220
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ifconfig.c,v 1.219 2009/05/26 16:03:24 pooka Exp $ */ 1/* $NetBSD: ifconfig.c,v 1.220 2009/08/07 18:53:37 dyoung Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -53,27 +53,27 @@ @@ -53,27 +53,27 @@
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE. 59 * SUCH DAMAGE.
60 */ 60 */
61 61
62#include <sys/cdefs.h> 62#include <sys/cdefs.h>
63#ifndef lint 63#ifndef lint
64__COPYRIGHT("@(#) Copyright (c) 1983, 1993\ 64__COPYRIGHT("@(#) Copyright (c) 1983, 1993\
65 The Regents of the University of California. All rights reserved."); 65 The Regents of the University of California. All rights reserved.");
66__RCSID("$NetBSD: ifconfig.c,v 1.219 2009/05/26 16:03:24 pooka Exp $"); 66__RCSID("$NetBSD: ifconfig.c,v 1.220 2009/08/07 18:53:37 dyoung Exp $");
67#endif /* not lint */ 67#endif /* not lint */
68 68
69#include <sys/param.h> 69#include <sys/param.h>
70#include <sys/queue.h> 70#include <sys/queue.h>
71#include <sys/socket.h> 71#include <sys/socket.h>
72#include <sys/ioctl.h> 72#include <sys/ioctl.h>
73 73
74#include <net/if.h> 74#include <net/if.h>
75#include <net/if_dl.h> 75#include <net/if_dl.h>
76#include <net/if_media.h> 76#include <net/if_media.h>
77#include <net/if_ether.h> 77#include <net/if_ether.h>
78#include <netinet/in.h> /* XXX */ 78#include <netinet/in.h> /* XXX */
79#include <netinet/in_var.h> /* XXX */ 79#include <netinet/in_var.h> /* XXX */
@@ -92,29 +92,29 @@ __RCSID("$NetBSD: ifconfig.c,v 1.219 200 @@ -92,29 +92,29 @@ __RCSID("$NetBSD: ifconfig.c,v 1.219 200
92#include <stdlib.h> 92#include <stdlib.h>
93#include <string.h> 93#include <string.h>
94#include <unistd.h> 94#include <unistd.h>
95#include <ifaddrs.h> 95#include <ifaddrs.h>
96#include <util.h> 96#include <util.h>
97 97
98#include "extern.h" 98#include "extern.h"
99 99
100#include "media.h" 100#include "media.h"
101#include "parse.h" 101#include "parse.h"
102#include "env.h" 102#include "env.h"
103 103
104static bool bflag, dflag, hflag, sflag, uflag; 104static bool bflag, dflag, hflag, sflag, uflag;
105bool lflag, vflag, zflag; 105bool lflag, Nflag, vflag, zflag;
106 106
107static char gflags[10 + 26 * 2 + 1] = "AabCdhlsuvz"; 107static char gflags[10 + 26 * 2 + 1] = "AabCdhlNsuvz";
108bool gflagset[10 + 26 * 2]; 108bool gflagset[10 + 26 * 2];
109 109
110static int carrier(prop_dictionary_t); 110static int carrier(prop_dictionary_t);
111static int clone_command(prop_dictionary_t, prop_dictionary_t); 111static int clone_command(prop_dictionary_t, prop_dictionary_t);
112static void do_setifpreference(prop_dictionary_t); 112static void do_setifpreference(prop_dictionary_t);
113static int flag_index(int); 113static int flag_index(int);
114static void init_afs(void); 114static void init_afs(void);
115static int list_cloners(prop_dictionary_t, prop_dictionary_t); 115static int list_cloners(prop_dictionary_t, prop_dictionary_t);
116static int media_status_exec(prop_dictionary_t, prop_dictionary_t); 116static int media_status_exec(prop_dictionary_t, prop_dictionary_t);
117static int no_cmds_exec(prop_dictionary_t, prop_dictionary_t); 117static int no_cmds_exec(prop_dictionary_t, prop_dictionary_t);
118static int notrailers(prop_dictionary_t, prop_dictionary_t); 118static int notrailers(prop_dictionary_t, prop_dictionary_t);
119static void printall(const char *, prop_dictionary_t); 119static void printall(const char *, prop_dictionary_t);
120static int setifaddr(prop_dictionary_t, prop_dictionary_t); 120static int setifaddr(prop_dictionary_t, prop_dictionary_t);
@@ -540,27 +540,27 @@ main(int argc, char **argv) @@ -540,27 +540,27 @@ main(int argc, char **argv)
540 prop_dictionary_t env, oenv; 540 prop_dictionary_t env, oenv;
541 const char *ifname; 541 const char *ifname;
542 542
543#ifdef RUMP_ACTION 543#ifdef RUMP_ACTION
544 rump_init(); 544 rump_init();
545#endif 545#endif
546 memset(match, 0, sizeof(match)); 546 memset(match, 0, sizeof(match));
547 547
548 init_afs(); 548 init_afs();
549 549
550 start = init_parser(); 550 start = init_parser();
551 551
552 /* Parse command-line options */ 552 /* Parse command-line options */
553 aflag = vflag = zflag = false; 553 aflag = Nflag = vflag = zflag = false;
554 while ((ch = getopt(argc, argv, gflags)) != -1) { 554 while ((ch = getopt(argc, argv, gflags)) != -1) {
555 switch (ch) { 555 switch (ch) {
556 case 'A': 556 case 'A':
557 warnx("-A is deprecated"); 557 warnx("-A is deprecated");
558 break; 558 break;
559 559
560 case 'a': 560 case 'a':
561 aflag = true; 561 aflag = true;
562 break; 562 break;
563 563
564 case 'b': 564 case 'b':
565 bflag = true; 565 bflag = true;
566 break; 566 break;
@@ -568,26 +568,29 @@ main(int argc, char **argv) @@ -568,26 +568,29 @@ main(int argc, char **argv)
568 case 'C': 568 case 'C':
569 Cflag = true; 569 Cflag = true;
570 break; 570 break;
571 571
572 case 'd': 572 case 'd':
573 dflag = true; 573 dflag = true;
574 break; 574 break;
575 case 'h': 575 case 'h':
576 hflag = true; 576 hflag = true;
577 break; 577 break;
578 case 'l': 578 case 'l':
579 lflag = true; 579 lflag = true;
580 break; 580 break;
 581 case 'N':
 582 Nflag = true;
 583 break;
581 584
582 case 's': 585 case 's':
583 sflag = true; 586 sflag = true;
584 break; 587 break;
585 588
586 case 'u': 589 case 'u':
587 uflag = true; 590 uflag = true;
588 break; 591 break;
589 592
590 case 'v': 593 case 'v':
591 vflag = true; 594 vflag = true;
592 break; 595 break;
593 596

cvs diff -r1.16 -r1.17 src/sbin/ifconfig/tunnel.c (expand / switch to unified diff)

--- src/sbin/ifconfig/tunnel.c 2008/07/15 21:27:58 1.16
+++ src/sbin/ifconfig/tunnel.c 2009/08/07 18:53:37 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tunnel.c,v 1.16 2008/07/15 21:27:58 dyoung Exp $ */ 1/* $NetBSD: tunnel.c,v 1.17 2009/08/07 18:53:37 dyoung Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1983, 1993 4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF  28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__RCSID("$NetBSD: tunnel.c,v 1.16 2008/07/15 21:27:58 dyoung Exp $"); 34__RCSID("$NetBSD: tunnel.c,v 1.17 2009/08/07 18:53:37 dyoung Exp $");
35#endif /* not lint */ 35#endif /* not lint */
36 36
37#include <sys/param.h>  37#include <sys/param.h>
38#include <sys/ioctl.h>  38#include <sys/ioctl.h>
39#include <sys/socket.h> 39#include <sys/socket.h>
40 40
41#include <net/if.h>  41#include <net/if.h>
42 42
43#ifdef INET6 43#ifdef INET6
44#include <netinet/in.h> 44#include <netinet/in.h>
45#endif 45#endif
46 46
47#include <ctype.h> 47#include <ctype.h>
@@ -147,27 +147,27 @@ deletetunnel(prop_dictionary_t env, prop @@ -147,27 +147,27 @@ deletetunnel(prop_dictionary_t env, prop
147{ 147{
148 if (indirect_ioctl(env, SIOCDIFPHYADDR, NULL) == -1) 148 if (indirect_ioctl(env, SIOCDIFPHYADDR, NULL) == -1)
149 err(EXIT_FAILURE, "SIOCDIFPHYADDR"); 149 err(EXIT_FAILURE, "SIOCDIFPHYADDR");
150 return 0; 150 return 0;
151} 151}
152 152
153static void 153static void
154tunnel_status(prop_dictionary_t env, prop_dictionary_t oenv) 154tunnel_status(prop_dictionary_t env, prop_dictionary_t oenv)
155{ 155{
156 char dstserv[sizeof(",65535")]; 156 char dstserv[sizeof(",65535")];
157 char srcserv[sizeof(",65535")]; 157 char srcserv[sizeof(",65535")];
158 char psrcaddr[NI_MAXHOST]; 158 char psrcaddr[NI_MAXHOST];
159 char pdstaddr[NI_MAXHOST]; 159 char pdstaddr[NI_MAXHOST];
160 const int niflag = NI_NUMERICHOST|NI_NUMERICSERV; 160 const int niflag = Nflag ? 0 : (NI_NUMERICHOST|NI_NUMERICSERV);
161 struct if_laddrreq req; 161 struct if_laddrreq req;
162 const struct afswtch *afp; 162 const struct afswtch *afp;
163 163
164 psrcaddr[0] = pdstaddr[0] = '\0'; 164 psrcaddr[0] = pdstaddr[0] = '\0';
165 165
166 memset(&req, 0, sizeof(req)); 166 memset(&req, 0, sizeof(req));
167 if (direct_ioctl(env, SIOCGLIFPHYADDR, &req) == -1) 167 if (direct_ioctl(env, SIOCGLIFPHYADDR, &req) == -1)
168 return; 168 return;
169 afp = lookup_af_bynum(req.addr.ss_family); 169 afp = lookup_af_bynum(req.addr.ss_family);
170#ifdef INET6 170#ifdef INET6
171 if (req.addr.ss_family == AF_INET6) 171 if (req.addr.ss_family == AF_INET6)
172 in6_fillscopeid((struct sockaddr_in6 *)&req.addr); 172 in6_fillscopeid((struct sockaddr_in6 *)&req.addr);
173#endif /* INET6 */ 173#endif /* INET6 */

cvs diff -r1.11 -r1.12 src/sbin/ifconfig/util.c (expand / switch to unified diff)

--- src/sbin/ifconfig/util.c 2009/04/27 20:10:49 1.11
+++ src/sbin/ifconfig/util.c 2009/08/07 18:53:37 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: util.c,v 1.11 2009/04/27 20:10:49 dyoung Exp $ */ 1/* $NetBSD: util.c,v 1.12 2009/08/07 18:53:37 dyoung Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 David Young. All rights reserved. 4 * Copyright (c) 2008 David Young. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -17,51 +17,52 @@ @@ -17,51 +17,52 @@
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29#ifndef lint 29#ifndef lint
30__RCSID("$NetBSD: util.c,v 1.11 2009/04/27 20:10:49 dyoung Exp $"); 30__RCSID("$NetBSD: util.c,v 1.12 2009/08/07 18:53:37 dyoung Exp $");
31#endif /* not lint */ 31#endif /* not lint */
32 32
33#include <ctype.h> 33#include <ctype.h>
34#include <err.h> 34#include <err.h>
35#include <errno.h> 35#include <errno.h>
36#include <netdb.h> 36#include <netdb.h>
37#include <stddef.h> 37#include <stddef.h>
38#include <stdio.h> 38#include <stdio.h>
39#include <stdlib.h> 39#include <stdlib.h>
40#include <string.h> 40#include <string.h>
41#include <unistd.h> 41#include <unistd.h>
42#include <util.h> 42#include <util.h>
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <sys/socket.h> 46#include <sys/socket.h>
47#include <ifaddrs.h> 47#include <ifaddrs.h>
48 48
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <net/if.h> 50#include <net/if.h>
51#include <net/if_dl.h> 51#include <net/if_dl.h>
52#include <netinet/in.h> /* XXX */ 52#include <netinet/in.h> /* XXX */
53 53
54#include "env.h" 54#include "env.h"
 55#include "extern.h"
55#include "util.h" 56#include "util.h"
56 57
57int 58int
58getsock(int naf) 59getsock(int naf)
59{ 60{
60 static int oaf = -1, s; 61 static int oaf = -1, s;
61 62
62 if (oaf == naf || (oaf != -1 && naf == AF_UNSPEC)) 63 if (oaf == naf || (oaf != -1 && naf == AF_UNSPEC))
63 return s; 64 return s;
64 65
65 if (oaf != -1) 66 if (oaf != -1)
66 close(s); 67 close(s);
67 68
@@ -269,27 +270,28 @@ print_link_addresses(prop_dictionary_t e @@ -269,27 +270,28 @@ print_link_addresses(prop_dictionary_t e
269 270
270 memcpy(&iflr.addr, ifa->ifa_addr, MIN(ifa->ifa_addr->sa_len, 271 memcpy(&iflr.addr, ifa->ifa_addr, MIN(ifa->ifa_addr->sa_len,
271 sizeof(iflr.addr))); 272 sizeof(iflr.addr)));
272 iflr.flags = IFLR_PREFIX; 273 iflr.flags = IFLR_PREFIX;
273 iflr.prefixlen = sdl->sdl_alen * NBBY; 274 iflr.prefixlen = sdl->sdl_alen * NBBY;
274 275
275 if (ioctl(s, SIOCGLIFADDR, &iflr) == -1) 276 if (ioctl(s, SIOCGLIFADDR, &iflr) == -1)
276 err(EXIT_FAILURE, "%s: ioctl", __func__); 277 err(EXIT_FAILURE, "%s: ioctl", __func__);
277 278
278 if (((iflr.flags & IFLR_ACTIVE) != 0) != print_active_only) 279 if (((iflr.flags & IFLR_ACTIVE) != 0) != print_active_only)
279 continue; 280 continue;
280 281
281 if (getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len, 282 if (getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len,
282 hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) == 0 && 283 hbuf, sizeof(hbuf), NULL, 0,
 284 Nflag ? 0 : NI_NUMERICHOST) == 0 &&
283 hbuf[0] != '\0') { 285 hbuf[0] != '\0') {
284 printf("\t%s %s\n", 286 printf("\t%s %s\n",
285 print_active_only ? "address:" : "link", hbuf); 287 print_active_only ? "address:" : "link", hbuf);
286 } 288 }
287 } 289 }
288 freeifaddrs(ifap); 290 freeifaddrs(ifap);
289} 291}
290 292
291#ifdef INET6 293#ifdef INET6
292/* KAME idiosyncrasy */ 294/* KAME idiosyncrasy */
293void 295void
294in6_fillscopeid(struct sockaddr_in6 *sin6) 296in6_fillscopeid(struct sockaddr_in6 *sin6)
295{ 297{