Path: blob/buildjre8/ios-missing-include/sys/kern_event.h
861 views
/*1* Copyright (c) 2000-2014 Apple Inc. All rights reserved.2*3* @APPLE_OSREFERENCE_LICENSE_HEADER_START@4*5* This file contains Original Code and/or Modifications of Original Code6* as defined in and that are subject to the Apple Public Source License7* Version 2.0 (the 'License'). You may not use this file except in8* compliance with the License. The rights granted to you under the License9* may not be used to create, or enable the creation or redistribution of,10* unlawful or unlicensed copies of an Apple operating system, or to11* circumvent, violate, or enable the circumvention or violation of, any12* terms of an Apple operating system software license agreement.13*14* Please obtain a copy of the License at15* http://www.opensource.apple.com/apsl/ and read it before using this file.16*17* The Original Code and all software distributed under the License are18* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER19* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,20* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,21* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.22* Please see the License for the specific language governing rights and23* limitations under the License.24*25* @APPLE_OSREFERENCE_LICENSE_HEADER_END@26*/27/* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */28/*!29* @header kern_event.h30* This header defines in-kernel functions for generating kernel events as31* well as functions for receiving kernel events using a kernel event32* socket.33*/3435#ifndef SYS_KERN_EVENT_H36#define SYS_KERN_EVENT_H3738#include <sys/appleapiopts.h>39#include <sys/ioccom.h>40#include <sys/sys_domain.h>4142#define KEV_SNDSPACE (4 * 1024)43#define KEV_RECVSPACE (32 * 1024)4445#define KEV_ANY_VENDOR 046#define KEV_ANY_CLASS 047#define KEV_ANY_SUBCLASS 04849/*50* Vendor Code51*/5253/*!54* @defined KEV_VENDOR_APPLE55* @discussion Apple generated kernel events use the hard coded vendor code56* value of 1. Third party kernel events use a dynamically allocated vendor57* code. The vendor code can be found using the SIOCGKEVVENDOR ioctl.58*/59#define KEV_VENDOR_APPLE 16061/*62* Definition of top-level classifications for KEV_VENDOR_APPLE63*/6465/*!66* @defined KEV_NETWORK_CLASS67* @discussion Network kernel event class.68*/69#define KEV_NETWORK_CLASS 17071/*!72* @defined KEV_IOKIT_CLASS73* @discussion IOKit kernel event class.74*/75#define KEV_IOKIT_CLASS 27677/*!78* @defined KEV_SYSTEM_CLASS79* @discussion System kernel event class.80*/81#define KEV_SYSTEM_CLASS 38283/*!84* @defined KEV_APPLESHARE_CLASS85* @discussion AppleShare kernel event class.86*/87#define KEV_APPLESHARE_CLASS 48889/*!90* @defined KEV_FIREWALL_CLASS91* @discussion Firewall kernel event class.92*/93#define KEV_FIREWALL_CLASS 59495/*!96* @defined KEV_IEEE80211_CLASS97* @discussion IEEE 802.11 kernel event class.98*/99#define KEV_IEEE80211_CLASS 6100101/*102* The following struct is KPI, but it was originally defined with a trailing103* array member of size one, intended to be used as a Variable-Length Array.104* That's problematic because the compiler doesn't know that the array is105* accessed out-of-bounds and can assume it isn't. This makes106* -Warray-bounds-pointer-arithmetic sad. We can't just change the code because107* it requires users to also change their uses of the class, at a minimum108* because kern_event_msg's size changes when making the last member a VLA. This109* macro allows users of this KPI to opt-in to the new behavior.110*/111#if defined(XNU_KERN_EVENT_DATA_IS_VLA)112#define XNU_KERN_EVENT_DATA_SIZE /* nothing, it's a VLA */113#else114#define XNU_KERN_EVENT_DATA_SIZE 1115#endif116117/*!118* @struct kern_event_msg119* @discussion This structure is prepended to all kernel events. This120* structure is used to determine the format of the remainder of121* the kernel event. This structure will appear on all messages122* received on a kernel event socket. To post a kernel event, a123* slightly different structure is used.124* @field total_size Total size of the kernel event message including the125* header.126* @field vendor_code The vendor code indicates which vendor generated the127* kernel event. This gives every vendor a unique set of classes128* and subclasses to use. Use the SIOCGKEVVENDOR ioctl to look up129* vendor codes for vendors other than Apple. Apple uses130* KEV_VENDOR_APPLE.131* @field kev_class The class of the kernel event.132* @field kev_subclass The subclass of the kernel event.133* @field id Monotonically increasing value.134* @field event_code The event code.135* @field event_data Any additional data about this event. Format will136* depend on the vendor_code, kev_class, kev_subclass, and137* event_code. The length of the event_data can be determined138* using total_size - KEV_MSG_HEADER_SIZE.139*/140struct kern_event_msg {141u_int32_t total_size; /* Size of entire event msg */142u_int32_t vendor_code; /* For non-Apple extensibility */143u_int32_t kev_class; /* Layer of event source */144u_int32_t kev_subclass; /* Component within layer */145u_int32_t id; /* Monotonically increasing value */146u_int32_t event_code; /* unique code */147u_int32_t event_data[XNU_KERN_EVENT_DATA_SIZE]; /* One or more data words */148};149150/*!151* @defined KEV_MSG_HEADER_SIZE152* @discussion Size of the header portion of the kern_event_msg structure.153* This accounts for everything right up to event_data. The size154* of the data can be found by subtracting KEV_MSG_HEADER_SIZE155* from the total size from the kern_event_msg.156*/157#define KEV_MSG_HEADER_SIZE (offsetof(struct kern_event_msg, event_data[0]))158159/*!160* @struct kev_request161* @discussion This structure is used with the SIOCSKEVFILT and162* SIOCGKEVFILT to set and get the control filter setting for a163* kernel control socket.164* @field total_size Total size of the kernel event message including the165* header.166* @field vendor_code All kernel events that don't match this vendor code167* will be ignored. KEV_ANY_VENDOR can be used to receive kernel168* events with any vendor code.169* @field kev_class All kernel events that don't match this class will be170* ignored. KEV_ANY_CLASS can be used to receive kernel events with171* any class.172* @field kev_subclass All kernel events that don't match this subclass173* will be ignored. KEV_ANY_SUBCLASS can be used to receive kernel174* events with any subclass.175*/176struct kev_request {177u_int32_t vendor_code;178u_int32_t kev_class;179u_int32_t kev_subclass;180};181182/*!183* @defined KEV_VENDOR_CODE_MAX_STR_LEN184* @discussion This define sets the maximum length of a string that can be185* used to identify a vendor or kext when looking up a vendor code.186*/187#define KEV_VENDOR_CODE_MAX_STR_LEN 200188189/*!190* @struct kev_vendor_code191* @discussion This structure is used with the SIOCGKEVVENDOR ioctl to192* convert from a string identifying a kext or vendor, in the193* form of a bundle identifier, to a vendor code.194* @field vendor_code After making the SIOCGKEVVENDOR ioctl call, this will195* be filled in with the vendor code if there is one.196* @field vendor_string A bundle style identifier.197*/198#pragma pack(4)199struct kev_vendor_code {200u_int32_t vendor_code;201char vendor_string[KEV_VENDOR_CODE_MAX_STR_LEN];202};203#pragma pack()204205/*!206* @defined SIOCGKEVID207* @discussion Retrieve the current event id. Each event generated will208* have a new id. The next event to be generated will have an id209* of id+1.210*/211#define SIOCGKEVID _IOR('e', 1, u_int32_t)212213/*!214* @defined SIOCSKEVFILT215* @discussion Set the kernel event filter for this socket. Kernel events216* not matching this filter will not be received on this socket.217*/218#define SIOCSKEVFILT _IOW('e', 2, struct kev_request)219220/*!221* @defined SIOCGKEVFILT222* @discussion Retrieve the kernel event filter for this socket. Kernel223* events not matching this filter will not be received on this224* socket.225*/226#define SIOCGKEVFILT _IOR('e', 3, struct kev_request)227228/*!229* @defined SIOCGKEVVENDOR230* @discussion Lookup the vendor code for the specified vendor. ENOENT will231* be returned if a vendor code for that vendor string does not232* exist.233*/234#define SIOCGKEVVENDOR _IOWR('e', 4, struct kev_vendor_code)235236237#endif /* SYS_KERN_EVENT_H */238239240