xref: /minix3/crypto/external/bsd/heimdal/dist/lib/ipc/heim-ipc.h (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc /*	$NetBSD: heim-ipc.h,v 1.1.1.1 2011/04/13 18:15:28 elric Exp $	*/
2*ebfedea0SLionel Sambuc 
3*ebfedea0SLionel Sambuc /*
4*ebfedea0SLionel Sambuc  * Copyright (c) 2009 Kungliga Tekniska H�gskolan
5*ebfedea0SLionel Sambuc  * (Royal Institute of Technology, Stockholm, Sweden).
6*ebfedea0SLionel Sambuc  * All rights reserved.
7*ebfedea0SLionel Sambuc  *
8*ebfedea0SLionel Sambuc  * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
9*ebfedea0SLionel Sambuc  *
10*ebfedea0SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
11*ebfedea0SLionel Sambuc  * modification, are permitted provided that the following conditions
12*ebfedea0SLionel Sambuc  * are met:
13*ebfedea0SLionel Sambuc  *
14*ebfedea0SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
15*ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
16*ebfedea0SLionel Sambuc  *
17*ebfedea0SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
18*ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
19*ebfedea0SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
20*ebfedea0SLionel Sambuc  *
21*ebfedea0SLionel Sambuc  * 3. Neither the name of the Institute nor the names of its contributors
22*ebfedea0SLionel Sambuc  *    may be used to endorse or promote products derived from this software
23*ebfedea0SLionel Sambuc  *    without specific prior written permission.
24*ebfedea0SLionel Sambuc  *
25*ebfedea0SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
26*ebfedea0SLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27*ebfedea0SLionel Sambuc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28*ebfedea0SLionel Sambuc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
29*ebfedea0SLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30*ebfedea0SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31*ebfedea0SLionel Sambuc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32*ebfedea0SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33*ebfedea0SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34*ebfedea0SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35*ebfedea0SLionel Sambuc  * SUCH DAMAGE.
36*ebfedea0SLionel Sambuc  */
37*ebfedea0SLionel Sambuc 
38*ebfedea0SLionel Sambuc #include <krb5/asn1-common.h>
39*ebfedea0SLionel Sambuc 
40*ebfedea0SLionel Sambuc typedef struct heim_ipc *heim_ipc;
41*ebfedea0SLionel Sambuc typedef struct heim_sipc *heim_sipc;
42*ebfedea0SLionel Sambuc typedef struct heim_icred *heim_icred;
43*ebfedea0SLionel Sambuc typedef struct heim_isemaphore *heim_isemaphore;
44*ebfedea0SLionel Sambuc typedef struct heim_octet_string heim_idata;
45*ebfedea0SLionel Sambuc typedef struct heim_sipc_call *heim_sipc_call;
46*ebfedea0SLionel Sambuc 
47*ebfedea0SLionel Sambuc /* common */
48*ebfedea0SLionel Sambuc 
49*ebfedea0SLionel Sambuc void
50*ebfedea0SLionel Sambuc heim_ipc_free_cred(heim_icred);
51*ebfedea0SLionel Sambuc 
52*ebfedea0SLionel Sambuc uid_t
53*ebfedea0SLionel Sambuc heim_ipc_cred_get_uid(heim_icred);
54*ebfedea0SLionel Sambuc 
55*ebfedea0SLionel Sambuc gid_t
56*ebfedea0SLionel Sambuc heim_ipc_cred_get_gid(heim_icred);
57*ebfedea0SLionel Sambuc 
58*ebfedea0SLionel Sambuc pid_t
59*ebfedea0SLionel Sambuc heim_ipc_cred_get_pid(heim_icred);
60*ebfedea0SLionel Sambuc 
61*ebfedea0SLionel Sambuc pid_t
62*ebfedea0SLionel Sambuc heim_ipc_cred_get_session(heim_icred);
63*ebfedea0SLionel Sambuc 
64*ebfedea0SLionel Sambuc void
65*ebfedea0SLionel Sambuc heim_ipc_main(void);
66*ebfedea0SLionel Sambuc 
67*ebfedea0SLionel Sambuc heim_isemaphore
68*ebfedea0SLionel Sambuc heim_ipc_semaphore_create(long);
69*ebfedea0SLionel Sambuc 
70*ebfedea0SLionel Sambuc long
71*ebfedea0SLionel Sambuc heim_ipc_semaphore_wait(heim_isemaphore, time_t);
72*ebfedea0SLionel Sambuc 
73*ebfedea0SLionel Sambuc long
74*ebfedea0SLionel Sambuc heim_ipc_semaphore_signal(heim_isemaphore);
75*ebfedea0SLionel Sambuc 
76*ebfedea0SLionel Sambuc void
77*ebfedea0SLionel Sambuc heim_ipc_semaphore_release(heim_isemaphore);
78*ebfedea0SLionel Sambuc 
79*ebfedea0SLionel Sambuc #define HEIM_IPC_WAIT_FOREVER ((time_t)-1)
80*ebfedea0SLionel Sambuc 
81*ebfedea0SLionel Sambuc void
82*ebfedea0SLionel Sambuc heim_ipc_free_data(heim_idata *);
83*ebfedea0SLionel Sambuc 
84*ebfedea0SLionel Sambuc /* client */
85*ebfedea0SLionel Sambuc 
86*ebfedea0SLionel Sambuc int
87*ebfedea0SLionel Sambuc heim_ipc_init_context(const char *, heim_ipc *);
88*ebfedea0SLionel Sambuc 
89*ebfedea0SLionel Sambuc void
90*ebfedea0SLionel Sambuc heim_ipc_free_context(heim_ipc);
91*ebfedea0SLionel Sambuc 
92*ebfedea0SLionel Sambuc int
93*ebfedea0SLionel Sambuc heim_ipc_call(heim_ipc, const heim_idata *, heim_idata *, heim_icred *);
94*ebfedea0SLionel Sambuc 
95*ebfedea0SLionel Sambuc int
96*ebfedea0SLionel Sambuc heim_ipc_async(heim_ipc, const heim_idata *, void *, void (*func)(void *, int, heim_idata *, heim_icred));
97*ebfedea0SLionel Sambuc 
98*ebfedea0SLionel Sambuc /* server */
99*ebfedea0SLionel Sambuc 
100*ebfedea0SLionel Sambuc #define HEIM_SIPC_TYPE_IPC		1
101*ebfedea0SLionel Sambuc #define HEIM_SIPC_TYPE_UINT32		2
102*ebfedea0SLionel Sambuc #define HEIM_SIPC_TYPE_HTTP		4
103*ebfedea0SLionel Sambuc 
104*ebfedea0SLionel Sambuc typedef void
105*ebfedea0SLionel Sambuc (*heim_ipc_complete)(heim_sipc_call, int, heim_idata *);
106*ebfedea0SLionel Sambuc 
107*ebfedea0SLionel Sambuc typedef void
108*ebfedea0SLionel Sambuc (*heim_ipc_callback)(void *, const heim_idata *,
109*ebfedea0SLionel Sambuc 		     const heim_icred, heim_ipc_complete, heim_sipc_call);
110*ebfedea0SLionel Sambuc 
111*ebfedea0SLionel Sambuc 
112*ebfedea0SLionel Sambuc int
113*ebfedea0SLionel Sambuc heim_sipc_launchd_mach_init(const char *, heim_ipc_callback,
114*ebfedea0SLionel Sambuc 			    void *, heim_sipc *);
115*ebfedea0SLionel Sambuc 
116*ebfedea0SLionel Sambuc int
117*ebfedea0SLionel Sambuc heim_sipc_stream_listener(int, int, heim_ipc_callback,
118*ebfedea0SLionel Sambuc 			  void *, heim_sipc *);
119*ebfedea0SLionel Sambuc 
120*ebfedea0SLionel Sambuc int
121*ebfedea0SLionel Sambuc heim_sipc_service_unix(const char *, heim_ipc_callback,
122*ebfedea0SLionel Sambuc 		       void *, heim_sipc *);
123*ebfedea0SLionel Sambuc 
124*ebfedea0SLionel Sambuc 
125*ebfedea0SLionel Sambuc void
126*ebfedea0SLionel Sambuc heim_sipc_timeout(time_t);
127*ebfedea0SLionel Sambuc 
128*ebfedea0SLionel Sambuc void
129*ebfedea0SLionel Sambuc heim_sipc_set_timeout_handler(void (*)(void));
130*ebfedea0SLionel Sambuc 
131*ebfedea0SLionel Sambuc void
132*ebfedea0SLionel Sambuc heim_sipc_free_context(heim_sipc);
133