[Freeswitch-svn] [commit] r8113 - freeswitch/branches/cseket/src/mod/endpoints/mod_sofia

Freeswitch SVN cseket at freeswitch.org
Mon Apr 14 13:57:47 EDT 2008


Author: cseket
Date: Mon Apr 14 13:57:47 2008
New Revision: 8113

Modified:
   freeswitch/branches/cseket/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/branches/cseket/src/mod/endpoints/mod_sofia/sofia.c

Log:
merge from trunk 8112

Modified: freeswitch/branches/cseket/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/cseket/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/branches/cseket/src/mod/endpoints/mod_sofia/mod_sofia.h	Mon Apr 14 13:57:47 2008
@@ -139,6 +139,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/branches/cseket/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/cseket/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/branches/cseket/src/mod/endpoints/mod_sofia/sofia.c	Mon Apr 14 13:57:47 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;
@@ -1456,6 +1465,28 @@
 	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) {
+		char *sql;
+		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
+						  );
+
+		sql = switch_mprintf("update sip_registrations 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