#include <sys/kern_event.h>
sys/kern_event.h
@header kern_event.h
This header defines in-kernel functions for generating kernel events as
well as functions for receiving kernel events using a kernel event
socket.
macroN_KEV_VECTORS
#define N_KEV_VECTORS 5
structkev_d_vectors
@struct kev_d_vectors
@discussion This structure is used to append some data to a kernel
event.
@field data_length The length of data.
@field data_ptr A pointer to data.
| u_int32_t | data_length | Length of the event data |
| void * | data_ptr | Pointer to event data |
structkev_msg
@struct kev_msg
@discussion This structure is used when posting a kernel event.
@field vendor_code The vendor code assigned by kev_vendor_code_find.
@field kev_class The event's class.
@field kev_class The event's subclass.
@field kev_class The event's code.
@field dv An array of vectors describing additional data to be appended
to the kernel event.
| u_int32_t | vendor_code | For non-Apple extensibility |
| u_int32_t | kev_class | Layer of event source |
| u_int32_t | kev_subclass | Component within layer |
| u_int32_t | event_code | The event code |
| struct kev_d_vectors[5] | dv | Up to n data vectors |
functionkev_vendor_code_find
errno_t kev_vendor_code_find(const char *vendor_string, u_int32_t *vendor_code)
@function kev_vendor_code_find
@discussion Lookup a vendor_code given a unique string. If the vendor
code has not been used since launch, a unique integer will be
assigned for that string. Vendor codes will remain the same
until the machine is rebooted.
@param vendor_string A bundle style vendor identifier(i.e. com.apple).
@param vendor_code Upon return, a unique vendor code for use when
posting kernel events.
@result May return ENOMEM if memory constraints prevent allocation of a
new vendor code.
functionkev_msg_post
errno_t kev_msg_post(struct kev_msg *event_msg)
@function kev_msg_post
@discussion Post a kernel event message.
@param event_msg A structure defining the kernel event message to post.
@result Will return zero upon success. May return a number of errors
depending on the type of failure. EINVAL indicates that there
was something wrong with the kerne event. The vendor code of
the kernel event must be assigned using kev_vendor_code_find.
If the message is too large, EMSGSIZE will be returned.