configd-293.8.tar.gz
[apple/configd.git] / configd.tproj / notify_server.c
CommitLineData
5958d7c0 1/*
be997540 2 * Copyright (c) 2000-2004, 2007 Apple Inc. All rights reserved.
5958d7c0
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
009ee3c6 5 *
009ee3c6
A
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
5958d7c0
A
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
009ee3c6
A
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 *
5958d7c0
A
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
0fae82ee
A
24/*
25 * Modification History
26 *
27 * March 24, 2000 Allan Nathanson <ajn@apple.com>
28 * - initial revision
29 */
30
5958d7c0
A
31#include "configd.h"
32#include "session.h"
33
009ee3c6 34__private_extern__
5958d7c0
A
35boolean_t
36notify_server(mach_msg_header_t *request, mach_msg_header_t *reply)
37{
009ee3c6
A
38 mach_no_senders_notification_t *Request = (mach_no_senders_notification_t *)request;
39 mig_reply_error_t *Reply = (mig_reply_error_t *)reply;
40
41 reply->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request->msgh_bits), 0);
42 reply->msgh_remote_port = request->msgh_remote_port;
43 reply->msgh_size = sizeof(mig_reply_error_t); /* Minimal size: update as needed */
44 reply->msgh_local_port = MACH_PORT_NULL;
45 reply->msgh_id = request->msgh_id + 100;
5958d7c0 46
009ee3c6
A
47 if ((Request->not_header.msgh_id > MACH_NOTIFY_LAST) ||
48 (Request->not_header.msgh_id < MACH_NOTIFY_FIRST)) {
49 Reply->NDR = NDR_record;
50 Reply->RetCode = MIG_BAD_ID;
5958d7c0
A
51 return FALSE; /* if this is not a notification message */
52 }
53
009ee3c6 54 switch (Request->not_header.msgh_id) {
5958d7c0 55 case MACH_NOTIFY_NO_SENDERS :
a40a14f8 56 __MACH_PORT_DEBUG(TRUE, "*** notify_server MACH_NOTIFY_NO_SENDERS", Request->not_header.msgh_local_port);
009ee3c6 57 cleanupSession(Request->not_header.msgh_local_port);
5958d7c0 58
009ee3c6
A
59 Reply->Head.msgh_bits = 0;
60 Reply->Head.msgh_remote_port = MACH_PORT_NULL;
61 Reply->RetCode = KERN_SUCCESS;
5958d7c0
A
62 return TRUE;
63 default :
64 break;
65 }
66
0fae82ee 67 SCLog(_configd_verbose, LOG_DEBUG, CFSTR("HELP!, Received notification: port=%d, msgh_id=%d"),
dbf6a266
A
68 Request->not_header.msgh_local_port,
69 Request->not_header.msgh_id);
5958d7c0 70
009ee3c6
A
71 Reply->NDR = NDR_record;
72 Reply->RetCode = MIG_BAD_ID;
73 return FALSE; /* if this is not a notification we are handling */
5958d7c0 74}