[Freeswitch-svn] [commit] r8102 - freeswitch/trunk/src/mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Mon Apr 14 11:28:07 EDT 2008
Author: anthm
Date: Mon Apr 14 11:28:07 2008
New Revision: 8102
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
add unregister-on-options-fail
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 Mon Apr 14 11:28:07 2008
@@ -138,6 +138,7 @@
PFLAG_SECURE = (1 << 15),
PFLAG_BLIND_AUTH = (1 << 16),
PFLAG_WORKER_RUNNING = (1 << 17),
+ PFLAG_UNREG_OPTIONS_FAIL = (1 << 18)
} PFLAGS;
typedef enum {
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Apr 14 11:28:07 2008
@@ -61,6 +61,9 @@
static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
+static void sofia_handle_sip_r_options(switch_core_session_t *session, int status,
+ char const *phrase,
+ nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
void sofia_handle_sip_r_notify(switch_core_session_t *session, int status,
char const *phrase,
@@ -274,9 +277,11 @@
case nua_r_invite:
sofia_handle_sip_r_invite(session, status, phrase, nua, profile, nh, sofia_private, sip, tags);
break;
+ case nua_r_options:
+ sofia_handle_sip_r_options(session, status, phrase, nua, profile, nh, sofia_private, sip, tags);
+ break;
case nua_r_get_params:
case nua_r_unregister:
- case nua_r_options:
case nua_i_fork:
case nua_r_info:
case nua_r_bye:
@@ -1152,6 +1157,10 @@
if (switch_true(val)) {
profile->pflags |= PFLAG_PRESENCE;
}
+ } else if (!strcasecmp(var, "unregister-on-options-fail")) {
+ if (switch_true(val)) {
+ profile->pflags |= PFLAG_UNREG_OPTIONS_FAIL;
+ }
} else if (!strcasecmp(var, "require-secure-rtp")) {
if (switch_true(val)) {
profile->pflags |= PFLAG_SECURE;
@@ -1438,6 +1447,27 @@
return status;
}
+static void sofia_handle_sip_r_options(switch_core_session_t *session, int status,
+ char const *phrase,
+ nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
+{
+ if ((profile->pflags & PFLAG_UNREG_OPTIONS_FAIL) && status != 200 && sip && sip->sip_to) {
+ time_t now = switch_timestamp(NULL);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n",
+ sip->sip_to->a_url->url_user,
+ sip->sip_to->a_url->url_host
+ );
+
+ char *sql = switch_mprintf("update sip_registratons set expired=%ld where sip_user='%s' and sip_host='%s'",
+ (long)now,
+ sip->sip_to->a_url->url_user,
+ sip->sip_to->a_url->url_host
+ );
+ sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
+ }
+}
+
+
static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
More information about the Freeswitch-svn
mailing list