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** cnassoc.h 82** 83** FACILITY: 84** 85** Remote Procedure Call (RPC) 86** 87** ABSTRACT: 88** 89** Interface to the NCA Connection Protocol Service's Association Service. 90** 91** 92*/ 93 94#ifndef _CNASSOC_H 95#define _CNASSOC_H 1 96 97/******************************************************************************/ 98/* 99 * R P C _ C N _ A S S O C _ A C B _ I N C _ R E F 100 */ 101 102#ifdef RPC_CN_DEBUG_REFCNT 103static void RPC_CN_ASSOC_ACB_INC_REF(rpc_cn_assoc_t *assoc) 104{ 105 (assoc)->assoc_acb_ref_count++; 106 RPC_DBG_PRINTF (rpc_e_dbg_general, RPC_C_CN_DBG_GENERAL, 107 ("(RPC_CN_ASSOC_ACB_INC_REF) assoc->%x new refcnt->%d\n", 108 assoc, assoc->assoc_acb_ref_count)); 109} 110#else 111#define RPC_CN_ASSOC_ACB_INC_REF(assoc) (assoc)->assoc_acb_ref_count++; 112#endif /* RPC_CN_DEBUG_REFCNT */ 113 114/* 115 * R P C _ C N _ A S S O C _ A C B _ D E C _ R E F 116 */ 117 118#ifdef RPC_CN_DEBUG_REFCNT 119static void RPC_CN_ASSOC_ACB_DEC_REF(rpc_cn_assoc_t *assoc) 120{ 121 (assoc)->assoc_acb_ref_count--; 122 RPC_DBG_PRINTF (rpc_e_dbg_general, RPC_C_CN_DBG_GENERAL, 123 ("(RPC_CN_ASSOC_ACB_DEC_REF) assoc->%x new refcnt->%d\n", 124 assoc, assoc->assoc_acb_ref_count)); 125} 126#else 127#define RPC_CN_ASSOC_ACB_DEC_REF(assoc) (assoc)->assoc_acb_ref_count--; 128#endif /* RPC_CN_DEBUG_REFCNT */ 129 130/* 131 * R P C _ C N _ A S S O C _ G R P 132 */ 133 134#define RPC_CN_ASSOC_GRP(grp_id)\ 135 (RPC_CN_LOCAL_ID_VALID (grp_id)) ?\ 136 &rpc_g_cn_assoc_grp_tbl.assoc_grp_vector[(grp_id).parts.id_index] : NULL; 137 138/* 139 * R P C _ C N _ A S S O C _ S Y N T A X _ E Q U A L 140 */ 141#if (uuid_c_version == 1) 142#define RPC_CN_ASSOC_SYNTAX_EQUAL(s1, s2, st)\ 143 ((memcmp (&((s1)->id), &((s2)->id), sizeof (idl_uuid_t)) == 0) &&\ 144 (((s1)->version & 0xFFFF) == ((s2)->version & 0xFFFF)) &&\ 145 (((s1)->version >> 16) == ((s2)->version >> 16))) 146#else 147error "***Make sure memcmp works on this version of UUIDs***" 148#endif 149 150/* 151 * R P C _ C N _ A S S O C _ C A L L 152 */ 153 154#define RPC_CN_ASSOC_CALL(assoc) (assoc)->call_rep 155 156/* 157 * R P C _ C N _ A S S O C _ M A X _ X M I T _ F R A G 158 */ 159 160#define RPC_CN_ASSOC_MAX_XMIT_FRAG(assoc) (assoc)->assoc_max_xmit_frag 161 162/* 163 * R P C _ C N _ A S S O C _ M A X _ R E C V _ F R A G 164 */ 165 166#define RPC_CN_ASSOC_MAX_RECV_FRAG(assoc) (assoc)->assoc_max_recv_frag 167 168/* 169 * R P C _ C N _ A S S O C _ C O N T E X T _ I D 170 */ 171 172#define RPC_CN_ASSOC_CONTEXT_ID(assoc) (assoc)->assoc_pres_context_id 173 174/* 175 * R P C _ C N _ A S S O C _ N D R _ F O R M A T 176 */ 177 178#define RPC_CN_ASSOC_NDR_FORMAT(assoc) (assoc)->assoc_remote_ndr_format 179 180/* 181 * R P C _ C N _ A S S O C _ S E C U R I T Y 182 */ 183 184#define RPC_CN_ASSOC_SECURITY(assoc) &(assoc)->security 185 186/* 187 * R P C _ C N _ A S S O C _ W A K E U P 188 */ 189 190#define RPC_CN_ASSOC_WAKEUP(assoc) rpc__cn_assoc_queue_dummy_frag(assoc); 191 192/* 193 * R P C _ C N _ A S S O C _ C A N C E L _ A N D _ W A K E U P 194 */ 195 196#define RPC_CN_ASSOC_CANCEL_AND_WAKEUP(assoc)\ 197{\ 198 RPC_CALL_LOCK (((rpc_call_rep_t *) assoc->call_rep));\ 199 rpc__cthread_cancel (((rpc_call_rep_t *) assoc->call_rep));\ 200 rpc__cn_assoc_queue_dummy_frag(assoc);\ 201 RPC_CALL_UNLOCK (((rpc_call_rep_t *) assoc->call_rep));\ 202} 203 204 205/******************************************************************************/ 206/* 207 * R P C _ _ C N _ A S S O C _ R E Q U E S T 208 */ 209 210rpc_cn_assoc_t *rpc__cn_assoc_request ( 211 rpc_cn_call_rep_p_t /* call_r */, 212 rpc_cn_binding_rep_p_t /* binding_r */, 213 rpc_if_rep_p_t /* if_r */, 214 rpc_transfer_syntax_t * /* syntax */, 215 unsigned16 * /* context_id */, 216 rpc_cn_sec_context_p_t * /* sec */, 217 unsigned32 * /* st */ ); 218 219/* 220 * R P C _ _ C N _ A S S O C _ L I S T E N 221 */ 222 223rpc_cn_assoc_t *rpc__cn_assoc_listen ( 224 rpc_socket_t /* newsock */, 225 unsigned_char_p_t /* endpoint */, 226 unsigned32 * /* st */ ); 227 228/* 229 * R P C _ _ C N _ A S S O C _ A L L O C 230 */ 231 232PRIVATE void rpc__cn_assoc_alloc ( 233 rpc_cn_assoc_p_t /* assoc */, 234 unsigned32 * /* st */ ); 235 236/* 237 * R P C _ _ C N _ A S S O C _ D E A L L O C 238 */ 239 240PRIVATE void rpc__cn_assoc_dealloc ( 241 rpc_cn_assoc_p_t /* assoc */, 242 rpc_cn_call_rep_p_t /* call_rep */, 243 unsigned32 * /* st */ ); 244 245/* 246 * R P C _ _ C N _ A S S O C _ A B O R T 247 */ 248 249void rpc__cn_assoc_abort ( 250 rpc_cn_assoc_p_t /* assoc */, 251 unsigned32 * /* st */ ); 252 253/* 254 * R P C _ _ C N _ A S S O C _ P O P _ C A L L 255 */ 256 257PRIVATE rpc_cn_call_rep_t *rpc__cn_assoc_pop_call ( 258 rpc_cn_assoc_p_t /* assoc */, 259 rpc_cn_call_rep_p_t /* call_rep */ ); 260 261/* 262 * R P C _ _ C N _ A S S O C _ P U S H _ C A L L 263 */ 264 265PRIVATE void rpc__cn_assoc_push_call ( 266 rpc_cn_assoc_p_t /* assoc */, 267 rpc_cn_call_rep_p_t /* call_r */, 268 unsigned32 * /* st */ ); 269 270/* 271 * R P C _ _ C N _ A S S O C _ Q U E U E _ F R A G 272 */ 273 274PRIVATE void rpc__cn_assoc_queue_frag ( 275 rpc_cn_assoc_p_t /* assoc */, 276 rpc_cn_fragbuf_p_t /* fragbuf */, 277 boolean32 /* signal */ ); 278 279/* 280 * R P C _ _ C N _ A S S O C _ Q U E U E _ D U M M Y _ F R A G 281 */ 282 283PRIVATE void rpc__cn_assoc_queue_dummy_frag ( 284 rpc_cn_assoc_p_t /* assoc */ ); 285 286/* 287 * R P C _ _ C N _ A S S O C _ R E C E I V E _ F R A G 288 */ 289 290PRIVATE void rpc__cn_assoc_receive_frag ( 291 rpc_cn_assoc_p_t /* assoc */, 292 rpc_cn_fragbuf_p_t * /* frag_buf */, 293 unsigned32 * /* st */ ); 294 295/* 296 * R P C _ _ C N _ A S S O C _ S E N D _ F R A G 297 */ 298 299PRIVATE void rpc__cn_assoc_send_frag ( 300 rpc_cn_assoc_p_t /* assoc */, 301 rpc_iovector_p_t /* iovector */, 302 rpc_cn_sec_context_p_t /* sec */, 303 unsigned32 * /* st */ ); 304 305/* 306 * R P C _ _ C N _ A S S O C _ S E N D _ F R A G B U F 307 */ 308 309PRIVATE void rpc__cn_assoc_send_fragbuf ( 310 rpc_cn_assoc_p_t /* assoc */, 311 rpc_cn_fragbuf_p_t /* fragbuf */, 312 rpc_cn_sec_context_p_t /* sec */, 313 boolean32 /* freebuf */, 314 unsigned32 * /* st */ ); 315 316/* 317 * R P C _ _ C N _ A S S O C _ S Y N T A X _ F R E E 318 */ 319 320PRIVATE void rpc__cn_assoc_syntax_free ( 321 rpc_cn_syntax_p_t */* syntax */ ); 322 323/* 324 * R P C _ _ C N _ A S S O C _ S Y N T A X _ N E G O T I A T E 325 */ 326 327PRIVATE void rpc__cn_assoc_syntax_negotiate ( 328 rpc_cn_assoc_p_t /* assoc */, 329 rpc_cn_pres_cont_list_p_t /* pres_cont_list */, 330 unsigned32 * /* size */, 331 rpc_cn_pres_result_list_t * /* pres_result_list */, 332 unsigned32 * /* st */ ); 333 334/* 335 * R P C _ _ C N _ A S S O C _ S Y N T A X _ L K U P _ B Y _ I D 336 */ 337 338PRIVATE void rpc__cn_assoc_syntax_lkup_by_id ( 339 rpc_cn_assoc_p_t /* assoc */, 340 unsigned32 /* context_id */, 341 rpc_cn_syntax_p_t * /* pres_context */, 342 unsigned32 * /* st */ ); 343 344/* 345 * R P C _ _ C N _ A S S O C _ S Y N T A X _ L K U P _ B Y _ C L 346 */ 347 348PRIVATE void rpc__cn_assoc_syntax_lkup_by_cl ( 349 rpc_cn_assoc_p_t /* assoc */, 350 unsigned32 /* call_id */, 351 rpc_cn_syntax_p_t * /* pres_context */, 352 unsigned32 * /* st */ ); 353 354/* 355 * R P C _ _ C N _ A S S O C _ S E C _ L K U P _ B Y _ I D 356 */ 357 358PRIVATE void rpc__cn_assoc_sec_lkup_by_id ( 359 rpc_cn_assoc_p_t /* assoc */, 360 unsigned32 /* key_id */, 361 rpc_cn_sec_context_p_t * /* sec */, 362 unsigned32 * /* st */ ); 363 364/* 365 * R P C _ _ C N _ A S S O C _ S E C _ L K U P _ B Y _ CL 366 */ 367 368PRIVATE void rpc__cn_assoc_sec_lkup_by_cl ( 369 rpc_cn_assoc_p_t /* assoc */, 370 unsigned32 /* call_id */, 371 rpc_cn_sec_context_p_t * /* sec */, 372 unsigned32 * /* st */ ); 373 374/* 375 * R P C _ _ C N _ A S S O C _ S E C _ A L L O C 376 */ 377 378PRIVATE rpc_cn_sec_context_t *rpc__cn_assoc_sec_alloc ( 379 rpc_auth_info_p_t /* info */, 380 unsigned32 * /* st */ ); 381 382/* 383 * R P C _ _ C N _ A S S O C _ S E C _ F R E E 384 */ 385 386PRIVATE void rpc__cn_assoc_sec_free ( 387 rpc_cn_sec_context_p_t */* sec */ ); 388 389/* 390 * R P C _ _ C N _ A S S O C _ P O S T _ E R R O R 391 */ 392 393PRIVATE void rpc__cn_assoc_post_error ( 394 rpc_cn_assoc_p_t /* assoc */, 395 unsigned32 /* st */ ); 396 397/* 398 * R P C _ _ C N _ A S S O C _ S M _ P R O T O C O L _ E R R O R 399 */ 400 401PRIVATE unsigned32 rpc__cn_assoc_sm_protocol_error ( 402 dce_pointer_t /* spc_struct */, 403 dce_pointer_t /* event_param */, 404 dce_pointer_t /* sm */ ); 405 406/* 407 * R P C _ _ C N _ A S S O C _ S T A T U S _ T O _ P R E J 408 */ 409 410PRIVATE unsigned32 rpc__cn_assoc_status_to_prej ( 411 unsigned32 /* prej */ ); 412 413/* 414 * R P C _ _ C N _ A S S O C _ P R E J _ T O _ S T A T U S 415 */ 416 417PRIVATE unsigned32 rpc__cn_assoc_prej_to_status ( 418 unsigned32 /* prej */ ); 419 420/* 421 * R P C _ _ C N _ A S S O C _ P P R O V _ T O _ S T A T U S 422 */ 423 424PRIVATE unsigned32 rpc__cn_assoc_pprov_to_status ( 425 unsigned32 /* pprov */ ); 426 427/* 428 * R P C _ _ C N _ A S S O C _ A C B _ C R E A T E 429 */ 430 431void rpc__cn_assoc_acb_create ( rpc_cn_assoc_p_t/* assoc */ ); 432 433/* 434 * R P C _ _ C N _ A S S O C _ A C B _ F R E E 435 */ 436 437void rpc__cn_assoc_acb_free ( rpc_cn_assoc_p_t /* assoc */ ); 438 439/* 440 * R P C _ _ C N _ A S S O C _ A C B _ D E A L L O C 441 */ 442 443PRIVATE void rpc__cn_assoc_acb_dealloc (rpc_cn_assoc_p_t/* assoc */ ); 444 445/* 446 * R P C _ _ C N _ A S S O C _ G R P _ A L L O C 447 */ 448 449PRIVATE rpc_cn_local_id_t rpc__cn_assoc_grp_alloc ( 450 rpc_addr_p_t /* rpc_addr */, 451 rpc_transport_info_p_t /* prot_info */, 452 unsigned32 /* type */, 453 unsigned32 /* rem_id */, 454 unsigned32 * /* st */ ); 455 456/* 457 * R P C _ _ C N _ A S S O C _ G R P _ D E A L L O C 458 */ 459 460PRIVATE void rpc__cn_assoc_grp_dealloc ( 461 rpc_cn_local_id_t /* grp_id */ ); 462 463/* 464 * R P C _ _ C N _ A S S O C _ G R P _ A D D _ A S S O C 465 */ 466 467PRIVATE void rpc__cn_assoc_grp_add_assoc ( 468 rpc_cn_local_id_t /* grp_id */, 469 rpc_cn_assoc_p_t /* assoc */ ); 470 471/* 472 * R P C _ _ C N _ A S S O C _ G R P _ R E M _ A S S O C 473 */ 474 475PRIVATE void rpc__cn_assoc_grp_rem_assoc ( 476 rpc_cn_local_id_t /* grp_id */, 477 rpc_cn_assoc_p_t /* assoc */ ); 478 479/* 480 * R P C _ _ C N _ A S S O C _ G R P _ L K U P _ B Y _ A D D R 481 */ 482 483PRIVATE rpc_cn_local_id_t rpc__cn_assoc_grp_lkup_by_addr ( 484 rpc_addr_p_t /* rpc_addr */, 485 rpc_transport_info_p_t /* transport_info */, 486 unsigned32 /* type */, 487 unsigned32 * /* st */ ); 488 489/* 490 * R P C _ _ C N _ A S S O C _ G R P _ L K U P _ B Y _ R E M I D 491 */ 492 493PRIVATE rpc_cn_local_id_t rpc__cn_assoc_grp_lkup_by_remid ( 494 unsigned32 /* rem_id */, 495 unsigned32 /* type */, 496 rpc_addr_p_t /* rpc_addr */, 497 unsigned32 * /* st */ ); 498 499/* 500 * R P C _ _ C N _ A S S O C _ G R P _ L K U P _ B Y _ I D 501 */ 502 503PRIVATE rpc_cn_local_id_t rpc__cn_assoc_grp_lkup_by_id ( 504 rpc_cn_local_id_t /* grp_id */, 505 unsigned32 /* type */, 506 rpc_transport_info_p_t transport_info, 507 unsigned32 * /* st */ ); 508 509/* 510 * R P C _ _ C N _ A S S O C _ G R P _ T B L _ I N I T 511 */ 512 513PRIVATE void rpc__cn_assoc_grp_tbl_init (void); 514 515/* 516 * R P C _ _ C N _ G R P _ S M _ P R O T O C O L _ E R R O R 517 */ 518 519PRIVATE unsigned32 rpc__cn_grp_sm_protocol_error ( 520 dce_pointer_t /* spc_struct */, 521 dce_pointer_t /* event_param */, 522 dce_pointer_t /* sm */); 523 524#endif 525