Module Name:    src
Committed By:   pooka
Date:           Mon Dec 13 21:15:31 UTC 2010

Modified Files:
        src/distrib/sets/lists/base: mi
        src/distrib/sets/lists/comp: mi
        src/usr.bin/netstat: Makefile bpf.c if.c inet.c inet6.c main.c mbuf.c
            show.c unix.c
Added Files:
        src/usr.bin/netstat: netstat_hostops.c netstat_rumpops.c prog_ops.h

Log Message:
Add netstat rump client.  For now, it always sets -X, i.e. will
use only sysctl and no kvm (implementing /dev/mem for a rump kernel
would probably not be hard, but still a non-zero effort).

Note: since there is absolutely no network activity in a fresh rump
kernel, rump.netstat usually displays exactly nothing when invoked
without parameters.  Arguments like -r, -bi, -p icmp etc. produce
more stuff.


To generate a diff of this commit:
cvs rdiff -u -r1.903 -r1.904 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1540 -r1.1541 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/netstat/Makefile \
    src/usr.bin/netstat/mbuf.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/netstat/bpf.c
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/netstat/if.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/netstat/inet.c
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/netstat/inet6.c
cvs rdiff -u -r1.76 -r1.77 src/usr.bin/netstat/main.c
cvs rdiff -u -r0 -r1.1 src/usr.bin/netstat/netstat_hostops.c \
    src/usr.bin/netstat/netstat_rumpops.c src/usr.bin/netstat/prog_ops.h
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/netstat/show.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/netstat/unix.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.903 src/distrib/sets/lists/base/mi:1.904
--- src/distrib/sets/lists/base/mi:1.903	Mon Dec 13 20:51:11 2010
+++ src/distrib/sets/lists/base/mi	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.903 2010/12/13 20:51:11 pooka Exp $
+# $NetBSD: mi,v 1.904 2010/12/13 21:15:30 pooka Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -534,6 +534,7 @@
 ./usr/bin/netpgpkeys				base-crypto-bin		crypto
 ./usr/bin/netpgpverify				base-crypto-bin		crypto
 ./usr/bin/netstat				base-netutil-bin
+./usr/bin/rump.netstat				base-netutil-bin
 ./usr/bin/newaliases				base-mailwrapper-bin
 ./usr/bin/newgrp				base-util-bin
 ./usr/bin/newsyslog				base-util-bin

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1540 src/distrib/sets/lists/comp/mi:1.1541
--- src/distrib/sets/lists/comp/mi:1.1540	Mon Dec 13 20:51:11 2010
+++ src/distrib/sets/lists/comp/mi	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1540 2010/12/13 20:51:11 pooka Exp $
+#	$NetBSD: mi,v 1.1541 2010/12/13 21:15:30 pooka Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3271,6 +3271,7 @@
 ./usr/libdata/debug/usr/bin/netpgpkeys.debug	comp-crypto-debug	crypto,debug
 ./usr/libdata/debug/usr/bin/netpgpverify.debug	comp-crypto-debug	crypto,debug
 ./usr/libdata/debug/usr/bin/netstat.debug	comp-netutil-debug	debug
+./usr/libdata/debug/usr/bin/rump.netstat.debug	comp-netutil-debug	debug
 ./usr/libdata/debug/usr/bin/newgrp.debug	comp-util-debug		debug
 ./usr/libdata/debug/usr/bin/newsyslog.debug	comp-util-debug		debug
 ./usr/libdata/debug/usr/bin/nfsstat.debug	comp-nfsclient-debug	debug

Index: src/usr.bin/netstat/Makefile
diff -u src/usr.bin/netstat/Makefile:1.29 src/usr.bin/netstat/Makefile:1.30
--- src/usr.bin/netstat/Makefile:1.29	Mon Sep 14 10:36:50 2009
+++ src/usr.bin/netstat/Makefile	Mon Dec 13 21:15:30 2010
@@ -1,11 +1,11 @@
-#	$NetBSD: Makefile,v 1.29 2009/09/14 10:36:50 degroote Exp $
+#	$NetBSD: Makefile,v 1.30 2010/12/13 21:15:30 pooka Exp $
 #	from: @(#)Makefile	8.1 (Berkeley) 6/12/93
 
 .include <bsd.own.mk>
 
 USE_FORT?= yes	# setgid
 
-PROG=	netstat
+RUMPPRG=netstat
 SRCS=	atalk.c bpf.c fast_ipsec.c if.c inet.c inet6.c ipsec.c iso.c \
 	main.c mbuf.c mroute.c mroute6.c show.c route.c tp_astring.c \
 	unix.c
@@ -17,6 +17,12 @@
 CPPFLAGS+= -DIPSEC
 CPPFLAGS+= -I${NETBSDSRCDIR}/sys/dist/pf
 
+.PATH:  ${.CURDIR}/../../lib/libc/gen
+.PATH:  ${.CURDIR}/../../lib/libc/net
+CPPFLAGS+= -DRUMP_ACTION
+RUMPSRCS+= sysctlbyname.c sysctlgetmibinfo.c sysctlnametomib.c
+RUMPSRCS+= if_indextoname.c getifaddrs.c
+
 .if (${USE_INET6} != "no")
 CPPFLAGS+= -DINET6
 .endif
Index: src/usr.bin/netstat/mbuf.c
diff -u src/usr.bin/netstat/mbuf.c:1.29 src/usr.bin/netstat/mbuf.c:1.30
--- src/usr.bin/netstat/mbuf.c:1.29	Sun Apr 12 16:08:37 2009
+++ src/usr.bin/netstat/mbuf.c	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.c,v 1.29 2009/04/12 16:08:37 lukem Exp $	*/
+/*	$NetBSD: mbuf.c,v 1.30 2010/12/13 21:15:30 pooka Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)mbuf.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: mbuf.c,v 1.29 2009/04/12 16:08:37 lukem Exp $");
+__RCSID("$NetBSD: mbuf.c,v 1.30 2010/12/13 21:15:30 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -55,6 +55,7 @@
 #include <err.h>
 #include <stdbool.h>
 #include "netstat.h"
+#include "prog_ops.h"
 
 #define	YES	1
 
@@ -109,7 +110,7 @@
 
 	if (use_sysctl) {
 		size_t mbstatlen = sizeof(mbstat);
-		if (sysctl(mbstats_ctl,
+		if (prog_sysctl(mbstats_ctl,
 			    sizeof(mbstats_ctl) / sizeof(mbstats_ctl[0]),
 			    &mbstat, &mbstatlen, NULL, 0) < 0) {
 			warn("mbstat: sysctl failed");
@@ -202,8 +203,9 @@
 	if (!use_sysctl)
 		return;
 
-	if (sysctl(mowners_ctl, sizeof(mowners_ctl)/sizeof(mowners_ctl[0]),
-		    NULL, &len, NULL, 0) < 0) {
+	if (prog_sysctl(mowners_ctl,
+	    sizeof(mowners_ctl)/sizeof(mowners_ctl[0]),
+	    NULL, &len, NULL, 0) < 0) {
 		if (errno == ENOENT)
 			return;
 		warn("mowners: sysctl test");
@@ -216,8 +218,9 @@
 		return;
 	}
 
-	if (sysctl(mowners_ctl, sizeof(mowners_ctl)/sizeof(mowners_ctl[0]),
-		    data, &len, NULL, 0) < 0) {
+	if (prog_sysctl(mowners_ctl,
+	    sizeof(mowners_ctl)/sizeof(mowners_ctl[0]),
+	    data, &len, NULL, 0) < 0) {
 		warn("mowners: sysctl get");
 		free(data);
 		return;

Index: src/usr.bin/netstat/bpf.c
diff -u src/usr.bin/netstat/bpf.c:1.9 src/usr.bin/netstat/bpf.c:1.10
--- src/usr.bin/netstat/bpf.c:1.9	Sun Apr 12 16:08:37 2009
+++ src/usr.bin/netstat/bpf.c	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.9 2009/04/12 16:08:37 lukem Exp $	*/
+/*	$NetBSD: bpf.c,v 1.10 2010/12/13 21:15:30 pooka Exp $	*/
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -44,6 +44,7 @@
 #include <net/bpfdesc.h>
 #include <net/bpf.h>
 #include "netstat.h"
+#include "prog_ops.h"
 
 void
 bpf_stats(void)
@@ -92,7 +93,8 @@
 		v = NULL;
 		sz = 0;
 		do {
-			rc = sysctl(&name[0], namelen, v, &sz, NULL, 0);
+			rc = prog_sysctl(&name[0], namelen,
+			    v, &sz, NULL, 0);
 			if (rc == -1 && errno != ENOMEM)
 				err(1, "sysctl: net.bpf.peers");
 			if (rc == -1 && v != NULL) {
@@ -158,7 +160,7 @@
 			name[namelen++] = szproc;
 			name[namelen++] = 1;
 
-			if (sysctl(&name[0], namelen, &p, &szproc, 
+			if (prog_sysctl(&name[0], namelen, &p, &szproc, 
 			    NULL, 0) == -1)
 				printf("-\n");
 			else

Index: src/usr.bin/netstat/if.c
diff -u src/usr.bin/netstat/if.c:1.69 src/usr.bin/netstat/if.c:1.70
--- src/usr.bin/netstat/if.c:1.69	Fri Jul  9 07:04:30 2010
+++ src/usr.bin/netstat/if.c	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.69 2010/07/09 07:04:30 enami Exp $	*/
+/*	$NetBSD: if.c,v 1.70 2010/12/13 21:15:30 pooka 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.69 2010/07/09 07:04:30 enami Exp $");
+__RCSID("$NetBSD: if.c,v 1.70 2010/12/13 21:15:30 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -65,6 +65,7 @@
 #include <err.h>
 
 #include "netstat.h"
+#include "prog_ops.h"
 
 #define	MAXIF	100
 
@@ -163,11 +164,11 @@
 	size_t len;
 	char name[IFNAMSIZ + 1];	/* + 1 for `*' */
 
-	if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1)
+	if (prog_sysctl(mib, 6, NULL, &len, NULL, 0) == -1)
 		err(1, "sysctl");
 	if ((buf = malloc(len)) == NULL)
 		err(1, NULL);
-	if (sysctl(mib, 6, buf, &len, NULL, 0) == -1)
+	if (prog_sysctl(mib, 6, buf, &len, NULL, 0) == -1)
 		err(1, "sysctl");
 
 	intpr_header();
@@ -983,11 +984,11 @@
 	char name[IFNAMSIZ];
 	size_t len;
 
-	if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1)
+	if (prog_sysctl(mib, 6, NULL, &len, NULL, 0) == -1)
 		err(1, "sysctl");
 	if ((buf = malloc(len)) == NULL)
 		err(1, NULL);
-	if (sysctl(mib, 6, buf, &len, NULL, 0) == -1)
+	if (prog_sysctl(mib, 6, buf, &len, NULL, 0) == -1)
 		err(1, "sysctl");
 
 	lim = buf + len;

Index: src/usr.bin/netstat/inet.c
diff -u src/usr.bin/netstat/inet.c:1.92 src/usr.bin/netstat/inet.c:1.93
--- src/usr.bin/netstat/inet.c:1.92	Mon Dec  7 18:48:45 2009
+++ src/usr.bin/netstat/inet.c	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet.c,v 1.92 2009/12/07 18:48:45 christos Exp $	*/
+/*	$NetBSD: inet.c,v 1.93 2010/12/13 21:15:30 pooka Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet.c,v 1.92 2009/12/07 18:48:45 christos Exp $");
+__RCSID("$NetBSD: inet.c,v 1.93 2010/12/13 21:15:30 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -88,6 +88,7 @@
 #include <stdlib.h>
 #include <err.h>
 #include "netstat.h"
+#include "prog_ops.h"
 
 char	*inetname(struct in_addr *);
 void	inetprint(struct in_addr *, u_int16_t, const char *, int);
@@ -194,8 +195,8 @@
 		if (sysctlnametomib(mibname, mib, &namelen) == -1)
 			err(1, "sysctlnametomib: %s", mibname);
 
-		if (sysctl(mib, sizeof(mib) / sizeof(*mib), NULL, &size,
-			   NULL, 0) == -1)
+		if (prog_sysctl(mib, sizeof(mib) / sizeof(*mib),
+		    NULL, &size, NULL, 0) == -1)
 			err(1, "sysctl (query)");
 
 		if ((pcblist = malloc(size)) == NULL)
@@ -205,8 +206,8 @@
 	        mib[6] = sizeof(*pcblist);
         	mib[7] = size / sizeof(*pcblist);
 
-		if (sysctl(mib, sizeof(mib) / sizeof(*mib), pcblist,
-			   &size, NULL, 0) == -1)
+		if (prog_sysctl(mib, sizeof(mib) / sizeof(*mib),
+		    pcblist, &size, NULL, 0) == -1)
 			err(1, "sysctl (copy)");
 
 		for (i = 0; i < size / sizeof(*pcblist); i++) {

Index: src/usr.bin/netstat/inet6.c
diff -u src/usr.bin/netstat/inet6.c:1.52 src/usr.bin/netstat/inet6.c:1.53
--- src/usr.bin/netstat/inet6.c:1.52	Sun Apr 12 16:08:37 2009
+++ src/usr.bin/netstat/inet6.c	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet6.c,v 1.52 2009/04/12 16:08:37 lukem Exp $	*/
+/*	$NetBSD: inet6.c,v 1.53 2010/12/13 21:15:30 pooka 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.52 2009/04/12 16:08:37 lukem Exp $");
+__RCSID("$NetBSD: inet6.c,v 1.53 2010/12/13 21:15:30 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -129,6 +129,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "netstat.h"
+#include "prog_ops.h"
 
 #ifdef INET6
 
@@ -252,8 +253,8 @@
 			err(1, "sysctlnametomib: %s", mibname);
 		}
 
-		if (sysctl(mib, sizeof(mib) / sizeof(*mib), NULL, &size,
-		    NULL, 0) == -1)
+		if (prog_sysctl(mib, sizeof(mib) / sizeof(*mib),
+		    NULL, &size, NULL, 0) == -1)
 			err(1, "sysctl (query)");
 		
 		if ((pcblist = malloc(size)) == NULL)
@@ -263,7 +264,7 @@
 		mib[6] = sizeof(*pcblist);
 		mib[7] = size / sizeof(*pcblist);
 
-		if (sysctl(mib, sizeof(mib) / sizeof(*mib), pcblist,
+		if (prog_sysctl(mib, sizeof(mib) / sizeof(*mib), pcblist,
 		    &size, NULL, 0) == -1)
 			err(1, "sysctl (copy)");
 

Index: src/usr.bin/netstat/main.c
diff -u src/usr.bin/netstat/main.c:1.76 src/usr.bin/netstat/main.c:1.77
--- src/usr.bin/netstat/main.c:1.76	Tue Jun 29 12:38:12 2010
+++ src/usr.bin/netstat/main.c	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.76 2010/06/29 12:38:12 kefren Exp $	*/
+/*	$NetBSD: main.c,v 1.77 2010/12/13 21:15:30 pooka 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.76 2010/06/29 12:38:12 kefren Exp $");
+__RCSID("$NetBSD: main.c,v 1.77 2010/12/13 21:15:30 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -64,6 +64,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "netstat.h"
+#include "prog_ops.h"
 
 struct nlist nl[] = {
 #define	N_MBSTAT	0
@@ -422,6 +423,12 @@
 	char *cp;
 	u_long pcbaddr;
 
+	if (prog_init) {
+		if (prog_init() == -1)
+			err(1, "init failed");
+		force_sysctl = 1; /* cheap trick */
+	}
+
 	egid = getegid();
 	(void)setegid(getgid());
 	tp = NULL;

Index: src/usr.bin/netstat/show.c
diff -u src/usr.bin/netstat/show.c:1.10 src/usr.bin/netstat/show.c:1.11
--- src/usr.bin/netstat/show.c:1.10	Sun Jun 27 06:52:38 2010
+++ src/usr.bin/netstat/show.c	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: show.c,v 1.10 2010/06/27 06:52:38 kefren Exp $	*/
+/*	$NetBSD: show.c,v 1.11 2010/12/13 21:15:30 pooka Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -57,6 +57,7 @@
 #include <unistd.h>
 
 #include "netstat.h"
+#include "prog_ops.h"
 
 char	*any_ntoa(const struct sockaddr *);
 char	*link_print(struct sockaddr *);
@@ -123,12 +124,12 @@
 	mib[3] = paf;
 	mib[4] = NET_RT_DUMP;
 	mib[5] = 0;
-	if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
+	if (prog_sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
 		err(1, "route-sysctl-estimate");
 	if (needed > 0) {
 		if ((buf = malloc(needed)) == 0)
 			err(1, NULL);
-		if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
+		if (prog_sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
 			err(1, "sysctl of routing table");
 		lim = buf + needed;
 	}
@@ -157,7 +158,7 @@
 	mib[3] = NET_KEY_SPD_DUMP;
 	mib[4] = mib[5] = 0;
 
-	if (sysctl(mib, 4, NULL, &needed, NULL, 0) == -1) {
+	if (prog_sysctl(mib, 4, NULL, &needed, NULL, 0) == -1) {
 		if (errno == ENOPROTOOPT)
 			return;
 		err(1, "spd-sysctl-estimate");
@@ -165,7 +166,7 @@
 	if (needed > 0) {
 		if ((buf = malloc(needed)) == 0)
 			err(1, NULL);
-		if (sysctl(mib, 4, buf, &needed, NULL, 0) == -1)
+		if (prog_sysctl(mib, 4, buf, &needed, NULL, 0) == -1)
 			err(1,"sysctl of spd");
 		lim = buf + needed;
 	}

Index: src/usr.bin/netstat/unix.c
diff -u src/usr.bin/netstat/unix.c:1.30 src/usr.bin/netstat/unix.c:1.31
--- src/usr.bin/netstat/unix.c:1.30	Thu Apr 22 14:37:06 2010
+++ src/usr.bin/netstat/unix.c	Mon Dec 13 21:15:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: unix.c,v 1.30 2010/04/22 14:37:06 plunky Exp $	*/
+/*	$NetBSD: unix.c,v 1.31 2010/12/13 21:15:30 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)unix.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: unix.c,v 1.30 2010/04/22 14:37:06 plunky Exp $");
+__RCSID("$NetBSD: unix.c,v 1.31 2010/12/13 21:15:30 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -64,6 +64,7 @@
 #include <kvm.h>
 #include <err.h>
 #include "netstat.h"
+#include "prog_ops.h"
 
 static	void unixdomainprhdr(void);
 static	void unixdomainpr0(u_long, u_long, u_long, u_long, u_long, u_long,
@@ -163,8 +164,8 @@
 				    &namelen) == -1)
 			err(1, "sysctlnametomib: %s", mibname);
 
-		if (sysctl(mib, sizeof(mib) / sizeof(*mib), NULL, &size,
-			   NULL, 0) == -1)
+		if (prog_sysctl(mib, sizeof(mib) / sizeof(*mib),
+		    NULL, &size, NULL, 0) == -1)
 			err(1, "sysctl (query)");
 
 		if ((pcblist = malloc(size)) == NULL)
@@ -174,7 +175,7 @@
 		mib[6] = sizeof(*pcblist);
 		mib[7] = size / sizeof(*pcblist);
 
-		if (sysctl(mib, sizeof(mib) / sizeof(*mib), pcblist,
+		if (prog_sysctl(mib, sizeof(mib) / sizeof(*mib), pcblist,
 			   &size, NULL, 0) == -1)
 			err(1, "sysctl (copy)");
 

Added files:

Index: src/usr.bin/netstat/netstat_hostops.c
diff -u /dev/null src/usr.bin/netstat/netstat_hostops.c:1.1
--- /dev/null	Mon Dec 13 21:15:31 2010
+++ src/usr.bin/netstat/netstat_hostops.c	Mon Dec 13 21:15:30 2010
@@ -0,0 +1,41 @@
+/*	$NetBSD: netstat_hostops.c,v 1.1 2010/12/13 21:15:30 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: netstat_hostops.c,v 1.1 2010/12/13 21:15:30 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_sysctl = sysctl,
+};
Index: src/usr.bin/netstat/netstat_rumpops.c
diff -u /dev/null src/usr.bin/netstat/netstat_rumpops.c:1.1
--- /dev/null	Mon Dec 13 21:15:31 2010
+++ src/usr.bin/netstat/netstat_rumpops.c	Mon Dec 13 21:15:30 2010
@@ -0,0 +1,46 @@
+/*	$NetBSD: netstat_rumpops.c,v 1.1 2010/12/13 21:15:30 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: netstat_rumpops.c,v 1.1 2010/12/13 21:15:30 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+
+#include <rump/rump.h>
+#include <rump/rumpclient.h>
+#include <rump/rump_syscalls.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_init =	rumpclient_init,
+
+	.op_sysctl =	rump_sys___sysctl,
+};
Index: src/usr.bin/netstat/prog_ops.h
diff -u /dev/null src/usr.bin/netstat/prog_ops.h:1.1
--- /dev/null	Mon Dec 13 21:15:31 2010
+++ src/usr.bin/netstat/prog_ops.h	Mon Dec 13 21:15:30 2010
@@ -0,0 +1,45 @@
+/*      $NetBSD: prog_ops.h,v 1.1 2010/12/13 21:15:30 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _PROG_OPS_H_
+#define _PROG_OPS_H_
+
+#include <sys/types.h>
+
+struct prog_ops {
+	int (*op_init)(void);
+
+	int (*op_sysctl)(const int *, u_int, void *, size_t *,
+			 const void *, size_t);
+};
+extern const struct prog_ops prog_ops;
+
+#define prog_init prog_ops.op_init
+#define prog_sysctl prog_ops.op_sysctl
+
+#endif /* _PROG_OPS_H_ */

Reply via email to