]> git.saurik.com Git - apple/configd.git/blob - SystemConfiguration.fproj/SCDPrivate.c
ed1e0cb0dcc2b74b657c0f08b67c083366f3fd65
[apple/configd.git] / SystemConfiguration.fproj / SCDPrivate.c
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*
25 * Modification History
26 *
27 * June 1, 2001 Allan Nathanson <ajn@apple.com>
28 * - public API conversion
29 *
30 * November 9, 2000 Allan Nathanson <ajn@apple.com>
31 * - initial revision
32 */
33
34 #include <SystemConfiguration/SystemConfiguration.h>
35 #include <SystemConfiguration/SCValidation.h>
36 #include <SystemConfiguration/SCPrivate.h>
37
38 #include <sys/types.h>
39 #include <sys/socket.h>
40 #include <net/if.h>
41 #include <net/if_dl.h>
42 #include <netinet/in.h>
43 #include <arpa/inet.h>
44
45 #include <mach/mach.h>
46 #include <mach/notify.h>
47 #include <mach/mach_error.h>
48 #include <pthread.h>
49
50 #define N_QUICK 32
51
52
53 char *
54 _SC_cfstring_to_cstring(CFStringRef cfstr, char *buf, int bufLen, CFStringEncoding encoding)
55 {
56 CFIndex last;
57 CFIndex len = CFStringGetLength(cfstr);
58
59 /* how much buffer space will we really need? */
60 (void)CFStringGetBytes(cfstr,
61 CFRangeMake(0, len),
62 encoding,
63 0,
64 FALSE,
65 NULL,
66 0,
67 &len);
68
69 if (buf) {
70 /* check the size of the provided buffer */
71 if (bufLen < (len + 1)) {
72 return NULL; /* if too small */
73 }
74 } else {
75 /* allocate a buffer */
76 bufLen = len + 1;
77 buf = CFAllocatorAllocate(NULL, bufLen, 0);
78 if (!buf) {
79 return NULL;
80 }
81 }
82
83 (void)CFStringGetBytes(cfstr,
84 CFRangeMake(0, len),
85 encoding,
86 0,
87 FALSE,
88 buf,
89 bufLen,
90 &last);
91 buf[last] = '\0';
92
93 return buf;
94 }
95
96
97 void
98 _SC_sockaddr_to_string(const struct sockaddr *address, char *buf, size_t bufLen)
99 {
100 bzero(buf, bufLen);
101 switch (address->sa_family) {
102 case AF_INET :
103 (void)inet_ntop(((struct sockaddr_in *)address)->sin_family,
104 &((struct sockaddr_in *)address)->sin_addr,
105 buf,
106 bufLen);
107 break;
108 case AF_INET6 : {
109 (void)inet_ntop(((struct sockaddr_in6 *)address)->sin6_family,
110 &((struct sockaddr_in6 *)address)->sin6_addr,
111 buf,
112 bufLen);
113 if (((struct sockaddr_in6 *)address)->sin6_scope_id != 0) {
114 int n;
115
116 n = strlen(buf);
117 if ((n+IF_NAMESIZE+1) <= (int)bufLen) {
118 buf[n++] = '%';
119 if_indextoname(((struct sockaddr_in6 *)address)->sin6_scope_id, &buf[n]);
120 }
121 }
122 break;
123 }
124 case AF_LINK :
125 if (((struct sockaddr_dl *)address)->sdl_len < bufLen) {
126 bufLen = ((struct sockaddr_dl *)address)->sdl_len;
127 } else {
128 bufLen = bufLen - 1;
129 }
130
131 bcopy(((struct sockaddr_dl *)address)->sdl_data, buf, bufLen);
132 break;
133 default :
134 snprintf(buf, bufLen, "unexpected address family %d", address->sa_family);
135 break;
136 }
137
138 return;
139 }
140
141
142 Boolean
143 _SCSerialize(CFPropertyListRef obj, CFDataRef *xml, void **dataRef, CFIndex *dataLen)
144 {
145 CFDataRef myXml;
146 CFWriteStreamRef stream;
147
148 if (!xml && !(dataRef && dataLen)) {
149 /* if not keeping track of allocated space */
150 return FALSE;
151 }
152
153 stream = CFWriteStreamCreateWithAllocatedBuffers(NULL, NULL);
154 CFWriteStreamOpen(stream);
155 CFPropertyListWriteToStream(obj, stream, kCFPropertyListBinaryFormat_v1_0, NULL);
156 CFWriteStreamClose(stream);
157 myXml = CFWriteStreamCopyProperty(stream, kCFStreamPropertyDataWritten);
158 CFRelease(stream);
159 if (!myXml) {
160 SCLog(TRUE, LOG_ERR, CFSTR("_SCSerialize() failed"));
161 if (xml) *xml = NULL;
162 if (dataRef) *dataRef = NULL;
163 if (dataLen) *dataLen = 0;
164 return FALSE;
165 }
166
167 if (xml) {
168 *xml = myXml;
169 if (dataRef) {
170 *dataRef = (void *)CFDataGetBytePtr(myXml);
171 }
172 if (dataLen) {
173 *dataLen = CFDataGetLength(myXml);
174 }
175 } else {
176 kern_return_t status;
177
178 *dataLen = CFDataGetLength(myXml);
179 status = vm_allocate(mach_task_self(), (void *)dataRef, *dataLen, TRUE);
180 if (status != KERN_SUCCESS) {
181 SCLog(TRUE, LOG_ERR, CFSTR("_SCSerialize(): %s"), mach_error_string(status));
182 CFRelease(myXml);
183 *dataRef = NULL;
184 *dataLen = 0;
185 return FALSE;
186 }
187
188 bcopy((char *)CFDataGetBytePtr(myXml), *dataRef, *dataLen);
189 CFRelease(myXml);
190 }
191
192 return TRUE;
193 }
194
195
196 Boolean
197 _SCUnserialize(CFPropertyListRef *obj, CFDataRef xml, void *dataRef, CFIndex dataLen)
198 {
199 CFStringRef xmlError;
200
201 if (!xml) {
202 kern_return_t status;
203
204 xml = CFDataCreateWithBytesNoCopy(NULL, (void *)dataRef, dataLen, kCFAllocatorNull);
205 *obj = CFPropertyListCreateFromXMLData(NULL,
206 xml,
207 kCFPropertyListImmutable,
208 &xmlError);
209 CFRelease(xml);
210
211 status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen);
212 if (status != KERN_SUCCESS) {
213 SCLog(_sc_verbose, LOG_DEBUG, CFSTR("_SCUnserialize(): %s"), mach_error_string(status));
214 /* non-fatal???, proceed */
215 }
216 } else {
217 *obj = CFPropertyListCreateFromXMLData(NULL,
218 xml,
219 kCFPropertyListImmutable,
220 &xmlError);
221 }
222
223 if (*obj == NULL) {
224 if (xmlError) {
225 SCLog(TRUE, LOG_ERR, CFSTR("_SCUnserialize(): %@"), xmlError);
226 CFRelease(xmlError);
227 }
228 _SCErrorSet(kSCStatusFailed);
229 return FALSE;
230 }
231
232 return TRUE;
233 }
234
235
236 Boolean
237 _SCSerializeString(CFStringRef str, CFDataRef *data, void **dataRef, CFIndex *dataLen)
238 {
239 CFDataRef myData;
240
241 if (!isA_CFString(str)) {
242 /* if not a CFString */
243 return FALSE;
244 }
245
246 if (!data && !(dataRef && dataLen)) {
247 /* if not keeping track of allocated space */
248 return FALSE;
249 }
250
251 myData = CFStringCreateExternalRepresentation(NULL, str, kCFStringEncodingUTF8, 0);
252 if (!myData) {
253 SCLog(TRUE, LOG_ERR, CFSTR("_SCSerializeString() failed"));
254 if (data) *data = NULL;
255 if (dataRef) *dataRef = NULL;
256 if (dataLen) *dataLen = 0;
257 return FALSE;
258 }
259
260 if (data) {
261 *data = myData;
262 if (dataRef) {
263 *dataRef = (void *)CFDataGetBytePtr(myData);
264 }
265 if (dataLen) {
266 *dataLen = CFDataGetLength(myData);
267 }
268 } else {
269 kern_return_t status;
270
271 *dataLen = CFDataGetLength(myData);
272 status = vm_allocate(mach_task_self(), (void *)dataRef, *dataLen, TRUE);
273 if (status != KERN_SUCCESS) {
274 SCLog(TRUE, LOG_ERR, CFSTR("_SCSerializeString(): %s"), mach_error_string(status));
275 CFRelease(myData);
276 *dataRef = NULL;
277 *dataLen = 0;
278 return FALSE;
279 }
280
281 bcopy((char *)CFDataGetBytePtr(myData), *dataRef, *dataLen);
282 CFRelease(myData);
283 }
284
285 return TRUE;
286 }
287
288
289 Boolean
290 _SCUnserializeString(CFStringRef *str, CFDataRef utf8, void *dataRef, CFIndex dataLen)
291 {
292 if (!utf8) {
293 kern_return_t status;
294
295 utf8 = CFDataCreateWithBytesNoCopy(NULL, dataRef, dataLen, kCFAllocatorNull);
296 *str = CFStringCreateFromExternalRepresentation(NULL, utf8, kCFStringEncodingUTF8);
297 CFRelease(utf8);
298
299 status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen);
300 if (status != KERN_SUCCESS) {
301 SCLog(_sc_verbose, LOG_DEBUG, CFSTR("_SCUnserializeString(): %s"), mach_error_string(status));
302 /* non-fatal???, proceed */
303 }
304 } else {
305 *str = CFStringCreateFromExternalRepresentation(NULL, utf8, kCFStringEncodingUTF8);
306 }
307
308 if (*str == NULL) {
309 SCLog(TRUE, LOG_ERR, CFSTR("_SCUnserializeString() failed"));
310 return FALSE;
311 }
312
313 return TRUE;
314 }
315
316
317 Boolean
318 _SCSerializeData(CFDataRef data, void **dataRef, CFIndex *dataLen)
319 {
320 kern_return_t status;
321
322 if (!isA_CFData(data)) {
323 /* if not a CFData */
324 return FALSE;
325 }
326
327 *dataLen = CFDataGetLength(data);
328 status = vm_allocate(mach_task_self(), (void *)dataRef, *dataLen, TRUE);
329 if (status != KERN_SUCCESS) {
330 SCLog(TRUE, LOG_ERR, CFSTR("_SCSerializeData(): %s"), mach_error_string(status));
331 *dataRef = NULL;
332 *dataLen = 0;
333 return FALSE;
334 }
335
336 bcopy((char *)CFDataGetBytePtr(data), *dataRef, *dataLen);
337
338 return TRUE;
339 }
340
341
342 Boolean
343 _SCUnserializeData(CFDataRef *data, void *dataRef, CFIndex dataLen)
344 {
345 kern_return_t status;
346
347 *data = CFDataCreate(NULL, dataRef, dataLen);
348 status = vm_deallocate(mach_task_self(), (vm_address_t)dataRef, dataLen);
349 if (status != KERN_SUCCESS) {
350 SCLog(_sc_verbose, LOG_DEBUG, CFSTR("_SCUnserializeData(): %s"), mach_error_string(status));
351 _SCErrorSet(kSCStatusFailed);
352 return FALSE;
353 }
354
355 return TRUE;
356 }
357
358
359 CFDictionaryRef
360 _SCSerializeMultiple(CFDictionaryRef dict)
361 {
362 const void * keys_q[N_QUICK];
363 const void ** keys = keys_q;
364 CFIndex nElements;
365 CFDictionaryRef newDict = NULL;
366 const void * pLists_q[N_QUICK];
367 const void ** pLists = pLists_q;
368 const void * values_q[N_QUICK];
369 const void ** values = values_q;
370
371 nElements = CFDictionaryGetCount(dict);
372 if (nElements > 0) {
373 CFIndex i;
374
375 if (nElements > (CFIndex)(sizeof(keys_q) / sizeof(CFTypeRef))) {
376 keys = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
377 values = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
378 pLists = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
379 }
380 bzero(pLists, nElements * sizeof(CFTypeRef));
381
382 CFDictionaryGetKeysAndValues(dict, keys, values);
383 for (i = 0; i < nElements; i++) {
384 if (!_SCSerialize((CFPropertyListRef)values[i], (CFDataRef *)&pLists[i], NULL, NULL)) {
385 goto done;
386 }
387 }
388 }
389
390 newDict = CFDictionaryCreate(NULL,
391 keys,
392 pLists,
393 nElements,
394 &kCFTypeDictionaryKeyCallBacks,
395 &kCFTypeDictionaryValueCallBacks);
396
397 done :
398
399 if (nElements > 0) {
400 CFIndex i;
401
402 for (i = 0; i < nElements; i++) {
403 if (pLists[i]) CFRelease(pLists[i]);
404 }
405
406 if (keys != keys_q) {
407 CFAllocatorDeallocate(NULL, keys);
408 CFAllocatorDeallocate(NULL, values);
409 CFAllocatorDeallocate(NULL, pLists);
410 }
411 }
412
413 return newDict;
414 }
415
416
417 CFDictionaryRef
418 _SCUnserializeMultiple(CFDictionaryRef dict)
419 {
420 const void * keys_q[N_QUICK];
421 const void ** keys = keys_q;
422 CFIndex nElements;
423 CFDictionaryRef newDict = NULL;
424 const void * pLists_q[N_QUICK];
425 const void ** pLists = pLists_q;
426 const void * values_q[N_QUICK];
427 const void ** values = values_q;
428
429 nElements = CFDictionaryGetCount(dict);
430 if (nElements > 0) {
431 CFIndex i;
432
433 if (nElements > (CFIndex)(sizeof(keys_q) / sizeof(CFTypeRef))) {
434 keys = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
435 values = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
436 pLists = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
437 }
438 bzero(pLists, nElements * sizeof(CFTypeRef));
439
440 CFDictionaryGetKeysAndValues(dict, keys, values);
441 for (i = 0; i < nElements; i++) {
442 if (!_SCUnserialize((CFPropertyListRef *)&pLists[i], values[i], NULL, 0)) {
443 goto done;
444 }
445 }
446 }
447
448 newDict = CFDictionaryCreate(NULL,
449 keys,
450 pLists,
451 nElements,
452 &kCFTypeDictionaryKeyCallBacks,
453 &kCFTypeDictionaryValueCallBacks);
454
455 done :
456
457 if (nElements > 0) {
458 CFIndex i;
459
460 for (i = 0; i < nElements; i++) {
461 if (pLists[i]) CFRelease(pLists[i]);
462 }
463
464 if (keys != keys_q) {
465 CFAllocatorDeallocate(NULL, keys);
466 CFAllocatorDeallocate(NULL, values);
467 CFAllocatorDeallocate(NULL, pLists);
468 }
469 }
470
471 return newDict;
472 }
473
474
475 __private_extern__ void
476 _SC_signalRunLoop(CFTypeRef obj, CFRunLoopSourceRef rls, CFArrayRef rlList)
477 {
478 CFRunLoopRef rl = NULL;
479 CFRunLoopRef rl1 = NULL;
480 CFIndex i;
481 CFIndex n = CFArrayGetCount(rlList);
482
483 if (n == 0) {
484 return;
485 }
486
487 /* get first runLoop for this object */
488 for (i = 0; i < n; i += 3) {
489 if (!CFEqual(obj, CFArrayGetValueAtIndex(rlList, i))) {
490 continue;
491 }
492
493 rl1 = (CFRunLoopRef)CFArrayGetValueAtIndex(rlList, i+1);
494 break;
495 }
496
497 if (!rl1) {
498 /* if not scheduled */
499 return;
500 }
501
502 /* check if we have another runLoop for this object */
503 rl = rl1;
504 for (i = i+3; i < n; i += 3) {
505 CFRunLoopRef rl2;
506
507 if (!CFEqual(obj, CFArrayGetValueAtIndex(rlList, i))) {
508 continue;
509 }
510
511 rl2 = (CFRunLoopRef)CFArrayGetValueAtIndex(rlList, i+1);
512 if (!CFEqual(rl1, rl2)) {
513 /* we've got more than one runLoop */
514 rl = NULL;
515 break;
516 }
517 }
518
519 if (rl) {
520 /* if we only have one runLoop */
521 CFRunLoopWakeUp(rl);
522 return;
523 }
524
525 /* more than one different runLoop, so we must pick one */
526 for (i = 0; i < n; i+=3) {
527 CFStringRef rlMode;
528
529 if (!CFEqual(obj, CFArrayGetValueAtIndex(rlList, i))) {
530 continue;
531 }
532
533 rl = (CFRunLoopRef)CFArrayGetValueAtIndex(rlList, i+1);
534 rlMode = CFRunLoopCopyCurrentMode(rl);
535 if (rlMode && CFRunLoopIsWaiting(rl) && CFRunLoopContainsSource(rl, rls, rlMode)) {
536 /* we've found a runLoop that's "ready" */
537 CFRelease(rlMode);
538 CFRunLoopWakeUp(rl);
539 return;
540 }
541 if (rlMode) CFRelease(rlMode);
542 }
543
544 /* didn't choose one above, so choose first */
545 CFRunLoopWakeUp(rl1);
546 return;
547 }
548
549
550 __private_extern__ Boolean
551 _SC_isScheduled(CFTypeRef obj, CFRunLoopRef runLoop, CFStringRef runLoopMode, CFMutableArrayRef rlList)
552 {
553 CFIndex i;
554 CFIndex n = CFArrayGetCount(rlList);
555
556 for (i = 0; i < n; i += 3) {
557 if (obj && !CFEqual(obj, CFArrayGetValueAtIndex(rlList, i))) {
558 continue;
559 }
560 if (runLoop && !CFEqual(runLoop, CFArrayGetValueAtIndex(rlList, i+1))) {
561 continue;
562 }
563 if (runLoopMode && !CFEqual(runLoopMode, CFArrayGetValueAtIndex(rlList, i+2))) {
564 continue;
565 }
566 return TRUE;
567 }
568
569 return FALSE;
570 }
571
572
573 __private_extern__ void
574 _SC_schedule(CFTypeRef obj, CFRunLoopRef runLoop, CFStringRef runLoopMode, CFMutableArrayRef rlList)
575 {
576 CFArrayAppendValue(rlList, obj);
577 CFArrayAppendValue(rlList, runLoop);
578 CFArrayAppendValue(rlList, runLoopMode);
579
580 return;
581 }
582
583
584 __private_extern__ Boolean
585 _SC_unschedule(CFTypeRef obj, CFRunLoopRef runLoop, CFStringRef runLoopMode, CFMutableArrayRef rlList, Boolean all)
586 {
587 CFIndex i = 0;
588 Boolean found = FALSE;
589 CFIndex n = CFArrayGetCount(rlList);
590
591 while (i < n) {
592 if (obj && !CFEqual(obj, CFArrayGetValueAtIndex(rlList, i))) {
593 i += 3;
594 continue;
595 }
596 if (runLoop && !CFEqual(runLoop, CFArrayGetValueAtIndex(rlList, i+1))) {
597 i += 3;
598 continue;
599 }
600 if (runLoopMode && !CFEqual(runLoopMode, CFArrayGetValueAtIndex(rlList, i+2))) {
601 i += 3;
602 continue;
603 }
604
605 found = TRUE;
606
607 CFArrayRemoveValueAtIndex(rlList, i + 2);
608 CFArrayRemoveValueAtIndex(rlList, i + 1);
609 CFArrayRemoveValueAtIndex(rlList, i);
610
611 if (!all) {
612 return found;
613 }
614
615 n -= 3;
616 }
617
618 return found;
619 }
620
621
622 void
623 __showMachPortStatus()
624 {
625 #ifdef DEBUG
626 /* print status of in-use mach ports */
627 if (_sc_debug) {
628 kern_return_t status;
629 mach_port_name_array_t ports;
630 mach_port_type_array_t types;
631 int pi, pn, tn;
632 CFMutableStringRef str;
633
634 SCLog(_sc_verbose, LOG_DEBUG, CFSTR("----------"));
635
636 /* report on ALL mach ports associated with this task */
637 status = mach_port_names(mach_task_self(), &ports, &pn, &types, &tn);
638 if (status == MACH_MSG_SUCCESS) {
639 str = CFStringCreateMutable(NULL, 0);
640 for (pi = 0; pi < pn; pi++) {
641 char rights[16], *rp = &rights[0];
642
643 if (types[pi] != MACH_PORT_TYPE_NONE) {
644 *rp++ = ' ';
645 *rp++ = '(';
646 if (types[pi] & MACH_PORT_TYPE_SEND)
647 *rp++ = 'S';
648 if (types[pi] & MACH_PORT_TYPE_RECEIVE)
649 *rp++ = 'R';
650 if (types[pi] & MACH_PORT_TYPE_SEND_ONCE)
651 *rp++ = 'O';
652 if (types[pi] & MACH_PORT_TYPE_PORT_SET)
653 *rp++ = 'P';
654 if (types[pi] & MACH_PORT_TYPE_DEAD_NAME)
655 *rp++ = 'D';
656 *rp++ = ')';
657 }
658 *rp = '\0';
659 CFStringAppendFormat(str, NULL, CFSTR(" %d%s"), ports[pi], rights);
660 }
661 SCLog(_sc_verbose, LOG_DEBUG, CFSTR("Task ports (n=%d):%@"), pn, str);
662 CFRelease(str);
663 } else {
664 /* log (but ignore) errors */
665 SCLog(_sc_verbose, LOG_DEBUG, CFSTR("mach_port_names(): %s"), mach_error_string(status));
666 }
667 }
668 #endif /* DEBUG */
669 return;
670 }
671
672
673 void
674 __showMachPortReferences(mach_port_t port)
675 {
676 #ifdef DEBUG
677 kern_return_t status;
678 mach_port_urefs_t refs_send = 0;
679 mach_port_urefs_t refs_recv = 0;
680 mach_port_urefs_t refs_once = 0;
681 mach_port_urefs_t refs_pset = 0;
682 mach_port_urefs_t refs_dead = 0;
683
684 SCLog(_sc_verbose, LOG_DEBUG, CFSTR("user references for mach port %d"), port);
685
686 status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, &refs_send);
687 if (status != KERN_SUCCESS) {
688 SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" mach_port_get_refs(MACH_PORT_RIGHT_SEND): %s"), mach_error_string(status));
689 return;
690 }
691
692 status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, &refs_recv);
693 if (status != KERN_SUCCESS) {
694 SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" mach_port_get_refs(MACH_PORT_RIGHT_RECEIVE): %s"), mach_error_string(status));
695 return;
696 }
697
698 status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND_ONCE, &refs_once);
699 if (status != KERN_SUCCESS) {
700 SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" mach_port_get_refs(MACH_PORT_RIGHT_SEND_ONCE): %s"), mach_error_string(status));
701 return;
702 }
703
704 status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_PORT_SET, &refs_pset);
705 if (status != KERN_SUCCESS) {
706 SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" mach_port_get_refs(MACH_PORT_RIGHT_PORT_SET): %s"), mach_error_string(status));
707 return;
708 }
709
710 status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_DEAD_NAME, &refs_dead);
711 if (status != KERN_SUCCESS) {
712 SCLog(_sc_verbose, LOG_DEBUG, CFSTR(" mach_port_get_refs(MACH_PORT_RIGHT_DEAD_NAME): %s"), mach_error_string(status));
713 return;
714 }
715
716 SCLog(_sc_verbose, LOG_DEBUG,
717 CFSTR(" send = %d, receive = %d, send once = %d, port set = %d, dead name = %d"),
718 refs_send,
719 refs_recv,
720 refs_once,
721 refs_pset,
722 refs_dead);
723
724 #endif /* DEBUG */
725 return;
726 }