2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // sstransit - SecurityServer client library transition code.
22 // These are the functions that implement CssmClient methods in terms of
23 // MIG IPC client calls, plus their supporting machinery.
25 // WARNING! HERE BE DRAGONS!
26 // This code involves moderately arcane magic including (but not limited to)
27 // dancing macros paired off with self-maintaining stack objects. Don't take
28 // anything for granted! Be very afraid of ALL-CAPS names. Your best bet is
29 // probably to stick with the existing patterns.
35 #include <Security/mach++.h>
36 #include <Security/cssmwalkers.h>
37 #include <Security/AuthorizationWalkers.h>
43 // stock leading argument profile used by all calls
44 #define UCSP_ARGS mGlobal().serverPort, mig_get_reply_port(), &rcode
46 // IPC/IPCN wrap the actual Mach IPC call. IPC also activates the connection first
47 #define IPCN(statement) \
48 { CSSM_RETURN rcode; check(statement); if (rcode != CSSM_OK) CssmError::throwMe(rcode); }
49 #define IPC(statement) { activate(); IPCN(statement); }
51 // pass mandatory or optional CssmData arguments into an IPC call
52 #define DATA(arg) arg.data(), arg.length()
53 #define OPTIONALDATA(arg) (arg ? arg->data() : NULL), (arg ? arg->length() : 0)
55 // pass structured arguments in/out of IPC calls. See "data walkers" for details
56 #define COPY(copy) copy, copy.length(), copy
57 #define COPY_OUT(copy) ©, ©##Length, ©##Base
58 #define COPY_OUT_DECL(type,name) type *name, *name##Base; mach_msg_type_number_t name##Length
62 // DataOutput manages an output CssmData argument.
66 DataOutput(CssmData
&arg
, CssmAllocator
&alloc
)
67 : argument(arg
), allocator(alloc
) { mData
= NULL
; }
70 void **data() { return &mData
; }
71 mach_msg_type_number_t
*length() { return &mLength
; }
74 CssmAllocator
&allocator
;
78 mach_msg_type_number_t mLength
;
83 // Bundle up a Context for IPC transmission
87 SendContext(const Context
&ctx
);
88 ~SendContext() { CssmAllocator::standard().free(attributes
); }
90 const Context
&context
;
91 CSSM_CONTEXT_ATTRIBUTE
*attributes
;
95 #define CONTEXT(ctx) ctx.context, ctx.attributes, ctx.attributes, ctx.attributeSize
97 } // end namespace Security