]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/kern_event.h
5a232c02a3e09762573cf62119dc81b558d94169
[apple/xnu.git] / bsd / sys / kern_event.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */
23
24
25 #ifndef SYS_KERN_EVENT_H
26 #define SYS_KERN_EVENT_H
27
28 #include <sys/appleapiopts.h>
29 #include <sys/ioccom.h>
30 #include <sys/sys_domain.h>
31
32 #define KEVENTS_ON 1
33 #define KEV_SNDSPACE (4 * 1024)
34 #define KEV_RECVSPACE (8 * 1024)
35
36 #define KEV_ANY_VENDOR 0
37 #define KEV_ANY_CLASS 0
38 #define KEV_ANY_SUBCLASS 0
39
40 /*
41 * Vendor Code
42 */
43
44 #define KEV_VENDOR_APPLE 1
45
46
47 /*
48 * Definition of top-level classifications
49 */
50
51 #define KEV_NETWORK_CLASS 1
52 #define KEV_IOKIT_CLASS 2
53 #define KEV_SYSTEM_CLASS 3
54
55
56 struct kern_event_msg {
57 u_long total_size; /* Size of entire event msg */
58 u_long vendor_code; /* For non-Apple extensibility */
59 u_long kev_class; /* Layer of event source */
60 u_long kev_subclass; /* Component within layer */
61 u_long id; /* Monotonically increasing value */
62 u_long event_code; /* unique code */
63 u_long event_data[1]; /* One or more data longwords */
64
65 };
66
67 #define KEV_MSG_HEADER_SIZE (6 * sizeof(u_long))
68
69
70 struct kev_request {
71 u_long vendor_code;
72 u_long kev_class;
73 u_long kev_subclass;
74 };
75
76 #define SIOCGKEVID _IOR('e', 1, u_long)
77 #define SIOCSKEVFILT _IOW('e', 2, struct kev_request)
78 #define SIOCGKEVFILT _IOR('e', 3, struct kev_request)
79
80 #ifdef KERNEL
81 #ifdef __APPLE_API_UNSTABLE
82
83 #define N_KEV_VECTORS 5
84
85 struct kev_d_vectors {
86
87 u_long data_length; /* Length of the event data */
88 void *data_ptr; /* Pointer to event data */
89 };
90
91
92 struct kev_msg {
93 u_long vendor_code; /* For non-Apple extensibility */
94 u_long kev_class; /* Layer of event source */
95 u_long kev_subclass; /* Component within layer */
96 u_long event_code; /* The event code */
97 struct kev_d_vectors dv[N_KEV_VECTORS]; /* Up to n data vectors */
98 };
99
100 int kev_post_msg(struct kev_msg *event);
101
102 #endif /* ___APPLE_API_UNSTABLE */
103 #ifdef __APPLE_API_PRIVATE
104
105 LIST_HEAD(kern_event_head, kern_event_pcb);
106
107 struct kern_event_pcb {
108 LIST_ENTRY(kern_event_pcb) ev_link; /* glue on list of all PCBs */
109 struct socket *ev_socket; /* pointer back to socket */
110 u_long vendor_code_filter;
111 u_long class_filter;
112 u_long subclass_filter;
113 };
114
115 #define sotoevpcb(so) ((struct kern_event_pcb *)((so)->so_pcb))
116
117 #endif /* __APPLE_API_PRIVATE */
118 #endif
119
120 #endif