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