]> git.saurik.com Git - apple/configd.git/blob - configd.tproj/notify_server.c
configd-42.tar.gz
[apple/configd.git] / configd.tproj / notify_server.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 /*
24 * Modification History
25 *
26 * March 24, 2000 Allan Nathanson <ajn@apple.com>
27 * - initial revision
28 */
29
30 #include "configd.h"
31 #include "session.h"
32 #include "notify.h"
33
34 boolean_t
35 notify_server(mach_msg_header_t *request, mach_msg_header_t *reply)
36 {
37 mach_no_senders_notification_t *notify = (mach_no_senders_notification_t *)request;
38
39 if ((notify->not_header.msgh_id > MACH_NOTIFY_LAST) ||
40 (notify->not_header.msgh_id < MACH_NOTIFY_FIRST)) {
41 return FALSE; /* if this is not a notification message */
42 }
43
44 switch (notify->not_header.msgh_id) {
45 case MACH_NOTIFY_NO_SENDERS :
46 SCLog(_configd_verbose, LOG_DEBUG, CFSTR("No more senders for port %d, closing."),
47 notify->not_header.msgh_local_port);
48 cleanupSession(notify->not_header.msgh_local_port);
49
50 (void) mach_port_destroy(mach_task_self(), notify->not_header.msgh_local_port);
51
52 notify->not_header.msgh_remote_port = MACH_PORT_NULL;
53 return TRUE;
54 case MACH_NOTIFY_DEAD_NAME :
55 SCLog(_configd_verbose, LOG_DEBUG, CFSTR("Dead name for port %d, closing."),
56 notify->not_header.msgh_local_port);
57 cleanupSession(notify->not_header.msgh_local_port);
58
59 (void) mach_port_destroy(mach_task_self(), notify->not_header.msgh_local_port);
60
61 notify->not_header.msgh_remote_port = MACH_PORT_NULL;
62 return TRUE;
63 default :
64 break;
65 }
66
67 SCLog(_configd_verbose, LOG_DEBUG, CFSTR("HELP!, Received notification: port=%d, msgh_id=%d"),
68 notify->not_header.msgh_local_port,
69 notify->not_header.msgh_id);
70
71 return FALSE;
72 }