mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-12 04:16:44 +00:00
Merge branch 'nsg-4.3' of git.sangoma.com:smg_freeswitch into nsg-4.3
This commit is contained in:
commit
2dd7ab104d
@ -16,6 +16,7 @@ switch_status_t megaco_profile_status(switch_stream_handle_t *stream, megaco_pro
|
|||||||
switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_profile_t* mg_cfg);
|
switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_profile_t* mg_cfg);
|
||||||
switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, megaco_profile_t* mg_cfg);
|
switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, megaco_profile_t* mg_cfg);
|
||||||
switch_status_t handle_term_status_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile, char* term_id);
|
switch_status_t handle_term_status_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile, char* term_id);
|
||||||
|
switch_status_t handle_all_term_status_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile);
|
||||||
void get_peer_xml_buffer(char* prntBuf, MgPeerSta* cfm);
|
void get_peer_xml_buffer(char* prntBuf, MgPeerSta* cfm);
|
||||||
void megaco_cli_print_usage(switch_stream_handle_t *stream);
|
void megaco_cli_print_usage(switch_stream_handle_t *stream);
|
||||||
switch_status_t handle_show_activecalls_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile);
|
switch_status_t handle_show_activecalls_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile);
|
||||||
@ -188,21 +189,6 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre
|
|||||||
stream->write_function(stream, "-ERR No such profile\n");
|
stream->write_function(stream, "-ERR No such profile\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************/
|
|
||||||
}else if (!strcmp(argv[2], "termstatus")) {
|
|
||||||
/**********************************************************************************/
|
|
||||||
/* mg <mg-profile> termstatus <term-id> */
|
|
||||||
|
|
||||||
if (zstr(argv[3])) {
|
|
||||||
goto usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(profile){
|
|
||||||
megaco_profile_release(profile);
|
|
||||||
handle_term_status_cli_cmd(stream, profile, argv[3]);
|
|
||||||
} else {
|
|
||||||
stream->write_function(stream, "-ERR No such profile\n");
|
|
||||||
}
|
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
}else if (!strcmp(argv[2], "show")) {
|
}else if (!strcmp(argv[2], "show")) {
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
@ -214,12 +200,25 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre
|
|||||||
if(profile){
|
if(profile){
|
||||||
megaco_profile_release(profile);
|
megaco_profile_release(profile);
|
||||||
if(!strcasecmp(argv[3], "activecalls")){
|
if(!strcasecmp(argv[3], "activecalls")){
|
||||||
|
/* mg <mg-profile> show activecalls */
|
||||||
handle_show_activecalls_cli_cmd(stream, profile);
|
handle_show_activecalls_cli_cmd(stream, profile);
|
||||||
}
|
/*******************************************************************/
|
||||||
} else {
|
}else if(!strcasecmp(argv[3], "alltermstatus")){
|
||||||
|
/*******************************************************************/
|
||||||
|
/* mg <mg-profile> show alltermstatus */
|
||||||
|
handle_all_term_status_cli_cmd(stream, profile);
|
||||||
|
}else if(!strcasecmp(argv[3], "termstatus")){
|
||||||
|
/*******************************************************************/
|
||||||
|
/* mg <mg-profile> show termstatus <term-id> */
|
||||||
|
if (zstr(argv[4])) {
|
||||||
|
goto usage;
|
||||||
|
}
|
||||||
|
handle_term_status_cli_cmd(stream, profile, argv[4]);
|
||||||
|
} else {
|
||||||
|
/*******************************************************************/
|
||||||
stream->write_function(stream, "-ERR No such profile\n");
|
stream->write_function(stream, "-ERR No such profile\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
}else {
|
}else {
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
@ -271,7 +270,6 @@ void megaco_cli_print_usage(switch_stream_handle_t *stream)
|
|||||||
stream->write_function(stream, "Usage: Profile Specific\n");
|
stream->write_function(stream, "Usage: Profile Specific\n");
|
||||||
stream->write_function(stream, "mg profile <profile-name> start \n");
|
stream->write_function(stream, "mg profile <profile-name> start \n");
|
||||||
stream->write_function(stream, "mg profile <profile-name> stop \n");
|
stream->write_function(stream, "mg profile <profile-name> stop \n");
|
||||||
stream->write_function(stream, "mg profile <profile-name> termstatus <term-id> \n");
|
|
||||||
stream->write_function(stream, "mg profile <profile-name> status \n");
|
stream->write_function(stream, "mg profile <profile-name> status \n");
|
||||||
stream->write_function(stream, "mg profile <profile-name> xmlstatus \n");
|
stream->write_function(stream, "mg profile <profile-name> xmlstatus \n");
|
||||||
stream->write_function(stream, "mg profile <profile-name> peerxmlstatus \n");
|
stream->write_function(stream, "mg profile <profile-name> peerxmlstatus \n");
|
||||||
@ -280,6 +278,8 @@ void megaco_cli_print_usage(switch_stream_handle_t *stream)
|
|||||||
stream->write_function(stream, "mg profile <profile-name> send ito notify \n");
|
stream->write_function(stream, "mg profile <profile-name> send ito notify \n");
|
||||||
stream->write_function(stream, "mg profile <profile-name> send cng <term-id> \n");
|
stream->write_function(stream, "mg profile <profile-name> send cng <term-id> \n");
|
||||||
stream->write_function(stream, "mg profile <profile-name> show activecalls \n");
|
stream->write_function(stream, "mg profile <profile-name> show activecalls \n");
|
||||||
|
stream->write_function(stream, "mg profile <profile-name> show termstatus <term-id> \n");
|
||||||
|
stream->write_function(stream, "mg profile <profile-name> show alltermstatus \n");
|
||||||
|
|
||||||
stream->write_function(stream, "Usage: Logging \n");
|
stream->write_function(stream, "Usage: Logging \n");
|
||||||
stream->write_function(stream, "mg logging enable \n");
|
stream->write_function(stream, "mg logging enable \n");
|
||||||
@ -698,7 +698,54 @@ void get_peer_xml_buffer(char* prntBuf, MgPeerSta* cfm)
|
|||||||
|
|
||||||
}
|
}
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
switch_status_t handle_all_term_status_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile)
|
||||||
|
{
|
||||||
|
void *val = NULL;
|
||||||
|
switch_hash_index_t *hi = NULL;
|
||||||
|
mg_termination_t *term = NULL;
|
||||||
|
const void *var;
|
||||||
|
|
||||||
|
if(!mg_profile){
|
||||||
|
stream->write_function(stream, "-ERR NULL profile\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->write_function(stream, " Termination Name");
|
||||||
|
stream->write_function(stream, "\t Termination State");
|
||||||
|
stream->write_function(stream, "\t Termination Type");
|
||||||
|
stream->write_function(stream, "\t Span-Id ");
|
||||||
|
stream->write_function(stream, "\t Channel-Id ");
|
||||||
|
|
||||||
|
for (hi = switch_hash_first(NULL, mg_profile->terminations); hi; hi = switch_hash_next(hi)) {
|
||||||
|
switch_hash_this(hi, &var, NULL, &val);
|
||||||
|
term = (mg_termination_t *) val;
|
||||||
|
if(!term) continue;
|
||||||
|
|
||||||
|
stream->write_function(stream, "\n");
|
||||||
|
|
||||||
|
stream->write_function(stream, " %s",(NULL != term->name)?term->name:"NULL");
|
||||||
|
if(MG_TERM_RTP == term->type){
|
||||||
|
stream->write_function(stream, "\t\t\t IN-SERVICE");
|
||||||
|
}else{
|
||||||
|
stream->write_function(stream, "\t\t\t %s",
|
||||||
|
(switch_test_flag(term, MG_IN_SERVICE))?"IN-SERVICE":"OUT-OF-SERVICE");
|
||||||
|
}
|
||||||
|
stream->write_function(stream, "\t\t %s",(MG_TERM_RTP == term->type)?"MG_TERM_RTP":"MG_TERM_TDM");
|
||||||
|
|
||||||
|
if(MG_TERM_TDM == term->type){
|
||||||
|
stream->write_function(stream, "\t\t %s",
|
||||||
|
(NULL != term->u.tdm.span_name)?term->u.tdm.span_name:"NULL");
|
||||||
|
stream->write_function(stream, "\t\t %d",term->u.tdm.channel);
|
||||||
|
}else{
|
||||||
|
stream->write_function(stream, "\t\t -");
|
||||||
|
stream->write_function(stream, "\t\t -");
|
||||||
|
}
|
||||||
|
stream->write_function(stream, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
/******************************************************************************/
|
||||||
switch_status_t handle_term_status_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile, char* term_id)
|
switch_status_t handle_term_status_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile, char* term_id)
|
||||||
{
|
{
|
||||||
mg_termination_t* term = NULL;
|
mg_termination_t* term = NULL;
|
||||||
|
@ -1065,7 +1065,7 @@ error:
|
|||||||
*/
|
*/
|
||||||
switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd)
|
switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd)
|
||||||
{
|
{
|
||||||
mg_context_t* mg_ctxt = NULL;
|
mg_context_t* mg_ctxt = NULL;
|
||||||
MgMgcoContextId *ctxtId;
|
MgMgcoContextId *ctxtId;
|
||||||
MgStr errTxt;
|
MgStr errTxt;
|
||||||
MgMgcoInd *mgErr;
|
MgMgcoInd *mgErr;
|
||||||
@ -1073,7 +1073,11 @@ switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand
|
|||||||
MgMgcoTermIdLst* termLst;
|
MgMgcoTermIdLst* termLst;
|
||||||
mg_termination_t* term = NULL;
|
mg_termination_t* term = NULL;
|
||||||
switch_status_t ret;
|
switch_status_t ret;
|
||||||
|
MgMgcoAudRetParm *desc;
|
||||||
|
MgMgcoMediaDesc* inc_med_desc = NULL;
|
||||||
|
MgMgcoLocalDesc *local = NULL;
|
||||||
int err_code;
|
int err_code;
|
||||||
|
int mediaId;
|
||||||
/*MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.mod;*/
|
/*MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.mod;*/
|
||||||
U32 txn_id = inc_cmd->transId.val;
|
U32 txn_id = inc_cmd->transId.val;
|
||||||
|
|
||||||
@ -1114,109 +1118,109 @@ switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand
|
|||||||
/* context id presence check is already being done, we are here it means context-id requested in megaco message is present */
|
/* context id presence check is already being done, we are here it means context-id requested in megaco message is present */
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
/* MGT_TERMID_ROOT = If ROOT term then there will not be any conext */
|
/* MGT_TERMID_ROOT = If ROOT term then there will not be any conext */
|
||||||
|
|
||||||
if(MGT_TERMID_ROOT == termId->type.val){
|
if(MGT_TERMID_ROOT == termId->type.val){
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||||
"Modify request is for ROOT termination \n");
|
"Modify request is for ROOT termination \n");
|
||||||
|
|
||||||
/* check if we have ito packg request */
|
/* check if we have ito packg request */
|
||||||
mg_is_ito_pkg_req(mg_profile, inc_cmd);
|
mg_is_ito_pkg_req(mg_profile, inc_cmd);
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
} else if(MGT_TERMID_OTHER == termId->type.val){
|
} else if(MGT_TERMID_OTHER == termId->type.val){
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
#ifdef BIT_64
|
#ifdef BIT_64
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||||
"Modify request is for termination[%s] and context: type[%d], value[%d] \n",
|
"Modify request is for termination[%s] and context: type[%d], value[%d] \n",
|
||||||
termId->name.lcl.val, ctxtId->type.val, ctxtId->val.val);
|
termId->name.lcl.val, ctxtId->type.val, ctxtId->val.val);
|
||||||
#else
|
#else
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||||
"Modify request is for termination[%s] and context: type[%d], value[%ld] \n",
|
"Modify request is for termination[%s] and context: type[%d], value[%ld] \n",
|
||||||
termId->name.lcl.val, ctxtId->type.val, ctxtId->val.val);
|
termId->name.lcl.val, ctxtId->type.val, ctxtId->val.val);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
|
term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
|
||||||
|
|
||||||
if(NULL == term){
|
if(NULL == term){
|
||||||
mg_util_set_term_string(&errTxt,termId);
|
mg_util_set_term_string(&errTxt,termId);
|
||||||
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID;
|
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* termination specified...context should also be specified */
|
/* termination specified...context should also be specified */
|
||||||
|
|
||||||
/* check if we have terminations in the context */
|
/* check if we have terminations in the context */
|
||||||
|
|
||||||
if (NOTPRSNT != ctxtId->type.pres) {
|
if (NOTPRSNT != ctxtId->type.pres) {
|
||||||
if(MGT_CXTID_OTHER == ctxtId->type.val) {
|
if(MGT_CXTID_OTHER == ctxtId->type.val) {
|
||||||
/*find context based on received context-id */
|
/*find context based on received context-id */
|
||||||
mg_ctxt = megaco_get_context(mg_profile, ctxtId->val.val);
|
mg_ctxt = megaco_get_context(mg_profile, ctxtId->val.val);
|
||||||
if(NULL == mg_ctxt){
|
if(NULL == mg_ctxt){
|
||||||
mg_util_set_ctxt_string(&errTxt, ctxtId);
|
mg_util_set_ctxt_string(&errTxt, ctxtId);
|
||||||
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_CTXT;
|
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_CTXT;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SWITCH_STATUS_FALSE == megaco_context_is_term_present(mg_ctxt, term)){
|
if(SWITCH_STATUS_FALSE == megaco_context_is_term_present(mg_ctxt, term)){
|
||||||
/* ERROR - termination didnt bind with requested context */
|
/* ERROR - termination didnt bind with requested context */
|
||||||
mg_util_set_term_string(&errTxt,termId);
|
mg_util_set_term_string(&errTxt,termId);
|
||||||
err_code = MGT_MGCO_RSP_CODE_NO_TERM_CTXT;
|
err_code = MGT_MGCO_RSP_CODE_NO_TERM_CTXT;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(MGT_CXTID_NULL == ctxtId->type.val) {
|
}else if(MGT_CXTID_NULL == ctxtId->type.val) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||||
"Modify request is for NULL Context \n");
|
"Modify request is for NULL Context \n");
|
||||||
/*TODO - NULL context...nothing to do now...jump to response to send +ve response */
|
/*TODO - NULL context...nothing to do now...jump to response to send +ve response */
|
||||||
goto response;
|
goto response;
|
||||||
}else if(MGT_CXTID_ALL == ctxtId->type.val) {
|
}else if(MGT_CXTID_ALL == ctxtId->type.val) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||||
"Modify request is for ALL Context \n");
|
"Modify request is for ALL Context \n");
|
||||||
/*TODO - ALL context...nothing to do now...jump to response to send +ve response */
|
/*TODO - ALL context...nothing to do now...jump to response to send +ve response */
|
||||||
goto response;
|
goto response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Not sure if MODIFY can come with Context ALL with specified term */
|
/* Not sure if MODIFY can come with Context ALL with specified term */
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
ret = mg_prc_descriptors(mg_profile, inc_cmd, term, &inc_cmd->u.mgCmdInd[0]->memCp);
|
ret = mg_prc_descriptors(mg_profile, inc_cmd, term, &inc_cmd->u.mgCmdInd[0]->memCp);
|
||||||
|
|
||||||
/* IF there is any error , return */
|
/* IF there is any error , return */
|
||||||
if(term->mg_error_code && (*term->mg_error_code == MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT)){
|
if(term->mg_error_code && (*term->mg_error_code == MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT)){
|
||||||
mg_util_set_err_string(&errTxt, " Unsupported Codec ");
|
mg_util_set_err_string(&errTxt, " Unsupported Codec ");
|
||||||
err_code = MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT;
|
err_code = MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT;
|
||||||
/* TODO delete RTP termination */
|
/* TODO delete RTP termination */
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(MG_TERM_RTP == term->type){
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"MODIFY REQUEST - Updated RTP attributes:"
|
||||||
|
" local_addr[%s] local_port[%d] remote_addr[%s], remote_port[%d], ptime[%d] pt[%d], "
|
||||||
|
" rfc2833_pt[%d] rate[%d], codec[%s], term_id[%d]\n",
|
||||||
|
((NULL != term->u.rtp.local_addr)?term->u.rtp.local_addr:NULL),
|
||||||
|
term->u.rtp.local_port,
|
||||||
|
((NULL != term->u.rtp.remote_addr)?term->u.rtp.remote_addr:NULL),
|
||||||
|
term->u.rtp.remote_port,
|
||||||
|
term->u.rtp.ptime,
|
||||||
|
term->u.rtp.pt,
|
||||||
|
term->u.rtp.rfc2833_pt,
|
||||||
|
term->u.rtp.rate,
|
||||||
|
((NULL != term->u.rtp.codec)?term->u.rtp.codec:NULL),
|
||||||
|
term->u.rtp.term_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
mg_print_t38_attributes(term);
|
||||||
|
|
||||||
|
|
||||||
|
/* SDP updated to termination */
|
||||||
|
megaco_activate_termination(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MG_TERM_RTP == term->type){
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"MODIFY REQUEST - Updated RTP attributes:"
|
|
||||||
" local_addr[%s] local_port[%d] remote_addr[%s], remote_port[%d], ptime[%d] pt[%d], "
|
|
||||||
" rfc2833_pt[%d] rate[%d], codec[%s], term_id[%d]\n",
|
|
||||||
((NULL != term->u.rtp.local_addr)?term->u.rtp.local_addr:NULL),
|
|
||||||
term->u.rtp.local_port,
|
|
||||||
((NULL != term->u.rtp.remote_addr)?term->u.rtp.remote_addr:NULL),
|
|
||||||
term->u.rtp.remote_port,
|
|
||||||
term->u.rtp.ptime,
|
|
||||||
term->u.rtp.pt,
|
|
||||||
term->u.rtp.rfc2833_pt,
|
|
||||||
term->u.rtp.rate,
|
|
||||||
((NULL != term->u.rtp.codec)?term->u.rtp.codec:NULL),
|
|
||||||
term->u.rtp.term_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
mg_print_t38_attributes(term);
|
|
||||||
|
|
||||||
|
|
||||||
/* SDP updated to termination */
|
|
||||||
megaco_activate_termination(term);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO - copy inc descriptor...not sure if we need to do this.. */
|
/* TODO - copy inc descriptor...not sure if we need to do this.. */
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
@ -1230,54 +1234,97 @@ switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand
|
|||||||
/* Kapil - to fill the response structure and call the response API to send Modify response */
|
/* Kapil - to fill the response structure and call the response API to send Modify response */
|
||||||
|
|
||||||
response:
|
response:
|
||||||
{ /* send response */
|
{ /* send response */
|
||||||
|
|
||||||
MgMgcoCommand rsp;
|
MgMgcoCommand rsp;
|
||||||
int ret = 0x00;
|
int ret = 0x00;
|
||||||
|
|
||||||
memset(&rsp,0, sizeof(rsp));
|
memset(&rsp,0, sizeof(rsp));
|
||||||
|
|
||||||
/*copy transaction-id*/
|
/*copy transaction-id*/
|
||||||
memcpy(&rsp.transId, &inc_cmd->transId,sizeof(MgMgcoTransId));
|
memcpy(&rsp.transId, &inc_cmd->transId,sizeof(MgMgcoTransId));
|
||||||
|
|
||||||
/*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
|
/*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
|
||||||
memcpy(&rsp.contextId, &inc_cmd->contextId,sizeof(MgMgcoContextId));
|
memcpy(&rsp.contextId, &inc_cmd->contextId,sizeof(MgMgcoContextId));
|
||||||
|
|
||||||
/*copy peer identifier */
|
/*copy peer identifier */
|
||||||
memcpy(&rsp.peerId, &inc_cmd->peerId,sizeof(TknU32));
|
memcpy(&rsp.peerId, &inc_cmd->peerId,sizeof(TknU32));
|
||||||
|
|
||||||
/*fill response structue */
|
/*fill response structue */
|
||||||
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&rsp.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
|
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&rsp.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
rsp.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
||||||
rsp.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
rsp.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
||||||
rsp.u.mgCmdRsp[0]->type.val = MGT_MODIFY;
|
rsp.u.mgCmdRsp[0]->type.val = MGT_MODIFY;
|
||||||
rsp.u.mgCmdRsp[0]->u.mod.pres.pres = PRSNT_NODEF;
|
rsp.u.mgCmdRsp[0]->u.mod.pres.pres = PRSNT_NODEF;
|
||||||
rsp.u.mgCmdRsp[0]->u.mod.termIdLst.num.pres = PRSNT_NODEF;
|
rsp.u.mgCmdRsp[0]->u.mod.termIdLst.num.pres = PRSNT_NODEF;
|
||||||
rsp.u.mgCmdRsp[0]->u.mod.termIdLst.num.val = 1;
|
rsp.u.mgCmdRsp[0]->u.mod.termIdLst.num.val = 1;
|
||||||
|
|
||||||
mgUtlAllocMgMgcoTermIdLst(&rsp.u.mgCmdRsp[0]->u.mod.termIdLst, &inc_cmd->u.mgCmdReq[0]->cmd.u.mod.termIdLst);
|
mgUtlAllocMgMgcoTermIdLst(&rsp.u.mgCmdRsp[0]->u.mod.termIdLst, &inc_cmd->u.mgCmdReq[0]->cmd.u.mod.termIdLst);
|
||||||
|
|
||||||
#ifdef GCP_VER_2_1
|
#ifdef GCP_VER_2_1
|
||||||
termId = rsp.u.mgCmdRsp[0]->u.mod.termIdLst.terms[0];
|
termId = rsp.u.mgCmdRsp[0]->u.mod.termIdLst.terms[0];
|
||||||
#else
|
#else
|
||||||
termId = &(rsp.u.mgCmdRsp[0]->u.mod.termId);
|
termId = &(rsp.u.mgCmdRsp[0]->u.mod.termId);
|
||||||
#endif
|
#endif
|
||||||
/*mg_fill_mgco_termid(termId, (char*)"term1",&req->u.mgCmdRsp[0]->memCp);*/
|
/*mg_fill_mgco_termid(termId, (char*)"term1",&req->u.mgCmdRsp[0]->memCp);*/
|
||||||
|
|
||||||
/* We will always send one command at a time..*/
|
if((MG_TERM_RTP == term->type) &&
|
||||||
rsp.cmdStatus.pres = PRSNT_NODEF;
|
((NOTPRSNT != inc_cmd->u.mgCmdInd[0]->cmd.u.mod.dl.num.pres) &&
|
||||||
rsp.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
|
(0 != inc_cmd->u.mgCmdInd[0]->cmd.u.mod.dl.num.val))) {
|
||||||
|
/* Whatever Media descriptor we have received, we can copy that and then
|
||||||
|
* whatever we want we can modify the fields */
|
||||||
|
/* Kapil - TODO - will see if there is any problem of coping the
|
||||||
|
* descriptor */
|
||||||
|
|
||||||
rsp.cmdType.pres = PRSNT_NODEF;
|
inc_med_desc = &inc_cmd->u.mgCmdInd[0]->cmd.u.mod.dl.descs[0]->u.media;
|
||||||
rsp.cmdType.val = CH_CMD_TYPE_RSP;
|
|
||||||
|
if (mgUtlGrowList((void ***)&rsp.u.mgCmdRsp[0]->u.mod.audit.parms, sizeof(MgMgcoAudRetParm),
|
||||||
|
&rsp.u.mgCmdRsp[0]->u.mod.audit.num, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
|
||||||
|
{
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy media descriptor */
|
||||||
|
desc = rsp.u.mgCmdRsp[0]->u.mod.audit.parms[rsp.u.mgCmdRsp[0]->u.mod.audit.num.val-1];
|
||||||
|
desc->type.pres = PRSNT_NODEF;
|
||||||
|
desc->type.val = MGT_MEDIADESC;
|
||||||
|
mgUtlCpyMgMgcoMediaDesc(&desc->u.media, inc_med_desc, &rsp.u.mgCmdRsp[0]->memCp);
|
||||||
|
/* see if we have received local descriptor */
|
||||||
|
if((NOTPRSNT != desc->u.media.num.pres) &&
|
||||||
|
(0 != desc->u.media.num.val))
|
||||||
|
{
|
||||||
|
for(mediaId=0; mediaId<desc->u.media.num.val; mediaId++) {
|
||||||
|
if(MGT_MEDIAPAR_LOCAL == desc->u.media.parms[mediaId]->type.val) {
|
||||||
|
local = &desc->u.media.parms[mediaId]->u.local;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* only for RTP */
|
||||||
|
if(SWITCH_STATUS_FALSE == mg_build_sdp(&desc->u.media, inc_med_desc, mg_profile, term, &rsp.u.mgCmdRsp[0]->memCp)) {
|
||||||
|
if(term->mg_error_code && (*term->mg_error_code == MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT)){
|
||||||
|
mg_util_set_err_string(&errTxt, " Unsupported Codec ");
|
||||||
|
err_code = MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We will always send one command at a time..*/
|
||||||
|
rsp.cmdStatus.pres = PRSNT_NODEF;
|
||||||
|
rsp.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
|
||||||
|
|
||||||
|
rsp.cmdType.pres = PRSNT_NODEF;
|
||||||
|
rsp.cmdType.val = CH_CMD_TYPE_RSP;
|
||||||
|
|
||||||
|
|
||||||
ret = sng_mgco_send_cmd(mg_profile->idx, &rsp);
|
ret = sng_mgco_send_cmd(mg_profile->idx, &rsp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
@ -452,24 +452,26 @@ void mgco_fill_t38_sdp_attr(CmSdpAttrSet *s, mg_termination_t* term, CmMemListCp
|
|||||||
"CM_SDP_ATTR_T38_FAX: TYPE not present \n");
|
"CM_SDP_ATTR_T38_FAX: TYPE not present \n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
printf("f->u.unknown.name.val[%s, len=%d]\n", f->u.unknown.name.val, f->u.unknown.name.len);
|
||||||
|
|
||||||
/* NOTE - Ideally i should not change ,whatever is coming we can return..due to
|
/* NOTE - Ideally i should not change ,whatever is coming we can return..due to
|
||||||
trillium issue forcefully coping the data...will remove once get trillium fix*/
|
trillium issue forcefully coping the data...will remove once get trillium fix*/
|
||||||
if(f->type.val == CM_SDP_ATTR_T38_FAX_UNKNOWN) {
|
if(f->type.val == CM_SDP_ATTR_T38_FAX_UNKNOWN) {
|
||||||
if((i==0) && term->u.rtp.t38_options->T38FaxRateManagement){
|
if(!strncasecmp((char*)f->u.unknown.name.val,"transferredTCF",14) && term->u.rtp.t38_options->T38FaxRateManagement){
|
||||||
|
printf("KAPIL - adding FaxRateManagement \n");
|
||||||
MG_SET_TKNSTROSXL((f->u.unknown.name),strlen("FaxRateManagement"),"FaxRateManagement", memCp);
|
MG_SET_TKNSTROSXL((f->u.unknown.name),strlen("FaxRateManagement"),"FaxRateManagement", memCp);
|
||||||
MG_SET_TKNSTROSXL((f->u.unknown.val),
|
MG_SET_TKNSTROSXL((f->u.unknown.val),
|
||||||
strlen(term->u.rtp.t38_options->T38FaxRateManagement),
|
strlen(term->u.rtp.t38_options->T38FaxRateManagement),
|
||||||
term->u.rtp.t38_options->T38FaxRateManagement, memCp);
|
term->u.rtp.t38_options->T38FaxRateManagement, memCp);
|
||||||
}
|
}else if((!strncasecmp((char*)f->u.unknown.name.val,"t38UDPRedundancy",16)) && term->u.rtp.t38_options->T38FaxUdpEC){
|
||||||
if((i==1) && term->u.rtp.t38_options->T38FaxUdpEC){
|
printf("KAPIL - adding FaxUdpEC \n");
|
||||||
MG_SET_TKNSTROSXL((f->u.unknown.name),strlen("FaxUdpEC"),"FaxUdpEC", memCp);
|
MG_SET_TKNSTROSXL((f->u.unknown.name),strlen("FaxUdpEC"),"FaxUdpEC", memCp);
|
||||||
MG_SET_TKNSTROSXL((f->u.unknown.val),
|
MG_SET_TKNSTROSXL((f->u.unknown.val),
|
||||||
strlen(term->u.rtp.t38_options->T38FaxUdpEC),
|
strlen(term->u.rtp.t38_options->T38FaxUdpEC),
|
||||||
term->u.rtp.t38_options->T38FaxUdpEC, memCp);
|
term->u.rtp.t38_options->T38FaxUdpEC, memCp);
|
||||||
}
|
}else if(!strncasecmp((char*)f->u.unknown.name.val,"14400",5)){
|
||||||
if((i==2)){
|
|
||||||
char buf[10] = {0};
|
char buf[10] = {0};
|
||||||
|
printf("KAPIL - adding MaxBitRate \n");
|
||||||
sprintf(buf,"%d",term->u.rtp.t38_options->T38MaxBitRate);
|
sprintf(buf,"%d",term->u.rtp.t38_options->T38MaxBitRate);
|
||||||
MG_SET_TKNSTROSXL((f->u.unknown.name),strlen("MaxBitRate"),"MaxBitRate", memCp);
|
MG_SET_TKNSTROSXL((f->u.unknown.name),strlen("MaxBitRate"),"MaxBitRate", memCp);
|
||||||
MG_SET_TKNSTROSXL((f->u.unknown.val),
|
MG_SET_TKNSTROSXL((f->u.unknown.val),
|
||||||
@ -2065,16 +2067,19 @@ switch_status_t mg_rem_unsupported_codecs (megaco_profile_t* mg_profile, mg_term
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************************************************************/
|
/*****************************************************************************************************************************/
|
||||||
|
|
||||||
switch_status_t mg_build_sdp(MgMgcoMediaDesc* out, MgMgcoMediaDesc* inc, megaco_profile_t* mg_profile, mg_termination_t* term, CmMemListCp *memCp)
|
switch_status_t mg_build_sdp(MgMgcoMediaDesc* out, MgMgcoMediaDesc* inc, megaco_profile_t* mg_profile, mg_termination_t* term, CmMemListCp *memCp)
|
||||||
{
|
{
|
||||||
CmSdpU8OrNil *fmt = NULL;
|
CmSdpU8OrNil *fmt = NULL;
|
||||||
CmSdpInfoSet *psdp = NULL;
|
CmSdpInfoSet *psdp = NULL;
|
||||||
|
CmSdpInfoSet *pRsdp = NULL;
|
||||||
char* ipAddress[4];
|
char* ipAddress[4];
|
||||||
int i = 0x00;
|
int i = 0x00;
|
||||||
int j = 0x00;
|
int j = 0x00;
|
||||||
int choose_codec = 0x00;
|
int choose_codec = 0x00;
|
||||||
int k = 0x00;
|
int k = 0x00;
|
||||||
MgMgcoLocalDesc *local = NULL;
|
MgMgcoLocalDesc *local = NULL;
|
||||||
|
MgMgcoLocalDesc *remote = NULL;
|
||||||
int fresh_sdp = 0x00;
|
int fresh_sdp = 0x00;
|
||||||
char* dup = NULL;
|
char* dup = NULL;
|
||||||
CmSdpMedProtoFmts *format=NULL;
|
CmSdpMedProtoFmts *format=NULL;
|
||||||
@ -2107,17 +2112,51 @@ switch_status_t mg_build_sdp(MgMgcoMediaDesc* out, MgMgcoMediaDesc* inc, megaco_
|
|||||||
for(i=0; i<out->num.val; i++) {
|
for(i=0; i<out->num.val; i++) {
|
||||||
if(MGT_MEDIAPAR_LOCAL == out->parms[i]->type.val) {
|
if(MGT_MEDIAPAR_LOCAL == out->parms[i]->type.val) {
|
||||||
local = &out->parms[i]->u.local;
|
local = &out->parms[i]->u.local;
|
||||||
break;
|
|
||||||
} else if(MGT_MEDIAPAR_STRPAR == out->parms[i]->type.val){
|
} else if(MGT_MEDIAPAR_STRPAR == out->parms[i]->type.val){
|
||||||
MgMgcoStreamDesc *stream = &out->parms[i]->u.stream;
|
MgMgcoStreamDesc *stream = &out->parms[i]->u.stream;
|
||||||
if((NOTPRSNT != stream->sl.pres.pres) && (NOTPRSNT != stream->sl.local.pres.pres)){
|
if((NOTPRSNT != stream->sl.pres.pres) && (NOTPRSNT != stream->sl.local.pres.pres)){
|
||||||
local = &stream->sl.local;
|
local = &stream->sl.local;
|
||||||
}
|
}
|
||||||
|
}else if(MGT_MEDIAPAR_REMOTE == out->parms[i]->type.val) {
|
||||||
|
remote = &out->parms[i]->u.remote;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(remote && (NOTPRSNT != remote->sdp.numComp.pres) && (0 != remote->sdp.numComp.val)){
|
||||||
|
pRsdp = &(remote->sdp);
|
||||||
|
for(i=0; i< pRsdp->numComp.val; i++) {
|
||||||
|
/* fill media descriptors */
|
||||||
|
{
|
||||||
|
CmSdpMediaDescSet* med = &pRsdp->info[pRsdp->numComp.val-1]->mediaDescSet;
|
||||||
|
CmSdpMediaDesc* media;
|
||||||
|
|
||||||
|
if((NOTPRSNT != med->numComp.pres) || (0 != med->numComp.val)){
|
||||||
|
for(j =0;j < med->numComp.val; j++){
|
||||||
|
media = med->mediaDesc[j];
|
||||||
|
|
||||||
|
/* check for codec */
|
||||||
|
if((NOTPRSNT != media->field.par.numProtFmts.pres) ||
|
||||||
|
(0 != media->field.par.numProtFmts.val)){
|
||||||
|
for(k =0;k < media->field.par.numProtFmts.val; k++){
|
||||||
|
format = media->field.par.pflst[k];
|
||||||
|
if ((NOTPRSNT != format->protType.pres) &&
|
||||||
|
(CM_SDP_MEDIA_PROTO_UDPTL == format->protType.val)){
|
||||||
|
/* ideally whatever is received we can send back *
|
||||||
|
* due to issue in trillium , we need to manually copy the fields now */
|
||||||
|
mgco_fill_t38_sdp_attr(&media->attrSet, term, memCp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**********************************************************************************************************************************/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!local || (NOTPRSNT == local->sdp.numComp.pres) || (0 == local->sdp.numComp.val)){
|
if(!local || (NOTPRSNT == local->sdp.numComp.pres) || (0 == local->sdp.numComp.val)){
|
||||||
/* local sdp is not part of media descriptor, then add local sdp*/
|
/* local sdp is not part of media descriptor, then add local sdp*/
|
||||||
mg_add_local_descriptor(out, mg_profile, term, memCp);
|
mg_add_local_descriptor(out, mg_profile, term, memCp);
|
||||||
|
@ -71,7 +71,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
|
|||||||
for (mg_term = switch_xml_child(mg_phys_terms, "map"); mg_term; mg_term = mg_term->next) {
|
for (mg_term = switch_xml_child(mg_phys_terms, "map"); mg_term; mg_term = mg_term->next) {
|
||||||
// <map termination-id-prefix="Term1/" termination-id-base="1" tech="freetdm" channel-prefix="wp2" channel-map"1-15,17-31"/>
|
// <map termination-id-prefix="Term1/" termination-id-base="1" tech="freetdm" channel-prefix="wp2" channel-map"1-15,17-31"/>
|
||||||
const char *prefix = switch_xml_attr(mg_term, "termination-id-prefix");
|
const char *prefix = switch_xml_attr(mg_term, "termination-id-prefix");
|
||||||
//const char *sztermination_id_base = switch_xml_attr(mg_term, "termination-id-base");
|
const char *sztermination_id_base = switch_xml_attr(mg_term, "termination-id-base");
|
||||||
const char *tech = switch_xml_attr(mg_term, "tech");
|
const char *tech = switch_xml_attr(mg_term, "tech");
|
||||||
const char *channel_prefix = switch_xml_attr(mg_term, "channel-prefix");
|
const char *channel_prefix = switch_xml_attr(mg_term, "channel-prefix");
|
||||||
const char *channel_map = switch_xml_attr(mg_term, "channel-map");
|
const char *channel_map = switch_xml_attr(mg_term, "channel-map");
|
||||||
@ -84,6 +84,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
|
|||||||
int chanmap_count = 0;
|
int chanmap_count = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int startchan, endchan, j;
|
int startchan, endchan, j;
|
||||||
|
int mg_term_idx = (sztermination_id_base)?atoi(sztermination_id_base):1;
|
||||||
|
|
||||||
/* we can have following combinations *
|
/* we can have following combinations *
|
||||||
* i) only one channel i.e. channel-map="1"
|
* i) only one channel i.e. channel-map="1"
|
||||||
@ -103,14 +104,15 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
|
|||||||
startchan = atoi(chanmap[0]);
|
startchan = atoi(chanmap[0]);
|
||||||
endchan = atoi(chanmap[1]);
|
endchan = atoi(chanmap[1]);
|
||||||
for (j = startchan; j <= endchan; j++) {
|
for (j = startchan; j <= endchan; j++) {
|
||||||
mg_create_tdm_term(profile, tech, channel_prefix, prefix, j, j);
|
mg_create_tdm_term(profile, tech, channel_prefix, prefix, mg_term_idx, j);
|
||||||
|
mg_term_idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
/* case (i) */
|
/* case (i) */
|
||||||
p = channel_map_dup;
|
p = channel_map_dup;
|
||||||
startchan = endchan = atoi(p);
|
startchan = endchan = atoi(p);
|
||||||
mg_create_tdm_term(profile, tech, channel_prefix, prefix, startchan, startchan);
|
mg_create_tdm_term(profile, tech, channel_prefix, prefix, mg_term_idx, startchan);
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
@ -124,9 +126,10 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
|
|||||||
|
|
||||||
for (j = startchan; j <= endchan; j++) {
|
for (j = startchan; j <= endchan; j++) {
|
||||||
if (0 == i)
|
if (0 == i)
|
||||||
mg_create_tdm_term(profile, tech, channel_prefix, prefix, j, j);
|
mg_create_tdm_term(profile, tech, channel_prefix, prefix, mg_term_idx, j);
|
||||||
else
|
else
|
||||||
mg_create_tdm_term(profile, tech, channel_prefix, prefix, j, j-1);
|
mg_create_tdm_term(profile, tech, channel_prefix, prefix, mg_term_idx, j-1);
|
||||||
|
mg_term_idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user