/** * * sip_platform_udp_read_socket * * Read from the socket to extract received message * * Parameters: s - the socket * * Return Value: None * */ void sip_platform_udp_read_socket (cpr_socket_t s) { cprBuffer_t buf; uint16_t len = 0; cpr_sockaddr_storage from; cpr_socklen_t from_len; const char *fname = "sip_platform_udp_read_socket"; if (af_family_listen == AF_INET6) { from_len = sizeof(cpr_sockaddr_in6_t); } else { from_len = sizeof(cpr_sockaddr_in_t); } buf = SIPTaskGetBuffer(CPR_MAX_MSG_SIZE); if (buf) { if ((sip_platform_udp_channel_read(s, buf, &len, (cpr_sockaddr_t *)&from, &from_len) == SIP_OK) && (len != 0)) { (void) SIPTaskProcessUDPMessage(buf, len, from); } } else { CCSIP_DEBUG_ERROR(SIP_F_PREFIX"No buffers available to read UDP socket.\n", fname); } }
void send_protocol_config_msg (void) { const char *fname = "send_protocol_config_msg"; char *msg; TNP_DEBUG(DEB_F_PREFIX"send TCP_DONE message to sip thread..\n", DEB_F_PREFIX_ARGS(SIP_CC_INIT, fname)); msg = (char *) SIPTaskGetBuffer(4); if (msg == NULL) { TNP_DEBUG(DEB_F_PREFIX"failed to allocate message..\n", DEB_F_PREFIX_ARGS(SIP_CC_INIT, fname)); return; } /* send a config done message to the SIP Task */ if (SIPTaskSendMsg(TCP_PHN_CFG_TCP_DONE, msg, 0, NULL) == CPR_FAILURE) { err_msg("%s: notify SIP stack ready failed", fname); cpr_free(msg); } gsm_set_initialized(); PHNChangeState(STATE_CONNECTED); }
void sip_platform_post_timer (uint32_t cmd, void *data) { static const char fname[] = "sip_platform_post_timer"; uint32_t *timer_msg = NULL; /* grab msg buffer */ timer_msg = (uint32_t *) SIPTaskGetBuffer(sizeof(uint32_t)); if (!timer_msg) { CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_SYSBUF_UNAVAILABLE), fname); return; } *timer_msg = (long) data; /* Put it on the SIP message queue */ if (SIPTaskSendMsg(cmd, (cprBuffer_t) timer_msg, sizeof(uint32_t), NULL) == CPR_FAILURE) { cpr_free(timer_msg); CCSIP_DEBUG_ERROR(SIP_F_PREFIX "Send msg failed.\n", fname); } return; }
/* * 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; } }