1/*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1.  Redistributions of source code must retain the above copyright
11 *     notice, this list of conditions and the following disclaimer.
12 * 2.  Redistributions in binary form must reproduce the above copyright
13 *     notice, this list of conditions and the following disclaimer in the
14 *     documentation and/or other materials provided with the distribution.
15 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of its
16 *     contributors may be used to endorse or promote products derived from
17 *     this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * Portions of this software have been released under the following terms:
31 *
32 * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC.
33 * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY
34 * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION
35 *
36 * To anyone who acknowledges that this file is provided "AS IS"
37 * without any express or implied warranty:
38 * permission to use, copy, modify, and distribute this file for any
39 * purpose is hereby granted without fee, provided that the above
40 * copyright notices and this notice appears in all source code copies,
41 * and that none of the names of Open Software Foundation, Inc., Hewlett-
42 * Packard Company or Digital Equipment Corporation be used
43 * in advertising or publicity pertaining to distribution of the software
44 * without specific, written prior permission.  Neither Open Software
45 * Foundation, Inc., Hewlett-Packard Company nor Digital
46 * Equipment Corporation makes any representations about the suitability
47 * of this software for any purpose.
48 *
49 * Copyright (c) 2007, Novell, Inc. All rights reserved.
50 * Redistribution and use in source and binary forms, with or without
51 * modification, are permitted provided that the following conditions
52 * are met:
53 *
54 * 1.  Redistributions of source code must retain the above copyright
55 *     notice, this list of conditions and the following disclaimer.
56 * 2.  Redistributions in binary form must reproduce the above copyright
57 *     notice, this list of conditions and the following disclaimer in the
58 *     documentation and/or other materials provided with the distribution.
59 * 3.  Neither the name of Novell Inc. nor the names of its contributors
60 *     may be used to endorse or promote products derived from this
61 *     this software without specific prior written permission.
62 *
63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
64 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
65 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
66 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY
67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
68 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
69 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
70 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73 *
74 * @APPLE_LICENSE_HEADER_END@
75 */
76
77/*
78**
79**  NAME
80**
81**      comprot.h
82**
83**  FACILITY:
84**
85**      Remote Procedure Call (RPC)
86**
87**  ABSTRACT:
88**
89**  Generic interface to RPC Protocol Services.
90**
91**
92*/
93
94#ifndef _COMPROT_H
95#define _COMPROT_H
96
97#ifdef __cplusplus
98extern "C" {
99#endif
100
101/***********************************************************************/
102/*
103 * The Call EPV.
104 */
105typedef rpc_call_rep_t *(*rpc_prot_call_start_fn_t) (
106        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
107        unsigned32                  /* in  */    /*call_options*/,
108        rpc_if_rep_p_t              /* in  */    /*ifspec_h*/,
109        unsigned32                  /* in  */    /*opn*/,
110        rpc_transfer_syntax_t       /* in  */   * /*transfer_syntax*/,
111        unsigned32                  /* out */   * /*st*/
112    );
113
114typedef void (*rpc_prot_call_transmit_fn_t) (
115        rpc_call_rep_p_t            /* in  */    /*call_r*/,
116        rpc_iovector_p_t            /* in  */    /*call_args*/,
117        unsigned32                  /* out */   * /*st*/
118    );
119
120typedef void (*rpc_prot_call_transceive_fn_t) (
121        rpc_call_rep_p_t            /* in  */    /*call_r*/,
122        rpc_iovector_p_t            /* in  */    /*in_call_args*/,
123        rpc_iovector_elt_t          /* out */   * /*out_call_args*/,
124        ndr_format_t                /* out */   * /*remote_ndr_format*/,
125        unsigned32                  /* out */   * /*st*/
126    );
127
128typedef void (*rpc_prot_call_receive_fn_t) (
129        rpc_call_rep_p_t            /* in  */    /*call_r*/,
130        rpc_iovector_elt_t          /* out */   * /*call_args*/,
131        unsigned32                  /* out */   * /*st*/
132    );
133
134typedef void (*rpc_prot_call_end_fn_t) (
135        rpc_call_rep_p_t            /* in,out */ * /*call_r*/,
136        unsigned32                  /* out */   * /*st*/
137    );
138
139typedef void (*rpc_prot_call_blk_til_free_fn_t) (
140        rpc_call_rep_p_t            /* in  */    /*call_r*/,
141        unsigned32                  /* out */   * /*st*/
142    );
143
144typedef void (*rpc_prot_call_transmit_fault_fn_t) (
145        rpc_call_rep_p_t            /* in  */    /*call_r*/,
146        rpc_iovector_p_t            /* in  */    /*call_fault_info*/,
147        unsigned32                  /* out */   * /*st*/
148    );
149
150typedef void (*rpc_prot_call_cancel_fn_t) (
151        rpc_call_rep_p_t            /* in  */    /*call_r*/,
152        unsigned32                  /* out */   * /*st*/
153    );
154
155typedef void (*rpc_prot_call_receive_flt_fn_t) (
156        rpc_call_rep_p_t            /* in  */    /*call_r*/,
157        rpc_iovector_elt_t          /* out */   * /*fault_info*/,
158        ndr_format_t                /* out */   * /*remote_ndr_format*/,
159        unsigned32                  /* out */   * /*st*/
160    );
161
162typedef boolean32 (*rpc_prot_call_did_mgr_execute_fn_t) (
163        rpc_call_rep_p_t            /* in  */    /*call_r*/,
164        unsigned32                  /* out */   * /*st*/
165    );
166
167typedef struct
168{
169    rpc_prot_call_start_fn_t        call_start;
170    rpc_prot_call_transmit_fn_t     call_transmit;
171    rpc_prot_call_transceive_fn_t   call_transceive;
172    rpc_prot_call_receive_fn_t      call_receive;
173    rpc_prot_call_end_fn_t          call_end;
174    rpc_prot_call_blk_til_free_fn_t call_block_until_free;
175    rpc_prot_call_transmit_fault_fn_t call_transmit_fault;
176    rpc_prot_call_cancel_fn_t       call_cancel;
177    rpc_prot_call_receive_flt_fn_t  call_receive_fault;
178    rpc_prot_call_did_mgr_execute_fn_t  call_did_mgr_execute;
179} rpc_prot_call_epv_t, *rpc_prot_call_epv_p_t;
180
181/***********************************************************************/
182/*
183 * The Management EPV.
184 */
185typedef unsigned32 (*rpc_prot_mgt_inq_call_sent_fn_t) (
186        void
187    );
188
189typedef unsigned32 (*rpc_prot_mgt_inq_call_rcvd_fn_t) (
190        void
191    );
192
193typedef unsigned32 (*rpc_prot_mgt_inq_pkts_sent_fn_t) (
194        void
195    );
196
197typedef unsigned32 (*rpc_prot_mgt_inq_pkts_rcvd_fn_t) (
198        void
199    );
200
201typedef struct
202{
203    rpc_prot_mgt_inq_call_sent_fn_t mgmt_inq_calls_sent;
204    rpc_prot_mgt_inq_call_rcvd_fn_t mgmt_inq_calls_rcvd;
205    rpc_prot_mgt_inq_pkts_sent_fn_t mgmt_inq_pkts_sent;
206    rpc_prot_mgt_inq_pkts_rcvd_fn_t mgmt_inq_pkts_rcvd;
207} rpc_prot_mgmt_epv_t, *rpc_prot_mgmt_epv_p_t;
208
209/***********************************************************************/
210/*
211 * The Binding EPV.
212 */
213typedef rpc_binding_rep_t *(*rpc_prot_binding_alloc_fn_t) (
214        boolean32                   /* in  */    /*is_server*/,
215        unsigned32                  /* out */   * /*st*/
216    );
217
218typedef void (*rpc_prot_binding_init_fn_t) (
219        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
220        unsigned32                  /* out */   * /*st*/
221    );
222
223typedef void (*rpc_prot_binding_reset_fn_t) (
224        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
225        unsigned32                  /* out */   * /*st*/
226    );
227
228typedef void (*rpc_prot_binding_changed_fn_t) (
229        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
230        unsigned32                  /* out */   * /*st*/
231    );
232
233typedef void (*rpc_prot_binding_free_fn_t) (
234        rpc_binding_rep_p_t         /* in,out */ * /*binding_r*/,
235        unsigned32                  /* out */   * /*st*/
236    );
237
238typedef void (*rpc_prot_binding_inq_addr_fn_t) (
239        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
240        rpc_addr_p_t                /* out */   * /*rpc_addr*/,
241        unsigned32                  /* out */   * /*st*/
242    );
243
244typedef void (*rpc_prot_binding_inq_client_fn_t) (
245        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
246        rpc_client_handle_t         /* out */   * /*client_h*/,
247        unsigned32                  /* out */   * /*st*/
248    );
249
250typedef void (*rpc_prot_binding_copy_fn_t) (
251        rpc_binding_rep_p_t         /* in  */    /*src_binding_r*/,
252        rpc_binding_rep_p_t         /* in  */    /*dst_binding_r*/,
253        unsigned32                  /* out */   * /*st*/
254    );
255
256typedef void (*rpc_prot_binding_cross_fork_fn_t) (
257        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
258        unsigned32                  /* out */   * /*st*/
259    );
260
261typedef struct
262{
263    rpc_prot_binding_alloc_fn_t         binding_alloc;
264    rpc_prot_binding_init_fn_t          binding_init;
265    rpc_prot_binding_reset_fn_t         binding_reset;
266    rpc_prot_binding_changed_fn_t       binding_changed;
267    rpc_prot_binding_free_fn_t          binding_free;
268    rpc_prot_binding_inq_addr_fn_t      binding_inq_addr;
269    rpc_prot_binding_inq_client_fn_t    binding_inq_client;
270    rpc_prot_binding_copy_fn_t          binding_copy;
271    rpc_prot_binding_cross_fork_fn_t    binding_cross_fork;
272} rpc_prot_binding_epv_t, *rpc_prot_binding_epv_p_t;
273
274/***********************************************************************/
275/*
276 * The Network EPV.
277 */
278
279typedef void (*rpc_prot_net_use_socket_fn_t) (
280        rpc_socket_t                /* in */	 /*rpc_sock*/,
281        unsigned32                  /* in  */    /*max_calls*/,
282        unsigned32                  /* out */   * /*st*/
283    );
284
285typedef void (*rpc_prot_net_use_protseq_fn_t) (
286        rpc_protseq_id_t            /* in  */    /*pseq_id*/,
287        unsigned32                  /* in  */    /*max_calls*/,
288        rpc_addr_p_t                /* in  */    /*rpc_addr*/,
289        unsigned_char_p_t           /* in  */    /*endpoint*/,
290        unsigned32                  /* out */   * /*st*/
291    );
292
293typedef void (*rpc_prot_net_mon_fn_t) (
294        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
295        rpc_client_handle_t         /* in  */    /*client_h*/,
296        rpc_network_rundown_fn_t    /* in  */    /*rundown*/,
297        unsigned32                  /* out */   * /*st*/
298    );
299
300typedef void (*rpc_prot_net_stop_mon_fn_t) (
301        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
302        rpc_client_handle_t         /* in  */    /*client_h*/,
303        unsigned32                  /* out */   * /*st*/
304    );
305
306typedef void (*rpc_prot_net_maint_fn_t) (
307        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
308        unsigned32                  /* out */   * /*st*/
309    );
310
311typedef void (*rpc_prot_net_stop_maint_fn_t) (
312        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
313        unsigned32                  /* out */   * /*st*/
314    );
315
316typedef void (*rpc_prot_net_close_fn_t) (
317        rpc_binding_rep_p_t         /* in  */    /*binding_r*/,
318        unsigned32                  /* out */   * /*st*/
319    );
320
321typedef void (*rpc_prot_net_select_disp_fn_t) (
322        rpc_socket_t                /* in  */    /*desc*/,
323        dce_pointer_t                   /* in  */    /*priv_info*/,
324        boolean32                   /* in  */    /*is_active*/,
325        unsigned32                  /* out */   * /*st*/
326    );
327
328typedef void (*rpc_prot_net_inq_prot_vers_fn_t) (
329        unsigned8                   /* out */   * /*prot_id*/,
330        unsigned32                  /* out */   * /*version_major*/,
331        unsigned32                  /* out */   * /*version_minor*/,
332        unsigned32                  /* out */   * /*st*/
333    );
334
335typedef void (*rpc_prot_net_getpeereid_fn_t) (
336        rpc_binding_rep_p_t         /* in */	  /*binding_r*/,
337        uid_t                       /* out  */  * /*uid*/,
338        gid_t                       /* out */   * /*gid*/,
339        unsigned32                  /* out */   * /*st*/
340    );
341
342    typedef struct
343{
344    rpc_prot_net_use_socket_fn_t    network_use_socket;
345    rpc_prot_net_use_protseq_fn_t   network_use_protseq;
346    rpc_prot_net_mon_fn_t           network_mon;
347    rpc_prot_net_stop_mon_fn_t      network_stop_mon;
348    rpc_prot_net_maint_fn_t         network_maint;
349    rpc_prot_net_stop_maint_fn_t    network_stop_maint;
350    rpc_prot_net_select_disp_fn_t   network_select_disp;
351    rpc_prot_net_inq_prot_vers_fn_t network_inq_prot_vers;
352    rpc_prot_net_close_fn_t         network_close;
353    rpc_prot_net_getpeereid_fn_t    network_getpeereid;
354} rpc_prot_network_epv_t, *rpc_prot_network_epv_p_t;
355
356/***********************************************************************/
357/*
358 * Signature of the fork handling routines.
359 *
360 */
361typedef void (*rpc_prot_fork_handler_fn_t) (
362        rpc_fork_stage_id_t     operation
363    );
364
365/***********************************************************************/
366/*
367 * Signature of the init routine provided.
368 *
369 * Note: double underscores were added to these names just to diffrentiate
370 * them from the names of structure members that bother VAXC
371 */
372typedef void (*rpc_prot_init_fn_t) (
373        rpc_prot_call_epv_p_t       * /*call__epv*/,
374        rpc_prot_mgmt_epv_p_t       * /*mgmt__epv*/,
375        rpc_prot_binding_epv_p_t    * /*binding__epv*/,
376        rpc_prot_network_epv_p_t    * /*network__epv*/,
377        rpc_prot_fork_handler_fn_t  * /*fork_handler*/,
378        unsigned32                  * /*st*/
379    );
380
381/*
382 * Declarations of the RPC Protocol Service init routines.
383 */
384void rpc__cn_init_func(void);
385
386void rpc__ncacn_init (
387        rpc_prot_call_epv_p_t       * /*call_epv*/,
388        rpc_prot_mgmt_epv_p_t       * /*mgmt_epv*/,
389        rpc_prot_binding_epv_p_t    * /*binding_epv*/,
390        rpc_prot_network_epv_p_t    * /*network_epv*/,
391        rpc_prot_fork_handler_fn_t  * /*fork_handler*/,
392        unsigned32                  * /*st*/
393    );
394
395void rpc__ncadg_init (
396        rpc_prot_call_epv_p_t       * /*call_epv*/,
397        rpc_prot_mgmt_epv_p_t       * /*mgmt_epv*/,
398        rpc_prot_binding_epv_p_t    * /*binding_epv*/,
399        rpc_prot_network_epv_p_t    * /*network_epv*/,
400        rpc_prot_fork_handler_fn_t  * /*fork_handler*/,
401        unsigned32                  * /*st*/
402    );
403
404void rpc__ncatp_init (
405        rpc_prot_call_epv_p_t       * /*call_epv*/,
406        rpc_prot_mgmt_epv_p_t       * /*mgmt_epv*/,
407        rpc_prot_binding_epv_p_t    * /*binding_epv*/,
408        rpc_prot_network_epv_p_t    * /*network_epv*/,
409        unsigned32                  * /*st*/
410    );
411
412#ifdef __cplusplus
413}
414#endif
415
416#endif /* _COMPROT_H */
417