1/* 2 * FSM pseudo code used in the design/implementation of the CC PTMP monitor. 3 * 4 * The CCBSStatusRequest messages are handled independently from this FSM. 5 * 6 * The CCBSInterrogate/CCNRInterrogate messages are initiated by a dialplan 7 * application/AMI/CLI (future) and are handled outside of this FSM. 8 */ 9FSM CC_PTMP_Monitor 10{ 11 State CC_STATE_IDLE { 12 Stimulus CC_EVENT_AVAILABLE { 13 /* 14 * Before event is posted: 15 * Received CallInfoRetain 16 * Created cc_record 17 * Saved CallLinkageID 18 */ 19 Action Pass_Up_CC_Available; 20 Next_State CC_STATE_AVAILABLE; 21 } 22 Stimulus CC_EVENT_CANCEL { 23 Action Set_Selfdestruct; 24 } 25 } 26 State CC_STATE_AVAILABLE { 27 /* 28 * The upper layer is responsible for canceling the CC available 29 * offering as a safeguard in case the network cable is disconnected. 30 * The timer should be set much longer than the network T_RETENTION 31 * timer so normally the CC records will be cleaned up by network 32 * activity. 33 */ 34 Stimulus CC_EVENT_CC_REQUEST { 35 /* cc_record->is_ccnr is set before event posted. */ 36 Action Queue_CC_Request; 37 Action Start_T_ACTIVATE; 38 Next_State CC_STATE_REQUESTED; 39 } 40 Stimulus CC_EVENT_TIMEOUT_T_RETENTION { 41 /* 42 * Received EraseCallLinkageID 43 * T_RETENTION expired on the network side so we will pretend 44 * that it expired on our side. 45 */ 46 Action Pass_Up_CC_Cancel; 47 Action Set_Selfdestruct; 48 Next_State CC_STATE_IDLE; 49 } 50 Stimulus CC_EVENT_CANCEL { 51 Action Set_Selfdestruct; 52 Next_State CC_STATE_IDLE; 53 } 54 } 55 State CC_STATE_REQUESTED { 56 Stimulus CC_EVENT_CC_REQUEST_ACCEPT { 57 /* 58 * Before event is posted: 59 * Received CCBSRequest/CCNRRequest response 60 * Saved CCBSReference 61 */ 62 Action Relese_LinkID; 63 Action Pass_Up_CC_Req_Rsp_Success; 64 Action Stop_T_ACTIVATE; 65 /* 66 * Start T_CCBS2 or T_CCNR2 depending upon CC mode. 67 * For PTMP TE mode these timers are not defined. However, 68 * we will use them anyway to protect our resources from leaks 69 * caused by the network cable being disconnected. These 70 * timers should be set much longer than the network 71 * so normally the CC records will be cleaned up by network 72 * activity. 73 */ 74 Action Start_T_SUPERVISION; 75 Next_State CC_STATE_ACTIVATED; 76 } 77 Stimulus CC_EVENT_CC_REQUEST_FAIL { 78 Action Pass_Up_CC_Req_Rsp_Fail(error/reject, code); 79 Action Pass_Up_CC_Cancel; 80 Action Stop_T_ACTIVATE; 81 Action Set_Selfdestruct; 82 Next_State CC_STATE_IDLE; 83 } 84 Stimulus CC_EVENT_TIMEOUT_T_ACTIVATE { 85 Action Pass_Up_CC_Req_Rsp_Timeout; 86 Action Pass_Up_CC_Cancel; 87 Action Stop_T_ACTIVATE; 88 Action Set_Selfdestruct; 89 Next_State CC_STATE_IDLE; 90 } 91 Stimulus CC_EVENT_LINK_CANCEL { 92 /* Received CCBSErase */ 93 /* Claim it was a timeout */ 94 Action Pass_Up_CC_Req_Rsp_Timeout; 95 Action Pass_Up_CC_Cancel; 96 Action Stop_T_ACTIVATE; 97 Action Set_Selfdestruct; 98 Next_State CC_STATE_IDLE; 99 } 100 Stimulus CC_EVENT_CANCEL { 101 Next_State CC_STATE_WAIT_DESTRUCTION; 102 } 103 } 104 State CC_STATE_WAIT_DESTRUCTION { 105 /* We were in the middle of a cc-request when we were asked to cancel. */ 106 Stimulus CC_EVENT_CC_REQUEST_ACCEPT { 107 /* 108 * Before event is posted: 109 * Received CCBSRequest/CCNRRequest response 110 * Saved CCBSReference 111 */ 112 Action Send_CC_Deactivate_Req; 113 Action Stop_T_ACTIVATE; 114 Action Set_Selfdestruct; 115 Next_State CC_STATE_IDLE; 116 } 117 Stimulus CC_EVENT_CC_REQUEST_FAIL { 118 Action Stop_T_ACTIVATE; 119 Action Set_Selfdestruct; 120 Next_State CC_STATE_IDLE; 121 } 122 Stimulus CC_EVENT_TIMEOUT_T_ACTIVATE { 123 Action Stop_T_ACTIVATE; 124 Action Set_Selfdestruct; 125 Next_State CC_STATE_IDLE; 126 } 127 Stimulus CC_EVENT_LINK_CANCEL { 128 /* Received CCBSErase */ 129 Action Stop_T_ACTIVATE; 130 Action Set_Selfdestruct; 131 Next_State CC_STATE_IDLE; 132 } 133 } 134 State CC_STATE_ACTIVATED { 135 Stimulus CC_EVENT_B_FREE { 136 /* Received CCBSBFree */ 137 Action Pass_Up_B_Free; 138 } 139 Stimulus CC_EVENT_REMOTE_USER_FREE { 140 /* Received CCBSRemoteUserFree */ 141 Action Pass_Up_Remote_User_Free; 142 Next_State CC_STATE_WAIT_CALLBACK; 143 } 144 Stimulus CC_EVENT_TIMEOUT_T_SUPERVISION { 145 Action Send_CC_Deactivate_Req; 146 Action Pass_Up_CC_Cancel; 147 Action Stop_T_SUPERVISION; 148 Action Set_Selfdestruct; 149 Next_State CC_STATE_IDLE; 150 } 151 Stimulus CC_EVENT_LINK_CANCEL { 152 /* Received CCBSErase */ 153 Action Pass_Up_CC_Cancel; 154 Action Stop_T_SUPERVISION; 155 Action Set_Selfdestruct; 156 Next_State CC_STATE_IDLE; 157 } 158 Stimulus CC_EVENT_CANCEL { 159 Action Send_CC_Deactivate_Req; 160 Action Stop_T_SUPERVISION; 161 Action Set_Selfdestruct; 162 Next_State CC_STATE_IDLE; 163 } 164 } 165 State CC_STATE_WAIT_CALLBACK { 166 Stimulus CC_EVENT_STOP_ALERTING { 167 Action Pass_Up_Stop_Alerting; 168 Next_State CC_STATE_ACTIVATED; 169 } 170 Stimulus CC_EVENT_RECALL { 171 /* The original call parameters have already been set. */ 172 Action Queue_SETUP_Recall; 173 Next_State CC_STATE_CALLBACK; 174 } 175 Stimulus CC_EVENT_TIMEOUT_T_SUPERVISION { 176 Action Send_CC_Deactivate_Req; 177 Action Pass_Up_CC_Cancel; 178 Action Stop_T_SUPERVISION; 179 Action Set_Selfdestruct; 180 Next_State CC_STATE_IDLE; 181 } 182 Stimulus CC_EVENT_LINK_CANCEL { 183 /* Received CCBSErase */ 184 Action Pass_Up_CC_Cancel; 185 Action Stop_T_SUPERVISION; 186 Action Set_Selfdestruct; 187 Next_State CC_STATE_IDLE; 188 } 189 Stimulus CC_EVENT_CANCEL { 190 Action Send_CC_Deactivate_Req; 191 Action Stop_T_SUPERVISION; 192 Action Set_Selfdestruct; 193 Next_State CC_STATE_IDLE; 194 } 195 } 196 State CC_STATE_CALLBACK { 197 /* 198 * We are waiting for the CC records to be torn down because 199 * CC is complete. 200 * This state is mainly to block CC_EVENT_STOP_ALERTING since 201 * we are the one doing the CC recall so we do not need to stop 202 * alerting. 203 */ 204 Stimulus CC_EVENT_TIMEOUT_T_SUPERVISION { 205 Action Send_CC_Deactivate_Req; 206 Action Pass_Up_CC_Cancel; 207 Action Stop_T_SUPERVISION; 208 Action Set_Selfdestruct; 209 Next_State CC_STATE_IDLE; 210 } 211 Stimulus CC_EVENT_LINK_CANCEL { 212 /* Received CCBSErase */ 213 Action Pass_Up_CC_Cancel; 214 Action Stop_T_SUPERVISION; 215 Action Set_Selfdestruct; 216 Next_State CC_STATE_IDLE; 217 } 218 Stimulus CC_EVENT_CANCEL { 219 Action Send_CC_Deactivate_Req; 220 Action Stop_T_SUPERVISION; 221 Action Set_Selfdestruct; 222 Next_State CC_STATE_IDLE; 223 } 224 } 225} 226