提交 a6b85b7d authored 作者: root's avatar root

fixing two add for same termination back-2-back scenario, 2nd add should reject…

fixing two add for same termination back-2-back scenario, 2nd add should reject as term already in context
上级 ee8047eb
...@@ -185,6 +185,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha ...@@ -185,6 +185,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->mg_ctxt = NULL;
term->profile = profile; term->profile = profile;
switch_set_flag(term, MGT_ALLOCATED); switch_set_flag(term, MGT_ALLOCATED);
...@@ -231,6 +232,8 @@ void megaco_termination_destroy(mg_termination_t *term) ...@@ -231,6 +232,8 @@ void megaco_termination_destroy(mg_termination_t *term)
free(term->active_events); free(term->active_events);
term->active_events = NULL; term->active_events = NULL;
} }
term->mg_ctxt = NULL;
switch_clear_flag(term, MGT_ALLOCATED); switch_clear_flag(term, MGT_ALLOCATED);
switch_clear_flag(term, MGT_ACTIVE); switch_clear_flag(term, MGT_ACTIVE);
......
...@@ -566,6 +566,10 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i ...@@ -566,6 +566,10 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
goto error; goto error;
} }
if(!term->mg_ctxt){
term->mg_ctxt = mg_ctxt;
}
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name); 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;
...@@ -580,6 +584,15 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i ...@@ -580,6 +584,15 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
goto error; goto error;
} }
if(!term->mg_ctxt){
term->mg_ctxt = mg_ctxt;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Termination[%s] already in context..rejecting ADD \n", term->name);
mg_util_set_err_string(&errTxt, " Term already is in call ");
err_code = MGT_MGCP_RSP_CODE_PROT_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); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name);
} }
/********************************************************************/ /********************************************************************/
......
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
#define MG_INACTIVITY_TMR_RESOLUTION 100 /* mit in ito package is experessed in 10ms steps */ #define MG_INACTIVITY_TMR_RESOLUTION 100 /* mit in ito package is experessed in 10ms steps */
/* rtp/avp profiles */
#define MG_RTP_AVP_PROFILE_A_LAW 8
#define MG_RTP_AVP_PROFILE_U_LAW 0
typedef enum{ typedef enum{
MG_SDP_NONE, MG_SDP_NONE,
MG_SDP_LOCAL, MG_SDP_LOCAL,
......
...@@ -789,7 +789,7 @@ void mgco_print_CmSdpU8OrNil(CmSdpU8OrNil* p) ...@@ -789,7 +789,7 @@ void mgco_print_CmSdpU8OrNil(CmSdpU8OrNil* p)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"CmSdpU8OrNil: Value = %d \n", (NOTPRSNT != p->val.pres)?p->val.val:-1); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"CmSdpU8OrNil: Value = %d \n", (NOTPRSNT != p->val.pres)?p->val.val:-1);
} }
void mgco_print_sdp_media_param(CmSdpMedPar *s) void mgco_print_sdp_media_param(CmSdpMedPar *s, mg_termination_t* term, mgco_sdp_types_e sdp_type)
{ {
int i=0x00; int i=0x00;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "***** Media Parameter *********** \n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "***** Media Parameter *********** \n");
...@@ -832,6 +832,12 @@ void mgco_print_sdp_media_param(CmSdpMedPar *s) ...@@ -832,6 +832,12 @@ void mgco_print_sdp_media_param(CmSdpMedPar *s)
for(i=0;i<r->num.val;i++){ for(i=0;i<r->num.val;i++){
mgco_print_CmSdpU8OrNil(r->fmts[i]); mgco_print_CmSdpU8OrNil(r->fmts[i]);
if(MG_RTP_AVP_PROFILE_A_LAW == r->fmts[i]->val.val){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, " MG_RTP_AVP_PROFILE_A_LAW: \n");
}else if(MG_RTP_AVP_PROFILE_U_LAW == r->fmts[i]->val.val){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, " MG_RTP_AVP_PROFILE_U_LAW: \n");
}
} }
} }
break; break;
...@@ -1074,7 +1080,7 @@ void mgco_handle_sdp(CmSdpInfoSet *sdp, mg_termination_t* term, mgco_sdp_types_e ...@@ -1074,7 +1080,7 @@ void mgco_handle_sdp(CmSdpInfoSet *sdp, mg_termination_t* term, mgco_sdp_types_e
break; break;
} }
} }
mgco_print_sdp_media_param(&f->par); mgco_print_sdp_media_param(&f->par, term, sdp_type);
} }
/*info */ /*info */
......
...@@ -99,6 +99,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) ...@@ -99,6 +99,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
term->pool = pool; term->pool = pool;
term->type = MG_TERM_TDM; term->type = MG_TERM_TDM;
term->profile = profile; term->profile = profile;
term->mg_ctxt = NULL;
term->active_events = NULL;
term->name = switch_core_sprintf(pool, "%s%d", prefix, j); term->name = switch_core_sprintf(pool, "%s%d", prefix, j);
term->u.tdm.channel = j; term->u.tdm.channel = j;
term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix); term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix);
......
...@@ -94,6 +94,14 @@ enum { ...@@ -94,6 +94,14 @@ enum {
} mg_termination_flags; } mg_termination_flags;
struct mg_context_s {
uint32_t context_id;
mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS];
megaco_profile_t *profile;
mg_context_t *next;
switch_memory_pool_t *pool;
};
struct mg_termination_s { struct mg_termination_s {
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
mg_termination_type_t type; mg_termination_type_t type;
...@@ -104,6 +112,7 @@ struct mg_termination_s { ...@@ -104,6 +112,7 @@ struct mg_termination_s {
MgMgcoReqEvtDesc *active_events; /* !< active megaco events */ MgMgcoReqEvtDesc *active_events; /* !< active megaco events */
mg_termination_t *next; /*!< List for physical terminations */ mg_termination_t *next; /*!< List for physical terminations */
uint32_t flags; uint32_t flags;
mg_context_t* mg_ctxt;
union { union {
struct { struct {
...@@ -131,13 +140,7 @@ struct mg_termination_s { ...@@ -131,13 +140,7 @@ struct mg_termination_s {
}; };
struct mg_context_s {
uint32_t context_id;
mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS];
megaco_profile_t *profile;
mg_context_t *next;
switch_memory_pool_t *pool;
};
#define MG_CONTEXT_MODULO 16 #define MG_CONTEXT_MODULO 16
#define MG_MAX_CONTEXTS 32768 #define MG_MAX_CONTEXTS 32768
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论