Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/netstat use the common code from route.c



details:   https://anonhg.NetBSD.org/src/rev/ffdbfa9f7191
branches:  trunk
changeset: 333516:ffdbfa9f7191
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 06 21:30:09 2014 +0000

description:
use the common code from route.c

diffstat:

 usr.bin/netstat/Makefile  |   10 +-
 usr.bin/netstat/if.c      |   15 +-
 usr.bin/netstat/main.c    |    9 +-
 usr.bin/netstat/mroute.c  |   13 +-
 usr.bin/netstat/mroute6.c |    7 +-
 usr.bin/netstat/netstat.h |   22 +-
 usr.bin/netstat/route.c   |   43 +-
 usr.bin/netstat/show.c    |  727 ----------------------------------------------
 8 files changed, 44 insertions(+), 802 deletions(-)

diffs (truncated from 1114 to 300 lines):

diff -r 0f7f4ab55822 -r ffdbfa9f7191 usr.bin/netstat/Makefile
--- a/usr.bin/netstat/Makefile  Thu Nov 06 21:29:32 2014 +0000
+++ b/usr.bin/netstat/Makefile  Thu Nov 06 21:30:09 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.39 2013/03/01 18:26:11 joerg Exp $
+#      $NetBSD: Makefile,v 1.40 2014/11/06 21:30:09 christos Exp $
 #      from: @(#)Makefile      8.1 (Berkeley) 6/12/93
 
 .include <bsd.own.mk>
@@ -7,20 +7,22 @@
 
 RUMPPRG=netstat
 SRCS=  atalk.c bpf.c fast_ipsec.c if.c inet.c inet6.c \
-       main.c mbuf.c mroute.c mroute6.c pfkey.c pfsync.c show.c route.c \
-       unix.c vtw.c
+       main.c mbuf.c mroute.c mroute6.c pfkey.c pfsync.c route.c \
+       unix.c vtw.c rtutil.c
 BINGRP=        kmem
 BINMODE=2555
 LDADD= -lkvm
 DPADD= ${LIBKVM}
-CPPFLAGS+= -DIPSEC
+CPPFLAGS+= -DIPSEC -I${.CURDIR}
 CPPFLAGS+= -I${NETBSDSRCDIR}/sys/dist/pf
+CPPFLAGS+= -I${NETBSDSRCDIR}/sbin/route
 
 CWARNFLAGS.clang+=     -Wno-format
 COPTS.show.c += -Wno-format-nonliteral
 
 .PATH:  ${.CURDIR}/../../lib/libc/gen
 .PATH:  ${.CURDIR}/../../lib/libc/net
+.PATH:  ${.CURDIR}/../../sbin/route
 CPPFLAGS+= -DRUMP_ACTION
 RUMPSRCS+= sysctlbyname.c sysctlgetmibinfo.c sysctlnametomib.c
 RUMPSRCS+= if_indextoname.c getifaddrs.c
diff -r 0f7f4ab55822 -r ffdbfa9f7191 usr.bin/netstat/if.c
--- a/usr.bin/netstat/if.c      Thu Nov 06 21:29:32 2014 +0000
+++ b/usr.bin/netstat/if.c      Thu Nov 06 21:30:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.79 2013/10/19 15:56:06 christos Exp $ */
+/*     $NetBSD: if.c,v 1.80 2014/11/06 21:30:09 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.79 2013/10/19 15:56:06 christos Exp $");
+__RCSID("$NetBSD: if.c,v 1.80 2014/11/06 21:30:09 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -63,6 +63,7 @@
 #include <err.h>
 
 #include "netstat.h"
+#include "rtutil.h"
 #include "prog_ops.h"
 
 #define        MAXIF   100
@@ -356,7 +357,7 @@
                in = inet_makeaddr(ifaddr.in.ia_subnet,
                        INADDR_ANY);
                cp = netname4(in.s_addr,
-                       ifaddr.in.ia_subnetmask);
+                       ifaddr.in.ia_subnetmask, nflag);
 #else
                if (use_sysctl) {
                        netmask = ((struct sockaddr_in *)rtinfo[RTAX_NETMASK])->sin_addr.s_addr;
@@ -364,14 +365,14 @@
                        struct in_ifaddr *ifaddr_in = (void *)rtinfo;
                        netmask = ifaddr_in->ia_subnetmask;
                }
-               cp = netname4(sin->sin_addr.s_addr, netmask);
+               cp = netname4(sin->sin_addr.s_addr, netmask, nflag);
 #endif
                if (vflag)
                        n = strlen(cp) < 13 ? 13 : strlen(cp);
                else
                        n = 13;
                printf("%-*.*s ", n, n, cp);
-               cp = routename4(sin->sin_addr.s_addr);
+               cp = routename4(sin->sin_addr.s_addr, nflag);
                if (vflag)
                        n = strlen(cp) < 17 ? 17 : strlen(cp);
                else
@@ -390,7 +391,7 @@
                                   sizeof inm);
                                printf("\n%25s %-17.17s ", "",
                                   routename4(
-                                     inm.inm_addr.s_addr));
+                                     inm.inm_addr.s_addr, nflag));
                                multiaddr =
                                   (u_long)inm.inm_list.le_next;
                        }
@@ -412,7 +413,7 @@
                        netmask6 = &ifaddr_in6->ia_prefixmask;
                }
 
-               cp = netname6(sin6, netmask6);
+               cp = netname6(sin6, netmask6, nflag);
                if (vflag)
                        n = strlen(cp) < 13 ? 13 : strlen(cp);
                else
diff -r 0f7f4ab55822 -r ffdbfa9f7191 usr.bin/netstat/main.c
--- a/usr.bin/netstat/main.c    Thu Nov 06 21:29:32 2014 +0000
+++ b/usr.bin/netstat/main.c    Thu Nov 06 21:30:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.92 2014/10/09 23:45:47 enami Exp $  */
+/*     $NetBSD: main.c,v 1.93 2014/11/06 21:30:09 christos Exp $       */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "from: @(#)main.c       8.4 (Berkeley) 3/1/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.92 2014/10/09 23:45:47 enami Exp $");
+__RCSID("$NetBSD: main.c,v 1.93 2014/11/06 21:30:09 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -64,6 +64,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "netstat.h"
+#include "rtutil.h"
 #include "prog_ops.h"
 
 struct nlist nl[] = {
@@ -468,7 +469,7 @@
                        nlistf = optarg;
                        break;
                case 'n':
-                       numeric_addr = numeric_port = nflag = 1;
+                       numeric_addr = numeric_port = nflag = RT_NFLAG;
                        break;
                case 'P':
                        errno = 0;
@@ -637,7 +638,7 @@
                                rt_stats(use_sysctl ? 0 : nl[N_RTSTAT].n_value);
                        else {
                                if (use_sysctl)
-                                       p_rttables(af);
+                                       p_rttables(af, nflag, 0, ~0);
                                else
                                        routepr(nl[N_RTREE].n_value);
                        }
diff -r 0f7f4ab55822 -r ffdbfa9f7191 usr.bin/netstat/mroute.c
--- a/usr.bin/netstat/mroute.c  Thu Nov 06 21:29:32 2014 +0000
+++ b/usr.bin/netstat/mroute.c  Thu Nov 06 21:30:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mroute.c,v 1.24 2012/03/20 20:34:58 matt Exp $ */
+/*     $NetBSD: mroute.c,v 1.25 2014/11/06 21:30:09 christos Exp $     */
 
 /*
  * Copyright (c) 1992, 1993
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "from: @(#)mroute.c     8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: mroute.c,v 1.24 2012/03/20 20:34:58 matt Exp $");
+__RCSID("$NetBSD: mroute.c,v 1.25 2014/11/06 21:30:09 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -103,6 +103,7 @@
 #include <stdlib.h>
 #include <kvm.h>
 #include "netstat.h"
+#include "rtutil.h"
 
 static char *pktscale(u_long);
 static void print_bw_meter(struct bw_meter *, int *);
@@ -196,9 +197,9 @@
 
                printf(" %3u     %3u  %5u  %-15.15s",
                    vifi, v->v_threshold, v->v_rate_limit,
-                   routename4(v->v_lcl_addr.s_addr));
+                   routename4(v->v_lcl_addr.s_addr, nflag));
                printf("  %-15.15s  %6lu  %7lu\n", (v->v_flags & VIFF_TUNNEL) ?
-                   routename4(v->v_rmt_addr.s_addr) : "",
+                   routename4(v->v_rmt_addr.s_addr, nflag) : "",
                    v->v_pkt_in, v->v_pkt_out);
        }
        if (!banner_printed)
@@ -223,9 +224,9 @@
 
                        kread((u_long)mfcp, (char *)&mfc, sizeof(mfc));
                        printf("  %3lu  %-15.15s",
-                           i, routename4(mfc.mfc_origin.s_addr));
+                           i, routename4(mfc.mfc_origin.s_addr, nflag));
                        printf("  %-15.15s  %7s     %3u ",
-                           routename4(mfc.mfc_mcastgrp.s_addr),
+                           routename4(mfc.mfc_mcastgrp.s_addr, nflag),
                            pktscale(mfc.mfc_pkt_cnt), mfc.mfc_parent);
                        for (vifi = 0; vifi <= numvifs; ++vifi)
                                if (mfc.mfc_ttls[vifi])
diff -r 0f7f4ab55822 -r ffdbfa9f7191 usr.bin/netstat/mroute6.c
--- a/usr.bin/netstat/mroute6.c Thu Nov 06 21:29:32 2014 +0000
+++ b/usr.bin/netstat/mroute6.c Thu Nov 06 21:30:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mroute6.c,v 1.14 2013/10/18 20:26:45 christos Exp $    */
+/*     $NetBSD: mroute6.c,v 1.15 2014/11/06 21:30:09 christos Exp $    */
 
 /*
  * Copyright (C) 1998 WIDE Project.
@@ -117,6 +117,7 @@
 #include <stdio.h>
 #include <kvm.h>
 #include "netstat.h"
+#include "rtutil.h"
 
 #ifdef INET6
 
@@ -212,9 +213,9 @@
                        }
                        
                        printf(" %-*.*s", WID_ORG, WID_ORG,
-                           routename6(&mfc.mf6c_origin));
+                           routename6(&mfc.mf6c_origin, nflag));
                        printf(" %-*.*s", WID_GRP, WID_GRP,
-                           routename6(&mfc.mf6c_mcastgrp));
+                           routename6(&mfc.mf6c_mcastgrp, nflag));
                        printf(" %9llu", (unsigned long long)mfc.mf6c_pkt_cnt);
 
                        for (waitings = 0, rtep = mfc.mf6c_stall; rtep; ) {
diff -r 0f7f4ab55822 -r ffdbfa9f7191 usr.bin/netstat/netstat.h
--- a/usr.bin/netstat/netstat.h Thu Nov 06 21:29:32 2014 +0000
+++ b/usr.bin/netstat/netstat.h Thu Nov 06 21:30:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netstat.h,v 1.50 2014/04/28 15:41:15 christos Exp $    */
+/*     $NetBSD: netstat.h,v 1.51 2014/11/06 21:30:09 christos Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -102,7 +102,6 @@
 void   rip6_stats(u_long, const char *);
 void   mroute6pr(u_long, u_long, u_long);
 void   mrt6_stats(u_long, u_long);
-char   *routename6(struct sockaddr_in6 *);
 #endif /*INET6*/
 
 #ifdef IPSEC
@@ -114,28 +113,9 @@
 void   hostpr(u_long, u_long);
 void   impstats(u_long, u_long);
 
-void   pr_rthdr(int, int);
-void   pr_family(int);
-struct rt_metrics;
-void   pr_rtrmx(struct rt_metrics *);
 void   rt_stats(u_long);
 char   *ns_phost(struct sockaddr *);
 
-void   p_rttables(int);
-void   p_flags(int, const char *);
-void   p_addr(struct sockaddr *, struct sockaddr *, int);
-void   p_gwaddr(struct sockaddr *, int);
-void   p_sockaddr(struct sockaddr *, struct sockaddr *, int, int);
-char   *routename(struct sockaddr *);
-char   *routename4(in_addr_t);
-char   *netname(struct sockaddr *, struct sockaddr *);
-char   *netname4(in_addr_t, in_addr_t);
-
-/* char        *routename(u_int32_t); */
-/* char        *netname(u_int32_t, u_int32_t); */
-#ifdef INET6
-char   *netname6(struct sockaddr_in6 *, struct sockaddr_in6 *);
-#endif 
 const char *atalk_print(const struct sockaddr *, int);
 const char *atalk_print2(const struct sockaddr *, const struct sockaddr *,
     int);
diff -r 0f7f4ab55822 -r ffdbfa9f7191 usr.bin/netstat/route.c
--- a/usr.bin/netstat/route.c   Thu Nov 06 21:29:32 2014 +0000
+++ b/usr.bin/netstat/route.c   Thu Nov 06 21:30:09 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.82 2014/04/28 15:41:15 christos Exp $      */
+/*     $NetBSD: route.c,v 1.83 2014/11/06 21:30:09 christos Exp $      */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)route.c      8.3 (Berkeley) 3/9/94";
 #else
-__RCSID("$NetBSD: route.c,v 1.82 2014/04/28 15:41:15 christos Exp $");
+__RCSID("$NetBSD: route.c,v 1.83 2014/11/06 21:30:09 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -66,6 +66,7 @@
 #include <unistd.h>
 
 #include "netstat.h"
+#include "rtutil.h"
 
 #define kget(p, d) (kread((u_long)(p), (char *)&(d), sizeof (d)))
 



Home | Main Index | Thread Index | Old Index