2 * Copyright (c) 2018-2019 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #include <sys/sysctl.h>
32 #include <net/multi_layer_pkt_log.h>
34 SYSCTL_NODE(_net
, OID_AUTO
, mpklog
,
35 CTLFLAG_RW
| CTLFLAG_LOCKED
, 0, "Multi-layer packet logging");
38 * Note: net_mpklog_enabled allows to override the interface flags IFXF_MPK_LOG
40 int net_mpklog_enabled
= 1;
41 static int sysctl_net_mpklog_enabled SYSCTL_HANDLER_ARGS
;
42 SYSCTL_PROC(_net_mpklog
, OID_AUTO
, enabled
, CTLTYPE_INT
| CTLFLAG_LOCKED
| CTLFLAG_RW
,
43 0, 0, &sysctl_net_mpklog_enabled
, "I", "Multi-layer packet logging enabled");
45 static int sysctl_net_mpklog_type SYSCTL_HANDLER_ARGS
;
46 uint8_t net_mpklog_type
= OS_LOG_TYPE_DEFAULT
;
47 SYSCTL_PROC(_net_mpklog
, OID_AUTO
, type
, CTLTYPE_INT
| CTLFLAG_LOCKED
| CTLFLAG_RW
,
48 0, 0, &sysctl_net_mpklog_type
, "I", "Multi-layer packet logging type");
50 SYSCTL_INT(_net_mpklog
, OID_AUTO
, version
, CTLFLAG_RD
| CTLFLAG_LOCKED
,
51 (int *)NULL
, MPKL_VERSION
, "Multi-layer packet logging version");
54 sysctl_net_mpklog_enabled SYSCTL_HANDLER_ARGS
56 #pragma unused(arg1, arg2)
57 int value
= net_mpklog_enabled
;
59 int error
= sysctl_handle_int(oidp
, &value
, 0, req
);
60 if (error
|| !req
->newptr
) {
64 net_mpklog_enabled
= (value
== 0) ? 0 : 1;
66 os_log(OS_LOG_DEFAULT
, "%s:%d set net_mpklog_enabled to %d",
67 proc_best_name(current_proc()), proc_selfpid(), net_mpklog_enabled
);
73 sysctl_net_mpklog_type SYSCTL_HANDLER_ARGS
75 #pragma unused(arg1, arg2)
76 int value
= net_mpklog_type
;
78 int error
= sysctl_handle_int(oidp
, &value
, 0, req
);
79 if (error
|| !req
->newptr
) {
83 if (value
!= OS_LOG_TYPE_DEFAULT
&&
84 value
!= OS_LOG_TYPE_INFO
) {
87 net_mpklog_type
= (uint8_t)value
;
89 os_log(OS_LOG_DEFAULT
, "%s:%d set net_mpklog_type to %u (%s)",
90 proc_best_name(current_proc()), proc_selfpid(), net_mpklog_type
,
91 net_mpklog_type
== OS_LOG_TYPE_DEFAULT
? "default" : "info");