|
4 | 4 |
|
5 | 5 | #define PROX_FDTYPE_VNODE 1 |
6 | 6 | #define PROC_PIDFDVNODEPATHINFO 2 |
| 7 | +#define PROC_PIDFDSOCKETINFO 3 |
7 | 8 | #define PROC_PIDFDPIPEINFO 6 |
8 | 9 |
|
9 | 10 | #define PROC_PIDLISTFDS 1 |
@@ -77,4 +78,190 @@ struct pipe_fdinfo { |
77 | 78 | struct pipe_info pipeinfo; |
78 | 79 | }; |
79 | 80 |
|
80 | | -#endif |
| 81 | +/* https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/proc_info.h */ |
| 82 | + |
| 83 | +#include <sys/ioctl.h> |
| 84 | +#include <sys/un.h> |
| 85 | + |
| 86 | +#define MAX_KCTL_NAME 96 |
| 87 | + |
| 88 | +typedef struct in6_addr { |
| 89 | + union { |
| 90 | + __uint8_t __u6_addr8[16]; |
| 91 | + __uint16_t __u6_addr16[8]; |
| 92 | + __uint32_t __u6_addr32[4]; |
| 93 | + } __u6_addr; /* 128-bit IP6 address */ |
| 94 | +} in6_addr_t; |
| 95 | + |
| 96 | + |
| 97 | +struct in_addr { |
| 98 | + in_addr_t s_addr; |
| 99 | +}; |
| 100 | + |
| 101 | +#define INI_IPV4 0x1 |
| 102 | +#define INI_IPV6 0x2 |
| 103 | + |
| 104 | +struct in4in6_addr { |
| 105 | + u_int32_t i46a_pad32[3]; |
| 106 | + struct in_addr i46a_addr4; |
| 107 | +}; |
| 108 | + |
| 109 | +struct in_sockinfo { |
| 110 | + int insi_fport; /* foreign port */ |
| 111 | + int insi_lport; /* local port */ |
| 112 | + uint64_t insi_gencnt; /* generation count of this instance */ |
| 113 | + uint32_t insi_flags; /* generic IP/datagram flags */ |
| 114 | + uint32_t insi_flow; |
| 115 | + |
| 116 | + uint8_t insi_vflag; /* ini_IPV4 or ini_IPV6 */ |
| 117 | + uint8_t insi_ip_ttl; /* time to live proto */ |
| 118 | + uint32_t rfu_1; /* reserved */ |
| 119 | + /* protocol dependent part */ |
| 120 | + union { |
| 121 | + struct in4in6_addr ina_46; |
| 122 | + struct in6_addr ina_6; |
| 123 | + } insi_faddr; /* foreign host table entry */ |
| 124 | + union { |
| 125 | + struct in4in6_addr ina_46; |
| 126 | + struct in6_addr ina_6; |
| 127 | + } insi_laddr; /* local host table entry */ |
| 128 | + struct { |
| 129 | + u_char in4_tos; /* type of service */ |
| 130 | + } insi_v4; |
| 131 | + struct { |
| 132 | + uint8_t in6_hlim; |
| 133 | + int in6_cksum; |
| 134 | + u_short in6_ifindex; |
| 135 | + short in6_hops; |
| 136 | + } insi_v6; |
| 137 | +}; |
| 138 | + |
| 139 | +#define TSI_T_REXMT 0 /* retransmit */ |
| 140 | +#define TSI_T_PERSIST 1 /* retransmit persistence */ |
| 141 | +#define TSI_T_KEEP 2 /* keep alive */ |
| 142 | +#define TSI_T_2MSL 3 /* 2*msl quiet time timer */ |
| 143 | +#define TSI_T_NTIMERS 4 |
| 144 | + |
| 145 | +#define TSI_S_CLOSED 0 /* closed */ |
| 146 | +#define TSI_S_LISTEN 1 /* listening for connection */ |
| 147 | +#define TSI_S_SYN_SENT 2 /* active, have sent syn */ |
| 148 | +#define TSI_S_SYN_RECEIVED 3 /* have send and received syn */ |
| 149 | +#define TSI_S_ESTABLISHED 4 /* established */ |
| 150 | +#define TSI_S__CLOSE_WAIT 5 /* rcvd fin, waiting for close */ |
| 151 | +#define TSI_S_FIN_WAIT_1 6 /* have closed, sent fin */ |
| 152 | +#define TSI_S_CLOSING 7 /* closed xchd FIN; await FIN ACK */ |
| 153 | +#define TSI_S_LAST_ACK 8 /* had fin and close; await FIN ACK */ |
| 154 | +#define TSI_S_FIN_WAIT_2 9 /* have closed, fin is acked */ |
| 155 | +#define TSI_S_TIME_WAIT 10 /* in 2*msl quiet wait after close */ |
| 156 | +#define TSI_S_RESERVED 11 /* pseudo state: reserved */ |
| 157 | + |
| 158 | +struct tcp_sockinfo { |
| 159 | + struct in_sockinfo tcpsi_ini; |
| 160 | + int tcpsi_state; |
| 161 | + int tcpsi_timer[TSI_T_NTIMERS]; |
| 162 | + int tcpsi_mss; |
| 163 | + uint32_t tcpsi_flags; |
| 164 | + uint32_t rfu_1; /* reserved */ |
| 165 | + uint64_t tcpsi_tp; /* opaque handle of TCP protocol control block */ |
| 166 | +}; |
| 167 | + |
| 168 | +struct un_sockinfo { |
| 169 | + uint64_t unsi_conn_so; /* opaque handle of connected socket */ |
| 170 | + uint64_t unsi_conn_pcb; /* opaque handle of connected protocol control block */ |
| 171 | + union { |
| 172 | + struct sockaddr_un ua_sun; |
| 173 | + char ua_dummy[SOCK_MAXADDRLEN]; |
| 174 | + } unsi_addr; /* bound address */ |
| 175 | + union { |
| 176 | + struct sockaddr_un ua_sun; |
| 177 | + char ua_dummy[SOCK_MAXADDRLEN]; |
| 178 | + } unsi_caddr; /* address of socket connected to */ |
| 179 | +}; |
| 180 | + |
| 181 | +struct ndrv_info { |
| 182 | + uint32_t ndrvsi_if_family; |
| 183 | + uint32_t ndrvsi_if_unit; |
| 184 | + char ndrvsi_if_name[IF_NAMESIZE]; |
| 185 | +}; |
| 186 | + |
| 187 | +struct kern_event_info { |
| 188 | + uint32_t kesi_vendor_code_filter; |
| 189 | + uint32_t kesi_class_filter; |
| 190 | + uint32_t kesi_subclass_filter; |
| 191 | +}; |
| 192 | + |
| 193 | +struct kern_ctl_info { |
| 194 | + uint32_t kcsi_id; |
| 195 | + uint32_t kcsi_reg_unit; |
| 196 | + uint32_t kcsi_flags; /* support flags */ |
| 197 | + uint32_t kcsi_recvbufsize; /* request more than the default buffer size */ |
| 198 | + uint32_t kcsi_sendbufsize; /* request more than the default buffer size */ |
| 199 | + uint32_t kcsi_unit; |
| 200 | + char kcsi_name[MAX_KCTL_NAME]; /* unique nke identifier, provided by DTS */ |
| 201 | +}; |
| 202 | + |
| 203 | +struct vsock_sockinfo { |
| 204 | + uint32_t local_cid; |
| 205 | + uint32_t local_port; |
| 206 | + uint32_t remote_cid; |
| 207 | + uint32_t remote_port; |
| 208 | +}; |
| 209 | + |
| 210 | +struct sockbuf_info { |
| 211 | + uint32_t sbi_cc; |
| 212 | + uint32_t sbi_hiwat; /* SO_RCVBUF, SO_SNDBUF */ |
| 213 | + uint32_t sbi_mbcnt; |
| 214 | + uint32_t sbi_mbmax; |
| 215 | + uint32_t sbi_lowat; |
| 216 | + short sbi_flags; |
| 217 | + short sbi_timeo; |
| 218 | +}; |
| 219 | + |
| 220 | +enum { |
| 221 | + SOCKINFO_GENERIC = 0, |
| 222 | + SOCKINFO_IN = 1, |
| 223 | + SOCKINFO_TCP = 2, |
| 224 | + SOCKINFO_UN = 3, |
| 225 | + SOCKINFO_NDRV = 4, |
| 226 | + SOCKINFO_KERN_EVENT = 5, |
| 227 | + SOCKINFO_KERN_CTL = 6, |
| 228 | + SOCKINFO_VSOCK = 7, |
| 229 | +}; |
| 230 | + |
| 231 | +struct socket_info { |
| 232 | + struct vinfo_stat soi_stat; |
| 233 | + uint64_t soi_so; /* opaque handle of socket */ |
| 234 | + uint64_t soi_pcb; /* opaque handle of protocol control block */ |
| 235 | + int soi_type; |
| 236 | + int soi_protocol; |
| 237 | + int soi_family; |
| 238 | + short soi_options; |
| 239 | + short soi_linger; |
| 240 | + short soi_state; |
| 241 | + short soi_qlen; |
| 242 | + short soi_incqlen; |
| 243 | + short soi_qlimit; |
| 244 | + short soi_timeo; |
| 245 | + u_short soi_error; |
| 246 | + uint32_t soi_oobmark; |
| 247 | + struct sockbuf_info soi_rcv; |
| 248 | + struct sockbuf_info soi_snd; |
| 249 | + int soi_kind; |
| 250 | + uint32_t rfu_1; /* reserved */ |
| 251 | + union { |
| 252 | + struct in_sockinfo pri_in; /* SOCKINFO_IN */ |
| 253 | + struct tcp_sockinfo pri_tcp; /* SOCKINFO_TCP */ |
| 254 | + struct un_sockinfo pri_un; /* SOCKINFO_UN */ |
| 255 | + struct ndrv_info pri_ndrv; /* SOCKINFO_NDRV */ |
| 256 | + struct kern_event_info pri_kern_event; /* SOCKINFO_KERN_EVENT */ |
| 257 | + struct kern_ctl_info pri_kern_ctl; /* SOCKINFO_KERN_CTL */ |
| 258 | + struct vsock_sockinfo pri_vsock; /* SOCKINFO_VSOCK */ |
| 259 | + } soi_proto; |
| 260 | +}; |
| 261 | + |
| 262 | +struct socket_fdinfo { |
| 263 | + struct proc_fileinfo pfi; |
| 264 | + struct socket_info psi; |
| 265 | +}; |
| 266 | + |
| 267 | +#endif // !_PROCINFO_H_ |
0 commit comments