1139825Simp/*- 21541Srgrimes * Copyright (c) 1989, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley by 61541Srgrimes * Mike Karels at Berkeley Software Design, Inc. 71541Srgrimes * 81541Srgrimes * Redistribution and use in source and binary forms, with or without 91541Srgrimes * modification, are permitted provided that the following conditions 101541Srgrimes * are met: 111541Srgrimes * 1. Redistributions of source code must retain the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer. 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 4. Neither the name of the University nor the names of its contributors 171541Srgrimes * may be used to endorse or promote products derived from this software 181541Srgrimes * without specific prior written permission. 191541Srgrimes * 201541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301541Srgrimes * SUCH DAMAGE. 311541Srgrimes * 321541Srgrimes * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 3350477Speter * $FreeBSD: releng/10.3/sys/sys/sysctl.h 273736 2014-10-27 14:38:00Z hselasky $ 341541Srgrimes */ 351541Srgrimes 361541Srgrimes#ifndef _SYS_SYSCTL_H_ 371541Srgrimes#define _SYS_SYSCTL_H_ 381541Srgrimes 3950520Sphk#include <sys/queue.h> 4034925Sdufault 4183366Sjulianstruct thread; 421541Srgrimes/* 431541Srgrimes * Definitions for sysctl call. The sysctl call uses a hierarchical name 441541Srgrimes * for objects that can be examined or modified. The name is expressed as 451541Srgrimes * a sequence of integers. Like a file path name, the meaning of each 461541Srgrimes * component depends on its place in the hierarchy. The top-level and kern 471541Srgrimes * identifiers are defined here, and other identifiers are defined in the 481541Srgrimes * respective subsystem header files. 491541Srgrimes */ 501541Srgrimes 51255078Spjd#define CTL_MAXNAME 24 /* largest number of components supported */ 521541Srgrimes 531541Srgrimes/* 541541Srgrimes * Each subsystem defined by sysctl defines a list of variables 558876Srgrimes * for that subsystem. Each name is either a node with further 561541Srgrimes * levels defined below it, or it is a leaf of some particular 571541Srgrimes * type given below. Each sysctl level defines a set of name/type 58122707Strhodes * pairs to be used by sysctl(8) in manipulating the subsystem. 591541Srgrimes */ 601541Srgrimesstruct ctlname { 611541Srgrimes char *ctl_name; /* subsystem name */ 62255078Spjd int ctl_type; /* type of name */ 631541Srgrimes}; 6411863Sphk 65255078Spjd#define CTLTYPE 0xf /* mask for the type */ 661541Srgrimes#define CTLTYPE_NODE 1 /* name is a node */ 671541Srgrimes#define CTLTYPE_INT 2 /* name describes an integer */ 681541Srgrimes#define CTLTYPE_STRING 3 /* name describes a string */ 69217616Smdf#define CTLTYPE_S64 4 /* name describes a signed 64-bit number */ 7011863Sphk#define CTLTYPE_OPAQUE 5 /* name describes a structure */ 7111863Sphk#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ 7278435Spirzyk#define CTLTYPE_UINT 6 /* name describes an unsigned integer */ 7378435Spirzyk#define CTLTYPE_LONG 7 /* name describes a long */ 7478435Spirzyk#define CTLTYPE_ULONG 8 /* name describes an unsigned long */ 75217616Smdf#define CTLTYPE_U64 9 /* name describes an unsigned 64-bit number */ 761541Srgrimes 77255078Spjd#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ 78255078Spjd#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ 79255078Spjd#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) 80255078Spjd#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ 81255078Spjd#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ 82255078Spjd#define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */ 83255078Spjd#define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ 84255078Spjd#define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ 85255078Spjd#define CTLMASK_SECURE 0x00F00000 /* Secure level */ 86255078Spjd#define CTLFLAG_TUN 0x00080000 /* Tunable variable */ 87244123Spjd#define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) 88244123Spjd#define CTLFLAG_RWTUN (CTLFLAG_RW|CTLFLAG_TUN) 89255078Spjd#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ 90255078Spjd#define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ 91255078Spjd#define CTLFLAG_DYING 0x00010000 /* Oid is being removed */ 92255078Spjd#define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ 93255078Spjd#define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ 94255078Spjd#define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ 95269446Shselasky#define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ 96255078Spjd#define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) 9711863Sphk 9819268Sjulian/* 99255078Spjd * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. 100109246Sdillon * 101109246Sdillon * Secure when the securelevel is raised to at least N. 102109246Sdillon */ 103255078Spjd#define CTLSHIFT_SECURE 20 104255078Spjd#define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE)) 105255078Spjd#define CTLFLAG_SECURE2 (CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE)) 106255078Spjd#define CTLFLAG_SECURE3 (CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE)) 107109246Sdillon 108109246Sdillon/* 10919268Sjulian * USE THIS instead of a hardwired number from the categories below 11019268Sjulian * to get dynamically assigned sysctl entries using the linker-set 11119268Sjulian * technology. This is the way nearly all new sysctl variables should 11234925Sdufault * be implemented. 11319268Sjulian * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); 114255078Spjd */ 115255078Spjd#define OID_AUTO (-1) 11612582Sphk 11780339Sroam/* 11880339Sroam * The starting number for dynamically-assigned entries. WARNING! 11980339Sroam * ALL static sysctl entries should have numbers LESS than this! 12080339Sroam */ 121255078Spjd#define CTL_AUTO_START 0x100 12280339Sroam 12355205Speter#ifdef _KERNEL 124217239Sjhb#include <sys/linker_set.h> 125217239Sjhb 126273736Shselasky#ifdef KLD_MODULE 127273736Shselasky/* XXX allow overspecification of type in external kernel modules */ 128273736Shselasky#define SYSCTL_CT_ASSERT_MASK CTLTYPE 129273736Shselasky#else 130273736Shselasky#define SYSCTL_CT_ASSERT_MASK 0 131273736Shselasky#endif 132273736Shselasky 133255078Spjd#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, \ 134219819Sjeff intptr_t arg2, struct sysctl_req *req 13511863Sphk 136120781Sbms/* definitions for sysctl_req 'lock' member */ 137217915Smdf#define REQ_UNWIRED 1 138217915Smdf#define REQ_WIRED 2 139120781Sbms 140136404Speter/* definitions for sysctl_req 'flags' member */ 141255078Spjd#if defined(__amd64__) || defined(__ia64__) || defined(__powerpc64__) ||\ 142255078Spjd (defined(__mips__) && defined(__mips_n64)) 143136404Speter#define SCTL_MASK32 1 /* 32 bit emulation */ 144136404Speter#endif 145136404Speter 14612243Sphk/* 14712243Sphk * This describes the access space for a sysctl request. This is needed 14812243Sphk * so that we can use the interface from the kernel or from user-space. 14912243Sphk */ 15012243Sphkstruct sysctl_req { 15186183Srwatson struct thread *td; /* used for access checking */ 152255078Spjd int lock; /* wiring state */ 15312243Sphk void *oldptr; 154255078Spjd size_t oldlen; 155255078Spjd size_t oldidx; 15638517Sdfr int (*oldfunc)(struct sysctl_req *, const void *, size_t); 15712243Sphk void *newptr; 158255078Spjd size_t newlen; 159255078Spjd size_t newidx; 16038517Sdfr int (*newfunc)(struct sysctl_req *, void *, size_t); 161255078Spjd size_t validlen; 162255078Spjd int flags; 16312243Sphk}; 16412243Sphk 16560938SjakeSLIST_HEAD(sysctl_oid_list, sysctl_oid); 16644078Sdfr 16712243Sphk/* 16812243Sphk * This describes one "oid" in the MIB tree. Potentially more nodes can 16912243Sphk * be hidden behind it, expanded by the handler. 17012243Sphk */ 17111863Sphkstruct sysctl_oid { 17244078Sdfr struct sysctl_oid_list *oid_parent; 17360938Sjake SLIST_ENTRY(sysctl_oid) oid_link; 174255078Spjd int oid_number; 175255078Spjd u_int oid_kind; 17611863Sphk void *oid_arg1; 177255078Spjd intptr_t oid_arg2; 17812623Sphk const char *oid_name; 179255078Spjd int (*oid_handler)(SYSCTL_HANDLER_ARGS); 18012623Sphk const char *oid_fmt; 181255078Spjd int oid_refcnt; 182255078Spjd u_int oid_running; 183141433Sphk const char *oid_descr; 18411863Sphk}; 18511863Sphk 186255078Spjd#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) 187255078Spjd#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) 18812243Sphk 18962573Sphkint sysctl_handle_int(SYSCTL_HANDLER_ARGS); 190155758Sandreint sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS); 19162573Sphkint sysctl_handle_long(SYSCTL_HANDLER_ARGS); 192217616Smdfint sysctl_handle_64(SYSCTL_HANDLER_ARGS); 19362573Sphkint sysctl_handle_string(SYSCTL_HANDLER_ARGS); 19462573Sphkint sysctl_handle_opaque(SYSCTL_HANDLER_ARGS); 195249268Sglebiusint sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS); 19611865Sphk 197262737Sglebiusint sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS); 198262737Sglebiusint sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS); 199262737Sglebius 200194784Sjeffint sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS); 201194935Sjeffint sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS); 202194784Sjeffint sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS); 203194784Sjeff 20444078Sdfr/* 20544078Sdfr * These functions are used to add/remove an oid from the mib. 20644078Sdfr */ 20744078Sdfrvoid sysctl_register_oid(struct sysctl_oid *oidp); 20844078Sdfrvoid sysctl_unregister_oid(struct sysctl_oid *oidp); 20944078Sdfr 21063212Sabial/* Declare a static oid to allow child oids to be added to it. */ 211255078Spjd#define SYSCTL_DECL(name) \ 21244078Sdfr extern struct sysctl_oid_list sysctl_##name##_children 21344078Sdfr 214255078Spjd/* Hide these in macros. */ 215255078Spjd#define SYSCTL_CHILDREN(oid_ptr) \ 216255078Spjd (struct sysctl_oid_list *)(oid_ptr)->oid_arg1 217269446Shselasky#define SYSCTL_PARENT(oid_ptr) NULL /* not supported */ 218255078Spjd#define SYSCTL_CHILDREN_SET(oid_ptr, val) (oid_ptr)->oid_arg1 = (val) 219255078Spjd#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl_##oid_name##_children) 22063212Sabial 221255078Spjd/* === Structs and macros related to context handling. === */ 22263212Sabial 22363212Sabial/* All dynamically created sysctls can be tracked in a context list. */ 22463212Sabialstruct sysctl_ctx_entry { 22563212Sabial struct sysctl_oid *entry; 22663212Sabial TAILQ_ENTRY(sysctl_ctx_entry) link; 22763212Sabial}; 22863212Sabial 22963212SabialTAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); 23063212Sabial 231255078Spjd#define SYSCTL_NODE_CHILDREN(parent, name) \ 232108649Sjake sysctl_##parent##_##name##_children 233108649Sjake 234160469Simp#ifndef NO_SYSCTL_DESCR 235255078Spjd#define __DESCR(d) d 236160469Simp#else 237255078Spjd#define __DESCR(d) "" 238160469Simp#endif 239160469Simp 24038859Sbde/* This constructs a "raw" MIB oid. */ 241255078Spjd#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr)\ 242255078Spjd static struct sysctl_oid sysctl__##parent##_##name = { \ 243255078Spjd &sysctl_##parent##_children, \ 244255078Spjd { NULL }, \ 245255078Spjd nbr, \ 246255078Spjd kind, \ 247255078Spjd a1, \ 248255078Spjd a2, \ 249255078Spjd #name, \ 250255078Spjd handler, \ 251255078Spjd fmt, \ 252255078Spjd 0, \ 253255078Spjd 0, \ 254255078Spjd __DESCR(descr) \ 255255078Spjd }; \ 256100113Smarkm DATA_SET(sysctl_set, sysctl__##parent##_##name) 25711863Sphk 258255078Spjd#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ 259160469Simp sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) 26063212Sabial 261269446Shselasky/* This constructs a root node from which other nodes can hang. */ 262269446Shselasky#define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ 263273736Shselasky SYSCTL_NODE(, nbr, name, access, handler, descr); \ 264273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 265273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) 266269446Shselasky 26738859Sbde/* This constructs a node from which other oids can hang. */ 268255078Spjd#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ 269108649Sjake struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); \ 270105582Sphk SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|(access), \ 271273736Shselasky (void*)&SYSCTL_NODE_CHILDREN(parent, name), 0, handler, "N", descr); \ 272273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 273273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) 27411863Sphk 275269446Shselasky#define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \ 276269446Shselasky SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(), nbr, name, access, handler, descr) 277269446Shselasky 278273736Shselasky#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ 279273736Shselasky({ \ 280273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 281273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ 282273736Shselasky sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ 283273736Shselasky NULL, 0, handler, "N", __DESCR(descr)); \ 284273736Shselasky}) 28563212Sabial 28638859Sbde/* Oid for a string. len can be 0 to indicate '\0' termination. */ 287273736Shselasky#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ 288273736Shselasky SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ 289273736Shselasky arg, len, sysctl_handle_string, "A", descr); \ 290273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 291273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) 29211863Sphk 293273736Shselasky#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ 294273736Shselasky({ \ 295273736Shselasky char *__arg = (arg); \ 296273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 297273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ 298273736Shselasky sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ 299273736Shselasky __arg, len, sysctl_handle_string, "A", __DESCR(descr)); \ 300273736Shselasky}) 30163212Sabial 302273736Shselasky/* Oid for an int. If ptr is SYSCTL_NULL_INT_PTR, val is returned. */ 303273736Shselasky#define SYSCTL_NULL_INT_PTR ((int *)NULL) 304273736Shselasky#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ 305273736Shselasky SYSCTL_OID(parent, nbr, name, \ 306273736Shselasky CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ 307273736Shselasky ptr, val, sysctl_handle_int, "I", descr); \ 308273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 309273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ 310273736Shselasky CTASSERT(sizeof(int) == sizeof(*(ptr))) 31111863Sphk 312217313Smdf#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \ 313273736Shselasky({ \ 314273736Shselasky int *__ptr = (ptr); \ 315273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 316273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ 317217313Smdf sysctl_add_oid(ctx, parent, nbr, name, \ 318217313Smdf CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ 319273736Shselasky __ptr, val, sysctl_handle_int, "I", __DESCR(descr)); \ 320273736Shselasky}) 32163212Sabial 32262622Sjhb/* Oid for an unsigned int. If ptr is NULL, val is returned. */ 323273736Shselasky#define SYSCTL_NULL_UINT_PTR ((unsigned *)NULL) 324273736Shselasky#define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ 325273736Shselasky SYSCTL_OID(parent, nbr, name, \ 326273736Shselasky CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ 327273736Shselasky ptr, val, sysctl_handle_int, "IU", descr); \ 328273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 329273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT);\ 330273736Shselasky CTASSERT(sizeof(unsigned) == sizeof(*(ptr))) 33162622Sjhb 332217313Smdf#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \ 333273736Shselasky({ \ 334273736Shselasky unsigned *__ptr = (ptr); \ 335273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 336273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT); \ 337217313Smdf sysctl_add_oid(ctx, parent, nbr, name, \ 338217313Smdf CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ 339273736Shselasky __ptr, val, sysctl_handle_int, "IU", __DESCR(descr)); \ 340273736Shselasky}) 34163212Sabial 34242095Sdfr/* Oid for a long. The pointer must be non NULL. */ 343273736Shselasky#define SYSCTL_NULL_LONG_PTR ((long *)NULL) 344273736Shselasky#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ 345273736Shselasky SYSCTL_OID(parent, nbr, name, \ 346273736Shselasky CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ 347273736Shselasky ptr, val, sysctl_handle_long, "L", descr); \ 348273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 349273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG);\ 350273736Shselasky CTASSERT(sizeof(long) == sizeof(*(ptr))) 35138517Sdfr 352217313Smdf#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \ 353273736Shselasky({ \ 354273736Shselasky long *__ptr = (ptr); \ 355273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 356273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG); \ 357217313Smdf sysctl_add_oid(ctx, parent, nbr, name, \ 358217313Smdf CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ 359273736Shselasky __ptr, 0, sysctl_handle_long, "L", __DESCR(descr)); \ 360273736Shselasky}) 36163212Sabial 362112744Srobert/* Oid for an unsigned long. The pointer must be non NULL. */ 363273736Shselasky#define SYSCTL_NULL_ULONG_PTR ((unsigned long *)NULL) 364217313Smdf#define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \ 365217313Smdf SYSCTL_OID(parent, nbr, name, \ 366217313Smdf CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ 367273736Shselasky ptr, val, sysctl_handle_long, "LU", descr); \ 368273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 369273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG); \ 370273736Shselasky CTASSERT(sizeof(unsigned long) == sizeof(*(ptr))) 37162622Sjhb 372217313Smdf#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \ 373273736Shselasky({ \ 374273736Shselasky unsigned long *__ptr = (ptr); \ 375273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 376273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG); \ 377217313Smdf sysctl_add_oid(ctx, parent, nbr, name, \ 378217313Smdf CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ 379273736Shselasky __ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)); \ 380273736Shselasky}) 38163212Sabial 382180661Spjd/* Oid for a quad. The pointer must be non NULL. */ 383273736Shselasky#define SYSCTL_NULL_QUAD_PTR ((int64_t *)NULL) 384273736Shselasky#define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \ 385273736Shselasky SYSCTL_OID(parent, nbr, name, \ 386273736Shselasky CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ 387273736Shselasky ptr, val, sysctl_handle_64, "Q", descr); \ 388273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 389273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ 390273736Shselasky CTASSERT(sizeof(int64_t) == sizeof(*(ptr))) 391180661Spjd 392217313Smdf#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \ 393273736Shselasky({ \ 394273736Shselasky int64_t *__ptr = (ptr); \ 395273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 396273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ 397217313Smdf sysctl_add_oid(ctx, parent, nbr, name, \ 398217616Smdf CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ 399273736Shselasky __ptr, 0, sysctl_handle_64, "Q", __DESCR(descr)); \ 400273736Shselasky}) 401180661Spjd 402273736Shselasky#define SYSCTL_NULL_UQUAD_PTR ((uint64_t *)NULL) 403217313Smdf#define SYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr) \ 404217313Smdf SYSCTL_OID(parent, nbr, name, \ 405217616Smdf CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 406273736Shselasky ptr, val, sysctl_handle_64, "QU", descr); \ 407273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 408273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ 409273736Shselasky CTASSERT(sizeof(uint64_t) == sizeof(*(ptr))) 410217313Smdf 411217313Smdf#define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr) \ 412273736Shselasky({ \ 413273736Shselasky uint64_t *__ptr = (ptr); \ 414273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 415273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ 416217313Smdf sysctl_add_oid(ctx, parent, nbr, name, \ 417217616Smdf CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 418273736Shselasky __ptr, 0, sysctl_handle_64, "QU", __DESCR(descr)); \ 419273736Shselasky}) 420217313Smdf 421273736Shselasky/* Oid for a CPU dependant variable */ 422273736Shselasky#define SYSCTL_ADD_UAUTO(ctx, parent, nbr, name, access, ptr, descr) \ 423273736Shselasky({ \ 424273736Shselasky struct sysctl_oid *__ret; \ 425273736Shselasky CTASSERT(sizeof(uint64_t) == sizeof(*(ptr)) || \ 426273736Shselasky sizeof(unsigned) == sizeof(*(ptr))); \ 427273736Shselasky CTASSERT(((access) & CTLTYPE) == 0); \ 428273736Shselasky if (sizeof(uint64_t) == sizeof(*(ptr))) { \ 429273736Shselasky __ret = sysctl_add_oid(ctx, parent, nbr, name, \ 430273736Shselasky CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 431273736Shselasky (ptr), 0, sysctl_handle_64, "QU", \ 432273736Shselasky __DESCR(descr)); \ 433273736Shselasky } else { \ 434273736Shselasky __ret = sysctl_add_oid(ctx, parent, nbr, name, \ 435273736Shselasky CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ 436273736Shselasky (ptr), 0, sysctl_handle_int, "IU", \ 437273736Shselasky __DESCR(descr)); \ 438273736Shselasky } \ 439273736Shselasky __ret; \ 440273736Shselasky}) 441273736Shselasky 442255496Sjhb/* Oid for a 64-bit unsigned counter(9). The pointer must be non NULL. */ 443262738Sglebius#define SYSCTL_COUNTER_U64(parent, nbr, name, access, ptr, descr) \ 444249268Sglebius SYSCTL_OID(parent, nbr, name, \ 445249268Sglebius CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 446273736Shselasky (ptr), 0, sysctl_handle_counter_u64, "QU", descr); \ 447273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 448273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ 449273736Shselasky CTASSERT(sizeof(counter_u64_t) == sizeof(*(ptr))); \ 450273736Shselasky CTASSERT(sizeof(uint64_t) == sizeof(**(ptr))) 451249268Sglebius 452273736Shselasky#define SYSCTL_ADD_COUNTER_U64(ctx, parent, nbr, name, access, ptr, descr) \ 453273736Shselasky({ \ 454273736Shselasky counter_u64_t *__ptr = (ptr); \ 455273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 456273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ 457249268Sglebius sysctl_add_oid(ctx, parent, nbr, name, \ 458249268Sglebius CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 459273736Shselasky __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr)); \ 460273736Shselasky}) 461249268Sglebius 46238859Sbde/* Oid for an opaque object. Specified by a pointer and a length. */ 463273736Shselasky#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ 464273736Shselasky SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ 465273736Shselasky ptr, len, sysctl_handle_opaque, fmt, descr); \ 466273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 467273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) 46811863Sphk 469273736Shselasky#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \ 470273736Shselasky({ \ 471273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 472273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ 473273736Shselasky sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ 474273736Shselasky ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr)); \ 475273736Shselasky}) 47663212Sabial 47738859Sbde/* Oid for a struct. Specified by a pointer and a type. */ 478273736Shselasky#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ 479273736Shselasky SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ 480273736Shselasky ptr, sizeof(struct type), sysctl_handle_opaque, \ 481273736Shselasky "S," #type, descr); \ 482273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 483273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) 48411863Sphk 485255078Spjd#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \ 486273736Shselasky({ \ 487273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 488273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ 489273736Shselasky sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ 490273736Shselasky (ptr), sizeof(struct type), \ 491273736Shselasky sysctl_handle_opaque, "S," #type, __DESCR(descr)); \ 492273736Shselasky}) 49363212Sabial 49438859Sbde/* Oid for a procedure. Specified by a pointer and an arg. */ 495255078Spjd#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ 496273736Shselasky SYSCTL_OID(parent, nbr, name, (access), \ 497273736Shselasky ptr, arg, handler, fmt, descr); \ 498273736Shselasky CTASSERT(((access) & CTLTYPE) != 0) 49963212Sabial 500255078Spjd#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ 501273736Shselasky({ \ 502273736Shselasky CTASSERT(((access) & CTLTYPE) != 0); \ 503273736Shselasky sysctl_add_oid(ctx, parent, nbr, name, (access), \ 504273736Shselasky (ptr), (arg), (handler), (fmt), __DESCR(descr)); \ 505273736Shselasky}) 50663212Sabial 507262737Sglebius/* Oid to handle limits on uma(9) zone specified by pointer. */ 508273736Shselasky#define SYSCTL_UMA_MAX(parent, nbr, name, access, ptr, descr) \ 509273736Shselasky SYSCTL_OID(parent, nbr, name, \ 510273736Shselasky CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ 511273736Shselasky (ptr), 0, sysctl_handle_uma_zone_max, "I", descr); \ 512273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 513273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) 514273736Shselasky 515273736Shselasky#define SYSCTL_ADD_UMA_MAX(ctx, parent, nbr, name, access, ptr, descr) \ 516273736Shselasky({ \ 517273736Shselasky uma_zone_t __ptr = (ptr); \ 518273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 519273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ 520262737Sglebius sysctl_add_oid(ctx, parent, nbr, name, \ 521262737Sglebius CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ 522273736Shselasky __ptr, 0, sysctl_handle_uma_zone_max, "I", __DESCR(descr)); \ 523273736Shselasky}) 524262737Sglebius 525262737Sglebius/* Oid to obtain current use of uma(9) zone specified by pointer. */ 526262737Sglebius#define SYSCTL_UMA_CUR(parent, nbr, name, access, ptr, descr) \ 527262737Sglebius SYSCTL_OID(parent, nbr, name, \ 528262737Sglebius CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 529273736Shselasky (ptr), 0, sysctl_handle_uma_zone_cur, "I", descr); \ 530273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 531273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) 532273736Shselasky 533262737Sglebius#define SYSCTL_ADD_UMA_CUR(ctx, parent, nbr, name, access, ptr, descr) \ 534273736Shselasky({ \ 535273736Shselasky uma_zone_t __ptr = (ptr); \ 536273736Shselasky CTASSERT(((access) & CTLTYPE) == 0 || \ 537273736Shselasky ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ 538262737Sglebius sysctl_add_oid(ctx, parent, nbr, name, \ 539262737Sglebius CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 540273736Shselasky __ptr, 0, sysctl_handle_uma_zone_cur, "I", __DESCR(descr)); \ 541273736Shselasky}) 542262737Sglebius 543175019Sjhb/* 544175019Sjhb * A macro to generate a read-only sysctl to indicate the presense of optional 545175019Sjhb * kernel features. 546175019Sjhb */ 547175019Sjhb#define FEATURE(name, desc) \ 548224159Srwatson SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD | CTLFLAG_CAPRD, \ 549273736Shselasky SYSCTL_NULL_INT_PTR, 1, desc) 550191688Szec 55155205Speter#endif /* _KERNEL */ 55211863Sphk 5531541Srgrimes/* 5541541Srgrimes * Top-level identifiers 5551541Srgrimes */ 5561541Srgrimes#define CTL_UNSPEC 0 /* unused */ 5571541Srgrimes#define CTL_KERN 1 /* "high kernel": proc, limits */ 5581541Srgrimes#define CTL_VM 2 /* virtual memory */ 55996755Strhodes#define CTL_VFS 3 /* filesystem, mount type is next */ 5601541Srgrimes#define CTL_NET 4 /* network, see socket.h */ 5611541Srgrimes#define CTL_DEBUG 5 /* debugging parameters */ 5621541Srgrimes#define CTL_HW 6 /* generic cpu/io */ 5631541Srgrimes#define CTL_MACHDEP 7 /* machine dependent */ 5641541Srgrimes#define CTL_USER 8 /* user-level */ 56534925Sdufault#define CTL_P1003_1B 9 /* POSIX 1003.1B */ 56634030Sdufault#define CTL_MAXID 10 /* number of valid top-level ids */ 56734030Sdufault 5681541Srgrimes/* 5691541Srgrimes * CTL_KERN identifiers 5701541Srgrimes */ 571255078Spjd#define KERN_OSTYPE 1 /* string: system version */ 572255078Spjd#define KERN_OSRELEASE 2 /* string: system release */ 573255078Spjd#define KERN_OSREV 3 /* int: system revision */ 574255078Spjd#define KERN_VERSION 4 /* string: compile time info */ 575255078Spjd#define KERN_MAXVNODES 5 /* int: max vnodes */ 576255078Spjd#define KERN_MAXPROC 6 /* int: max processes */ 577255078Spjd#define KERN_MAXFILES 7 /* int: max open files */ 578255078Spjd#define KERN_ARGMAX 8 /* int: max arguments to exec */ 579255078Spjd#define KERN_SECURELVL 9 /* int: system security level */ 5801541Srgrimes#define KERN_HOSTNAME 10 /* string: hostname */ 5811541Srgrimes#define KERN_HOSTID 11 /* int: host identifier */ 5821541Srgrimes#define KERN_CLOCKRATE 12 /* struct: struct clockrate */ 5831541Srgrimes#define KERN_VNODE 13 /* struct: vnode structures */ 5841541Srgrimes#define KERN_PROC 14 /* struct: process entries */ 5851541Srgrimes#define KERN_FILE 15 /* struct: file entries */ 5861541Srgrimes#define KERN_PROF 16 /* node: kernel profiling info */ 5871541Srgrimes#define KERN_POSIX1 17 /* int: POSIX.1 version */ 5881541Srgrimes#define KERN_NGROUPS 18 /* int: # of supplemental group ids */ 5891541Srgrimes#define KERN_JOB_CONTROL 19 /* int: is job control available */ 5901541Srgrimes#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ 5911541Srgrimes#define KERN_BOOTTIME 21 /* struct: time kernel was booted */ 592255078Spjd#define KERN_NISDOMAINNAME 22 /* string: YP domain name */ 593255078Spjd#define KERN_UPDATEINTERVAL 23 /* int: update process sleep time */ 594255078Spjd#define KERN_OSRELDATE 24 /* int: kernel release date */ 595255078Spjd#define KERN_NTP_PLL 25 /* node: NTP PLL control */ 5963038Swollman#define KERN_BOOTFILE 26 /* string: name of booted kernel */ 5976577Sguido#define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */ 598255078Spjd#define KERN_MAXPROCPERUID 28 /* int: max processes per uid */ 599255078Spjd#define KERN_DUMPDEV 29 /* struct cdev *: device to dump on */ 60023083Swollman#define KERN_IPC 30 /* node: anything related to IPC */ 60123083Swollman#define KERN_DUMMY 31 /* unused */ 60214235Speter#define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */ 60314235Speter#define KERN_USRSTACK 33 /* int: address of USRSTACK */ 60437931Sjoerg#define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ 60578431Swollman#define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ 606168545Spjd#define KERN_HOSTUUID 36 /* string: host UUID identifier */ 607169727Skan#define KERN_ARND 37 /* int: from arc4rand() */ 608169727Skan#define KERN_MAXID 38 /* number of valid kern ids */ 6092946Swollman/* 6101541Srgrimes * KERN_PROC subtypes 6111541Srgrimes */ 612255078Spjd#define KERN_PROC_ALL 0 /* everything */ 6131541Srgrimes#define KERN_PROC_PID 1 /* by process id */ 6141541Srgrimes#define KERN_PROC_PGRP 2 /* by process group id */ 6151541Srgrimes#define KERN_PROC_SESSION 3 /* by session of pid */ 6161541Srgrimes#define KERN_PROC_TTY 4 /* by controlling tty */ 6171541Srgrimes#define KERN_PROC_UID 5 /* by effective uid */ 6181541Srgrimes#define KERN_PROC_RUID 6 /* by real uid */ 61953239Sphk#define KERN_PROC_ARGS 7 /* get/set arguments/proctitle */ 620116261Sscottl#define KERN_PROC_PROC 8 /* only return procs */ 621117464Srobert#define KERN_PROC_SV_NAME 9 /* get syscall vector name */ 622129597Sgad#define KERN_PROC_RGID 10 /* by real group id */ 623130725Sgad#define KERN_PROC_GID 11 /* by effective group id */ 624145216Sdas#define KERN_PROC_PATHNAME 12 /* path to executable */ 625185548Speter#define KERN_PROC_OVMMAP 13 /* Old VM map entries for process */ 626185548Speter#define KERN_PROC_OFILEDESC 14 /* Old file descriptors for process */ 627174197Srwatson#define KERN_PROC_KSTACK 15 /* Kernel stacks for process */ 628126125Sdeischen#define KERN_PROC_INC_THREAD 0x10 /* 629126125Sdeischen * modifier for pid, pgrp, tty, 630130725Sgad * uid, ruid, gid, rgid and proc 631185548Speter * This effectively uses 16-31 632126125Sdeischen */ 633185548Speter#define KERN_PROC_VMMAP 32 /* VM map entries for process */ 634185548Speter#define KERN_PROC_FILEDESC 33 /* File descriptors for process */ 635195853Sbrooks#define KERN_PROC_GROUPS 34 /* process groups */ 636227833Strociny#define KERN_PROC_ENV 35 /* get environment */ 637227833Strociny#define KERN_PROC_AUXV 36 /* get ELF auxiliary vector */ 638227955Strociny#define KERN_PROC_RLIMIT 37 /* process resource limits */ 639228046Strociny#define KERN_PROC_PS_STRINGS 38 /* get ps_strings location */ 640232181Strociny#define KERN_PROC_UMASK 39 /* process umask */ 641233389Strociny#define KERN_PROC_OSREL 40 /* osreldate for process binary */ 642258885Skib#define KERN_PROC_SIGTRAMP 41 /* signal trampoline location */ 6431541Srgrimes 6448876Srgrimes/* 64523083Swollman * KERN_IPC identifiers 64623083Swollman */ 647255078Spjd#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ 64823083Swollman#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ 64923083Swollman#define KIPC_SOMAXCONN 3 /* int: max length of connection q */ 65023083Swollman#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ 65123083Swollman#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ 65223083Swollman#define KIPC_MAX_HDR 6 /* int: max total length of headers */ 65323083Swollman#define KIPC_MAX_DATALEN 7 /* int: max length of data? */ 65423083Swollman 65523083Swollman/* 6561541Srgrimes * CTL_HW identifiers 6571541Srgrimes */ 6581541Srgrimes#define HW_MACHINE 1 /* string: machine class */ 6591541Srgrimes#define HW_MODEL 2 /* string: specific machine model */ 6601541Srgrimes#define HW_NCPU 3 /* int: number of cpus */ 6611541Srgrimes#define HW_BYTEORDER 4 /* int: machine byte order */ 6621541Srgrimes#define HW_PHYSMEM 5 /* int: total memory */ 6631541Srgrimes#define HW_USERMEM 6 /* int: non-kernel memory */ 6641541Srgrimes#define HW_PAGESIZE 7 /* int: software page size */ 6651541Srgrimes#define HW_DISKNAMES 8 /* strings: disk drive names */ 6661541Srgrimes#define HW_DISKSTATS 9 /* struct: diskstats[] */ 667255078Spjd#define HW_FLOATINGPT 10 /* int: has HW floating point? */ 668255078Spjd#define HW_MACHINE_ARCH 11 /* string: machine architecture */ 669142834Swes#define HW_REALMEM 12 /* int: 'real' memory */ 670172674Snetchild#define HW_MAXID 13 /* number of valid hw ids */ 6711541Srgrimes 6721541Srgrimes/* 6731541Srgrimes * CTL_USER definitions 6741541Srgrimes */ 6751541Srgrimes#define USER_CS_PATH 1 /* string: _CS_PATH */ 6761541Srgrimes#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ 6771541Srgrimes#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ 6781541Srgrimes#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ 6791541Srgrimes#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ 6801541Srgrimes#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ 6811541Srgrimes#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ 6821541Srgrimes#define USER_LINE_MAX 8 /* int: LINE_MAX */ 6831541Srgrimes#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ 6841541Srgrimes#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ 6851541Srgrimes#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ 6861541Srgrimes#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ 6871541Srgrimes#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ 6881541Srgrimes#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ 6891541Srgrimes#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ 6901541Srgrimes#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ 6911541Srgrimes#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ 6921541Srgrimes#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ 6931541Srgrimes#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ 6941541Srgrimes#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ 6951541Srgrimes#define USER_MAXID 21 /* number of valid user ids */ 6961541Srgrimes 697255078Spjd#define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */ 698255078Spjd#define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */ 699255078Spjd#define CTL_P1003_1B_MEMLOCK 3 /* boolean */ 700255078Spjd#define CTL_P1003_1B_MEMLOCK_RANGE 4 /* boolean */ 701255078Spjd#define CTL_P1003_1B_MEMORY_PROTECTION 5 /* boolean */ 702255078Spjd#define CTL_P1003_1B_MESSAGE_PASSING 6 /* boolean */ 703255078Spjd#define CTL_P1003_1B_PRIORITIZED_IO 7 /* boolean */ 704255078Spjd#define CTL_P1003_1B_PRIORITY_SCHEDULING 8 /* boolean */ 705255078Spjd#define CTL_P1003_1B_REALTIME_SIGNALS 9 /* boolean */ 706255078Spjd#define CTL_P1003_1B_SEMAPHORES 10 /* boolean */ 707255078Spjd#define CTL_P1003_1B_FSYNC 11 /* boolean */ 708255078Spjd#define CTL_P1003_1B_SHARED_MEMORY_OBJECTS 12 /* boolean */ 709255078Spjd#define CTL_P1003_1B_SYNCHRONIZED_IO 13 /* boolean */ 710255078Spjd#define CTL_P1003_1B_TIMERS 14 /* boolean */ 711255078Spjd#define CTL_P1003_1B_AIO_LISTIO_MAX 15 /* int */ 712255078Spjd#define CTL_P1003_1B_AIO_MAX 16 /* int */ 713255078Spjd#define CTL_P1003_1B_AIO_PRIO_DELTA_MAX 17 /* int */ 714255078Spjd#define CTL_P1003_1B_DELAYTIMER_MAX 18 /* int */ 715255078Spjd#define CTL_P1003_1B_MQ_OPEN_MAX 19 /* int */ 716255078Spjd#define CTL_P1003_1B_PAGESIZE 20 /* int */ 717255078Spjd#define CTL_P1003_1B_RTSIG_MAX 21 /* int */ 718255078Spjd#define CTL_P1003_1B_SEM_NSEMS_MAX 22 /* int */ 719255078Spjd#define CTL_P1003_1B_SEM_VALUE_MAX 23 /* int */ 720255078Spjd#define CTL_P1003_1B_SIGQUEUE_MAX 24 /* int */ 721255078Spjd#define CTL_P1003_1B_TIMER_MAX 25 /* int */ 72234925Sdufault 723255078Spjd#define CTL_P1003_1B_MAXID 26 72434925Sdufault 72555205Speter#ifdef _KERNEL 7261541Srgrimes 72744078Sdfr/* 72844078Sdfr * Declare some common oids. 72944078Sdfr */ 73044078Sdfrextern struct sysctl_oid_list sysctl__children; 73144078SdfrSYSCTL_DECL(_kern); 732175019SjhbSYSCTL_DECL(_kern_features); 733159481SrwatsonSYSCTL_DECL(_kern_ipc); 734174167SrwatsonSYSCTL_DECL(_kern_proc); 735177435SjeffSYSCTL_DECL(_kern_sched); 736178272SjeffSYSCTL_DECL(_kern_sched_stats); 73744078SdfrSYSCTL_DECL(_sysctl); 73844078SdfrSYSCTL_DECL(_vm); 739161492SalcSYSCTL_DECL(_vm_stats); 740161492SalcSYSCTL_DECL(_vm_stats_misc); 74144078SdfrSYSCTL_DECL(_vfs); 74244078SdfrSYSCTL_DECL(_net); 74344078SdfrSYSCTL_DECL(_debug); 74491687SphkSYSCTL_DECL(_debug_sizeof); 745189577SimpSYSCTL_DECL(_dev); 74644078SdfrSYSCTL_DECL(_hw); 747144071SphkSYSCTL_DECL(_hw_bus); 748189577SimpSYSCTL_DECL(_hw_bus_devices); 749189577SimpSYSCTL_DECL(_hw_bus_info); 75044078SdfrSYSCTL_DECL(_machdep); 75144078SdfrSYSCTL_DECL(_user); 75250465SmarcelSYSCTL_DECL(_compat); 753157157SrwatsonSYSCTL_DECL(_regression); 754162383SrwatsonSYSCTL_DECL(_security); 755162383SrwatsonSYSCTL_DECL(_security_bsd); 75644078Sdfr 7577090Sbdeextern char machine[]; 7587090Sbdeextern char osrelease[]; 7597090Sbdeextern char ostype[]; 760116105Sjmallettextern char kern_ident[]; 7617090Sbde 76263212Sabial/* Dynamic oid handling */ 76363212Sabialstruct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, 764255078Spjd struct sysctl_oid_list *parent, int nbr, const char *name, int kind, 765255078Spjd void *arg1, intptr_t arg2, int (*handler)(SYSCTL_HANDLER_ARGS), 766255078Spjd const char *fmt, const char *descr); 767219819Sjeffint sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del, 768255078Spjd int recurse); 769174113Spetervoid sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); 770126319Sdesint sysctl_move_oid(struct sysctl_oid *oidp, 771255078Spjd struct sysctl_oid_list *parent); 77263212Sabialint sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse); 77363212Sabialint sysctl_ctx_init(struct sysctl_ctx_list *clist); 77463212Sabialint sysctl_ctx_free(struct sysctl_ctx_list *clist); 77563212Sabialstruct sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist, 776255078Spjd struct sysctl_oid *oidp); 77763212Sabialstruct sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist, 778255078Spjd struct sysctl_oid *oidp); 77963212Sabialint sysctl_ctx_entry_del(struct sysctl_ctx_list *clist, 780255078Spjd struct sysctl_oid *oidp); 78163212Sabial 78283366Sjulianint kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, 783255078Spjd size_t *oldlenp, void *new, size_t newlen, size_t *retval, 784255078Spjd int flags); 785255078Spjdint kernel_sysctlbyname(struct thread *td, char *name, void *old, 786255078Spjd size_t *oldlenp, void *new, size_t newlen, size_t *retval, 787255078Spjd int flags); 78883366Sjulianint userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, 789255078Spjd size_t *oldlenp, int inkernel, void *new, size_t newlen, 790255078Spjd size_t *retval, int flags); 79153977Sgreenint sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, 792255078Spjd int *nindx, struct sysctl_req *req); 793188232Sjhbvoid sysctl_lock(void); 794188232Sjhbvoid sysctl_unlock(void); 795126253Struckmanint sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); 7963421Sphk 797212750Smdfstruct sbuf; 798255078Spjdstruct sbuf *sbuf_new_for_sysctl(struct sbuf *, char *, int, 799255078Spjd struct sysctl_req *); 80055205Speter#else /* !_KERNEL */ 8011541Srgrimes#include <sys/cdefs.h> 8021541Srgrimes 8031541Srgrimes__BEGIN_DECLS 804204170Sedint sysctl(const int *, u_int, void *, size_t *, const void *, size_t); 805204170Sedint sysctlbyname(const char *, void *, size_t *, const void *, size_t); 80692719Salfredint sysctlnametomib(const char *, int *, size_t *); 8071541Srgrimes__END_DECLS 80855205Speter#endif /* _KERNEL */ 8094468Sbde 8101541Srgrimes#endif /* !_SYS_SYSCTL_H_ */ 811