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** cnasgsm.h 82** 83** FACILITY: 84** 85** Remote Procedure Call (RPC) 86** 87** ABSTRACT: 88** 89** Definitions of types/constants internal to the 90** NCA Connection (cn) Association (as) Group (g) State Machine (sm). 91** 92** 93*/ 94 95 96#ifndef _CNASGSM_H 97#define _CNASGSM_H 1 98/***********************************************************************/ 99/* 100 * R P C _ C N _ A S S O C _ G R P _ S M _ T R C 101 */ 102#ifdef DEBUG 103#define RPC_CN_ASSOC_GRP_SM_TRC(assoc_grp, event_id)\ 104{\ 105 if ((assoc_grp)->grp_flags & RPC_C_CN_ASSOC_GRP_CLIENT)\ 106 {\ 107 RPC_DBG_PRINTF (rpc_e_dbg_cn_state, RPC_C_CN_DBG_ASSOC_GRP_SM_TRACE, \ 108 ("STATE CLIENT GRP: %p state->%s event->%s\n",\ 109 assoc_grp,\ 110 rpc_g_cn_grp_client_states[(assoc_grp)->grp_state.cur_state-RPC_C_CN_STATEBASE],\ 111 rpc_g_cn_grp_client_events[event_id-RPC_C_CN_STATEBASE]));\ 112 }\ 113 else\ 114 {\ 115 RPC_DBG_PRINTF (rpc_e_dbg_cn_state, RPC_C_CN_DBG_ASSOC_GRP_SM_TRACE, \ 116 ("STATE SERVER GRP: %p state->%s event->%s\n",\ 117 assoc_grp,\ 118 rpc_g_cn_grp_server_states[(assoc_grp)->grp_state.cur_state-RPC_C_CN_STATEBASE],\ 119 rpc_g_cn_grp_server_events[event_id-RPC_C_CN_STATEBASE]));\ 120 }\ 121} 122#else 123#define RPC_CN_ASSOC_GRP_SM_TRC(assoc_grp, event_id) 124#endif 125 126 127/***********************************************************************/ 128/* 129 * R P C _ C N _ A S S O C _ G R P _ S M _ T R C _ S T A T E 130 */ 131#ifdef DEBUG 132#define RPC_CN_ASSOC_GRP_SM_TRC_STATE(assoc_grp)\ 133{\ 134 if ((assoc_grp)->grp_flags & RPC_C_CN_ASSOC_GRP_CLIENT)\ 135 {\ 136 RPC_DBG_PRINTF (rpc_e_dbg_cn_state, RPC_C_CN_DBG_ASSOC_GRP_SM_TRACE, \ 137 ("STATE CLIENT GRP: %x new state->%s\n",\ 138 assoc_grp->grp_remid.all,\ 139 rpc_g_cn_grp_client_states[(assoc_grp)->grp_state.cur_state-RPC_C_CN_STATEBASE])); \ 140 }\ 141 else\ 142 {\ 143 RPC_DBG_PRINTF (rpc_e_dbg_cn_state, RPC_C_CN_DBG_ASSOC_GRP_SM_TRACE, \ 144 ("STATE SERVER GRP: %x new state->%s\n",\ 145 assoc_grp->grp_id.all,\ 146 rpc_g_cn_grp_server_states[(assoc_grp)->grp_state.cur_state-RPC_C_CN_STATEBASE])); \ 147 }\ 148} 149#else 150#define RPC_CN_ASSOC_GRP_SM_TRC_STATE(assoc_grp) 151#endif 152 153 154/***********************************************************************/ 155/* 156 * R P C _ C N _ A S S O C _ G R P _ E V A L _ E V E N T 157 * 158 * This macro will be called when association group events are detected. 159 */ 160#define RPC_CN_ASSOC_GRP_EVAL_EVENT(assoc_grp, event_id, event_param, st)\ 161{\ 162 RPC_CN_ASSOC_GRP_SM_TRC (assoc_grp, event_id);\ 163 st = rpc__cn_sm_eval_event ((event_id),\ 164 (dce_pointer_t) (event_param),\ 165 (dce_pointer_t) (assoc_grp),\ 166 &((assoc_grp)->grp_state));\ 167 if ((assoc_grp)->grp_state.cur_state == RPC_C_ASSOC_GRP_CLOSED)\ 168 {\ 169 rpc__cn_assoc_grp_dealloc (assoc_grp->grp_id);\ 170 }\ 171 RPC_CN_ASSOC_GRP_SM_TRC_STATE (assoc_grp); \ 172} 173 174 175/***********************************************************************/ 176/* 177 * R P C _ C N _ A S S O C _ G R P _ I N S E R T _ E V E N T 178 * 179 * This macro will be called when an event is generated inside an 180 * action routine of the association group state machine. 181 */ 182#define RPC_CN_ASSOC_GRP_INSERT_EVENT(assoc_grp, event)\ 183{\ 184 RPC_DBG_PRINTF (rpc_e_dbg_cn_state, RPC_C_CN_DBG_ASSOC_GRP_SM_TRACE, \ 185 ("STATE INSERT EVENT ")); \ 186 RPC_CN_ASSOC_SM_TRC ((assoc_grp), (event)->event_id);\ 187 rpc__cn_sm_insert_event ((event),\ 188 &((assoc_grp)->grp_state));\ 189} 190 191/***********************************************************************/ 192/* 193 * A S S O C G R P E V E N T S 194 */ 195 196/* 197 * Events common to both client and server state machines 198 * 199 * State values are incremented by 100 to distinguish them from 200 * action routine indexes which are all < 100. This was done as 201 * an efficiency measure to the engine, rpc__cn_sm_eval_event(). 202 */ 203#define RPC_C_ASSOC_GRP_NEW 100 204#define RPC_C_ASSOC_GRP_ADD_ASSOC 101 205#define RPC_C_ASSOC_GRP_REM_ASSOC 102 206 207/* 208 * Events only applicable to server state machine 209 */ 210#define RPC_C_ASSOC_GRP_NO_CALLS_IND 103 211 212 213/***********************************************************************/ 214/* 215 * A S S O C G R P S T A T E S 216 */ 217 218/* 219 * States common to both client and server state machines 220 */ 221#define RPC_C_ASSOC_GRP_CLOSED 100 222#define RPC_C_ASSOC_GRP_OPEN 101 223#define RPC_C_ASSOC_GRP_ACTIVE 102 224 225/***********************************************************************/ 226/* 227 * C L I E N T A S S O C G R P S T A T E S 228 */ 229 230#define RPC_C_CLIENT_ASSOC_GRP_STATES 103 231 232/***********************************************************************/ 233/* 234 * C L I E N T A S S O C G R P T A B L E S 235 */ 236EXTERNAL rpc_cn_sm_state_entry_p_t rpc_g_cn_client_grp_sm []; 237EXTERNAL rpc_cn_sm_action_fn_t rpc_g_cn_client_grp_action_tbl []; 238 239#if DEBUG 240EXTERNAL const char *rpc_g_cn_grp_client_events []; 241EXTERNAL const char *rpc_g_cn_grp_client_states []; 242#endif 243 244/***********************************************************************/ 245/* 246 * S E R V E R A S S O C G R P S T A T E S 247 */ 248 249#define RPC_C_SERVER_ASSOC_GRP_CALL_WAIT 103 250#define RPC_C_SERVER_ASSOC_GRP_STATES 104 251 252/***********************************************************************/ 253/* 254 * S E R V E R A S S O C G R P T A B L E S 255 */ 256EXTERNAL rpc_cn_sm_state_entry_p_t rpc_g_cn_server_grp_sm []; 257EXTERNAL rpc_cn_sm_action_fn_t rpc_g_cn_server_grp_action_tbl []; 258 259#if DEBUG 260EXTERNAL const char *rpc_g_cn_grp_server_events []; 261EXTERNAL const char *rpc_g_cn_grp_server_states []; 262#endif 263#endif /* _CNASGSM_H */ 264