1#ifndef _resource_notify_user_
2#define _resource_notify_user_
3
4/* Module resource_notify */
5
6#include <string.h>
7#include <mach/ndr.h>
8#include <mach/boolean.h>
9#include <mach/kern_return.h>
10#include <mach/notify.h>
11#include <mach/mach_types.h>
12#include <mach/message.h>
13#include <mach/mig_errors.h>
14#include <mach/port.h>
15
16/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
17
18#if defined(__has_include)
19#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
20#ifndef USING_MIG_STRNCPY_ZEROFILL
21#define USING_MIG_STRNCPY_ZEROFILL
22#endif
23#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
24#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
25#ifdef __cplusplus
26extern "C" {
27#endif
28#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS_CSTRING_ATTR
29#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS_CSTRING_COUNTEDBY_ATTR(C) __unsafe_indexable
30#endif
31 extern int mig_strncpy_zerofill(char * dest, const char * src, int len) __attribute__((weak_import));
32#ifdef __cplusplus
33}
34#endif
35#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
36#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
37#endif /* __has_include */
38
39/* END MIG_STRNCPY_ZEROFILL CODE */
40
41#if (__MigKernelSpecificCode) || (_MIG_KERNEL_SPECIFIC_CODE_)
42#include <kern/ipc_mig.h>
43#endif /* __MigKernelSpecificCode */
44
45#ifdef AUTOTEST
46#ifndef FUNCTION_PTR_T
47#define FUNCTION_PTR_T
48typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
49typedef struct {
50 char * name;
51 function_ptr_t function;
52} function_table_entry;
53typedef function_table_entry *function_table_t;
54#endif /* FUNCTION_PTR_T */
55#endif /* AUTOTEST */
56
57#ifndef resource_notify_MSG_COUNT
58#define resource_notify_MSG_COUNT 6
59#endif /* resource_notify_MSG_COUNT */
60
61#include <Availability.h>
62#include <mach/std_types.h>
63#include <mach/mig.h>
64#include <mach/mig.h>
65#include <mach/mach_types.h>
66#include <mach/mach_types.h>
67#include <mach/resource_monitors.h>
68#include <mach/clock_types.h>
69
70#ifdef __BeforeMigUserHeader
71__BeforeMigUserHeader
72#endif /* __BeforeMigUserHeader */
73
74#include <sys/cdefs.h>
75__BEGIN_DECLS
76
77
78/* SimpleRoutine cpu_usage_violation */
79#ifdef mig_external
80mig_external
81#else
82extern
83#endif /* mig_external */
84kern_return_t send_cpu_usage_violation
85(
86 mach_port_t receiver,
87 proc_name_t procname,
88 int pid,
89 posix_path_t killed_proc_path,
90 mach_timespec_t timestamp,
91 int64_t observed_cpu_nsecs,
92 int64_t observation_nsecs,
93 int64_t cpu_nsecs_allowed,
94 int64_t limit_window_nsecs,
95 resource_notify_flags_t flags
96);
97
98/* SimpleRoutine cpu_wakes_violation */
99#ifdef mig_external
100mig_external
101#else
102extern
103#endif /* mig_external */
104kern_return_t send_cpu_wakes_violation
105(
106 mach_port_t receiver,
107 proc_name_t procname,
108 int pid,
109 posix_path_t killed_proc_path,
110 mach_timespec_t timestamp,
111 int64_t observed_cpu_wakes,
112 int64_t observation_nsecs,
113 int64_t cpu_wakes_allowed,
114 int64_t limit_window_nsecs,
115 resource_notify_flags_t flags
116);
117
118/* SimpleRoutine disk_writes_violation */
119#ifdef mig_external
120mig_external
121#else
122extern
123#endif /* mig_external */
124kern_return_t send_disk_writes_violation
125(
126 mach_port_t receiver,
127 proc_name_t procname,
128 int pid,
129 posix_path_t killed_proc_path,
130 mach_timespec_t timestamp,
131 int64_t observed_bytes_dirtied,
132 int64_t observation_nsecs,
133 int64_t bytes_dirtied_allowed,
134 int64_t limit_window_nsecs,
135 resource_notify_flags_t flags
136);
137
138/* SimpleRoutine port_space_violation */
139#ifdef mig_external
140mig_external
141#else
142extern
143#endif /* mig_external */
144kern_return_t send_port_space_violation
145(
146 mach_port_t receiver,
147 proc_name_t procname,
148 int pid,
149 mach_timespec_t timestamp,
150 int64_t observed_ports,
151 int64_t ports_allowed,
152 mach_port_t fatal_port,
153 resource_notify_flags_t flags
154);
155
156/* SimpleRoutine file_descriptors_violation */
157#ifdef mig_external
158mig_external
159#else
160extern
161#endif /* mig_external */
162kern_return_t send_file_descriptors_violation
163(
164 mach_port_t receiver,
165 proc_name_t procname,
166 int pid,
167 mach_timespec_t timestamp,
168 int64_t observed_filedesc,
169 int64_t filedesc_allowed,
170 mach_port_t fatal_port,
171 resource_notify_flags_t flags
172);
173
174/* SimpleRoutine kqworkloops_violation */
175#ifdef mig_external
176mig_external
177#else
178extern
179#endif /* mig_external */
180kern_return_t send_kqworkloops_violation
181(
182 mach_port_t receiver,
183 proc_name_t procname,
184 int pid,
185 mach_timespec_t timestamp,
186 int64_t observed_kqworkloops,
187 int64_t kqworkloops_allowed,
188 mach_port_t fatal_port,
189 resource_notify_flags_t flags
190);
191
192__END_DECLS
193
194/********************** Caution **************************/
195/* The following data types should be used to calculate */
196/* maximum message sizes only. The actual message may be */
197/* smaller, and the position of the arguments within the */
198/* message layout may vary from what is presented here. */
199/* For example, if any of the arguments are variable- */
200/* sized, and less than the maximum is sent, the data */
201/* will be packed tight in the actual message to reduce */
202/* the presence of holes. */
203/********************** Caution **************************/
204
205/* typedefs for all requests */
206
207#ifndef __Request__resource_notify_subsystem__defined
208#define __Request__resource_notify_subsystem__defined
209
210#ifdef __MigPackStructs
211#pragma pack(push, 4)
212#endif
213 typedef struct {
214 mach_msg_header_t Head;
215 NDR_record_t NDR;
216 proc_name_t procname;
217 char procnamePad[3];
218 int pid;
219 posix_path_t killed_proc_path;
220 mach_timespec_t timestamp;
221 int64_t observed_cpu_nsecs;
222 int64_t observation_nsecs;
223 int64_t cpu_nsecs_allowed;
224 int64_t limit_window_nsecs;
225 resource_notify_flags_t flags;
226 } __Request__cpu_usage_violation_t __attribute__((unused));
227#ifdef __MigPackStructs
228#pragma pack(pop)
229#endif
230
231#ifdef __MigPackStructs
232#pragma pack(push, 4)
233#endif
234 typedef struct {
235 mach_msg_header_t Head;
236 NDR_record_t NDR;
237 proc_name_t procname;
238 char procnamePad[3];
239 int pid;
240 posix_path_t killed_proc_path;
241 mach_timespec_t timestamp;
242 int64_t observed_cpu_wakes;
243 int64_t observation_nsecs;
244 int64_t cpu_wakes_allowed;
245 int64_t limit_window_nsecs;
246 resource_notify_flags_t flags;
247 } __Request__cpu_wakes_violation_t __attribute__((unused));
248#ifdef __MigPackStructs
249#pragma pack(pop)
250#endif
251
252#ifdef __MigPackStructs
253#pragma pack(push, 4)
254#endif
255 typedef struct {
256 mach_msg_header_t Head;
257 NDR_record_t NDR;
258 proc_name_t procname;
259 char procnamePad[3];
260 int pid;
261 posix_path_t killed_proc_path;
262 mach_timespec_t timestamp;
263 int64_t observed_bytes_dirtied;
264 int64_t observation_nsecs;
265 int64_t bytes_dirtied_allowed;
266 int64_t limit_window_nsecs;
267 resource_notify_flags_t flags;
268 } __Request__disk_writes_violation_t __attribute__((unused));
269#ifdef __MigPackStructs
270#pragma pack(pop)
271#endif
272
273#ifdef __MigPackStructs
274#pragma pack(push, 4)
275#endif
276 typedef struct {
277 mach_msg_header_t Head;
278 /* start of the kernel processed data */
279 mach_msg_body_t msgh_body;
280 mach_msg_port_descriptor_t fatal_port;
281 /* end of the kernel processed data */
282 NDR_record_t NDR;
283 proc_name_t procname;
284 char procnamePad[3];
285 int pid;
286 mach_timespec_t timestamp;
287 int64_t observed_ports;
288 int64_t ports_allowed;
289 resource_notify_flags_t flags;
290 } __Request__port_space_violation_t __attribute__((unused));
291#ifdef __MigPackStructs
292#pragma pack(pop)
293#endif
294
295#ifdef __MigPackStructs
296#pragma pack(push, 4)
297#endif
298 typedef struct {
299 mach_msg_header_t Head;
300 /* start of the kernel processed data */
301 mach_msg_body_t msgh_body;
302 mach_msg_port_descriptor_t fatal_port;
303 /* end of the kernel processed data */
304 NDR_record_t NDR;
305 proc_name_t procname;
306 char procnamePad[3];
307 int pid;
308 mach_timespec_t timestamp;
309 int64_t observed_filedesc;
310 int64_t filedesc_allowed;
311 resource_notify_flags_t flags;
312 } __Request__file_descriptors_violation_t __attribute__((unused));
313#ifdef __MigPackStructs
314#pragma pack(pop)
315#endif
316
317#ifdef __MigPackStructs
318#pragma pack(push, 4)
319#endif
320 typedef struct {
321 mach_msg_header_t Head;
322 /* start of the kernel processed data */
323 mach_msg_body_t msgh_body;
324 mach_msg_port_descriptor_t fatal_port;
325 /* end of the kernel processed data */
326 NDR_record_t NDR;
327 proc_name_t procname;
328 char procnamePad[3];
329 int pid;
330 mach_timespec_t timestamp;
331 int64_t observed_kqworkloops;
332 int64_t kqworkloops_allowed;
333 resource_notify_flags_t flags;
334 } __Request__kqworkloops_violation_t __attribute__((unused));
335#ifdef __MigPackStructs
336#pragma pack(pop)
337#endif
338#endif /* !__Request__resource_notify_subsystem__defined */
339
340/* union of all requests */
341
342#ifndef __RequestUnion__send_resource_notify_subsystem__defined
343#define __RequestUnion__send_resource_notify_subsystem__defined
344union __RequestUnion__send_resource_notify_subsystem {
345 __Request__cpu_usage_violation_t Request_send_cpu_usage_violation;
346 __Request__cpu_wakes_violation_t Request_send_cpu_wakes_violation;
347 __Request__disk_writes_violation_t Request_send_disk_writes_violation;
348 __Request__port_space_violation_t Request_send_port_space_violation;
349 __Request__file_descriptors_violation_t Request_send_file_descriptors_violation;
350 __Request__kqworkloops_violation_t Request_send_kqworkloops_violation;
351};
352#endif /* !__RequestUnion__send_resource_notify_subsystem__defined */
353/* typedefs for all replies */
354
355#ifndef __Reply__resource_notify_subsystem__defined
356#define __Reply__resource_notify_subsystem__defined
357
358#ifdef __MigPackStructs
359#pragma pack(push, 4)
360#endif
361 typedef struct {
362 mach_msg_header_t Head;
363 NDR_record_t NDR;
364 kern_return_t RetCode;
365 } __Reply__cpu_usage_violation_t __attribute__((unused));
366#ifdef __MigPackStructs
367#pragma pack(pop)
368#endif
369
370#ifdef __MigPackStructs
371#pragma pack(push, 4)
372#endif
373 typedef struct {
374 mach_msg_header_t Head;
375 NDR_record_t NDR;
376 kern_return_t RetCode;
377 } __Reply__cpu_wakes_violation_t __attribute__((unused));
378#ifdef __MigPackStructs
379#pragma pack(pop)
380#endif
381
382#ifdef __MigPackStructs
383#pragma pack(push, 4)
384#endif
385 typedef struct {
386 mach_msg_header_t Head;
387 NDR_record_t NDR;
388 kern_return_t RetCode;
389 } __Reply__disk_writes_violation_t __attribute__((unused));
390#ifdef __MigPackStructs
391#pragma pack(pop)
392#endif
393
394#ifdef __MigPackStructs
395#pragma pack(push, 4)
396#endif
397 typedef struct {
398 mach_msg_header_t Head;
399 NDR_record_t NDR;
400 kern_return_t RetCode;
401 } __Reply__port_space_violation_t __attribute__((unused));
402#ifdef __MigPackStructs
403#pragma pack(pop)
404#endif
405
406#ifdef __MigPackStructs
407#pragma pack(push, 4)
408#endif
409 typedef struct {
410 mach_msg_header_t Head;
411 NDR_record_t NDR;
412 kern_return_t RetCode;
413 } __Reply__file_descriptors_violation_t __attribute__((unused));
414#ifdef __MigPackStructs
415#pragma pack(pop)
416#endif
417
418#ifdef __MigPackStructs
419#pragma pack(push, 4)
420#endif
421 typedef struct {
422 mach_msg_header_t Head;
423 NDR_record_t NDR;
424 kern_return_t RetCode;
425 } __Reply__kqworkloops_violation_t __attribute__((unused));
426#ifdef __MigPackStructs
427#pragma pack(pop)
428#endif
429#endif /* !__Reply__resource_notify_subsystem__defined */
430
431/* union of all replies */
432
433#ifndef __ReplyUnion__send_resource_notify_subsystem__defined
434#define __ReplyUnion__send_resource_notify_subsystem__defined
435union __ReplyUnion__send_resource_notify_subsystem {
436 __Reply__cpu_usage_violation_t Reply_send_cpu_usage_violation;
437 __Reply__cpu_wakes_violation_t Reply_send_cpu_wakes_violation;
438 __Reply__disk_writes_violation_t Reply_send_disk_writes_violation;
439 __Reply__port_space_violation_t Reply_send_port_space_violation;
440 __Reply__file_descriptors_violation_t Reply_send_file_descriptors_violation;
441 __Reply__kqworkloops_violation_t Reply_send_kqworkloops_violation;
442};
443#endif /* !__RequestUnion__send_resource_notify_subsystem__defined */
444
445#ifndef subsystem_to_name_map_resource_notify
446#define subsystem_to_name_map_resource_notify \
447 { "cpu_usage_violation", 827800 },\
448 { "cpu_wakes_violation", 827801 },\
449 { "disk_writes_violation", 827802 },\
450 { "port_space_violation", 827803 },\
451 { "file_descriptors_violation", 827804 },\
452 { "kqworkloops_violation", 827805 }
453#endif
454
455#ifdef __AfterMigUserHeader
456__AfterMigUserHeader
457#endif /* __AfterMigUserHeader */
458
459#endif /* _resource_notify_user_ */
460