提交 99439756 authored 作者: Anthony Minessale's avatar Anthony Minessale

add optional call_id arg to sofia profile foo flush_inbound_reg [<call_id>]

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7965 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 d57e0387
...@@ -1327,8 +1327,14 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t ...@@ -1327,8 +1327,14 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
} }
if (!strcasecmp(argv[1], "flush_inbound_reg")) { if (!strcasecmp(argv[1], "flush_inbound_reg")) {
if (argc > 2) {
sofia_reg_expire_call_id(profile, argv[2]);
stream->write_function(stream, "+OK flushing all registrations matching specified call_id\n");
} else {
sofia_reg_check_expire(profile, 0); sofia_reg_check_expire(profile, 0);
stream->write_function(stream, "+OK\n"); stream->write_function(stream, "+OK flushing all registrations\n");
}
goto done; goto done;
} }
...@@ -1542,7 +1548,7 @@ SWITCH_STANDARD_API(sofia_function) ...@@ -1542,7 +1548,7 @@ SWITCH_STANDARD_API(sofia_function)
const char *usage_string = "USAGE:\n" const char *usage_string = "USAGE:\n"
"--------------------------------------------------------------------------------\n" "--------------------------------------------------------------------------------\n"
"sofia help\n" "sofia help\n"
"sofia profile <profile_name> [start|stop|restart|flush_inbound_reg|[register|unregister] [<gateway name>|all]] [reloadxml]\n" "sofia profile <profile_name> [start|stop|restart|flush_inbound_reg [<call_id>]|[register|unregister] [<gateway name>|all]] [reloadxml]\n"
"sofia status [[profile | gateway] <name>]\n" "sofia status [[profile | gateway] <name>]\n"
"sofia loglevel [0-9]\n" "sofia loglevel [0-9]\n"
"--------------------------------------------------------------------------------\n"; "--------------------------------------------------------------------------------\n";
......
...@@ -602,3 +602,4 @@ switch_status_t sofia_glue_build_crypto(private_object_t *tech_pvt, int index, s ...@@ -602,3 +602,4 @@ switch_status_t sofia_glue_build_crypto(private_object_t *tech_pvt, int index, s
void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt); void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt);
switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt); switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt);
void sofia_presence_event_thread_start(void); void sofia_presence_event_thread_start(void);
void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id);
...@@ -206,6 +206,24 @@ int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames ...@@ -206,6 +206,24 @@ int sofia_reg_del_callback(void *pArg, int argc, char **argv, char **columnNames
return 0; return 0;
} }
void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id)
{
char sql[1024];
char *psql = sql;
switch_snprintf(sql, sizeof(sql), "select *,'%s' from sip_registrations where call_id='%s'", profile->name, call_id);
switch_mutex_lock(profile->ireg_mutex);
sofia_glue_execute_sql_callback(profile,
SWITCH_TRUE,
NULL,
sql,
sofia_reg_del_callback,
NULL);
switch_mutex_unlock(profile->ireg_mutex);
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where call_id='%s'", call_id);
sofia_glue_execute_sql(profile, &psql, SWITCH_FALSE);
}
void sofia_reg_check_expire(sofia_profile_t *profile, time_t now) void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
{ {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论