[Freeswitch-svn] [commit] r10514 - freeswitch/trunk/src/mod/endpoints/mod_sofia

FreeSWITCH SVN anthm at freeswitch.org
Fri Nov 21 17:50:21 PST 2008


Author: anthm
Date: Fri Nov 21 20:50:21 2008
New Revision: 10514

Log:
add patch from MODENDP-152

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

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	Fri Nov 21 20:50:21 2008
@@ -75,6 +75,7 @@
 #define MY_EVENT_UNREGISTER "sofia::unregister"
 #define MY_EVENT_EXPIRE "sofia::expire"
 #define MY_EVENT_GATEWAY_STATE "sofia::gateway_state"
+#define MY_EVENT_NOTIFY_REFER "sofia::notify_refer"
 
 #define MULTICAST_EVENT "multicast::event"
 #define SOFIA_REPLACES_HEADER "_sofia_replaces_"

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	Fri Nov 21 20:50:21 2008
@@ -84,6 +84,7 @@
 {
 	switch_channel_t *channel = NULL;
 	private_object_t *tech_pvt = NULL;
+	switch_event_t *s_event = NULL;
 
 	/* make sure we have a proper event */
 	if (!sip || !sip->sip_event) {
@@ -95,7 +96,7 @@
 		nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
 		return;
 	}
-	
+
 	if (session) {
 		channel = switch_core_session_get_channel(session);
 		switch_assert(channel != NULL);
@@ -103,6 +104,49 @@
 		switch_assert(tech_pvt != NULL);
 	}
 
+	/* For additional NOTIFY event packages see http://www.iana.org/assignments/sip-events. */
+	if (!strcasecmp(sip->sip_event->o_type, "refer")) {
+		if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_NOTIFY_REFER) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "content-type", sip->sip_content_type->c_type);
+			switch_event_add_body(s_event, "%s", sip->sip_payload->pl_data);
+		}
+	}
+
+	/* add common headers for the NOTIFY to the switch_event and fire if it exists */
+	if (s_event != NULL) {
+		switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event-package", sip->sip_event->o_type);
+		switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event-id", sip->sip_event->o_id);
+
+		switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "contact", "%s@%s", 
+								sip->sip_contact->m_url->url_user, sip->sip_contact->m_url->url_host);
+		switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", 
+								sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host);
+		switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-tag", sip->sip_from->a_tag);
+		switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", 
+								sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
+		switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "to-tag", sip->sip_to->a_tag);
+
+		if (sip->sip_call_id && sip->sip_call_id->i_id) {
+			switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "call-id", sip->sip_call_id->i_id);
+		}
+		if (sip->sip_subscription_state && sip->sip_subscription_state->ss_substate) {
+			switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "subscription-substate", sip->sip_subscription_state->ss_substate);
+		}
+		if (sip->sip_subscription_state && sip->sip_subscription_state->ss_reason) {
+			switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "subscription-reason", sip->sip_subscription_state->ss_reason);
+		}
+		if (sip->sip_subscription_state && sip->sip_subscription_state->ss_retry_after) {
+			switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "subscription-retry-after", sip->sip_subscription_state->ss_retry_after);
+		}
+		if (sip->sip_subscription_state && sip->sip_subscription_state->ss_expires) {
+			switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "subscription-expires", sip->sip_subscription_state->ss_expires);
+		}
+		if (session) {
+			switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "UniqueID", switch_core_session_get_uuid(session));
+		}
+		switch_event_fire(&s_event);
+	}
+
 	if (!strcasecmp(sip->sip_event->o_type, "refer")) {
 		if (session && channel && tech_pvt) {
 			if (sip->sip_payload && sip->sip_payload->pl_data) {



More information about the Freeswitch-svn mailing list