clean up indenting in sofia

This commit is contained in:
Anthony Minessale 2010-06-23 13:22:52 -05:00
parent 39f6c58557
commit 0bff1a411b
3 changed files with 274 additions and 319 deletions

View File

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs -T size_t " > ./.indent.pro echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs -T size_t " > ./.indent.pro
grep "typedef struct.*_t;" `find ./src/include/ -name \*.h` | grep apr_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro
grep "typedef struct.*_t;" `find ./src/include/ -name \*.h` | grep switch_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro for i in `find src/ -name \*.c` ; do cat $i | perl -ne 'print "-T $1 " if (/([0-9A-Za-z_-]+_t)/)' ; done | sort | uniq >> ./.indent.pro
grep "} switch_" ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ./.indent.pro for i in `find src/ -name \*.h` ; do cat $i | perl -ne 'print "-T $1 " if (/([0-9A-Za-z_-]+_t)/)' ; done | sort | uniq >> ./.indent.pro

View File

@ -109,7 +109,9 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
if (!sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) { if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) {
switch_channel_set_state(channel, CS_RESET);
} else {
if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) { if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
switch_channel_set_state(channel, CS_EXECUTE); switch_channel_set_state(channel, CS_EXECUTE);
} else { } else {
@ -119,7 +121,7 @@ static switch_status_t sofia_on_init(switch_core_session_t *session)
} }
} }
end: end:
switch_mutex_unlock(tech_pvt->sofia_mutex); switch_mutex_unlock(tech_pvt->sofia_mutex);
@ -168,7 +170,10 @@ static switch_status_t sofia_on_reset(switch_core_session_t *session)
int x = 0; int x = 0;
if (other_uuid) { if (other_uuid) {
for(x = 0; other_session == NULL && x < 5; x++) { for (x = 0; other_session == NULL && x < 20; x++) {
if (!switch_channel_up(channel)) {
break;
}
other_session = switch_core_session_locate(other_uuid); other_session = switch_core_session_locate(other_uuid);
switch_yield(100000); switch_yield(100000);
} }
@ -178,11 +183,8 @@ static switch_status_t sofia_on_reset(switch_core_session_t *session)
switch_channel_t *other_channel = switch_core_session_get_channel(other_session); switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
switch_channel_clear_flag(channel, CF_BRIDGE_ORIGINATOR); switch_channel_clear_flag(channel, CF_BRIDGE_ORIGINATOR);
switch_channel_wait_for_state_timeout(other_channel, CS_RESET, 5000); switch_channel_wait_for_state_timeout(other_channel, CS_RESET, 5000);
switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL); switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 2000, NULL);
switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
if (switch_channel_test_flag(channel, CF_PROXY_MODE) && switch_channel_test_flag(other_channel, CF_PROXY_MODE)) { if (switch_channel_test_flag(channel, CF_PROXY_MODE) && switch_channel_test_flag(other_channel, CF_PROXY_MODE)) {
switch_ivr_signal_bridge(session, other_session); switch_ivr_signal_bridge(session, other_session);
} else { } else {
@ -251,7 +253,7 @@ char *generate_pai_str(switch_core_session_t *session)
if (zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "effective_callee_id_number"))) && if (zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "effective_callee_id_number"))) &&
zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number"))) && zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number"))) &&
zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "callee_id_number")))) { zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "callee_id_number")))) {
callee_number = tech_pvt->caller_profile->destination_number; callee_number = tech_pvt->caller_profile->destination_number;
} }
@ -374,7 +376,7 @@ switch_status_t sofia_on_destroy(switch_core_session_t *session)
switch_mutex_unlock(tech_pvt->profile->flag_mutex); switch_mutex_unlock(tech_pvt->profile->flag_mutex);
sofia_glue_deactivate_rtp(tech_pvt); sofia_glue_deactivate_rtp(tech_pvt);
if (sofia_test_pflag(tech_pvt->profile, PFLAG_DESTROY) && !tech_pvt->profile->inuse) { if (sofia_test_pflag(tech_pvt->profile, PFLAG_DESTROY) && !tech_pvt->profile->inuse) {
sofia_profile_destroy(tech_pvt->profile); sofia_profile_destroy(tech_pvt->profile);
} }
@ -399,7 +401,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
if ((gateway_name = switch_channel_get_variable(channel, "sip_gateway_name"))) { if ((gateway_name = switch_channel_get_variable(channel, "sip_gateway_name"))) {
gateway_ptr = sofia_reg_find_gateway(gateway_name); gateway_ptr = sofia_reg_find_gateway(gateway_name);
} }
switch_mutex_lock(tech_pvt->sofia_mutex); switch_mutex_lock(tech_pvt->sofia_mutex);
rec = sofia_test_flag(tech_pvt, TFLAG_RECOVERING); rec = sofia_test_flag(tech_pvt, TFLAG_RECOVERING);
@ -415,16 +417,16 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
} else { } else {
tech_pvt->profile->ib_failed_calls++; tech_pvt->profile->ib_failed_calls++;
} }
if (gateway_ptr) { if (gateway_ptr) {
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
gateway_ptr->ob_failed_calls++; gateway_ptr->ob_failed_calls++;
} else { } else {
gateway_ptr->ib_failed_calls++; gateway_ptr->ib_failed_calls++;
} }
} }
} }
if (gateway_ptr) { if (gateway_ptr) {
sofia_reg_release_gateway(gateway_ptr); sofia_reg_release_gateway(gateway_ptr);
} }
@ -462,7 +464,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
} }
if (sofia_test_pflag(tech_pvt->profile, PFLAG_DESTROY)) { if (sofia_test_pflag(tech_pvt->profile, PFLAG_DESTROY)) {
sofia_set_flag(tech_pvt, TFLAG_BYE); sofia_set_flag(tech_pvt, TFLAG_BYE);
} else if (tech_pvt->nh && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { } else if (tech_pvt->nh && !sofia_test_flag(tech_pvt, TFLAG_BYE)) {
char reason[128] = ""; char reason[128] = "";
char *bye_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX); char *bye_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX);
@ -897,7 +899,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
} }
return status; return status;
} }
/* Try to read an RTCP frame, if successful raise an event */ /* Try to read an RTCP frame, if successful raise an event */
if (switch_rtcp_zerocopy_read_frame(tech_pvt->rtp_session, &rtcp_frame) == SWITCH_STATUS_SUCCESS) { if (switch_rtcp_zerocopy_read_frame(tech_pvt->rtp_session, &rtcp_frame) == SWITCH_STATUS_SUCCESS) {
switch_event_t *event; switch_event_t *event;
@ -905,7 +907,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
if (switch_event_create(&event, SWITCH_EVENT_RECV_RTCP_MESSAGE) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_RECV_RTCP_MESSAGE) == SWITCH_STATUS_SUCCESS) {
char buf[30]; char buf[30];
char* uuid = switch_core_session_get_uuid(session); char *uuid = switch_core_session_get_uuid(session);
if (uuid) { if (uuid) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session)); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));
} }
@ -922,10 +924,10 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
snprintf(buf, sizeof(buf), "%u", rtcp_frame.timestamp); snprintf(buf, sizeof(buf), "%u", rtcp_frame.timestamp);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "RTP-Timestamp", buf); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "RTP-Timestamp", buf);
snprintf(buf, sizeof(buf), "%u", rtcp_frame.packet_count); snprintf(buf, sizeof(buf), "%u", rtcp_frame.packet_count);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Sender-Packet-Count", buf); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Sender-Packet-Count", buf);
snprintf(buf, sizeof(buf), "%u", rtcp_frame.octect_count); snprintf(buf, sizeof(buf), "%u", rtcp_frame.octect_count);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Octect-Packet-Count", buf); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Octect-Packet-Count", buf);
snprintf(buf, sizeof(buf), "%" SWITCH_SIZE_T_FMT, tech_pvt->read_frame.timestamp); snprintf(buf, sizeof(buf), "%" SWITCH_SIZE_T_FMT, tech_pvt->read_frame.timestamp);
@ -989,9 +991,9 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
if (tech_pvt->last_codec_ms && tech_pvt->last_codec_ms == codec_ms) { if (tech_pvt->last_codec_ms && tech_pvt->last_codec_ms == codec_ms) {
tech_pvt->mismatch_count++; tech_pvt->mismatch_count++;
} }
tech_pvt->last_codec_ms = codec_ms; tech_pvt->last_codec_ms = codec_ms;
if (tech_pvt->mismatch_count > MAX_MISMATCH_FRAMES) { if (tech_pvt->mismatch_count > MAX_MISMATCH_FRAMES) {
if (switch_rtp_ready(tech_pvt->rtp_session) && codec_ms != tech_pvt->codec_ms) { if (switch_rtp_ready(tech_pvt->rtp_session) && codec_ms != tech_pvt->codec_ms) {
const char *val; const char *val;
@ -1017,8 +1019,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
"ShoreTel\n" "ShoreTel\n"
"Sonus/L3\n" "Sonus/L3\n"
"We will try to fix it but some of the devices on this list are so broken,\n" "We will try to fix it but some of the devices on this list are so broken,\n"
"who knows what will happen..\n", "who knows what will happen..\n", (int) tech_pvt->codec_ms, (int) codec_ms);
(int) tech_pvt->codec_ms, (int) codec_ms);
switch_channel_set_variable_printf(channel, "sip_h_X-Broken-PTIME", "Adv=%d;Sent=%d", switch_channel_set_variable_printf(channel, "sip_h_X-Broken-PTIME", "Adv=%d;Sent=%d",
(int) tech_pvt->codec_ms, (int) codec_ms); (int) tech_pvt->codec_ms, (int) codec_ms);
@ -1090,7 +1091,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
tech_pvt->mismatch_count = 0; tech_pvt->mismatch_count = 0;
tech_pvt->last_ts = 0; tech_pvt->last_ts = 0;
} }
skip: skip:
if ((bytes = tech_pvt->read_impl.encoded_bytes_per_packet)) { if ((bytes = tech_pvt->read_impl.encoded_bytes_per_packet)) {
frames = (tech_pvt->read_frame.datalen / bytes); frames = (tech_pvt->read_frame.datalen / bytes);
@ -1223,7 +1224,7 @@ static void start_udptl(private_object_t *tech_pvt, switch_t38_options_t *t38_op
t38_options->remote_ip, t38_options->remote_port); t38_options->remote_ip, t38_options->remote_port);
return; return;
} }
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, t38_options->remote_ip, if (switch_rtp_set_remote_address(tech_pvt->rtp_session, t38_options->remote_ip,
t38_options->remote_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { t38_options->remote_port, 0, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "IMAGE UDPTL REPORTS ERROR: [%s]\n", err); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "IMAGE UDPTL REPORTS ERROR: [%s]\n", err);
@ -1539,19 +1540,19 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
case SWITCH_MESSAGE_INDICATE_UDPTL_MODE: case SWITCH_MESSAGE_INDICATE_UDPTL_MODE:
{ {
switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options"); switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
if (!t38_options) { if (!t38_options) {
nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END()); nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
goto end_lock; goto end_lock;
} }
start_udptl(tech_pvt, t38_options); start_udptl(tech_pvt, t38_options);
} }
case SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION: case SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION:
{ {
switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options"); switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
if (!t38_options) { if (!t38_options) {
nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END()); nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
goto end_lock; goto end_lock;
@ -1560,7 +1561,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
start_udptl(tech_pvt, t38_options); start_udptl(tech_pvt, t38_options);
sofia_glue_set_image_sdp(tech_pvt, t38_options, msg->numeric_arg); sofia_glue_set_image_sdp(tech_pvt, t38_options, msg->numeric_arg);
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX); char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
if (sofia_use_soa(tech_pvt)) { if (sofia_use_soa(tech_pvt)) {
@ -1570,8 +1571,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")), SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")),
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
TAG_END());
} else { } else {
nua_respond(tech_pvt->nh, SIP_200_OK, nua_respond(tech_pvt->nh, SIP_200_OK,
NUTAG_AUTOANSWER(0), NUTAG_AUTOANSWER(0),
@ -1579,13 +1579,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")), SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")),
SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_CONTENT_TYPE_STR("application/sdp"),
SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_END());
} }
switch_safe_free(extra_headers); switch_safe_free(extra_headers);
sofia_set_flag_locked(tech_pvt, TFLAG_ANS); sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
} }
} }
break; break;
@ -1594,7 +1592,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options"); switch_t38_options_t *t38_options = switch_channel_get_private(tech_pvt->channel, "t38_options");
sofia_glue_set_image_sdp(tech_pvt, t38_options, msg->numeric_arg); sofia_glue_set_image_sdp(tech_pvt, t38_options, msg->numeric_arg);
switch_channel_set_flag(channel, CF_REQ_MEDIA); switch_channel_set_flag(channel, CF_REQ_MEDIA);
sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE); sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
sofia_glue_do_invite(session); sofia_glue_do_invite(session);
@ -1822,10 +1820,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
mydata = switch_core_session_strdup(session, dest); mydata = switch_core_session_strdup(session, dest);
len = strlen(mydata) * 2; len = strlen(mydata) * 2;
newdest = switch_core_session_alloc(session, len); newdest = switch_core_session_alloc(session, len);
argc = switch_split(mydata, ',', argv); argc = switch_split(mydata, ',', argv);
for(i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
if (!strchr(argv[i], '<') && !strchr(argv[i], '>')) { if (!strchr(argv[i], '<') && !strchr(argv[i], '>')) {
if (i == argc - 1) { if (i == argc - 1) {
switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>", argv[i]); switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>", argv[i]);
@ -1840,7 +1838,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
} }
} }
} }
dest = newdest; dest = newdest;
} else { } else {
@ -1848,7 +1846,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
dest = switch_core_session_sprintf(session, "\"unknown\" <%s>", dest); dest = switch_core_session_sprintf(session, "\"unknown\" <%s>", dest);
} }
} }
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Redirecting to %s\n", dest); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Redirecting to %s\n", dest);
if (argc > 1) { if (argc > 1) {
@ -1864,7 +1862,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
switch_safe_free(extra_headers); switch_safe_free(extra_headers);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Too late for redirecting, already answered\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Too late for redirecting, already answered\n");
} }
} }
break; break;
@ -2034,7 +2032,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX); char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full"); const char *call_info = switch_channel_get_variable(channel, "presence_call_info_full");
switch (ring_ready_val) { switch (ring_ready_val) {
case SWITCH_RING_READY_QUEUED: case SWITCH_RING_READY_QUEUED:
@ -2150,7 +2148,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) { if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX); char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) && if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) &&
tech_pvt->early_sdp && strcmp(tech_pvt->early_sdp, tech_pvt->local_sdp_str)) { tech_pvt->early_sdp && strcmp(tech_pvt->early_sdp, tech_pvt->local_sdp_str)) {
/* The SIP RFC for SOA forbids sending a 183 with one sdp then a 200 with another but it won't do us much good unless /* The SIP RFC for SOA forbids sending a 183 with one sdp then a 200 with another but it won't do us much good unless
we do so in this case we will abandon the SOA rules and go rogue. we do so in this case we will abandon the SOA rules and go rogue.
@ -2199,7 +2197,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
break; break;
} }
end_lock: end_lock:
//if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) { //if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) {
//sofia_send_callee_id(session, NULL, NULL); //sofia_send_callee_id(session, NULL, NULL);
@ -2207,7 +2205,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
switch_mutex_unlock(tech_pvt->sofia_mutex); switch_mutex_unlock(tech_pvt->sofia_mutex);
end: end:
if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) { if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
status = SWITCH_STATUS_FALSE; status = SWITCH_STATUS_FALSE;
@ -2263,9 +2261,9 @@ const char *sofia_state_string(int state)
} }
struct cb_helper_sql2str { struct cb_helper_sql2str {
char *buf; char *buf;
size_t len; size_t len;
int matches; int matches;
}; };
struct cb_helper { struct cb_helper {
@ -2289,7 +2287,7 @@ static int show_reg_callback(void *pArg, int argc, char **argv, char **columnNam
time_t now = switch_epoch_time_now(NULL); time_t now = switch_epoch_time_now(NULL);
switch_time_t etime = atoi(argv[6]); switch_time_t etime = atoi(argv[6]);
switch_size_t retsize; switch_size_t retsize;
exp_secs = etime - now; exp_secs = etime - now;
switch_time_exp_lt(&tm, switch_time_from_sec(etime)); switch_time_exp_lt(&tm, switch_time_from_sec(etime));
switch_strftime_nocheck(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm);
@ -2335,19 +2333,21 @@ static int show_reg_callback_xml(void *pArg, int argc, char **argv, char **colum
switch_strftime_nocheck(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm);
} }
cb->stream->write_function(cb->stream," <registration>\n"); cb->stream->write_function(cb->stream, " <registration>\n");
cb->stream->write_function(cb->stream," <call-id>%s</call-id>\n", switch_str_nil(argv[0])); cb->stream->write_function(cb->stream, " <call-id>%s</call-id>\n", switch_str_nil(argv[0]));
cb->stream->write_function(cb->stream," <user>%s@%s</user>\n", switch_str_nil(argv[1]), switch_str_nil(argv[2])); cb->stream->write_function(cb->stream, " <user>%s@%s</user>\n", switch_str_nil(argv[1]), switch_str_nil(argv[2]));
cb->stream->write_function(cb->stream," <contact>%s</contact>\n", switch_amp_encode(switch_str_nil(argv[3]), xmlbuf, buflen)); cb->stream->write_function(cb->stream, " <contact>%s</contact>\n", switch_amp_encode(switch_str_nil(argv[3]), xmlbuf, buflen));
cb->stream->write_function(cb->stream," <agent>%s</agent>\n", switch_str_nil(argv[7])); cb->stream->write_function(cb->stream, " <agent>%s</agent>\n", switch_str_nil(argv[7]));
cb->stream->write_function(cb->stream," <status>%s(%s) exp(%s) expsecs(%d)</status>\n", switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, exp_secs); cb->stream->write_function(cb->stream, " <status>%s(%s) exp(%s) expsecs(%d)</status>\n", switch_str_nil(argv[4]), switch_str_nil(argv[5]),
cb->stream->write_function(cb->stream," <host>%s</host>\n", switch_str_nil(argv[11])); exp_buf, exp_secs);
cb->stream->write_function(cb->stream," <network-ip>%s</network-ip>\n", switch_str_nil(argv[12])); cb->stream->write_function(cb->stream, " <host>%s</host>\n", switch_str_nil(argv[11]));
cb->stream->write_function(cb->stream," <network-port>%s</network-port>\n", switch_str_nil(argv[13])); cb->stream->write_function(cb->stream, " <network-ip>%s</network-ip>\n", switch_str_nil(argv[12]));
cb->stream->write_function(cb->stream," <sip-auth-user>%s</sip-auth-user>\n", switch_url_encode(switch_str_nil(argv[14]), xmlbuf, sizeof(xmlbuf))); cb->stream->write_function(cb->stream, " <network-port>%s</network-port>\n", switch_str_nil(argv[13]));
cb->stream->write_function(cb->stream," <sip-auth-realm>%s</sip-auth-realm>\n", switch_str_nil(argv[15])); cb->stream->write_function(cb->stream, " <sip-auth-user>%s</sip-auth-user>\n",
cb->stream->write_function(cb->stream," <mwi-account>%s@%s</mwi-account>\n", switch_str_nil(argv[16]), switch_str_nil(argv[17])); switch_url_encode(switch_str_nil(argv[14]), xmlbuf, sizeof(xmlbuf)));
cb->stream->write_function(cb->stream," </registration>\n"); cb->stream->write_function(cb->stream, " <sip-auth-realm>%s</sip-auth-realm>\n", switch_str_nil(argv[15]));
cb->stream->write_function(cb->stream, " <mwi-account>%s@%s</mwi-account>\n", switch_str_nil(argv[16]), switch_str_nil(argv[17]));
cb->stream->write_function(cb->stream, " </registration>\n");
return 0; return 0;
} }
@ -2368,7 +2368,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
if (argc > 0) { if (argc > 0) {
if (argc == 1) { if (argc == 1) {
/* show summary of all gateways*/ /* show summary of all gateways */
uint32_t ib_failed = 0; uint32_t ib_failed = 0;
uint32_t ib = 0; uint32_t ib = 0;
@ -2383,7 +2383,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
profile = (sofia_profile_t *) val; profile = (sofia_profile_t *) val;
if (sofia_test_pflag(profile, PFLAG_RUNNING)) { if (sofia_test_pflag(profile, PFLAG_RUNNING)) {
if (!strcmp(vvar, profile->name)) { /* not an alias */ if (!strcmp(vvar, profile->name)) { /* not an alias */
for (gp = profile->gateways; gp; gp = gp->next) { for (gp = profile->gateways; gp; gp = gp->next) {
char *pkey = switch_mprintf("%s::%s", profile->name, gp->name); char *pkey = switch_mprintf("%s::%s", profile->name, gp->name);
@ -2395,9 +2395,9 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
ob_failed += gp->ob_failed_calls; ob_failed += gp->ob_failed_calls;
ob += gp->ob_calls; ob += gp->ob_calls;
stream->write_function(stream, "%25s\t%32s\t%s\t%ld/%ld\t%ld/%ld", stream->write_function(stream, "%25s\t%32s\t%s\t%ld/%ld\t%ld/%ld",
pkey, gp->register_to, sofia_state_names[gp->state], pkey, gp->register_to, sofia_state_names[gp->state],
gp->ib_failed_calls, gp->ib_calls, gp->ob_failed_calls, gp->ob_calls); gp->ib_failed_calls, gp->ib_calls, gp->ob_failed_calls, gp->ob_calls);
if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) { if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
time_t now = switch_epoch_time_now(NULL); time_t now = switch_epoch_time_now(NULL);
@ -2415,8 +2415,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
switch_mutex_unlock(mod_sofia_globals.hash_mutex); switch_mutex_unlock(mod_sofia_globals.hash_mutex);
stream->write_function(stream, "%s\n", line); stream->write_function(stream, "%s\n", line);
stream->write_function(stream, "%d gateway%s: Inound(Failed/Total): %ld/%ld," stream->write_function(stream, "%d gateway%s: Inound(Failed/Total): %ld/%ld,"
"Outbound(Failed/Total):%ld/%ld\n", c, c == 1 ? "" : "s", "Outbound(Failed/Total):%ld/%ld\n", c, c == 1 ? "" : "s", ib_failed, ib, ob_failed, ob);
ib_failed, ib, ob_failed, ob);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -2457,7 +2456,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
} else if (!strcasecmp(argv[0], "profile")) { } else if (!strcasecmp(argv[0], "profile")) {
struct cb_helper cb; struct cb_helper cb;
char *sql = NULL; char *sql = NULL;
int x = 0 ; int x = 0;
cb.row_process = 0; cb.row_process = 0;
@ -2624,9 +2623,8 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
char *pkey = switch_mprintf("%s::%s", profile->name, gp->name); char *pkey = switch_mprintf("%s::%s", profile->name, gp->name);
switch_assert(gp->state < REG_STATE_LAST); switch_assert(gp->state < REG_STATE_LAST);
stream->write_function(stream, "%25s\t%s\t %40s\t%s", stream->write_function(stream, "%25s\t%s\t %40s\t%s", pkey, "gateway", gp->register_to, sofia_state_names[gp->state]);
pkey, "gateway", gp->register_to, sofia_state_names[gp->state]);
free(pkey); free(pkey);
if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) { if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
@ -2663,45 +2661,45 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
if (argc > 0) { if (argc > 0) {
if (argc == 1) { if (argc == 1) {
/* show summary of all gateways */ /* show summary of all gateways */
stream->write_function(stream, "%s\n", header); stream->write_function(stream, "%s\n", header);
stream->write_function(stream, "<gateways>\n", header); stream->write_function(stream, "<gateways>\n", header);
switch_mutex_lock(mod_sofia_globals.hash_mutex); switch_mutex_lock(mod_sofia_globals.hash_mutex);
for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) { for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
switch_hash_this(hi, &vvar, NULL, &val); switch_hash_this(hi, &vvar, NULL, &val);
profile = (sofia_profile_t *) val; profile = (sofia_profile_t *) val;
if (sofia_test_pflag(profile, PFLAG_RUNNING)) { if (sofia_test_pflag(profile, PFLAG_RUNNING)) {
if (!strcmp(vvar, profile->name)) { /* not an alias */ if (!strcmp(vvar, profile->name)) { /* not an alias */
for (gp = profile->gateways; gp; gp = gp->next) { for (gp = profile->gateways; gp; gp = gp->next) {
switch_assert(gp->state < REG_STATE_LAST); switch_assert(gp->state < REG_STATE_LAST);
stream->write_function(stream, "\t<gateway>\n"); stream->write_function(stream, "\t<gateway>\n");
stream->write_function(stream, "\t\t<profile>%s</profile>\n", profile->name); stream->write_function(stream, "\t\t<profile>%s</profile>\n", profile->name);
stream->write_function(stream, "\t\t<to>%s</to>\n", gp->register_to); stream->write_function(stream, "\t\t<to>%s</to>\n", gp->register_to);
stream->write_function(stream, "\t\t<state>%s</state>\n", sofia_state_names[gp->state]); stream->write_function(stream, "\t\t<state>%s</state>\n", sofia_state_names[gp->state]);
stream->write_function(stream, "\t\t<calls-in>%ld</calls-in>\n", gp->ib_calls); stream->write_function(stream, "\t\t<calls-in>%ld</calls-in>\n", gp->ib_calls);
stream->write_function(stream, "\t\t<calls-out>%ld</calls-out>\n", gp->ob_calls); stream->write_function(stream, "\t\t<calls-out>%ld</calls-out>\n", gp->ob_calls);
stream->write_function(stream, "\t\t<failed-calls-in>%ld</failed-calls-in>\n", gp->ib_failed_calls); stream->write_function(stream, "\t\t<failed-calls-in>%ld</failed-calls-in>\n", gp->ib_failed_calls);
stream->write_function(stream, "\t\t<failed-calls-out>%ld</failed-calls-out>\n", gp->ob_failed_calls); stream->write_function(stream, "\t\t<failed-calls-out>%ld</failed-calls-out>\n", gp->ob_failed_calls);
if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) { if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
time_t now = switch_epoch_time_now(NULL); time_t now = switch_epoch_time_now(NULL);
if (gp->retry > now) { if (gp->retry > now) {
stream->write_function(stream, "\t\t<retry>%ds</retry>\n", gp->retry - now); stream->write_function(stream, "\t\t<retry>%ds</retry>\n", gp->retry - now);
} else { } else {
stream->write_function(stream, "\t\t<retry>NEVER</retry>\n"); stream->write_function(stream, "\t\t<retry>NEVER</retry>\n");
} }
} }
stream->write_function(stream, "\t</gateway>\n"); stream->write_function(stream, "\t</gateway>\n");
} }
} }
} }
} }
switch_mutex_unlock(mod_sofia_globals.hash_mutex); switch_mutex_unlock(mod_sofia_globals.hash_mutex);
stream->write_function(stream, "</gateways>\n"); stream->write_function(stream, "</gateways>\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -3150,7 +3148,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
stream->write_function(stream, "-ERR Unknown command!\n"); stream->write_function(stream, "-ERR Unknown command!\n");
done: done:
if (profile) { if (profile) {
sofia_glue_release_profile(profile); sofia_glue_release_profile(profile);
} }
@ -3174,14 +3172,15 @@ static int contact_callback(void *pArg, int argc, char **argv, char **columnName
} }
static int sql2str_callback(void *pArg, int argc, char **argv, char **columnNames) static int sql2str_callback(void *pArg, int argc, char **argv, char **columnNames)
{ {
struct cb_helper_sql2str *cbt = (struct cb_helper_sql2str *) pArg; struct cb_helper_sql2str *cbt = (struct cb_helper_sql2str *) pArg;
switch_copy_string(cbt->buf, argv[0], cbt->len); switch_copy_string(cbt->buf, argv[0], cbt->len);
cbt->matches++; cbt->matches++;
return 0; return 0;
} }
SWITCH_STANDARD_API(sofia_count_reg_function) { SWITCH_STANDARD_API(sofia_count_reg_function)
{
char *data; char *data;
char *user = NULL; char *user = NULL;
char *domain = NULL; char *domain = NULL;
@ -3190,7 +3189,7 @@ SWITCH_STANDARD_API(sofia_count_reg_function) {
char *p; char *p;
char *reply = "-1"; char *reply = "-1";
sofia_profile_t *profile = NULL; sofia_profile_t *profile = NULL;
if (!cmd) { if (!cmd) {
stream->write_function(stream, "%s", ""); stream->write_function(stream, "%s", "");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -3209,13 +3208,12 @@ SWITCH_STANDARD_API(sofia_count_reg_function) {
if ((domain = strchr(user, '@'))) { if ((domain = strchr(user, '@'))) {
*domain++ = '\0'; *domain++ = '\0';
if ( (concat = strchr( domain, '/')) ) { if ((concat = strchr(domain, '/'))) {
*concat++ = '\0'; *concat++ = '\0';
} }
} } else {
else { if ((concat = strchr(user, '/'))) {
if ( (concat = strchr( user, '/')) ) { *concat++ = '\0';
*concat++ = '\0';
} }
} }
@ -3248,13 +3246,13 @@ SWITCH_STANDARD_API(sofia_count_reg_function) {
if (zstr(user)) { if (zstr(user)) {
sql = switch_mprintf("select count(*) " sql = switch_mprintf("select count(*) "
"from sip_registrations where (sip_host='%q' or presence_hosts like '%%%q%%')", "from sip_registrations where (sip_host='%q' or presence_hosts like '%%%q%%')",
( concat != NULL ) ? concat : "", domain, domain); (concat != NULL) ? concat : "", domain, domain);
} else { } else {
sql = switch_mprintf("select count(*) " sql = switch_mprintf("select count(*) "
"from sip_registrations where (sip_user='%q' or dir_user='%q') and (sip_host='%q' or presence_hosts like '%%%q%%')", "from sip_registrations where (sip_user='%q' or dir_user='%q') and (sip_host='%q' or presence_hosts like '%%%q%%')",
( concat != NULL ) ? concat : "", user, user, domain, domain); (concat != NULL) ? concat : "", user, user, domain, domain);
} }
switch_assert(sql); switch_assert(sql);
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sql2str_callback, &cb); sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sql2str_callback, &cb);
@ -3265,7 +3263,7 @@ SWITCH_STANDARD_API(sofia_count_reg_function) {
stream->write_function(stream, "0"); stream->write_function(stream, "0");
} }
reply = NULL; reply = NULL;
} }
} }
@ -3281,6 +3279,7 @@ SWITCH_STANDARD_API(sofia_count_reg_function) {
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_STANDARD_API(sofia_contact_function) SWITCH_STANDARD_API(sofia_contact_function)
{ {
char *data; char *data;
@ -3447,7 +3446,7 @@ SWITCH_STANDARD_API(sofia_gateway_data_function)
sofia_reg_release_gateway(gateway); sofia_reg_release_gateway(gateway);
end: end:
switch_safe_free(mydata); switch_safe_free(mydata);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -3464,11 +3463,11 @@ SWITCH_STANDARD_API(sofia_function)
"--------------------------------------------------------------------------------\n" "--------------------------------------------------------------------------------\n"
"sofia help\n" "sofia help\n"
"sofia profile <profile_name> [[start|stop|restart|rescan] [reloadxml]|" "sofia profile <profile_name> [[start|stop|restart|rescan] [reloadxml]|"
"flush_inbound_reg [<call_id>] [reboot]|" "flush_inbound_reg [<call_id>] [reboot]|"
"[register|unregister] [<gateway name>|all]|" "[register|unregister] [<gateway name>|all]|"
"killgw <gateway name>|" "killgw <gateway name>|"
"[stun-auto-disable|stun-enabled] [true|false]]|" "[stun-auto-disable|stun-enabled] [true|false]]|"
"siptrace [on|off]\n" "siptrace [on|off]\n"
"sofia status|xmlstatus profile <name> [ reg <contact str> ] | [ pres <pres str> ] | [ user <user@domain> ]\n" "sofia status|xmlstatus profile <name> [ reg <contact str> ] | [ pres <pres str> ] | [ user <user@domain> ]\n"
"sofia status|xmlstatus gateway <name>\n" "sofia status|xmlstatus gateway <name>\n"
"sofia loglevel <all|default|tport|iptsec|nea|nta|nth_client|nth_server|nua|soa|sresolv|stun> [0-9]\n" "sofia loglevel <all|default|tport|iptsec|nea|nta|nth_client|nth_server|nua|soa|sresolv|stun> [0-9]\n"
@ -3550,7 +3549,7 @@ SWITCH_STANDARD_API(sofia_function)
stream->write_function(stream, "Unknown Command [%s]\n", argv[0]); stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
} }
done: done:
switch_safe_free(mycmd); switch_safe_free(mycmd);
return status; return status;
} }
@ -3860,14 +3859,14 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
} }
sql = switch_mprintf("insert into sip_dialogs (uuid,presence_id,presence_data,profile_name,hostname) " sql = switch_mprintf("insert into sip_dialogs (uuid,presence_id,presence_data,profile_name,hostname) "
"values ('%q', '%q', '%q', '%q', '%q')", switch_core_session_get_uuid(nsession), "values ('%q', '%q', '%q', '%q', '%q')", switch_core_session_get_uuid(nsession),
switch_str_nil(presence_id), switch_str_nil(presence_data), profile->name, mod_sofia_globals.hostname); switch_str_nil(presence_id), switch_str_nil(presence_data), profile->name, mod_sofia_globals.hostname);
sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex); sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
switch_safe_free(sql); switch_safe_free(sql);
} }
caller_profile = switch_caller_profile_clone(nsession, outbound_profile); caller_profile = switch_caller_profile_clone(nsession, outbound_profile);
caller_profile->destination_number = switch_sanitize_number(caller_profile->destination_number); caller_profile->destination_number = switch_sanitize_number(caller_profile->destination_number);
not_const = (char *) caller_profile->caller_id_name; not_const = (char *) caller_profile->caller_id_name;
@ -3937,7 +3936,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
if (switch_core_session_compare(session, nsession)) { if (switch_core_session_compare(session, nsession)) {
/* It's another sofia channel! so lets cache what they use as a pt for telephone event so /* It's another sofia channel! so lets cache what they use as a pt for telephone event so
we can keep it the same we can keep it the same
*/ */
private_object_t *ctech_pvt; private_object_t *ctech_pvt;
ctech_pvt = switch_core_session_get_private(session); ctech_pvt = switch_core_session_get_private(session);
switch_assert(ctech_pvt != NULL); switch_assert(ctech_pvt != NULL);
@ -3970,14 +3969,14 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
goto done; goto done;
error: error:
if (nsession) { if (nsession) {
switch_core_session_destroy(&nsession); switch_core_session_destroy(&nsession);
} }
if (pool) { if (pool) {
*pool = NULL; *pool = NULL;
} }
done: done:
if (profile) { if (profile) {
if (cause == SWITCH_CAUSE_SUCCESS) { if (cause == SWITCH_CAUSE_SUCCESS) {
@ -4131,12 +4130,12 @@ static void general_event_handler(switch_event_t *event)
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' " sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
"from sip_registrations where mwi_user='%s' and mwi_host='%q'", "from sip_registrations where mwi_user='%s' and mwi_host='%q'",
ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host) ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
); );
} else { } else {
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' " sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
"from sip_registrations where sip_user='%s' and sip_host='%q'", "from sip_registrations where sip_user='%s' and sip_host='%q'",
ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host) ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
); );
} }
} }
@ -4192,9 +4191,7 @@ static void general_event_handler(switch_event_t *event)
NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END()); NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END());
nua_message(nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(ct), nua_message(nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(ct),
TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_IF(!zstr(subject), SIPTAG_SUBJECT_STR(subject)), TAG_END());
TAG_IF(!zstr(subject), SIPTAG_SUBJECT_STR(subject)),
TAG_END());
free(id); free(id);
@ -4292,7 +4289,7 @@ static void general_event_handler(switch_event_t *event)
sofia_glue_release_profile(profile); sofia_glue_release_profile(profile);
} }
done: done:
switch_safe_free(local_dup); switch_safe_free(local_dup);
@ -4326,7 +4323,7 @@ static void general_event_handler(switch_event_t *event)
profile->sipip = switch_core_strdup(profile->pool, new_ip4); profile->sipip = switch_core_strdup(profile->pool, new_ip4);
rb++; rb++;
} }
for (x = 0; x < profile->rtpip_index; x++) { for (x = 0; x < profile->rtpip_index; x++) {
if (!strcmp(profile->rtpip[x], old_ip4)) { if (!strcmp(profile->rtpip[x], old_ip4)) {
@ -4339,13 +4336,13 @@ static void general_event_handler(switch_event_t *event)
rb++; rb++;
} }
} }
if (!strcmp(profile->sipip, old_ip6)) { if (!strcmp(profile->sipip, old_ip6)) {
profile->sipip = switch_core_strdup(profile->pool, new_ip6); profile->sipip = switch_core_strdup(profile->pool, new_ip6);
rb++; rb++;
} }
if (rb) { if (rb) {
sofia_set_pflag_locked(profile, PFLAG_RESPAWN); sofia_set_pflag_locked(profile, PFLAG_RESPAWN);
sofia_clear_pflag_locked(profile, PFLAG_RUNNING); sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
@ -4456,7 +4453,7 @@ static switch_status_t list_profile_gateway(const char *line, const char *cursor
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
} }
end: end:
switch_safe_free(dup); switch_safe_free(dup);

View File

@ -46,7 +46,7 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
const char *username = tech_pvt->profile->username; const char *username = tech_pvt->profile->username;
//sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA); //sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
if (!ip) { if (!ip) {
if (!(ip = tech_pvt->adv_sdp_audio_ip)) { if (!(ip = tech_pvt->adv_sdp_audio_ip)) {
ip = tech_pvt->proxy_sdp_audio_ip; ip = tech_pvt->proxy_sdp_audio_ip;
@ -78,25 +78,15 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
} }
tech_pvt->session_id++; tech_pvt->session_id++;
family = strchr(ip, ':') ? "IP6" : "IP4"; family = strchr(ip, ':') ? "IP6" : "IP4";
switch_snprintf(buf, sizeof(buf), switch_snprintf(buf, sizeof(buf),
"v=0\n" "v=0\n"
"o=%s %010u %010u IN %s %s\n" "o=%s %010u %010u IN %s %s\n"
"s=%s\n" "s=%s\n" "c=IN %s %s\n" "t=0 0\n", username, tech_pvt->owner_id, tech_pvt->session_id, family, ip, username, family, ip);
"c=IN %s %s\n"
"t=0 0\n",
username,
tech_pvt->owner_id,
tech_pvt->session_id,
family,
ip,
username,
family,
ip);
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"m=image %d udptl t38\n" "m=image %d udptl t38\n"
@ -117,16 +107,13 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
t38_options->T38FaxTranscodingMMR ? "a=T38FaxTranscodingMMR\n" : "", t38_options->T38FaxTranscodingMMR ? "a=T38FaxTranscodingMMR\n" : "",
t38_options->T38FaxTranscodingJBIG ? "a=T38FaxTranscodingJBIG\n" : "", t38_options->T38FaxTranscodingJBIG ? "a=T38FaxTranscodingJBIG\n" : "",
t38_options->T38FaxRateManagement, t38_options->T38FaxRateManagement,
t38_options->T38FaxMaxBuffer, t38_options->T38FaxMaxBuffer,
t38_options->T38FaxMaxDatagram, t38_options->T38FaxMaxDatagram, t38_options->T38FaxUdpEC, t38_options->T38VendorInfo ? t38_options->T38VendorInfo : "0 0 0");
t38_options->T38FaxUdpEC,
t38_options->T38VendorInfo ? t38_options->T38VendorInfo : "0 0 0");
if (insist) { if (insist) {
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "m=audio 0 RTP/AVP 19\n");
"m=audio 0 RTP/AVP 19\n");
} }
sofia_glue_tech_set_local_sdp(tech_pvt, buf, SWITCH_TRUE); sofia_glue_tech_set_local_sdp(tech_pvt, buf, SWITCH_TRUE);
@ -134,7 +121,7 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s image media sdp:\n%s\n", switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s image media sdp:\n%s\n",
switch_channel_get_name(tech_pvt->channel), tech_pvt->local_sdp_str); switch_channel_get_name(tech_pvt->channel), tech_pvt->local_sdp_str);
} }
@ -195,8 +182,8 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
} }
if (!sr) { if (!sr) {
if ((var_val = switch_channel_get_variable(tech_pvt->channel, "media_audio_mode"))) { if ((var_val = switch_channel_get_variable(tech_pvt->channel, "media_audio_mode"))) {
sr=var_val; sr = var_val;
} else { } else {
sr = "sendrecv"; sr = "sendrecv";
} }
@ -400,7 +387,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
} }
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n"); switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n");
if (tech_pvt->video_rm_encoding) { if (tech_pvt->video_rm_encoding) {
const char *of; const char *of;
rate = tech_pvt->video_rm_rate; rate = tech_pvt->video_rm_rate;
@ -522,7 +509,7 @@ void sofia_glue_tech_prepare_codecs(private_object_t *tech_pvt)
} }
} }
ready: ready:
if (codec_string) { if (codec_string) {
char *tmp_codec_string; char *tmp_codec_string;
@ -707,7 +694,7 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
} }
out: out:
switch_safe_free(stun_ip); switch_safe_free(stun_ip);
@ -731,7 +718,7 @@ const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name)
switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int force) switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt, int force)
{ {
char *lookup_rtpip = tech_pvt->rtpip; /* Pointer to externally looked up address */ char *lookup_rtpip = tech_pvt->rtpip; /* Pointer to externally looked up address */
switch_port_t sdp_port, rtcp_port; /* The external port to be sent in the SDP */ switch_port_t sdp_port, rtcp_port; /* The external port to be sent in the SDP */
const char *use_ip = NULL; /* The external IP to be sent in the SDP */ const char *use_ip = NULL; /* The external IP to be sent in the SDP */
/* Don't do anything if we're in proxy mode or if a (remote) port already has been found */ /* Don't do anything if we're in proxy mode or if a (remote) port already has been found */
@ -914,7 +901,7 @@ sofia_transport_t sofia_glue_url2transport(const url_t *url)
return (tls) ? SOFIA_TRANSPORT_TCP_TLS : SOFIA_TRANSPORT_UDP; return (tls) ? SOFIA_TRANSPORT_TCP_TLS : SOFIA_TRANSPORT_UDP;
} }
sofia_transport_t sofia_glue_via2transport(const sip_via_t *via) sofia_transport_t sofia_glue_via2transport(const sip_via_t * via)
{ {
char *ptr = NULL; char *ptr = NULL;
@ -1168,7 +1155,7 @@ switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt)
switch_channel_set_flag(tech_pvt->channel, CF_VIDEO); switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
if (switch_rtp_ready(tech_pvt->video_rtp_session)) { if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
const char *rport = NULL; const char *rport = NULL;
switch_port_t remote_rtcp_port = 0; switch_port_t remote_rtcp_port = 0;
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_video_rtcp_port"))) { if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_video_rtcp_port"))) {
remote_rtcp_port = atoi(rport); remote_rtcp_port = atoi(rport);
@ -1209,8 +1196,8 @@ switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt)
if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port"))) { if ((rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port"))) {
remote_rtcp_port = atoi(rport); remote_rtcp_port = atoi(rport);
} }
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) { tech_pvt->remote_sdp_audio_port, remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err);
@ -1305,7 +1292,7 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt)
} else if (!strncmp("o=", p, 2)) { } else if (!strncmp("o=", p, 2)) {
char *oe = strchr(p, '\n'); char *oe = strchr(p, '\n');
switch_size_t len; switch_size_t len;
if (oe) { if (oe) {
const char *family = "IP4"; const char *family = "IP4";
char o_line[1024] = ""; char o_line[1024] = "";
@ -1317,33 +1304,29 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt)
len = (oe - p); len = (oe - p);
p += len; p += len;
family = strchr(tech_pvt->profile->sipip, ':') ? "IP6" : "IP4"; family = strchr(tech_pvt->profile->sipip, ':') ? "IP6" : "IP4";
if (!tech_pvt->owner_id) { if (!tech_pvt->owner_id) {
tech_pvt->owner_id = (uint32_t) switch_epoch_time_now(NULL) * 31821U + 13849U; tech_pvt->owner_id = (uint32_t) switch_epoch_time_now(NULL) * 31821U + 13849U;
} }
if (!tech_pvt->session_id) { if (!tech_pvt->session_id) {
tech_pvt->session_id = tech_pvt->owner_id; tech_pvt->session_id = tech_pvt->owner_id;
} }
tech_pvt->session_id++; tech_pvt->session_id++;
snprintf(o_line, sizeof(o_line), "o=%s %010u %010u IN %s %s\n", snprintf(o_line, sizeof(o_line), "o=%s %010u %010u IN %s %s\n",
tech_pvt->profile->username, tech_pvt->profile->username, tech_pvt->owner_id, tech_pvt->session_id, family, tech_pvt->profile->sipip);
tech_pvt->owner_id,
tech_pvt->session_id,
family,
tech_pvt->profile->sipip);
strncpy(q, o_line, strlen(o_line)); strncpy(q, o_line, strlen(o_line));
q += strlen(o_line) - 1; q += strlen(o_line) - 1;
} }
} else if (!strncmp("s=", p, 2)) { } else if (!strncmp("s=", p, 2)) {
char *se = strchr(p, '\n'); char *se = strchr(p, '\n');
switch_size_t len; switch_size_t len;
@ -1476,7 +1459,7 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt)
} }
end: end:
if (bad) { if (bad) {
return; return;
@ -1520,7 +1503,7 @@ char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefi
int x = 0; int x = 0;
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
const char *boundary = switch_core_session_get_uuid(session); const char *boundary = switch_core_session_get_uuid(session);
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
if ((hi = switch_channel_variable_first(channel))) { if ((hi = switch_channel_variable_first(channel))) {
for (; hi; hi = hi->next) { for (; hi; hi = hi->next) {
@ -1828,9 +1811,9 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
/* /*
Does the "genius" who wanted SIP to be "text-based" so it was "easier to read" even use it now, Does the "genius" who wanted SIP to be "text-based" so it was "easier to read" even use it now,
or did he just suggest it to make our lives miserable? or did he just suggest it to make our lives miserable?
*/ */
use_from_str = from_str; use_from_str = from_str;
if (!switch_stristr("sip:", use_from_str)) { if (!switch_stristr("sip:", use_from_str)) {
@ -1893,7 +1876,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
if ((val = switch_channel_get_variable(channel, "sip_cid_type"))) { if ((val = switch_channel_get_variable(channel, "sip_cid_type"))) {
cid_type = sofia_cid_name2type(val); cid_type = sofia_cid_name2type(val);
} }
if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING) && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) { if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING) && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) {
if (zstr((use_name = switch_channel_get_variable(tech_pvt->channel, "effective_callee_id_name"))) && if (zstr((use_name = switch_channel_get_variable(tech_pvt->channel, "effective_callee_id_name"))) &&
@ -2067,7 +2050,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
if ((mp = sofia_glue_get_multipart(session, SOFIA_MULTIPART_PREFIX, tech_pvt->local_sdp_str, &mp_type))) { if ((mp = sofia_glue_get_multipart(session, SOFIA_MULTIPART_PREFIX, tech_pvt->local_sdp_str, &mp_type))) {
sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA); sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
} }
if (sofia_use_soa(tech_pvt)) { if (sofia_use_soa(tech_pvt)) {
nua_invite(tech_pvt->nh, nua_invite(tech_pvt->nh,
NUTAG_AUTOANSWER(0), NUTAG_AUTOANSWER(0),
@ -2120,10 +2103,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
TAG_IF(cseq, SIPTAG_CSEQ(cseq)), TAG_IF(cseq, SIPTAG_CSEQ(cseq)),
NUTAG_MEDIA_ENABLE(0), NUTAG_MEDIA_ENABLE(0),
SIPTAG_CONTENT_TYPE_STR(mp_type ? mp_type : "application/sdp"), SIPTAG_CONTENT_TYPE_STR(mp_type ? mp_type : "application/sdp"),
SIPTAG_PAYLOAD_STR(mp ? mp : tech_pvt->local_sdp_str), SIPTAG_PAYLOAD_STR(mp ? mp : tech_pvt->local_sdp_str), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
TAG_IF(rep, SIPTAG_REPLACES_STR(rep)),
SOATAG_HOLD(holdstr),
TAG_END());
} }
sofia_glue_free_destination(dst); sofia_glue_free_destination(dst);
@ -2216,7 +2196,7 @@ void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt)
} }
#define add_stat(_i, _s) \ #define add_stat(_i, _s) \
switch_snprintf(var_name, sizeof(var_name), "rtp_%s_%s", switch_str_nil(prefix), _s) ; \ switch_snprintf(var_name, sizeof(var_name), "rtp_%s_%s", switch_str_nil(prefix), _s) ; \
switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_SIZE_T_FMT, _i); \ switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_SIZE_T_FMT, _i); \
switch_channel_set_variable(tech_pvt->channel, var_name, var_val) switch_channel_set_variable(tech_pvt->channel, var_name, var_val)
@ -2478,7 +2458,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
switch_rtp_set_default_payload(tech_pvt->rtp_session, tech_pvt->pt); switch_rtp_set_default_payload(tech_pvt->rtp_session, tech_pvt->pt);
} }
end: end:
if (resetting) { if (resetting) {
switch_core_session_unlock_codec_write(tech_pvt->session); switch_core_session_unlock_codec_write(tech_pvt->session);
switch_core_session_unlock_codec_read(tech_pvt->session); switch_core_session_unlock_codec_read(tech_pvt->session);
@ -2582,7 +2562,7 @@ switch_status_t sofia_glue_add_crypto(private_object_t *tech_pvt, const char *ke
} }
bad: bad:
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Error!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Error!\n");
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
@ -2713,7 +2693,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) { if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
const char *rport = NULL; const char *rport = NULL;
switch_port_t remote_rtcp_port = 0; switch_port_t remote_rtcp_port = 0;
sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE); sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
@ -2721,9 +2701,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
remote_rtcp_port = atoi(rport); remote_rtcp_port = atoi(rport);
} }
if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port, if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port,
remote_rtcp_port, SWITCH_TRUE, &err) != remote_rtcp_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err);
} else { } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n", switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "AUDIO RTP CHANGING DEST TO: [%s:%d]\n",
@ -2829,7 +2808,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (tech_pvt->profile->auto_rtp_bugs & RTP_BUG_IGNORE_MARK_BIT) { if (tech_pvt->profile->auto_rtp_bugs & RTP_BUG_IGNORE_MARK_BIT) {
tech_pvt->rtp_bugs |= RTP_BUG_IGNORE_MARK_BIT; tech_pvt->rtp_bugs |= RTP_BUG_IGNORE_MARK_BIT;
} }
switch_rtp_intentional_bugs(tech_pvt->rtp_session, tech_pvt->rtp_bugs); switch_rtp_intentional_bugs(tech_pvt->rtp_session, tech_pvt->rtp_bugs);
if ((vad_in && inb) || (vad_out && !inb)) { if ((vad_in && inb) || (vad_out && !inb)) {
@ -2845,7 +2824,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
switch_rtp_activate_stun_ping(tech_pvt->rtp_session, tech_pvt->stun_ip, tech_pvt->stun_port, stun_ping, switch_rtp_activate_stun_ping(tech_pvt->rtp_session, tech_pvt->stun_ip, tech_pvt->stun_port, stun_ping,
(tech_pvt->stun_flags & STUN_FLAG_FUNNY) ? 1 : 0); (tech_pvt->stun_flags & STUN_FLAG_FUNNY) ? 1 : 0);
} }
if ((val = switch_channel_get_variable(tech_pvt->channel, "rtcp_audio_interval_msec")) || (val = tech_pvt->profile->rtcp_audio_interval_msec)) { if ((val = switch_channel_get_variable(tech_pvt->channel, "rtcp_audio_interval_msec")) || (val = tech_pvt->profile->rtcp_audio_interval_msec)) {
const char *rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port"); const char *rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port");
switch_port_t remote_port = 0; switch_port_t remote_port = 0;
@ -2857,7 +2836,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
} else { } else {
int interval = atoi(val); int interval = atoi(val);
if (interval < 100 || interval > 5000) { if (interval < 100 || interval > 5000) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Invalid rtcp interval spec [%d] must be between 100 and 5000\n", interval); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR,
"Invalid rtcp interval spec [%d] must be between 100 and 5000\n", interval);
} else { } else {
switch_rtp_activate_rtcp(tech_pvt->rtp_session, interval, remote_port); switch_rtp_activate_rtcp(tech_pvt->rtp_session, interval, remote_port);
} }
@ -2943,7 +2923,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip); switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp); switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
video: video:
sofia_glue_check_video_codecs(tech_pvt); sofia_glue_check_video_codecs(tech_pvt);
if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding && tech_pvt->remote_sdp_video_port) { if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding && tech_pvt->remote_sdp_video_port) {
@ -3087,7 +3067,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
switch_channel_set_variable_printf(tech_pvt->channel, "rtp_use_video_ssrc", "%u", tech_pvt->ssrc); switch_channel_set_variable_printf(tech_pvt->channel, "rtp_use_video_ssrc", "%u", tech_pvt->ssrc);
if ((val = switch_channel_get_variable(tech_pvt->channel, "rtcp_audio_interval_msec")) || (val = tech_pvt->profile->rtcp_audio_interval_msec)) { if ((val = switch_channel_get_variable(tech_pvt->channel, "rtcp_audio_interval_msec"))
|| (val = tech_pvt->profile->rtcp_audio_interval_msec)) {
const char *rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_video_rtcp_port"); const char *rport = switch_channel_get_variable(tech_pvt->channel, "sip_remote_video_rtcp_port");
switch_port_t remote_port = 0; switch_port_t remote_port = 0;
if (rport) { if (rport) {
@ -3098,7 +3079,8 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
} else { } else {
int interval = atoi(val); int interval = atoi(val);
if (interval < 100 || interval > 5000) { if (interval < 100 || interval > 5000) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Invalid rtcp interval spec [%d] must be between 100 and 5000\n", interval); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR,
"Invalid rtcp interval spec [%d] must be between 100 and 5000\n", interval);
} else { } else {
switch_rtp_activate_rtcp(tech_pvt->rtp_session, interval, remote_port); switch_rtp_activate_rtcp(tech_pvt->rtp_session, interval, remote_port);
} }
@ -3121,12 +3103,12 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
goto end; goto end;
} }
video_up: video_up:
sofia_set_flag(tech_pvt, TFLAG_IO); sofia_set_flag(tech_pvt, TFLAG_IO);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
end: end:
sofia_glue_tech_track(tech_pvt->profile, tech_pvt->session); sofia_glue_tech_track(tech_pvt->profile, tech_pvt->session);
@ -3337,7 +3319,7 @@ void sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly)
if (tech_pvt->max_missed_hold_packets) { if (tech_pvt->max_missed_hold_packets) {
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_hold_packets); switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_hold_packets);
} }
if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) { if (!(stream = switch_channel_get_variable(tech_pvt->channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
stream = tech_pvt->profile->hold_music; stream = tech_pvt->profile->hold_music;
} }
@ -3416,10 +3398,10 @@ void sofia_glue_copy_t38_options(switch_t38_options_t *t38_options, switch_core_
local_t38_options->T38VendorInfo = switch_core_session_strdup(session, t38_options->T38VendorInfo); local_t38_options->T38VendorInfo = switch_core_session_strdup(session, t38_options->T38VendorInfo);
local_t38_options->remote_ip = switch_core_session_strdup(session, t38_options->remote_ip); local_t38_options->remote_ip = switch_core_session_strdup(session, t38_options->remote_ip);
local_t38_options->remote_port = t38_options->remote_port; local_t38_options->remote_port = t38_options->remote_port;
switch_channel_set_private(channel, "t38_options", local_t38_options); switch_channel_set_private(channel, "t38_options", local_t38_options);
} }
static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_session_t *sdp, sdp_media_t *m) static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_session_t *sdp, sdp_media_t *m)
{ {
@ -3429,15 +3411,15 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_
if (!t38_options) { if (!t38_options) {
t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t)); t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t));
} }
t38_options->remote_port = m->m_port; t38_options->remote_port = m->m_port;
if (m->m_connections) { if (m->m_connections) {
t38_options->remote_ip = switch_core_session_strdup(tech_pvt->session, m->m_connections->c_address); t38_options->remote_ip = switch_core_session_strdup(tech_pvt->session, m->m_connections->c_address);
} else if (sdp && sdp->sdp_connection) { } else if (sdp && sdp->sdp_connection) {
t38_options->remote_ip = switch_core_session_strdup(tech_pvt->session, sdp->sdp_connection->c_address); t38_options->remote_ip = switch_core_session_strdup(tech_pvt->session, sdp->sdp_connection->c_address);
} }
for (attr = m->m_attributes; attr; attr = attr->a_next) { for (attr = m->m_attributes; attr; attr = attr->a_next) {
if (!strcasecmp(attr->a_name, "T38FaxVersion") && attr->a_value) { if (!strcasecmp(attr->a_name, "T38FaxVersion") && attr->a_value) {
t38_options->T38FaxVersion = (uint16_t) atoi(attr->a_value); t38_options->T38FaxVersion = (uint16_t) atoi(attr->a_value);
@ -3465,7 +3447,7 @@ static switch_t38_options_t *tech_process_udptl(private_object_t *tech_pvt, sdp_
switch_channel_set_variable(tech_pvt->channel, "has_t38", "true"); switch_channel_set_variable(tech_pvt->channel, "has_t38", "true");
switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options); switch_channel_set_private(tech_pvt->channel, "t38_options", t38_options);
switch_channel_set_app_flag(tech_pvt->channel, CF_APP_T38); switch_channel_set_app_flag(tech_pvt->channel, CF_APP_T38);
return t38_options; return t38_options;
} }
@ -3494,7 +3476,7 @@ switch_t38_options_t *sofia_glue_extract_t38_options(switch_core_session_t *sess
break; break;
} }
} }
sdp_parser_free(parser); sdp_parser_free(parser);
return t38_options; return t38_options;
@ -3520,7 +3502,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
int scrooge = 0; int scrooge = 0;
sdp_parser_t *parser = NULL; sdp_parser_t *parser = NULL;
sdp_session_t *sdp; sdp_session_t *sdp;
if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) { if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
return 0; return 0;
} }
@ -3615,7 +3597,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
if (got_udptl && m->m_type == sdp_media_image && m->m_port) { if (got_udptl && m->m_type == sdp_media_image && m->m_port) {
switch_t38_options_t *t38_options = tech_process_udptl(tech_pvt, sdp, m); switch_t38_options_t *t38_options = tech_process_udptl(tech_pvt, sdp, m);
if (switch_true(switch_channel_get_variable(channel, "refuse_t38"))) { if (switch_true(switch_channel_get_variable(channel, "refuse_t38"))) {
match = 0; match = 0;
goto done; goto done;
@ -3626,7 +3608,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
if (var) { if (var) {
pass = switch_true(var); pass = switch_true(var);
} }
if (sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) { if (sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU)) {
pass = 0; pass = 0;
} }
@ -3635,10 +3617,10 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session); private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
switch_core_session_message_t *msg; switch_core_session_message_t *msg;
sofia_glue_copy_t38_options(t38_options, other_session); sofia_glue_copy_t38_options(t38_options, other_session);
sofia_set_flag(tech_pvt, TFLAG_T38_PASSTHRU); sofia_set_flag(tech_pvt, TFLAG_T38_PASSTHRU);
sofia_set_flag(other_tech_pvt, TFLAG_T38_PASSTHRU); sofia_set_flag(other_tech_pvt, TFLAG_T38_PASSTHRU);
msg = switch_core_session_alloc(other_session, sizeof(*msg)); msg = switch_core_session_alloc(other_session, sizeof(*msg));
msg->message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA; msg->message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA;
msg->from = __FILE__; msg->from = __FILE__;
@ -3648,15 +3630,15 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
switch_core_session_rwunlock(other_session); switch_core_session_rwunlock(other_session);
} }
} }
/* do nothing here, mod_fax will trigger a response (if it's listening =/)*/
/* do nothing here, mod_fax will trigger a response (if it's listening =/) */
match = 1; match = 1;
goto done; goto done;
} else if (m->m_type == sdp_media_audio && m->m_port && !got_audio) { } else if (m->m_type == sdp_media_audio && m->m_port && !got_audio) {
sdp_rtpmap_t *map; sdp_rtpmap_t *map;
for (attr = m->m_attributes; attr; attr = attr->a_next) { for (attr = m->m_attributes; attr; attr = attr->a_next) {
if (!strcasecmp(attr->a_name, "rtcp") && attr->a_value) { if (!strcasecmp(attr->a_name, "rtcp") && attr->a_value) {
switch_channel_set_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port", attr->a_value); switch_channel_set_variable(tech_pvt->channel, "sip_remote_audio_rtcp_port", attr->a_value);
} }
@ -3751,7 +3733,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
break; break;
} }
greed: greed:
x = 0; x = 0;
if (tech_pvt->rm_encoding) { // && !sofia_test_flag(tech_pvt, TFLAG_REINVITE)) { if (tech_pvt->rm_encoding) { // && !sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
@ -3820,7 +3802,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
} }
} }
} }
if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && !cng_pt && !strcasecmp(rm_encoding, "CN")) { if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && !cng_pt && !strcasecmp(rm_encoding, "CN")) {
cng_pt = (switch_payload_t) map->rm_pt; cng_pt = (switch_payload_t) map->rm_pt;
if (tech_pvt->rtp_session) { if (tech_pvt->rtp_session) {
@ -3864,7 +3846,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
} else { } else {
codec_ms = ptime; codec_ms = ptime;
} }
for (i = first; i < last && i < tech_pvt->num_codecs; i++) { for (i = first; i < last && i < tech_pvt->num_codecs; i++) {
@ -3909,7 +3891,8 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
char tmp[80]; char tmp[80];
int num; int num;
switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second, codec_ms); switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second,
codec_ms);
prefs[0] = tmp; prefs[0] = tmp;
num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1); num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
@ -4050,9 +4033,10 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
} }
} }
done: done:
if (parser) sdp_parser_free(parser); if (parser)
sdp_parser_free(parser);
tech_pvt->cng_pt = cng_pt; tech_pvt->cng_pt = cng_pt;
sofia_set_flag_locked(tech_pvt, TFLAG_SDP); sofia_set_flag_locked(tech_pvt, TFLAG_SDP);
@ -4202,7 +4186,7 @@ sofia_profile_t *sofia_glue_find_profile__(const char *file, const char *func, i
#endif #endif
} }
done: done:
switch_mutex_unlock(mod_sofia_globals.hash_mutex); switch_mutex_unlock(mod_sofia_globals.hash_mutex);
return profile; return profile;
@ -4335,26 +4319,6 @@ void sofia_glue_del_profile(sofia_profile_t *profile)
switch_mutex_unlock(mod_sofia_globals.hash_mutex); switch_mutex_unlock(mod_sofia_globals.hash_mutex);
} }
static int rebridge_callback(void *pArg, int argc, char **argv, char **columnNames)
{
char *uuid = argv[2];
switch_core_session_t *session;
if ((session = switch_core_session_locate(uuid))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) {
switch_channel_wait_for_state_timeout(channel, CS_INIT, 10000);
switch_channel_set_state(channel, CS_RESET);
}
switch_core_session_rwunlock(session);
}
return 0;
}
struct recover_helper { struct recover_helper {
sofia_profile_t *profile; sofia_profile_t *profile;
int total; int total;
@ -4411,7 +4375,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
switch_channel_set_variable_printf(channel, "sip_invite_route_uri", "<sip:%s@%s:%s;lr>", switch_channel_set_variable_printf(channel, "sip_invite_route_uri", "<sip:%s@%s:%s;lr>",
switch_channel_get_variable(channel, "sip_from_user"), switch_channel_get_variable(channel, "sip_from_user"),
switch_channel_get_variable(channel, "sip_network_ip"), switch_channel_get_variable(channel, "sip_network_port") switch_channel_get_variable(channel, "sip_network_ip"), switch_channel_get_variable(channel, "sip_network_port")
); );
tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_from_uri")); tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_from_uri"));
@ -4444,7 +4408,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
switch_channel_set_variable_printf(channel, "sip_route_uri", "sip:%s@%s:%s", switch_channel_set_variable_printf(channel, "sip_route_uri", "sip:%s@%s:%s",
switch_channel_get_variable(channel, "sip_req_user"), switch_channel_get_variable(channel, "sip_req_user"),
switch_channel_get_variable(channel, "sip_network_ip"), switch_channel_get_variable(channel, "sip_network_port") switch_channel_get_variable(channel, "sip_network_ip"), switch_channel_get_variable(channel, "sip_network_port")
); );
} }
if (session) { if (session) {
@ -4487,12 +4451,12 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
tech_pvt->remote_sdp_audio_ip = (char *) r_ip; tech_pvt->remote_sdp_audio_ip = (char *) r_ip;
tech_pvt->remote_sdp_audio_port = atoi(r_port); tech_pvt->remote_sdp_audio_port = atoi(r_port);
} }
if (switch_channel_test_flag(channel, CF_VIDEO)) { if (switch_channel_test_flag(channel, CF_VIDEO)) {
if ((tmp = switch_channel_get_variable(channel, "sip_use_video_pt"))) { if ((tmp = switch_channel_get_variable(channel, "sip_use_video_pt"))) {
tech_pvt->video_pt = tech_pvt->video_agreed_pt = atoi(tmp); tech_pvt->video_pt = tech_pvt->video_agreed_pt = atoi(tmp);
} }
tech_pvt->video_rm_encoding = (char *) switch_channel_get_variable(channel, "sip_use_video_codec_name"); tech_pvt->video_rm_encoding = (char *) switch_channel_get_variable(channel, "sip_use_video_codec_name");
tech_pvt->video_rm_fmtp = (char *) switch_channel_get_variable(channel, "sip_use_video_codec_fmtp"); tech_pvt->video_rm_fmtp = (char *) switch_channel_get_variable(channel, "sip_use_video_codec_fmtp");
@ -4501,35 +4465,34 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
port = switch_channel_get_variable(channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE); port = switch_channel_get_variable(channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE);
r_ip = switch_channel_get_variable(channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE); r_ip = switch_channel_get_variable(channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE);
r_port = switch_channel_get_variable(channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE); r_port = switch_channel_get_variable(channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE);
sofia_set_flag(tech_pvt, TFLAG_VIDEO); sofia_set_flag(tech_pvt, TFLAG_VIDEO);
if ((tmp = switch_channel_get_variable(channel, "sip_use_video_codec_rate"))) { if ((tmp = switch_channel_get_variable(channel, "sip_use_video_codec_rate"))) {
tech_pvt->video_rm_rate = atoi(tmp); tech_pvt->video_rm_rate = atoi(tmp);
} }
if ((tmp = switch_channel_get_variable(channel, "sip_use_video_codec_ptime"))) { if ((tmp = switch_channel_get_variable(channel, "sip_use_video_codec_ptime"))) {
tech_pvt->video_codec_ms = atoi(tmp); tech_pvt->video_codec_ms = atoi(tmp);
} }
tech_pvt->adv_sdp_video_port = tech_pvt->local_sdp_video_port = atoi(port); tech_pvt->adv_sdp_video_port = tech_pvt->local_sdp_video_port = atoi(port);
if (r_ip && r_port) { if (r_ip && r_port) {
tech_pvt->remote_sdp_video_ip = (char *) r_ip; tech_pvt->remote_sdp_video_ip = (char *) r_ip;
tech_pvt->remote_sdp_video_port = atoi(r_port); tech_pvt->remote_sdp_video_port = atoi(r_port);
} }
//sofia_glue_tech_set_video_codec(tech_pvt, 1); //sofia_glue_tech_set_video_codec(tech_pvt, 1);
} }
sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1); sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
switch_xml_free(xml); switch_xml_free(xml);
return 0; return 0;
} }
} }
if (switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) { if (switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) {
sofia_set_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE); sofia_set_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE);
} else { } else {
@ -4545,17 +4508,15 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
switch_caller_extension_add_application(session, extension, var, val); switch_caller_extension_add_application(session, extension, var, val);
} }
} }
switch_channel_set_caller_extension(channel, extension); switch_channel_set_caller_extension(channel, extension);
} }
switch_channel_set_state(channel, CS_INIT); switch_channel_set_state(channel, CS_INIT);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Resurrecting fallen channel %s\n", switch_channel_get_name(channel));
switch_core_session_thread_launch(session);
} }
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Resurrecting fallen channel %s\n", switch_channel_get_name(channel));
switch_core_session_thread_launch(session);
switch_xml_free(xml); switch_xml_free(xml);
h->total++; h->total++;
@ -4600,13 +4561,6 @@ int sofia_glue_recover(switch_bool_t flush)
free(sql); free(sql);
sql = NULL; sql = NULL;
sql = switch_mprintf("select profile_name, hostname, uuid "
"from sip_recovery where runtime_uuid!='%q' and profile_name='%q'", switch_core_get_uuid(), profile->name);
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, rebridge_callback, NULL);
free(sql);
sql = NULL;
sql = switch_mprintf("delete " sql = switch_mprintf("delete "
"from sip_recovery where runtime_uuid!='%q' and profile_name='%q'", switch_core_get_uuid(), profile->name); "from sip_recovery where runtime_uuid!='%q' and profile_name='%q'", switch_core_get_uuid(), profile->name);
@ -4693,16 +4647,16 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
" presence_hosts VARCHAR(255),\n" " presence_hosts VARCHAR(255),\n"
" contact VARCHAR(1024),\n" " contact VARCHAR(1024),\n"
" status VARCHAR(255),\n" " status VARCHAR(255),\n"
" rpid VARCHAR(255),\n" " rpid VARCHAR(255),\n"
" expires INTEGER,\n" " expires INTEGER,\n"
" user_agent VARCHAR(255),\n" " user_agent VARCHAR(255),\n"
" server_user VARCHAR(255),\n" " server_user VARCHAR(255),\n"
" server_host VARCHAR(255),\n" " server_host VARCHAR(255),\n"
" profile_name VARCHAR(255),\n" " profile_name VARCHAR(255),\n"
" hostname VARCHAR(255),\n" " hostname VARCHAR(255),\n"
" network_ip VARCHAR(255),\n" " network_ip VARCHAR(255),\n"
" network_port VARCHAR(6),\n" " network_port VARCHAR(6),\n"
" sip_username VARCHAR(255),\n" " sip_username VARCHAR(255),\n"
" sip_realm VARCHAR(255),\n" " sip_realm VARCHAR(255),\n"
" mwi_user VARCHAR(255),\n" " mwi_user VARCHAR(255),\n"
" mwi_host VARCHAR(255),\n" " mwi_host VARCHAR(255),\n"
@ -4716,7 +4670,8 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
" profile_name VARCHAR(255),\n" " profile_name VARCHAR(255),\n"
" hostname VARCHAR(255),\n" " hostname VARCHAR(255),\n"
" uuid VARCHAR(255),\n" " uuid VARCHAR(255),\n"
" metadata text\n" ");\n"; " metadata text\n"
");\n";
char pres_sql[] = char pres_sql[] =
"CREATE TABLE sip_presence (\n" "CREATE TABLE sip_presence (\n"
@ -4879,8 +4834,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
"or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' " "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
"and network_ip like '%%' and network_port like '%%' and sip_username " "and network_ip like '%%' and network_port like '%%' and sip_username "
"like '%%' and mwi_user like '%%' and mwi_host like '%%' " "like '%%' and mwi_user like '%%' and mwi_host like '%%' "
"and orig_server_host like '%%' and orig_hostname like '%%'", "and orig_server_host like '%%' and orig_hostname like '%%'", mod_sofia_globals.hostname);
mod_sofia_globals.hostname);
if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) { if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_registrations", NULL, NULL); switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_registrations", NULL, NULL);
@ -4981,9 +4935,8 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
"or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' " "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
"and network_ip like '%%' and network_port like '%%' and sip_username " "and network_ip like '%%' and network_port like '%%' and sip_username "
"like '%%' and mwi_user like '%%' and mwi_host like '%%' " "like '%%' and mwi_user like '%%' and mwi_host like '%%' "
"and orig_server_host like '%%' and orig_hostname like '%%'", "and orig_server_host like '%%' and orig_hostname like '%%'", mod_sofia_globals.hostname);
mod_sofia_globals.hostname);
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_registrations", reg_sql); switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_registrations", reg_sql);
free(test_sql); free(test_sql);
@ -5010,7 +4963,9 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql); switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql);
free(test_sql); free(test_sql);
test_sql = switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str = '' or hostname='%q' and network_ip like '%%'", mod_sofia_globals.hostname); test_sql =
switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str = '' or hostname='%q' and network_ip like '%%'",
mod_sofia_globals.hostname);
switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_shared_appearance_dialogs", shared_appearance_dialogs_sql); switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_shared_appearance_dialogs", shared_appearance_dialogs_sql);
free(test_sql); free(test_sql);
@ -5082,7 +5037,7 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
switch_core_db_exec(db, "create index if not exists sr_2 on sip_recovery (profile_name)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists sr_2 on sip_recovery (profile_name)", NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists sr_3 on sip_recovery (hostname)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists sr_3 on sip_recovery (hostname)", NULL, NULL, NULL);
switch_core_db_exec(db, "create index if not exists sr_4 on sip_recovery (uuid)", NULL, NULL, NULL); switch_core_db_exec(db, "create index if not exists sr_4 on sip_recovery (uuid)", NULL, NULL, NULL);
} }
if (odbc_dbh) { if (odbc_dbh) {
@ -5474,7 +5429,7 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt)
other_channel = switch_core_session_get_channel(other_session); other_channel = switch_core_session_get_channel(other_session);
if (switch_channel_test_flag(other_channel, CF_ANSWERED)) { /* Check if the other channel is answered */ if (switch_channel_test_flag(other_channel, CF_ANSWERED)) { /* Check if the other channel is answered */
simplify = switch_channel_get_variable(tech_pvt->channel, "sip_auto_simplify"); simplify = switch_channel_get_variable(tech_pvt->channel, "sip_auto_simplify");
simplify_other_channel = switch_channel_get_variable(other_channel, "sip_auto_simplify"); simplify_other_channel = switch_channel_get_variable(other_channel, "sip_auto_simplify");
@ -5491,12 +5446,13 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt)
} }
if (inbound_channel && inbound_session && !zstr(network_addr_a) && !zstr(network_addr_b) && !strcmp(network_addr_a, network_addr_b)) { if (inbound_channel && inbound_session && !zstr(network_addr_a) && !zstr(network_addr_b) && !strcmp(network_addr_a, network_addr_b)) {
if (strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->sipip)) && strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->extsipip))) { if (strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->sipip))
&& strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->extsipip))) {
switch_core_session_message_t *msg; switch_core_session_message_t *msg;
switch_log_printf(SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, switch_channel_get_uuid(inbound_channel), SWITCH_LOG_NOTICE, switch_log_printf(SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, switch_channel_get_uuid(inbound_channel),
"Will simplify channel [%s]\n", switch_channel_get_name(inbound_channel)); SWITCH_LOG_NOTICE, "Will simplify channel [%s]\n", switch_channel_get_name(inbound_channel));
msg = switch_core_session_alloc(inbound_session, sizeof(*msg)); msg = switch_core_session_alloc(inbound_session, sizeof(*msg));
MESSAGE_STAMP_FFL(msg); MESSAGE_STAMP_FFL(msg);
@ -5512,7 +5468,7 @@ void sofia_glue_tech_simplify(private_object_t *tech_pvt)
if (!did_simplify && inbound_channel) { if (!did_simplify && inbound_channel) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, switch_channel_get_uuid(inbound_channel), SWITCH_LOG_NOTICE, switch_log_printf(SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, switch_channel_get_uuid(inbound_channel), SWITCH_LOG_NOTICE,
"Could not simplify channel [%s]\n", switch_channel_get_name(inbound_channel)); "Could not simplify channel [%s]\n", switch_channel_get_name(inbound_channel));
} }
} }