Bug Summary

File:obj-scan-build/pflocal/socketServer.c
Location:line 612, column 2
Description:Value stored to 'msgh_simple' is never read

Annotated Source Code

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