]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fixing two add for same termination back-2-back scenario, 2nd add should reject as...
authorroot <root@nsg-media-test.sangoma.local>
Thu, 26 Jul 2012 17:50:43 +0000 (13:50 -0400)
committerroot <root@nsg-media-test.sangoma.local>
Thu, 26 Jul 2012 17:50:43 +0000 (13:50 -0400)
src/mod/endpoints/mod_media_gateway/media_gateway.c
src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c
src/mod/endpoints/mod_media_gateway/media_gateway_stack.h
src/mod/endpoints/mod_media_gateway/media_gateway_utils.c
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h

index 3d10abf05cd2d991be9f4fa97450d7d48e560509..e47055236aa5d36fb2c45dac1553fa6d0cb43615 100644 (file)
@@ -185,6 +185,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
     term->pool = pool;
     term->type = termtype;
     term->active_events = NULL;
+    term->mg_ctxt = NULL;
     term->profile = profile;
     switch_set_flag(term, MGT_ALLOCATED);
     
@@ -231,6 +232,8 @@ void megaco_termination_destroy(mg_termination_t *term)
         free(term->active_events);
         term->active_events = NULL;
     }
+
+    term->mg_ctxt = NULL;
     
     switch_clear_flag(term, MGT_ALLOCATED);
     switch_clear_flag(term, MGT_ACTIVE);
index 27fe1a4a4baa507ecd22b6dfe4690cf5942cb6f2..57c8843aee59e1f04f633c821c133b3808cf5a3a 100644 (file)
@@ -566,6 +566,10 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
             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);
 
         is_rtp = 0x01;
@@ -580,6 +584,15 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
                    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);
     }
     /********************************************************************/
index 9401ce49ce918d0ead9730cacebc6940cb6b8f03..e5c16df9c03df4f8e6815b7620774e694f39563c 100644 (file)
 
 #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{
        MG_SDP_NONE,
        MG_SDP_LOCAL,
index 56a1ffdc3a27486c1e52952575c32860623c488f..908b6041188778f77b0c7c26e9f0d9caa2265bfd 100644 (file)
@@ -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); 
 }
 
-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;
     switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "***** Media Parameter *********** \n");
@@ -832,6 +832,12 @@ void mgco_print_sdp_media_param(CmSdpMedPar *s)
 
                             for(i=0;i<r->num.val;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;
@@ -1074,7 +1080,7 @@ void mgco_handle_sdp(CmSdpInfoSet *sdp, mg_termination_t* term, mgco_sdp_types_e
                                                                break;
                                                }
                                        }
-                                       mgco_print_sdp_media_param(&f->par);
+                                       mgco_print_sdp_media_param(&f->par, term, sdp_type);
                                }
 
                                /*info */
index f30c1d955d9064fde8d7a5c91e1399ba13d6f3e1..e3c3b8c3de9dadd65f6bf32b24db118147efe984 100644 (file)
@@ -99,6 +99,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
                                 term->pool = pool;
                                 term->type = MG_TERM_TDM;
                                 term->profile = profile;
+                                term->mg_ctxt = NULL;
+                               term->active_events = NULL;
                                 term->name = switch_core_sprintf(pool, "%s%d", prefix, j);
                                 term->u.tdm.channel = j;
                                 term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix);
index bf2fda7a05b86a74fb839d724ea75da9467d86cf..e0022d8ecd38b1fe3f4e28729e36bed0b842a35f 100644 (file)
@@ -94,6 +94,14 @@ enum {
     
 } 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 {
     switch_memory_pool_t *pool;
     mg_termination_type_t type;
@@ -104,6 +112,7 @@ struct mg_termination_s {
     MgMgcoReqEvtDesc  *active_events;     /* !< active megaco events */
     mg_termination_t *next; /*!< List for physical terminations */
     uint32_t flags;
+    mg_context_t* mg_ctxt;
     
     union {
         struct {
@@ -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_MAX_CONTEXTS 32768