integrating term/context alloc/delete api to megaco command handler code

This commit is contained in:
Kapil 2012-07-23 15:24:43 -04:00
parent 63c53a858b
commit d7e4b509b6
6 changed files with 377 additions and 195 deletions

View File

@ -167,6 +167,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
term->pool = pool; term->pool = pool;
term->type = termtype; term->type = termtype;
term->active_events = NULL; term->active_events = NULL;
term->profile = profile;
if (termtype == MG_TERM_RTP) { if (termtype == MG_TERM_RTP) {
/* Fill in local address and reserve an rtp port */ /* Fill in local address and reserve an rtp port */
@ -212,6 +213,23 @@ void megaco_termination_destroy(mg_termination_t *term)
switch_core_destroy_memory_pool(&term->pool); switch_core_destroy_memory_pool(&term->pool);
} }
switch_status_t megaco_context_is_term_present(mg_context_t *ctx, mg_termination_t *term)
{
switch_assert(ctx != NULL);
switch_assert(term != NULL);
if (ctx->terminations[0] && (term == ctx->terminations[0])) {
return SWITCH_STATUS_SUCCESS;
}
if (ctx->terminations[1] && (term == ctx->terminations[1])) {
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_FALSE;
}
switch_status_t megaco_context_add_termination(mg_context_t *ctx, mg_termination_t *term) switch_status_t megaco_context_add_termination(mg_context_t *ctx, mg_termination_t *term)
{ {
@ -247,6 +265,21 @@ switch_status_t megaco_context_add_termination(mg_context_t *ctx, mg_termination
} }
switch_status_t megaco_context_sub_all_termination(mg_context_t *ctx)
{
switch_assert(ctx != NULL);
/* Channels will automatically go to park once the bridge ends */
if (ctx->terminations[0]) {
megaco_termination_destroy(ctx->terminations[0]);
ctx->terminations[0] = NULL;
} else if (ctx->terminations[1]) {
megaco_termination_destroy(ctx->terminations[1]);
}
return SWITCH_STATUS_SUCCESS;
}
switch_status_t megaco_context_sub_termination(mg_context_t *ctx, mg_termination_t *term) switch_status_t megaco_context_sub_termination(mg_context_t *ctx, mg_termination_t *term)
{ {
switch_assert(ctx != NULL); switch_assert(ctx != NULL);
@ -315,7 +348,8 @@ mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id)
mg_context_t *megaco_choose_context(megaco_profile_t *profile) mg_context_t *megaco_choose_context(megaco_profile_t *profile)
{ {
mg_context_t *ctx; mg_context_t *ctx;
int i = 0x0;; int i = 0x0;
int j = 0x0;
switch_thread_rwlock_wrlock(profile->contexts_rwlock); switch_thread_rwlock_wrlock(profile->contexts_rwlock);
/* Try the next one */ /* Try the next one */
@ -332,6 +366,9 @@ mg_context_t *megaco_choose_context(megaco_profile_t *profile)
ctx = malloc(sizeof *ctx); ctx = malloc(sizeof *ctx);
ctx->context_id = profile->next_context_id; ctx->context_id = profile->next_context_id;
ctx->profile = profile; ctx->profile = profile;
for(j = 0; j< MG_CONTEXT_MAX_TERMS; j++){
ctx->terminations[j] = NULL;
}
if (!profile->contexts[i]) { if (!profile->contexts[i]) {
profile->contexts[i] = ctx; profile->contexts[i] = ctx;

View File

@ -319,26 +319,16 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
MgMgcoTermIdLst* termLst; MgMgcoTermIdLst* termLst;
int err_code; int err_code;
int is_rtp = 0x00; int is_rtp = 0x00;
char rtp_term_name[32];
MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.add; MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.add;
U32 txn_id = inc_cmd->transId.val; U32 txn_id = inc_cmd->transId.val;
mg_termination_t* term = NULL; mg_termination_t* term = NULL;
MgMgcoMediaDesc* inc_med_desc; MgMgcoMediaDesc* inc_med_desc;
MgMgcoAudRetParm *desc; MgMgcoAudRetParm *desc;
mg_context_t* mg_ctxt; mg_context_t* mg_ctxt;
MgMgcoStreamDesc *stream;
MgMgcoLocalDesc *local;
MgMgcoRemoteDesc* remote;
CmSdpInfoSet *psdp;
CmSdpInfoSet *prsdp;
char* ipAddress = "192.168.1.1";
/* TODO - Kapil dummy line , will need to add with proper code */ /* TODO - Kapil dummy line , will need to add with proper code */
inc_med_desc = &cmd->dl.descs[0]->u.media; inc_med_desc = &cmd->dl.descs[0]->u.media;
memset(&rtp_term_name[0], 0, 32);
/********************************************************************/ /********************************************************************/
ctxtId = &inc_cmd->contextId; ctxtId = &inc_cmd->contextId;
termLst = mg_get_term_id_list(inc_cmd); termLst = mg_get_term_id_list(inc_cmd);
@ -367,6 +357,12 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
mg_ctxt = megaco_choose_context(mg_profile); mg_ctxt = megaco_choose_context(mg_profile);
if(NULL == mg_ctxt){
mg_util_set_err_string(&errTxt, " Resource Failure ");
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
goto error;
}
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Context[%p] with context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Context[%p] with context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id);
/* fill Trillium Context structure with allocated context */ /* fill Trillium Context structure with allocated context */
@ -383,15 +379,34 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
if ((NOTPRSNT != termId->type.pres) && if ((NOTPRSNT != termId->type.pres) &&
(MGT_TERMID_CHOOSE == termId->type.val)){ (MGT_TERMID_CHOOSE == termId->type.val)){
term = megaco_choose_termination(mg_profile, "RTP"); /* TODO - RTP string has be configured one */
if(NULL == term){
mg_util_set_err_string(&errTxt, " Resource Failure ");
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
goto error;
}
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name);
is_rtp = 0x01; is_rtp = 0x01;
strcpy(rtp_term_name,"rtp/1");
/* TODO - Matt */ /* TODO - Matt */
/* allocate rtp term and associated the same to context */ /* allocate rtp term and associated the same to context */
/********************************************************************/ /********************************************************************/
}else{ /* Physical termination */ }else{ /* Physical termination */
/* TODO - Matt - associate physical termination to context */
/* get physical termination */
} }
/********************************************************************/
/* associate physical termination to context */
if(SWITCH_STATUS_FALSE == megaco_context_add_termination(mg_ctxt, term)){
mg_util_set_err_string(&errTxt, " Resource Failure ");
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
goto error;
}
/********************************************************************/ /********************************************************************/
ret = mg_prc_descriptors(mg_profile, inc_cmd, term); ret = mg_prc_descriptors(mg_profile, inc_cmd, term);
@ -458,7 +473,7 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
} }
out_termId = rsp.u.mgCmdRsp[0]->u.add.termIdLst.terms[rsp.u.mgCmdRsp[0]->u.add.termIdLst.num.val-1]; out_termId = rsp.u.mgCmdRsp[0]->u.add.termIdLst.terms[rsp.u.mgCmdRsp[0]->u.add.termIdLst.num.val-1];
mg_fill_mgco_termid(out_termId, (char*)rtp_term_name, strlen((char*)rtp_term_name), &rsp.u.mgCmdRsp[0]->memCp); mg_fill_mgco_termid(out_termId, (char*)term->name, strlen((char*)term->name), &rsp.u.mgCmdRsp[0]->memCp);
} }
/* Whatever Media descriptor we have received, we can copy that and then /* Whatever Media descriptor we have received, we can copy that and then
@ -480,6 +495,15 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
desc->type.val = MGT_MEDIADESC; desc->type.val = MGT_MEDIADESC;
mgUtlCpyMgMgcoMediaDesc(&desc->u.media, inc_med_desc, &rsp.u.mgCmdRsp[0]->memCp); mgUtlCpyMgMgcoMediaDesc(&desc->u.media, inc_med_desc, &rsp.u.mgCmdRsp[0]->memCp);
#if 0
{
MgMgcoStreamDesc *stream;
MgMgcoLocalDesc *local;
MgMgcoRemoteDesc* remote;
CmSdpInfoSet *psdp;
CmSdpInfoSet *prsdp;
char* ipAddress = "192.168.1.1";
/* Most probably we need to add local descriptor */ /* Most probably we need to add local descriptor */
@ -642,6 +666,8 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
else { else {
printf("!local->pres.pres false \n"); printf("!local->pres.pres false \n");
} }
}
#endif
@ -667,7 +693,7 @@ error:
mg_build_mgco_err_request(&mgErr, txn_id, ctxtId, err_code, &errTxt)) { mg_build_mgco_err_request(&mgErr, txn_id, ctxtId, err_code, &errTxt)) {
sng_mgco_send_err(mg_profile->idx, mgErr); sng_mgco_send_err(mg_profile->idx, mgErr);
} }
mg_free_cmd(cmd); mg_free_cmd(inc_cmd);
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
@ -683,6 +709,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;
MgMgcoContextId *ctxtId; MgMgcoContextId *ctxtId;
MgStr errTxt; MgStr errTxt;
MgMgcoInd *mgErr; MgMgcoInd *mgErr;
@ -691,7 +718,7 @@ switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand
mg_termination_t* term = NULL; mg_termination_t* term = NULL;
switch_status_t ret; switch_status_t ret;
int err_code; int err_code;
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;
/********************************************************************/ /********************************************************************/
@ -729,23 +756,72 @@ 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 */
/********************************************************************/
/* Matt - to check if we have terminations in the context */ /* MGT_TERMID_ROOT = If ROOT term then there will not be any conext */
/* TODO - Matt */ if(MGT_TERMID_ROOT == termId->type.val){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
"Modify request is for ROOT termination \n");
/* TODO */
/* Matt to indicate ERROR - If there is no terminations in requested context */ /********************************************************************/
} else if(MGT_TERMID_OTHER == termId->type.val){
/********************************************************************/
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
"Modify request is for termination[%s] and context: type[%d], value[%d] \n",
termId->name.lcl.val, ctxtId->type.val, ctxtId->val.val);
/* Kapil - If there is an error - send response back to MG stack with MGT_MGCO_RSP_CODE_NO_TERM_CTXT error code*/ term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
if(NULL == term){
mg_util_set_term_string(&errTxt,termId);
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID;
goto error;
}
/* termination specified...context should also be specified */
/* check if we have terminations in the context */
if (NOTPRSNT != ctxtId->type.pres) {
if(MGT_CXTID_OTHER == ctxtId->type.val) {
/*find context based on received context-id */
mg_ctxt = megaco_get_context(mg_profile, ctxtId->val.val);
if(NULL == mg_ctxt){
mg_util_set_ctxt_string(&errTxt, ctxtId);
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_CTXT;
goto error;
}
if(SWITCH_STATUS_FALSE == megaco_context_is_term_present(mg_ctxt, term)){
/* ERROR - termination didnt bind with requested context */
mg_util_set_term_string(&errTxt,termId);
err_code = MGT_MGCO_RSP_CODE_NO_TERM_CTXT;
goto error;
}
}else if(MGT_CXTID_NULL == ctxtId->type.val) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
"Modify request is for NULL Context \n");
/*TODO - NULL context...nothing to do now...jump to response to send +ve response */
goto response;
}else if(MGT_CXTID_ALL == ctxtId->type.val) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
"Modify request is for ALL Context \n");
/*TODO - ALL context...nothing to do now...jump to response to send +ve response */
goto response;
}
}
/* Not sure if MODIFY can come with Context ALL with specified term */
/********************************************************************/ /********************************************************************/
/* TODO - dummy code will replace with proper choose_termination api */
term = malloc(sizeof(*term));
term->active_events = NULL;
ret = mg_prc_descriptors(mg_profile, inc_cmd, term); ret = mg_prc_descriptors(mg_profile, inc_cmd, term);
}
/********************************************************************/ /********************************************************************/
/* Matt - to provide the response SDP structure which needs to fill in Modify command response */ /* Matt - to provide the response SDP structure which needs to fill in Modify command response */
@ -756,6 +832,7 @@ 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:
{ /* send response */ { /* send response */
MgMgcoCommand rsp; MgMgcoCommand rsp;
@ -812,7 +889,7 @@ error:
mg_build_mgco_err_request(&mgErr, txn_id, ctxtId, err_code, &errTxt)) { mg_build_mgco_err_request(&mgErr, txn_id, ctxtId, err_code, &errTxt)) {
sng_mgco_send_err(mg_profile->idx, mgErr); sng_mgco_send_err(mg_profile->idx, mgErr);
} }
mg_free_cmd(cmd); mg_free_cmd(inc_cmd);
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
@ -834,26 +911,40 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
MgMgcoTermId *termId; MgMgcoTermId *termId;
MgMgcoTermIdLst* termLst; MgMgcoTermIdLst* termLst;
int err_code; int err_code;
MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.add; /*MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.add;*/
U32 txn_id = inc_cmd->transId.val; U32 txn_id = inc_cmd->transId.val;
mg_context_t* mg_ctxt = NULL; mg_context_t* mg_ctxt = NULL;
mg_termination_t* term = NULL;
uint8_t wild = 0x00; uint8_t wild = 0x00;
wild = inc_cmd->u.mgCmdReq[0]->wild.pres; wild = inc_cmd->u.mgCmdReq[0]->wild.pres;
/********************************************************************/ /************************************************************************************************************************************************************/
ctxtId = &inc_cmd->contextId; ctxtId = &inc_cmd->contextId;
termLst = mg_get_term_id_list(inc_cmd); termLst = mg_get_term_id_list(inc_cmd);
termId = termLst->terms[0]; termId = termLst->terms[0];
/********************************************************************/ /************************************************************************************************************************************************************/
/* Validating Subtract request *******************************************/ /* Validating Subtract request *******************************************/
if(NOTPRSNT == ctxtId->type.pres){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," SUB Request processing failed, Context Not Present\n");
mg_util_set_ctxt_string(&errTxt, ctxtId);
err_code = MGT_MGCO_RSP_CODE_PROT_ERROR;
goto error;
}
if(NOTPRSNT == termId->type.pres){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," SUB Request processing failed, Termination Not Present\n");
mg_util_set_term_string(&errTxt,termId);
err_code = MGT_MGCO_RSP_CODE_PROT_ERROR;
goto error;
}
/*-- NULL Context & CHOOSE Context not applicable for SUB request --*/ /*-- NULL Context & CHOOSE Context not applicable for SUB request --*/
if ((NOTPRSNT != ctxtId->type.pres) && if ((MGT_CXTID_CHOOSE == ctxtId->type.val) ||
((MGT_CXTID_CHOOSE == ctxtId->type.val) || (MGT_CXTID_NULL == ctxtId->type.val)) {
(MGT_CXTID_NULL == ctxtId->type.val))) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," SUB Request processing failed, Context CHOOSE/NULL not allowed\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," SUB Request processing failed, Context CHOOSE/NULL not allowed\n");
@ -862,9 +953,8 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
goto error; goto error;
} }
/* ROOT Termination & CHOOSE Termination not allowed */ /* ROOT Termination & CHOOSE Termination not allowed */
else if ((NOTPRSNT != termId->type.pres) && else if ((MGT_TERMID_ROOT == termId->type.val) ||
((MGT_TERMID_ROOT == termId->type.val) || (MGT_TERMID_CHOOSE == termId->type.val)) {
(MGT_TERMID_CHOOSE == termId->type.val))) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," SUB Request processing failed, Termination ROOT/CHOOSE not allowed\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," SUB Request processing failed, Termination ROOT/CHOOSE not allowed\n");
@ -872,33 +962,76 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
err_code = MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER; err_code = MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER;
goto error; goto error;
} }
/************************************************************************************************************************************************************/
/********************************************************************/ if (MGT_CXTID_OTHER == ctxtId->type.val){
/* TODO - see if we receive wild card SUB for ALL context */
/********************************************************************/ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," SUB Request for Context[%d] \n", ctxtId->val.val);
/* Matt - TODO - check if we have terminations in the context */
/* Matt to indicate ERROR - If there is no terminations in requested context */
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Received context_id[%d]\n", ctxtId->val.val);
#if 0
/*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);
#endif if(NULL == mg_ctxt){
mg_util_set_ctxt_string(&errTxt, ctxtId);
if(mg_ctxt){ err_code = MGT_MGCO_RSP_CODE_UNKNOWN_CTXT;
goto error;
}
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Found Context[%p] for context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Found Context[%p] for context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id);
/* TODO - remove terminations from context....as if now there is no termination associated with Context */
if(MGT_TERMID_ALL == termId->type.val){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," SUB Request for context[%d] with ALL termination \n", mg_ctxt->context_id);
/* remove terminations from context */
megaco_context_sub_all_termination(mg_ctxt);
}else if(MGT_TERMID_OTHER == termId->type.val){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," SUB Request for termination[%s] \n", (char*)termId->name.lcl.val);
term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
if(SWITCH_STATUS_FALSE == megaco_context_is_term_present(mg_ctxt, term)){
/* ERROR - termination didnt bind with requested context */
mg_util_set_term_string(&errTxt,termId);
err_code = MGT_MGCO_RSP_CODE_NO_TERM_CTXT;
goto error;
}
if(NULL == term){
mg_util_set_term_string(&errTxt,termId);
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID;
goto error;
}
/* remove termination from context */
megaco_context_sub_termination(mg_ctxt, term);
}
/* release context*/ /* release context*/
megaco_release_context(mg_ctxt); megaco_release_context(mg_ctxt);
} }
/*************************************************************************************************************************/ /************************************************************************************************************************************************************/
/* CONTEXT = ALL */
if (MGT_CXTID_ALL == ctxtId->type.val){
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," SUB Request for ALL context \n");
/* TODO */
/* As of now sending +ve response */
goto response;
}
/************************************************************************************************************************************************************/
response:
/************************************************************************************************************************************************************/
/* resp code -- begin */ /* resp code -- begin */
{ {
MgMgcoCommand rsp; MgMgcoCommand rsp;
@ -951,7 +1084,7 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
} }
/* sample resp code -- end */ /* sample resp code -- end */
/*************************************************************************************************************************/ /************************************************************************************************************************************************************/
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -960,7 +1093,7 @@ error:
mg_build_mgco_err_request(&mgErr, txn_id, ctxtId, err_code, &errTxt)) { mg_build_mgco_err_request(&mgErr, txn_id, ctxtId, err_code, &errTxt)) {
sng_mgco_send_err(mg_profile->idx, mgErr); sng_mgco_send_err(mg_profile->idx, mgErr);
} }
mg_free_cmd(cmd); mg_free_cmd(inc_cmd);
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }

View File

@ -132,6 +132,7 @@ void handle_mg_alarm(Pst *pst, MgMngmt *sta);
void handle_tucl_alarm(Pst *pst, HiMngmt *sta); void handle_tucl_alarm(Pst *pst, HiMngmt *sta);
int mg_enable_logging(void); int mg_enable_logging(void);
int mg_disable_logging(void); int mg_disable_logging(void);
void mg_util_set_err_string ( MgStr *errTxt, char* str);
switch_status_t sng_mgco_cfg(megaco_profile_t* profile); switch_status_t sng_mgco_cfg(megaco_profile_t* profile);

View File

@ -318,6 +318,13 @@ void mg_util_set_txn_string(MgStr *errTxt, U32 *txnId)
} }
/*****************************************************************************************************************************/
void mg_util_set_err_string ( MgStr *errTxt, char* str)
{
MG_ZERO((errTxt->val), sizeof(errTxt->val));
errTxt->len = strlen(str);
strcpy((char*)&errTxt->val, str);
}
/*****************************************************************************************************************************/ /*****************************************************************************************************************************/
void mg_util_set_ctxt_string ( MgStr *errTxt, MgMgcoContextId *ctxtId) void mg_util_set_ctxt_string ( MgStr *errTxt, MgMgcoContextId *ctxtId)
{ {

View File

@ -500,7 +500,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
/*If term type is other then check if that term is configured with us..for term type CHOOSE/ALL , no need to check */ /*If term type is other then check if that term is configured with us..for term type CHOOSE/ALL , no need to check */
if (MGT_TERMID_OTHER == termId->type.val){ if (MGT_TERMID_OTHER == termId->type.val){
if(SWITCH_STATUS_FALSE != mg_stack_termination_is_in_service((char*)termId->name.lcl.val, termId->name.lcl.len)){ if(SWITCH_STATUS_FALSE == mg_stack_termination_is_in_service((char*)termId->name.lcl.val, termId->name.lcl.len)){
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;

View File

@ -210,6 +210,8 @@ void mg_rtp_release_id(megaco_profile_t *profile, uint32_t id);
mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id); mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id);
mg_context_t *megaco_choose_context(megaco_profile_t *profile); mg_context_t *megaco_choose_context(megaco_profile_t *profile);
void megaco_release_context(mg_context_t *ctx); void megaco_release_context(mg_context_t *ctx);
switch_status_t megaco_context_sub_termination(mg_context_t *ctx, mg_termination_t *term);
switch_status_t megaco_context_sub_all_termination(mg_context_t *ctx);
mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const char *prefix); mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const char *prefix);
mg_termination_t *megaco_find_termination(megaco_profile_t *profile, const char *name); mg_termination_t *megaco_find_termination(megaco_profile_t *profile, const char *name);
@ -225,6 +227,8 @@ switch_status_t mg_config_cleanup(megaco_profile_t* profile);
switch_status_t mg_peer_config_cleanup(mg_peer_profile_t* profile); switch_status_t mg_peer_config_cleanup(mg_peer_profile_t* profile);
switch_status_t megaco_peer_profile_destroy(mg_peer_profile_t **profile); switch_status_t megaco_peer_profile_destroy(mg_peer_profile_t **profile);
switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stream); switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stream);
switch_status_t megaco_context_add_termination(mg_context_t *ctx, mg_termination_t *term);
switch_status_t megaco_context_is_term_present(mg_context_t *ctx, mg_termination_t *term);
#endif /* MOD_MEGACO_H */ #endif /* MOD_MEGACO_H */