11590Srgrimes/*- 21590Srgrimes * Copyright (c) 1980, 1989, 1992, 1993 31590Srgrimes * The Regents of the University of California. All rights reserved. 41590Srgrimes * 51590Srgrimes * Redistribution and use in source and binary forms, with or without 61590Srgrimes * modification, are permitted provided that the following conditions 71590Srgrimes * are met: 81590Srgrimes * 1. Redistributions of source code must retain the above copyright 91590Srgrimes * notice, this list of conditions and the following disclaimer. 101590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111590Srgrimes * notice, this list of conditions and the following disclaimer in the 121590Srgrimes * documentation and/or other materials provided with the distribution. 131590Srgrimes * 4. Neither the name of the University nor the names of its contributors 141590Srgrimes * may be used to endorse or promote products derived from this software 151590Srgrimes * without specific prior written permission. 161590Srgrimes * 171590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201590Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271590Srgrimes * SUCH DAMAGE. 281590Srgrimes * 2929759Swollman * From: @(#)systat.h 8.1 (Berkeley) 6/6/93 3050477Speter * $FreeBSD$ 311590Srgrimes */ 321590Srgrimes 331590Srgrimes#include <curses.h> 341590Srgrimes 351590Srgrimesstruct cmdtab { 36226396Sed const char *c_name; /* command name */ 37226396Sed void (*c_refresh)(void); /* display refresh */ 38226396Sed void (*c_fetch)(void); /* sets up data structures */ 39226396Sed void (*c_label)(void); /* label display */ 4029759Swollman int (*c_init)(void); /* initialize namelist, etc. */ 4129759Swollman WINDOW *(*c_open)(void); /* open display */ 4229759Swollman void (*c_close)(WINDOW *); /* close display */ 4387715Smarkm int (*c_cmd)(const char *, const char *); /* display command interpreter */ 4429759Swollman void (*c_reset)(void); /* reset ``mode since'' display */ 451590Srgrimes char c_flags; /* see below */ 461590Srgrimes}; 471590Srgrimes 48158161Sbde/* 4974671Stmm * If we are started with privileges, use a kmem interface for netstat handling, 5074671Stmm * otherwise use sysctl. 5174671Stmm * In case of many open sockets, the sysctl handling might become slow. 5274671Stmm */ 53158161Sbdeextern int use_kvm; 5474671Stmm 551590Srgrimes#define CF_INIT 0x1 /* been initialized */ 561590Srgrimes#define CF_LOADAV 0x2 /* display w/ load average */ 571590Srgrimes 581590Srgrimes#define TCP 0x1 591590Srgrimes#define UDP 0x2 601590Srgrimes 61158160Sbde#define MAINWIN_ROW 3 /* top row for the main/lower window */ 62158160Sbde 6374671Stmm#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) 641590Srgrimes#define KREAD(addr, buf, len) kvm_ckread((addr), (buf), (len)) 651590Srgrimes#define NVAL(indx) namelist[(indx)].n_value 661590Srgrimes#define NPTR(indx) (void *)NVAL((indx)) 671590Srgrimes#define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len)) 68