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 {
@ -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,10 +183,7 @@ 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);
@ -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);
@ -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,9 +1579,7 @@ 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);
@ -2340,11 +2338,13 @@ static int show_reg_callback_xml(void *pArg, int argc, char **argv, char **colum
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]),
exp_buf, exp_secs);
cb->stream->write_function(cb->stream, " <host>%s</host>\n", switch_str_nil(argv[11])); cb->stream->write_function(cb->stream, " <host>%s</host>\n", switch_str_nil(argv[11]));
cb->stream->write_function(cb->stream, " <network-ip>%s</network-ip>\n", switch_str_nil(argv[12])); cb->stream->write_function(cb->stream, " <network-ip>%s</network-ip>\n", switch_str_nil(argv[12]));
cb->stream->write_function(cb->stream, " <network-port>%s</network-port>\n", switch_str_nil(argv[13])); 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-user>%s</sip-auth-user>\n", switch_url_encode(switch_str_nil(argv[14]), xmlbuf, sizeof(xmlbuf))); 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, " <sip-auth-realm>%s</sip-auth-realm>\n", switch_str_nil(argv[15])); 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, " <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"); cb->stream->write_function(cb->stream, " </registration>\n");
@ -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;
} }
@ -2625,8 +2624,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
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) {
@ -3181,7 +3179,8 @@ static int sql2str_callback(void *pArg, int argc, char **argv, char **columnName
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;
@ -3212,8 +3211,7 @@ SWITCH_STANDARD_API(sofia_count_reg_function) {
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';
} }
@ -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;
@ -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);

View File

@ -85,17 +85,7 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
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),
@ -118,15 +108,12 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
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);
@ -1333,11 +1320,7 @@ void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt)
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;
@ -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);
@ -2722,8 +2702,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
} }
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",
@ -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);
} }
@ -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);
} }
@ -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);
@ -4052,7 +4035,8 @@ 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);
@ -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;
@ -4518,7 +4482,6 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
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);
} }
@ -4550,11 +4513,9 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
} }
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_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_core_session_thread_launch(session);
}
switch_xml_free(xml); switch_xml_free(xml);
@ -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);
@ -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,8 +4935,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);
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);
@ -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);