fix pnp config for grandstream

This commit is contained in:
Michael Jerris 2012-06-19 14:22:57 -04:00
parent 1e696d2c93
commit ea503ea23e
2 changed files with 10 additions and 1 deletions

View File

@ -4935,6 +4935,8 @@ static void general_event_handler(switch_event_t *event)
const char *body = switch_event_get_body(event); const char *body = switch_event_get_body(event);
const char *to_uri = switch_event_get_header(event, "to-uri"); const char *to_uri = switch_event_get_header(event, "to-uri");
const char *from_uri = switch_event_get_header(event, "from-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; sofia_profile_t *profile;
@ -4993,7 +4995,8 @@ static void general_event_handler(switch_event_t *event)
nua_notify(nh, nua_notify(nh,
NUTAG_NEWSUB(1), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), 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)), 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); switch_safe_free(route_uri);

View 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 ) { if ( sip->sip_event && sip->sip_event->o_type && !strcasecmp(sip->sip_event->o_type, "ua-profile") && contact_host ) {
switch_event_t *params; switch_event_t *params;
char *uri = NULL; char *uri = NULL;
char *extra_headers = NULL;
if ( contact_port ) { if ( contact_port ) {
uri = switch_mprintf("sip:%s:%s", contact_host, 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 ) { if ( uri ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending pnp NOTIFY to %s\n", 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_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, "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, "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, "to-uri", uri);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "from-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_header_string(params, SWITCH_STACK_BOTTOM, "content-type", "application/url");
switch_event_add_body(params, "%s", profile->pnp_prov_url); switch_event_add_body(params, "%s", profile->pnp_prov_url);
switch_event_fire(&params); switch_event_fire(&params);
switch_safe_free(uri); switch_safe_free(uri);
switch_safe_free(extra_headers);
} }
} }