]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix pnp config for grandstream
authorMichael Jerris <mike@jerris.com>
Tue, 19 Jun 2012 18:22:57 +0000 (14:22 -0400)
committerMichael Jerris <mike@jerris.com>
Tue, 19 Jun 2012 18:22:57 +0000 (14:22 -0400)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index 5766eff62d168225f7dae9df1f55c2849033705a..0f80cda54b2c244bfa49593c1a8766b3febf73fb 100644 (file)
@@ -4935,6 +4935,8 @@ static void general_event_handler(switch_event_t *event)
                        const char *body = switch_event_get_body(event);
                        const char *to_uri = switch_event_get_header(event, "to-uri");
                        const char *from_uri = switch_event_get_header(event, "from-uri");
+                       const char *extra_headers = switch_event_get_header(event, "extra-headers");
+
                        sofia_profile_t *profile;
 
 
@@ -4993,7 +4995,8 @@ static void general_event_handler(switch_event_t *event)
                                        nua_notify(nh,
                                                           NUTAG_NEWSUB(1), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
                                                           TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
-                                                          SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END());
+                                                          SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
+                                                          TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
                                        
 
                                        switch_safe_free(route_uri);
index fd7357ed821ea769dbbaabf50a62bb9cbdbe62c1..0d52ee0e95d5609104b4d26fa0131c361163a64c 100644 (file)
@@ -3654,6 +3654,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
        if ( sip->sip_event && sip->sip_event->o_type && !strcasecmp(sip->sip_event->o_type, "ua-profile") && contact_host ) {
                switch_event_t *params;
                char *uri = NULL;
+               char *extra_headers = NULL;
 
                if ( contact_port ) {
                        uri = switch_mprintf("sip:%s:%s", contact_host, contact_port);
@@ -3664,16 +3665,21 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                if ( uri ) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending pnp NOTIFY to %s\n", uri);
 
+                       /* Grandstream REALLY uses a header called Message Body */
+                       extra_headers = switch_mprintf("Message Body: %s\r\n", profile->pnp_prov_url);
+
                        switch_event_create(&params, SWITCH_EVENT_NOTIFY);
                        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", profile->pnp_notify_profile);
                        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "event-string", sip->sip_event->o_type);
                        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "to-uri", uri);
                        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "from-uri", uri);
+                       switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "extra-headers", extra_headers);
                        switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "content-type", "application/url");
                        switch_event_add_body(params, "%s", profile->pnp_prov_url);
                        switch_event_fire(&params);
 
                        switch_safe_free(uri);
+                       switch_safe_free(extra_headers);
                }
        }