10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*8275SEric Cheng * Common Development and Distribution License (the "License"). 6*8275SEric Cheng * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*8275SEric Cheng * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_EXACCT_IMPL_H 270Sstevel@tonic-gate #define _SYS_EXACCT_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifdef __cplusplus 300Sstevel@tonic-gate extern "C" { 310Sstevel@tonic-gate #endif 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <sys/types.h> 340Sstevel@tonic-gate #include <sys/utsname.h> 350Sstevel@tonic-gate #include <sys/zone.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate /* 380Sstevel@tonic-gate * Setting the exacct error code. libexacct provides more detailed codes for 390Sstevel@tonic-gate * identifying causes of operational failure; the kernel doesn't use this 400Sstevel@tonic-gate * facility, since the kernel operations can't fail. (KM_SLEEP allocations, 410Sstevel@tonic-gate * for instance.) 420Sstevel@tonic-gate */ 430Sstevel@tonic-gate #ifdef _KERNEL 440Sstevel@tonic-gate #define EXACCT_SET_ERR(x) 450Sstevel@tonic-gate #else /* _KERNEL */ 460Sstevel@tonic-gate extern void exacct_seterr(int); 470Sstevel@tonic-gate #define EXACCT_SET_ERR(x) exacct_seterr(x) 480Sstevel@tonic-gate #endif /* _KERNEL */ 490Sstevel@tonic-gate 500Sstevel@tonic-gate typedef struct task_usage { 510Sstevel@tonic-gate hrtime_t tu_utime; /* user time */ 520Sstevel@tonic-gate hrtime_t tu_stime; /* system time */ 530Sstevel@tonic-gate 540Sstevel@tonic-gate uint64_t tu_minflt; /* minor faults */ 550Sstevel@tonic-gate uint64_t tu_majflt; /* major faults */ 560Sstevel@tonic-gate uint64_t tu_sndmsg; /* messages sent */ 570Sstevel@tonic-gate uint64_t tu_rcvmsg; /* messages received */ 580Sstevel@tonic-gate uint64_t tu_ioch; /* characters read and written */ 590Sstevel@tonic-gate uint64_t tu_iblk; /* input blocks */ 600Sstevel@tonic-gate uint64_t tu_oblk; /* output blocks */ 610Sstevel@tonic-gate uint64_t tu_vcsw; /* voluntary context switches */ 620Sstevel@tonic-gate uint64_t tu_icsw; /* involuntary context switches */ 630Sstevel@tonic-gate uint64_t tu_nsig; /* signals received */ 640Sstevel@tonic-gate uint64_t tu_nswp; /* swaps */ 650Sstevel@tonic-gate uint64_t tu_nscl; /* system calls */ 660Sstevel@tonic-gate uint64_t tu_startsec; /* start time (seconds) */ 670Sstevel@tonic-gate uint64_t tu_startnsec; /* start time (nanoseconds) */ 680Sstevel@tonic-gate uint64_t tu_finishsec; /* finish time (seconds) */ 690Sstevel@tonic-gate uint64_t tu_finishnsec; /* finish time (nanoseconds) */ 700Sstevel@tonic-gate taskid_t tu_anctaskid; /* ancestor task's ID */ 710Sstevel@tonic-gate } task_usage_t; 720Sstevel@tonic-gate 730Sstevel@tonic-gate typedef struct proc_usage { 740Sstevel@tonic-gate uint64_t pu_minflt; /* minor faults */ 750Sstevel@tonic-gate uint64_t pu_majflt; /* major faults */ 760Sstevel@tonic-gate uint64_t pu_sndmsg; /* messages sent */ 770Sstevel@tonic-gate uint64_t pu_rcvmsg; /* messages received */ 780Sstevel@tonic-gate uint64_t pu_ioch; /* characters read and written */ 790Sstevel@tonic-gate uint64_t pu_iblk; /* input blocks */ 800Sstevel@tonic-gate uint64_t pu_oblk; /* output blocks */ 810Sstevel@tonic-gate uint64_t pu_vcsw; /* voluntary context switches */ 820Sstevel@tonic-gate uint64_t pu_icsw; /* involuntary context switches */ 830Sstevel@tonic-gate uint64_t pu_nsig; /* signals received */ 840Sstevel@tonic-gate uint64_t pu_nswp; /* swaps */ 850Sstevel@tonic-gate uint64_t pu_nscl; /* system calls */ 860Sstevel@tonic-gate uint64_t pu_utimesec; /* user time (seconds) */ 870Sstevel@tonic-gate uint64_t pu_utimensec; /* user time (nanoseconds) */ 880Sstevel@tonic-gate uint64_t pu_stimesec; /* system time (seconds) */ 890Sstevel@tonic-gate uint64_t pu_stimensec; /* system time (nanoseconds) */ 900Sstevel@tonic-gate uint64_t pu_startsec; /* start time (seconds) */ 910Sstevel@tonic-gate uint64_t pu_startnsec; /* start time (nanoseconds) */ 920Sstevel@tonic-gate uint64_t pu_finishsec; /* finish time (seconds) */ 930Sstevel@tonic-gate uint64_t pu_finishnsec; /* finish time (nanoseconds) */ 940Sstevel@tonic-gate uint64_t pu_mem_rss_avg; /* average RSS (K) */ 950Sstevel@tonic-gate uint64_t pu_mem_rss_max; /* peak RSS (K) */ 960Sstevel@tonic-gate 970Sstevel@tonic-gate pid_t pu_pid; /* process ID */ 980Sstevel@tonic-gate uid_t pu_ruid; /* user ID */ 990Sstevel@tonic-gate gid_t pu_rgid; /* group ID */ 1000Sstevel@tonic-gate projid_t pu_projid; /* project ID */ 1010Sstevel@tonic-gate taskid_t pu_taskid; /* task ID */ 1020Sstevel@tonic-gate uint32_t pu_acflag; /* accounting flags */ 1030Sstevel@tonic-gate char *pu_command; /* command string */ 1040Sstevel@tonic-gate uint32_t pu_major; /* major number of controlling tty */ 1050Sstevel@tonic-gate uint32_t pu_minor; /* minor number of controlling tty */ 1060Sstevel@tonic-gate int pu_wstat; /* wait() status */ 1070Sstevel@tonic-gate pid_t pu_ancpid; /* ancestor process's ID */ 1080Sstevel@tonic-gate char pu_zonename[ZONENAME_MAX]; /* Zone name */ 1090Sstevel@tonic-gate char pu_nodename[_SYS_NMLN]; 1100Sstevel@tonic-gate } proc_usage_t; 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate typedef struct flow_usage { 1130Sstevel@tonic-gate uint32_t fu_saddr[4]; /* source address */ 1140Sstevel@tonic-gate uint32_t fu_daddr[4]; /* remote address */ 1150Sstevel@tonic-gate uint8_t fu_protocol; /* protocol type */ 1160Sstevel@tonic-gate uint16_t fu_sport; /* source port */ 1170Sstevel@tonic-gate uint16_t fu_dport; /* remote port */ 1180Sstevel@tonic-gate uint8_t fu_dsfield; /* DS field */ 1190Sstevel@tonic-gate uint32_t fu_nbytes; /* number of bytes (incl. IP header) */ 1200Sstevel@tonic-gate uint32_t fu_npackets; /* number of packets */ 1210Sstevel@tonic-gate uint64_t fu_ctime; /* creation time for this item */ 1220Sstevel@tonic-gate uint64_t fu_lseen; /* when the last item of this desc. was seen */ 1230Sstevel@tonic-gate projid_t fu_projid; /* project ID */ 1240Sstevel@tonic-gate uid_t fu_userid; /* user ID */ 1250Sstevel@tonic-gate boolean_t fu_isv4; /* to extract the correct l/r-addr */ 1260Sstevel@tonic-gate char *fu_aname; /* action instance name */ 1270Sstevel@tonic-gate } flow_usage_t; 1280Sstevel@tonic-gate 129*8275SEric Cheng #define EX_NET_LNDESC_REC 1 130*8275SEric Cheng #define EX_NET_FLDESC_REC 2 131*8275SEric Cheng #define EX_NET_LNSTAT_REC 3 132*8275SEric Cheng #define EX_NET_FLSTAT_REC 4 133*8275SEric Cheng 134*8275SEric Cheng typedef struct net_stat_s { 135*8275SEric Cheng char *ns_name; 136*8275SEric Cheng uint64_t ns_ibytes; 137*8275SEric Cheng uint64_t ns_obytes; 138*8275SEric Cheng uint64_t ns_ipackets; 139*8275SEric Cheng uint64_t ns_opackets; 140*8275SEric Cheng uint64_t ns_ierrors; 141*8275SEric Cheng uint64_t ns_oerrors; 142*8275SEric Cheng boolean_t ns_isref; 143*8275SEric Cheng } net_stat_t; 144*8275SEric Cheng 145*8275SEric Cheng typedef struct net_desc_s { 146*8275SEric Cheng char *nd_name; 147*8275SEric Cheng char *nd_devname; 148*8275SEric Cheng uchar_t nd_ehost[6]; 149*8275SEric Cheng uchar_t nd_edest[6]; 150*8275SEric Cheng ushort_t nd_vlan_tpid; 151*8275SEric Cheng ushort_t nd_vlan_tci; 152*8275SEric Cheng ushort_t nd_sap; 153*8275SEric Cheng ushort_t nd_priority; 154*8275SEric Cheng uint64_t nd_bw_limit; 155*8275SEric Cheng uint32_t nd_saddr[4]; 156*8275SEric Cheng uint32_t nd_daddr[4]; 157*8275SEric Cheng boolean_t nd_isv4; 158*8275SEric Cheng uint16_t nd_sport; 159*8275SEric Cheng uint16_t nd_dport; 160*8275SEric Cheng uint8_t nd_protocol; 161*8275SEric Cheng uint8_t nd_dsfield; 162*8275SEric Cheng int nd_type; 163*8275SEric Cheng } net_desc_t; 164*8275SEric Cheng 1650Sstevel@tonic-gate extern void exacct_order16(uint16_t *); 1660Sstevel@tonic-gate extern void exacct_order32(uint32_t *); 1670Sstevel@tonic-gate extern void exacct_order64(uint64_t *); 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate #ifdef __cplusplus 1700Sstevel@tonic-gate } 1710Sstevel@tonic-gate #endif 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate #endif /* _SYS_EXACCT_IMPL_H */ 174