summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/netstat.h
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-07-16 17:15:55 +0000
committerjhb <jhb@FreeBSD.org>2007-07-16 17:15:55 +0000
commit27187e7f6bd04a94e9ada0ca994e7c828abb4514 (patch)
tree165174828db97bceab2299030940226f1b6620cf /usr.bin/netstat/netstat.h
parent5a67dd7c20118e6593c9e3904b775b2274c2757b (diff)
downloadFreeBSD-src-27187e7f6bd04a94e9ada0ca994e7c828abb4514.zip
FreeBSD-src-27187e7f6bd04a94e9ada0ca994e7c828abb4514.tar.gz
Restore netstat -M functionality for most statistics on core dumps. In
general, when support was added to netstat for fetching data using sysctl, no provision was left for fetching equivalent data from a core dump, and in fact, netstat would _always_ fetch data from the live kernel using sysctl even when -M was specified resulting in the user believing they were getting data from coredumps when they actually weren't. Some specific changes: - Add a global 'live' variable that is true if netstat is running against the live kernel and false if -M has been specified. - Stop abusing the sysctl flag in the protocol tables to hold the protocol number. Instead, the protocol is now its own field in the tables, and it is passed as a separate parameter to the PCB and stat routines rather than overloading the KVM offset parameter. - Don't run PCB or stats functions who don't have a namelist offset if we are being run against a crash dump (!live). - For the inet and unix PCB routines, we generate the same buffer from KVM that the sysctl usually generates complete with the header and trailer. - Don't run bpf stats for !live (before it would just silently always run live). - kread() no longer trashes memory when opening the buffer if there is an error on open and the passed in buffer is smaller than _POSIX2_LINE_MAX. - The multicast routing code doesn't fallback to kvm on live kernels if the sysctl fails. Keeping this made the code rather hairy, and netstat is already tied to the kernel ABI anyway (even when using sysctl's since things like xinpcb contain an inpcb) so any kernels this is run against that have the multicast routing stuff should have the sysctls. - Don't try to dig around in the kernel linker in the netgraph PCB routine for core dumps. Other notes: - sctp's PCB routine only works on live kernels, it looked rather complicated to generate all the same stuff via KVM. Someone can always add it later if desired though. - Fix the ipsec removal bug where N_xxx for IPSEC stats weren't renumbered. - Use sysctlbyname() everywhere rather than hardcoded mib values. MFC after: 1 week Approved by: re (rwatson)
Diffstat (limited to 'usr.bin/netstat/netstat.h')
-rw-r--r--usr.bin/netstat/netstat.h78
1 files changed, 40 insertions, 38 deletions
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index a2df187..0c6f733 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -59,39 +59,41 @@ extern char *interface; /* desired i/f for stats, or NULL for all i/fs */
extern int unit; /* unit number for above */
extern int af; /* address family */
+extern int live; /* true if we are examining a live system */
-int kread(u_long addr, char *buf, int size);
+int kread(u_long addr, void *buf, size_t size);
const char *plural(uintmax_t);
const char *plurales(uintmax_t);
const char *pluralies(uintmax_t);
-void protopr(u_long, const char *, int);
-void tcp_stats(u_long, const char *, int);
-void udp_stats(u_long, const char *, int);
+int sotoxsocket(struct socket *, struct xsocket *);
+void protopr(u_long, const char *, int, int);
+void tcp_stats(u_long, const char *, int, int);
+void udp_stats(u_long, const char *, int, int);
#ifdef SCTP
-void sctp_protopr(u_long, const char *, int);
-void sctp_stats(u_long, const char *, int);
+void sctp_protopr(u_long, const char *, int, int);
+void sctp_stats(u_long, const char *, int, int);
#endif
-void ip_stats(u_long, const char *, int);
-void icmp_stats(u_long, const char *, int);
-void igmp_stats(u_long, const char *, int);
-void pim_stats(u_long, const char *, int);
-void carp_stats (u_long, const char *, int);
-void pfsync_stats (u_long, const char *, int);
+void ip_stats(u_long, const char *, int, int);
+void icmp_stats(u_long, const char *, int, int);
+void igmp_stats(u_long, const char *, int, int);
+void pim_stats(u_long, const char *, int, int);
+void carp_stats (u_long, const char *, int, int);
+void pfsync_stats (u_long, const char *, int, int);
#ifdef IPSEC
-void ipsec_stats(u_long, const char *, int);
-void esp_stats (u_long, const char *, int);
-void ah_stats (u_long, const char *, int);
-void ipcomp_stats (u_long, const char *, int);
+void ipsec_stats(u_long, const char *, int, int);
+void esp_stats (u_long, const char *, int, int);
+void ah_stats (u_long, const char *, int, int);
+void ipcomp_stats (u_long, const char *, int, int);
#endif
#ifdef INET6
-void ip6_stats(u_long, const char *, int);
+void ip6_stats(u_long, const char *, int, int);
void ip6_ifstats(char *);
-void icmp6_stats(u_long, const char *, int);
+void icmp6_stats(u_long, const char *, int, int);
void icmp6_ifstats(char *);
-void pim6_stats(u_long, const char *, int);
-void rip6_stats(u_long, const char *, int);
+void pim6_stats(u_long, const char *, int, int);
+void rip6_stats(u_long, const char *, int, int);
void mroute6pr(u_long, u_long);
void mrt6_stats(u_long);
@@ -103,7 +105,7 @@ void inet6print(struct in6_addr *, int, const char *, int);
#endif /*INET6*/
#ifdef IPSEC
-void pfkey_stats(u_long, const char *, int);
+void pfkey_stats(u_long, const char *, int, int);
#endif
void mbpr(void *, u_long);
@@ -129,29 +131,29 @@ char *ipx_print(struct sockaddr *);
char *ns_print(struct sockaddr *);
void routepr(u_long);
-void ipxprotopr(u_long, const char *, int);
-void spx_stats(u_long, const char *, int);
-void ipx_stats(u_long, const char *, int);
-void ipxerr_stats(u_long, const char *, int);
+void ipxprotopr(u_long, const char *, int, int);
+void spx_stats(u_long, const char *, int, int);
+void ipx_stats(u_long, const char *, int, int);
+void ipxerr_stats(u_long, const char *, int, int);
-void nsprotopr(u_long, const char *, int);
-void spp_stats(u_long, const char *, int);
-void idp_stats(u_long, const char *, int);
-void nserr_stats(u_long, const char *, int);
+void nsprotopr(u_long, const char *, int, int);
+void spp_stats(u_long, const char *, int, int);
+void idp_stats(u_long, const char *, int, int);
+void nserr_stats(u_long, const char *, int, int);
-void atalkprotopr(u_long, const char *, int);
-void ddp_stats(u_long, const char *, int);
+void atalkprotopr(u_long, const char *, int, int);
+void ddp_stats(u_long, const char *, int, int);
-void netgraphprotopr(u_long, const char *, int);
+void netgraphprotopr(u_long, const char *, int, int);
-void unixpr(void);
+void unixpr(u_long, u_long, u_long, u_long);
-void esis_stats(u_long, const char *, int);
-void clnp_stats(u_long, const char *, int);
-void cltp_stats(u_long, const char *, int);
-void iso_protopr(u_long, const char *, int);
+void esis_stats(u_long, const char *, int, int);
+void clnp_stats(u_long, const char *, int, int);
+void cltp_stats(u_long, const char *, int, int);
+void iso_protopr(u_long, const char *, int, int);
void iso_protopr1(u_long, int);
-void tp_protopr(u_long, const char *, int);
+void tp_protopr(u_long, const char *, int, int);
void tp_inproto(u_long);
void tp_stats(caddr_t, caddr_t);
OpenPOWER on IntegriCloud