diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index a9d05ce8db..4cd0868be0 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2875,7 +2875,6 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t stream->write_function(stream, "CALLS-OUT \t%u\n", profile->ob_calls); stream->write_function(stream, "FAILED-CALLS-OUT \t%u\n", profile->ob_failed_calls); } - stream->write_function(stream, "\nRegistrations:\n%s\n", line); cb.profile = profile; cb.stream = stream; @@ -2892,6 +2891,12 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host" " from sip_registrations where profile_name='%q' and contact like '%%%q%%'", profile->name, argv[3]); } + if (!sql && argv[2] && !strcasecmp(argv[2], "reg")) { + sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status," + "rpid,expires,user_agent,server_user,server_host,profile_name,hostname," + "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host" + " from sip_registrations where profile_name='%q'", profile->name); + } if (!sql && argv[2] && !strcasecmp(argv[2], "user") && argv[3]) { char *dup = strdup(argv[3]); char *host = NULL, *user = NULL; @@ -2922,20 +2927,18 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t switch_safe_free(sqlextra); } - if (!sql) { - sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status," - "rpid,expires,user_agent,server_user,server_host,profile_name,hostname," - "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host" - " from sip_registrations where profile_name='%q'", profile->name); + if (sql) { + stream->write_function(stream, "\nRegistrations:\n%s\n", line); + + sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, show_reg_callback, &cb); + switch_safe_free(sql); + + stream->write_function(stream, "Total items returned: %d\n", cb.row_process); + stream->write_function(stream, "%s\n", line); } - sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, show_reg_callback, &cb); - switch_safe_free(sql); - - stream->write_function(stream, "Total items returned: %d\n", cb.row_process); - stream->write_function(stream, "%s\n", line); - sofia_glue_release_profile(profile); + } else { stream->write_function(stream, "Invalid Profile!\n"); } @@ -3981,7 +3984,7 @@ SWITCH_STANDARD_API(sofia_function) " siptrace \n" " capture \n" " watchdog \n\n" - "sofia profile [reg ] | [pres ] | [user ]\n" + "sofia profile [reg []] | [pres ] | [user ]\n" "sofia gateway \n\n" "sofia loglevel [0-9]\n" "sofia tracelevel \n\n"