]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add sofia profile <profile> gwlist up|down to list up or downed profiles for feeding...
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 17 Sep 2010 19:11:57 +0000 (14:11 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 17 Sep 2010 19:11:57 +0000 (14:11 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_glue.c

index 5039fefe502a250c877e08ee914091dac61de2cf..1e8876e6381157ff5e364ecf8035542fd004d4e8 100644 (file)
@@ -3166,6 +3166,21 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
                goto done;
        }
 
+
+       if (!strcasecmp(argv[1], "gwlist")) {
+               int up = 1;
+               
+               if (argc > 2) {
+                       if (!strcasecmp(argv[2], "down")) {
+                               up = 0;
+                       }
+               }
+
+               sofia_glue_gateway_list(profile, stream, up);
+               goto done;
+       }
+
+
        stream->write_function(stream, "-ERR Unknown command!\n");
 
   done:
@@ -4637,6 +4652,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
        switch_console_set_complete("add sofia profile ::sofia::list_profiles siptrace on");
        switch_console_set_complete("add sofia profile ::sofia::list_profiles siptrace off");
 
+       switch_console_set_complete("add sofia profile ::sofia::list_profiles gwlist up");
+       switch_console_set_complete("add sofia profile ::sofia::list_profiles gwlist down");
+
        switch_console_set_complete("add sofia status profile ::sofia::list_profiles");
        switch_console_set_complete("add sofia status profile ::sofia::list_profiles reg");
        switch_console_set_complete("add sofia status gateway ::sofia::list_gateways");
index 96acbcd9edbb9951624d40c1fb68fe2b4709838a..5a6995806a9ce751effa7fe46ec02cef3893846a 100644 (file)
@@ -942,6 +942,7 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int
 const char *sofia_glue_strip_proto(const char *uri);
 switch_status_t reconfig_sofia(sofia_profile_t *profile);
 void sofia_glue_del_gateway(sofia_gateway_t *gp);
+void sofia_glue_gateway_list(sofia_profile_t *profile, switch_stream_handle_t *stream, int up);
 void sofia_glue_del_every_gateway(sofia_profile_t *profile);
 void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent,
                                                   const char *network_ip);
index d17981c9d0ea528c56ddd31d20ea61276eb7ee06..498230789af4806e7e2b0677dd761a31d797d468 100644 (file)
@@ -4267,6 +4267,28 @@ void sofia_glue_del_every_gateway(sofia_profile_t *profile)
 }
 
 
+void sofia_glue_gateway_list(sofia_profile_t *profile, switch_stream_handle_t *stream, int up)
+{
+       sofia_gateway_t *gp = NULL;
+       char *r = (char *) stream->data;
+
+       switch_mutex_lock(mod_sofia_globals.hash_mutex);
+       for (gp = profile->gateways; gp; gp = gp->next) {
+               int reged = (gp->state == REG_STATE_REGED);
+               
+               if (up ? reged : !reged) {
+                       stream->write_function(stream, "%s ", gp->name);
+               }
+       }
+
+       if (r) {
+               end_of(r) = '\0';
+       }
+
+       switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+}
+
+
 void sofia_glue_del_gateway(sofia_gateway_t *gp)
 {
        if (!gp->deleted) {