]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
adding api to release all calls/context during Subtract with Context ALL(C=*{S=*...
authorKapil Gupta <kgupta@sangoma.com>
Fri, 7 Sep 2012 16:10:16 +0000 (12:10 -0400)
committerKapil Gupta <kgupta@sangoma.com>
Fri, 7 Sep 2012 16:10:16 +0000 (12:10 -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_stack_alarms.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h

index 1a1bba547504d4b49f005a548ecfb6d31e2e314b..2025ab2443886458c6da3124d8dbb1093c595a29 100644 (file)
@@ -781,6 +781,22 @@ switch_status_t megaco_profile_destroy(megaco_profile_t **profile)
        return SWITCH_STATUS_SUCCESS;
 }
 
+switch_status_t mgco_process_mgc_failure(SuId suId)
+{
+       megaco_profile_t*    profile = NULL;
+
+       if(NULL == (profile = megaco_get_profile_by_suId(suId))){
+               return SWITCH_STATUS_FALSE;
+       }
+
+       if(0x01 == profile->peer_active){
+               /* MGC failure during active association , release all on-going calls contexts */
+               megaco_release_all_calls(profile);
+               profile->peer_active = 0x00;
+       }
+
+       return SWITCH_STATUS_SUCCESS;
+}
 
 switch_status_t mgco_init_ins_service_change(SuId suId)
 {
index fe99a25b8d00b7ccf4eb8f400a34edf16d868a1d..db297c7ff12efe7a805f50816898e2789cde64c0 100644 (file)
@@ -1335,7 +1335,7 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
 
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," SUB Request for ALL context \n");
 
-        /* TODO */
+               megaco_release_all_calls(mg_profile);
 
         /* As of now sending +ve response */
         goto response;
index 0b8c5746e106b6be047c49c782547a55e96e6df1..4b1c80c220be586464508e24a80156fb49151ee7 100644 (file)
@@ -247,6 +247,8 @@ switch_status_t mg_activate_ito_timer(megaco_profile_t* profile);
 
 void mg_restart_inactivity_timer(megaco_profile_t* profile);
 
+switch_status_t mgco_process_mgc_failure(SuId suId);
+
 
 /****************************************************************************************************************/
 /* MG Stack defines */
index 6cba35d7c9cf9c686e50374c81b2591d8198863b..4c3e507fd16c920386fbc9afbd36c7afc32f94fe 100644 (file)
@@ -76,6 +76,7 @@ void handle_mg_alarm(Pst *pst, MgMngmt *usta)
        {
         case LMG_EVENT_ALL_MGC_FAILED:
             {
+                               //mgco_process_mgc_failure(usta->t.usta.alarmInfo.sapId);
                 len = len + sprintf(prBuf+len, "ALL MGC Failed ");
                 break;
             }
index 45f240901d487be8f7bf0cbcf149e2d0bacf00cf..395254031cbd835c8381ad196054acebd70b7c2d 100644 (file)
@@ -230,6 +230,25 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_media_gateway_shutdown)
     return SWITCH_STATUS_SUCCESS;
 }
 
+/*****************************************************************************************************************************/
+switch_status_t megaco_release_all_calls(megaco_profile_t* mg_profile)
+{
+       mg_context_t* ctx = NULL;
+       uint32_t  context_id = 0x00;
+
+       if(NULL == mg_profile) return SWITCH_STATUS_FALSE;
+
+       for (context_id = 0; context_id < MG_MAX_CONTEXTS; context_id++) {
+                       ctx = megaco_get_context(mg_profile, context_id);
+                       if(NULL == ctx) continue;
+
+                       megaco_context_sub_all_termination(ctx);
+                       megaco_release_context(ctx);
+       }
+
+    return SWITCH_STATUS_SUCCESS;
+}
+
 /*****************************************************************************************************************************/
 switch_status_t megaco_start_all_profiles()
 {
index 640b22d7e0deaa2e3d233d21b7489baec433d06b..004c5153b7fe119a0450d6c6e6b7539e46ea008c 100644 (file)
@@ -332,6 +332,7 @@ mg_termination_t* megaco_find_termination_by_span_chan(megaco_profile_t *profile
 switch_status_t megaco_start_all_profiles(void);
 switch_status_t megaco_profile_start(const char *profilename);
 switch_status_t megaco_profile_destroy(megaco_profile_t **profile);
+switch_status_t megaco_release_all_calls(megaco_profile_t* mg_profile);
 
 uint32_t mg_rtp_request_id(megaco_profile_t *profile);
 void mg_rtp_release_id(megaco_profile_t *profile, uint32_t id);