//========================================= // // // Author: Zane Yi // Date: 2007.02.01 // //========================================= #include "./include/inc.h" #include "./include/isup_if.h" #include "./include/isup_struct.h" #include "./include/isup_debug.h" #include "./include/isup_def.h" #include "./include/isup_const.h" #include "./include/isup_msg.h" static void isup_cpc_clear(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; port_ptr->fsm_state.cpc_state = 0; port_ptr->cic_state.call_state = IDLE_FLAG; port_ptr->trace_flag = 0; return; } static void set_cause(SiCauseDgn *cause_ptr, u8 val, u8 location) { cause_ptr->pres = 1; cause_ptr->location = location; //(4)public network serving the remote user cause_ptr->cdeStand = 0; //CCITT standardized coding cause_ptr->causeVal = val; } static int isup_cpcoblocking_func(u32 start_pid, const SiRangStat *rs_ptr) { int i,temp,range; u32 pid; temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; range = temprange ? temp : rs_ptr->range; for(i = 0; i <= range; i++) { pid = start_pid + i; if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) { if(isup_db.port_pond[pid].cic_state.call_state==CALLOUT_FLAG) { isup_db.port_pond[pid].internal_cmd = CMD_BLO|SI_MGBR; isup_cpc_proc(pid); isup_db.port_pond[pid].internal_cmd = 0; } } } return 1; } static int isup_blrblocking_func(u32 start_pid, const SiRangStat *rs_ptr) { int i,temp,range; u32 pid; temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; range = temprange ? temp : rs_ptr->range; for(i = 0; i <= range; i++) { pid = start_pid + i; if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) { isup_db.port_pond[pid].internal_cmd = CMD_BLO|SI_MGBR; isup_blr_proc(pid); isup_db.port_pond[pid].internal_cmd = 0; } } return 1; } static int isup_blrunblocking_func(u32 start_pid, const SiRangStat *rs_ptr) { int i,temp,range; u32 pid; temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; range = temprange ? temp : rs_ptr->range; for(i = 0; i <= range; i++) { pid = start_pid + i; if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) { isup_db.port_pond[pid].internal_cmd = CMD_UNBLO|SI_MGBR; isup_blr_proc(pid); isup_db.port_pond[pid].internal_cmd = 0; } } return 1; } static int isup_blsblocking_func(u32 start_pid, const SiRangStat *rs_ptr) { int i,temp,range; u32 pid; temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; range = temprange ? temp : rs_ptr->range; for(i = 0; i <= range; i++) { pid = start_pid + i; if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) { isup_db.port_pond[pid].internal_cmd = CMD_BLO|SI_MGBS; isup_bls_proc(pid); isup_db.port_pond[pid].internal_cmd = 0; } } return 1; } static int isup_blsunblocking_func(u32 start_pid, const SiRangStat *rs_ptr) { int i,temp,range; u32 pid; temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; range = temprange ? temp : rs_ptr->range; for(i = 0; i <= range; i++) { pid = start_pid + i; if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) { isup_db.port_pond[pid].internal_cmd = CMD_UNBLO|SI_MGBS; isup_bls_proc(pid); isup_db.port_pond[pid].internal_cmd = 0; } } return 1; } static int isup_cgrr_func(u32 start_pid, const SiRangNoStat *rs_ptr) { int i,temp,range; u32 pid; temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; range = temprange ? temp : rs_ptr->range; memset(isup_db.port_pond[start_pid].status_field,0,ISUP_STATUS_LEN); for(i = 0; i <= range; i++) { pid = start_pid + i; if (isup_db.port_pond[pid].cic_state.blo_state & M_REMOTE_BLOCK) //Remotely blocked { isup_db.port_pond[pid].internal_cmd = CMD_UNBLO|SI_CGRR; isup_blr_proc(pid); isup_db.port_pond[pid].internal_cmd = 0; } if(isup_db.port_pond[pid].cic_state.blo_state & M_LOCAL_BLOCK) //Locally blocked { if(isup_db.port_pond[pid].fsm_state.mgbs_state != MGBS_WAIT_CGUA) isup_db.port_pond[start_pid].status_field[i>>3] |= 0x01 << (i&0x07); } } isup_db.port_pond[start_pid].gourp_range = range; for(i = 0; i <= range; i++)//indeed! { pid = start_pid + i; isup_db.port_pond[pid].internal_cmd = CMD_RESET|SI_CGRR; isup_cpc_proc(pid); isup_db.port_pond[pid].internal_cmd = 0; } return 1; } static int isup_cgrs_func(u32 start_pid, u8 range, u8 flag) { int i,temp; u32 pid; temp = ISUP_CIRCUIT_CIC-start_pid%ISUP_CIRCUIT_CIC -1; range = temprange ? temp : rs_ptr->range; for(i = 0; i <= range; i++) { pid = start_pid + i; if((rs_ptr->status[i>>3]>>(i&0x07)) & 0x01) isup_db.port_pond[pid].internal_cmd = CMD_BLO|SI_CGRS; else isup_db.port_pond[pid].internal_cmd = CMD_UNBLO|SI_CGRS; isup_db.port_pond[pid].cic_state.call_state = IDLE_FLAG; isup_blr_proc(pid); isup_db.port_pond[pid].internal_cmd = 0; } return 1; } static int get_priority(pid) { int circuit_id; const pal_circuit_struct* circuit_str; const pal_cg_struct* cg_str; circuit_id = pid/ISUP_CIRCUIT_CIC; circuit_str = pal_circuit_ptr(circuit_id); cg_str = pal_cg_ptr(circuit_str->cg_id); if(cg_str == NULL) return -1; return cg_str->attrib.priority; } int isup_event_handle(u32 pid, u8 primitive, u8 eventType) { int offset,circuit_id; Pst pst; EventHandle_struct *event_handle; const pal_circuit_struct* circuit_str; const pal_cg_struct* cg_str; const pal_sap_struct* sap_str; pst.sp_proc_id = pid; pst.su_proc_id = isup_db.port_pond[pid].su_proc_id; circuit_id = pid/ISUP_CIRCUIT_CIC; offset = pid%ISUP_CIRCUIT_CIC; circuit_str = pal_circuit_ptr(circuit_id); if(circuit_str == NULL) { isup_log_err(pid,"circuit_str==NULL\r\n"); return -1; } cg_str = pal_cg_ptr(circuit_str->cg_id); if(cg_str == NULL) { isup_log_err(pid,"cg_str==NULL\r\n"); return -1; } sap_str = pal_sap_ptr(cg_str->sap_id); if(sap_str == NULL) { isup_log_err(pid,"sap_str==NULL\r\n"); return -1; } pst.cic = circuit_str->attrib.head_cic + offset; pst.cg_id = circuit_str->cg_id; pst.tg_id = cg_str->attrib.tg_id; event_handle = &(sap_str->attrib.event_handle); switch(primitive) { case ISUP_SETUP_IND: { if (event_handle->h_isup_setup_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_setup_ind\r\n"); event_handle->h_isup_setup_ind(&pst, &isup_rv_pdus.m.initAddr, isup_rv_msg.msgList, isup_rv_msg.len); isup_db.port_pond[pid].su_proc_id = pst.su_proc_id; isup_db.port_pond[pid].trace_flag = pst.trace_flag; } else isup_log_err(pid,"Setup indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_SETUP_CNF: { if(eventType == EN_CON) { if(event_handle->h_isup_setup_con_cnf != NULL) { isup_trace_func(pid,"APP => function trace: isup_setup_ind\r\n"); event_handle->h_isup_setup_con_cnf(&pst, &isup_rv_pdus.m.connect, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Setup confirm handle is not registered@%s\r\n", __FUNCTION__); break; } else { if(event_handle->h_isup_setup_anm_cnf != NULL) { isup_trace_func(pid,"APP => function trace: isup_setup_anm_cnf\r\n"); event_handle->h_isup_setup_anm_cnf(&pst, &isup_rv_pdus.m.answer, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Setup confirm handle is not registered@%s\r\n", __FUNCTION__); break; } } case ISUP_RELEASE_IND: { if(event_handle->h_isup_release_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_release_ind\r\n"); event_handle->h_isup_release_ind(&pst, &isup_rv_pdus.m.release, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Release indication handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_RELEASE_CNF: { if(event_handle->h_isup_release_cnf != NULL) { isup_trace_func(pid,"APP => function trace: isup_release_cnf\r\n"); event_handle->h_isup_release_cnf(&pst, &isup_rv_pdus.m.relComplete, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Release confirm handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_ALERT_IND: { if(event_handle->h_isup_alert_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_alert_ind\r\n"); event_handle->h_isup_alert_ind(&pst, &isup_rv_pdus.m.addrComp, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Alert indication handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_INFO_IND: { if(event_handle->h_isup_info_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_info_ind\r\n"); event_handle->h_isup_info_ind(&pst, &isup_rv_pdus.m.subAddr, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Information indication handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_PROG_IND: { if(event_handle->h_isup_prog_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_prog_ind\r\n"); event_handle->h_isup_prog_ind(&pst, &isup_rv_pdus.m.caProg, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Call progress indication handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_SUSPEND_IND: { if(event_handle->h_isup_suspend_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_suspend_ind\r\n"); event_handle->h_isup_suspend_ind(&pst, &isup_rv_pdus.m.suspend, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Suspend indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_RESUME_IND: { if(event_handle->h_isup_resume_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_resume_ind\r\n"); event_handle->h_isup_resume_ind(&pst, &isup_rv_pdus.m.resume, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Resume indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_REATTEMPT_IND: { if(event_handle->h_isup_reattempt_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_reattempt_ind\r\n"); event_handle->h_isup_reattempt_ind(&pst); } else isup_log_err(pid,"Reattempt indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_FAILURE_IND: { if(event_handle->h_isup_failure_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_failure_ind\r\n"); event_handle->h_isup_failure_ind(&pst); } else isup_log_err(pid,"Failure indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_MAINTENANCE_IND: { if(event_handle->h_isup_maintenance_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_maintenance_ind\r\n"); switch(eventType) { case EN_NONE: break; case EN_T5_TIMEOUT: pst.su_proc_id = isup_db.port_pond[pid].su_proc_id; event_handle->h_isup_maintenance_ind(&pst,eventType); default: pst.su_proc_id = isup_db.port_pond[pid].sm_proc_id; event_handle->h_isup_maintenance_ind(&pst,eventType); break; } } else isup_log_err(pid,"Maintenance indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_STARTRESET_IND: { if(event_handle->h_isup_startreset_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_startreset_ind\r\n"); event_handle->h_isup_startreset_ind(&pst); } else isup_log_err(pid,"StartReset indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_DATA_IND: { if(event_handle->h_isup_data_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_data_ind\r\n"); event_handle->h_isup_data_ind(&pst, eventType, &isup_rv_pdus, isup_rv_msg.msgList, isup_rv_msg.len); } else isup_log_err(pid,"Data indicate handle is not registered@%s\r\n", __FUNCTION__); break; } //M case ISUP_BLOCK_IND: { if(event_handle->h_isup_block_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_block_ind\r\n"); if(eventType == EN_GROUP) event_handle->h_isup_block_ind(&pst, &isup_rv_pdus.m.cirGrpBlk); else event_handle->h_isup_block_ind(&pst, NULL); } else isup_log_err(pid,"Block indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_BLOCK_CNF: { if(event_handle->h_isup_block_cnf != NULL) { isup_trace_func(pid,"APP => function trace: isup_block_cnf\r\n"); pst.su_proc_id = isup_db.port_pond[pid].sm_proc_id; if(eventType == EN_GROUP) event_handle->h_isup_block_cnf(&pst, &isup_rv_pdus.m.cirGrpBlkAck); else event_handle->h_isup_block_cnf(&pst, NULL); } else isup_log_err(pid,"Block confirm handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_UNBLOCK_IND: { if(event_handle->h_isup_unblock_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_unblock_ind\r\n"); if(eventType == EN_GROUP) event_handle->h_isup_unblock_ind(&pst, &isup_rv_pdus.m.cirGrpUnblk); else event_handle->h_isup_unblock_ind(&pst, NULL); } else isup_log_err(pid,"Unblock indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_UNBLOCK_CNF: { if(event_handle->h_isup_unblock_cnf != NULL) { isup_trace_func(pid,"APP => function trace: isup_unblock_cnf\r\n"); pst.su_proc_id = isup_db.port_pond[pid].sm_proc_id; if(eventType == EN_GROUP) event_handle->h_isup_unblock_cnf(&pst, &isup_rv_pdus.m.cirGrpUblkAck); else event_handle->h_isup_unblock_cnf(&pst, NULL); } else isup_log_err(pid,"Unblock confirm handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_RESET_IND: { if(event_handle->h_isup_reset_ind != NULL) { isup_trace_func(pid,"APP => function trace: isup_reset_ind\r\n"); if(eventType == EN_GROUP) event_handle->h_isup_reset_ind(&pst, &isup_rv_pdus.m.cirGrpRes); else event_handle->h_isup_reset_ind(&pst, NULL); } else isup_log_err(pid,"Reset indicate handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_RESET_CNF: { if(event_handle->h_isup_reset_cnf != NULL) { isup_trace_func(pid,"APP => function trace: isup_reset_cnf\r\n"); pst.su_proc_id = isup_db.port_pond[pid].sm_proc_id; if(eventType == EN_GROUP) event_handle->h_isup_reset_cnf(&pst, &isup_rv_pdus.m.cirGrpResAck); else event_handle->h_isup_reset_cnf(&pst, NULL); } else isup_log_err(pid,"Reset confirm handle is not registered@%s\r\n", __FUNCTION__); break; } case ISUP_STOP_CNF: { // if(event_handle->h_isup_stop_cnf != NULL) // { isup_trace_func(pid,"APP => function trace: isup_stop_cnf\r\n"); // event_handle->h_isup_stop_cnf(&pst); // } // else // isup_log_err(pid,"Stop confirm handle is not registered@%s\r\n", __FUNCTION__); break; } default: break; } return 1; } void isup_cpc_proc(u32 pid) { u8 call_state; ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; call_state= port_ptr->cic_state.call_state; if(call_state==CALLOUT_FLAG) isup_cpco_proc(pid); else isup_cpci_proc(pid); } void isup_cpc_timer(u32 pid) { u16 timer_flag; ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; timer_flag= port_ptr->timer_flag; if(timer_flag&CALLIN_FLAG) isup_cpci_timer(pid); else if(timer_flag&CALLOUT_FLAG) isup_cpco_timer(pid); return; } void isup_cpci_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; int circuit_id,variant; const pal_circuit_struct* circuit_str; const pal_cg_struct* cg_str; circuit_id = pid/ISUP_CIRCUIT_CIC; circuit_str = pal_circuit_ptr(circuit_id); if(circuit_str == NULL) { isup_log_err(pid,"circuit_str==NULL\r\n"); return; } cg_str = pal_cg_ptr(circuit_str->cg_id); if(cg_str == NULL) { isup_log_err(pid,"cg_str==NULL\r\n"); return; } variant = cg_str->attrib.variant; switch(port_ptr->fsm_state.cpc_state) { case CPCI_IDLE: { if(port_ptr->sprc_cmd == M_IAM) { port_ptr->sprc_cmd = 0; if(isup_rv_pdus.m.initAddr.cgPtyCat.cgPtyCat!=TEST_CALL) { if (port_ptr->cic_state.blo_state & M_REMOTE_BLOCK) //Remotely blocked { port_ptr->internal_cmd = CMD_UNBLO|SI_CPCI; isup_blr_proc(pid); port_ptr->internal_cmd = 0; } if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK) //Locally blocked { port_ptr->internal_cmd = CMD_BLO|SI_CPCI; isup_bls_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); break; } } port_ptr->fsm_state.cpc_state = CPCI_WAIT_ACM; isup_event_handle(pid, ISUP_SETUP_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; isup_sd_pdus.m.relComplete.causeDgn.pres = 0; isup_send_msg(pid,M_RLC); isup_cpc_clear(pid); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; isup_log_err(pid,"Discard pid=%ld\r\n",pid); isup_cpc_clear(pid); } else if(port_ptr->sprc_cmd != 0) //Unexpected message { port_ptr->sprc_cmd = 0; port_ptr->internal_cmd = CMD_RESET|SI_CPCI; isup_crs_proc(pid); port_ptr->internal_cmd = 0; isup_log_err(pid,"unexpected message cpci idle pid=%ld\r\n",pid); isup_cpc_clear(pid); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; isup_crr_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { // port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; isup_cgrr_proc(pid); isup_cpc_clear(pid); } break; } case CPCI_WAIT_CONTINUITY: break; case CPCI_WAIT_ACM: { if(port_ptr->primitive_cmd == ISUP_ALERT_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_ACM); port_ptr->fsm_state.cpc_state = CPCI_WAIT_ANM; } else if(port_ptr->primitive_cmd == ISUP_SETUP_RSP) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_CON); port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; } else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) { port_ptr->primitive_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; isup_send_msg(pid,M_REL); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_SAM) { port_ptr->sprc_cmd = 0; isup_event_handle(pid, ISUP_INFO_IND, EN_NONE); } else if(port_ptr->sprc_cmd != 0) { port_ptr->sprc_cmd = 0; port_ptr->internal_cmd = CMD_RESET|SI_CPCI; isup_crs_proc(pid); port_ptr->internal_cmd = 0; isup_log_err(pid,"unexpected message cpci wait acm pid=%ld",pid); isup_cpc_clear(pid); isup_event_handle(pid, ISUP_STARTRESET_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } // else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBS)) // { // port_ptr->internal_cmd = 0; // isup_cpc_clear(pid); // isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); // } break; } case CPCI_WAIT_ANM: { if(port_ptr->primitive_cmd == ISUP_SETUP_RSP) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_ANM); port_ptr->timer_flag &= ~(CALLIN_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; } else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) { port_ptr->primitive_cmd = 0; port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; isup_send_msg(pid,M_REL); port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; } else if(port_ptr->primitive_cmd == ISUP_PROG_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_CPG); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if((port_ptr->sprc_cmd == M_SUS) && (variant == VARIANT_UK)) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; port_ptr->re_cause = 0x6f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } break; } case CPCI_ANSWERED: { if(port_ptr->primitive_cmd == ISUP_SUSPEND_REQ) { port_ptr->primitive_cmd = 0; port_ptr->cic_state.sus_state = ISUP_TERM_SUSPEND; isup_send_msg(pid,M_SUS); port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; } else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; isup_send_msg(pid,M_REL); port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; } else if(port_ptr->primitive_cmd == ISUP_PROG_REQ)//supplementary service { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_CPG); } else if(port_ptr->sprc_cmd == M_SUS) { port_ptr->sprc_cmd = 0; port_ptr->cic_state.sus_state = ISUP_ORIG_SUSPEND; port_ptr->fsm_state.cpc_state = CPCI_SUSPENDED; isup_event_handle(pid, ISUP_SUSPEND_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_CPG) //supplementary service { port_ptr->sprc_cmd = 0; isup_event_handle(pid, ISUP_PROG_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } break; } case CPCI_SUSPENDED: { if(port_ptr->primitive_cmd == ISUP_RESUME_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_RES); if(port_ptr->cic_state.sus_state == ISUP_TERM_SUSPEND) port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; } else if(port_ptr->primitive_cmd == ISUP_SUSPEND_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_SUS); } else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) { port_ptr->primitive_cmd = 0; port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; isup_send_msg(pid,M_REL); port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; } else if(port_ptr->sprc_cmd == M_RES) { port_ptr->sprc_cmd = 0; if(port_ptr->cic_state.sus_state == ISUP_ORIG_SUSPEND) port_ptr->fsm_state.cpc_state = CPCI_ANSWERED; isup_event_handle(pid, ISUP_RESUME_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_SUS) { port_ptr->sprc_cmd = 0; isup_event_handle(pid, ISUP_SUSPEND_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_REL_COMP; isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.cpc_state = CPCI_WAIT_GROUP_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } break; } case CPCI_WAIT_RLC: { if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLIN_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; isup_sd_pdus.m.relComplete.causeDgn.pres = 0; isup_send_msg(pid,M_RLC); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; isup_crr_proc(pid); port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLIN_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { // port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; port_ptr->timer_flag &= ~(CALLIN_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); isup_cgrr_proc(pid); isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLIN_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); } break; } case CPCI_WAIT_REL_COMP: { if(port_ptr->primitive_cmd == ISUP_RELEASE_RSP) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_RLC); isup_cpc_clear(pid); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; isup_crr_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { // port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; isup_cgrr_proc(pid); isup_cpc_clear(pid); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } break; } case CPCI_WAIT_RESET: { if(port_ptr->primitive_cmd == ISUP_RESET_RSP) { port_ptr->primitive_cmd = 0; port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; isup_crr_proc(pid); isup_cgrr_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } } break; case CPCI_WAIT_GROUP_RESET: { if(port_ptr->primitive_cmd == ISUP_RESET_RSP) { port_ptr->primitive_cmd = 0; port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCI; isup_crr_proc(pid); isup_cgrr_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } break; } default: break; } return; } void isup_cpci_timer(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.cpc_state) { case CPCI_WAIT_RLC: { if(++(port_ptr->w_time)%isup_timer_var.t1==0) { if(port_ptr->w_time%isup_timer_var.t5==0) { port_ptr->timer_flag &= ~(CALLIN_FLAG); port_ptr->internal_cmd = CMD_RESET|SI_CPCI; isup_crs_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T5_TIMEOUT); return; } else { set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); } } } default: break; } return; } void isup_cpco_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; int circuit_id,variant; const pal_circuit_struct* circuit_str; const pal_cg_struct* cg_str; circuit_id = pid/ISUP_CIRCUIT_CIC; circuit_str = pal_circuit_ptr(circuit_id); if(circuit_str == NULL) { isup_log_err(pid,"circuit_str==NULL\r\n"); return; } cg_str = pal_cg_ptr(circuit_str->cg_id); if(cg_str == NULL) { isup_log_err(pid,"cg_str==NULL\r\n"); return; } variant = cg_str->attrib.variant; switch(port_ptr->fsm_state.cpc_state) { case CPCO_IDLE: if(port_ptr->primitive_cmd == ISUP_SETUP_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_IAM); port_ptr->timer_flag |= CALLOUT_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_ACM; } else isup_cpc_clear(pid); break; case CPCO_WAIT_CONTINUITY: break; case CPCO_WAIT_ACM: if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag |= CALLOUT_FLAG; port_ptr->w_time = 0; port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; isup_send_msg(pid,M_REL); port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; } else if(port_ptr->primitive_cmd == ISUP_INFO_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_SAM); port_ptr->timer_flag |= CALLOUT_FLAG; port_ptr->w_time = 0; } else if(port_ptr->sprc_cmd == M_ACM) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= CALLOUT_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_ANM; isup_event_handle(pid, ISUP_ALERT_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_CON) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; isup_event_handle(pid, ISUP_SETUP_CNF, EN_CON); } else if(port_ptr->sprc_cmd == M_ANM) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; isup_event_handle(pid, ISUP_SETUP_CNF, EN_ANM); } else if(port_ptr->sprc_cmd == M_CPG) { isup_log_err(pid,"Discard M_CPG\r\n"); port_ptr->sprc_cmd = 0; //discard... } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= CALLOUT_FLAG; port_ptr->w_time = 0; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_IAM) { if(get_priority(pid)==0) //reattempt { port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); port_ptr->cic_state.call_state = CALLIN_FLAG; isup_event_handle(pid, ISUP_REATTEMPT_IND, EN_NONE); isup_cpci_proc(pid); break; } isup_log_err(pid,"Priority high,Discard IAM\r\n"); port_ptr->sprc_cmd = 0; } else if(port_ptr->sprc_cmd != 0) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->internal_cmd = CMD_RESET|SI_CPCO; isup_crs_proc(pid); port_ptr->internal_cmd = 0; isup_log_err(pid,"unexpected message cpco wait acm\r\n"); isup_event_handle(pid, ISUP_REATTEMPT_IND, EN_NONE); isup_cpc_clear(pid); } else if((port_ptr->internal_cmd & 0x0F) == CMD_BLO) { port_ptr->internal_cmd = 0; port_ptr->timer_flag |= CALLOUT_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_REATTEMPT_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; isup_event_handle(pid, ISUP_REATTEMPT_IND, EN_NONE); port_ptr->primitive_cmd = ISUP_RESET_RSP; isup_cpc_proc(pid); port_ptr->primitive_cmd = 0; } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); } break; case CPCO_WAIT_ANM: if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) { port_ptr->timer_flag |= (CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; port_ptr->primitive_cmd = 0; port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; isup_send_msg(pid,M_REL); } else if(port_ptr->sprc_cmd == M_ANM) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; isup_event_handle(pid, ISUP_SETUP_CNF,EN_ANM); } else if(port_ptr->sprc_cmd == M_CPG) { port_ptr->sprc_cmd = 0; isup_event_handle(pid, ISUP_PROG_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= (CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if((port_ptr->sprc_cmd == M_SUS) && (variant == VARIANT_UK)) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= CALLIN_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; port_ptr->re_cause = 0x6f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); } break; case CPCO_ANSWERED: if(port_ptr->primitive_cmd == ISUP_SUSPEND_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_SUS); port_ptr->cic_state.sus_state = ISUP_ORIG_SUSPEND; port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; } else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) { port_ptr->primitive_cmd = 0; port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; isup_send_msg(pid,M_REL); port_ptr->timer_flag |= (CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; } else if(port_ptr->primitive_cmd == ISUP_PROG_REQ)//supplementary service { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_CPG); } else if(port_ptr->sprc_cmd == M_SUS) { port_ptr->sprc_cmd = 0; port_ptr->cic_state.sus_state = ISUP_TERM_SUSPEND; port_ptr->fsm_state.cpc_state = CPCO_SUSPENDED; isup_event_handle(pid, ISUP_SUSPEND_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_CPG) //supplementary service { port_ptr->sprc_cmd = 0; isup_event_handle(pid, ISUP_PROG_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= (CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); } break; case CPCO_SUSPENDED: if(port_ptr->primitive_cmd == ISUP_RESUME_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_RES); if(port_ptr->cic_state.sus_state == ISUP_ORIG_SUSPEND) port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; } else if(port_ptr->primitive_cmd == ISUP_SUSPEND_REQ) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_SUS); } else if(port_ptr->primitive_cmd == ISUP_RELEASE_REQ) { port_ptr->primitive_cmd = 0; port_ptr->re_cause = isup_sd_pdus.m.release.causeDgn.causeVal; port_ptr->re_location = isup_sd_pdus.m.release.causeDgn.location; isup_send_msg(pid,M_REL); port_ptr->timer_flag |= (CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; } else if(port_ptr->sprc_cmd == M_RES) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; if(port_ptr->cic_state.sus_state == ISUP_TERM_SUSPEND) port_ptr->fsm_state.cpc_state = CPCO_ANSWERED; isup_event_handle(pid, ISUP_RESUME_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_SUS) { port_ptr->sprc_cmd = 0; isup_event_handle(pid, ISUP_SUSPEND_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_REL_COMP; isup_event_handle(pid, ISUP_RELEASE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= (CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_GROUP_RESET; isup_event_handle(pid, ISUP_RESET_IND, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); } break; case CPCO_WAIT_RLC: if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); } else if(port_ptr->sprc_cmd == M_REL) { port_ptr->sprc_cmd = 0; isup_sd_pdus.m.relComplete.causeDgn.pres = 0; isup_send_msg(pid,M_RLC); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; isup_crr_proc(pid); port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; // port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; isup_cgrr_proc(pid); port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->w_time = 0; isup_cpc_clear(pid); isup_event_handle(pid, ISUP_RELEASE_CNF, EN_NONE); } break; case CPCO_WAIT_REL_COMP: if(port_ptr->primitive_cmd == ISUP_RELEASE_RSP) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_RLC); isup_cpc_clear(pid); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CRR)) { port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; isup_crr_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->fsm_state.cpc_state = CPCO_WAIT_RESET; // port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; isup_cgrr_proc(pid); isup_cpc_clear(pid); } else if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } break; case CPCO_WAIT_RESET: if(port_ptr->primitive_cmd == ISUP_RESET_RSP) { port_ptr->primitive_cmd = 0; port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; isup_crr_proc(pid); isup_cgrr_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } break; case CPCO_WAIT_GROUP_RESET: if(port_ptr->primitive_cmd == ISUP_RESET_RSP) { port_ptr->primitive_cmd = 0; port_ptr->internal_cmd = CMD_RESET_COMP|SI_CPCO; isup_crr_proc(pid); isup_cgrr_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); } break; default: break; } return; } void isup_cpco_timer(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.cpc_state) { case CPCO_WAIT_ACM: if(++(port_ptr->w_time)%isup_timer_var.t7==0) { port_ptr->w_time = 0; port_ptr->fsm_state.cpc_state = CPCO_WAIT_RLC; port_ptr->re_cause = 0x1f; port_ptr->re_location = 4; set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); isup_event_handle(pid, ISUP_FAILURE_IND, EN_NONE); } break; case CPCO_WAIT_RLC: if(++(port_ptr->w_time)%isup_timer_var.t1==0) { if(port_ptr->w_time%isup_timer_var.t5==0) { port_ptr->timer_flag &= ~(CALLOUT_FLAG); port_ptr->internal_cmd = CMD_RESET|SI_CPCO; isup_crs_proc(pid); port_ptr->internal_cmd = 0; isup_cpc_clear(pid); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T5_TIMEOUT); } else { set_cause(&isup_sd_pdus.m.release.causeDgn, port_ptr->re_cause,port_ptr->re_location); isup_send_msg(pid,M_REL); } } break; default: break; } return; } void isup_csc_timer(u32 pid) { u16 timer_flag; ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; timer_flag= port_ptr->timer_flag; if(timer_flag&BLS_FLAG) isup_bls_timer(pid); if(timer_flag&MGBS_FLAG) isup_mgbs_timer(pid); if(timer_flag&CRS_FLAG) isup_crs_timer(pid); if(timer_flag&CGRS_FLAG) isup_cgrs_timer(pid); return; } void isup_bls_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.bls_state) { case BLS_IDLE: { if(port_ptr->primitive_cmd == ISUP_BLOCK_REQ) { port_ptr->primitive_cmd = 0; port_ptr->fsm_state.bls_state = BLS_WAIT_BLA; port_ptr->internal_cmd = CMD_BLO|SI_BLS; isup_cpc_proc(pid); port_ptr->internal_cmd = 0; port_ptr->timer_flag |= BLS_FLAG; port_ptr->w_time = 0; isup_send_msg(pid,M_BLO); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_BLA) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.bls_state = BLS_WAIT_UBA; port_ptr->timer_flag |= BLS_FLAG; port_ptr->w_time = 0; isup_send_msg(pid,M_UBL); } else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBS)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; } break; } case BLS_WAIT_BLA: { if(port_ptr->sprc_cmd == M_BLA) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(BLS_FLAG); port_ptr->w_time = 0; port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; if(port_ptr->w_time>=isup_timer_var.t13) isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); isup_event_handle(pid, ISUP_BLOCK_CNF, EN_NONE); } else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag &= ~(BLS_FLAG); port_ptr->w_time = 0; port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); port_ptr->fsm_state.bls_state = BLS_IDLE; isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_CRS) || port_ptr->internal_cmd == (CMD_UNBLO|SI_CGRS)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(BLS_FLAG); port_ptr->w_time = 0; port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); port_ptr->fsm_state.bls_state = BLS_IDLE; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBS)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(BLS_FLAG); port_ptr->w_time = 0; port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; if(port_ptr->w_time>=isup_timer_var.t13) isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_BLO|SI_CRR) || port_ptr->internal_cmd == (CMD_BLO|SI_CPCI)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag |= BLS_FLAG; port_ptr->w_time = 0; isup_send_msg(pid,M_BLO); } break; } case BLS_LOCAL_LOCKED: { if(port_ptr->sprc_cmd == M_UBA) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag |= BLS_FLAG; port_ptr->w_time = 0; isup_send_msg(pid,M_BLO); port_ptr->fsm_state.bls_state = BLS_WAIT_BLA; } else if(port_ptr->primitive_cmd == ISUP_UNBLOCK_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag |= BLS_FLAG; port_ptr->w_time = 0; isup_send_msg(pid,M_UBL); port_ptr->fsm_state.bls_state = BLS_WAIT_UBA; } else if(port_ptr->internal_cmd == (CMD_BLO|SI_CRR) || port_ptr->internal_cmd == (CMD_BLO|SI_CPCI)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag |= BLS_FLAG; port_ptr->w_time = 0; isup_send_msg(pid,M_BLO); port_ptr->fsm_state.bls_state = BLS_WAIT_BLA; } else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_CRS) || port_ptr->internal_cmd == (CMD_UNBLO|SI_CGRS)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); port_ptr->fsm_state.bls_state = BLS_IDLE; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_MGBS)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); port_ptr->fsm_state.bls_state = BLS_IDLE; } break; } case BLS_WAIT_UBA: { if(port_ptr->sprc_cmd == M_UBA) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(BLS_FLAG); port_ptr->w_time = 0; port_ptr->cic_state.blo_state &= ~(M_LOCAL_BLOCK); port_ptr->fsm_state.bls_state = BLS_IDLE; if(port_ptr->w_time>=isup_timer_var.t15) isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); isup_event_handle(pid, ISUP_UNBLOCK_CNF, EN_NONE); } else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag &= ~(BLS_FLAG); port_ptr->w_time = 0; port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBS)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(BLS_FLAG); port_ptr->w_time = 0; port_ptr->cic_state.blo_state |= M_LOCAL_BLOCK; port_ptr->fsm_state.bls_state = BLS_LOCAL_LOCKED; } break; } } return; } void isup_bls_timer(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.bls_state) { case BLS_WAIT_BLA: { if(++(port_ptr->w_time)%isup_timer_var.t12==0) { if(port_ptr->w_timew_time%isup_timer_var.t13==0) { isup_send_msg(pid,M_BLO); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T13_TIMEOUT); } } } break; case BLS_WAIT_UBA: { if(++(port_ptr->w_time)%isup_timer_var.t14==0) { if(port_ptr->w_timew_time%isup_timer_var.t15==0) { isup_send_msg(pid,M_UBL); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T15_TIMEOUT); } } break; } } return; } void isup_blr_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.blr_state) { case BLR_IDLE: { if(port_ptr->sprc_cmd == M_BLO) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.blr_state = BLR_WAIT_BLOCKING_RESP; port_ptr->internal_cmd = CMD_BLO|SI_BLR; isup_cpc_proc(pid); port_ptr->internal_cmd = 0; isup_event_handle(pid, ISUP_BLOCK_IND, EN_NONE); } else if(port_ptr->sprc_cmd == M_UBL) { port_ptr->sprc_cmd = 0; port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); port_ptr->fsm_state.blr_state = BLR_IDLE; isup_send_msg(pid,M_UBA); } else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBR)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; } else if(port_ptr->internal_cmd == (CMD_BLO|SI_CGRS)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } break; } case BLR_WAIT_BLOCKING_RESP: { if(port_ptr->primitive_cmd == ISUP_BLOCK_RSP) { port_ptr->primitive_cmd = 0; port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; isup_send_msg(pid,M_BLA); } else if(port_ptr->sprc_cmd == M_UBL) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.blr_state = BLR_WAIT_UNBLOCKING_RESP; isup_event_handle(pid, ISUP_UNBLOCK_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_BLO|SI_CGRS)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBR)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; } else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_CRR) || port_ptr->internal_cmd == (CMD_UNBLO|SI_CRS) || port_ptr->internal_cmd == (CMD_UNBLO|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); port_ptr->fsm_state.blr_state = BLR_IDLE; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_CLEAR_BLR); } break; } case BLR_REMOTE_LOCKED: { if(port_ptr->sprc_cmd == M_BLO) { port_ptr->sprc_cmd = 0; isup_send_msg(pid,M_BLA); } else if(port_ptr->sprc_cmd == M_UBL) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.blr_state = BLR_WAIT_UNBLOCKING_RESP; isup_event_handle(pid, ISUP_UNBLOCK_IND, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_MGBR)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); port_ptr->fsm_state.blr_state = BLR_IDLE; } else if((port_ptr->internal_cmd & 0x0F) == CMD_UNBLO) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); port_ptr->fsm_state.blr_state = BLR_IDLE; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_CLEAR_BLR); } break; } case BLR_WAIT_UNBLOCKING_RESP: { if(port_ptr->sprc_cmd == M_BLO) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.blr_state = BLR_WAIT_BLOCKING_RESP; isup_event_handle(pid, ISUP_BLOCK_IND, EN_NONE); } else if(port_ptr->primitive_cmd == ISUP_UNBLOCK_RSP) { port_ptr->primitive_cmd = 0; port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); port_ptr->fsm_state.blr_state = BLR_IDLE; isup_send_msg(pid,M_UBA); } else if(port_ptr->internal_cmd == (CMD_UNBLO|SI_CRR) || port_ptr->internal_cmd == (CMD_UNBLO|SI_CGRR)|| port_ptr->internal_cmd == (CMD_UNBLO|SI_MGBR)|| port_ptr->internal_cmd == (CMD_UNBLO|SI_CRS)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state &= ~(M_REMOTE_BLOCK); port_ptr->fsm_state.blr_state = BLR_IDLE; } else if(port_ptr->internal_cmd == (CMD_BLO|SI_MGBR)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; } else if(port_ptr->internal_cmd == (CMD_BLO|SI_CGRS)) { port_ptr->internal_cmd = 0; port_ptr->cic_state.blo_state |= M_REMOTE_BLOCK; port_ptr->fsm_state.blr_state = BLR_REMOTE_LOCKED; isup_event_handle(pid, ISUP_BLOCK_IND, EN_NONE); } break; } } return; } void isup_mgbr_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.mgbr_state) { case MGBR_IDLE: if(port_ptr->sprc_cmd == M_CGB) { port_ptr->sprc_cmd = 0; if((isup_rv_pdus.m.cirGrpBlk.rangStat.range > 0) && (isup_rv_pdus.m.cirGrpBlk.rangStat.range <= 31)) { port_ptr->fsm_state.mgbr_state = MGBR_WAIT_BLOCKING_RESP; isup_cpcoblocking_func(pid,&isup_rv_pdus.m.cirGrpBlk.rangStat); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); isup_event_handle(pid, ISUP_BLOCK_IND, EN_GROUP); } } else if(port_ptr->sprc_cmd == M_CGU) { port_ptr->sprc_cmd = 0; if((isup_rv_pdus.m.cirGrpBlk.rangStat.range > 0) && (isup_rv_pdus.m.cirGrpBlk.rangStat.range <= 31)) { port_ptr->fsm_state.mgbr_state = MGBR_WAIT_UNBLOCKING_RESP; isup_event_handle(pid, ISUP_UNBLOCK_IND, EN_GROUP); } } break; case MGBR_WAIT_BLOCKING_RESP: if((port_ptr->internal_cmd & 0x0F) == CMD_RESET) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.mgbr_state = MGBR_IDLE; } else if(port_ptr->primitive_cmd == ISUP_BLOCK_RSP) { port_ptr->primitive_cmd = 0; isup_send_msg(pid,M_CGBA); isup_blrblocking_func(pid,&isup_sd_pdus.m.cirGrpBlkAck.rangStat); port_ptr->fsm_state.mgbr_state = MGBR_IDLE; } break; case MGBR_WAIT_UNBLOCKING_RESP: if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRR)) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.mgbr_state = MGBR_IDLE; } else if(port_ptr->primitive_cmd == ISUP_UNBLOCK_RSP) { port_ptr->primitive_cmd = 0; isup_blrunblocking_func(pid,&isup_sd_pdus.m.cirGrpUblkAck.rangStat); isup_send_msg(pid,M_CGUA); port_ptr->fsm_state.mgbr_state = MGBR_IDLE; } break; default: break; } return; } void isup_mgbs_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.mgbs_state) { case MGBS_IDLE: if(port_ptr->primitive_cmd ==ISUP_BLOCK_REQ) { port_ptr->primitive_cmd = 0; isup_blsblocking_func(pid,&isup_sd_pdus.m.cirGrpBlk.rangStat); port_ptr->re_typeInd = isup_sd_pdus.m.cirGrpBlk.cgsmti.typeInd; memcpy(&port_ptr->re_rangStat,&isup_sd_pdus.m.cirGrpBlk.rangStat,sizeof(SiRangStat)); isup_send_msg(pid,M_CGB); port_ptr->timer_flag |= MGBS_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGBA; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } else if(port_ptr->primitive_cmd == ISUP_UNBLOCK_REQ) { port_ptr->primitive_cmd = 0; port_ptr->re_typeInd = isup_sd_pdus.m.cirGrpUnblk.cgsmti.typeInd; memcpy(&port_ptr->re_rangStat,&isup_sd_pdus.m.cirGrpUnblk.rangStat,sizeof(SiRangStat)); isup_send_msg(pid,M_CGU); port_ptr->timer_flag |= MGBS_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.mgbs_state = MGBS_WAIT_CGUA; } else if(port_ptr->sprc_cmd == M_CGBA) { port_ptr->sprc_cmd = 0; isup_log_err(pid,"Discard M_CGBA\r\n"); //discard } else if(port_ptr->sprc_cmd == M_CGUA) { port_ptr->sprc_cmd = 0; isup_log_err(pid,"Discard M_CGUA\r\n"); //discard } break; case MGBS_WAIT_CGBA: if(port_ptr->sprc_cmd == M_CGBA) { port_ptr->sprc_cmd = 0; if(port_ptr->w_time>=isup_timer_var.t19) isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); port_ptr->timer_flag &= ~(MGBS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.mgbs_state = MGBS_IDLE; isup_event_handle(pid, ISUP_BLOCK_CNF, EN_GROUP); } else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag &= ~(MGBS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.mgbs_state = MGBS_IDLE; isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); } else if (port_ptr->internal_cmd == (CMD_RESET|SI_CGRS)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(MGBS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.mgbs_state = MGBS_IDLE; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } break; case MGBS_WAIT_CGUA: if(port_ptr->sprc_cmd == M_CGUA) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(MGBS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.mgbs_state = MGBS_IDLE; isup_blsunblocking_func(pid,&isup_rv_pdus.m.cirGrpUblkAck.rangStat); if(port_ptr->w_time>=isup_timer_var.t21) isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); isup_event_handle(pid, ISUP_UNBLOCK_CNF, EN_GROUP); } else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag &= ~(MGBS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.mgbs_state = MGBS_IDLE; isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); } else if(port_ptr->internal_cmd == (CMD_RESET|SI_CGRS)) { port_ptr->internal_cmd = 0; port_ptr->timer_flag &= ~(MGBS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.mgbs_state = MGBS_IDLE; isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } break; default: break; } return; } void isup_mgbs_timer(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.mgbs_state) { case MGBS_WAIT_CGBA: { if(++(port_ptr->w_time)%isup_timer_var.t18==0) { if(port_ptr->w_timere_typeInd; memcpy(&isup_sd_pdus.m.cirGrpBlk.rangStat,&port_ptr->re_rangStat,sizeof(SiRangStat)); isup_send_msg(pid,M_CGB); } else if(port_ptr->w_time%isup_timer_var.t19==0) { isup_sd_pdus.m.cirGrpBlk.cgsmti.typeInd = port_ptr->re_typeInd; memcpy(&isup_sd_pdus.m.cirGrpBlk.rangStat,&port_ptr->re_rangStat,sizeof(SiRangStat)); isup_send_msg(pid,M_CGB); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T19_TIMEOUT); } } break; } case MGBS_WAIT_CGUA: { if(++(port_ptr->w_time)%isup_timer_var.t20==0) { if(port_ptr->w_timere_typeInd; memcpy(&isup_sd_pdus.m.cirGrpUnblk.rangStat,&port_ptr->re_rangStat,sizeof(SiRangStat)); isup_send_msg(pid,M_CGU); } else if(port_ptr->w_time%isup_timer_var.t21==0) { isup_sd_pdus.m.cirGrpUnblk.cgsmti.typeInd = port_ptr->re_typeInd; memcpy(&isup_sd_pdus.m.cirGrpUnblk.rangStat,&port_ptr->re_rangStat,sizeof(SiRangStat)); isup_send_msg(pid,M_CGU); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_T21_TIMEOUT); } } break; } default: break; } return; } void isup_crs_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.crs_state) { case CRS_IDLE: { if((port_ptr->internal_cmd & 0x0F) == CMD_RESET || port_ptr->primitive_cmd == ISUP_RESET_REQ) { port_ptr->fsm_state.crs_state = CRS_WAIT_REL; port_ptr->timer_flag |= CRS_FLAG; port_ptr->w_time = 0; if(port_ptr->primitive_cmd == ISUP_RESET_REQ) { port_ptr->primitive_cmd = 0; port_ptr->reset_flag = 2; port_ptr->internal_cmd = CMD_RESET|SI_CRS; isup_cpc_proc(pid); port_ptr->internal_cmd = 0; } else { port_ptr->internal_cmd = 0; port_ptr->reset_flag = 0; // isup_event_handle(pid, ISUP_STARTRESET_IND, EN_NONE); } if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK)//Locally block { port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; isup_bls_proc(pid); port_ptr->internal_cmd = 0; } if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK)//Remotely block { port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; isup_blr_proc(pid); port_ptr->internal_cmd = 0; } isup_send_msg(pid,M_RSC); port_ptr->cic_state.call_state = START_RESET; } } break; case CRS_WAIT_REL: if(port_ptr->sprc_cmd == M_RLC) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CRS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.crs_state = CRS_IDLE; port_ptr->cic_state.call_state = IDLE_FLAG; if(port_ptr->reset_flag == 2) isup_event_handle(pid, ISUP_RESET_CNF, EN_NONE); } else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag &= ~(CRS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.crs_state = CRS_IDLE; port_ptr->cic_state.call_state = IDLE_FLAG; isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); } break; default: break; } return; } void isup_crs_timer(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; if(port_ptr->fsm_state.crs_state == CRS_WAIT_REL) { port_ptr->cic_state.call_state = START_RESET; if(++(port_ptr->w_time)%isup_timer_var.t16==0) { if(port_ptr->w_timecic_state.blo_state & M_LOCAL_BLOCK)//Locally block { port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; isup_bls_proc(pid); port_ptr->internal_cmd = 0; } if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK)//Remotely block { port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; isup_blr_proc(pid); port_ptr->internal_cmd = 0; } isup_send_msg(pid,M_RSC); } else if(port_ptr->w_time%isup_timer_var.t17==0) { if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK)//Locally block { port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; isup_bls_proc(pid); port_ptr->internal_cmd = 0; } if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK)//Remotely block { port_ptr->internal_cmd = CMD_UNBLO|SI_CRS; isup_blr_proc(pid); port_ptr->internal_cmd = 0; } isup_send_msg(pid,M_RSC); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } } } return; } void isup_crr_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.crr_state) { case CRR_IDLE: if(port_ptr->sprc_cmd == M_RSC) { port_ptr->sprc_cmd = 0; port_ptr->fsm_state.crr_state = CRR_WAIT_RESPONSE; if(port_ptr->cic_state.blo_state & M_LOCAL_BLOCK)//Locally block { port_ptr->internal_cmd = CMD_BLO|SI_CRR; isup_bls_proc(pid); port_ptr->internal_cmd = 0; } if(port_ptr->cic_state.blo_state & M_REMOTE_BLOCK)//Remotely block { port_ptr->internal_cmd = CMD_UNBLO|SI_CRR; isup_blr_proc(pid); port_ptr->internal_cmd = 0; } port_ptr->internal_cmd = CMD_RESET|SI_CRR; isup_cpc_proc(pid); port_ptr->internal_cmd = 0; } break; case CRR_WAIT_RESPONSE: if((port_ptr->internal_cmd & 0x0F) == CMD_RESET_COMP) { port_ptr->internal_cmd = 0; port_ptr->fsm_state.crr_state = CRR_IDLE; isup_sd_pdus.m.relComplete.causeDgn.pres = 0; isup_send_msg(pid,M_RLC); } break; default: break; } return; } void isup_cgrr_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.cgrr_state) { case CGRR_IDLE: if(port_ptr->sprc_cmd == M_GRS) { port_ptr->sprc_cmd = 0; if((isup_rv_pdus.m.cirGrpRes.rangNoStat.range > 0) && (isup_rv_pdus.m.cirGrpRes.rangNoStat.range <= 31)) { port_ptr->fsm_state.cgrr_state = CGRR_WAIT_GROUP_RESET_COMP; port_ptr->internal_cmd = CMD_RESET|SI_CGRR; isup_mgbr_proc(pid); port_ptr->internal_cmd = 0; isup_cgrr_func(pid,&isup_rv_pdus.m.cirGrpRes.rangNoStat); } } break; case CGRR_WAIT_GROUP_RESET_COMP: isup_sd_pdus.m.cirGrpResAck.rangStat.range = port_ptr->gourp_range; memcpy(&isup_sd_pdus.m.cirGrpResAck.rangStat.status,port_ptr->status_field,ISUP_STATUS_LEN); isup_send_msg(pid,M_GRA); port_ptr->fsm_state.cgrr_state = CGRR_IDLE; break; default: break; } return; } void isup_cgrs_proc(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; switch(port_ptr->fsm_state.cgrs_state) { case CGRS_IDLE: if(port_ptr->primitive_cmd == ISUP_RESET_REQ) { port_ptr->primitive_cmd = 0; port_ptr->fsm_state.cgrs_state = CGRS_WAIT_GRA; port_ptr->internal_cmd = CMD_RESET|SI_CGRS; isup_mgbr_proc(pid); port_ptr->internal_cmd = 0; isup_cgrs_func(pid,isup_sd_pdus.m.cirGrpRes.rangNoStat.range,1); port_ptr->re_range = isup_sd_pdus.m.cirGrpRes.rangNoStat.range; isup_send_msg(pid,M_GRS); port_ptr->timer_flag |= CGRS_FLAG; port_ptr->w_time = 0; port_ptr->fsm_state.cgrs_state = CGRS_WAIT_GRA; } break; case CGRS_WAIT_GRA: if(port_ptr->sprc_cmd == M_GRA) { port_ptr->sprc_cmd = 0; port_ptr->timer_flag &= ~(CGRS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cgrs_state = MGBS_IDLE; isup_cgrsack_func(pid,&isup_rv_pdus.m.cirGrpResAck.rangStat); if(port_ptr->w_time>=isup_timer_var.t23) isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); isup_event_handle(pid, ISUP_RESET_CNF, EN_GROUP); } else if(port_ptr->primitive_cmd == ISUP_STOP_REQ) { port_ptr->primitive_cmd = 0; port_ptr->timer_flag &= ~(CGRS_FLAG); port_ptr->w_time = 0; port_ptr->fsm_state.cgrs_state = MGBS_IDLE; isup_event_handle(pid, ISUP_STOP_CNF, EN_NONE); } break; default: break; } return; } void isup_cgrs_timer(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; if(port_ptr->fsm_state.cgrs_state == CGRS_WAIT_GRA) { if(++(port_ptr->w_time)%isup_timer_var.t22==0) { if(port_ptr->w_timere_range; isup_send_msg(pid,M_GRS); } else if(port_ptr->w_time%isup_timer_var.t23==0) { isup_cgrs_func(pid,isup_sd_pdus.m.cirGrpRes.rangNoStat.range,0); isup_sd_pdus.m.cirGrpRes.rangNoStat.range = port_ptr->re_range; isup_send_msg(pid,M_GRS); isup_event_handle(pid, ISUP_MAINTENANCE_IND, EN_NONE); } } } return; } u8 isup_check_crs_waiting(u32 pid) { ISUP_Port_struct *port_ptr = &isup_db.port_pond[pid]; if(port_ptr->fsm_state.crs_state == CRS_WAIT_REL) return 1; else return 0; }