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