]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add patch from MODENDP-152
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 22 Nov 2008 01:50:21 +0000 (01:50 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 22 Nov 2008 01:50:21 +0000 (01:50 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10514 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c

index 4a58c7788eff69ee15b8dd02a05b0229bf415b84..838a0ee65cb11f893742d820072304cf26a86403 100644 (file)
@@ -75,6 +75,7 @@ typedef struct private_object private_object_t;
 #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_"
index 7f986bbaff5e2799731e231adb3e4cf53c83cc67..9d5edbdf7faae51181d5dab2bce31bfb1cf3b94b 100644 (file)
@@ -84,6 +84,7 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
 {
        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 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
                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 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
                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) {