1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Mike Karels at Berkeley Software Design, Inc. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 35 * $FreeBSD$ 36 */ 37 38 #ifndef _SYS_SYSCTL_H_ 39 #define _SYS_SYSCTL_H_ 40 41 #ifdef _KERNEL 42 #include <sys/queue.h> 43 #include <sys/tree.h> 44 #endif 45 46 /* 47 * Definitions for sysctl call. The sysctl call uses a hierarchical name 48 * for objects that can be examined or modified. The name is expressed as 49 * a sequence of integers. Like a file path name, the meaning of each 50 * component depends on its place in the hierarchy. The top-level and kern 51 * identifiers are defined here, and other identifiers are defined in the 52 * respective subsystem header files. 53 * 54 * Each subsystem defined by sysctl defines a list of variables for that 55 * subsystem. Each name is either a node with further levels defined below it, 56 * or it is a leaf of some particular type given below. Each sysctl level 57 * defines a set of name/type pairs to be used by sysctl(8) in manipulating the 58 * subsystem. 59 */ 60 61 #define CTL_MAXNAME 24 /* largest number of components supported */ 62 63 #define CTLTYPE 0xf /* mask for the type */ 64 #define CTLTYPE_NODE 1 /* name is a node */ 65 #define CTLTYPE_INT 2 /* name describes an integer */ 66 #define CTLTYPE_STRING 3 /* name describes a string */ 67 #define CTLTYPE_S64 4 /* name describes a signed 64-bit number */ 68 #define CTLTYPE_OPAQUE 5 /* name describes a structure */ 69 #define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ 70 #define CTLTYPE_UINT 6 /* name describes an unsigned integer */ 71 #define CTLTYPE_LONG 7 /* name describes a long */ 72 #define CTLTYPE_ULONG 8 /* name describes an unsigned long */ 73 #define CTLTYPE_U64 9 /* name describes an unsigned 64-bit number */ 74 #define CTLTYPE_U8 0xa /* name describes an unsigned 8-bit number */ 75 #define CTLTYPE_U16 0xb /* name describes an unsigned 16-bit number */ 76 #define CTLTYPE_S8 0xc /* name describes a signed 8-bit number */ 77 #define CTLTYPE_S16 0xd /* name describes a signed 16-bit number */ 78 #define CTLTYPE_S32 0xe /* name describes a signed 32-bit number */ 79 #define CTLTYPE_U32 0xf /* name describes an unsigned 32-bit number */ 80 81 #define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ 82 #define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ 83 #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) 84 #define CTLFLAG_DORMANT 0x20000000 /* This sysctl is not active yet */ 85 #define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ 86 #define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ 87 #define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */ 88 #define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ 89 #define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ 90 #define CTLMASK_SECURE 0x00F00000 /* Secure level */ 91 #define CTLFLAG_TUN 0x00080000 /* Default value is loaded from getenv() */ 92 #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) 93 #define CTLFLAG_RWTUN (CTLFLAG_RW|CTLFLAG_TUN) 94 #define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ 95 #define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ 96 #define CTLFLAG_DYING 0x00010000 /* Oid is being removed */ 97 #define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ 98 #define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ 99 #define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ 100 #define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ 101 #define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) 102 /* 103 * This is transient flag to be used until all sysctl handlers are converted 104 * to not lock Giant. 105 * One, and only one of CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT is required 106 * for SYSCTL_PROC and SYSCTL_NODE. 107 */ 108 #define CTLFLAG_NEEDGIANT 0x00000800 /* Handler require Giant */ 109 110 /* 111 * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. 112 * 113 * Secure when the securelevel is raised to at least N. 114 */ 115 #define CTLSHIFT_SECURE 20 116 #define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE)) 117 #define CTLFLAG_SECURE2 (CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE)) 118 #define CTLFLAG_SECURE3 (CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE)) 119 120 /* 121 * USE THIS instead of a hardwired number from the categories below 122 * to get dynamically assigned sysctl entries using the linker-set 123 * technology. This is the way nearly all new sysctl variables should 124 * be implemented. 125 * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); 126 */ 127 #define OID_AUTO (-1) 128 129 /* 130 * The starting number for dynamically-assigned entries. WARNING! 131 * ALL static sysctl entries should have numbers LESS than this! 132 */ 133 #define CTL_AUTO_START 0x100 134 135 #ifdef _KERNEL 136 #include <sys/linker_set.h> 137 138 #ifdef KLD_MODULE 139 /* XXX allow overspecification of type in external kernel modules */ 140 #define SYSCTL_CT_ASSERT_MASK CTLTYPE 141 #else 142 #define SYSCTL_CT_ASSERT_MASK 0 143 #endif 144 145 #define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, \ 146 intmax_t arg2, struct sysctl_req *req 147 148 /* definitions for sysctl_req 'lock' member */ 149 #define REQ_UNWIRED 1 150 #define REQ_WIRED 2 151 152 /* definitions for sysctl_req 'flags' member */ 153 #ifdef COMPAT_FREEBSD32 154 #define SCTL_MASK32 1 /* 32 bit emulation */ 155 #endif 156 157 /* 158 * This describes the access space for a sysctl request. This is needed 159 * so that we can use the interface from the kernel or from user-space. 160 */ 161 struct thread; 162 struct sysctl_req { 163 struct thread *td; /* used for access checking */ 164 int lock; /* wiring state */ 165 void *oldptr; 166 size_t oldlen; 167 size_t oldidx; 168 int (*oldfunc)(struct sysctl_req *, const void *, size_t); 169 const void *newptr; 170 size_t newlen; 171 size_t newidx; 172 int (*newfunc)(struct sysctl_req *, void *, size_t); 173 size_t validlen; 174 int flags; 175 }; 176 177 struct sysctl_oid; 178 179 /* RB Tree handling */ 180 RB_HEAD(sysctl_oid_list, sysctl_oid); 181 182 /* 183 * This describes one "oid" in the MIB tree. Potentially more nodes can 184 * be hidden behind it, expanded by the handler. 185 */ 186 struct sysctl_oid { 187 struct sysctl_oid_list oid_children; 188 struct sysctl_oid_list* oid_parent; 189 RB_ENTRY(sysctl_oid) oid_link; 190 /* Sort key for all siblings, and lookup key for userland */ 191 int oid_number; 192 u_int oid_kind; 193 void *oid_arg1; 194 intmax_t oid_arg2; 195 /* Must be unique amongst all siblings. */ 196 const char *oid_name; 197 int (*oid_handler)(SYSCTL_HANDLER_ARGS); 198 const char *oid_fmt; 199 int oid_refcnt; 200 u_int oid_running; 201 const char *oid_descr; 202 const char *oid_label; 203 }; 204 205 static inline int 206 cmp_sysctl_oid(struct sysctl_oid *a, struct sysctl_oid *b) 207 { 208 if (a->oid_number > b->oid_number) 209 return (1); 210 else if (a->oid_number < b->oid_number) 211 return (-1); 212 else 213 return (0); 214 } 215 216 RB_PROTOTYPE(sysctl_oid_list, sysctl_oid, oid_link, cmp_sysctl_oid); 217 218 #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) 219 #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) 220 #define SYSCTL_OUT_STR(r, p) (r->oldfunc)(r, p, strlen(p) + 1) 221 222 int sysctl_handle_bool(SYSCTL_HANDLER_ARGS); 223 int sysctl_handle_8(SYSCTL_HANDLER_ARGS); 224 int sysctl_handle_16(SYSCTL_HANDLER_ARGS); 225 int sysctl_handle_32(SYSCTL_HANDLER_ARGS); 226 int sysctl_handle_64(SYSCTL_HANDLER_ARGS); 227 int sysctl_handle_int(SYSCTL_HANDLER_ARGS); 228 int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS); 229 int sysctl_handle_long(SYSCTL_HANDLER_ARGS); 230 int sysctl_handle_string(SYSCTL_HANDLER_ARGS); 231 int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS); 232 int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS); 233 int sysctl_handle_counter_u64_array(SYSCTL_HANDLER_ARGS); 234 235 int sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS); 236 int sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS); 237 238 int sysctl_msec_to_sbintime(SYSCTL_HANDLER_ARGS); 239 int sysctl_usec_to_sbintime(SYSCTL_HANDLER_ARGS); 240 int sysctl_sec_to_timeval(SYSCTL_HANDLER_ARGS); 241 242 int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS); 243 int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS); 244 int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS); 245 246 /* 247 * These functions are used to add/remove an oid from the mib. 248 */ 249 void sysctl_register_oid(struct sysctl_oid *oidp); 250 void sysctl_register_disabled_oid(struct sysctl_oid *oidp); 251 void sysctl_enable_oid(struct sysctl_oid *oidp); 252 void sysctl_unregister_oid(struct sysctl_oid *oidp); 253 254 /* Declare a static oid to allow child oids to be added to it. */ 255 #define SYSCTL_DECL(name) \ 256 extern struct sysctl_oid sysctl__##name 257 258 /* Hide these in macros. */ 259 #define SYSCTL_CHILDREN(oid_ptr) (&(oid_ptr)->oid_children) 260 #define SYSCTL_PARENT(oid_ptr) \ 261 (((oid_ptr)->oid_parent != &sysctl__children) ? \ 262 __containerof((oid_ptr)->oid_parent, struct sysctl_oid, \ 263 oid_children) : (struct sysctl_oid *)NULL) 264 #define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl__##oid_name.oid_children) 265 266 /* === Structs and macros related to context handling. === */ 267 268 /* All dynamically created sysctls can be tracked in a context list. */ 269 struct sysctl_ctx_entry { 270 struct sysctl_oid *entry; 271 TAILQ_ENTRY(sysctl_ctx_entry) link; 272 }; 273 274 TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); 275 276 #define SYSCTL_NODE_CHILDREN(parent, name) \ 277 sysctl__##parent##_##name.oid_children 278 279 #ifndef NO_SYSCTL_DESCR 280 #define __DESCR(d) d 281 #else 282 #define __DESCR(d) "" 283 #endif 284 285 #ifdef notyet 286 #define SYSCTL_ENFORCE_FLAGS(x) \ 287 _Static_assert((((x) & CTLFLAG_MPSAFE) != 0) ^ (((x) & CTLFLAG_NEEDGIANT) != 0), \ 288 "Has to be either CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT") 289 #else 290 #define SYSCTL_ENFORCE_FLAGS(x) 291 #endif 292 293 /* This macro is only for internal use */ 294 #define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ 295 struct sysctl_oid id = { \ 296 .oid_parent = (parent_child_head), \ 297 .oid_children = RB_INITIALIZER(&id.oid_children), \ 298 .oid_number = (nbr), \ 299 .oid_kind = (kind), \ 300 .oid_arg1 = (a1), \ 301 .oid_arg2 = (a2), \ 302 .oid_name = (name), \ 303 .oid_handler = (handler), \ 304 .oid_fmt = (fmt), \ 305 .oid_descr = __DESCR(descr), \ 306 .oid_label = (label), \ 307 }; \ 308 DATA_SET(sysctl_set, id); \ 309 SYSCTL_ENFORCE_FLAGS(kind) 310 311 /* This constructs a static "raw" MIB oid. */ 312 #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ 313 SYSCTL_OID_WITH_LABEL(parent, nbr, name, kind, a1, a2, \ 314 handler, fmt, descr, NULL) 315 316 #define SYSCTL_OID_WITH_LABEL(parent, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ 317 static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ 318 SYSCTL_CHILDREN(&sysctl__##parent), \ 319 nbr, #name, kind, a1, a2, handler, fmt, descr, label) 320 321 /* This constructs a global "raw" MIB oid. */ 322 #define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr, label) \ 323 SYSCTL_OID_RAW(sysctl__##parent##_##name, \ 324 SYSCTL_CHILDREN(&sysctl__##parent), \ 325 nbr, #name, kind, a1, a2, handler, fmt, descr, label) 326 327 #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ 328 ({ \ 329 SYSCTL_ENFORCE_FLAGS(kind); \ 330 sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2,handler, \ 331 fmt, __DESCR(descr), NULL); \ 332 }) 333 334 /* This constructs a root node from which other nodes can hang. */ 335 #define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ 336 SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ 337 nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ 338 handler, "N", descr, NULL); \ 339 CTASSERT(((access) & CTLTYPE) == 0 || \ 340 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) 341 342 /* This constructs a node from which other oids can hang. */ 343 #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ 344 SYSCTL_NODE_WITH_LABEL(parent, nbr, name, access, handler, descr, NULL) 345 346 #define SYSCTL_NODE_WITH_LABEL(parent, nbr, name, access, handler, descr, label) \ 347 SYSCTL_OID_GLOBAL(parent, nbr, name, CTLTYPE_NODE|(access), \ 348 NULL, 0, handler, "N", descr, label); \ 349 SYSCTL_ENFORCE_FLAGS(access); \ 350 CTASSERT(((access) & CTLTYPE) == 0 || \ 351 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) 352 353 #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ 354 SYSCTL_ADD_NODE_WITH_LABEL(ctx, parent, nbr, name, access, \ 355 handler, descr, NULL) 356 357 #define SYSCTL_ADD_NODE_WITH_LABEL(ctx, parent, nbr, name, access, handler, descr, label) \ 358 ({ \ 359 CTASSERT(((access) & CTLTYPE) == 0 || \ 360 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ 361 SYSCTL_ENFORCE_FLAGS(access); \ 362 sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ 363 NULL, 0, handler, "N", __DESCR(descr), label); \ 364 }) 365 366 #define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \ 367 ({ \ 368 CTASSERT(((access) & CTLTYPE) == 0 || \ 369 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ 370 SYSCTL_ENFORCE_FLAGS(access); \ 371 sysctl_add_oid(ctx, &sysctl__children, nbr, name, \ 372 CTLTYPE_NODE|(access), \ 373 NULL, 0, handler, "N", __DESCR(descr), NULL); \ 374 }) 375 376 /* Oid for a string. len can be 0 to indicate '\0' termination. */ 377 #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ 378 SYSCTL_OID(parent, nbr, name, \ 379 CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), \ 380 arg, len, sysctl_handle_string, "A", descr); \ 381 CTASSERT(((access) & CTLTYPE) == 0 || \ 382 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) 383 384 #define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ 385 ({ \ 386 char *__arg = (arg); \ 387 CTASSERT(((access) & CTLTYPE) == 0 || \ 388 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ 389 sysctl_add_oid(ctx, parent, nbr, name, \ 390 CTLTYPE_STRING | CTLFLAG_MPSAFE | (access), \ 391 __arg, len, sysctl_handle_string, "A", __DESCR(descr), \ 392 NULL); \ 393 }) 394 395 /* Oid for a constant '\0' terminated string. */ 396 #define SYSCTL_CONST_STRING(parent, nbr, name, access, arg, descr) \ 397 SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING | CTLFLAG_MPSAFE | (access),\ 398 __DECONST(char *, arg), 0, sysctl_handle_string, "A", descr); \ 399 CTASSERT(!(access & CTLFLAG_WR)); \ 400 CTASSERT(((access) & CTLTYPE) == 0 || \ 401 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) 402 403 #define SYSCTL_ADD_CONST_STRING(ctx, parent, nbr, name, access, arg, descr) \ 404 ({ \ 405 char *__arg = __DECONST(char *, arg); \ 406 CTASSERT(!(access & CTLFLAG_WR)); \ 407 CTASSERT(((access) & CTLTYPE) == 0 || \ 408 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ 409 sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING | \ 410 CTLFLAG_MPSAFE | (access), __arg, 0, sysctl_handle_string, "A",\ 411 __DESCR(descr), NULL); \ 412 }) 413 414 /* Oid for a bool. If ptr is NULL, val is returned. */ 415 #define SYSCTL_NULL_BOOL_PTR ((bool *)NULL) 416 #define SYSCTL_BOOL(parent, nbr, name, access, ptr, val, descr) \ 417 SYSCTL_OID(parent, nbr, name, \ 418 CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ 419 ptr, val, sysctl_handle_bool, "CU", descr); \ 420 CTASSERT(((access) & CTLTYPE) == 0 && \ 421 sizeof(bool) == sizeof(*(ptr))) 422 423 #define SYSCTL_ADD_BOOL(ctx, parent, nbr, name, access, ptr, val, descr) \ 424 ({ \ 425 bool *__ptr = (ptr); \ 426 CTASSERT(((access) & CTLTYPE) == 0); \ 427 sysctl_add_oid(ctx, parent, nbr, name, \ 428 CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ 429 __ptr, val, sysctl_handle_bool, "CU", __DESCR(descr), \ 430 NULL); \ 431 }) 432 433 /* Oid for a signed 8-bit int. If ptr is NULL, val is returned. */ 434 #define SYSCTL_NULL_S8_PTR ((int8_t *)NULL) 435 #define SYSCTL_S8(parent, nbr, name, access, ptr, val, descr) \ 436 SYSCTL_OID(parent, nbr, name, \ 437 CTLTYPE_S8 | CTLFLAG_MPSAFE | (access), \ 438 ptr, val, sysctl_handle_8, "C", descr); \ 439 CTASSERT((((access) & CTLTYPE) == 0 || \ 440 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S8) && \ 441 sizeof(int8_t) == sizeof(*(ptr))) 442 443 #define SYSCTL_ADD_S8(ctx, parent, nbr, name, access, ptr, val, descr) \ 444 ({ \ 445 int8_t *__ptr = (ptr); \ 446 CTASSERT(((access) & CTLTYPE) == 0 || \ 447 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S8); \ 448 sysctl_add_oid(ctx, parent, nbr, name, \ 449 CTLTYPE_S8 | CTLFLAG_MPSAFE | (access), \ 450 __ptr, val, sysctl_handle_8, "C", __DESCR(descr), NULL); \ 451 }) 452 453 /* Oid for an unsigned 8-bit int. If ptr is NULL, val is returned. */ 454 #define SYSCTL_NULL_U8_PTR ((uint8_t *)NULL) 455 #define SYSCTL_U8(parent, nbr, name, access, ptr, val, descr) \ 456 SYSCTL_OID(parent, nbr, name, \ 457 CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ 458 ptr, val, sysctl_handle_8, "CU", descr); \ 459 CTASSERT((((access) & CTLTYPE) == 0 || \ 460 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U8) && \ 461 sizeof(uint8_t) == sizeof(*(ptr))) 462 463 #define SYSCTL_ADD_U8(ctx, parent, nbr, name, access, ptr, val, descr) \ 464 ({ \ 465 uint8_t *__ptr = (ptr); \ 466 CTASSERT(((access) & CTLTYPE) == 0 || \ 467 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U8); \ 468 sysctl_add_oid(ctx, parent, nbr, name, \ 469 CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ 470 __ptr, val, sysctl_handle_8, "CU", __DESCR(descr), NULL); \ 471 }) 472 473 /* Oid for a signed 16-bit int. If ptr is NULL, val is returned. */ 474 #define SYSCTL_NULL_S16_PTR ((int16_t *)NULL) 475 #define SYSCTL_S16(parent, nbr, name, access, ptr, val, descr) \ 476 SYSCTL_OID(parent, nbr, name, \ 477 CTLTYPE_S16 | CTLFLAG_MPSAFE | (access), \ 478 ptr, val, sysctl_handle_16, "S", descr); \ 479 CTASSERT((((access) & CTLTYPE) == 0 || \ 480 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S16) && \ 481 sizeof(int16_t) == sizeof(*(ptr))) 482 483 #define SYSCTL_ADD_S16(ctx, parent, nbr, name, access, ptr, val, descr) \ 484 ({ \ 485 int16_t *__ptr = (ptr); \ 486 CTASSERT(((access) & CTLTYPE) == 0 || \ 487 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S16); \ 488 sysctl_add_oid(ctx, parent, nbr, name, \ 489 CTLTYPE_S16 | CTLFLAG_MPSAFE | (access), \ 490 __ptr, val, sysctl_handle_16, "S", __DESCR(descr), NULL); \ 491 }) 492 493 /* Oid for an unsigned 16-bit int. If ptr is NULL, val is returned. */ 494 #define SYSCTL_NULL_U16_PTR ((uint16_t *)NULL) 495 #define SYSCTL_U16(parent, nbr, name, access, ptr, val, descr) \ 496 SYSCTL_OID(parent, nbr, name, \ 497 CTLTYPE_U16 | CTLFLAG_MPSAFE | (access), \ 498 ptr, val, sysctl_handle_16, "SU", descr); \ 499 CTASSERT((((access) & CTLTYPE) == 0 || \ 500 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U16) && \ 501 sizeof(uint16_t) == sizeof(*(ptr))) 502 503 #define SYSCTL_ADD_U16(ctx, parent, nbr, name, access, ptr, val, descr) \ 504 ({ \ 505 uint16_t *__ptr = (ptr); \ 506 CTASSERT(((access) & CTLTYPE) == 0 || \ 507 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U16); \ 508 sysctl_add_oid(ctx, parent, nbr, name, \ 509 CTLTYPE_U16 | CTLFLAG_MPSAFE | (access), \ 510 __ptr, val, sysctl_handle_16, "SU", __DESCR(descr), NULL); \ 511 }) 512 513 /* Oid for a signed 32-bit int. If ptr is NULL, val is returned. */ 514 #define SYSCTL_NULL_S32_PTR ((int32_t *)NULL) 515 #define SYSCTL_S32(parent, nbr, name, access, ptr, val, descr) \ 516 SYSCTL_OID(parent, nbr, name, \ 517 CTLTYPE_S32 | CTLFLAG_MPSAFE | (access), \ 518 ptr, val, sysctl_handle_32, "I", descr); \ 519 CTASSERT((((access) & CTLTYPE) == 0 || \ 520 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S32) && \ 521 sizeof(int32_t) == sizeof(*(ptr))) 522 523 #define SYSCTL_ADD_S32(ctx, parent, nbr, name, access, ptr, val, descr) \ 524 ({ \ 525 int32_t *__ptr = (ptr); \ 526 CTASSERT(((access) & CTLTYPE) == 0 || \ 527 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S32); \ 528 sysctl_add_oid(ctx, parent, nbr, name, \ 529 CTLTYPE_S32 | CTLFLAG_MPSAFE | (access), \ 530 __ptr, val, sysctl_handle_32, "I", __DESCR(descr), NULL); \ 531 }) 532 533 /* Oid for an unsigned 32-bit int. If ptr is NULL, val is returned. */ 534 #define SYSCTL_NULL_U32_PTR ((uint32_t *)NULL) 535 #define SYSCTL_U32(parent, nbr, name, access, ptr, val, descr) \ 536 SYSCTL_OID(parent, nbr, name, \ 537 CTLTYPE_U32 | CTLFLAG_MPSAFE | (access), \ 538 ptr, val, sysctl_handle_32, "IU", descr); \ 539 CTASSERT((((access) & CTLTYPE) == 0 || \ 540 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U32) && \ 541 sizeof(uint32_t) == sizeof(*(ptr))) 542 543 #define SYSCTL_ADD_U32(ctx, parent, nbr, name, access, ptr, val, descr) \ 544 ({ \ 545 uint32_t *__ptr = (ptr); \ 546 CTASSERT(((access) & CTLTYPE) == 0 || \ 547 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U32); \ 548 sysctl_add_oid(ctx, parent, nbr, name, \ 549 CTLTYPE_U32 | CTLFLAG_MPSAFE | (access), \ 550 __ptr, val, sysctl_handle_32, "IU", __DESCR(descr), NULL); \ 551 }) 552 553 /* Oid for a signed 64-bit int. If ptr is NULL, val is returned. */ 554 #define SYSCTL_NULL_S64_PTR ((int64_t *)NULL) 555 #define SYSCTL_S64(parent, nbr, name, access, ptr, val, descr) \ 556 SYSCTL_OID(parent, nbr, name, \ 557 CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ 558 ptr, val, sysctl_handle_64, "Q", descr); \ 559 CTASSERT((((access) & CTLTYPE) == 0 || \ 560 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) && \ 561 sizeof(int64_t) == sizeof(*(ptr))) 562 563 #define SYSCTL_ADD_S64(ctx, parent, nbr, name, access, ptr, val, descr) \ 564 ({ \ 565 int64_t *__ptr = (ptr); \ 566 CTASSERT(((access) & CTLTYPE) == 0 || \ 567 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ 568 sysctl_add_oid(ctx, parent, nbr, name, \ 569 CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ 570 __ptr, val, sysctl_handle_64, "Q", __DESCR(descr), NULL); \ 571 }) 572 573 /* Oid for an unsigned 64-bit int. If ptr is NULL, val is returned. */ 574 #define SYSCTL_NULL_U64_PTR ((uint64_t *)NULL) 575 #define SYSCTL_U64(parent, nbr, name, access, ptr, val, descr) \ 576 SYSCTL_OID(parent, nbr, name, \ 577 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 578 ptr, val, sysctl_handle_64, "QU", descr); \ 579 CTASSERT((((access) & CTLTYPE) == 0 || \ 580 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \ 581 sizeof(uint64_t) == sizeof(*(ptr))) 582 583 #define SYSCTL_ADD_U64(ctx, parent, nbr, name, access, ptr, val, descr) \ 584 ({ \ 585 uint64_t *__ptr = (ptr); \ 586 CTASSERT(((access) & CTLTYPE) == 0 || \ 587 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ 588 sysctl_add_oid(ctx, parent, nbr, name, \ 589 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 590 __ptr, val, sysctl_handle_64, "QU", __DESCR(descr), NULL); \ 591 }) 592 593 /* Oid for an int. If ptr is SYSCTL_NULL_INT_PTR, val is returned. */ 594 #define SYSCTL_NULL_INT_PTR ((int *)NULL) 595 #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ 596 SYSCTL_INT_WITH_LABEL(parent, nbr, name, access, ptr, val, descr, NULL) 597 598 #define SYSCTL_INT_WITH_LABEL(parent, nbr, name, access, ptr, val, descr, label) \ 599 SYSCTL_OID_WITH_LABEL(parent, nbr, name, \ 600 CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ 601 ptr, val, sysctl_handle_int, "I", descr, label); \ 602 CTASSERT((((access) & CTLTYPE) == 0 || \ 603 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) && \ 604 sizeof(int) == sizeof(*(ptr))) 605 606 #define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \ 607 ({ \ 608 int *__ptr = (ptr); \ 609 CTASSERT(((access) & CTLTYPE) == 0 || \ 610 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ 611 sysctl_add_oid(ctx, parent, nbr, name, \ 612 CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ 613 __ptr, val, sysctl_handle_int, "I", __DESCR(descr), NULL); \ 614 }) 615 616 /* Oid for an unsigned int. If ptr is NULL, val is returned. */ 617 #define SYSCTL_NULL_UINT_PTR ((unsigned *)NULL) 618 #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ 619 SYSCTL_OID(parent, nbr, name, \ 620 CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ 621 ptr, val, sysctl_handle_int, "IU", descr); \ 622 CTASSERT((((access) & CTLTYPE) == 0 || \ 623 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT) && \ 624 sizeof(unsigned) == sizeof(*(ptr))) 625 626 #define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \ 627 ({ \ 628 unsigned *__ptr = (ptr); \ 629 CTASSERT(((access) & CTLTYPE) == 0 || \ 630 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT); \ 631 sysctl_add_oid(ctx, parent, nbr, name, \ 632 CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ 633 __ptr, val, sysctl_handle_int, "IU", __DESCR(descr), NULL); \ 634 }) 635 636 /* Oid for a long. The pointer must be non NULL. */ 637 #define SYSCTL_NULL_LONG_PTR ((long *)NULL) 638 #define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ 639 SYSCTL_OID(parent, nbr, name, \ 640 CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ 641 ptr, val, sysctl_handle_long, "L", descr); \ 642 CTASSERT((((access) & CTLTYPE) == 0 || \ 643 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG) && \ 644 sizeof(long) == sizeof(*(ptr))) 645 646 #define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \ 647 ({ \ 648 long *__ptr = (ptr); \ 649 CTASSERT(((access) & CTLTYPE) == 0 || \ 650 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG); \ 651 sysctl_add_oid(ctx, parent, nbr, name, \ 652 CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ 653 __ptr, 0, sysctl_handle_long, "L", __DESCR(descr), NULL); \ 654 }) 655 656 /* Oid for an unsigned long. The pointer must be non NULL. */ 657 #define SYSCTL_NULL_ULONG_PTR ((unsigned long *)NULL) 658 #define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \ 659 SYSCTL_OID(parent, nbr, name, \ 660 CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ 661 ptr, val, sysctl_handle_long, "LU", descr); \ 662 CTASSERT((((access) & CTLTYPE) == 0 || \ 663 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG) && \ 664 sizeof(unsigned long) == sizeof(*(ptr))) 665 666 #define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \ 667 ({ \ 668 unsigned long *__ptr = (ptr); \ 669 CTASSERT(((access) & CTLTYPE) == 0 || \ 670 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG); \ 671 sysctl_add_oid(ctx, parent, nbr, name, \ 672 CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ 673 __ptr, 0, sysctl_handle_long, "LU", __DESCR(descr), NULL); \ 674 }) 675 676 /* Oid for a quad. The pointer must be non NULL. */ 677 #define SYSCTL_NULL_QUAD_PTR ((int64_t *)NULL) 678 #define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \ 679 SYSCTL_OID(parent, nbr, name, \ 680 CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ 681 ptr, val, sysctl_handle_64, "Q", descr); \ 682 CTASSERT((((access) & CTLTYPE) == 0 || \ 683 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) && \ 684 sizeof(int64_t) == sizeof(*(ptr))) 685 686 #define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \ 687 ({ \ 688 int64_t *__ptr = (ptr); \ 689 CTASSERT(((access) & CTLTYPE) == 0 || \ 690 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ 691 sysctl_add_oid(ctx, parent, nbr, name, \ 692 CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ 693 __ptr, 0, sysctl_handle_64, "Q", __DESCR(descr), NULL); \ 694 }) 695 696 #define SYSCTL_NULL_UQUAD_PTR ((uint64_t *)NULL) 697 #define SYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr) \ 698 SYSCTL_OID(parent, nbr, name, \ 699 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 700 ptr, val, sysctl_handle_64, "QU", descr); \ 701 CTASSERT((((access) & CTLTYPE) == 0 || \ 702 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \ 703 sizeof(uint64_t) == sizeof(*(ptr))) 704 705 #define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr) \ 706 ({ \ 707 uint64_t *__ptr = (ptr); \ 708 CTASSERT(((access) & CTLTYPE) == 0 || \ 709 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ 710 sysctl_add_oid(ctx, parent, nbr, name, \ 711 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 712 __ptr, 0, sysctl_handle_64, "QU", __DESCR(descr), NULL); \ 713 }) 714 715 /* Oid for a CPU dependent variable */ 716 #define SYSCTL_ADD_UAUTO(ctx, parent, nbr, name, access, ptr, descr) \ 717 ({ \ 718 struct sysctl_oid *__ret; \ 719 CTASSERT((sizeof(uint64_t) == sizeof(*(ptr)) || \ 720 sizeof(unsigned) == sizeof(*(ptr))) && \ 721 ((access) & CTLTYPE) == 0); \ 722 if (sizeof(uint64_t) == sizeof(*(ptr))) { \ 723 __ret = sysctl_add_oid(ctx, parent, nbr, name, \ 724 CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ 725 (ptr), 0, sysctl_handle_64, "QU", \ 726 __DESCR(descr), NULL); \ 727 } else { \ 728 __ret = sysctl_add_oid(ctx, parent, nbr, name, \ 729 CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ 730 (ptr), 0, sysctl_handle_int, "IU", \ 731 __DESCR(descr), NULL); \ 732 } \ 733 __ret; \ 734 }) 735 736 /* Oid for a 64-bit unsigned counter(9). The pointer must be non NULL. */ 737 #define SYSCTL_COUNTER_U64(parent, nbr, name, access, ptr, descr) \ 738 SYSCTL_OID(parent, nbr, name, \ 739 CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_STATS | (access), \ 740 (ptr), 0, sysctl_handle_counter_u64, "QU", descr); \ 741 CTASSERT((((access) & CTLTYPE) == 0 || \ 742 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \ 743 sizeof(counter_u64_t) == sizeof(*(ptr)) && \ 744 sizeof(uint64_t) == sizeof(**(ptr))) 745 746 #define SYSCTL_ADD_COUNTER_U64(ctx, parent, nbr, name, access, ptr, descr) \ 747 ({ \ 748 counter_u64_t *__ptr = (ptr); \ 749 CTASSERT(((access) & CTLTYPE) == 0 || \ 750 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ 751 sysctl_add_oid(ctx, parent, nbr, name, \ 752 CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_STATS | (access), \ 753 __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr), \ 754 NULL); \ 755 }) 756 757 /* Oid for an array of counter(9)s. The pointer and length must be non zero. */ 758 #define SYSCTL_COUNTER_U64_ARRAY(parent, nbr, name, access, ptr, len, descr) \ 759 SYSCTL_OID(parent, nbr, name, \ 760 CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_STATS | (access), \ 761 (ptr), (len), sysctl_handle_counter_u64_array, "QU", descr);\ 762 CTASSERT((((access) & CTLTYPE) == 0 || \ 763 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) && \ 764 sizeof(counter_u64_t) == sizeof(*(ptr)) && \ 765 sizeof(uint64_t) == sizeof(**(ptr))) 766 767 #define SYSCTL_ADD_COUNTER_U64_ARRAY(ctx, parent, nbr, name, access, \ 768 ptr, len, descr) \ 769 ({ \ 770 counter_u64_t *__ptr = (ptr); \ 771 CTASSERT(((access) & CTLTYPE) == 0 || \ 772 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ 773 sysctl_add_oid(ctx, parent, nbr, name, \ 774 CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | CTLFLAG_STATS | (access), \ 775 __ptr, len, sysctl_handle_counter_u64_array, "S", \ 776 __DESCR(descr), NULL); \ 777 }) 778 779 /* Oid for an opaque object. Specified by a pointer and a length. */ 780 #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ 781 SYSCTL_OID(parent, nbr, name, \ 782 CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ 783 ptr, len, sysctl_handle_opaque, fmt, descr); \ 784 CTASSERT(((access) & CTLTYPE) == 0 || \ 785 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) 786 787 #define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \ 788 ({ \ 789 CTASSERT(((access) & CTLTYPE) == 0 || \ 790 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ 791 sysctl_add_oid(ctx, parent, nbr, name, \ 792 CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ 793 ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr), NULL); \ 794 }) 795 796 /* Oid for a struct. Specified by a pointer and a type. */ 797 #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ 798 SYSCTL_OID(parent, nbr, name, \ 799 CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ 800 ptr, sizeof(struct type), sysctl_handle_opaque, \ 801 "S," #type, descr); \ 802 CTASSERT(((access) & CTLTYPE) == 0 || \ 803 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) 804 805 #define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \ 806 ({ \ 807 CTASSERT(((access) & CTLTYPE) == 0 || \ 808 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ 809 sysctl_add_oid(ctx, parent, nbr, name, \ 810 CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ 811 (ptr), sizeof(struct type), \ 812 sysctl_handle_opaque, "S," #type, __DESCR(descr), NULL); \ 813 }) 814 815 /* Oid for a procedure. Specified by a pointer and an arg. */ 816 #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ 817 SYSCTL_OID(parent, nbr, name, (access), \ 818 ptr, arg, handler, fmt, descr); \ 819 CTASSERT(((access) & CTLTYPE) != 0) 820 821 #define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ 822 ({ \ 823 CTASSERT(((access) & CTLTYPE) != 0); \ 824 SYSCTL_ENFORCE_FLAGS(access); \ 825 sysctl_add_oid(ctx, parent, nbr, name, (access), \ 826 (ptr), (arg), (handler), (fmt), __DESCR(descr), NULL); \ 827 }) 828 829 /* Oid to handle limits on uma(9) zone specified by pointer. */ 830 #define SYSCTL_UMA_MAX(parent, nbr, name, access, ptr, descr) \ 831 SYSCTL_OID(parent, nbr, name, \ 832 CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ 833 (ptr), 0, sysctl_handle_uma_zone_max, "I", descr); \ 834 CTASSERT(((access) & CTLTYPE) == 0 || \ 835 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) 836 837 #define SYSCTL_ADD_UMA_MAX(ctx, parent, nbr, name, access, ptr, descr) \ 838 ({ \ 839 uma_zone_t __ptr = (ptr); \ 840 CTASSERT(((access) & CTLTYPE) == 0 || \ 841 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ 842 sysctl_add_oid(ctx, parent, nbr, name, \ 843 CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ 844 __ptr, 0, sysctl_handle_uma_zone_max, "I", __DESCR(descr), \ 845 NULL); \ 846 }) 847 848 /* Oid to obtain current use of uma(9) zone specified by pointer. */ 849 #define SYSCTL_UMA_CUR(parent, nbr, name, access, ptr, descr) \ 850 SYSCTL_OID(parent, nbr, name, \ 851 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 852 (ptr), 0, sysctl_handle_uma_zone_cur, "I", descr); \ 853 CTASSERT(((access) & CTLTYPE) == 0 || \ 854 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) 855 856 #define SYSCTL_ADD_UMA_CUR(ctx, parent, nbr, name, access, ptr, descr) \ 857 ({ \ 858 uma_zone_t __ptr = (ptr); \ 859 CTASSERT(((access) & CTLTYPE) == 0 || \ 860 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ 861 sysctl_add_oid(ctx, parent, nbr, name, \ 862 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 863 __ptr, 0, sysctl_handle_uma_zone_cur, "I", __DESCR(descr), \ 864 NULL); \ 865 }) 866 867 /* OID expressing a sbintime_t as microseconds */ 868 #define SYSCTL_SBINTIME_USEC(parent, nbr, name, access, ptr, descr) \ 869 SYSCTL_OID(parent, nbr, name, \ 870 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 871 (ptr), 0, sysctl_usec_to_sbintime, "Q", descr); \ 872 CTASSERT(((access) & CTLTYPE) == 0 || \ 873 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) 874 #define SYSCTL_ADD_SBINTIME_USEC(ctx, parent, nbr, name, access, ptr, descr) \ 875 ({ \ 876 sbintime_t *__ptr = (ptr); \ 877 CTASSERT(((access) & CTLTYPE) == 0 || \ 878 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ 879 sysctl_add_oid(ctx, parent, nbr, name, \ 880 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 881 __ptr, 0, sysctl_usec_to_sbintime, "Q", __DESCR(descr), \ 882 NULL); \ 883 }) 884 885 /* OID expressing a sbintime_t as milliseconds */ 886 #define SYSCTL_SBINTIME_MSEC(parent, nbr, name, access, ptr, descr) \ 887 SYSCTL_OID(parent, nbr, name, \ 888 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 889 (ptr), 0, sysctl_msec_to_sbintime, "Q", descr); \ 890 CTASSERT(((access) & CTLTYPE) == 0 || \ 891 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) 892 #define SYSCTL_ADD_SBINTIME_MSEC(ctx, parent, nbr, name, access, ptr, descr) \ 893 ({ \ 894 sbintime_t *__ptr = (ptr); \ 895 CTASSERT(((access) & CTLTYPE) == 0 || \ 896 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ 897 sysctl_add_oid(ctx, parent, nbr, name, \ 898 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 899 __ptr, 0, sysctl_msec_to_sbintime, "Q", __DESCR(descr), \ 900 NULL); \ 901 }) 902 903 /* OID expressing a struct timeval as seconds */ 904 #define SYSCTL_TIMEVAL_SEC(parent, nbr, name, access, ptr, descr) \ 905 SYSCTL_OID(parent, nbr, name, \ 906 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 907 (ptr), 0, sysctl_sec_to_timeval, "I", descr); \ 908 CTASSERT(((access) & CTLTYPE) == 0 || \ 909 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) 910 #define SYSCTL_ADD_TIMEVAL_SEC(ctx, parent, nbr, name, access, ptr, descr) \ 911 ({ \ 912 struct timeval *__ptr = (ptr); \ 913 CTASSERT(((access) & CTLTYPE) == 0 || \ 914 ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ 915 sysctl_add_oid(ctx, parent, nbr, name, \ 916 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ 917 __ptr, 0, sysctl_sec_to_timeval, "I", __DESCR(descr), \ 918 NULL); \ 919 }) 920 921 #define SYSCTL_FOREACH(oidp, list) \ 922 RB_FOREACH(oidp, sysctl_oid_list, list) 923 924 /* 925 * A macro to generate a read-only sysctl to indicate the presence of optional 926 * kernel features. 927 */ 928 #define FEATURE(name, desc) \ 929 SYSCTL_INT_WITH_LABEL(_kern_features, OID_AUTO, name, \ 930 CTLFLAG_RD | CTLFLAG_CAPRD, SYSCTL_NULL_INT_PTR, 1, desc, "feature") 931 932 #endif /* _KERNEL */ 933 934 /* 935 * Top-level identifiers 936 */ 937 #define CTL_SYSCTL 0 /* "magic" numbers */ 938 #define CTL_KERN 1 /* "high kernel": proc, limits */ 939 #define CTL_VM 2 /* virtual memory */ 940 #define CTL_VFS 3 /* filesystem, mount type is next */ 941 #define CTL_NET 4 /* network, see socket.h */ 942 #define CTL_DEBUG 5 /* debugging parameters */ 943 #define CTL_HW 6 /* generic cpu/io */ 944 #define CTL_MACHDEP 7 /* machine dependent */ 945 #define CTL_USER 8 /* user-level */ 946 #define CTL_P1003_1B 9 /* POSIX 1003.1B */ 947 948 /* 949 * CTL_SYSCTL identifiers 950 */ 951 #define CTL_SYSCTL_DEBUG 0 /* printf all nodes */ 952 #define CTL_SYSCTL_NAME 1 /* string name of OID */ 953 #define CTL_SYSCTL_NEXT 2 /* next OID, honoring CTLFLAG_SKIP */ 954 #define CTL_SYSCTL_NAME2OID 3 /* int array of name */ 955 #define CTL_SYSCTL_OIDFMT 4 /* OID's kind and format */ 956 #define CTL_SYSCTL_OIDDESCR 5 /* OID's description */ 957 #define CTL_SYSCTL_OIDLABEL 6 /* aggregation label */ 958 #define CTL_SYSCTL_NEXTNOSKIP 7 /* next OID, ignoring CTLFLAG_SKIP */ 959 960 /* 961 * CTL_KERN identifiers 962 */ 963 #define KERN_OSTYPE 1 /* string: system version */ 964 #define KERN_OSRELEASE 2 /* string: system release */ 965 #define KERN_OSREV 3 /* int: system revision */ 966 #define KERN_VERSION 4 /* string: compile time info */ 967 #define KERN_MAXVNODES 5 /* int: max vnodes */ 968 #define KERN_MAXPROC 6 /* int: max processes */ 969 #define KERN_MAXFILES 7 /* int: max open files */ 970 #define KERN_ARGMAX 8 /* int: max arguments to exec */ 971 #define KERN_SECURELVL 9 /* int: system security level */ 972 #define KERN_HOSTNAME 10 /* string: hostname */ 973 #define KERN_HOSTID 11 /* int: host identifier */ 974 #define KERN_CLOCKRATE 12 /* struct: struct clockrate */ 975 /* was: #define KERN_VNODE 13 ; disabled in 2003 and removed in 2023 */ 976 #define KERN_PROC 14 /* struct: process entries */ 977 #define KERN_FILE 15 /* struct: file entries */ 978 #define KERN_PROF 16 /* node: kernel profiling info */ 979 #define KERN_POSIX1 17 /* int: POSIX.1 version */ 980 #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ 981 #define KERN_JOB_CONTROL 19 /* int: is job control available */ 982 #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ 983 #define KERN_BOOTTIME 21 /* struct: time kernel was booted */ 984 #define KERN_NISDOMAINNAME 22 /* string: YP domain name */ 985 #define KERN_UPDATEINTERVAL 23 /* int: update process sleep time */ 986 #define KERN_OSRELDATE 24 /* int: kernel release date */ 987 #define KERN_NTP_PLL 25 /* node: NTP PLL control */ 988 #define KERN_BOOTFILE 26 /* string: name of booted kernel */ 989 #define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */ 990 #define KERN_MAXPROCPERUID 28 /* int: max processes per uid */ 991 #define KERN_DUMPDEV 29 /* struct cdev *: device to dump on */ 992 #define KERN_IPC 30 /* node: anything related to IPC */ 993 #define KERN_DUMMY 31 /* unused */ 994 #define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */ 995 #define KERN_USRSTACK 33 /* int: address of USRSTACK */ 996 #define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ 997 #define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ 998 #define KERN_HOSTUUID 36 /* string: host UUID identifier */ 999 #define KERN_ARND 37 /* int: from arc4rand() */ 1000 #define KERN_MAXPHYS 38 /* int: MAXPHYS value */ 1001 #define KERN_LOCKF 39 /* struct: lockf reports */ 1002 /* 1003 * KERN_PROC subtypes 1004 */ 1005 #define KERN_PROC_ALL 0 /* everything */ 1006 #define KERN_PROC_PID 1 /* by process id */ 1007 #define KERN_PROC_PGRP 2 /* by process group id */ 1008 #define KERN_PROC_SESSION 3 /* by session of pid */ 1009 #define KERN_PROC_TTY 4 /* by controlling tty */ 1010 #define KERN_PROC_UID 5 /* by effective uid */ 1011 #define KERN_PROC_RUID 6 /* by real uid */ 1012 #define KERN_PROC_ARGS 7 /* get/set arguments/proctitle */ 1013 #define KERN_PROC_PROC 8 /* only return procs */ 1014 #define KERN_PROC_SV_NAME 9 /* get syscall vector name */ 1015 #define KERN_PROC_RGID 10 /* by real group id */ 1016 #define KERN_PROC_GID 11 /* by effective group id */ 1017 #define KERN_PROC_PATHNAME 12 /* path to executable */ 1018 #define KERN_PROC_OVMMAP 13 /* Old VM map entries for process */ 1019 #define KERN_PROC_OFILEDESC 14 /* Old file descriptors for process */ 1020 #define KERN_PROC_KSTACK 15 /* Kernel stacks for process */ 1021 #define KERN_PROC_INC_THREAD 0x10 /* 1022 * modifier for pid, pgrp, tty, 1023 * uid, ruid, gid, rgid and proc 1024 * This effectively uses 16-31 1025 */ 1026 #define KERN_PROC_VMMAP 32 /* VM map entries for process */ 1027 #define KERN_PROC_FILEDESC 33 /* File descriptors for process */ 1028 #define KERN_PROC_GROUPS 34 /* process groups */ 1029 #define KERN_PROC_ENV 35 /* get environment */ 1030 #define KERN_PROC_AUXV 36 /* get ELF auxiliary vector */ 1031 #define KERN_PROC_RLIMIT 37 /* process resource limits */ 1032 #define KERN_PROC_PS_STRINGS 38 /* get ps_strings location */ 1033 #define KERN_PROC_UMASK 39 /* process umask */ 1034 #define KERN_PROC_OSREL 40 /* osreldate for process binary */ 1035 #define KERN_PROC_SIGTRAMP 41 /* signal trampoline location */ 1036 #define KERN_PROC_CWD 42 /* process current working directory */ 1037 #define KERN_PROC_NFDS 43 /* number of open file descriptors */ 1038 #define KERN_PROC_SIGFASTBLK 44 /* address of fastsigblk magic word */ 1039 #define KERN_PROC_VM_LAYOUT 45 /* virtual address space layout info */ 1040 1041 /* 1042 * KERN_IPC identifiers 1043 */ 1044 #define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ 1045 #define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ 1046 #define KIPC_SOMAXCONN 3 /* int: max length of connection q */ 1047 #define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ 1048 #define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ 1049 #define KIPC_MAX_HDR 6 /* int: max total length of headers */ 1050 #define KIPC_MAX_DATALEN 7 /* int: max length of data? */ 1051 1052 /* 1053 * CTL_HW identifiers 1054 */ 1055 #define HW_MACHINE 1 /* string: machine class */ 1056 #define HW_MODEL 2 /* string: specific machine model */ 1057 #define HW_NCPU 3 /* int: number of cpus */ 1058 #define HW_BYTEORDER 4 /* int: machine byte order */ 1059 #define HW_PHYSMEM 5 /* int: total memory */ 1060 #define HW_USERMEM 6 /* int: non-kernel memory */ 1061 #define HW_PAGESIZE 7 /* int: software page size */ 1062 #define HW_DISKNAMES 8 /* strings: disk drive names */ 1063 #define HW_DISKSTATS 9 /* struct: diskstats[] */ 1064 #define HW_FLOATINGPT 10 /* int: has HW floating point? */ 1065 #define HW_MACHINE_ARCH 11 /* string: machine architecture */ 1066 #define HW_REALMEM 12 /* int: 'real' memory */ 1067 1068 /* 1069 * CTL_USER definitions 1070 */ 1071 #define USER_CS_PATH 1 /* string: _CS_PATH */ 1072 #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ 1073 #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ 1074 #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ 1075 #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ 1076 #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ 1077 #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ 1078 #define USER_LINE_MAX 8 /* int: LINE_MAX */ 1079 #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ 1080 #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ 1081 #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ 1082 #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ 1083 #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ 1084 #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ 1085 #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ 1086 #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ 1087 #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ 1088 #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ 1089 #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ 1090 #define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ 1091 #define USER_LOCALBASE 21 /* string: _PATH_LOCALBASE */ 1092 1093 #define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */ 1094 #define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */ 1095 #define CTL_P1003_1B_MEMLOCK 3 /* boolean */ 1096 #define CTL_P1003_1B_MEMLOCK_RANGE 4 /* boolean */ 1097 #define CTL_P1003_1B_MEMORY_PROTECTION 5 /* boolean */ 1098 #define CTL_P1003_1B_MESSAGE_PASSING 6 /* boolean */ 1099 #define CTL_P1003_1B_PRIORITIZED_IO 7 /* boolean */ 1100 #define CTL_P1003_1B_PRIORITY_SCHEDULING 8 /* boolean */ 1101 #define CTL_P1003_1B_REALTIME_SIGNALS 9 /* boolean */ 1102 #define CTL_P1003_1B_SEMAPHORES 10 /* boolean */ 1103 #define CTL_P1003_1B_FSYNC 11 /* boolean */ 1104 #define CTL_P1003_1B_SHARED_MEMORY_OBJECTS 12 /* boolean */ 1105 #define CTL_P1003_1B_SYNCHRONIZED_IO 13 /* boolean */ 1106 #define CTL_P1003_1B_TIMERS 14 /* boolean */ 1107 #define CTL_P1003_1B_AIO_LISTIO_MAX 15 /* int */ 1108 #define CTL_P1003_1B_AIO_MAX 16 /* int */ 1109 #define CTL_P1003_1B_AIO_PRIO_DELTA_MAX 17 /* int */ 1110 #define CTL_P1003_1B_DELAYTIMER_MAX 18 /* int */ 1111 #define CTL_P1003_1B_MQ_OPEN_MAX 19 /* int */ 1112 #define CTL_P1003_1B_PAGESIZE 20 /* int */ 1113 #define CTL_P1003_1B_RTSIG_MAX 21 /* int */ 1114 #define CTL_P1003_1B_SEM_NSEMS_MAX 22 /* int */ 1115 #define CTL_P1003_1B_SEM_VALUE_MAX 23 /* int */ 1116 #define CTL_P1003_1B_SIGQUEUE_MAX 24 /* int */ 1117 #define CTL_P1003_1B_TIMER_MAX 25 /* int */ 1118 1119 #ifdef _KERNEL 1120 1121 #define CTL_P1003_1B_MAXID 26 1122 1123 /* 1124 * Declare some common oids. 1125 */ 1126 extern struct sysctl_oid_list sysctl__children; 1127 SYSCTL_DECL(_kern); 1128 SYSCTL_DECL(_kern_features); 1129 SYSCTL_DECL(_kern_ipc); 1130 SYSCTL_DECL(_kern_proc); 1131 SYSCTL_DECL(_kern_sched); 1132 SYSCTL_DECL(_kern_sched_stats); 1133 SYSCTL_DECL(_sysctl); 1134 SYSCTL_DECL(_vm); 1135 SYSCTL_DECL(_vm_stats); 1136 SYSCTL_DECL(_vm_stats_misc); 1137 SYSCTL_DECL(_vfs); 1138 SYSCTL_DECL(_net); 1139 SYSCTL_DECL(_debug); 1140 SYSCTL_DECL(_debug_sizeof); 1141 SYSCTL_DECL(_dev); 1142 SYSCTL_DECL(_hw); 1143 SYSCTL_DECL(_hw_bus); 1144 SYSCTL_DECL(_hw_bus_devices); 1145 SYSCTL_DECL(_machdep); 1146 SYSCTL_DECL(_machdep_mitigations); 1147 SYSCTL_DECL(_user); 1148 SYSCTL_DECL(_compat); 1149 SYSCTL_DECL(_regression); 1150 SYSCTL_DECL(_security); 1151 SYSCTL_DECL(_security_bsd); 1152 1153 extern char machine[]; 1154 extern char osrelease[]; 1155 extern char ostype[]; 1156 extern char kern_ident[]; 1157 1158 /* Dynamic oid handling */ 1159 struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, 1160 struct sysctl_oid_list *parent, int nbr, const char *name, int kind, 1161 void *arg1, intmax_t arg2, int (*handler)(SYSCTL_HANDLER_ARGS), 1162 const char *fmt, const char *descr, const char *label); 1163 int sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del, 1164 int recurse); 1165 void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); 1166 int sysctl_move_oid(struct sysctl_oid *oidp, 1167 struct sysctl_oid_list *parent); 1168 int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse); 1169 int sysctl_ctx_init(struct sysctl_ctx_list *clist); 1170 int sysctl_ctx_free(struct sysctl_ctx_list *clist); 1171 struct sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist, 1172 struct sysctl_oid *oidp); 1173 struct sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist, 1174 struct sysctl_oid *oidp); 1175 int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist, 1176 struct sysctl_oid *oidp); 1177 1178 int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, 1179 size_t *oldlenp, void *new, size_t newlen, size_t *retval, 1180 int flags); 1181 int kernel_sysctlbyname(struct thread *td, char *name, void *old, 1182 size_t *oldlenp, void *new, size_t newlen, size_t *retval, 1183 int flags); 1184 int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, 1185 size_t *oldlenp, int inkernel, const void *new, size_t newlen, 1186 size_t *retval, int flags); 1187 int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, 1188 int *nindx, struct sysctl_req *req); 1189 void sysctl_wlock(void); 1190 void sysctl_wunlock(void); 1191 int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); 1192 int kern___sysctlbyname(struct thread *td, const char *name, 1193 size_t namelen, void *old, size_t *oldlenp, void *new, 1194 size_t newlen, size_t *retval, int flags, bool inkernel); 1195 1196 struct sbuf; 1197 struct sbuf *sbuf_new_for_sysctl(struct sbuf *, char *, int, 1198 struct sysctl_req *); 1199 #else /* !_KERNEL */ 1200 #include <sys/cdefs.h> 1201 #include <sys/_types.h> 1202 #ifndef _SIZE_T_DECLARED 1203 typedef __size_t size_t; 1204 #define _SIZE_T_DECLARED 1205 #endif 1206 1207 __BEGIN_DECLS 1208 int sysctl(const int *, unsigned int, void *, size_t *, const void *, size_t); 1209 int sysctlbyname(const char *, void *, size_t *, const void *, size_t); 1210 int sysctlnametomib(const char *, int *, size_t *); 1211 __END_DECLS 1212 #endif /* _KERNEL */ 1213 1214 #endif /* !_SYS_SYSCTL_H_ */ 1215