File: | obj-scan-build/pflocal/socketServer.c |
Location: | line 481, column 2 |
Description: | Assigned value is garbage or undefined |
1 | /* Module socket */ |
2 | |
3 | #ifndef _GNU_SOURCE1 |
4 | #define _GNU_SOURCE1 1 |
5 | #endif |
6 | |
7 | #define EXPORT_BOOLEAN |
8 | #include <mach/boolean.h> |
9 | #include <mach/kern_return.h> |
10 | #include <mach/message.h> |
11 | #include <mach/mig_errors.h> |
12 | #include <mach/mig_support.h> |
13 | |
14 | #ifndef mig_internalstatic |
15 | #define mig_internalstatic static |
16 | #endif |
17 | |
18 | #ifndef mig_external |
19 | #define mig_external |
20 | #endif |
21 | |
22 | #ifndef mig_unlikely |
23 | #define mig_unlikely(X)__builtin_expect (!! (X), 0) __builtin_expect (!! (X), 0) |
24 | #endif |
25 | |
26 | #ifndef TypeCheck1 |
27 | #define TypeCheck1 1 |
28 | #endif |
29 | |
30 | #ifndef UseExternRCSId1 |
31 | #define UseExternRCSId1 1 |
32 | #endif |
33 | |
34 | #define BAD_TYPECHECK(type, check)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) mig_unlikely (({\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
35 | union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
36 | _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
37 | #define msgh_request_portmsgh_local_port msgh_local_port |
38 | #define MACH_MSGH_BITS_REQUEST(bits)(((bits) & 0x0000ff00) >> 8) MACH_MSGH_BITS_LOCAL(bits)(((bits) & 0x0000ff00) >> 8) |
39 | #define msgh_reply_portmsgh_remote_port msgh_remote_port |
40 | #define MACH_MSGH_BITS_REPLY(bits)((bits) & 0x000000ff) MACH_MSGH_BITS_REMOTE(bits)((bits) & 0x000000ff) |
41 | |
42 | #include <hurd/ports.h> |
43 | #include <mach/std_types.h> |
44 | #include <mach/mach_types.h> |
45 | #include <device/device_types.h> |
46 | #include <device/net_status.h> |
47 | #include <sys/types.h> |
48 | #include <sys/stat.h> |
49 | #include <sys/statfs.h> |
50 | #include <sys/resource.h> |
51 | #include <sys/utsname.h> |
52 | #include <hurd/hurd_types.h> |
53 | #include "mig-decls.h" |
54 | |
55 | /* Routine socket_create */ |
56 | mig_internalstatic void _Xsocket_create |
57 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
58 | { |
59 | typedef struct { |
60 | mach_msg_header_t Head; |
61 | mach_msg_type_t sock_typeType; |
62 | int sock_type; |
63 | mach_msg_type_t protocolType; |
64 | int protocol; |
65 | } Request; |
66 | |
67 | typedef struct { |
68 | mach_msg_header_t Head; |
69 | mach_msg_type_t RetCodeType; |
70 | kern_return_t RetCode; |
71 | mach_msg_type_t sockType; |
72 | mach_port_t sock; |
73 | } Reply; |
74 | |
75 | Request *In0P = (Request *) InHeadP; |
76 | Reply *OutP = (Reply *) OutHeadP; |
77 | mig_external kern_return_t S_socket_create |
78 | (pf_t server, int sock_type, int protocol, mach_port_t *sock, mach_msg_type_name_t *sockPoly); |
79 | |
80 | boolean_t msgh_simple = msgh_simple; |
81 | const mach_msg_type_t sock_typeCheck = { |
82 | /* msgt_name = */ 2, |
83 | /* msgt_size = */ 32, |
84 | /* msgt_number = */ 1, |
85 | /* msgt_inline = */ TRUE((boolean_t) 1), |
86 | /* msgt_longform = */ FALSE((boolean_t) 0), |
87 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
88 | /* msgt_unused = */ 0 |
89 | }; |
90 | |
91 | const mach_msg_type_t protocolCheck = { |
92 | /* msgt_name = */ 2, |
93 | /* msgt_size = */ 32, |
94 | /* msgt_number = */ 1, |
95 | /* msgt_inline = */ TRUE((boolean_t) 1), |
96 | /* msgt_longform = */ FALSE((boolean_t) 0), |
97 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
98 | /* msgt_unused = */ 0 |
99 | }; |
100 | |
101 | const mach_msg_type_t sockType = { |
102 | /* msgt_name = */ -1, |
103 | /* msgt_size = */ 32, |
104 | /* msgt_number = */ 1, |
105 | /* msgt_inline = */ TRUE((boolean_t) 1), |
106 | /* msgt_longform = */ FALSE((boolean_t) 0), |
107 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
108 | /* msgt_unused = */ 0 |
109 | }; |
110 | |
111 | pf_t server; |
112 | mach_msg_type_name_t sockPoly; |
113 | |
114 | #if TypeCheck1 |
115 | if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
116 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
117 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
118 | #endif /* TypeCheck */ |
119 | |
120 | #if TypeCheck1 |
121 | if (BAD_TYPECHECK(&In0P->sock_typeType, &sock_typeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->sock_typeType); _c.t = * (&sock_typeCheck);_t.w != _c.w; })), 0)) |
122 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
123 | #endif /* TypeCheck */ |
124 | |
125 | #if TypeCheck1 |
126 | if (BAD_TYPECHECK(&In0P->protocolType, &protocolCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->protocolType); _c.t = *( &protocolCheck);_t.w != _c.w; })), 0)) |
127 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
128 | #endif /* TypeCheck */ |
129 | |
130 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
131 | server = ports_payload_get_name(In0P->Head.msgh_protected_payload); |
132 | else |
133 | server = In0P->Head.msgh_request_portmsgh_local_port; |
134 | OutP->RetCode = S_socket_create(server, In0P->sock_type, In0P->protocol, &OutP->sock, &sockPoly); |
135 | if (OutP->RetCode != KERN_SUCCESS0) |
136 | return; |
137 | |
138 | msgh_simple = TRUE((boolean_t) 1); |
139 | OutP->Head.msgh_size = 40; |
140 | |
141 | OutP->sockType = sockType; |
142 | |
143 | if (MACH_MSG_TYPE_PORT_ANY(sockPoly)(((sockPoly) >= 16) && ((sockPoly) <= 21))) |
144 | msgh_simple = FALSE((boolean_t) 0); |
145 | |
146 | OutP->sockType.msgt_name = sockPoly; |
147 | |
148 | if (!msgh_simple) |
149 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
150 | } |
151 | |
152 | /* Default implementation of S_socket_create */ |
153 | #ifdef MIG_EOPNOTSUPP |
154 | kern_return_t __attribute__ ((weak)) |
155 | S_socket_create |
156 | ( |
157 | pf_t server, |
158 | int sock_type, |
159 | int protocol, |
160 | mach_port_t *sock, |
161 | mach_msg_type_name_t *sockPoly |
162 | ) { return MIG_EOPNOTSUPP; } |
163 | #endif /* MIG_EOPNOTSUPP */ |
164 | |
165 | /* Routine socket_listen */ |
166 | mig_internalstatic void _Xsocket_listen |
167 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
168 | { |
169 | typedef struct { |
170 | mach_msg_header_t Head; |
171 | mach_msg_type_t queue_limitType; |
172 | int queue_limit; |
173 | } Request; |
174 | |
175 | typedef struct { |
176 | mach_msg_header_t Head; |
177 | mach_msg_type_t RetCodeType; |
178 | kern_return_t RetCode; |
179 | } Reply; |
180 | |
181 | Request *In0P = (Request *) InHeadP; |
182 | Reply *OutP = (Reply *) OutHeadP; |
183 | mig_external kern_return_t S_socket_listen |
184 | (sock_user_t sock, int queue_limit); |
185 | |
186 | const mach_msg_type_t queue_limitCheck = { |
187 | /* msgt_name = */ 2, |
188 | /* msgt_size = */ 32, |
189 | /* msgt_number = */ 1, |
190 | /* msgt_inline = */ TRUE((boolean_t) 1), |
191 | /* msgt_longform = */ FALSE((boolean_t) 0), |
192 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
193 | /* msgt_unused = */ 0 |
194 | }; |
195 | |
196 | sock_user_t sock; |
197 | |
198 | #if TypeCheck1 |
199 | if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
200 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
201 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
202 | #endif /* TypeCheck */ |
203 | |
204 | #if TypeCheck1 |
205 | if (BAD_TYPECHECK(&In0P->queue_limitType, &queue_limitCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->queue_limitType); _c.t = *(&queue_limitCheck);_t.w != _c.w; })), 0)) |
206 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
207 | #endif /* TypeCheck */ |
208 | |
209 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
210 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
211 | else |
212 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
213 | |
214 | OutP->RetCode = S_socket_listen(sock, In0P->queue_limit); |
215 | end_using_sock_user_port(sock); |
216 | } |
217 | |
218 | /* Default implementation of S_socket_listen */ |
219 | #ifdef MIG_EOPNOTSUPP |
220 | kern_return_t __attribute__ ((weak)) |
221 | S_socket_listen |
222 | ( |
223 | sock_user_t sock, |
224 | int queue_limit |
225 | ) { return MIG_EOPNOTSUPP; } |
226 | #endif /* MIG_EOPNOTSUPP */ |
227 | |
228 | /* Routine socket_accept */ |
229 | mig_internalstatic void _Xsocket_accept |
230 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
231 | { |
232 | typedef struct { |
233 | mach_msg_header_t Head; |
234 | } Request; |
235 | |
236 | typedef struct { |
237 | mach_msg_header_t Head; |
238 | mach_msg_type_t RetCodeType; |
239 | kern_return_t RetCode; |
240 | mach_msg_type_t conn_sockType; |
241 | mach_port_t conn_sock; |
242 | mach_msg_type_t peer_addrType; |
243 | mach_port_t peer_addr; |
244 | } Reply; |
245 | |
246 | Request *In0P = (Request *) InHeadP; |
247 | Reply *OutP = (Reply *) OutHeadP; |
248 | mig_external kern_return_t S_socket_accept |
249 | (sock_user_t sock, mach_port_t *conn_sock, mach_msg_type_name_t *conn_sockPoly, mach_port_t *peer_addr, mach_msg_type_name_t *peer_addrPoly); |
250 | |
251 | boolean_t msgh_simple = msgh_simple; |
252 | const mach_msg_type_t conn_sockType = { |
253 | /* msgt_name = */ -1, |
254 | /* msgt_size = */ 32, |
255 | /* msgt_number = */ 1, |
256 | /* msgt_inline = */ TRUE((boolean_t) 1), |
257 | /* msgt_longform = */ FALSE((boolean_t) 0), |
258 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
259 | /* msgt_unused = */ 0 |
260 | }; |
261 | |
262 | const mach_msg_type_t peer_addrType = { |
263 | /* msgt_name = */ -1, |
264 | /* msgt_size = */ 32, |
265 | /* msgt_number = */ 1, |
266 | /* msgt_inline = */ TRUE((boolean_t) 1), |
267 | /* msgt_longform = */ FALSE((boolean_t) 0), |
268 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
269 | /* msgt_unused = */ 0 |
270 | }; |
271 | |
272 | sock_user_t sock; |
273 | mach_msg_type_name_t conn_sockPoly; |
274 | mach_msg_type_name_t peer_addrPoly; |
275 | |
276 | #if TypeCheck1 |
277 | if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
278 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
279 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
280 | #endif /* TypeCheck */ |
281 | |
282 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
283 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
284 | else |
285 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
286 | |
287 | OutP->RetCode = S_socket_accept(sock, &OutP->conn_sock, &conn_sockPoly, &OutP->peer_addr, &peer_addrPoly); |
288 | end_using_sock_user_port(sock); |
289 | if (OutP->RetCode != KERN_SUCCESS0) |
290 | return; |
291 | |
292 | msgh_simple = TRUE((boolean_t) 1); |
293 | OutP->Head.msgh_size = 48; |
294 | |
295 | OutP->conn_sockType = conn_sockType; |
296 | |
297 | if (MACH_MSG_TYPE_PORT_ANY(conn_sockPoly)(((conn_sockPoly) >= 16) && ((conn_sockPoly) <= 21))) |
298 | msgh_simple = FALSE((boolean_t) 0); |
299 | |
300 | OutP->conn_sockType.msgt_name = conn_sockPoly; |
301 | |
302 | OutP->peer_addrType = peer_addrType; |
303 | |
304 | if (MACH_MSG_TYPE_PORT_ANY(peer_addrPoly)(((peer_addrPoly) >= 16) && ((peer_addrPoly) <= 21))) |
305 | msgh_simple = FALSE((boolean_t) 0); |
306 | |
307 | OutP->peer_addrType.msgt_name = peer_addrPoly; |
308 | |
309 | if (!msgh_simple) |
310 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
311 | } |
312 | |
313 | /* Default implementation of S_socket_accept */ |
314 | #ifdef MIG_EOPNOTSUPP |
315 | kern_return_t __attribute__ ((weak)) |
316 | S_socket_accept |
317 | ( |
318 | sock_user_t sock, |
319 | mach_port_t *conn_sock, |
320 | mach_msg_type_name_t *conn_sockPoly, |
321 | mach_port_t *peer_addr, |
322 | mach_msg_type_name_t *peer_addrPoly |
323 | ) { return MIG_EOPNOTSUPP; } |
324 | #endif /* MIG_EOPNOTSUPP */ |
325 | |
326 | /* Routine socket_connect */ |
327 | mig_internalstatic void _Xsocket_connect |
328 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
329 | { |
330 | typedef struct { |
331 | mach_msg_header_t Head; |
332 | mach_msg_type_t addrType; |
333 | addr_port_t addr; |
334 | } Request; |
335 | |
336 | typedef struct { |
337 | mach_msg_header_t Head; |
338 | mach_msg_type_t RetCodeType; |
339 | kern_return_t RetCode; |
340 | } Reply; |
341 | |
342 | Request *In0P = (Request *) InHeadP; |
343 | Reply *OutP = (Reply *) OutHeadP; |
344 | mig_external kern_return_t S_socket_connect |
345 | (sock_user_t sock, addr_t addr); |
346 | |
347 | const mach_msg_type_t addrCheck = { |
348 | /* msgt_name = */ 17, |
349 | /* msgt_size = */ 32, |
350 | /* msgt_number = */ 1, |
351 | /* msgt_inline = */ TRUE((boolean_t) 1), |
352 | /* msgt_longform = */ FALSE((boolean_t) 0), |
353 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
354 | /* msgt_unused = */ 0 |
355 | }; |
356 | |
357 | sock_user_t sock; |
358 | addr_t addr; |
359 | |
360 | #if TypeCheck1 |
361 | if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P ->Head.msgh_bits & 0x80000000U)), 0) |
362 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
363 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
364 | #endif /* TypeCheck */ |
365 | |
366 | #if TypeCheck1 |
367 | if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->addrType); _c.t = *(& addrCheck);_t.w != _c.w; })), 0)) |
368 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
369 | #endif /* TypeCheck */ |
370 | |
371 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
372 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
373 | else |
374 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
375 | |
376 | addr = begin_using_addr_port(In0P->addr); |
377 | |
378 | OutP->RetCode = S_socket_connect(sock, addr); |
379 | end_using_addr_port(addr); |
380 | end_using_sock_user_port(sock); |
381 | } |
382 | |
383 | /* Default implementation of S_socket_connect */ |
384 | #ifdef MIG_EOPNOTSUPP |
385 | kern_return_t __attribute__ ((weak)) |
386 | S_socket_connect |
387 | ( |
388 | sock_user_t sock, |
389 | addr_t addr |
390 | ) { return MIG_EOPNOTSUPP; } |
391 | #endif /* MIG_EOPNOTSUPP */ |
392 | |
393 | /* Routine socket_bind */ |
394 | mig_internalstatic void _Xsocket_bind |
395 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
396 | { |
397 | typedef struct { |
398 | mach_msg_header_t Head; |
399 | mach_msg_type_t addrType; |
400 | addr_port_t addr; |
401 | } Request; |
402 | |
403 | typedef struct { |
404 | mach_msg_header_t Head; |
405 | mach_msg_type_t RetCodeType; |
406 | kern_return_t RetCode; |
407 | } Reply; |
408 | |
409 | Request *In0P = (Request *) InHeadP; |
410 | Reply *OutP = (Reply *) OutHeadP; |
411 | mig_external kern_return_t S_socket_bind |
412 | (sock_user_t sock, addr_t addr); |
413 | |
414 | const mach_msg_type_t addrCheck = { |
415 | /* msgt_name = */ 17, |
416 | /* msgt_size = */ 32, |
417 | /* msgt_number = */ 1, |
418 | /* msgt_inline = */ TRUE((boolean_t) 1), |
419 | /* msgt_longform = */ FALSE((boolean_t) 0), |
420 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
421 | /* msgt_unused = */ 0 |
422 | }; |
423 | |
424 | sock_user_t sock; |
425 | addr_t addr; |
426 | |
427 | #if TypeCheck1 |
428 | if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P ->Head.msgh_bits & 0x80000000U)), 0) |
429 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
430 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
431 | #endif /* TypeCheck */ |
432 | |
433 | #if TypeCheck1 |
434 | if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->addrType); _c.t = *(& addrCheck);_t.w != _c.w; })), 0)) |
435 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
436 | #endif /* TypeCheck */ |
437 | |
438 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
439 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
440 | else |
441 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
442 | |
443 | addr = begin_using_addr_port(In0P->addr); |
444 | |
445 | OutP->RetCode = S_socket_bind(sock, addr); |
446 | end_using_addr_port(addr); |
447 | end_using_sock_user_port(sock); |
448 | } |
449 | |
450 | /* Default implementation of S_socket_bind */ |
451 | #ifdef MIG_EOPNOTSUPP |
452 | kern_return_t __attribute__ ((weak)) |
453 | S_socket_bind |
454 | ( |
455 | sock_user_t sock, |
456 | addr_t addr |
457 | ) { return MIG_EOPNOTSUPP; } |
458 | #endif /* MIG_EOPNOTSUPP */ |
459 | |
460 | /* Routine socket_name */ |
461 | mig_internalstatic void _Xsocket_name |
462 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
463 | { |
464 | typedef struct { |
465 | mach_msg_header_t Head; |
466 | } Request; |
467 | |
468 | typedef struct { |
469 | mach_msg_header_t Head; |
470 | mach_msg_type_t RetCodeType; |
471 | kern_return_t RetCode; |
472 | mach_msg_type_t addrType; |
473 | mach_port_t addr; |
474 | } Reply; |
475 | |
476 | Request *In0P = (Request *) InHeadP; |
477 | Reply *OutP = (Reply *) OutHeadP; |
478 | mig_external kern_return_t S_socket_name |
479 | (sock_user_t sock, mach_port_t *addr, mach_msg_type_name_t *addrPoly); |
480 | |
481 | boolean_t msgh_simple = msgh_simple; |
Assigned value is garbage or undefined | |
482 | const mach_msg_type_t addrType = { |
483 | /* msgt_name = */ -1, |
484 | /* msgt_size = */ 32, |
485 | /* msgt_number = */ 1, |
486 | /* msgt_inline = */ TRUE((boolean_t) 1), |
487 | /* msgt_longform = */ FALSE((boolean_t) 0), |
488 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
489 | /* msgt_unused = */ 0 |
490 | }; |
491 | |
492 | sock_user_t sock; |
493 | mach_msg_type_name_t addrPoly; |
494 | |
495 | #if TypeCheck1 |
496 | if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
497 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
498 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
499 | #endif /* TypeCheck */ |
500 | |
501 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
502 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
503 | else |
504 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
505 | |
506 | OutP->RetCode = S_socket_name(sock, &OutP->addr, &addrPoly); |
507 | end_using_sock_user_port(sock); |
508 | if (OutP->RetCode != KERN_SUCCESS0) |
509 | return; |
510 | |
511 | msgh_simple = TRUE((boolean_t) 1); |
512 | OutP->Head.msgh_size = 40; |
513 | |
514 | OutP->addrType = addrType; |
515 | |
516 | if (MACH_MSG_TYPE_PORT_ANY(addrPoly)(((addrPoly) >= 16) && ((addrPoly) <= 21))) |
517 | msgh_simple = FALSE((boolean_t) 0); |
518 | |
519 | OutP->addrType.msgt_name = addrPoly; |
520 | |
521 | if (!msgh_simple) |
522 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
523 | } |
524 | |
525 | /* Default implementation of S_socket_name */ |
526 | #ifdef MIG_EOPNOTSUPP |
527 | kern_return_t __attribute__ ((weak)) |
528 | S_socket_name |
529 | ( |
530 | sock_user_t sock, |
531 | mach_port_t *addr, |
532 | mach_msg_type_name_t *addrPoly |
533 | ) { return MIG_EOPNOTSUPP; } |
534 | #endif /* MIG_EOPNOTSUPP */ |
535 | |
536 | /* Routine socket_peername */ |
537 | mig_internalstatic void _Xsocket_peername |
538 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
539 | { |
540 | typedef struct { |
541 | mach_msg_header_t Head; |
542 | } Request; |
543 | |
544 | typedef struct { |
545 | mach_msg_header_t Head; |
546 | mach_msg_type_t RetCodeType; |
547 | kern_return_t RetCode; |
548 | mach_msg_type_t addrType; |
549 | mach_port_t addr; |
550 | } Reply; |
551 | |
552 | Request *In0P = (Request *) InHeadP; |
553 | Reply *OutP = (Reply *) OutHeadP; |
554 | mig_external kern_return_t S_socket_peername |
555 | (sock_user_t sock, mach_port_t *addr, mach_msg_type_name_t *addrPoly); |
556 | |
557 | boolean_t msgh_simple = msgh_simple; |
558 | const mach_msg_type_t addrType = { |
559 | /* msgt_name = */ -1, |
560 | /* msgt_size = */ 32, |
561 | /* msgt_number = */ 1, |
562 | /* msgt_inline = */ TRUE((boolean_t) 1), |
563 | /* msgt_longform = */ FALSE((boolean_t) 0), |
564 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
565 | /* msgt_unused = */ 0 |
566 | }; |
567 | |
568 | sock_user_t sock; |
569 | mach_msg_type_name_t addrPoly; |
570 | |
571 | #if TypeCheck1 |
572 | if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
573 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
574 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
575 | #endif /* TypeCheck */ |
576 | |
577 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
578 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
579 | else |
580 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
581 | |
582 | OutP->RetCode = S_socket_peername(sock, &OutP->addr, &addrPoly); |
583 | end_using_sock_user_port(sock); |
584 | if (OutP->RetCode != KERN_SUCCESS0) |
585 | return; |
586 | |
587 | msgh_simple = TRUE((boolean_t) 1); |
588 | OutP->Head.msgh_size = 40; |
589 | |
590 | OutP->addrType = addrType; |
591 | |
592 | if (MACH_MSG_TYPE_PORT_ANY(addrPoly)(((addrPoly) >= 16) && ((addrPoly) <= 21))) |
593 | msgh_simple = FALSE((boolean_t) 0); |
594 | |
595 | OutP->addrType.msgt_name = addrPoly; |
596 | |
597 | if (!msgh_simple) |
598 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
599 | } |
600 | |
601 | /* Default implementation of S_socket_peername */ |
602 | #ifdef MIG_EOPNOTSUPP |
603 | kern_return_t __attribute__ ((weak)) |
604 | S_socket_peername |
605 | ( |
606 | sock_user_t sock, |
607 | mach_port_t *addr, |
608 | mach_msg_type_name_t *addrPoly |
609 | ) { return MIG_EOPNOTSUPP; } |
610 | #endif /* MIG_EOPNOTSUPP */ |
611 | |
612 | /* Routine socket_connect2 */ |
613 | mig_internalstatic void _Xsocket_connect2 |
614 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
615 | { |
616 | typedef struct { |
617 | mach_msg_header_t Head; |
618 | mach_msg_type_t sock2Type; |
619 | socket_t sock2; |
620 | } Request; |
621 | |
622 | typedef struct { |
623 | mach_msg_header_t Head; |
624 | mach_msg_type_t RetCodeType; |
625 | kern_return_t RetCode; |
626 | } Reply; |
627 | |
628 | Request *In0P = (Request *) InHeadP; |
629 | Reply *OutP = (Reply *) OutHeadP; |
630 | mig_external kern_return_t S_socket_connect2 |
631 | (sock_user_t sock1, sock_user_t sock2); |
632 | |
633 | const mach_msg_type_t sock2Check = { |
634 | /* msgt_name = */ 17, |
635 | /* msgt_size = */ 32, |
636 | /* msgt_number = */ 1, |
637 | /* msgt_inline = */ TRUE((boolean_t) 1), |
638 | /* msgt_longform = */ FALSE((boolean_t) 0), |
639 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
640 | /* msgt_unused = */ 0 |
641 | }; |
642 | |
643 | sock_user_t sock1; |
644 | sock_user_t sock2; |
645 | |
646 | #if TypeCheck1 |
647 | if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P ->Head.msgh_bits & 0x80000000U)), 0) |
648 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || !(In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
649 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
650 | #endif /* TypeCheck */ |
651 | |
652 | #if TypeCheck1 |
653 | if (BAD_TYPECHECK(&In0P->sock2Type, &sock2Check)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->sock2Type); _c.t = *(& sock2Check);_t.w != _c.w; })), 0)) |
654 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
655 | #endif /* TypeCheck */ |
656 | |
657 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
658 | sock1 = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
659 | else |
660 | sock1 = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
661 | |
662 | sock2 = begin_using_sock_user_port(In0P->sock2); |
663 | |
664 | OutP->RetCode = S_socket_connect2(sock1, sock2); |
665 | end_using_sock_user_port(sock2); |
666 | end_using_sock_user_port(sock1); |
667 | } |
668 | |
669 | /* Default implementation of S_socket_connect2 */ |
670 | #ifdef MIG_EOPNOTSUPP |
671 | kern_return_t __attribute__ ((weak)) |
672 | S_socket_connect2 |
673 | ( |
674 | sock_user_t sock1, |
675 | sock_user_t sock2 |
676 | ) { return MIG_EOPNOTSUPP; } |
677 | #endif /* MIG_EOPNOTSUPP */ |
678 | |
679 | /* Routine socket_create_address */ |
680 | mig_internalstatic void _Xsocket_create_address |
681 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
682 | { |
683 | typedef struct { |
684 | mach_msg_header_t Head; |
685 | mach_msg_type_t sockaddr_typeType; |
686 | int sockaddr_type; |
687 | mach_msg_type_long_t sockaddrType; |
688 | char sockaddr[2048]; |
689 | } Request; |
690 | |
691 | typedef struct { |
692 | mach_msg_header_t Head; |
693 | mach_msg_type_t RetCodeType; |
694 | kern_return_t RetCode; |
695 | mach_msg_type_t addrType; |
696 | mach_port_t addr; |
697 | } Reply; |
698 | |
699 | Request *In0P = (Request *) InHeadP; |
700 | Reply *OutP = (Reply *) OutHeadP; |
701 | mig_external kern_return_t S_socket_create_address |
702 | (mach_port_t server, int sockaddr_type, data_t sockaddr, mach_msg_type_number_t sockaddrCnt, mach_port_t *addr, mach_msg_type_name_t *addrPoly); |
703 | |
704 | boolean_t msgh_simple = msgh_simple; |
705 | unsigned int msgh_size; |
706 | |
707 | const mach_msg_type_t sockaddr_typeCheck = { |
708 | /* msgt_name = */ 2, |
709 | /* msgt_size = */ 32, |
710 | /* msgt_number = */ 1, |
711 | /* msgt_inline = */ TRUE((boolean_t) 1), |
712 | /* msgt_longform = */ FALSE((boolean_t) 0), |
713 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
714 | /* msgt_unused = */ 0 |
715 | }; |
716 | |
717 | const mach_msg_type_t addrType = { |
718 | /* msgt_name = */ -1, |
719 | /* msgt_size = */ 32, |
720 | /* msgt_number = */ 1, |
721 | /* msgt_inline = */ TRUE((boolean_t) 1), |
722 | /* msgt_longform = */ FALSE((boolean_t) 0), |
723 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
724 | /* msgt_unused = */ 0 |
725 | }; |
726 | |
727 | mach_port_t server; |
728 | mach_msg_type_name_t addrPoly; |
729 | |
730 | #if TypeCheck1 |
731 | msgh_size = In0P->Head.msgh_size; |
732 | msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U); |
733 | if (mig_unlikely ((msgh_size < 44))__builtin_expect (!! ((msgh_size < 44)), 0)) |
734 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
735 | #endif /* TypeCheck */ |
736 | |
737 | #if TypeCheck1 |
738 | if (BAD_TYPECHECK(&In0P->sockaddr_typeType, &sockaddr_typeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->sockaddr_typeType); _c.t = *(&sockaddr_typeCheck);_t.w != _c.w; })), 0)) |
739 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
740 | #endif /* TypeCheck */ |
741 | |
742 | #if TypeCheck1 |
743 | if (mig_unlikely ((In0P->sockaddrType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In0P->sockaddrType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->sockaddrType.msgtl_name != 8 ) || (In0P->sockaddrType.msgtl_size != 8)), 0) |
744 | (In0P->sockaddrType.msgtl_name != 8) ||__builtin_expect (!! ((In0P->sockaddrType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->sockaddrType.msgtl_name != 8 ) || (In0P->sockaddrType.msgtl_size != 8)), 0) |
745 | (In0P->sockaddrType.msgtl_size != 8))__builtin_expect (!! ((In0P->sockaddrType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->sockaddrType.msgtl_name != 8 ) || (In0P->sockaddrType.msgtl_size != 8)), 0)) |
746 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
747 | #endif /* TypeCheck */ |
748 | |
749 | #if TypeCheck1 |
750 | if (mig_unlikely (msgh_size != 44 + ((In0P->sockaddrType.msgtl_header.msgt_inline) ? (In0P->sockaddrType.msgtl_number + 3) & ~3 : sizeof(char *)))__builtin_expect (!! (msgh_size != 44 + ((In0P->sockaddrType .msgtl_header.msgt_inline) ? (In0P->sockaddrType.msgtl_number + 3) & ~3 : sizeof(char *))), 0)) |
751 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
752 | #endif /* TypeCheck */ |
753 | |
754 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
755 | server = ports_payload_get_name(In0P->Head.msgh_protected_payload); |
756 | else |
757 | server = In0P->Head.msgh_request_portmsgh_local_port; |
758 | OutP->RetCode = S_socket_create_address(server, In0P->sockaddr_type, (In0P->sockaddrType.msgtl_header.msgt_inline) ? In0P->sockaddr : *((char **)In0P->sockaddr), In0P->sockaddrType.msgtl_number, &OutP->addr, &addrPoly); |
759 | if (OutP->RetCode == KERN_SUCCESS0) |
760 | if (!In0P->sockaddrType.msgtl_header.msgt_inline) |
761 | __mig_deallocate(* (vm_offset_t *) In0P->sockaddr, In0P->sockaddrType.msgtl_number); |
762 | if (OutP->RetCode != KERN_SUCCESS0) |
763 | return; |
764 | |
765 | msgh_simple = TRUE((boolean_t) 1); |
766 | OutP->Head.msgh_size = 40; |
767 | |
768 | OutP->addrType = addrType; |
769 | |
770 | if (MACH_MSG_TYPE_PORT_ANY(addrPoly)(((addrPoly) >= 16) && ((addrPoly) <= 21))) |
771 | msgh_simple = FALSE((boolean_t) 0); |
772 | |
773 | OutP->addrType.msgt_name = addrPoly; |
774 | |
775 | if (!msgh_simple) |
776 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
777 | } |
778 | |
779 | /* Default implementation of S_socket_create_address */ |
780 | #ifdef MIG_EOPNOTSUPP |
781 | kern_return_t __attribute__ ((weak)) |
782 | S_socket_create_address |
783 | ( |
784 | mach_port_t server, |
785 | int sockaddr_type, |
786 | data_t sockaddr, |
787 | mach_msg_type_number_t sockaddrCnt, |
788 | mach_port_t *addr, |
789 | mach_msg_type_name_t *addrPoly |
790 | ) { return MIG_EOPNOTSUPP; } |
791 | #endif /* MIG_EOPNOTSUPP */ |
792 | |
793 | /* Routine socket_fabricate_address */ |
794 | mig_internalstatic void _Xsocket_fabricate_address |
795 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
796 | { |
797 | typedef struct { |
798 | mach_msg_header_t Head; |
799 | mach_msg_type_t sockaddr_typeType; |
800 | int sockaddr_type; |
801 | } Request; |
802 | |
803 | typedef struct { |
804 | mach_msg_header_t Head; |
805 | mach_msg_type_t RetCodeType; |
806 | kern_return_t RetCode; |
807 | mach_msg_type_t addrType; |
808 | mach_port_t addr; |
809 | } Reply; |
810 | |
811 | Request *In0P = (Request *) InHeadP; |
812 | Reply *OutP = (Reply *) OutHeadP; |
813 | mig_external kern_return_t S_socket_fabricate_address |
814 | (mach_port_t server, int sockaddr_type, mach_port_t *addr, mach_msg_type_name_t *addrPoly); |
815 | |
816 | boolean_t msgh_simple = msgh_simple; |
817 | const mach_msg_type_t sockaddr_typeCheck = { |
818 | /* msgt_name = */ 2, |
819 | /* msgt_size = */ 32, |
820 | /* msgt_number = */ 1, |
821 | /* msgt_inline = */ TRUE((boolean_t) 1), |
822 | /* msgt_longform = */ FALSE((boolean_t) 0), |
823 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
824 | /* msgt_unused = */ 0 |
825 | }; |
826 | |
827 | const mach_msg_type_t addrType = { |
828 | /* msgt_name = */ -1, |
829 | /* msgt_size = */ 32, |
830 | /* msgt_number = */ 1, |
831 | /* msgt_inline = */ TRUE((boolean_t) 1), |
832 | /* msgt_longform = */ FALSE((boolean_t) 0), |
833 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
834 | /* msgt_unused = */ 0 |
835 | }; |
836 | |
837 | mach_port_t server; |
838 | mach_msg_type_name_t addrPoly; |
839 | |
840 | #if TypeCheck1 |
841 | if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
842 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
843 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
844 | #endif /* TypeCheck */ |
845 | |
846 | #if TypeCheck1 |
847 | if (BAD_TYPECHECK(&In0P->sockaddr_typeType, &sockaddr_typeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->sockaddr_typeType); _c.t = *(&sockaddr_typeCheck);_t.w != _c.w; })), 0)) |
848 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
849 | #endif /* TypeCheck */ |
850 | |
851 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
852 | server = ports_payload_get_name(In0P->Head.msgh_protected_payload); |
853 | else |
854 | server = In0P->Head.msgh_request_portmsgh_local_port; |
855 | OutP->RetCode = S_socket_fabricate_address(server, In0P->sockaddr_type, &OutP->addr, &addrPoly); |
856 | if (OutP->RetCode != KERN_SUCCESS0) |
857 | return; |
858 | |
859 | msgh_simple = TRUE((boolean_t) 1); |
860 | OutP->Head.msgh_size = 40; |
861 | |
862 | OutP->addrType = addrType; |
863 | |
864 | if (MACH_MSG_TYPE_PORT_ANY(addrPoly)(((addrPoly) >= 16) && ((addrPoly) <= 21))) |
865 | msgh_simple = FALSE((boolean_t) 0); |
866 | |
867 | OutP->addrType.msgt_name = addrPoly; |
868 | |
869 | if (!msgh_simple) |
870 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
871 | } |
872 | |
873 | /* Default implementation of S_socket_fabricate_address */ |
874 | #ifdef MIG_EOPNOTSUPP |
875 | kern_return_t __attribute__ ((weak)) |
876 | S_socket_fabricate_address |
877 | ( |
878 | mach_port_t server, |
879 | int sockaddr_type, |
880 | mach_port_t *addr, |
881 | mach_msg_type_name_t *addrPoly |
882 | ) { return MIG_EOPNOTSUPP; } |
883 | #endif /* MIG_EOPNOTSUPP */ |
884 | |
885 | /* Routine socket_whatis_address */ |
886 | mig_internalstatic void _Xsocket_whatis_address |
887 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
888 | { |
889 | typedef struct { |
890 | mach_msg_header_t Head; |
891 | } Request; |
892 | |
893 | typedef struct { |
894 | mach_msg_header_t Head; |
895 | mach_msg_type_t RetCodeType; |
896 | kern_return_t RetCode; |
897 | mach_msg_type_t sockaddr_typeType; |
898 | int sockaddr_type; |
899 | mach_msg_type_long_t sockaddrType; |
900 | char sockaddr[2048]; |
901 | } Reply; |
902 | |
903 | Request *In0P = (Request *) InHeadP; |
904 | Reply *OutP = (Reply *) OutHeadP; |
905 | mig_external kern_return_t S_socket_whatis_address |
906 | (addr_t addr, int *sockaddr_type, data_t *sockaddr, mach_msg_type_number_t *sockaddrCnt); |
907 | |
908 | boolean_t msgh_simple = msgh_simple; |
909 | const mach_msg_type_t sockaddr_typeType = { |
910 | /* msgt_name = */ 2, |
911 | /* msgt_size = */ 32, |
912 | /* msgt_number = */ 1, |
913 | /* msgt_inline = */ TRUE((boolean_t) 1), |
914 | /* msgt_longform = */ FALSE((boolean_t) 0), |
915 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
916 | /* msgt_unused = */ 0 |
917 | }; |
918 | |
919 | const mach_msg_type_long_t sockaddrType = { |
920 | { |
921 | /* msgt_name = */ 0, |
922 | /* msgt_size = */ 0, |
923 | /* msgt_number = */ 0, |
924 | /* msgt_inline = */ TRUE((boolean_t) 1), |
925 | /* msgt_longform = */ TRUE((boolean_t) 1), |
926 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
927 | /* msgt_unused = */ 0 |
928 | }, |
929 | /* msgtl_name = */ 8, |
930 | /* msgtl_size = */ 8, |
931 | /* msgtl_number = */ 2048, |
932 | }; |
933 | |
934 | addr_t addr; |
935 | mach_msg_type_number_t sockaddrCnt; |
936 | |
937 | char *sockaddrP; |
938 | |
939 | #if TypeCheck1 |
940 | if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
941 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
942 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
943 | #endif /* TypeCheck */ |
944 | |
945 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
946 | addr = begin_using_addr_payload(In0P->Head.msgh_protected_payload); |
947 | else |
948 | addr = begin_using_addr_port(In0P->Head.msgh_request_portmsgh_local_port); |
949 | |
950 | sockaddrP = OutP->sockaddr; |
951 | sockaddrCnt = 2048; |
952 | |
953 | OutP->RetCode = S_socket_whatis_address(addr, &OutP->sockaddr_type, &sockaddrP, &sockaddrCnt); |
954 | end_using_addr_port(addr); |
955 | if (OutP->RetCode != KERN_SUCCESS0) |
956 | return; |
957 | |
958 | msgh_simple = TRUE((boolean_t) 1); |
959 | |
960 | OutP->sockaddr_typeType = sockaddr_typeType; |
961 | |
962 | OutP->sockaddrType = sockaddrType; |
963 | if (sockaddrP != OutP->sockaddr) { |
964 | OutP->sockaddrType.msgtl_header.msgt_inline = FALSE((boolean_t) 0); |
965 | OutP->sockaddrType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1); |
966 | *((char **)OutP->sockaddr) = sockaddrP; |
967 | msgh_simple = FALSE((boolean_t) 0); |
968 | } |
969 | |
970 | OutP->sockaddrType.msgtl_number = sockaddrCnt; |
971 | OutP->Head.msgh_size = 52 + ((OutP->sockaddrType.msgtl_header.msgt_inline) ? (sockaddrCnt + 3) & ~3 : sizeof(char *)); |
972 | |
973 | if (!msgh_simple) |
974 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
975 | } |
976 | |
977 | /* Default implementation of S_socket_whatis_address */ |
978 | #ifdef MIG_EOPNOTSUPP |
979 | kern_return_t __attribute__ ((weak)) |
980 | S_socket_whatis_address |
981 | ( |
982 | addr_t addr, |
983 | int *sockaddr_type, |
984 | data_t *sockaddr, |
985 | mach_msg_type_number_t *sockaddrCnt |
986 | ) { return MIG_EOPNOTSUPP; } |
987 | #endif /* MIG_EOPNOTSUPP */ |
988 | |
989 | /* Routine socket_shutdown */ |
990 | mig_internalstatic void _Xsocket_shutdown |
991 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
992 | { |
993 | typedef struct { |
994 | mach_msg_header_t Head; |
995 | mach_msg_type_t directionType; |
996 | int direction; |
997 | } Request; |
998 | |
999 | typedef struct { |
1000 | mach_msg_header_t Head; |
1001 | mach_msg_type_t RetCodeType; |
1002 | kern_return_t RetCode; |
1003 | } Reply; |
1004 | |
1005 | Request *In0P = (Request *) InHeadP; |
1006 | Reply *OutP = (Reply *) OutHeadP; |
1007 | mig_external kern_return_t S_socket_shutdown |
1008 | (sock_user_t sock, int direction); |
1009 | |
1010 | const mach_msg_type_t directionCheck = { |
1011 | /* msgt_name = */ 2, |
1012 | /* msgt_size = */ 32, |
1013 | /* msgt_number = */ 1, |
1014 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1015 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1016 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1017 | /* msgt_unused = */ 0 |
1018 | }; |
1019 | |
1020 | sock_user_t sock; |
1021 | |
1022 | #if TypeCheck1 |
1023 | if (mig_unlikely ((In0P->Head.msgh_size != 32) ||__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
1024 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 32) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
1025 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1026 | #endif /* TypeCheck */ |
1027 | |
1028 | #if TypeCheck1 |
1029 | if (BAD_TYPECHECK(&In0P->directionType, &directionCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->directionType); _c.t = * (&directionCheck);_t.w != _c.w; })), 0)) |
1030 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1031 | #endif /* TypeCheck */ |
1032 | |
1033 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
1034 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
1035 | else |
1036 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
1037 | |
1038 | OutP->RetCode = S_socket_shutdown(sock, In0P->direction); |
1039 | end_using_sock_user_port(sock); |
1040 | } |
1041 | |
1042 | /* Default implementation of S_socket_shutdown */ |
1043 | #ifdef MIG_EOPNOTSUPP |
1044 | kern_return_t __attribute__ ((weak)) |
1045 | S_socket_shutdown |
1046 | ( |
1047 | sock_user_t sock, |
1048 | int direction |
1049 | ) { return MIG_EOPNOTSUPP; } |
1050 | #endif /* MIG_EOPNOTSUPP */ |
1051 | |
1052 | /* Routine socket_getopt */ |
1053 | mig_internalstatic void _Xsocket_getopt |
1054 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
1055 | { |
1056 | typedef struct { |
1057 | mach_msg_header_t Head; |
1058 | mach_msg_type_t levelType; |
1059 | int level; |
1060 | mach_msg_type_t optionType; |
1061 | int option; |
1062 | } Request; |
1063 | |
1064 | typedef struct { |
1065 | mach_msg_header_t Head; |
1066 | mach_msg_type_t RetCodeType; |
1067 | kern_return_t RetCode; |
1068 | mach_msg_type_long_t optvalType; |
1069 | char optval[2048]; |
1070 | } Reply; |
1071 | |
1072 | Request *In0P = (Request *) InHeadP; |
1073 | Reply *OutP = (Reply *) OutHeadP; |
1074 | mig_external kern_return_t S_socket_getopt |
1075 | (sock_user_t sock, int level, int option, data_t *optval, mach_msg_type_number_t *optvalCnt); |
1076 | |
1077 | boolean_t msgh_simple = msgh_simple; |
1078 | const mach_msg_type_t levelCheck = { |
1079 | /* msgt_name = */ 2, |
1080 | /* msgt_size = */ 32, |
1081 | /* msgt_number = */ 1, |
1082 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1083 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1084 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1085 | /* msgt_unused = */ 0 |
1086 | }; |
1087 | |
1088 | const mach_msg_type_t optionCheck = { |
1089 | /* msgt_name = */ 2, |
1090 | /* msgt_size = */ 32, |
1091 | /* msgt_number = */ 1, |
1092 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1093 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1094 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1095 | /* msgt_unused = */ 0 |
1096 | }; |
1097 | |
1098 | const mach_msg_type_long_t optvalType = { |
1099 | { |
1100 | /* msgt_name = */ 0, |
1101 | /* msgt_size = */ 0, |
1102 | /* msgt_number = */ 0, |
1103 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1104 | /* msgt_longform = */ TRUE((boolean_t) 1), |
1105 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1106 | /* msgt_unused = */ 0 |
1107 | }, |
1108 | /* msgtl_name = */ 8, |
1109 | /* msgtl_size = */ 8, |
1110 | /* msgtl_number = */ 2048, |
1111 | }; |
1112 | |
1113 | sock_user_t sock; |
1114 | mach_msg_type_number_t optvalCnt; |
1115 | |
1116 | char *optvalP; |
1117 | |
1118 | #if TypeCheck1 |
1119 | if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
1120 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
1121 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1122 | #endif /* TypeCheck */ |
1123 | |
1124 | #if TypeCheck1 |
1125 | if (BAD_TYPECHECK(&In0P->levelType, &levelCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->levelType); _c.t = *(& levelCheck);_t.w != _c.w; })), 0)) |
1126 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1127 | #endif /* TypeCheck */ |
1128 | |
1129 | #if TypeCheck1 |
1130 | if (BAD_TYPECHECK(&In0P->optionType, &optionCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->optionType); _c.t = *(& optionCheck);_t.w != _c.w; })), 0)) |
1131 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1132 | #endif /* TypeCheck */ |
1133 | |
1134 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
1135 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
1136 | else |
1137 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
1138 | |
1139 | optvalP = OutP->optval; |
1140 | optvalCnt = 2048; |
1141 | |
1142 | OutP->RetCode = S_socket_getopt(sock, In0P->level, In0P->option, &optvalP, &optvalCnt); |
1143 | end_using_sock_user_port(sock); |
1144 | if (OutP->RetCode != KERN_SUCCESS0) |
1145 | return; |
1146 | |
1147 | msgh_simple = TRUE((boolean_t) 1); |
1148 | |
1149 | OutP->optvalType = optvalType; |
1150 | if (optvalP != OutP->optval) { |
1151 | OutP->optvalType.msgtl_header.msgt_inline = FALSE((boolean_t) 0); |
1152 | OutP->optvalType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1); |
1153 | *((char **)OutP->optval) = optvalP; |
1154 | msgh_simple = FALSE((boolean_t) 0); |
1155 | } |
1156 | |
1157 | OutP->optvalType.msgtl_number = optvalCnt; |
1158 | OutP->Head.msgh_size = 44 + ((OutP->optvalType.msgtl_header.msgt_inline) ? (optvalCnt + 3) & ~3 : sizeof(char *)); |
1159 | |
1160 | if (!msgh_simple) |
1161 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
1162 | } |
1163 | |
1164 | /* Default implementation of S_socket_getopt */ |
1165 | #ifdef MIG_EOPNOTSUPP |
1166 | kern_return_t __attribute__ ((weak)) |
1167 | S_socket_getopt |
1168 | ( |
1169 | sock_user_t sock, |
1170 | int level, |
1171 | int option, |
1172 | data_t *optval, |
1173 | mach_msg_type_number_t *optvalCnt |
1174 | ) { return MIG_EOPNOTSUPP; } |
1175 | #endif /* MIG_EOPNOTSUPP */ |
1176 | |
1177 | /* Routine socket_setopt */ |
1178 | mig_internalstatic void _Xsocket_setopt |
1179 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
1180 | { |
1181 | typedef struct { |
1182 | mach_msg_header_t Head; |
1183 | mach_msg_type_t levelType; |
1184 | int level; |
1185 | mach_msg_type_t optionType; |
1186 | int option; |
1187 | mach_msg_type_long_t optvalType; |
1188 | char optval[2048]; |
1189 | } Request; |
1190 | |
1191 | typedef struct { |
1192 | mach_msg_header_t Head; |
1193 | mach_msg_type_t RetCodeType; |
1194 | kern_return_t RetCode; |
1195 | } Reply; |
1196 | |
1197 | Request *In0P = (Request *) InHeadP; |
1198 | Reply *OutP = (Reply *) OutHeadP; |
1199 | mig_external kern_return_t S_socket_setopt |
1200 | (sock_user_t sock, int level, int option, data_t optval, mach_msg_type_number_t optvalCnt); |
1201 | |
1202 | #if TypeCheck1 |
1203 | boolean_t msgh_simple = msgh_simple; |
1204 | #endif /* TypeCheck */ |
1205 | |
1206 | unsigned int msgh_size; |
1207 | |
1208 | const mach_msg_type_t levelCheck = { |
1209 | /* msgt_name = */ 2, |
1210 | /* msgt_size = */ 32, |
1211 | /* msgt_number = */ 1, |
1212 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1213 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1214 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1215 | /* msgt_unused = */ 0 |
1216 | }; |
1217 | |
1218 | const mach_msg_type_t optionCheck = { |
1219 | /* msgt_name = */ 2, |
1220 | /* msgt_size = */ 32, |
1221 | /* msgt_number = */ 1, |
1222 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1223 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1224 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1225 | /* msgt_unused = */ 0 |
1226 | }; |
1227 | |
1228 | sock_user_t sock; |
1229 | |
1230 | #if TypeCheck1 |
1231 | msgh_size = In0P->Head.msgh_size; |
1232 | msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U); |
1233 | if (mig_unlikely ((msgh_size < 52))__builtin_expect (!! ((msgh_size < 52)), 0)) |
1234 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1235 | #endif /* TypeCheck */ |
1236 | |
1237 | #if TypeCheck1 |
1238 | if (BAD_TYPECHECK(&In0P->levelType, &levelCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->levelType); _c.t = *(& levelCheck);_t.w != _c.w; })), 0)) |
1239 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1240 | #endif /* TypeCheck */ |
1241 | |
1242 | #if TypeCheck1 |
1243 | if (BAD_TYPECHECK(&In0P->optionType, &optionCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->optionType); _c.t = *(& optionCheck);_t.w != _c.w; })), 0)) |
1244 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1245 | #endif /* TypeCheck */ |
1246 | |
1247 | #if TypeCheck1 |
1248 | if (mig_unlikely ((In0P->optvalType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In0P->optvalType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->optvalType.msgtl_name != 8) || (In0P->optvalType.msgtl_size != 8)), 0) |
1249 | (In0P->optvalType.msgtl_name != 8) ||__builtin_expect (!! ((In0P->optvalType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->optvalType.msgtl_name != 8) || (In0P->optvalType.msgtl_size != 8)), 0) |
1250 | (In0P->optvalType.msgtl_size != 8))__builtin_expect (!! ((In0P->optvalType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->optvalType.msgtl_name != 8) || (In0P->optvalType.msgtl_size != 8)), 0)) |
1251 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1252 | #endif /* TypeCheck */ |
1253 | |
1254 | #if TypeCheck1 |
1255 | if (mig_unlikely (msgh_size != 52 + ((In0P->optvalType.msgtl_header.msgt_inline) ? (In0P->optvalType.msgtl_number + 3) & ~3 : sizeof(char *)))__builtin_expect (!! (msgh_size != 52 + ((In0P->optvalType .msgtl_header.msgt_inline) ? (In0P->optvalType.msgtl_number + 3) & ~3 : sizeof(char *))), 0)) |
1256 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1257 | #endif /* TypeCheck */ |
1258 | |
1259 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
1260 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
1261 | else |
1262 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
1263 | |
1264 | OutP->RetCode = S_socket_setopt(sock, In0P->level, In0P->option, (In0P->optvalType.msgtl_header.msgt_inline) ? In0P->optval : *((char **)In0P->optval), In0P->optvalType.msgtl_number); |
1265 | if (OutP->RetCode == KERN_SUCCESS0) |
1266 | if (!In0P->optvalType.msgtl_header.msgt_inline) |
1267 | __mig_deallocate(* (vm_offset_t *) In0P->optval, In0P->optvalType.msgtl_number); |
1268 | end_using_sock_user_port(sock); |
1269 | } |
1270 | |
1271 | /* Default implementation of S_socket_setopt */ |
1272 | #ifdef MIG_EOPNOTSUPP |
1273 | kern_return_t __attribute__ ((weak)) |
1274 | S_socket_setopt |
1275 | ( |
1276 | sock_user_t sock, |
1277 | int level, |
1278 | int option, |
1279 | data_t optval, |
1280 | mach_msg_type_number_t optvalCnt |
1281 | ) { return MIG_EOPNOTSUPP; } |
1282 | #endif /* MIG_EOPNOTSUPP */ |
1283 | |
1284 | /* Routine socket_send */ |
1285 | mig_internalstatic void _Xsocket_send |
1286 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
1287 | { |
1288 | typedef struct { |
1289 | mach_msg_header_t Head; |
1290 | mach_msg_type_t addrType; |
1291 | addr_port_t addr; |
1292 | mach_msg_type_t flagsType; |
1293 | int flags; |
1294 | mach_msg_type_long_t dataType; |
1295 | char data[2048]; |
1296 | mach_msg_type_long_t portsType; |
1297 | mach_port_t ports[512]; |
1298 | mach_msg_type_long_t controlType; |
1299 | char control[2048]; |
1300 | } Request; |
1301 | |
1302 | typedef struct { |
1303 | mach_msg_header_t Head; |
1304 | mach_msg_type_t RetCodeType; |
1305 | kern_return_t RetCode; |
1306 | mach_msg_type_t amountType; |
1307 | vm_size_t amount; |
1308 | } Reply; |
1309 | |
1310 | Request *In0P = (Request *) InHeadP; |
1311 | Request *In1P; |
1312 | Request *In2P; |
1313 | Reply *OutP = (Reply *) OutHeadP; |
1314 | mig_external kern_return_t S_socket_send |
1315 | (sock_user_t sock, addr_t addr, int flags, data_t data, mach_msg_type_number_t dataCnt, portarray_t ports, mach_msg_type_number_t portsCnt, data_t control, mach_msg_type_number_t controlCnt, vm_size_t *amount); |
1316 | |
1317 | unsigned int msgh_size; |
1318 | unsigned int msgh_size_delta; |
1319 | |
1320 | const mach_msg_type_t addrCheck = { |
1321 | /* msgt_name = */ 17, |
1322 | /* msgt_size = */ 32, |
1323 | /* msgt_number = */ 1, |
1324 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1325 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1326 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1327 | /* msgt_unused = */ 0 |
1328 | }; |
1329 | |
1330 | const mach_msg_type_t flagsCheck = { |
1331 | /* msgt_name = */ 2, |
1332 | /* msgt_size = */ 32, |
1333 | /* msgt_number = */ 1, |
1334 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1335 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1336 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1337 | /* msgt_unused = */ 0 |
1338 | }; |
1339 | |
1340 | const mach_msg_type_t amountType = { |
1341 | /* msgt_name = */ 2, |
1342 | /* msgt_size = */ 32, |
1343 | /* msgt_number = */ 1, |
1344 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1345 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1346 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1347 | /* msgt_unused = */ 0 |
1348 | }; |
1349 | |
1350 | sock_user_t sock; |
1351 | addr_t addr; |
1352 | |
1353 | #if TypeCheck1 |
1354 | msgh_size = In0P->Head.msgh_size; |
1355 | if (mig_unlikely ((msgh_size < 76) ||__builtin_expect (!! ((msgh_size < 76) || !(In0P->Head. msgh_bits & 0x80000000U)), 0) |
1356 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((msgh_size < 76) || !(In0P->Head. msgh_bits & 0x80000000U)), 0)) |
1357 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1358 | #endif /* TypeCheck */ |
1359 | |
1360 | #if TypeCheck1 |
1361 | if (BAD_TYPECHECK(&In0P->addrType, &addrCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->addrType); _c.t = *(& addrCheck);_t.w != _c.w; })), 0)) |
1362 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1363 | #endif /* TypeCheck */ |
1364 | |
1365 | #if TypeCheck1 |
1366 | if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->flagsType); _c.t = *(& flagsCheck);_t.w != _c.w; })), 0)) |
1367 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1368 | #endif /* TypeCheck */ |
1369 | |
1370 | #if TypeCheck1 |
1371 | if (mig_unlikely ((In0P->dataType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 8) || (In0P->dataType.msgtl_size != 8)), 0) |
1372 | (In0P->dataType.msgtl_name != 8) ||__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 8) || (In0P->dataType.msgtl_size != 8)), 0) |
1373 | (In0P->dataType.msgtl_size != 8))__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 8) || (In0P->dataType.msgtl_size != 8)), 0)) |
1374 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1375 | #endif /* TypeCheck */ |
1376 | |
1377 | msgh_size_delta = (In0P->dataType.msgtl_header.msgt_inline) ? (In0P->dataType.msgtl_number + 3) & ~3 : sizeof(char *); |
1378 | #if TypeCheck1 |
1379 | if (mig_unlikely (msgh_size < 76 + msgh_size_delta)__builtin_expect (!! (msgh_size < 76 + msgh_size_delta), 0 )) |
1380 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1381 | msgh_size -= msgh_size_delta; |
1382 | #endif /* TypeCheck */ |
1383 | |
1384 | In1P = (Request *) ((char *) In0P + msgh_size_delta - 2048); |
1385 | |
1386 | #if TypeCheck1 |
1387 | if (mig_unlikely ((In1P->portsType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In1P->portsType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In1P->portsType.msgtl_name != 17) || (In1P->portsType.msgtl_size != 32)), 0) |
1388 | (In1P->portsType.msgtl_name != 17) ||__builtin_expect (!! ((In1P->portsType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In1P->portsType.msgtl_name != 17) || (In1P->portsType.msgtl_size != 32)), 0) |
1389 | (In1P->portsType.msgtl_size != 32))__builtin_expect (!! ((In1P->portsType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In1P->portsType.msgtl_name != 17) || (In1P->portsType.msgtl_size != 32)), 0)) |
1390 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1391 | #endif /* TypeCheck */ |
1392 | |
1393 | msgh_size_delta = (In1P->portsType.msgtl_header.msgt_inline) ? 4 * In1P->portsType.msgtl_number : sizeof(mach_port_t *); |
1394 | #if TypeCheck1 |
1395 | if (mig_unlikely (msgh_size < 76 + msgh_size_delta)__builtin_expect (!! (msgh_size < 76 + msgh_size_delta), 0 )) |
1396 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1397 | msgh_size -= msgh_size_delta; |
1398 | #endif /* TypeCheck */ |
1399 | |
1400 | In2P = (Request *) ((char *) In1P + msgh_size_delta - 2048); |
1401 | |
1402 | #if TypeCheck1 |
1403 | if (mig_unlikely ((In2P->controlType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In2P->controlType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In2P->controlType.msgtl_name != 8 ) || (In2P->controlType.msgtl_size != 8)), 0) |
1404 | (In2P->controlType.msgtl_name != 8) ||__builtin_expect (!! ((In2P->controlType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In2P->controlType.msgtl_name != 8 ) || (In2P->controlType.msgtl_size != 8)), 0) |
1405 | (In2P->controlType.msgtl_size != 8))__builtin_expect (!! ((In2P->controlType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In2P->controlType.msgtl_name != 8 ) || (In2P->controlType.msgtl_size != 8)), 0)) |
1406 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1407 | #endif /* TypeCheck */ |
1408 | |
1409 | #if TypeCheck1 |
1410 | if (mig_unlikely (msgh_size != 76 + ((In2P->controlType.msgtl_header.msgt_inline) ? (In2P->controlType.msgtl_number + 3) & ~3 : sizeof(char *)))__builtin_expect (!! (msgh_size != 76 + ((In2P->controlType .msgtl_header.msgt_inline) ? (In2P->controlType.msgtl_number + 3) & ~3 : sizeof(char *))), 0)) |
1411 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1412 | #endif /* TypeCheck */ |
1413 | |
1414 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
1415 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
1416 | else |
1417 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
1418 | |
1419 | addr = begin_using_addr_port(In0P->addr); |
1420 | |
1421 | OutP->RetCode = S_socket_send(sock, addr, In0P->flags, (In0P->dataType.msgtl_header.msgt_inline) ? In0P->data : *((char **)In0P->data), In0P->dataType.msgtl_number, (In1P->portsType.msgtl_header.msgt_inline) ? In1P->ports : *((mach_port_t **)In1P->ports), In1P->portsType.msgtl_number, (In2P->controlType.msgtl_header.msgt_inline) ? In2P->control : *((char **)In2P->control), In2P->controlType.msgtl_number, &OutP->amount); |
1422 | if (OutP->RetCode == KERN_SUCCESS0) |
1423 | if (!In2P->controlType.msgtl_header.msgt_inline) |
1424 | __mig_deallocate(* (vm_offset_t *) In2P->control, In2P->controlType.msgtl_number); |
1425 | if (OutP->RetCode == KERN_SUCCESS0) |
1426 | if (!In1P->portsType.msgtl_header.msgt_inline) |
1427 | __mig_deallocate(* (vm_offset_t *) In1P->ports, 4 * In1P->portsType.msgtl_number); |
1428 | if (OutP->RetCode == KERN_SUCCESS0) |
1429 | if (!In0P->dataType.msgtl_header.msgt_inline) |
1430 | __mig_deallocate(* (vm_offset_t *) In0P->data, In0P->dataType.msgtl_number); |
1431 | end_using_addr_port(addr); |
1432 | end_using_sock_user_port(sock); |
1433 | if (OutP->RetCode != KERN_SUCCESS0) |
1434 | return; |
1435 | |
1436 | OutP->Head.msgh_size = 40; |
1437 | |
1438 | OutP->amountType = amountType; |
1439 | } |
1440 | |
1441 | /* Default implementation of S_socket_send */ |
1442 | #ifdef MIG_EOPNOTSUPP |
1443 | kern_return_t __attribute__ ((weak)) |
1444 | S_socket_send |
1445 | ( |
1446 | sock_user_t sock, |
1447 | addr_t addr, |
1448 | int flags, |
1449 | data_t data, |
1450 | mach_msg_type_number_t dataCnt, |
1451 | portarray_t ports, |
1452 | mach_msg_type_number_t portsCnt, |
1453 | data_t control, |
1454 | mach_msg_type_number_t controlCnt, |
1455 | vm_size_t *amount |
1456 | ) { return MIG_EOPNOTSUPP; } |
1457 | #endif /* MIG_EOPNOTSUPP */ |
1458 | |
1459 | /* Routine socket_recv */ |
1460 | mig_internalstatic void _Xsocket_recv |
1461 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
1462 | { |
1463 | typedef struct { |
1464 | mach_msg_header_t Head; |
1465 | mach_msg_type_t flagsType; |
1466 | int flags; |
1467 | mach_msg_type_t amountType; |
1468 | vm_size_t amount; |
1469 | } Request; |
1470 | |
1471 | typedef struct { |
1472 | mach_msg_header_t Head; |
1473 | mach_msg_type_t RetCodeType; |
1474 | kern_return_t RetCode; |
1475 | mach_msg_type_t addrType; |
1476 | mach_port_t addr; |
1477 | mach_msg_type_long_t dataType; |
1478 | char data[2048]; |
1479 | mach_msg_type_long_t portsType; |
1480 | mach_port_t ports[512]; |
1481 | mach_msg_type_long_t controlType; |
1482 | char control[2048]; |
1483 | mach_msg_type_t outflagsType; |
1484 | int outflags; |
1485 | } Reply; |
1486 | |
1487 | Request *In0P = (Request *) InHeadP; |
1488 | Reply *OutP = (Reply *) OutHeadP; |
1489 | mig_external kern_return_t S_socket_recv |
1490 | (sock_user_t sock, mach_port_t *addr, mach_msg_type_name_t *addrPoly, int flags, data_t *data, mach_msg_type_number_t *dataCnt, portarray_t *ports, mach_msg_type_name_t *portsPoly, mach_msg_type_number_t *portsCnt, data_t *control, mach_msg_type_number_t *controlCnt, int *outflags, vm_size_t amount); |
1491 | |
1492 | boolean_t msgh_simple = msgh_simple; |
1493 | unsigned int msgh_size; |
1494 | unsigned int msgh_size_delta; |
1495 | |
1496 | const mach_msg_type_t flagsCheck = { |
1497 | /* msgt_name = */ 2, |
1498 | /* msgt_size = */ 32, |
1499 | /* msgt_number = */ 1, |
1500 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1501 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1502 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1503 | /* msgt_unused = */ 0 |
1504 | }; |
1505 | |
1506 | const mach_msg_type_t amountCheck = { |
1507 | /* msgt_name = */ 2, |
1508 | /* msgt_size = */ 32, |
1509 | /* msgt_number = */ 1, |
1510 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1511 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1512 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1513 | /* msgt_unused = */ 0 |
1514 | }; |
1515 | |
1516 | const mach_msg_type_t addrType = { |
1517 | /* msgt_name = */ -1, |
1518 | /* msgt_size = */ 32, |
1519 | /* msgt_number = */ 1, |
1520 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1521 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1522 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1523 | /* msgt_unused = */ 0 |
1524 | }; |
1525 | |
1526 | const mach_msg_type_long_t dataType = { |
1527 | { |
1528 | /* msgt_name = */ 0, |
1529 | /* msgt_size = */ 0, |
1530 | /* msgt_number = */ 0, |
1531 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1532 | /* msgt_longform = */ TRUE((boolean_t) 1), |
1533 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1534 | /* msgt_unused = */ 0 |
1535 | }, |
1536 | /* msgtl_name = */ 8, |
1537 | /* msgtl_size = */ 8, |
1538 | /* msgtl_number = */ 2048, |
1539 | }; |
1540 | |
1541 | const mach_msg_type_long_t portsType = { |
1542 | { |
1543 | /* msgt_name = */ 0, |
1544 | /* msgt_size = */ 0, |
1545 | /* msgt_number = */ 0, |
1546 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1547 | /* msgt_longform = */ TRUE((boolean_t) 1), |
1548 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1549 | /* msgt_unused = */ 0 |
1550 | }, |
1551 | /* msgtl_name = */ -1, |
1552 | /* msgtl_size = */ 32, |
1553 | /* msgtl_number = */ 512, |
1554 | }; |
1555 | |
1556 | const mach_msg_type_long_t controlType = { |
1557 | { |
1558 | /* msgt_name = */ 0, |
1559 | /* msgt_size = */ 0, |
1560 | /* msgt_number = */ 0, |
1561 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1562 | /* msgt_longform = */ TRUE((boolean_t) 1), |
1563 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1564 | /* msgt_unused = */ 0 |
1565 | }, |
1566 | /* msgtl_name = */ 8, |
1567 | /* msgtl_size = */ 8, |
1568 | /* msgtl_number = */ 2048, |
1569 | }; |
1570 | |
1571 | const mach_msg_type_t outflagsType = { |
1572 | /* msgt_name = */ 2, |
1573 | /* msgt_size = */ 32, |
1574 | /* msgt_number = */ 1, |
1575 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1576 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1577 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1578 | /* msgt_unused = */ 0 |
1579 | }; |
1580 | |
1581 | sock_user_t sock; |
1582 | mach_msg_type_name_t addrPoly; |
1583 | mach_msg_type_number_t dataCnt; |
1584 | mach_port_t ports[512]; |
1585 | mach_msg_type_name_t portsPoly; |
1586 | mach_msg_type_number_t portsCnt; |
1587 | char control[2048]; |
1588 | mach_msg_type_number_t controlCnt; |
1589 | int outflags; |
1590 | |
1591 | char *dataP; |
1592 | mach_port_t *portsP; |
1593 | char *controlP; |
1594 | |
1595 | #if TypeCheck1 |
1596 | if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
1597 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
1598 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1599 | #endif /* TypeCheck */ |
1600 | |
1601 | #if TypeCheck1 |
1602 | if (BAD_TYPECHECK(&In0P->flagsType, &flagsCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->flagsType); _c.t = *(& flagsCheck);_t.w != _c.w; })), 0)) |
1603 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1604 | #endif /* TypeCheck */ |
1605 | |
1606 | #if TypeCheck1 |
1607 | if (BAD_TYPECHECK(&In0P->amountType, &amountCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->amountType); _c.t = *(& amountCheck);_t.w != _c.w; })), 0)) |
1608 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1609 | #endif /* TypeCheck */ |
1610 | |
1611 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
1612 | sock = begin_using_sock_user_payload(In0P->Head.msgh_protected_payload); |
1613 | else |
1614 | sock = begin_using_sock_user_port(In0P->Head.msgh_request_portmsgh_local_port); |
1615 | |
1616 | dataP = OutP->data; |
1617 | dataCnt = 2048; |
1618 | |
1619 | portsP = ports; |
1620 | portsCnt = 512; |
1621 | |
1622 | controlP = control; |
1623 | controlCnt = 2048; |
1624 | |
1625 | OutP->RetCode = S_socket_recv(sock, &OutP->addr, &addrPoly, In0P->flags, &dataP, &dataCnt, &portsP, &portsPoly, &portsCnt, &controlP, &controlCnt, &outflags, In0P->amount); |
1626 | end_using_sock_user_port(sock); |
1627 | if (OutP->RetCode != KERN_SUCCESS0) |
1628 | return; |
1629 | |
1630 | msgh_simple = TRUE((boolean_t) 1); |
1631 | |
1632 | OutP->addrType = addrType; |
1633 | |
1634 | if (MACH_MSG_TYPE_PORT_ANY(addrPoly)(((addrPoly) >= 16) && ((addrPoly) <= 21))) |
1635 | msgh_simple = FALSE((boolean_t) 0); |
1636 | |
1637 | OutP->addrType.msgt_name = addrPoly; |
1638 | |
1639 | OutP->dataType = dataType; |
1640 | if (dataP != OutP->data) { |
1641 | OutP->dataType.msgtl_header.msgt_inline = FALSE((boolean_t) 0); |
1642 | OutP->dataType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1); |
1643 | *((char **)OutP->data) = dataP; |
1644 | msgh_simple = FALSE((boolean_t) 0); |
1645 | } |
1646 | |
1647 | OutP->dataType.msgtl_number = dataCnt; |
1648 | msgh_size_delta = (OutP->dataType.msgtl_header.msgt_inline) ? (dataCnt + 3) & ~3 : sizeof(char *); |
1649 | msgh_size = 84 + msgh_size_delta; |
1650 | OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048); |
1651 | |
1652 | OutP->portsType = portsType; |
1653 | |
1654 | if (portsP != ports) { |
1655 | OutP->portsType.msgtl_header.msgt_inline = FALSE((boolean_t) 0); |
1656 | OutP->portsType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1); |
1657 | *((mach_port_t **)OutP->ports) = portsP; |
1658 | msgh_simple = FALSE((boolean_t) 0); |
1659 | } |
1660 | else { |
1661 | memcpy(OutP->ports, ports, 4 * portsCnt); |
1662 | } |
1663 | |
1664 | if (MACH_MSG_TYPE_PORT_ANY(portsPoly)(((portsPoly) >= 16) && ((portsPoly) <= 21))) |
1665 | msgh_simple = FALSE((boolean_t) 0); |
1666 | |
1667 | OutP->portsType.msgtl_name = portsPoly; |
1668 | |
1669 | OutP->portsType.msgtl_number = portsCnt; |
1670 | msgh_size_delta = (OutP->portsType.msgtl_header.msgt_inline) ? 4 * portsCnt : sizeof(mach_port_t *); |
1671 | msgh_size += msgh_size_delta; |
1672 | OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048); |
1673 | |
1674 | OutP->controlType = controlType; |
1675 | |
1676 | if (controlP != control) { |
1677 | OutP->controlType.msgtl_header.msgt_inline = FALSE((boolean_t) 0); |
1678 | OutP->controlType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1); |
1679 | *((char **)OutP->control) = controlP; |
1680 | msgh_simple = FALSE((boolean_t) 0); |
1681 | } |
1682 | else { |
1683 | memcpy(OutP->control, control, controlCnt); |
1684 | } |
1685 | |
1686 | OutP->controlType.msgtl_number = controlCnt; |
1687 | msgh_size_delta = (OutP->controlType.msgtl_header.msgt_inline) ? (controlCnt + 3) & ~3 : sizeof(char *); |
1688 | msgh_size += msgh_size_delta; |
1689 | OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048); |
1690 | |
1691 | OutP->outflagsType = outflagsType; |
1692 | |
1693 | OutP->outflags = outflags; |
1694 | |
1695 | OutP = (Reply *) OutHeadP; |
1696 | if (!msgh_simple) |
1697 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
1698 | OutP->Head.msgh_size = msgh_size; |
1699 | } |
1700 | |
1701 | /* Default implementation of S_socket_recv */ |
1702 | #ifdef MIG_EOPNOTSUPP |
1703 | kern_return_t __attribute__ ((weak)) |
1704 | S_socket_recv |
1705 | ( |
1706 | sock_user_t sock, |
1707 | mach_port_t *addr, |
1708 | mach_msg_type_name_t *addrPoly, |
1709 | int flags, |
1710 | data_t *data, |
1711 | mach_msg_type_number_t *dataCnt, |
1712 | portarray_t *ports, |
1713 | mach_msg_type_name_t *portsPoly, |
1714 | mach_msg_type_number_t *portsCnt, |
1715 | data_t *control, |
1716 | mach_msg_type_number_t *controlCnt, |
1717 | int *outflags, |
1718 | vm_size_t amount |
1719 | ) { return MIG_EOPNOTSUPP; } |
1720 | #endif /* MIG_EOPNOTSUPP */ |
1721 | |
1722 | mig_routine_t socket_server_routines[] = { |
1723 | _Xsocket_create, |
1724 | _Xsocket_listen, |
1725 | _Xsocket_accept, |
1726 | _Xsocket_connect, |
1727 | _Xsocket_bind, |
1728 | _Xsocket_name, |
1729 | _Xsocket_peername, |
1730 | _Xsocket_connect2, |
1731 | _Xsocket_create_address, |
1732 | _Xsocket_fabricate_address, |
1733 | _Xsocket_whatis_address, |
1734 | _Xsocket_shutdown, |
1735 | _Xsocket_getopt, |
1736 | _Xsocket_setopt, |
1737 | _Xsocket_send, |
1738 | _Xsocket_recv, |
1739 | }; |
1740 | |
1741 | mig_external boolean_t socket_server |
1742 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
1743 | { |
1744 | mach_msg_header_t *InP = InHeadP; |
1745 | mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; |
1746 | |
1747 | const mach_msg_type_t RetCodeType = { |
1748 | /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322, |
1749 | /* msgt_size = */ 32, |
1750 | /* msgt_number = */ 1, |
1751 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1752 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1753 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1754 | /* msgt_unused = */ 0 |
1755 | }; |
1756 | |
1757 | mig_routine_t routine; |
1758 | |
1759 | OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)((((InP->msgh_bits) & 0x000000ff)) | ((0) << 8)); |
1760 | OutP->Head.msgh_size = sizeof *OutP; |
1761 | OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_remote_port; |
1762 | OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0); |
1763 | OutP->Head.msgh_seqno = 0; |
1764 | OutP->Head.msgh_id = InP->msgh_id + 100; |
1765 | |
1766 | OutP->RetCodeType = RetCodeType; |
1767 | |
1768 | if ((InP->msgh_id > 26015) || (InP->msgh_id < 26000) || |
1769 | ((routine = socket_server_routines[InP->msgh_id - 26000]) == 0)) { |
1770 | OutP->RetCode = MIG_BAD_ID-303; |
1771 | return FALSE((boolean_t) 0); |
1772 | } |
1773 | (*routine) (InP, &OutP->Head); |
1774 | return TRUE((boolean_t) 1); |
1775 | } |
1776 | |
1777 | mig_external mig_routine_t socket_server_routine |
1778 | (const mach_msg_header_t *InHeadP) |
1779 | { |
1780 | int msgh_id; |
1781 | |
1782 | msgh_id = InHeadP->msgh_id - 26000; |
1783 | |
1784 | if ((msgh_id > 15) || (msgh_id < 0)) |
1785 | return 0; |
1786 | |
1787 | return socket_server_routines[msgh_id]; |
1788 | } |
1789 |