cc_rcs_t sub_send_msg (cprBuffer_t buf, uint32_t cmd, uint16_t len, cc_srcs_t dst_id) { cpr_status_e rc; CC_DEBUG_MSG sub_print_msg((char *)buf, len); switch (dst_id) { case CC_SRC_GSM: rc = gsm_send_msg(cmd, buf, len); if (rc == CPR_FAILURE) { cprReleaseBuffer(buf); } break; case CC_SRC_SIP: rc = SIPTaskSendMsg(cmd, buf, len, NULL); if (rc == CPR_FAILURE) { cprReleaseBuffer(buf); } break; case CC_SRC_MISC_APP: rc = MiscAppTaskSendMsg(cmd, buf, len); if (rc == CPR_FAILURE) { cprReleaseBuffer(buf); } break; default: rc = CPR_FAILURE; break; } return (rc == CPR_SUCCESS) ? CC_RC_SUCCESS : CC_RC_ERROR; }
static void dp_int_message (line_t line, callid_t call_id, char digit, char *digit_str, boolean collect_more, void *tmr_data, int msg_id, char *g_call_id, monitor_mode_t monitor_mode) { char fname[] = "dp_int_message"; dp_int_t *pmsg; pmsg = (dp_int_t *) cc_get_msg_buf(sizeof(dp_int_t)); if (!pmsg) { err_msg(get_debug_string(CC_NO_MSG_BUFFER), fname); return; } pmsg->line = line; pmsg->call_id = call_id; pmsg->digit = digit; if (digit_str) { sstrncpy(pmsg->digit_str, digit_str, MAX_DIALSTRING); } pmsg->collect_more = collect_more; pmsg->tmr_ptr = tmr_data; if (digit_str) { sstrncpy(pmsg->global_call_id, g_call_id, CC_GCID_LEN); } pmsg->monitor_mode = monitor_mode; if (gsm_send_msg(msg_id, (cprBuffer_t) pmsg, sizeof(dp_int_t)) != CPR_SUCCESS) { err_msg(get_debug_string(CC_SEND_FAILURE), fname); } }
cc_rcs_t sub_send_msg (cprBuffer_t buf, uint32_t cmd, uint16_t len, cc_srcs_t dst_id) { cpr_status_e rc; /* This buffer is assumed to be at least of size int */ MOZ_ASSERT(len >= sizeof(int)); if (len < sizeof(int)) { return CC_RC_ERROR; } CC_DEBUG_MSG sub_print_msg((char *)buf, len); switch (dst_id) { case CC_SRC_GSM: rc = gsm_send_msg(cmd, buf, len); if (rc == CPR_FAILURE) { cpr_free(buf); } break; case CC_SRC_SIP: rc = SIPTaskSendMsg(cmd, buf, len, NULL); if (rc == CPR_FAILURE) { cpr_free(buf); } break; case CC_SRC_MISC_APP: rc = MiscAppTaskSendMsg(cmd, buf, len); if (rc == CPR_FAILURE) { cpr_free(buf); } break; default: rc = CPR_FAILURE; break; } return (rc == CPR_SUCCESS) ? CC_RC_SUCCESS : CC_RC_ERROR; }
/* * Function: send_task_unload_msg * * Description: * - send shutdown and thread destroy msg to sip, gsm, ccapp, misc * threads * Parameters: destination thread * * Returns: none * */ void send_task_unload_msg(cc_srcs_t dest_id) { const char *fname = "send_task_unload_msg"; uint16_t len = 4; cprBuffer_t msg = gsm_get_buffer(len); int sdpmode = 0; config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (msg == NULL) { err_msg("%s: failed to allocate msg cprBuffer_t\n", fname); return; } DEF_DEBUG(DEB_F_PREFIX"send Unload message to %s task ..\n", DEB_F_PREFIX_ARGS(SIP_CC_INIT, fname), dest_id == CC_SRC_SIP ? "SIP" : dest_id == CC_SRC_GSM ? "GSM" : dest_id == CC_SRC_MISC_APP ? "Misc App" : dest_id == CC_SRC_CCAPP ? "CCApp" : "Unknown"); switch(dest_id) { case CC_SRC_SIP: { /* send this msg so phone can send unRegister msg */ SIPTaskPostShutdown(SIP_EXTERNAL, CC_CAUSE_SHUTDOWN, ""); /* allow unRegister msg to sent out and shutdown to complete */ if (!sdpmode) { cprSleep(2000); } /* send a unload message to the SIP Task to kill sip thread*/ msg = SIPTaskGetBuffer(len); if (msg == NULL) { err_msg("%s:%d: failed to allocate sip msg buffer\n", fname); return; } if (SIPTaskSendMsg(THREAD_UNLOAD, (cprBuffer_t)msg, len, NULL) == CPR_FAILURE) { cpr_free(msg); err_msg("%s: Unable to send THREAD_UNLOAD msg to sip thread", fname); } } break; case CC_SRC_GSM: { msg = gsm_get_buffer(len); if (msg == NULL) { err_msg("%s: failed to allocate gsm msg cprBuffer_t\n", fname); return; } if (CPR_FAILURE == gsm_send_msg(THREAD_UNLOAD, msg, len)) { err_msg("%s: Unable to send THREAD_UNLOAD msg to gsm thread", fname); } } break; case CC_SRC_MISC_APP: { msg = cpr_malloc(len); if (msg == NULL) { err_msg("%s: failed to allocate misc msg cprBuffer_t\n", fname); return; } if (CPR_FAILURE == MiscAppTaskSendMsg(THREAD_UNLOAD, msg, len)) { err_msg("%s: Unable to send THREAD_UNLOAD msg to Misc App thread", fname); } } break; case CC_SRC_CCAPP: { msg = cpr_malloc(len); if (msg == NULL) { err_msg("%s: failed to allocate ccapp msg cprBuffer_t\n", fname); return; } if (ccappTaskPostMsg(CCAPP_THREAD_UNLOAD, msg, len, CCAPP_CCPROVIER) == CPR_FAILURE ) { err_msg("%s: Unable to send THREAD_UNLOAD msg to CCapp thread", fname); } err_msg("%s: send UNLOAD msg to CCapp thread good", fname); } break; default: err_msg("%s: Unknown destination task passed=%d.", fname, dest_id); break; } }