From 25e7be1c60abdfa30a573559fecf3b6b1af29177 Mon Sep 17 00:00:00 2001 From: Raymond Chandler Date: Wed, 16 Oct 2013 10:56:01 -0400 Subject: [PATCH] FS-2731 apply patch --- src/mod/endpoints/mod_sofia/mod_sofia.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index b99c7aae96..7286c5de16 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -4557,6 +4557,9 @@ static int notify_csta_callback(void *pArg, int argc, char **argv, char **column char *ct = argv[i++]; char *id = NULL; char *contact; + sip_cseq_t *cseq = NULL; + uint32_t callsequence; + uint32_t now = (uint32_t) switch_epoch_time_now(NULL); sofia_destination_t *dst = NULL; char *route_uri = NULL; @@ -4581,14 +4584,22 @@ static int notify_csta_callback(void *pArg, int argc, char **argv, char **column route_uri = sofia_glue_strip_uri(dst->route_uri); } + switch_mutex_lock(profile->ireg_mutex); + if (!profile->cseq_base) { + profile->cseq_base = (now - 1312693200) * 10; + } + callsequence = ++profile->cseq_base; + switch_mutex_unlock(profile->ireg_mutex); + //nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END()); - nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(full_from), SIPTAG_TO_STR(full_to), SIPTAG_CONTACT_STR(profile->url), TAG_END()); + nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(full_to), SIPTAG_TO_STR(full_from), SIPTAG_CONTACT_STR(profile->url), TAG_END()); + cseq = sip_cseq_create(nh->nh_home, callsequence, SIP_METHOD_NOTIFY); nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_notify(nh, NUTAG_NEWSUB(1), TAG_IF(dst->route_uri, NUTAG_PROXY(route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)), - SIPTAG_EVENT_STR("as-feature-event"), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END()); + SIPTAG_EVENT_STR("as-feature-event"), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), SIPTAG_CSEQ(cseq), TAG_END()); @@ -4872,7 +4883,7 @@ static void general_event_handler(switch_event_t *event) SWITCH_STANDARD_STREAM(fwdi_stream); write_csta_xml_chunk(event, fwdi_stream, "ForwardingEvent", "forwardImmediate"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] is %d bytes long\n", (char *)fwdi_stream.data, (int)strlen(fwdi_stream.data)); - stream.write_function(&stream, "--%s\nContent-Type: application/x-as-feature-event+xml\nContent-Length:%d\nContent-ID:<%s@%s>\n\n%s", boundary_string, strlen(fwdi_stream.data), user, host, fwdi_stream.data); + stream.write_function(&stream, "--%s\r\nContent-Type: application/x-as-feature-event+xml\r\nContent-Length: %d\r\nContent-ID: <%si@%s>\r\n\r\n%s", boundary_string, strlen(fwdi_stream.data), user, host, fwdi_stream.data); switch_safe_free(fwdi_stream.data); } if ((header_name = switch_event_get_header(event, "forward_busy"))) { @@ -4880,7 +4891,7 @@ static void general_event_handler(switch_event_t *event) SWITCH_STANDARD_STREAM(fwdb_stream); write_csta_xml_chunk(event, fwdb_stream, "ForwardingEvent", "forwardBusy"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] is %d bytes long\n", (char *)fwdb_stream.data, (int)strlen(fwdb_stream.data)); - stream.write_function(&stream, "--%s\nContent-Type: application/x-as-feature-event+xml\nContent-Length:%d\nContent-ID:<%s@%s>\n\n%s", boundary_string, strlen(fwdb_stream.data), user, host, fwdb_stream.data); + stream.write_function(&stream, "--%s\r\nContent-Type: application/x-as-feature-event+xml\r\nContent-Length: %d\r\nContent-ID: <%sb@%s>\r\n\r\n%s", boundary_string, strlen(fwdb_stream.data), user, host, fwdb_stream.data); switch_safe_free(fwdb_stream.data); } if ((header_name = switch_event_get_header(event, "forward_no_answer"))) { @@ -4888,17 +4899,17 @@ static void general_event_handler(switch_event_t *event) SWITCH_STANDARD_STREAM(fwdna_stream); write_csta_xml_chunk(event, fwdna_stream, "ForwardingEvent", "forwardNoAns"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] is %d bytes long\n", (char *)fwdna_stream.data, (int)strlen(fwdna_stream.data)); - stream.write_function(&stream, "--%s\nContent-Type: application/x-as-feature-event+xml\nContent-Length:%d\nContent-ID:<%s@%s>\n\n%s", boundary_string, strlen(fwdna_stream.data), user, host, fwdna_stream.data); + stream.write_function(&stream, "--%s\r\nContent-Type: application/x-as-feature-event+xml\r\nContent-Length: %d\r\nContent-ID: <%sn@%s>\r\n\r\n%s", boundary_string, strlen(fwdna_stream.data), user, host, fwdna_stream.data); switch_safe_free(fwdna_stream.data); } SWITCH_STANDARD_STREAM(dnd_stream); write_csta_xml_chunk(event, dnd_stream, "DoNotDisturbEvent", NULL); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] is %d bytes long\n", (char *)dnd_stream.data, (int)strlen(dnd_stream.data)); - stream.write_function(&stream, "--%s\nContent-Type:application/x-as-feature-event+xml\nContent-Length:%d\nContent-ID:<%s@%s>\n\n%s", boundary_string, strlen(dnd_stream.data), user, host, dnd_stream.data); + stream.write_function(&stream, "--%s\r\nContent-Type: application/x-as-feature-event+xml\r\nContent-Length: %d\r\nContent-ID: <%sd@%s>\r\n\r\n%s", boundary_string, strlen(dnd_stream.data), user, host, dnd_stream.data); switch_safe_free(dnd_stream.data); - stream.write_function(&stream, "--%s--\n", boundary_string); + stream.write_function(&stream, "--%s--\r\n", boundary_string); ct = switch_mprintf("multipart/mixed; boundary=\"%s\"", boundary_string); } else {