Commit | Line | Data |
---|---|---|
0c530ab8 A |
1 | /* |
2 | * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. | |
3 | * | |
2d21ac55 A |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
5 | * | |
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. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
0c530ab8 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
0c530ab8 A |
27 | */ |
28 | ||
29 | #ifndef _SYS_PROC_INFO_H | |
30 | #define _SYS_PROC_INFO_H | |
31 | ||
32 | #include <sys/cdefs.h> | |
33 | #include <sys/param.h> | |
34 | #include <sys/types.h> | |
35 | #include <sys/stat.h> | |
36 | #include <sys/mount.h> | |
37 | #include <sys/socket.h> | |
38 | #include <sys/un.h> | |
39 | #include <sys/kern_control.h> | |
40 | #include <net/if.h> | |
41 | #include <net/route.h> | |
42 | #include <netinet/in.h> | |
43 | #include <netinet/tcp.h> | |
44 | ||
45 | __BEGIN_DECLS | |
46 | ||
47 | ||
b0d623f7 | 48 | #define PROC_ALL_PIDS 1 |
0c530ab8 A |
49 | #define PROC_PGRP_ONLY 2 |
50 | #define PROC_TTY_ONLY 3 | |
51 | #define PROC_UID_ONLY 4 | |
52 | #define PROC_RUID_ONLY 5 | |
6d2010ae | 53 | #define PROC_PPID_ONLY 6 |
0c530ab8 A |
54 | |
55 | struct proc_bsdinfo { | |
56 | uint32_t pbi_flags; /* 64bit; emulated etc */ | |
57 | uint32_t pbi_status; | |
58 | uint32_t pbi_xstatus; | |
59 | uint32_t pbi_pid; | |
60 | uint32_t pbi_ppid; | |
61 | uid_t pbi_uid; | |
62 | gid_t pbi_gid; | |
63 | uid_t pbi_ruid; | |
64 | gid_t pbi_rgid; | |
65 | uid_t pbi_svuid; | |
66 | gid_t pbi_svgid; | |
b0d623f7 A |
67 | uint32_t rfu_1; /* reserved */ |
68 | char pbi_comm[MAXCOMLEN]; | |
69 | char pbi_name[2*MAXCOMLEN]; /* empty if no name is registered */ | |
0c530ab8 A |
70 | uint32_t pbi_nfiles; |
71 | uint32_t pbi_pgid; | |
72 | uint32_t pbi_pjobc; | |
73 | uint32_t e_tdev; /* controlling tty dev */ | |
74 | uint32_t e_tpgid; /* tty process group id */ | |
0c530ab8 | 75 | int32_t pbi_nice; |
b0d623f7 A |
76 | uint64_t pbi_start_tvsec; |
77 | uint64_t pbi_start_tvusec; | |
0c530ab8 A |
78 | }; |
79 | ||
80 | ||
6d2010ae A |
81 | struct proc_bsdshortinfo { |
82 | uint32_t pbsi_pid; /* process id */ | |
83 | uint32_t pbsi_ppid; /* process parent id */ | |
84 | uint32_t pbsi_pgid; /* process perp id */ | |
85 | uint32_t pbsi_status; /* p_stat value, SZOMB, SRUN, etc */ | |
86 | char pbsi_comm[MAXCOMLEN]; /* upto 16 characters of process name */ | |
87 | uint32_t pbsi_flags; /* 64bit; emulated etc */ | |
88 | uid_t pbsi_uid; /* current uid on process */ | |
89 | gid_t pbsi_gid; /* current gid on process */ | |
90 | uid_t pbsi_ruid; /* current ruid on process */ | |
91 | gid_t pbsi_rgid; /* current tgid on process */ | |
92 | uid_t pbsi_svuid; /* current svuid on process */ | |
93 | gid_t pbsi_svgid; /* current svgid on process */ | |
94 | uint32_t pbsi_rfu; /* reserved for future use*/ | |
95 | }; | |
96 | ||
0c530ab8 A |
97 | |
98 | /* pbi_flags values */ | |
6d2010ae A |
99 | #define PROC_FLAG_SYSTEM 1 /* System process */ |
100 | #define PROC_FLAG_TRACED 2 /* process currently being traced, possibly by gdb */ | |
101 | #define PROC_FLAG_INEXIT 4 /* process is working its way in exit() */ | |
0c530ab8 | 102 | #define PROC_FLAG_PPWAIT 8 |
6d2010ae A |
103 | #define PROC_FLAG_LP64 0x10 /* 64bit process */ |
104 | #define PROC_FLAG_SLEADER 0x20 /* The process is the session leader */ | |
105 | #define PROC_FLAG_CTTY 0x40 /* process has a control tty */ | |
106 | #define PROC_FLAG_CONTROLT 0x80 /* Has a controlling terminal */ | |
107 | #define PROC_FLAG_THCWD 0x100 /* process has a thread with cwd */ | |
b0d623f7 | 108 | /* process control bits for resource starvation */ |
6d2010ae A |
109 | #define PROC_FLAG_PC_THROTTLE 0x200 /* In resource starvation situations, this process is to be throttled */ |
110 | #define PROC_FLAG_PC_SUSP 0x400 /* In resource starvation situations, this process is to be suspended */ | |
111 | #define PROC_FLAG_PC_KILL 0x600 /* In resource starvation situations, this process is to be terminated */ | |
b0d623f7 A |
112 | #define PROC_FLAG_PC_MASK 0x600 |
113 | /* process action bits for resource starvation */ | |
6d2010ae A |
114 | #define PROC_FLAG_PA_THROTTLE 0x800 /* The process is currently throttled due to resource starvation */ |
115 | #define PROC_FLAG_PA_SUSP 0x1000 /* The process is currently suspended due to resource starvation */ | |
116 | #define PROC_FLAG_PSUGID 0x2000 /* process has set privileges since last exec */ | |
117 | #define PROC_FLAG_EXEC 0x4000 /* process has called exec */ | |
118 | #ifdef PRIVATE | |
119 | #define PROC_FLAG_DARWINBG 0x8000 /* process in darwin background */ | |
120 | #define PROC_FLAG_EXT_DARWINBG 0x10000 /* process in darwin background - external enforcement */ | |
121 | #endif | |
0c530ab8 A |
122 | |
123 | ||
124 | struct proc_taskinfo { | |
b0d623f7 A |
125 | uint64_t pti_virtual_size; /* virtual memory size (bytes) */ |
126 | uint64_t pti_resident_size; /* resident memory size (bytes) */ | |
0c530ab8 A |
127 | uint64_t pti_total_user; /* total time */ |
128 | uint64_t pti_total_system; | |
129 | uint64_t pti_threads_user; /* existing threads only */ | |
130 | uint64_t pti_threads_system; | |
131 | int32_t pti_policy; /* default policy for new threads */ | |
132 | int32_t pti_faults; /* number of page faults */ | |
b0d623f7 A |
133 | int32_t pti_pageins; /* number of actual pageins */ |
134 | int32_t pti_cow_faults; /* number of copy-on-write faults */ | |
0c530ab8 | 135 | int32_t pti_messages_sent; /* number of messages sent */ |
b0d623f7 A |
136 | int32_t pti_messages_received; /* number of messages received */ |
137 | int32_t pti_syscalls_mach; /* number of mach system calls */ | |
138 | int32_t pti_syscalls_unix; /* number of unix system calls */ | |
139 | int32_t pti_csw; /* number of context switches */ | |
0c530ab8 A |
140 | int32_t pti_threadnum; /* number of threads in the task */ |
141 | int32_t pti_numrunning; /* number of running threads */ | |
142 | int32_t pti_priority; /* task priority*/ | |
143 | }; | |
144 | ||
145 | struct proc_taskallinfo { | |
b0d623f7 A |
146 | struct proc_bsdinfo pbsd; |
147 | struct proc_taskinfo ptinfo; | |
0c530ab8 A |
148 | }; |
149 | ||
b0d623f7 | 150 | #define MAXTHREADNAMESIZE 64 |
0c530ab8 A |
151 | |
152 | struct proc_threadinfo { | |
b0d623f7 A |
153 | uint64_t pth_user_time; /* user run time */ |
154 | uint64_t pth_system_time; /* system run time */ | |
155 | int32_t pth_cpu_usage; /* scaled cpu usage percentage */ | |
0c530ab8 | 156 | int32_t pth_policy; /* scheduling policy in effect */ |
b0d623f7 A |
157 | int32_t pth_run_state; /* run state (see below) */ |
158 | int32_t pth_flags; /* various flags (see below) */ | |
159 | int32_t pth_sleep_time; /* number of seconds that thread */ | |
0c530ab8 A |
160 | int32_t pth_curpri; /* cur priority*/ |
161 | int32_t pth_priority; /* priority*/ | |
b0d623f7 A |
162 | int32_t pth_maxpriority; /* max priority*/ |
163 | char pth_name[MAXTHREADNAMESIZE]; /* thread name, if any */ | |
0c530ab8 A |
164 | }; |
165 | ||
166 | struct proc_regioninfo { | |
167 | uint32_t pri_protection; | |
168 | uint32_t pri_max_protection; | |
169 | uint32_t pri_inheritance; | |
170 | uint32_t pri_flags; /* shared, external pager, is submap */ | |
171 | uint64_t pri_offset; | |
172 | uint32_t pri_behavior; | |
173 | uint32_t pri_user_wired_count; | |
174 | uint32_t pri_user_tag; | |
175 | uint32_t pri_pages_resident; | |
176 | uint32_t pri_pages_shared_now_private; | |
b0d623f7 A |
177 | uint32_t pri_pages_swapped_out; |
178 | uint32_t pri_pages_dirtied; | |
179 | uint32_t pri_ref_count; | |
180 | uint32_t pri_shadow_depth; | |
181 | uint32_t pri_share_mode; | |
0c530ab8 A |
182 | uint32_t pri_private_pages_resident; |
183 | uint32_t pri_shared_pages_resident; | |
184 | uint32_t pri_obj_id; | |
2d21ac55 | 185 | uint32_t pri_depth; |
0c530ab8 A |
186 | uint64_t pri_address; |
187 | uint64_t pri_size; | |
0c530ab8 A |
188 | }; |
189 | ||
190 | #define PROC_REGION_SUBMAP 1 | |
191 | #define PROC_REGION_SHARED 2 | |
192 | ||
193 | #define SM_COW 1 | |
194 | #define SM_PRIVATE 2 | |
195 | #define SM_EMPTY 3 | |
196 | #define SM_SHARED 4 | |
197 | #define SM_TRUESHARED 5 | |
198 | #define SM_PRIVATE_ALIASED 6 | |
199 | #define SM_SHARED_ALIASED 7 | |
6d2010ae | 200 | #define SM_LARGE_PAGE 8 |
0c530ab8 A |
201 | |
202 | ||
203 | /* | |
204 | * Thread run states (state field). | |
205 | */ | |
206 | ||
207 | #define TH_STATE_RUNNING 1 /* thread is running normally */ | |
208 | #define TH_STATE_STOPPED 2 /* thread is stopped */ | |
209 | #define TH_STATE_WAITING 3 /* thread is waiting normally */ | |
210 | #define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible | |
211 | wait */ | |
212 | #define TH_STATE_HALTED 5 /* thread is halted at a | |
213 | clean point */ | |
214 | ||
215 | /* | |
216 | * Thread flags (flags field). | |
217 | */ | |
218 | #define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */ | |
219 | #define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */ | |
220 | ||
221 | ||
b0d623f7 A |
222 | struct proc_workqueueinfo { |
223 | uint32_t pwq_nthreads; /* total number of workqueue threads */ | |
224 | uint32_t pwq_runthreads; /* total number of running workqueue threads */ | |
225 | uint32_t pwq_blockedthreads; /* total number of blocked workqueue threads */ | |
6d2010ae | 226 | uint32_t pwq_state; |
b0d623f7 | 227 | }; |
0c530ab8 | 228 | |
6d2010ae A |
229 | /* |
230 | * workqueue state (pwq_state field) | |
231 | */ | |
232 | #define WQ_EXCEEDED_CONSTRAINED_THREAD_LIMIT 0x1 | |
233 | #define WQ_EXCEEDED_TOTAL_THREAD_LIMIT 0x2 | |
234 | ||
235 | ||
0c530ab8 A |
236 | struct proc_fileinfo { |
237 | uint32_t fi_openflags; | |
238 | uint32_t fi_status; | |
239 | off_t fi_offset; | |
240 | int32_t fi_type; | |
b0d623f7 | 241 | int32_t rfu_1; /* reserved */ |
0c530ab8 A |
242 | }; |
243 | ||
2d21ac55 A |
244 | /* stats flags in proc_fileinfo */ |
245 | #define PROC_FP_SHARED 1 /* shared by more than one fd */ | |
246 | #define PROC_FP_CLEXEC 2 /* close on exec */ | |
247 | ||
248 | /* | |
249 | * A copy of stat64 with static sized fields. | |
250 | */ | |
251 | struct vinfo_stat { | |
252 | uint32_t vst_dev; /* [XSI] ID of device containing file */ | |
253 | uint16_t vst_mode; /* [XSI] Mode of file (see below) */ | |
254 | uint16_t vst_nlink; /* [XSI] Number of hard links */ | |
255 | uint64_t vst_ino; /* [XSI] File serial number */ | |
256 | uid_t vst_uid; /* [XSI] User ID of the file */ | |
257 | gid_t vst_gid; /* [XSI] Group ID of the file */ | |
258 | int64_t vst_atime; /* [XSI] Time of last access */ | |
259 | int64_t vst_atimensec; /* nsec of last access */ | |
260 | int64_t vst_mtime; /* [XSI] Last data modification time */ | |
261 | int64_t vst_mtimensec; /* last data modification nsec */ | |
262 | int64_t vst_ctime; /* [XSI] Time of last status change */ | |
263 | int64_t vst_ctimensec; /* nsec of last status change */ | |
264 | int64_t vst_birthtime; /* File creation time(birth) */ | |
265 | int64_t vst_birthtimensec; /* nsec of File creation time */ | |
266 | off_t vst_size; /* [XSI] file size, in bytes */ | |
267 | int64_t vst_blocks; /* [XSI] blocks allocated for file */ | |
268 | int32_t vst_blksize; /* [XSI] optimal blocksize for I/O */ | |
269 | uint32_t vst_flags; /* user defined flags for file */ | |
270 | uint32_t vst_gen; /* file generation number */ | |
271 | uint32_t vst_rdev; /* [XSI] Device ID */ | |
272 | int64_t vst_qspare[2]; /* RESERVED: DO NOT USE! */ | |
273 | }; | |
0c530ab8 A |
274 | |
275 | struct vnode_info { | |
2d21ac55 A |
276 | struct vinfo_stat vi_stat; |
277 | int vi_type; | |
2d21ac55 | 278 | int vi_pad; |
b0d623f7 | 279 | fsid_t vi_fsid; |
0c530ab8 A |
280 | }; |
281 | ||
282 | struct vnode_info_path { | |
283 | struct vnode_info vip_vi; | |
b0d623f7 | 284 | char vip_path[MAXPATHLEN]; /* tail end of it */ |
0c530ab8 A |
285 | }; |
286 | ||
287 | struct vnode_fdinfo { | |
2d21ac55 | 288 | struct proc_fileinfo pfi; |
0c530ab8 A |
289 | struct vnode_info pvi; |
290 | }; | |
291 | ||
292 | struct vnode_fdinfowithpath { | |
b0d623f7 A |
293 | struct proc_fileinfo pfi; |
294 | struct vnode_info_path pvip; | |
0c530ab8 A |
295 | }; |
296 | ||
0c530ab8 | 297 | struct proc_regionwithpathinfo { |
b0d623f7 A |
298 | struct proc_regioninfo prp_prinfo; |
299 | struct vnode_info_path prp_vip; | |
0c530ab8 A |
300 | }; |
301 | ||
302 | struct proc_vnodepathinfo { | |
b0d623f7 A |
303 | struct vnode_info_path pvi_cdir; |
304 | struct vnode_info_path pvi_rdir; | |
0c530ab8 A |
305 | }; |
306 | ||
2d21ac55 | 307 | struct proc_threadwithpathinfo { |
b0d623f7 A |
308 | struct proc_threadinfo pt; |
309 | struct vnode_info_path pvip; | |
2d21ac55 | 310 | }; |
0c530ab8 A |
311 | |
312 | /* | |
313 | * Socket | |
314 | */ | |
315 | ||
316 | ||
317 | /* | |
318 | * IPv4 and IPv6 Sockets | |
319 | */ | |
320 | ||
321 | #define INI_IPV4 0x1 | |
322 | #define INI_IPV6 0x2 | |
323 | ||
324 | struct in4in6_addr { | |
b0d623f7 A |
325 | u_int32_t i46a_pad32[3]; |
326 | struct in_addr i46a_addr4; | |
0c530ab8 A |
327 | }; |
328 | ||
329 | struct in_sockinfo { | |
b0d623f7 A |
330 | int insi_fport; /* foreign port */ |
331 | int insi_lport; /* local port */ | |
0c530ab8 A |
332 | uint64_t insi_gencnt; /* generation count of this instance */ |
333 | uint32_t insi_flags; /* generic IP/datagram flags */ | |
334 | uint32_t insi_flow; | |
335 | ||
336 | uint8_t insi_vflag; /* ini_IPV4 or ini_IPV6 */ | |
b0d623f7 A |
337 | uint8_t insi_ip_ttl; /* time to live proto */ |
338 | uint32_t rfu_1; /* reserved */ | |
0c530ab8 A |
339 | /* protocol dependent part */ |
340 | union { | |
b0d623f7 A |
341 | struct in4in6_addr ina_46; |
342 | struct in6_addr ina_6; | |
343 | } insi_faddr; /* foreign host table entry */ | |
0c530ab8 | 344 | union { |
b0d623f7 A |
345 | struct in4in6_addr ina_46; |
346 | struct in6_addr ina_6; | |
347 | } insi_laddr; /* local host table entry */ | |
0c530ab8 | 348 | struct { |
b0d623f7 A |
349 | u_char in4_tos; /* type of service */ |
350 | } insi_v4; | |
0c530ab8 | 351 | struct { |
b0d623f7 A |
352 | uint8_t in6_hlim; |
353 | int in6_cksum; | |
354 | u_short in6_ifindex; | |
355 | short in6_hops; | |
356 | } insi_v6; | |
0c530ab8 A |
357 | }; |
358 | ||
359 | /* | |
360 | * TCP Sockets | |
361 | */ | |
362 | ||
b0d623f7 A |
363 | #define TSI_T_REXMT 0 /* retransmit */ |
364 | #define TSI_T_PERSIST 1 /* retransmit persistence */ | |
365 | #define TSI_T_KEEP 2 /* keep alive */ | |
366 | #define TSI_T_2MSL 3 /* 2*msl quiet time timer */ | |
0c530ab8 A |
367 | #define TSI_T_NTIMERS 4 |
368 | ||
b0d623f7 A |
369 | #define TSI_S_CLOSED 0 /* closed */ |
370 | #define TSI_S_LISTEN 1 /* listening for connection */ | |
371 | #define TSI_S_SYN_SENT 2 /* active, have sent syn */ | |
372 | #define TSI_S_SYN_RECEIVED 3 /* have send and received syn */ | |
373 | #define TSI_S_ESTABLISHED 4 /* established */ | |
374 | #define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */ | |
375 | #define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */ | |
376 | #define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */ | |
377 | #define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */ | |
378 | #define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */ | |
379 | #define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */ | |
380 | #define TSI_S_RESERVED 11 /* pseudo state: reserved */ | |
0c530ab8 A |
381 | |
382 | struct tcp_sockinfo { | |
b0d623f7 A |
383 | struct in_sockinfo tcpsi_ini; |
384 | int tcpsi_state; | |
385 | int tcpsi_timer[TSI_T_NTIMERS]; | |
386 | int tcpsi_mss; | |
387 | uint32_t tcpsi_flags; | |
388 | uint32_t rfu_1; /* reserved */ | |
389 | uint64_t tcpsi_tp; /* opaque handle of TCP protocol control block */ | |
0c530ab8 A |
390 | }; |
391 | ||
392 | /* | |
393 | * Unix Domain Sockets | |
394 | */ | |
395 | ||
396 | ||
397 | struct un_sockinfo { | |
b0d623f7 A |
398 | uint64_t unsi_conn_so; /* opaque handle of connected socket */ |
399 | uint64_t unsi_conn_pcb; /* opaque handle of connected protocol control block */ | |
0c530ab8 | 400 | union { |
b0d623f7 A |
401 | struct sockaddr_un ua_sun; |
402 | char ua_dummy[SOCK_MAXADDRLEN]; | |
403 | } unsi_addr; /* bound address */ | |
0c530ab8 | 404 | union { |
b0d623f7 A |
405 | struct sockaddr_un ua_sun; |
406 | char ua_dummy[SOCK_MAXADDRLEN]; | |
407 | } unsi_caddr; /* address of socket connected to */ | |
0c530ab8 A |
408 | }; |
409 | ||
410 | /* | |
411 | * PF_NDRV Sockets | |
412 | */ | |
413 | ||
414 | struct ndrv_info { | |
b0d623f7 A |
415 | uint32_t ndrvsi_if_family; |
416 | uint32_t ndrvsi_if_unit; | |
417 | char ndrvsi_if_name[IF_NAMESIZE]; | |
0c530ab8 A |
418 | }; |
419 | ||
420 | /* | |
421 | * Kernel Event Sockets | |
422 | */ | |
423 | ||
424 | struct kern_event_info { | |
b0d623f7 A |
425 | uint32_t kesi_vendor_code_filter; |
426 | uint32_t kesi_class_filter; | |
427 | uint32_t kesi_subclass_filter; | |
0c530ab8 A |
428 | }; |
429 | ||
430 | /* | |
431 | * Kernel Control Sockets | |
432 | */ | |
433 | ||
434 | struct kern_ctl_info { | |
b0d623f7 A |
435 | uint32_t kcsi_id; |
436 | uint32_t kcsi_reg_unit; | |
437 | uint32_t kcsi_flags; /* support flags */ | |
438 | uint32_t kcsi_recvbufsize; /* request more than the default buffer size */ | |
439 | uint32_t kcsi_sendbufsize; /* request more than the default buffer size */ | |
440 | uint32_t kcsi_unit; | |
441 | char kcsi_name[MAX_KCTL_NAME]; /* unique nke identifier, provided by DTS */ | |
0c530ab8 A |
442 | }; |
443 | ||
444 | /* soi_state */ | |
445 | ||
b0d623f7 A |
446 | #define SOI_S_NOFDREF 0x0001 /* no file table ref any more */ |
447 | #define SOI_S_ISCONNECTED 0x0002 /* socket connected to a peer */ | |
448 | #define SOI_S_ISCONNECTING 0x0004 /* in process of connecting to peer */ | |
449 | #define SOI_S_ISDISCONNECTING 0x0008 /* in process of disconnecting */ | |
450 | #define SOI_S_CANTSENDMORE 0x0010 /* can't send more data to peer */ | |
451 | #define SOI_S_CANTRCVMORE 0x0020 /* can't receive more data from peer */ | |
452 | #define SOI_S_RCVATMARK 0x0040 /* at mark on input */ | |
453 | #define SOI_S_PRIV 0x0080 /* privileged for broadcast, raw... */ | |
454 | #define SOI_S_NBIO 0x0100 /* non-blocking ops */ | |
455 | #define SOI_S_ASYNC 0x0200 /* async i/o notify */ | |
456 | #define SOI_S_INCOMP 0x0800 /* Unaccepted, incomplete connection */ | |
457 | #define SOI_S_COMP 0x1000 /* unaccepted, complete connection */ | |
458 | #define SOI_S_ISDISCONNECTED 0x2000 /* socket disconnected from peer */ | |
459 | #define SOI_S_DRAINING 0x4000 /* close waiting for blocked system calls to drain */ | |
0c530ab8 A |
460 | |
461 | struct sockbuf_info { | |
b0d623f7 A |
462 | uint32_t sbi_cc; |
463 | uint32_t sbi_hiwat; /* SO_RCVBUF, SO_SNDBUF */ | |
464 | uint32_t sbi_mbcnt; | |
465 | uint32_t sbi_mbmax; | |
466 | uint32_t sbi_lowat; | |
467 | short sbi_flags; | |
468 | short sbi_timeo; | |
0c530ab8 A |
469 | }; |
470 | ||
471 | enum { | |
b0d623f7 A |
472 | SOCKINFO_GENERIC = 0, |
473 | SOCKINFO_IN = 1, | |
0c530ab8 | 474 | SOCKINFO_TCP = 2, |
b0d623f7 | 475 | SOCKINFO_UN = 3, |
0c530ab8 A |
476 | SOCKINFO_NDRV = 4, |
477 | SOCKINFO_KERN_EVENT = 5, | |
478 | SOCKINFO_KERN_CTL = 6 | |
479 | }; | |
480 | ||
481 | struct socket_info { | |
b0d623f7 | 482 | struct vinfo_stat soi_stat; |
0c530ab8 A |
483 | uint64_t soi_so; /* opaque handle of socket */ |
484 | uint64_t soi_pcb; /* opaque handle of protocol control block */ | |
b0d623f7 A |
485 | int soi_type; |
486 | int soi_protocol; | |
487 | int soi_family; | |
0c530ab8 A |
488 | short soi_options; |
489 | short soi_linger; | |
490 | short soi_state; | |
491 | short soi_qlen; | |
492 | short soi_incqlen; | |
493 | short soi_qlimit; | |
494 | short soi_timeo; | |
495 | u_short soi_error; | |
496 | uint32_t soi_oobmark; | |
b0d623f7 A |
497 | struct sockbuf_info soi_rcv; |
498 | struct sockbuf_info soi_snd; | |
499 | int soi_kind; | |
500 | uint32_t rfu_1; /* reserved */ | |
0c530ab8 | 501 | union { |
b0d623f7 A |
502 | struct in_sockinfo pri_in; /* SOCKINFO_IN */ |
503 | struct tcp_sockinfo pri_tcp; /* SOCKINFO_TCP */ | |
504 | struct un_sockinfo pri_un; /* SOCKINFO_UN */ | |
505 | struct ndrv_info pri_ndrv; /* SOCKINFO_NDRV */ | |
506 | struct kern_event_info pri_kern_event; /* SOCKINFO_KERN_EVENT */ | |
507 | struct kern_ctl_info pri_kern_ctl; /* SOCKINFO_KERN_CTL */ | |
508 | } soi_proto; | |
0c530ab8 A |
509 | }; |
510 | ||
511 | struct socket_fdinfo { | |
b0d623f7 A |
512 | struct proc_fileinfo pfi; |
513 | struct socket_info psi; | |
0c530ab8 A |
514 | }; |
515 | ||
516 | ||
517 | ||
518 | struct psem_info { | |
b0d623f7 | 519 | struct vinfo_stat psem_stat; |
0c530ab8 A |
520 | char psem_name[MAXPATHLEN]; |
521 | }; | |
522 | ||
523 | struct psem_fdinfo { | |
b0d623f7 | 524 | struct proc_fileinfo pfi; |
0c530ab8 A |
525 | struct psem_info pseminfo; |
526 | }; | |
527 | ||
528 | ||
529 | ||
530 | struct pshm_info { | |
b0d623f7 | 531 | struct vinfo_stat pshm_stat; |
0c530ab8 A |
532 | uint64_t pshm_mappaddr; |
533 | char pshm_name[MAXPATHLEN]; | |
534 | }; | |
535 | ||
536 | struct pshm_fdinfo { | |
b0d623f7 A |
537 | struct proc_fileinfo pfi; |
538 | struct pshm_info pshminfo; | |
0c530ab8 A |
539 | }; |
540 | ||
541 | ||
542 | struct pipe_info { | |
b0d623f7 A |
543 | struct vinfo_stat pipe_stat; |
544 | uint64_t pipe_handle; | |
545 | uint64_t pipe_peerhandle; | |
0c530ab8 | 546 | int pipe_status; |
b0d623f7 | 547 | int rfu_1; /* reserved */ |
0c530ab8 A |
548 | }; |
549 | ||
550 | struct pipe_fdinfo { | |
b0d623f7 | 551 | struct proc_fileinfo pfi; |
0c530ab8 A |
552 | struct pipe_info pipeinfo; |
553 | }; | |
554 | ||
555 | ||
556 | struct kqueue_info { | |
b0d623f7 A |
557 | struct vinfo_stat kq_stat; |
558 | uint32_t kq_state; | |
559 | uint32_t rfu_1; /* reserved */ | |
0c530ab8 A |
560 | }; |
561 | #define PROC_KQUEUE_SELECT 1 | |
562 | #define PROC_KQUEUE_SLEEP 2 | |
563 | ||
564 | struct kqueue_fdinfo { | |
b0d623f7 | 565 | struct proc_fileinfo pfi; |
0c530ab8 A |
566 | struct kqueue_info kqueueinfo; |
567 | }; | |
568 | ||
569 | struct appletalk_info { | |
b0d623f7 | 570 | struct vinfo_stat atalk_stat; |
0c530ab8 A |
571 | }; |
572 | ||
573 | struct appletalk_fdinfo { | |
b0d623f7 A |
574 | struct proc_fileinfo pfi; |
575 | struct appletalk_info appletalkinfo; | |
0c530ab8 A |
576 | }; |
577 | ||
578 | ||
579 | ||
580 | /* defns of process file desc type */ | |
b0d623f7 A |
581 | #define PROX_FDTYPE_ATALK 0 |
582 | #define PROX_FDTYPE_VNODE 1 | |
583 | #define PROX_FDTYPE_SOCKET 2 | |
584 | #define PROX_FDTYPE_PSHM 3 | |
585 | #define PROX_FDTYPE_PSEM 4 | |
586 | #define PROX_FDTYPE_KQUEUE 5 | |
587 | #define PROX_FDTYPE_PIPE 6 | |
588 | #define PROX_FDTYPE_FSEVENTS 7 | |
0c530ab8 A |
589 | |
590 | struct proc_fdinfo { | |
b0d623f7 A |
591 | int32_t proc_fd; |
592 | uint32_t proc_fdtype; | |
0c530ab8 A |
593 | }; |
594 | ||
6d2010ae A |
595 | struct proc_fileportinfo { |
596 | uint32_t proc_fileport; | |
597 | uint32_t proc_fdtype; | |
598 | }; | |
599 | ||
b0d623f7 A |
600 | /* Flavors for proc_pidinfo() */ |
601 | #define PROC_PIDLISTFDS 1 | |
602 | #define PROC_PIDLISTFD_SIZE (sizeof(struct proc_fdinfo)) | |
0c530ab8 | 603 | |
b0d623f7 A |
604 | #define PROC_PIDTASKALLINFO 2 |
605 | #define PROC_PIDTASKALLINFO_SIZE (sizeof(struct proc_taskallinfo)) | |
0c530ab8 | 606 | |
b0d623f7 A |
607 | #define PROC_PIDTBSDINFO 3 |
608 | #define PROC_PIDTBSDINFO_SIZE (sizeof(struct proc_bsdinfo)) | |
0c530ab8 | 609 | |
b0d623f7 A |
610 | #define PROC_PIDTASKINFO 4 |
611 | #define PROC_PIDTASKINFO_SIZE (sizeof(struct proc_taskinfo)) | |
0c530ab8 | 612 | |
b0d623f7 A |
613 | #define PROC_PIDTHREADINFO 5 |
614 | #define PROC_PIDTHREADINFO_SIZE (sizeof(struct proc_threadinfo)) | |
0c530ab8 | 615 | |
b0d623f7 A |
616 | #define PROC_PIDLISTTHREADS 6 |
617 | #define PROC_PIDLISTTHREADS_SIZE (2* sizeof(uint32_t)) | |
0c530ab8 A |
618 | |
619 | ||
b0d623f7 A |
620 | #define PROC_PIDREGIONINFO 7 |
621 | #define PROC_PIDREGIONINFO_SIZE (sizeof(struct proc_regioninfo)) | |
0c530ab8 | 622 | |
b0d623f7 A |
623 | #define PROC_PIDREGIONPATHINFO 8 |
624 | #define PROC_PIDREGIONPATHINFO_SIZE (sizeof(struct proc_regionwithpathinfo)) | |
0c530ab8 | 625 | |
b0d623f7 A |
626 | #define PROC_PIDVNODEPATHINFO 9 |
627 | #define PROC_PIDVNODEPATHINFO_SIZE (sizeof(struct proc_vnodepathinfo)) | |
0c530ab8 | 628 | |
b0d623f7 A |
629 | #define PROC_PIDTHREADPATHINFO 10 |
630 | #define PROC_PIDTHREADPATHINFO_SIZE (sizeof(struct proc_threadwithpathinfo)) | |
2d21ac55 | 631 | |
b0d623f7 A |
632 | #define PROC_PIDPATHINFO 11 |
633 | #define PROC_PIDPATHINFO_SIZE (MAXPATHLEN) | |
634 | #define PROC_PIDPATHINFO_MAXSIZE (4*MAXPATHLEN) | |
2d21ac55 | 635 | |
b0d623f7 A |
636 | #define PROC_PIDWORKQUEUEINFO 12 |
637 | #define PROC_PIDWORKQUEUEINFO_SIZE (sizeof(struct proc_workqueueinfo)) | |
0c530ab8 | 638 | |
6d2010ae A |
639 | #define PROC_PIDT_SHORTBSDINFO 13 |
640 | #define PROC_PIDT_SHORTBSDINFO_SIZE (sizeof(struct proc_bsdshortinfo)) | |
641 | ||
642 | #define PROC_PIDLISTFILEPORTS 14 | |
643 | #define PROC_PIDLISTFILEPORTS_SIZE (sizeof(struct proc_fileportinfo)) | |
644 | ||
b0d623f7 | 645 | /* Flavors for proc_pidfdinfo */ |
0c530ab8 | 646 | |
b0d623f7 A |
647 | #define PROC_PIDFDVNODEINFO 1 |
648 | #define PROC_PIDFDVNODEINFO_SIZE (sizeof(struct vnode_fdinfo)) | |
0c530ab8 | 649 | |
b0d623f7 A |
650 | #define PROC_PIDFDVNODEPATHINFO 2 |
651 | #define PROC_PIDFDVNODEPATHINFO_SIZE (sizeof(struct vnode_fdinfowithpath)) | |
0c530ab8 | 652 | |
b0d623f7 A |
653 | #define PROC_PIDFDSOCKETINFO 3 |
654 | #define PROC_PIDFDSOCKETINFO_SIZE (sizeof(struct socket_fdinfo)) | |
0c530ab8 | 655 | |
b0d623f7 A |
656 | #define PROC_PIDFDPSEMINFO 4 |
657 | #define PROC_PIDFDPSEMINFO_SIZE (sizeof(struct psem_fdinfo)) | |
0c530ab8 | 658 | |
b0d623f7 A |
659 | #define PROC_PIDFDPSHMINFO 5 |
660 | #define PROC_PIDFDPSHMINFO_SIZE (sizeof(struct pshm_fdinfo)) | |
0c530ab8 | 661 | |
b0d623f7 A |
662 | #define PROC_PIDFDPIPEINFO 6 |
663 | #define PROC_PIDFDPIPEINFO_SIZE (sizeof(struct pipe_fdinfo)) | |
0c530ab8 | 664 | |
b0d623f7 A |
665 | #define PROC_PIDFDKQUEUEINFO 7 |
666 | #define PROC_PIDFDKQUEUEINFO_SIZE (sizeof(struct kqueue_fdinfo)) | |
0c530ab8 | 667 | |
b0d623f7 A |
668 | #define PROC_PIDFDATALKINFO 8 |
669 | #define PROC_PIDFDATALKINFO_SIZE (sizeof(struct appletalk_fdinfo)) | |
0c530ab8 | 670 | |
6d2010ae A |
671 | /* Flavors for proc_pidfileportinfo */ |
672 | ||
673 | #define PROC_PIDFILEPORTVNODEPATHINFO 2 /* out: vnode_fdinfowithpath */ | |
674 | #define PROC_PIDFILEPORTVNODEPATHINFO_SIZE \ | |
675 | PROC_PIDFDVNODEPATHINFO_SIZE | |
676 | ||
677 | #define PROC_PIDFILEPORTSOCKETINFO 3 /* out: socket_fdinfo */ | |
678 | #define PROC_PIDFILEPORTSOCKETINFO_SIZE PROC_PIDFDSOCKETINFO_SIZE | |
679 | ||
680 | #define PROC_PIDFILEPORTPSHMINFO 5 /* out: pshm_fdinfo */ | |
681 | #define PROC_PIDFILEPORTPSHMINFO_SIZE PROC_PIDFDPSHMINFO_SIZE | |
682 | ||
683 | #define PROC_PIDFILEPORTPIPEINFO 6 /* out: pipe_fdinfo */ | |
684 | #define PROC_PIDFILEPORTPIPEINFO_SIZE PROC_PIDFDPIPEINFO_SIZE | |
685 | ||
b0d623f7 A |
686 | /* used for proc_setcontrol */ |
687 | #define PROC_SELFSET_PCONTROL 1 | |
0c530ab8 | 688 | |
6d2010ae A |
689 | #define PROC_SELFSET_THREADNAME 2 |
690 | #define PROC_SELFSET_THREADNAME_SIZE (MAXTHREADNAMESIZE -1) | |
691 | ||
692 | #define PROC_SELFSET_VMRSRCOWNER 3 | |
693 | ||
0c530ab8 | 694 | #ifdef XNU_KERNEL_PRIVATE |
b0d623f7 A |
695 | #ifndef pshmnode |
696 | struct pshmnode; | |
697 | #endif | |
698 | ||
699 | #ifndef psemnode | |
700 | struct psemnode ; | |
701 | #endif | |
702 | ||
703 | #ifndef pipe | |
704 | struct pipe; | |
705 | #endif | |
706 | ||
0c530ab8 A |
707 | extern int fill_socketinfo(socket_t so, struct socket_info *si); |
708 | extern int fill_pshminfo(struct pshmnode * pshm, struct pshm_info * pinfo); | |
709 | extern int fill_pseminfo(struct psemnode * psem, struct psem_info * pinfo); | |
710 | extern int fill_pipeinfo(struct pipe * cpipe, struct pipe_info * pinfo); | |
711 | extern int fill_kqueueinfo(struct kqueue * kq, struct kqueue_info * kinfo); | |
b0d623f7 | 712 | extern int fill_procworkqueue(proc_t, struct proc_workqueueinfo *); |
0c530ab8 A |
713 | #endif /* XNU_KERNEL_PRIVATE */ |
714 | ||
0c530ab8 A |
715 | __END_DECLS |
716 | ||
717 | #endif /*_SYS_PROC_INFO_H */ |