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);
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)
{
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");
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;
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);