[Freeswitch-svn] [commit] r7965 - freeswitch/trunk/src/mod/endpoints/mod_sofia
Author: anthm Date: Tue Mar 25 18:06:48 2008 New Revision: 7965 Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Log: add optional call_id arg to sofia profile foo flush_inbound_reg [<call_id>] Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Mar 25 18:06:48 2008 @@ -1325,10 +1325,16 @@ stream->write_function(stream, "Invalid Profile [%s]", switch_str_nil(profile_name)); return SWITCH_STATUS_SUCCESS; } - + if (!strcasecmp(argv[1], "flush_inbound_reg")) { - sofia_reg_check_expire(profile, 0); - stream->write_function(stream, "+OK\n"); + 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); + stream->write_function(stream, "+OK flushing all registrations\n"); + } + goto done; } @@ -1542,7 +1548,7 @@ const char *usage_string = "USAGE:\n" "--------------------------------------------------------------------------------\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 loglevel [0-9]\n" "--------------------------------------------------------------------------------\n"; Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Tue Mar 25 18:06:48 2008 @@ -602,3 +602,4 @@ 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); void sofia_presence_event_thread_start(void); +void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id); Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Tue Mar 25 18:06:48 2008 @@ -206,6 +206,24 @@ 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) {
participants (1)
-
Freeswitch SVN