systat.h revision 77583
1157184Sache/*- 2157184Sache * Copyright (c) 1980, 1989, 1992, 1993 3157184Sache * The Regents of the University of California. All rights reserved. 4157184Sache * 5157184Sache * Redistribution and use in source and binary forms, with or without 6157184Sache * modification, are permitted provided that the following conditions 7157184Sache * are met: 8157184Sache * 1. Redistributions of source code must retain the above copyright 9157184Sache * notice, this list of conditions and the following disclaimer. 10157184Sache * 2. Redistributions in binary form must reproduce the above copyright 11157184Sache * notice, this list of conditions and the following disclaimer in the 12157184Sache * documentation and/or other materials provided with the distribution. 13157184Sache * 3. All advertising materials mentioning features or use of this software 14157184Sache * must display the following acknowledgement: 15157184Sache * This product includes software developed by the University of 16157184Sache * California, Berkeley and its contributors. 17157184Sache * 4. Neither the name of the University nor the names of its contributors 18157184Sache * may be used to endorse or promote products derived from this software 19157184Sache * without specific prior written permission. 20157184Sache * 21157184Sache * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22157184Sache * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23157184Sache * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24157184Sache * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25157184Sache * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26157184Sache * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27157184Sache * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28157184Sache * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29157184Sache * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30157184Sache * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31157184Sache * SUCH DAMAGE. 32157184Sache * 33157184Sache * From: @(#)systat.h 8.1 (Berkeley) 6/6/93 34157184Sache * $FreeBSD: head/usr.bin/systat/systat.h 77583 2001-06-01 13:29:19Z tmm $ 35157184Sache */ 36157184Sache 37157184Sache#include <curses.h> 38157184Sache 39157184Sachestruct cmdtab { 40157184Sache char *c_name; /* command name */ 41157184Sache void (*c_refresh)(void); /* display refresh */ 42157184Sache void (*c_fetch)(void); /* sets up data structures */ 43157184Sache void (*c_label)(void); /* label display */ 44157184Sache int (*c_init)(void); /* initialize namelist, etc. */ 45157184Sache WINDOW *(*c_open)(void); /* open display */ 46157184Sache void (*c_close)(WINDOW *); /* close display */ 47157184Sache int (*c_cmd)(char *, char *); /* display command interpreter */ 48157184Sache void (*c_reset)(void); /* reset ``mode since'' display */ 49157184Sache char c_flags; /* see below */ 50157184Sache}; 51157184Sache 52157184Sache/* 53157184Sache * If we are started with privileges, use a kmem interface for netstat handling, 54157184Sache * otherwise use sysctl. 55157184Sache * In case of many open sockets, the sysctl handling might become slow. 56157184Sache */ 57157184Sacheextern int use_kvm; 58157184Sache 59157184Sache#define CF_INIT 0x1 /* been initialized */ 60157184Sache#define CF_LOADAV 0x2 /* display w/ load average */ 61157184Sache 62157184Sache#define TCP 0x1 63157184Sache#define UDP 0x2 64157184Sache 65157184Sache#define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) 66157184Sache#define KREAD(addr, buf, len) kvm_ckread((addr), (buf), (len)) 67157184Sache#define NVAL(indx) namelist[(indx)].n_value 68157184Sache#define NPTR(indx) (void *)NVAL((indx)) 69157184Sache#define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len)) 70157184Sache