2 * Copyright (c) 2000-2017 Apple Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * Modification History
27 * December 3, 2002 Dieter Siegmund <dieter@apple.com>
28 * - handle the new KEV_INET_ARPCOLLISION event
29 * - format the event into a DynamicStore key
30 * State:/Network/Interface/ifname/IPv4Collision/ip_addr/hw_addr
31 * and send a notification on the key
33 * August 8, 2002 Allan Nathanson <ajn@apple.com>
34 * - added support for KEV_INET6_xxx events
36 * January 6, 2002 Jessica Vazquez <vazquez@apple.com>
37 * - added handling for KEV_ATALK_xxx events
39 * July 2, 2001 Dieter Siegmund <dieter@apple.com>
40 * - added handling for KEV_DL_PROTO_{ATTACHED, DETACHED}
41 * - mark an interface up if the number of protocols remaining is not 0,
42 * mark an interface down if the number is zero
43 * - allocate socket on demand instead of keeping it open all the time
45 * June 23, 2001 Allan Nathanson <ajn@apple.com>
46 * - update to public SystemConfiguration.framework APIs
48 * May 17, 2001 Allan Nathanson <ajn@apple.com>
49 * - add/maintain per-interface address/netmask/destaddr information
50 * in the dynamic store.
52 * June 30, 2000 Allan Nathanson <ajn@apple.com>
62 #include <sys/sysctl.h>
63 #include <sys/kern_event.h>
64 #include <network/config.h>
65 #include <netinet6/nd6.h>
67 static dispatch_queue_t S_kev_queue
;
68 static dispatch_source_t S_kev_source
;
69 __private_extern__ Boolean network_changed
= FALSE
;
70 __private_extern__ SCDynamicStoreRef store
= NULL
;
71 __private_extern__ Boolean _verbose
= FALSE
;
74 __private_extern__ os_log_t
75 __log_KernelEventMonitor()
77 static os_log_t log
= NULL
;
80 log
= os_log_create("com.apple.SystemConfiguration", "KernelEventMonitor");
87 #define MESSAGES_MAX 100
88 static CFMutableArrayRef S_messages
;
89 static Boolean S_messages_modified
;
94 S_messages
= CFArrayCreateMutable(NULL
,
96 &kCFTypeArrayCallBacks
);
103 if (S_messages
!= NULL
) {
104 CFRelease(S_messages
);
111 messages_should_add_message(void)
113 if (S_messages
== NULL
114 || CFArrayGetCount(S_messages
) >= MESSAGES_MAX
) {
121 messages_add_message(CFStringRef message
)
123 if (messages_should_add_message()) {
124 CFArrayAppendValue(S_messages
, message
);
125 S_messages_modified
= TRUE
;
130 __private_extern__
void
131 messages_add_msg_with_arg(const char * msg
, const char * arg
)
133 if (messages_should_add_message()) {
136 str
= CFStringCreateWithFormat(NULL
, NULL
,
137 CFSTR("%12.8f: %s %s"),
138 CFAbsoluteTimeGetCurrent(),
140 messages_add_message(str
);
149 if (S_messages
!= NULL
&& S_messages_modified
) {
150 SCDynamicStoreSetValue(NULL
,
151 CFSTR("Plugin:KernelEventMonitor"),
153 S_messages_modified
= FALSE
;
159 check_interface_link_status(const char * if_name
)
161 if (S_messages
== NULL
) {
162 return; /* we're not in early boot of system */
164 link_update_status_if_missing(if_name
);
170 dgram_socket(int domain
)
174 s
= socket(domain
, SOCK_DGRAM
, 0);
176 SC_log(LOG_ERR
, "socket() failed: %s", strerror(errno
));
183 ifflags_set(int s
, char * name
, short flags
)
188 bzero(&ifr
, sizeof(ifr
));
189 strlcpy(ifr
.ifr_name
, name
, sizeof(ifr
.ifr_name
));
190 ret
= ioctl(s
, SIOCGIFFLAGS
, (caddr_t
)&ifr
);
194 ifr
.ifr_flags
|= flags
;
195 return (ioctl(s
, SIOCSIFFLAGS
, &ifr
));
199 ifflags_clear(int s
, char * name
, short flags
)
204 bzero(&ifr
, sizeof(ifr
));
205 strlcpy(ifr
.ifr_name
, name
, sizeof(ifr
.ifr_name
));
206 ret
= ioctl(s
, SIOCGIFFLAGS
, (caddr_t
)&ifr
);
210 ifr
.ifr_flags
&= ~flags
;
211 return (ioctl(s
, SIOCSIFFLAGS
, &ifr
));
215 mark_if_up(char * name
)
217 int s
= dgram_socket(AF_INET
);
220 ifflags_set(s
, name
, IFF_UP
);
225 mark_if_down(char * name
)
227 int s
= dgram_socket(AF_INET
);
230 ifflags_clear(s
, name
, IFF_UP
);
235 post_network_changed(void)
237 if (network_changed
) {
240 status
= notify_post(_SC_NOTIFY_NETWORK_CHANGE
);
241 if (status
!= NOTIFY_STATUS_OK
) {
242 SC_log(LOG_NOTICE
, "notify_post() failed: error=%u", status
);
245 network_changed
= FALSE
;
252 logEvent(CFStringRef evStr
, struct kern_event_msg
*ev_msg
)
261 SC_log(LOG_DEBUG
, "%@ event:", evStr
);
262 SC_log(LOG_DEBUG
, " Event size=%d, id=%d, vendor=%d, class=%d, subclass=%d, code=%d",
267 ev_msg
->kev_subclass
,
269 for (i
= 0, j
= KEV_MSG_HEADER_SIZE
; j
< ev_msg
->total_size
; i
++, j
+=4) {
270 SC_log(LOG_DEBUG
, " Event data[%2d] = %08x", i
, ev_msg
->event_data
[i
]);
275 copy_if_name(const struct net_event_data
* ev
, char * ifr_name
, int ifr_len
)
277 snprintf(ifr_name
, ifr_len
, "%s%d", ev
->if_name
, ev
->if_unit
);
281 static uint8_t info_zero
[DLIL_MODARGLEN
];
284 processEvent_Apple_Network(struct kern_event_msg
*ev_msg
)
286 size_t dataLen
= (ev_msg
->total_size
- KEV_MSG_HEADER_SIZE
);
287 void * event_data
= &ev_msg
->event_data
[0];
288 char ifr_name
[IFNAMSIZ
];
289 Boolean handled
= TRUE
;
291 switch (ev_msg
->kev_subclass
) {
292 case KEV_INET_SUBCLASS
: {
293 switch (ev_msg
->event_code
) {
294 case KEV_INET_NEW_ADDR
:
295 case KEV_INET_CHANGED_ADDR
:
296 case KEV_INET_ADDR_DELETED
:
297 case KEV_INET_SIFDSTADDR
:
298 case KEV_INET_SIFBRDADDR
:
299 case KEV_INET_SIFNETMASK
: {
300 struct kev_in_data
* ev
;
302 ev
= (struct kev_in_data
*)event_data
;
303 if (dataLen
< sizeof(*ev
)) {
307 copy_if_name(&ev
->link_data
, ifr_name
, sizeof(ifr_name
));
308 SC_log(LOG_INFO
, "Process IPv4 address change: %s: %d", (char *)ifr_name
, ev_msg
->event_code
);
309 ipv4_interface_update(NULL
, ifr_name
);
310 if (ev_msg
->event_code
311 != KEV_INET_ADDR_DELETED
) {
312 check_interface_link_status(ifr_name
);
316 case KEV_INET_ARPCOLLISION
: {
317 struct kev_in_collision
* ev
;
319 ev
= (struct kev_in_collision
*)event_data
;
320 if ((dataLen
< sizeof(*ev
))
321 || (dataLen
< (sizeof(*ev
) + ev
->hw_len
))) {
325 copy_if_name(&ev
->link_data
, ifr_name
, sizeof(ifr_name
));
326 SC_log(LOG_INFO
, "Process ARP collision: %s", (char *)ifr_name
);
327 ipv4_arp_collision(ifr_name
,
333 #if !TARGET_OS_IPHONE
334 case KEV_INET_PORTINUSE
: {
335 struct kev_in_portinuse
* ev
;
336 ev
= (struct kev_in_portinuse
*)event_data
;
337 if (dataLen
< sizeof(*ev
)) {
341 SC_log(LOG_INFO
, "Process port-in-use: %hu, %u", ev
->port
, ev
->req_pid
);
342 ipv4_port_in_use(ev
->port
, ev
->req_pid
);
345 #endif /* !TARGET_OS_IPHONE */
346 case KEV_INET_ARPRTRFAILURE
: {
347 const struct kev_in_arpfailure
* ev
;
349 ev
= (const struct kev_in_arpfailure
*)event_data
;
350 if (dataLen
< sizeof(*ev
)) {
354 copy_if_name(&ev
->link_data
, ifr_name
, sizeof(ifr_name
));
355 SC_log(LOG_INFO
, "Process router ARP failure: %s", (char *)ifr_name
);
356 ipv4_router_arp_failure(ifr_name
);
359 case KEV_INET_ARPRTRALIVE
: {
360 const struct kev_in_arpalive
* ev
;
362 ev
= (const struct kev_in_arpalive
*)event_data
;
363 if (dataLen
< sizeof(*ev
)) {
367 copy_if_name(&ev
->link_data
, ifr_name
, sizeof(ifr_name
));
368 SC_log(LOG_INFO
, "Process router ARP alive: %s", (char *)ifr_name
);
369 ipv4_router_arp_alive(ifr_name
);
378 case KEV_INET6_SUBCLASS
: {
379 struct kev_in6_data
* ev
;
381 ev
= (struct kev_in6_data
*)event_data
;
382 switch (ev_msg
->event_code
) {
383 case KEV_INET6_NEW_USER_ADDR
:
384 case KEV_INET6_CHANGED_ADDR
:
385 case KEV_INET6_ADDR_DELETED
:
386 case KEV_INET6_NEW_LL_ADDR
:
387 case KEV_INET6_NEW_RTADV_ADDR
:
388 if (dataLen
< sizeof(*ev
)) {
392 copy_if_name(&ev
->link_data
, ifr_name
, sizeof(ifr_name
));
393 SC_log(LOG_INFO
, "Process IPv6 address change: %s: %d", (char *)ifr_name
, ev_msg
->event_code
);
394 interface_update_ipv6(NULL
, ifr_name
);
395 if (ev_msg
->event_code
== KEV_INET6_NEW_USER_ADDR
396 && (ev
->ia6_flags
& IN6_IFF_DUPLICATED
) != 0) {
397 ipv6_duplicated_address(ifr_name
,
398 &ev
->ia_addr
.sin6_addr
,
402 if (ev_msg
->event_code
403 != KEV_INET6_ADDR_DELETED
) {
404 check_interface_link_status(ifr_name
);
408 case KEV_INET6_REQUEST_NAT64_PREFIX
:
409 if (dataLen
< sizeof(*ev
)) {
413 copy_if_name(&ev
->link_data
, ifr_name
, sizeof(ifr_name
));
414 SC_log(LOG_INFO
, "Process NAT64 prefix request: %s", (char *)ifr_name
);
415 nat64_prefix_request(ifr_name
);
424 case KEV_DL_SUBCLASS
: {
425 struct net_event_data
* ev
;
427 ev
= (struct net_event_data
*)event_data
;
428 switch (ev_msg
->event_code
) {
429 case KEV_DL_IF_ATTACHED
:
431 * new interface added
433 if (dataLen
< sizeof(*ev
)) {
437 copy_if_name(ev
, ifr_name
, sizeof(ifr_name
));
438 SC_log(LOG_INFO
, "Process interface attach: %s", (char *)ifr_name
);
442 case KEV_DL_IF_DETACHED
:
446 if (dataLen
< sizeof(*ev
)) {
450 copy_if_name(ev
, ifr_name
, sizeof(ifr_name
));
451 SC_log(LOG_INFO
, "Process interface detach: %s", (char *)ifr_name
);
452 link_remove(ifr_name
);
455 case KEV_DL_IF_DETACHING
:
457 * interface detaching
459 if (dataLen
< sizeof(*ev
)) {
463 copy_if_name(ev
, ifr_name
, sizeof(ifr_name
));
464 SC_log(LOG_INFO
, "Process interface detaching: %s", (char *)ifr_name
);
465 interface_detaching(ifr_name
);
468 case KEV_DL_PROTO_ATTACHED
:
469 case KEV_DL_PROTO_DETACHED
: {
470 struct kev_dl_proto_data
* protoEvent
;
472 protoEvent
= (struct kev_dl_proto_data
*)event_data
;
473 if (dataLen
< sizeof(*protoEvent
)) {
477 copy_if_name(&protoEvent
->link_data
,
478 ifr_name
, sizeof(ifr_name
));
479 SC_log(LOG_INFO
, "Process protocol %s: %s (pf=%d, n=%d)",
480 (ev_msg
->event_code
== KEV_DL_PROTO_ATTACHED
) ? "attach" : "detach",
482 protoEvent
->proto_family
,
483 protoEvent
->proto_remaining_count
);
484 if (protoEvent
->proto_remaining_count
== 0) {
485 mark_if_down(ifr_name
);
487 mark_if_up(ifr_name
);
492 #ifdef KEV_DL_IF_IDLE_ROUTE_REFCNT
493 case KEV_DL_IF_IDLE_ROUTE_REFCNT
: {
495 * interface route refcnt idle
497 if (dataLen
< sizeof(*ev
)) {
501 copy_if_name(ev
, ifr_name
, sizeof(ifr_name
));
502 SC_log(LOG_INFO
, "Process interface idle: %s", (char *)ifr_name
);
503 interface_update_idle_state(ifr_name
);
506 #endif // KEV_DL_IF_IDLE_ROUTE_REFCNT
508 case KEV_DL_LINK_OFF
:
509 case KEV_DL_LINK_ON
:
511 * update the link status in the store
513 if (dataLen
< sizeof(*ev
)) {
517 copy_if_name(ev
, ifr_name
, sizeof(ifr_name
));
518 SC_log(LOG_INFO
, "Process interface link %s: %s",
519 (ev_msg
->event_code
== KEV_DL_LINK_ON
) ? "up" : "down",
521 link_update_status(ifr_name
, FALSE
, FALSE
);
524 #ifdef KEV_DL_LINK_QUALITY_METRIC_CHANGED
525 case KEV_DL_LINK_QUALITY_METRIC_CHANGED
: {
526 struct kev_dl_link_quality_metric_data
* lqm_data
;
527 lqm_data
= (struct kev_dl_link_quality_metric_data
*) event_data
;
529 if (dataLen
< sizeof(*ev
)) {
533 copy_if_name(ev
, ifr_name
, sizeof(ifr_name
));
534 SC_log(LOG_INFO
, "Process interface quality: %s (q=%d)",
536 lqm_data
->link_quality_metric
);
537 interface_update_quality_metric(ifr_name
,
538 lqm_data
->link_quality_metric
);
541 #endif // KEV_DL_LINK_QUALITY_METRIC_CHANGED
544 case KEV_DL_ISSUES
: {
545 struct kev_dl_issues
*issues
;
547 issues
= (struct kev_dl_issues
*)event_data
;
548 if (dataLen
< sizeof(*ev
)) {
552 copy_if_name(ev
, ifr_name
, sizeof(ifr_name
));
553 SC_log(LOG_INFO
, "Process interface link issues: %s",
555 interface_update_link_issues(ifr_name
,
560 (bcmp(issues
->info
, info_zero
, DLIL_MODARGLEN
) != 0)
565 #endif // KEV_DL_ISSUES
573 #ifdef KEV_NETPOLICY_SUBCLASS
574 case KEV_NETPOLICY_SUBCLASS
: {
577 #endif // KEV_NETPOLICY_SUBCLASS
579 #ifdef KEV_SOCKET_SUBCLASS
580 case KEV_SOCKET_SUBCLASS
: {
583 #endif // KEV_SOCKET_SUBCLASS
585 #ifdef KEV_ND6_SUBCLASS
586 case KEV_ND6_SUBCLASS
: {
587 struct kev_nd6_event
* ev
;
589 ev
= (struct kev_nd6_event
*)event_data
;
590 switch (ev_msg
->event_code
) {
591 case KEV_ND6_ADDR_DETACHED
:
592 case KEV_ND6_ADDR_DEPRECATED
:
593 case KEV_ND6_ADDR_EXPIRED
:
594 if (dataLen
< sizeof(*ev
)) {
598 copy_if_name(&ev
->link_data
, ifr_name
, sizeof(ifr_name
));
599 SC_log(LOG_INFO
, "Process ND6 address change: %s: %d", (char *)ifr_name
, ev_msg
->event_code
);
600 interface_update_ipv6(NULL
, ifr_name
);
602 case KEV_ND6_RTR_EXPIRED
:
603 if (dataLen
< sizeof(*ev
)) {
607 copy_if_name(&ev
->link_data
, ifr_name
, sizeof(ifr_name
));
608 SC_log(LOG_INFO
, "Process IPv6 router expired: %s: %d", (char *)ifr_name
, ev_msg
->event_code
);
609 ipv6_router_expired(ifr_name
);
616 #endif // KEV_ND6_SUBCLASS
618 #ifdef KEV_NECP_SUBCLASS
619 case KEV_NECP_SUBCLASS
: {
622 #endif // KEV_NECP_SUBCLASS
624 #ifdef KEV_NETAGENT_SUBCLASS
625 case KEV_NETAGENT_SUBCLASS
: {
628 #endif // KEV_NETAGENT_SUBCLASS
630 #ifdef KEV_LOG_SUBCLASS
631 case KEV_LOG_SUBCLASS
: {
634 #endif // KEV_LOG_SUBCLASS
636 #ifdef KEV_NETEVENT_SUBCLASS
637 case KEV_NETEVENT_SUBCLASS
: {
640 #endif // KEV_NETEVENT_SUBCLASS
647 logEvent(CFSTR("Error processing (Apple network subclass)"), ev_msg
);
653 eventCallback(int so
)
657 struct kern_event_msg ev_msg1
; // first kernel event
659 struct kern_event_msg
*ev_msg
= &buf
.ev_msg1
;
663 status
= recv(so
, &buf
, sizeof(buf
), 0);
665 SC_log(LOG_NOTICE
, "recv() failed: %s", strerror(errno
));
671 while (offset
< status
) {
672 if ((offset
+ (ssize_t
)ev_msg
->total_size
) > status
) {
673 SC_log(LOG_NOTICE
, "missed SYSPROTO_EVENT event, buffer not big enough");
677 switch (ev_msg
->vendor_code
) {
678 case KEV_VENDOR_APPLE
:
679 switch (ev_msg
->kev_class
) {
680 case KEV_NETWORK_CLASS
:
681 processEvent_Apple_Network(ev_msg
);
691 offset
+= ev_msg
->total_size
;
692 ev_msg
= (struct kern_event_msg
*)(void *)&buf
.bytes
[offset
];
697 post_network_changed();
704 __private_extern__
void
705 config_new_interface(const char * ifname
)
707 xpc_object_t if_list
;
709 if (ifname
== NULL
) {
710 network_config_check_interface_settings(NULL
);
713 if_list
= xpc_array_create(NULL
, 0);
714 xpc_array_set_string(if_list
, XPC_ARRAY_APPEND
, ifname
);
715 network_config_check_interface_settings(if_list
);
716 xpc_release(if_list
);
721 update_interfaces(const char * msg
, Boolean first_time
)
723 Boolean added
= FALSE
;
724 struct ifaddrs
* ifap
= NULL
;
725 CFMutableArrayRef ifList
= NULL
;
726 struct ifaddrs
* scan
;
728 if (getifaddrs(&ifap
) == -1) {
729 messages_add_msg_with_arg("getifaddrs", strerror(errno
));
730 SC_log(LOG_NOTICE
, "getifaddrs() failed: %s", strerror(errno
));
734 /* update list of interfaces & link status */
735 ifList
= interfaceListCopy();
736 for (scan
= ifap
; scan
!= NULL
; scan
= scan
->ifa_next
) {
737 if (scan
->ifa_addr
== NULL
738 || scan
->ifa_addr
->sa_family
!= AF_LINK
) {
741 /* get the per-interface link/media information */
742 if (interfaceListAddInterface(ifList
, scan
->ifa_name
)) {
743 messages_add_msg_with_arg(msg
, scan
->ifa_name
);
746 config_new_interface(scan
->ifa_name
);
751 /* update the global list if an interface was added */
753 interfaceListUpdate(ifList
);
757 /* update IPv4/IPv6 addresses that are already assigned */
759 ipv4_interface_update(ifap
, NULL
);
760 interface_update_ipv6(ifap
, NULL
);
767 /* tell networkd to get the interface list itself */
768 config_new_interface(NULL
);
773 #define TIMER_INTERVAL (6LL * NSEC_PER_SEC)
774 #define MAX_TIMER_COUNT 20
777 check_for_new_interfaces(void * context
);
782 dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW
, TIMER_INTERVAL
),
785 check_for_new_interfaces
);
790 check_for_new_interfaces(void * context
)
792 #pragma unused(context)
798 /* update KEV driven content in case a message got dropped */
799 snprintf(msg
, sizeof(msg
), "update %d (of %d)", count
, MAX_TIMER_COUNT
);
801 update_interfaces(msg
, FALSE
);
806 /* schedule the next timer, if needed */
807 if (count
< MAX_TIMER_COUNT
) {
820 SC_log(LOG_DEBUG
, "prime() called");
824 update_interfaces("prime", TRUE
);
828 network_changed
= TRUE
;
829 post_network_changed();
832 /* start handling kernel events */
833 dispatch_resume(S_kev_source
);
835 /* schedule polling timer */
844 prime_KernelEventMonitor()
846 dispatch_async(S_kev_queue
, ^{ prime(); });
851 initialize_store(void)
853 store
= SCDynamicStoreCreate(NULL
,
854 CFSTR("Kernel Event Monitor plug-in"),
858 SC_log(LOG_ERR
, "SCDynamicStoreCreate() failed: %s", SCErrorString(SCError()));
867 load_KernelEventMonitor(CFBundleRef bundle
, Boolean bundleVerbose
)
869 struct kev_request kev_req
;
877 SC_log(LOG_DEBUG
, "load() called");
878 SC_log(LOG_DEBUG
, " bundle ID = %@", CFBundleGetIdentifier(bundle
));
880 if (!initialize_store()) {
881 SC_log(LOG_ERR
, "kernel event monitor disabled");
885 /* Open an event socket */
886 so
= socket(PF_SYSTEM
, SOCK_RAW
, SYSPROTO_EVENT
);
888 /* establish filter to return events of interest */
889 kev_req
.vendor_code
= KEV_VENDOR_APPLE
;
890 kev_req
.kev_class
= KEV_NETWORK_CLASS
;
891 kev_req
.kev_subclass
= KEV_ANY_SUBCLASS
;
892 status
= ioctl(so
, SIOCSKEVFILT
, &kev_req
);
894 SC_log(LOG_ERR
, "could not establish event filter, ioctl() failed: %s", strerror(errno
));
899 SC_log(LOG_ERR
, "could not open event socket, socket() failed: %s", strerror(errno
));
905 status
= ioctl(so
, FIONBIO
, &yes
);
907 SC_log(LOG_ERR
, "could not set non-blocking io, ioctl() failed: %s", strerror(errno
));
914 SC_log(LOG_ERR
, "kernel event monitor disabled");
919 S_kev_queue
= dispatch_queue_create("com.apple.SystemConfiguration.KernelEventMonitor", NULL
);
921 = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ
, so
, 0, S_kev_queue
);
922 dispatch_source_set_cancel_handler(S_kev_source
, ^{
925 dispatch_source_set_event_handler(S_kev_source
, ^{
926 os_activity_t activity
;
929 activity
= os_activity_create("processing network kernel events",
931 OS_ACTIVITY_FLAG_DEFAULT
);
932 os_activity_scope(activity
);
934 ok
= eventCallback(so
);
936 SC_log(LOG_ERR
, "kernel event monitor disabled");
937 dispatch_source_cancel(S_kev_source
);
940 os_release(activity
);
942 // NOTE: dispatch_resume() will be called in prime()
951 #define appendAddress appendAddress_v4
952 #define getIF getIF_v4
953 #define updateStore updateStore_v4
959 #define appendAddress appendAddress_v6
960 #define getIF getIF_v6
961 #define updateStore updateStore_v6
968 main(int argc
, char **argv
)
971 _sc_verbose
= (argc
> 1) ? TRUE
: FALSE
;
973 load_KernelEventMonitor(CFBundleGetMainBundle(), (argc
> 1) ? TRUE
: FALSE
);
974 prime_KernelEventMonitor();