/******************************************************** * * Message timer support functions for SIP SM * ********************************************************/ void sip_platform_msg_timers_init (void) { static const char fname[] = "sip_platform_msg_timers_init"; static long timer_init_complete = 0; int i; cprTimer_t timer, reg_timer; for (i = 0; i < MAX_CCBS; i++) { if (timer_init_complete) { if ((cprCancelTimer(sipPlatformUISMTimers[i].timer) == CPR_FAILURE) || (cprCancelTimer(sipPlatformUISMTimers[i].reg_timer) == CPR_FAILURE)) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_GENERAL_FUNCTIONCALL_FAILED), fname, "cprCancelTimer"); } } timer = sipPlatformUISMTimers[i].timer; reg_timer = sipPlatformUISMTimers[i].reg_timer; if (sipPlatformUISMTimers[i].message_buffer != NULL) { cpr_free(sipPlatformUISMTimers[i].message_buffer); sipPlatformUISMTimers[i].message_buffer = NULL; sipPlatformUISMTimers[i].message_buffer_len = 0; } memset(&sipPlatformUISMTimers[i], 0, sizeof(sipPlatformUITimer_t)); sipPlatformUISMTimers[i].timer = timer; sipPlatformUISMTimers[i].reg_timer = reg_timer; } timer_init_complete = 1; return; }
/** * cprUpdateTimer * * @brief Updates the expiration time for a running timer * * The cprUpdateTimer function cancels a previously started timer referenced by * the parameter timer and then restarts the same timer with the duration passed * in. * * @param[in] timer - which timer to update * @param[in] duration - how long before timer expires in milliseconds * * @return CPR_SUCCESS or CPR_FAILURE */ cprRC_t cprUpdateTimer (cprTimer_t timer, uint32_t duration) { static const char fname[] = "cprUpdateTimer"; cpr_timer_t *cprTimerPtr; void *timerData; cprTimerPtr = (cpr_timer_t *) timer; if (cprTimerPtr != NULL) { /* Grab data before cancelling timer */ timerData = cprTimerPtr->data; } else { CPR_ERROR("%s - NULL pointer passed in.\n", fname); errno = EINVAL; return CPR_FAILURE; } if (cprCancelTimer(timer) == CPR_SUCCESS) { if (cprStartTimer(timer, duration, timerData) == CPR_SUCCESS) { return CPR_SUCCESS; } else { CPR_ERROR("%s - Failed to start timer %s\n", fname, cprTimerPtr->name); return CPR_FAILURE; } } CPR_ERROR("%s - Failed to cancel timer %s\n", fname, cprTimerPtr->name); return CPR_FAILURE; }
/** * cprDestroyTimer * * @brief Destroys a timer. * * This function will cancel the timer and then destroy it. It sets * all links to NULL and then frees the timer block. * * @param[in] timer - which timer to destroy * * @return CPR_SUCCESS or CPR_FAILURE */ cprRC_t cprDestroyTimer (cprTimer_t timer) { static const char fname[] = "cprDestroyTimer"; cpr_timer_t *cprTimerPtr; cprRC_t rc; //CPR_INFO("cprDestroyTimer:destroying timer=%x\n", timer); cprTimerPtr = (cpr_timer_t *) timer; if (cprTimerPtr != NULL) { rc = cprCancelTimer(timer); if (rc == CPR_SUCCESS) { cprTimerPtr->cprTimerId = 0; cpr_free(cprTimerPtr->u.handlePtr); cpr_free(cprTimerPtr); return CPR_SUCCESS; } else { CPR_ERROR("%s - Cancel of Timer %s failed.\n", fname, cprTimerPtr->name); return CPR_FAILURE; } } /* Bad application! */ CPR_ERROR("%s - NULL pointer passed in.\n", fname); errno = EINVAL; return CPR_FAILURE; }
void sip_platform_msg_timer_stop (int idx) { static const char fname[] = "sip_platform_msg_timer_stop"; if ((idx < MIN_TEL_LINES) || (idx >= MAX_CCBS)) { CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_LINE_NUMBER_INVALID), fname, idx); return; } if ((cprCancelTimer(sipPlatformUISMTimers[idx].timer) == CPR_FAILURE) || (cprCancelTimer(sipPlatformUISMTimers[idx].reg_timer) == CPR_FAILURE)) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), idx, 0, fname, "cprCancelTimer"); return; } sipPlatformUISMTimers[idx].outstanding = FALSE; }
/** ** sip_platform_reg_all_fail_timer_stop * Stops the Reg-All Fail timer * * @param none * * @return SIP_OK if timer could be stopped; else SIP_ERROR * */ int sip_platform_reg_all_fail_timer_stop (void) { static const char fname[] = "sip_platform_reg_all_fail_timer_stop"; if (cprCancelTimer(sipPlatformRegAllFailedTimer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), 0, 0, fname, "cprCancelTimer"); return SIP_ERROR; } return SIP_OK; }
/** ** sip_platform_pass_through_timer_stop * Stops the Pass Through timer * * @param none * * @return SIP_OK if timer could be stopped; else SIP_ERROR * */ int sip_platform_pass_through_timer_stop (void) { static const char fname[] = "sip_platform_pass_through_timer_stop"; if (cprCancelTimer(sipPassThroughTimer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), 0, 0, fname, "cprCancelTimer"); return SIP_ERROR; } return SIP_OK; }
int sip_platform_notify_timer_stop () { static const char fname[] = "sip_platform_notify_timer_stop"; if (cprCancelTimer(sipPlatformNotifyTimer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), 0, 0, fname, "cprCancelTimer"); return SIP_ERROR; } return SIP_OK; }
void sip_platform_msg_timer_subnot_stop (sipPlatformUITimer_t *timer_p) { static const char fname[] = "sip_platform_msg_timer_stop_subnot"; if (timer_p->message_buffer != NULL) { cpr_free(timer_p->message_buffer); timer_p->message_buffer = NULL; } if (cprCancelTimer(timer_p->timer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(DEB_F_PREFIX "%s failed\n", DEB_F_PREFIX_ARGS(SIP_TIMER, fname), "cprCancelTimer"); return; } }
static void dp_do_redial (line_t line, callid_t call_id) { const char fname[] = "dp_do_redial"; DPINT_DEBUG(DEB_F_PREFIX"line=%d call_id=%d\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line, call_id); if (line == 0) { line = dp_get_redial_line(); } //CSCsz63263, use prime line instead if last redialed line is unregistered if(ccsip_is_line_registered(line) == FALSE) { DPINT_DEBUG(DEB_F_PREFIX"line %d unregistered, use line %d instead \n", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line, PRIME_LINE_ID); line = PRIME_LINE_ID; if( ccsip_is_line_registered(line) == FALSE) { DPINT_DEBUG(DEB_F_PREFIX" prime line %d unregistered\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line); return; } } if (g_dp_int.gReDialed[0] == NUL) { DPINT_DEBUG(DEB_F_PREFIX"NO DIAL STRING line=%d call_id=%d\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line, call_id); return; } sstrncpy(g_dp_int.gDialed, g_dp_int.gReDialed, MAX_DIALSTRING); g_dp_int.line = line; g_dp_int.call_id = call_id; g_dp_int.allow_proceed = TRUE; /* * If we are doing redial, then we won't be entering any more digits */ g_dp_int.gDialplanDone = TRUE; (void) cprCancelTimer(g_dp_int.dial_timer); kpml_set_subscription_reject(line, call_id); kpml_flush_quarantine_buffer(line, call_id); cc_dialstring(CC_SRC_GSM, call_id, line, &g_dp_int.gReDialed[0]); }
int sip_platform_subnot_periodic_timer_stop (void) { static const char fname[] = "sip_platform_subnot_periodic_timer_stop"; if (sipPlatformSubNotPeriodicTimer.started == TRUE) { if (cprCancelTimer(sipPlatformSubNotPeriodicTimer.timer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), -1, 0, fname, "cprCancelTimer"); return SIP_ERROR; } } sipPlatformSubNotPeriodicTimer.started = FALSE; return SIP_OK; }
int sip_platform_supervision_disconnect_timer_stop (int idx) { static const char fname[] = "sip_platform_supervision_disconnect_timer_stop"; if ((idx < TEL_CCB_START) || (idx > TEL_CCB_END)) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_LINE_NUMBER_INVALID), fname, idx); return SIP_ERROR; } if (cprCancelTimer(sipPlatformSupervisionTimers[idx].timer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), idx, 0, fname, "cprCancelTimer"); return SIP_ERROR; } return SIP_OK; }
/* * Function: dp_restart_dial_timer() * * Parameters: line - line number * call_id - call indentification * timeout - timeout value for the dial timer * * Description: Start dial timer * * Returns: none */ static void dp_restart_dial_timer (line_t line, callid_t call_id, int timeout) { const char fname[] = "dp_restart_dial_timer"; DPINT_DEBUG(DEB_F_PREFIX"line=%d call_id=%d timeout=%u\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line, call_id, timeout); g_dp_int.timer_info.index.line = line; g_dp_int.timer_info.index.call_id = call_id; if (g_dp_int.dial_timer) { (void) cprCancelTimer(g_dp_int.dial_timer); (void) cprStartTimer(g_dp_int.dial_timer, timeout, &g_dp_int.timer_info); } }
/* * Function: dp_check_plar_warmline() * * Parameters: line - line number * call_id - call indentification * * Description: Check if the line is warmline or plar. Since digit is * detected, cancel the warmline timer. * * Returns: boolean */ static boolean dp_check_plar_warmline (line_t line, callid_t call_id) { /* Check the timeout (timeout==0 for plar) to make sure it is not warm line. * If it is warm line then cancel the timer to stop sending a INV */ if (g_dp_int.empty_rewrite[0] && (g_dp_int.offhook_timeout == 0)) { //plar return (TRUE); } else if (g_dp_int.empty_rewrite[0] && g_dp_int.offhook_timeout) { //warm line (void) cprCancelTimer(g_dp_int.dial_timer); memset(g_dp_int.empty_rewrite, 0, sizeof(g_dp_int.empty_rewrite)); } return (FALSE); }
static void fsm_clear_cac_data (cac_data_t *cac_data) { if (cac_data->cac_fail_timer) { (void) cprCancelTimer(cac_data->cac_fail_timer); (void) cprDestroyTimer(cac_data->cac_fail_timer); } (void) sll_remove(s_cac_list, cac_data); fim_free_event(cac_data->msg_ptr); /* Release buffer too */ cpr_free(cac_data->msg_ptr); cpr_free(cac_data); }
int sip_platform_localexpires_timer_stop (int idx) { static const char fname[] = "sip_platform_localexpires_timer_stop"; if ((idx < MIN_TEL_LINES) || (idx >= MAX_CCBS)) { CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_LINE_NUMBER_INVALID), fname, idx); return SIP_ERROR; } if (cprCancelTimer(sipPlatformUISMLocalExpiresTimers[idx].timer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), idx, 0, fname, "cprCancelTimer"); return SIP_ERROR; } return SIP_OK; }
/* * Function: free_sub_request() * * Parameters: sup_req_p - pointer to subscription request * * Description: removes from LL, cancels timers if necessary and frees the memory * * Returns: void */ static void free_sub_request (pres_subscription_req_t *sub_req_p) { /* * remove the node from the linked list of subscriptions. */ (void) sll_remove(s_pres_req_list, (void *)sub_req_p); /* * If it is a line button subscription, cancel retry-timer if it is running */ if (sub_req_p->app_id > 0) { (void) cprCancelTimer(s_retry_after_timers[sub_req_p->app_id - 1]); } /* * free the memory */ cpr_free(sub_req_p); }
/* * Function: dp_clear_dialing_data() * * Parameters: line - line number * call_id - call indentification * * Description: This routine is called to stop and clean up dialing data. * * * Returns: none */ static void dp_clear_dialing_data (line_t line, callid_t call_id) { const char fname[] = "dp_clear_dialing_data"; DPINT_DEBUG(DEB_F_PREFIX"line=%d call_id=%d\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line, call_id); g_dp_int.call_id = 0; g_dp_int.line = 0; g_dp_int.gDialplanDone = FALSE; g_dp_int.allow_proceed = FALSE; memset(g_dp_int.gDialed, 0, sizeof(g_dp_int.gDialed)); memset(g_dp_int.empty_rewrite, 0, sizeof(g_dp_int.empty_rewrite)); /* Stop interdigit timer */ (void) cprCancelTimer(g_dp_int.dial_timer); /* Flush any collected KPML digits on this line */ //kpml_flush_quarantine_buffer (line, call_id); }
/* * Function: notify_ind_cb() * * Parameters: msg_data - the response data provoded by SIP stack. * * Description: is invoked by SIP stack when it receives a NOTIFY message. it takes * action based on subscription_state and blf state derived from event body. * * Returns: void */ static void notify_ind_cb (ccsip_sub_not_data_t * msg_data) { static const char fname[] = "notify_ind_cb"; int sub_state = msg_data->u.notify_ind_data.subscription_state; sip_subs_state_reason_e reason = msg_data->u.notify_ind_data.subscription_state_reason; uint32_t retry_after = msg_data->u.notify_ind_data.retry_after; int request_id = msg_data->request_id; sub_id_t sub_id = msg_data->sub_id; pres_subscription_req_t *sub_req_p; Presence_ext_t *event_body_p = NULL; uint32_t cseq = msg_data->u.notify_ind_data.cseq; int blf_state; BLF_DEBUG(DEB_F_PREFIX"Entering (subscription_state=%d)", DEB_F_PREFIX_ARGS(BLF, fname), sub_state); /* * memory for event bodies is allocated by sip stack and it is the * responsibility of the user (this module) to free it when it is done with it. */ if ((msg_data->u.notify_ind_data.eventData != NULL) && (msg_data->u.notify_ind_data.eventData->type != EVENT_DATA_PRESENCE)) { BLF_ERROR(MISC_F_PREFIX"NOTIFY does not contain presence body", fname); free_event_data(msg_data->u.notify_ind_data.eventData); msg_data->u.notify_ind_data.eventData = NULL; } event_body_p = (msg_data->u.notify_ind_data.eventData == NULL) ? NULL : &(msg_data->u.notify_ind_data.eventData->u.presence_rpid); if ((s_pres_req_list == NULL) || ((sub_req_p = (pres_subscription_req_t *) sll_find(s_pres_req_list, &request_id)) == NULL)) { /* * since we do not have subscription for this, help SIP stack clean up. * first, post SIPSPI_EV_CC_NOTIFY_RESPONSE so that SIP stack sends 481, then * post SIPSPI_EV_CC_SUBSCRIPTION_TERMINATED so that SIP stack cleans up. */ (void) sub_int_notify_ack(sub_id, SIP_CLI_ERR_CALLEG, cseq); (void) sub_int_subscribe_term(sub_id, TRUE, request_id, CC_SUBSCRIPTIONS_PRESENCE); free_event_data(msg_data->u.notify_ind_data.eventData); BLF_DEBUG(DEB_F_PREFIX"Exiting : subscription does not exist", DEB_F_PREFIX_ARGS(BLF, fname)); return; } /* * post SIPSPI_EV_CC_NOTIFY_RESPONSE. */ (void) sub_int_notify_ack(sub_id, SIP_STATUS_SUCCESS, cseq); /* * check if it is out of sequence NOTIFY, if so, do not use the presence state carried in it. */ if (cseq < sub_req_p->highest_cseq) { free_event_data(msg_data->u.notify_ind_data.eventData); BLF_ERROR(MISC_F_PREFIX"Exiting : out of sequence NOTIFY received", fname); return; } else { sub_req_p->highest_cseq = cseq; } /* * If the Subscription_state is terminated, then ... */ if (sub_state == SUBSCRIPTION_STATE_TERMINATED) { /* * post SIPSPI_EV_CC_SUBSCRIPTION_TERMINATED to SIP stack. */ (void) sub_int_subscribe_term(sub_id, TRUE, sub_req_p->request_id, CC_SUBSCRIPTIONS_PRESENCE); if (reason == SUBSCRIPTION_STATE_REASON_DEACTIVATED) { /* if the reason is "decativated", re-subscribe. */ sub_req_p->sub_id = CCSIP_SUBS_INVALID_SUB_ID; sub_req_p->highest_cseq = 0; /* * post SIPSPI_EV_CC_SUBSCRIBE to SIP stack */ if (send_subscribe_ev_to_sip_task(sub_req_p) != CC_RC_SUCCESS) { /* let platform know that we can not continue */ ui_BLF_notification(request_id, CC_SIP_BLF_REJECTED, sub_req_p->app_id); /* * remove the node from the list of subscriptions. */ free_sub_request(sub_req_p); } } else if ((reason == SUBSCRIPTION_STATE_REASON_TIMEOUT) || (reason == SUBSCRIPTION_STATE_REASON_PROBATION) || (reason == SUBSCRIPTION_STATE_REASON_GIVEUP)) { /* let the app know that susbcription expired so that it can resusbcribe later */ ui_BLF_notification(request_id, CC_SIP_BLF_EXPIRED, sub_req_p->app_id); sub_req_p->blf_state = CC_SIP_BLF_EXPIRED; if (sub_req_p->app_id > 0) { /* * Since it is speeddial/blf, we must send a new subscription. */ sub_req_p->sub_id = CCSIP_SUBS_INVALID_SUB_ID; sub_req_p->highest_cseq = 0; if ((reason == SUBSCRIPTION_STATE_REASON_PROBATION) || (reason == SUBSCRIPTION_STATE_REASON_GIVEUP)) { /* * Start a timer based on retry-after value. If retry-after value is 0, * use a default value of 5 sec */ if (retry_after == 0) { retry_after = DEFAULT_RETRY_AFTER_MILLISECS; } else { retry_after = (retry_after * 1000); // converting into millisecs } if ((cprCancelTimer(s_retry_after_timers[sub_req_p->app_id - 1]) == CPR_SUCCESS) && (cprStartTimer(s_retry_after_timers[sub_req_p->app_id - 1], retry_after, (void *) sub_req_p) == CPR_SUCCESS)) { /* * Timer successfully started. free up event data and return. */ free_event_data(msg_data->u.notify_ind_data.eventData); BLF_DEBUG(DEB_F_PREFIX"Exiting : retry_after Timer started", DEB_F_PREFIX_ARGS(BLF, fname)); return; } } if (send_subscribe_ev_to_sip_task(sub_req_p) != CC_RC_SUCCESS) { /* * remove the node from the list of subscriptions. */ free_sub_request(sub_req_p); BLF_ERROR(MISC_F_PREFIX"Unable to send SUBSCRIBE", fname); } BLF_DEBUG(DEB_F_PREFIX"subscribed again after expiration", DEB_F_PREFIX_ARGS(BLF, fname)); } else { /* * and remove the node from the list of subscriptions. */ free_sub_request(sub_req_p); } } else { ui_BLF_notification(request_id, CC_SIP_BLF_REJECTED, sub_req_p->app_id); /* * and remove the node from the list of subscriptions. */ free_sub_request(sub_req_p); } } else { /* derive the BLF state from event data */ blf_state = extract_blf_state(event_body_p, sub_req_p->feature_mask); ui_BLF_notification(request_id, blf_state, sub_req_p->app_id); sub_req_p->blf_state = blf_state; /* * if blf state is ALERTING, * play blf alerting audible tone. */ if (blf_state == CC_SIP_BLF_ALERTING) { /* * Post an event to GSM to play alerting tone. */ cc_feature(CC_SRC_MISC_APP, CC_NO_CALL_ID, 0, CC_FEATURE_BLF_ALERT_TONE, NULL); } DEF_DEBUG(DEB_F_PREFIX"SUB %d: BLF %d", DEB_F_PREFIX_ARGS(BLF_INFO, fname), sub_state, blf_state); } free_event_data(msg_data->u.notify_ind_data.eventData); BLF_DEBUG(DEB_F_PREFIX"Exiting : acted based on subscription state", DEB_F_PREFIX_ARGS(BLF, fname)); return; }
/* * Function: dp_cancel_offhook_timer * * Parameters: * * Description: * called to cancel offhook timer. * Returns: none */ void dp_cancel_offhook_timer (void) { if ((g_dp_int.gTimerType == DP_OFFHOOK_TIMER) && (g_dp_int.dial_timer)) { (void) cprCancelTimer(g_dp_int.dial_timer); } }
int sip_platform_msg_timer_start (uint32_t msec, void *data, int idx, char *message_buffer, int message_buffer_len, int message_type, cpr_ip_addr_t *ipaddr, uint16_t port, boolean isRegister) { static const char fname[] = "sip_platform_msg_timer_start"; cprTimer_t timer; /* validate index */ if ((idx < MIN_TEL_LINES) || (idx >= MAX_CCBS)) { CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_LINE_NUMBER_INVALID), fname, idx); return SIP_ERROR; } /* validate length */ if (message_buffer_len >= SIP_UDP_MESSAGE_SIZE) { CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_MSG_BUFFER_TOO_BIG), fname, message_buffer_len); return SIP_ERROR; } /* stop the timer if it is running */ if (cprCancelTimer(sipPlatformUISMTimers[idx].timer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), idx, 0, fname, "cprCancelTimer"); return SIP_ERROR; } if (cprCancelTimer(sipPlatformUISMTimers[idx].reg_timer) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), idx, 0, fname, "cprCancelTimer"); return SIP_ERROR; } if (sipPlatformUISMTimers[idx].message_buffer == NULL) { sipPlatformUISMTimers[idx].message_buffer = (char *)cpr_malloc(message_buffer_len+1); if (sipPlatformUISMTimers[idx].message_buffer == NULL) return SIP_ERROR; } else if (message_buffer != sipPlatformUISMTimers[idx].message_buffer) { cpr_free(sipPlatformUISMTimers[idx].message_buffer); sipPlatformUISMTimers[idx].message_buffer = (char *)cpr_malloc(message_buffer_len+1); if (sipPlatformUISMTimers[idx].message_buffer == NULL) return SIP_ERROR; } sipPlatformUISMTimers[idx].message_buffer_len = message_buffer_len; sipPlatformUISMTimers[idx].message_buffer[message_buffer_len] = '\0'; memcpy(sipPlatformUISMTimers[idx].message_buffer, message_buffer, message_buffer_len); sipPlatformUISMTimers[idx].message_type = (sipMethod_t) message_type; sipPlatformUISMTimers[idx].ipaddr = *ipaddr; sipPlatformUISMTimers[idx].port = port; /* start the timer */ if (isRegister) { timer = sipPlatformUISMTimers[idx].reg_timer; } else { timer = sipPlatformUISMTimers[idx].timer; } if (cprStartTimer(timer, msec, data) == CPR_FAILURE) { CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED), idx, 0, fname, "cprStartTimer"); cpr_free(sipPlatformUISMTimers[idx].message_buffer); sipPlatformUISMTimers[idx].message_buffer = NULL; sipPlatformUISMTimers[idx].message_buffer_len = 0; return SIP_ERROR; } sipPlatformUISMTimers[idx].outstanding = TRUE; return SIP_OK; }
/* * Function: dp_dial_immediate * * Parameters: * line_id - line number * call_id - call indentification * * Description: * called when the client wants DP module to stop matching and * send the dialstring. This used for example when User pressed Dial Softkey. * * Returns: none */ static void dp_dial_immediate (line_t line, callid_t call_id, boolean collect_more, char *digit_str, char *global_call_id, monitor_mode_t monitor_mode) { const char fname[] = "dp_dial_immediate"; if (g_dp_int.line != line || g_dp_int.call_id != call_id) { return; } DPINT_DEBUG(DEB_F_PREFIX"line=%d call_id=%d dialed digits=%s\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line, call_id, g_dp_int.gDialed); /* Do not dial anything else even if UI asks to do so, if the line is PLAR */ if (dp_check_and_handle_plar_dialing(line, call_id) == TRUE) { return; } if (g_dp_int.dial_timer) { (void) cprCancelTimer(g_dp_int.dial_timer); } if (g_dp_int.gDialplanDone) { // if used with CCM, we should allow user to continue to input more digits // after they've entered partial destination number onhook then press dial if (sip_regmgr_get_cc_mode(line) == REG_MODE_CCM) { return; } // KPML mode and user pressed DIAL softkey. So send 0x82 digit to KPML if (!kpml_update_dialed_digits(line, call_id, (char)DIAL_KEY)) { kpml_quarantine_digits(line, call_id, (char)DIAL_KEY); } return; } /* CTI applications can do a initcallreq without providing the dialstring * In this case generate just the offhook event to GSM */ if (digit_str[0] == 0 && global_call_id[0] != 0) { cc_offhook_ext(CC_SRC_GSM, call_id, line, global_call_id, monitor_mode); return; } g_dp_int.gDialplanDone = TRUE; if (digit_str[0] != 0) { sstrncpy(g_dp_int.gDialed, digit_str, MAX_DIALSTRING); } /* This case should not happen, as dial softkey is displayed only after the * 1st digit. dp_dial_immediate function is called for dial softkey invocation. */ if (g_dp_int.gDialed[0] == 0) { return; } else { g_dp_int.line = line; g_dp_int.call_id = call_id; kpml_flush_quarantine_buffer(line, call_id); cc_dialstring_ext(CC_SRC_GSM, call_id, line, g_dp_int.gDialed, global_call_id, monitor_mode); } if (collect_more == FALSE) { /* * Since no more digits are collected, * allow proceed event to go through UI. */ g_dp_int.allow_proceed = TRUE; kpml_set_subscription_reject(line, call_id); kpml_flush_quarantine_buffer(line, call_id); } }
/* * Function: dp_check_dialplan() * * Parameters: line - line number * call_id - call indentification * cursor - indicates number digits in the dial string * strDigs - collected digit string. * * Description: Check dial plan with collected digits. * * Returns: None */ static void dp_check_dialplan (line_t line, callid_t call_id, unsigned char digit) { const char fname[] = "dp_check_dialplan"; int timeout = DIAL_TIMEOUT; DialMatchAction action; vcm_tones_t tone; lsm_states_t lsm_state; /* if the dialing is done then don't * do anything */ if (g_dp_int.gDialplanDone) { DPINT_DEBUG(DEB_F_PREFIX"Dialplan Match Completed: line=%d call_id=%d digits=%d", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line, call_id, digit); return; } DPINT_DEBUG(DEB_F_PREFIX"line=%d call_id=%d digits=%s", DEB_F_PREFIX_ARGS(DIALPLAN, fname), line, call_id, &g_dp_int.gDialed[0]); dp_store_digits(line, call_id, digit); /* get current digit in GSM format */ if (digit == '*') { digit = 0x0E; } else if (digit == '#') { digit = 0x0F; } else { digit = digit - '0'; } /* see if we match any dial plans */ action = MatchDialTemplate(g_dp_int.gDialed, line, &timeout, NULL, 0, NULL, &tone); switch (action) { case DIAL_FULLPATTERN: DPINT_DEBUG(DEB_F_PREFIX"Full pattern match\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname)); if (timeout <= 0) { cc_dialstring(CC_SRC_GSM, g_dp_int.call_id, g_dp_int.line, g_dp_int.gDialed); /* flush collected digits. Invite has been sent */ kpml_flush_quarantine_buffer(line, call_id); (void) cprCancelTimer(g_dp_int.dial_timer); g_dp_int.gDialplanDone = TRUE; return; } cc_digit_begin(CC_SRC_GSM, call_id, line, digit); break; case DIAL_IMMEDIATELY: DPINT_DEBUG(DEB_F_PREFIX"Dial immediately\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname)); /* * The user pressed the # key and the phone should dial immediately */ (void) cprCancelTimer(g_dp_int.dial_timer); g_dp_int.gDialplanDone = TRUE; cc_dialstring(CC_SRC_GSM, g_dp_int.call_id, g_dp_int.line, g_dp_int.gDialed); //kpml_set_subscription_reject(line, call_id); kpml_flush_quarantine_buffer(line, call_id); return; case DIAL_GIVETONE: DPINT_DEBUG(DEB_F_PREFIX"Give tone\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname)); /* we need new dial tone */ lsm_state = lsm_get_state(call_id); if (lsm_state == LSM_S_NONE) { DPINT_DEBUG(DEB_F_PREFIX"call not found\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname)); return; } (void)cc_call_action(call_id, LSM_NO_LINE, CC_ACTION_STOP_TONE, NULL); vcmToneStart(tone, FALSE, CREATE_CALL_HANDLE(line, call_id), 0 /* group_id */, 0/* stream_id */, VCM_PLAY_TONE_TO_EAR); break; default: DPINT_DEBUG(DEB_F_PREFIX"No match\n", DEB_F_PREFIX_ARGS(DIALPLAN, fname)); cc_digit_begin(CC_SRC_GSM, call_id, line, digit); break; } dp_restart_dial_timer(line, call_id, timeout * 1000); g_dp_int.gTimerType = DP_INTERDIGIT_TIMER; return; }