From 8e47f3c660276bc653f6cb1ac2611d5345244bd9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 22 Feb 2012 15:26:38 -0600 Subject: [PATCH] FS-3937 --resolve --- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia_glue.c | 24 ++++++++++++++++++++ src/mod/endpoints/mod_sofia/sofia_presence.c | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 0a2f672df6..9947e3778e 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -1117,6 +1117,7 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use const char *body, const char *o_contact, const char *network_ip); char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix); void sofia_glue_set_extra_headers(switch_core_session_t *session, sip_t const *sip, const char *prefix); +char *sofia_glue_get_extra_headers_from_event(switch_event_t *event, const char *prefix); void sofia_info_send_sipfrag(switch_core_session_t *aleg, switch_core_session_t *bleg); void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *profile, sip_t const *sip, switch_bool_t send); void sofia_send_callee_id(switch_core_session_t *session, const char *name, const char *number); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index d8824dae33..43de002cd4 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1975,6 +1975,30 @@ void sofia_glue_set_extra_headers(switch_core_session_t *session, sip_t const *s switch_channel_api_on(channel, "api_on_sip_extra_headers"); } +char *sofia_glue_get_extra_headers_from_event(switch_event_t *event, const char *prefix) +{ + char *extra_headers = NULL; + switch_stream_handle_t stream = { 0 }; + switch_event_header_t *hp; + + SWITCH_STANDARD_STREAM(stream); + for (hp = event->headers; hp; hp = hp->next) { + if (!zstr(hp->name) && !zstr(hp->value) && !strncasecmp(hp->name, prefix, strlen(prefix))) { + char *name = strdup(hp->name); + const char *hname = name + strlen(prefix); + stream.write_function(&stream, "%s: %s\r\n", hname, (char *)hp->value); + free(name); + } + } + + if (!zstr((char *) stream.data)) { + extra_headers = stream.data; + } else { + switch_safe_free(stream.data); + } + + return extra_headers; +} switch_status_t sofia_glue_do_invite(switch_core_session_t *session) { diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index ecedd8898e..e469eaca22 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -116,6 +116,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) char header[256] = ""; char *route_uri = NULL; const char *network_ip = NULL, *network_port = NULL, *from_proto; + char *extra_headers = NULL; proto = switch_event_get_header(message_event, "proto"); from_proto = switch_event_get_header(message_event, "from_proto"); @@ -129,6 +130,8 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) network_ip = switch_event_get_header(message_event, "to_sip_ip"); network_port = switch_event_get_header(message_event, "to_sip_port"); + extra_headers = sofia_glue_get_extra_headers_from_event(message_event, SOFIA_SIP_HEADER_PREFIX); + if (!to) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To: header.\n"); goto end; @@ -322,6 +325,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(body), SIPTAG_HEADER_STR(header), + TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); sofia_glue_free_destination(dst);