mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for mod_sofia
This commit is contained in:
parent
6f9ee4216c
commit
d654faa5a9
@ -932,7 +932,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
|
||||
cid = generate_pai_str(tech_pvt);
|
||||
|
||||
|
||||
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) && tech_pvt->mparams.early_sdp) {
|
||||
if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) && tech_pvt->mparams.early_sdp && tech_pvt->mparams.local_sdp_str) {
|
||||
char *a, *b;
|
||||
|
||||
/* start at the s= line to avoid some devices who update the o= between messages */
|
||||
@ -1042,7 +1042,7 @@ static switch_status_t sofia_read_text_frame(switch_core_session_t *session, swi
|
||||
rframe->m = 1;
|
||||
*frame = rframe;
|
||||
|
||||
if (msrp_h_content_type && !strcasecmp(msrp_h_content_type, "message/cpim")) {
|
||||
if (!strcasecmp(msrp_h_content_type, "message/cpim")) {
|
||||
char *stripped_text = switch_html_strip((char *)rframe->data);
|
||||
memcpy(rframe->data, stripped_text, strlen(stripped_text)+1);
|
||||
rframe->datalen = strlen(stripped_text);
|
||||
@ -1326,6 +1326,8 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
switch_assert(tech_pvt != NULL);
|
||||
|
||||
if (msg->message_id == SWITCH_MESSAGE_INDICATE_SIGNAL_DATA) {
|
||||
sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) msg->pointer_arg;
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
@ -1341,7 +1343,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
|
||||
|
||||
if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
if (switch_channel_down(channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto end;
|
||||
}
|
||||
@ -1513,7 +1515,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
/* ones that do need to lock sofia mutex */
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
if (switch_channel_down(channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
goto end_lock;
|
||||
}
|
||||
@ -2029,11 +2031,10 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
if ( ver_str ) {
|
||||
char *argv[4] = { 0 };
|
||||
char *dotted = strdup( ver_str + 1 );
|
||||
if ( dotted ) {
|
||||
switch_separate_string(dotted, '.', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
if ( argv[0] && argv[1] && argv[2] ) {
|
||||
version = ( atoi(argv[0]) * 10000 ) + ( atoi(argv[1]) * 100 ) + atoi(argv[2]);
|
||||
}
|
||||
switch_assert(dotted);
|
||||
switch_separate_string(dotted, '.', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
if ( argv[0] && argv[1] && argv[2] ) {
|
||||
version = ( atoi(argv[0]) * 10000 ) + ( atoi(argv[1]) * 100 ) + atoi(argv[2]);
|
||||
}
|
||||
switch_safe_free( dotted );
|
||||
}
|
||||
@ -2701,7 +2702,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
|
||||
end:
|
||||
|
||||
if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
if (switch_channel_down(channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
@ -3071,7 +3072,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
cb.profile = profile;
|
||||
cb.stream = stream;
|
||||
|
||||
if (!sql && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
|
||||
if (argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
|
||||
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
|
||||
"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
|
||||
"network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host,ping_status,ping_time"
|
||||
@ -3274,8 +3275,6 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
stream->write_function(stream, "</gateways>\n");
|
||||
|
||||
} else if (argc == 1 && !strcasecmp(argv[0], "profile")) {
|
||||
} else if (!strcasecmp(argv[0], "gateway")) {
|
||||
if ((gp = sofia_reg_find_gateway(argv[1]))) {
|
||||
switch_assert(gp->state < REG_STATE_LAST);
|
||||
@ -3377,7 +3376,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
|
||||
cb.profile = profile;
|
||||
cb.stream = stream;
|
||||
|
||||
if (!sql && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
|
||||
if (argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
|
||||
|
||||
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
|
||||
"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
|
||||
@ -3789,9 +3788,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
|
||||
stream->write_function(stream, "-ERR Unknown command!\n");
|
||||
|
||||
done:
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
sofia_glue_release_profile(profile);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@ -3864,7 +3861,7 @@ SWITCH_STANDARD_API(sofia_count_reg_function)
|
||||
profile_name = domain;
|
||||
}
|
||||
|
||||
if (user && profile_name) {
|
||||
if (profile_name) {
|
||||
char *sql;
|
||||
|
||||
if (!(profile = sofia_glue_find_profile(profile_name))) {
|
||||
@ -3957,7 +3954,7 @@ SWITCH_STANDARD_API(sofia_username_of_function)
|
||||
profile_name = domain;
|
||||
}
|
||||
|
||||
if (user && profile_name) {
|
||||
if (profile_name) {
|
||||
char *sql;
|
||||
|
||||
if (!(profile = sofia_glue_find_profile(profile_name))) {
|
||||
@ -4114,8 +4111,6 @@ SWITCH_STANDARD_API(sofia_contact_function)
|
||||
domain = dup_domain;
|
||||
}
|
||||
|
||||
if (!user) goto end;
|
||||
|
||||
if (zstr(profile_name) || strcmp(profile_name, "*") || zstr(domain)) {
|
||||
if (!zstr(profile_name)) {
|
||||
profile = sofia_glue_find_profile(profile_name);
|
||||
@ -4172,8 +4167,6 @@ SWITCH_STANDARD_API(sofia_contact_function)
|
||||
|
||||
reply = (char *) mystream.data;
|
||||
|
||||
end:
|
||||
|
||||
if (zstr(reply)) {
|
||||
reply = "error/user_not_registered";
|
||||
} else if (end_of(reply) == ',') {
|
||||
@ -4303,7 +4296,7 @@ SWITCH_STANDARD_API(sofia_presence_data_function)
|
||||
*concat++ = '\0';
|
||||
}
|
||||
} else {
|
||||
if ((concat = strchr(user, '/'))) {
|
||||
if (user && (concat = strchr(user, '/'))) {
|
||||
*concat++ = '\0';
|
||||
}
|
||||
}
|
||||
@ -4907,7 +4900,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (profile && sofia_test_pflag(profile, PFLAG_STANDBY)) {
|
||||
if (sofia_test_pflag(profile, PFLAG_STANDBY)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "System Paused\n");
|
||||
cause = SWITCH_CAUSE_SYSTEM_SHUTDOWN;
|
||||
goto error;
|
||||
@ -5418,7 +5411,7 @@ void general_event_handler(switch_event_t *event)
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1), TAG_IF(sip_sub_st, SIPTAG_SUBSCRIPTION_STATE_STR(sip_sub_st)),
|
||||
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),
|
||||
SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
|
||||
SIPTAG_EVENT_STR(es), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
|
||||
TAG_END());
|
||||
|
||||
@ -5447,7 +5440,7 @@ void general_event_handler(switch_event_t *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if (to_uri && from_uri && ct && es) {
|
||||
if (to_uri && from_uri) {
|
||||
sofia_destination_t *dst = NULL;
|
||||
nua_handle_t *nh;
|
||||
char *route_uri = NULL;
|
||||
@ -5472,7 +5465,7 @@ void general_event_handler(switch_event_t *event)
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
|
||||
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
|
||||
SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
|
||||
SIPTAG_EVENT_STR(es), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
|
||||
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
|
||||
TAG_END());
|
||||
|
||||
@ -5755,12 +5748,13 @@ void general_event_handler(switch_event_t *event)
|
||||
} else {
|
||||
if (local_user_full) {
|
||||
local_dup = strdup(local_user_full);
|
||||
switch_assert(local_dup);
|
||||
local_user = local_dup;
|
||||
if ((local_host = strchr(local_user, '@'))) {
|
||||
*local_host++ = '\0';
|
||||
}
|
||||
|
||||
if (!local_user || !local_host || !sofia_reg_find_reg_url(profile, local_user, local_host, buf, sizeof(buf))) {
|
||||
if (!local_host || !sofia_reg_find_reg_url(profile, local_user, local_host, buf, sizeof(buf))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find local user\n");
|
||||
goto done;
|
||||
}
|
||||
@ -5789,9 +5783,7 @@ void general_event_handler(switch_event_t *event)
|
||||
nua_handle_unref(nh);
|
||||
}
|
||||
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
sofia_glue_release_profile(profile);
|
||||
|
||||
done:
|
||||
|
||||
@ -5936,9 +5928,7 @@ void write_csta_xml_chunk(switch_event_t *event, switch_stream_handle_t stream,
|
||||
ringcount = switch_event_get_header(event, "ringCount");
|
||||
}
|
||||
|
||||
if (fwdtype) {
|
||||
stream.write_function(&stream, " <forwardingType>%s</forwardingType>\n", fwdtype);
|
||||
}
|
||||
stream.write_function(&stream, " <forwardingType>%s</forwardingType>\n", fwdtype);
|
||||
if (fwdstatus) {
|
||||
stream.write_function(&stream, " <forwardStatus>%s</forwardStatus>\n", fwdstatus);
|
||||
}
|
||||
|
@ -1132,8 +1132,8 @@ void sofia_reg_release_gateway__(const char *file, const char *func, int line, s
|
||||
} \
|
||||
} \
|
||||
\
|
||||
if (_session) break; \
|
||||
} while(!_session)
|
||||
break; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
|
@ -607,7 +607,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||
goto end;
|
||||
} else if (!strncasecmp(msg->string_arg, "debug:", 6)) {
|
||||
s = msg->string_arg + 6;
|
||||
if (s && !strcmp(s, "off")) {
|
||||
if (!strcmp(s, "off")) {
|
||||
s = NULL;
|
||||
}
|
||||
switch_rtp_debug_jitter_buffer(tech_pvt->rtp_session, s);
|
||||
|
@ -326,7 +326,7 @@ switch_status_t sip_dig_function(_In_opt_z_ const char *cmd, _In_opt_ switch_cor
|
||||
usage(2);
|
||||
}
|
||||
|
||||
multiple = argv[i] && argv[i +1];
|
||||
if (argv[i + 1]) multiple = 1;
|
||||
|
||||
if (!count_transports(dig, NULL, NULL)) {
|
||||
prepare_transport(dig, "udp");
|
||||
@ -822,7 +822,7 @@ int dig_addr(struct dig *dig,
|
||||
}
|
||||
}
|
||||
|
||||
if (count1 + count2) {
|
||||
if (count1 + count2 > 0) {
|
||||
double w = weight / (count1 + count2) / tcount;
|
||||
|
||||
if (count1)
|
||||
|
@ -211,6 +211,7 @@ static char *strip_quotes(const char *in)
|
||||
|
||||
if (end_of(t) == '"') {
|
||||
r = strdup(t);
|
||||
switch_assert(r);
|
||||
end_of(r) = '\0';
|
||||
}
|
||||
}
|
||||
@ -702,9 +703,7 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
|
||||
int status_val = 0;
|
||||
if ((p = strchr(sip->sip_payload->pl_data, ' '))) {
|
||||
p++;
|
||||
if (p) {
|
||||
status_val = atoi(p);
|
||||
}
|
||||
status_val = atoi(p);
|
||||
}
|
||||
if (!status_val || status_val >= 200) {
|
||||
switch_channel_set_variable(channel, "sip_refer_reply", sip->sip_payload->pl_data);
|
||||
@ -1057,9 +1056,7 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
|
||||
switch_snprintf(st, sizeof(st), "sip:%d", status);
|
||||
switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
|
||||
|
||||
if (phrase) {
|
||||
switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
|
||||
}
|
||||
switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
|
||||
|
||||
switch_snprintf(st, sizeof(st), "%d", cause);
|
||||
switch_channel_set_variable(channel, "sip_term_cause", st);
|
||||
@ -1289,6 +1286,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
|
||||
}
|
||||
if (!zstr(passerted->paid_display)) {
|
||||
dup = strdup(passerted->paid_display);
|
||||
switch_assert(dup);
|
||||
if (*dup == '"') {
|
||||
name = dup + 1;
|
||||
} else {
|
||||
@ -1304,6 +1302,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
|
||||
}
|
||||
if (!zstr(rpid->rpid_display)) {
|
||||
dup = strdup(rpid->rpid_display);
|
||||
switch_assert(dup);
|
||||
if (*dup == '"') {
|
||||
name = dup + 1;
|
||||
} else {
|
||||
@ -2735,9 +2734,7 @@ void event_handler(switch_event_t *event)
|
||||
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Expired propagated registration for %s@%s->%s\n", from_user, from_host, contact_str);
|
||||
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
sofia_glue_release_profile(profile);
|
||||
} else if ((subclass = switch_event_get_header_nil(event, "orig-event-subclass")) && !strcasecmp(subclass, MY_EVENT_REGISTER)) {
|
||||
char *from_user = switch_event_get_header_nil(event, "orig-from-user");
|
||||
char *from_host = switch_event_get_header_nil(event, "orig-from-host");
|
||||
@ -2852,9 +2849,7 @@ void event_handler(switch_event_t *event)
|
||||
}
|
||||
|
||||
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
sofia_glue_release_profile(profile);
|
||||
end:
|
||||
switch_safe_free(fixed_contact_str);
|
||||
switch_safe_free(dup_mwi_account);
|
||||
@ -2881,9 +2876,7 @@ void event_handler(switch_event_t *event)
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating sip_user_state for %s@%s. Ping-Status: %s\n", from_user, from_host, ping_status);
|
||||
}
|
||||
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4360,7 +4353,7 @@ switch_status_t config_gateway(const char *profile_name, const char *gateway_nam
|
||||
|
||||
done:
|
||||
|
||||
if (profile) sofia_glue_release_profile(profile);
|
||||
sofia_glue_release_profile(profile);
|
||||
if (xml) switch_xml_free(xml);
|
||||
|
||||
switch_event_destroy(¶ms);
|
||||
@ -4903,7 +4896,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
||||
profile->record_template = switch_core_strdup(profile->pool, val);
|
||||
} else if (!strcasecmp(var, "record-path")) {
|
||||
profile->record_path = switch_core_strdup(profile->pool, val);
|
||||
} else if ((!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media"))) {
|
||||
} else if (!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media")) {
|
||||
if (switch_true(val)) {
|
||||
sofia_set_flag(profile, TFLAG_INB_NOMEDIA);
|
||||
} else {
|
||||
@ -5682,7 +5675,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
||||
if ((p = strrchr(profile->ws_ip, ':'))) {
|
||||
*p++ = '\0';
|
||||
|
||||
if (p && (tmp = atol(p)) && tmp > 0) {
|
||||
if ((tmp = atol(p)) && tmp > 0) {
|
||||
profile->ws_port = (switch_port_t) tmp;
|
||||
}
|
||||
}
|
||||
@ -5695,7 +5688,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
||||
if ((p = strrchr(profile->wss_ip, ':'))) {
|
||||
*p++ = '\0';
|
||||
|
||||
if (p && (tmp = atol(p)) && tmp > 0) {
|
||||
if ((tmp = atol(p)) && tmp > 0) {
|
||||
profile->wss_port = (switch_port_t) tmp;
|
||||
}
|
||||
}
|
||||
@ -6168,9 +6161,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
|
||||
if ((switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_PROFILE_START) == SWITCH_STATUS_SUCCESS)) {
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "module_name", "mod_sofia");
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_name", profile->name);
|
||||
if (profile) {
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_uri", profile->url);
|
||||
}
|
||||
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_uri", profile->url);
|
||||
switch_event_fire(&s_event);
|
||||
}
|
||||
} else {
|
||||
@ -6532,8 +6523,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||
state = "progressing";
|
||||
}
|
||||
|
||||
if (sip &&
|
||||
sip->sip_from && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
|
||||
if (sip->sip_from && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
|
||||
sip->sip_to && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host) {
|
||||
sql =
|
||||
switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 and hostname='%q' and event='call-info' and "
|
||||
@ -6618,7 +6608,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||
|
||||
}
|
||||
|
||||
if (channel && sip && (status == 300 || status == 301 || status == 302 || status == 305) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
|
||||
if (channel && (status == 300 || status == 301 || status == 302 || status == 305) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
|
||||
sip_contact_t *p_contact = sip->sip_contact;
|
||||
int i = 0;
|
||||
char var_name[80];
|
||||
@ -6659,10 +6649,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||
free(invite_contact);
|
||||
i++;
|
||||
}
|
||||
if (home) {
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
}
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
switch_snprintf(var_name, sizeof(var_name), "sip:%d", status);
|
||||
switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, var_name);
|
||||
switch_channel_hangup(channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
|
||||
@ -6791,10 +6779,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||
free(invite_contact);
|
||||
}
|
||||
|
||||
if (home) {
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
}
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
|
||||
free(stream.data);
|
||||
|
||||
@ -6810,11 +6796,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||
tech_pvt->redirected = switch_core_session_strdup(session, invite_contact);
|
||||
|
||||
free(invite_contact);
|
||||
|
||||
if (home) {
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
}
|
||||
su_home_unref(home);
|
||||
home = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7424,7 +7407,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
}
|
||||
|
||||
if (r_sdp) {
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MODE) && r_sdp) {
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
|
||||
char ibuf[35] = "", pbuf[35] = "";
|
||||
const char *ptr;
|
||||
|
||||
@ -8374,6 +8357,8 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
uint8_t match = 0;
|
||||
int is_ok = 1;
|
||||
|
||||
if (!tech_pvt) goto done;
|
||||
|
||||
if (tech_pvt->mparams.num_codecs) {
|
||||
match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_RESPONSE);
|
||||
}
|
||||
@ -9213,9 +9198,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
}
|
||||
}
|
||||
}
|
||||
if (b_session) {
|
||||
switch_core_session_rwunlock(b_session);
|
||||
}
|
||||
switch_core_session_rwunlock(b_session);
|
||||
}
|
||||
nua_handle_unref(bnh);
|
||||
} else { /* the other channel is on a different box, we have to go find them */
|
||||
@ -9231,7 +9214,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
"REFER from %s replaces %s (%s@%s) with %s on another server\n",
|
||||
switch_core_session_get_uuid(session), rep, exten, (char *) refer_to->r_url->url_host, br_a);
|
||||
|
||||
if (refer_to && refer_to->r_url->url_port) {
|
||||
if (refer_to->r_url->url_port) {
|
||||
port = refer_to->r_url->url_port;
|
||||
}
|
||||
|
||||
@ -9522,7 +9505,7 @@ static switch_status_t create_info_event(sip_t const *sip,
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (sip && sip->sip_content_type) {
|
||||
if (sip->sip_content_type) {
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "SIP-Content-Type", sip->sip_content_type->c_type);
|
||||
}
|
||||
|
||||
@ -9596,7 +9579,7 @@ switch_status_t sofia_proxy_sip_i_message(nua_t *nua, sofia_profile_t *profile,
|
||||
|
||||
other_tech_pvt = (private_object_t *) switch_core_session_get_private(other_session);
|
||||
|
||||
if (sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
|
||||
if (sip && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
|
||||
ct = sip->sip_content_type->c_type;
|
||||
}
|
||||
|
||||
@ -9639,11 +9622,11 @@ switch_status_t sofia_proxy_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua
|
||||
|
||||
other_tech_pvt = (private_object_t *) switch_core_session_get_private(other_session);
|
||||
|
||||
if (sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
|
||||
if (sip && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
|
||||
ct = sip->sip_content_type->c_type;
|
||||
}
|
||||
|
||||
if (!strncasecmp(sip->sip_content_type->c_type, "application", 11) && !strcasecmp(sip->sip_content_type->c_subtype, "media_control+xml")) {
|
||||
if (sip && sip->sip_content_type->c_type && !strncasecmp(sip->sip_content_type->c_type, "application", 11) && !strcasecmp(sip->sip_content_type->c_subtype, "media_control+xml")) {
|
||||
if (switch_channel_test_flag(channel, CF_VIDEO)) {
|
||||
switch_core_media_gen_key_frame(session);
|
||||
switch_channel_set_flag(channel, CF_VIDEO_REFRESH_REQ);
|
||||
@ -9728,6 +9711,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
switch_status_t status;
|
||||
|
||||
switch_assert(cmd);
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
switch_assert(stream.data);
|
||||
|
||||
@ -10047,7 +10031,7 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
|
||||
|
||||
if (sip->sip_payload && sip->sip_payload->pl_data) {
|
||||
if (sip && sip->sip_payload && sip->sip_payload->pl_data) {
|
||||
tech_pvt->mparams.last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data);
|
||||
}
|
||||
}
|
||||
@ -10076,7 +10060,7 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
|
||||
switch_core_recovery_track(session);
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
|
||||
if (profile && sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
|
||||
if (channel && sip->sip_call_info) {
|
||||
char *p;
|
||||
if ((call_info = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_call_info))) {
|
||||
@ -10259,7 +10243,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
switch_channel_get_name(tech_pvt->channel), network_ip, network_port, switch_version_full_human());
|
||||
|
||||
|
||||
if (sip && sip->sip_via && sip->sip_via->v_protocol && switch_stristr("sip/2.0/ws", sip->sip_via->v_protocol)) {
|
||||
if (sip->sip_via && sip->sip_via->v_protocol && switch_stristr("sip/2.0/ws", sip->sip_via->v_protocol)) {
|
||||
is_nat = "websockets";
|
||||
}
|
||||
|
||||
@ -10276,7 +10260,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
sip->sip_user_agent->g_string &&
|
||||
(!strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20)))
|
||||
) {
|
||||
if (sip && sip->sip_via) {
|
||||
if (sip->sip_via) {
|
||||
const char *port = sip->sip_via->v_port;
|
||||
const char *host = sip->sip_via->v_host;
|
||||
|
||||
@ -10297,12 +10281,10 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
char *last_acl = NULL;
|
||||
const char *contact_host = NULL;
|
||||
|
||||
if (sip) {
|
||||
if (sip->sip_via && sip->sip_via->v_host) {
|
||||
contact_host = sip->sip_via->v_host;
|
||||
} else if (sip->sip_contact) {
|
||||
contact_host = sip->sip_contact->m_url->url_host;
|
||||
}
|
||||
if (sip->sip_via && sip->sip_via->v_host) {
|
||||
contact_host = sip->sip_via->v_host;
|
||||
} else if (sip->sip_contact) {
|
||||
contact_host = sip->sip_contact->m_url->url_host;
|
||||
}
|
||||
|
||||
if (!zstr(contact_host)) {
|
||||
@ -10495,7 +10477,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
calling_myself++;
|
||||
}
|
||||
|
||||
if (sip && sip->sip_from) {
|
||||
if (sip->sip_from) {
|
||||
user = switch_core_session_sprintf(session, "%s@%s", sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host);
|
||||
blind_result = sofia_locate_user(user, session, sip, &x_user);
|
||||
}
|
||||
@ -10559,7 +10541,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
}
|
||||
}
|
||||
|
||||
if (sip->sip_via || sip->sip_contact) {
|
||||
if (sip->sip_via) {
|
||||
char tmp[35] = "";
|
||||
const char *ipv6 = strchr(tech_pvt->mparams.remote_ip, ':');
|
||||
|
||||
@ -10575,9 +10557,6 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
switch_channel_set_variable(channel, "sip_received_ip", tech_pvt->mparams.remote_ip);
|
||||
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->mparams.remote_port);
|
||||
switch_channel_set_variable(channel, "sip_received_port", tmp);
|
||||
}
|
||||
|
||||
if (sip->sip_via) {
|
||||
switch_channel_set_variable(channel, "sip_via_protocol", sofia_glue_transport2str(sofia_glue_via2transport(sip->sip_via)));
|
||||
}
|
||||
|
||||
@ -10897,9 +10876,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
nua_set_hparams(nh, SIPTAG_VIA_STR(tech_pvt->user_via), TAG_END());
|
||||
}
|
||||
|
||||
if (sip->sip_contact) {
|
||||
url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
|
||||
}
|
||||
url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
|
||||
|
||||
if (sip->sip_referred_by) {
|
||||
referred_by_user = sip->sip_referred_by->b_url->url_user;
|
||||
@ -11042,8 +11019,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
char *sql;
|
||||
char *state = "progressing";
|
||||
|
||||
if (sip &&
|
||||
sip->sip_from && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
|
||||
if (sip->sip_from && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
|
||||
sip->sip_to && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host) {
|
||||
sql =
|
||||
switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 and hostname='%q' and event='call-info' and "
|
||||
@ -11127,16 +11103,16 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
switch_channel_set_variable(channel, "sip_gateway", gateway->name);
|
||||
|
||||
if (!zstr(extension)) {
|
||||
if (!strcasecmp(extension, "auto_to_user")) {
|
||||
if (!strcasecmp(extension, "auto_to_user") && sip->sip_to) {
|
||||
destination_number = sip->sip_to->a_url->url_user;
|
||||
} else if (!strcasecmp(extension, "auto")) {
|
||||
if (gw_name) {
|
||||
if (gw_name && sip->sip_to) {
|
||||
destination_number = sip->sip_to->a_url->url_user;
|
||||
}
|
||||
} else {
|
||||
destination_number = switch_core_session_strdup(session, extension);
|
||||
}
|
||||
} else if (!gw_param_name) {
|
||||
} else if (!gw_param_name && sip->sip_to) {
|
||||
destination_number = sip->sip_to->a_url->url_user;
|
||||
}
|
||||
|
||||
@ -11220,10 +11196,10 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
}
|
||||
}
|
||||
|
||||
if (sip && sip->sip_replaces) {
|
||||
if (sip->sip_replaces) {
|
||||
msg_common_t *rp_common = sip->sip_replaces->rp_common;
|
||||
switch_channel_set_variable(channel, "sip_replaces_call_id", sip->sip_replaces->rp_call_id);
|
||||
if (rp_common && rp_common->h_class->hc_params) {
|
||||
if (rp_common->h_class->hc_params) {
|
||||
int i, n;
|
||||
msg_param_t const *params = * (msg_param_t const **) ((char *)rp_common + rp_common->h_class->hc_params);
|
||||
for (i = 0; params[i]; i++) {
|
||||
@ -11249,7 +11225,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
}
|
||||
}
|
||||
nua_handle_unref(bnh);
|
||||
} else if (sip && sip->sip_replaces && sip->sip_replaces->rp_call_id) {
|
||||
} else if (sip->sip_replaces && sip->sip_replaces->rp_call_id) {
|
||||
switch_core_session_t *b_session = NULL;
|
||||
if ((b_session = switch_core_session_locate((char*) sip->sip_replaces->rp_call_id))) {
|
||||
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
|
||||
@ -11386,9 +11362,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
if (sip->sip_from) {
|
||||
from = sip->sip_from->a_url;
|
||||
}
|
||||
if (sip->sip_contact) {
|
||||
contact = sip->sip_contact->m_url;
|
||||
}
|
||||
contact = sip->sip_contact->m_url;
|
||||
|
||||
if (sip->sip_user_agent) {
|
||||
user_agent = switch_str_nil(sip->sip_user_agent->g_string);
|
||||
@ -11410,10 +11384,8 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
from_tag = switch_str_nil(sip->sip_from->a_tag);
|
||||
}
|
||||
|
||||
if (contact) {
|
||||
contact_user = switch_str_nil(contact->url_user);
|
||||
contact_host = switch_str_nil(contact->url_host);
|
||||
}
|
||||
contact_user = switch_str_nil(contact->url_user);
|
||||
contact_host = switch_str_nil(contact->url_host);
|
||||
|
||||
if (profile->pres_type) {
|
||||
const char *presence_data = switch_channel_get_variable(channel, "presence_data");
|
||||
@ -11422,9 +11394,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
|
||||
char *p = NULL;
|
||||
time_t now;
|
||||
|
||||
if (sip->sip_contact) {
|
||||
full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
|
||||
}
|
||||
full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
|
||||
|
||||
if (call_info_str && switch_stristr("appearance", call_info_str)) {
|
||||
switch_channel_set_variable(channel, "presence_call_info_full", call_info_str);
|
||||
@ -11478,15 +11448,16 @@ void sofia_handle_sip_i_invite_replaces(switch_core_session_t *session, switch_c
|
||||
switch_caller_profile_t *orig_cp, *cp;
|
||||
//const char *sent_name, *sent_number;
|
||||
orig_cp = switch_channel_get_caller_profile(b_channel);
|
||||
tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_name);
|
||||
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_number);
|
||||
|
||||
if (!call_info) {
|
||||
tech_pvt->caller_profile->caller_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_name);
|
||||
tech_pvt->caller_profile->caller_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
|
||||
}
|
||||
|
||||
if (orig_cp) {
|
||||
tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_name);
|
||||
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_number);
|
||||
|
||||
if (!call_info) {
|
||||
tech_pvt->caller_profile->caller_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_name);
|
||||
tech_pvt->caller_profile->caller_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
|
||||
}
|
||||
|
||||
cp = switch_caller_profile_dup(tech_pvt->caller_profile->pool, orig_cp);
|
||||
switch_channel_set_originator_caller_profile(channel, cp);
|
||||
}
|
||||
@ -11593,39 +11564,43 @@ void sofia_handle_sip_i_invite_replaces(switch_core_session_t *session, switch_c
|
||||
switch_event_t *event = NULL;
|
||||
if (switch_channel_var_true(channel, "sip_replaces_a-leg")) {
|
||||
switch_channel_mark_hold(b_channel, SWITCH_FALSE);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", sip->sip_replaces->rp_call_id);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s picked up on a-leg\n", sip->sip_replaces->rp_call_id);
|
||||
if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
|
||||
&& sip && sip->sip_call_id
|
||||
&& switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(b_channel, event);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
|
||||
switch_event_fire(&event);
|
||||
if (sip) {
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", sip->sip_replaces->rp_call_id);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s picked up on a-leg\n", sip->sip_replaces->rp_call_id);
|
||||
if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
|
||||
&& sip->sip_call_id
|
||||
&& switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(b_channel, event);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-For"))) {
|
||||
switch_channel_set_variable(b_channel, "transfer_refer_for", nightmare_xfer_uuid);
|
||||
}
|
||||
if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-From"))) {
|
||||
switch_channel_set_variable(b_channel, "transfer_refer_from", nightmare_xfer_uuid);
|
||||
if (sip) {
|
||||
if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-For"))) {
|
||||
switch_channel_set_variable(b_channel, "transfer_refer_for", nightmare_xfer_uuid);
|
||||
}
|
||||
if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-From"))) {
|
||||
switch_channel_set_variable(b_channel, "transfer_refer_from", nightmare_xfer_uuid);
|
||||
}
|
||||
}
|
||||
|
||||
if (!zstr(bridge_uuid)) {
|
||||
if (sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id && switch_channel_test_flag(b_channel, CF_BRIDGED) &&
|
||||
if (sip && sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id && switch_channel_test_flag(b_channel, CF_BRIDGED) &&
|
||||
switch_true(switch_find_parameter(*(sip->sip_replaces->rp_params), "early-only", switch_core_session_get_pool(session)))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercept rejected\n", bridge_uuid);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "hangup:CALL_REJECTED");
|
||||
} else {
|
||||
switch_channel_mark_hold(b_channel, SWITCH_FALSE);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercepted\n", bridge_uuid);
|
||||
if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
|
||||
&& sip && sip->sip_call_id
|
||||
&& switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(b_channel, event);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
switch_channel_mark_hold(b_channel, SWITCH_FALSE);
|
||||
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercepted\n", bridge_uuid);
|
||||
if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
|
||||
&& sip && sip->sip_call_id
|
||||
&& switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(b_channel, event);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
|
||||
|
@ -230,6 +230,8 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, char **i
|
||||
|
||||
stun_ip = strdup(sourceip + 5);
|
||||
|
||||
switch_assert(stun_ip);
|
||||
|
||||
if ((p = strchr(stun_ip, ':'))) {
|
||||
int iport;
|
||||
*p++ = '\0';
|
||||
@ -794,11 +796,13 @@ char *sofia_glue_strip_uri(const char *str)
|
||||
if ((p = strchr(str, '<'))) {
|
||||
p++;
|
||||
r = strdup(p);
|
||||
switch_assert(r);
|
||||
if ((p = strchr(r, '>'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
} else {
|
||||
r = strdup(str);
|
||||
switch_assert(r);
|
||||
}
|
||||
|
||||
return r;
|
||||
@ -858,23 +862,12 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char
|
||||
if (switch_stristr("port=", stripped)) {
|
||||
new_uri = switch_core_session_sprintf(session, "%s%s%s", uri_only ? "" : "<", stripped, uri_only ? "" : ">");
|
||||
} else {
|
||||
|
||||
if (strchr(stripped, ';')) {
|
||||
if (params) {
|
||||
new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s;%s%s",
|
||||
uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), params, uri_only ? "" : ">");
|
||||
} else {
|
||||
new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s%s",
|
||||
uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), uri_only ? "" : ">");
|
||||
}
|
||||
if (params) {
|
||||
new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s;%s%s",
|
||||
uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), params, uri_only ? "" : ">");
|
||||
} else {
|
||||
if (params) {
|
||||
new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s;%s%s",
|
||||
uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), params, uri_only ? "" : ">");
|
||||
} else {
|
||||
new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s%s",
|
||||
uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), uri_only ? "" : ">");
|
||||
}
|
||||
new_uri = switch_core_session_sprintf(session, "%s%s;transport=%s%s",
|
||||
uri_only ? "" : "<", stripped, sofia_glue_transport2str(transport), uri_only ? "" : ">");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -988,7 +981,9 @@ char *sofia_glue_get_extra_headers_from_event(switch_event_t *event, const char
|
||||
for (hp = event->headers; hp; hp = hp->next) {
|
||||
if (!zstr(hp->name) && !zstr(hp->value) && !strncasecmp(hp->name, prefix, strlen(prefix))) {
|
||||
char *name = strdup(hp->name);
|
||||
const char *hname = name + strlen(prefix);
|
||||
const char *hname;
|
||||
switch_assert(name);
|
||||
hname = name + strlen(prefix);
|
||||
stream.write_function(&stream, "%s: %s\r\n", hname, (char *)hp->value);
|
||||
free(name);
|
||||
}
|
||||
@ -1912,6 +1907,7 @@ char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup)
|
||||
url++;
|
||||
if (to_dup) {
|
||||
url = strdup(url);
|
||||
switch_assert(url);
|
||||
e = strchr(url, '>');
|
||||
}
|
||||
|
||||
@ -2329,9 +2325,7 @@ int sofia_recover_callback(switch_core_session_t *session)
|
||||
|
||||
r++;
|
||||
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
sofia_glue_release_profile(profile);
|
||||
|
||||
|
||||
return r;
|
||||
@ -2905,6 +2899,8 @@ char *sofia_glue_get_register_host(const char *uri)
|
||||
|
||||
register_host = strdup(s);
|
||||
|
||||
switch_assert(register_host);
|
||||
|
||||
/* remove port for register_host for testing nat acl take into account
|
||||
ipv6 addresses which are required to have brackets around the addr
|
||||
*/
|
||||
@ -3298,7 +3294,7 @@ char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua
|
||||
}
|
||||
}
|
||||
|
||||
if (!np->is_nat && sip && sip->sip_via && sip->sip_via->v_port &&
|
||||
if (!np->is_nat && sip->sip_via && sip->sip_via->v_port &&
|
||||
atoi(sip->sip_via->v_port) == 5060 && np->network_port != 5060 ) {
|
||||
np->is_nat = "via port";
|
||||
}
|
||||
|
@ -271,14 +271,14 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
|
||||
"Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nNobody to send to: Profile %s\n", proto, from, to,
|
||||
body ? body : "[no body]", prof ? prof : "NULL");
|
||||
body ? body : "[no body]", prof);
|
||||
// emit no recipient event
|
||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ERROR) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Error-Type", "chat");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Error-Reason", "no recipient");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-To", to);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-From", from);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-Profile", prof ? prof : "NULL");
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-Profile", prof);
|
||||
switch_event_add_body(event, "%s", body);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
@ -301,6 +301,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
|
||||
dup_dest = strdup(dst->to);
|
||||
}
|
||||
|
||||
switch_assert(dup_dest);
|
||||
|
||||
remote_host = strdup(dup_dest);
|
||||
if (!zstr(remote_host)) {
|
||||
@ -319,7 +320,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
|
||||
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
if (dup_dest && (p = strstr(dup_dest, ";fs_"))) {
|
||||
if ((p = strstr(dup_dest, ";fs_"))) {
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
@ -627,10 +628,7 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
|
||||
|
||||
switch_safe_free(stream.data);
|
||||
switch_safe_free(dup_account);
|
||||
|
||||
if (profile) {
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
|
||||
static int sofia_presence_dialog_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
@ -709,7 +707,7 @@ static void do_normal_probe(switch_event_t *event)
|
||||
probe_euser = (p + 1);
|
||||
}
|
||||
|
||||
if (probe_euser && probe_host &&
|
||||
if (probe_host &&
|
||||
((profile = sofia_glue_find_profile(probe_host)) || (profile_name && (profile = sofia_glue_find_profile(profile_name))))) {
|
||||
sql = switch_mprintf("select state,status,rpid,presence_id,uuid from sip_dialogs "
|
||||
"where hostname='%q' and profile_name='%q' and call_info_state != 'seized' and "
|
||||
@ -846,7 +844,7 @@ static void do_dialog_probe(switch_event_t *event)
|
||||
probe_euser = (p + 1);
|
||||
}
|
||||
|
||||
if (probe_euser && probe_host) {
|
||||
if (probe_host) {
|
||||
char *sub_call_id = switch_event_get_header(event, "sub-call-id");
|
||||
char *profile_name = switch_event_get_header(event, "sip_profile");
|
||||
sofia_profile_t *profile = sofia_glue_find_profile(probe_host);
|
||||
@ -1811,6 +1809,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
|
||||
|
||||
presence_id = argv[12];
|
||||
free_me = strdup(presence_id);
|
||||
switch_assert(free_me);
|
||||
if ((p = strchr(free_me, '@'))) *p = '\0';
|
||||
user = free_me;
|
||||
}
|
||||
@ -1906,6 +1905,7 @@ char *get_display_name_from_contact(const char *in, char* dst)
|
||||
strcpy(dst, "");
|
||||
if (strchr(in, '<') && strchr(in, '>')) {
|
||||
buf = strdup(in);
|
||||
switch_assert(buf);
|
||||
p = strchr(buf, '<');
|
||||
*p = '\0';
|
||||
if (!zstr(buf)) {
|
||||
@ -1914,6 +1914,7 @@ char *get_display_name_from_contact(const char *in, char* dst)
|
||||
if (*p == '"') {
|
||||
if (end_of(p+1) == '"') {
|
||||
char *q = strdup(p + 1);
|
||||
switch_assert(q);
|
||||
end_of(q) = '\0';
|
||||
strcpy(dst, q);
|
||||
switch_safe_free(q);
|
||||
@ -2722,6 +2723,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
|
||||
free_me = strdup(presence_id);
|
||||
|
||||
switch_assert(free_me);
|
||||
|
||||
if ((p = strchr(free_me, '@'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
@ -2887,14 +2890,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
free(buf);
|
||||
#endif
|
||||
|
||||
if (is_dialog) {
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
}
|
||||
|
||||
if (is_dialog) {
|
||||
// Usually we report the dialogs FROM the probed user. The exception is when the monitored endpoint is internal,
|
||||
// and its presence_id is set in the dialplan. Reverse the direction if this is not a registered entity.
|
||||
const char *caller = switch_str_nil(switch_event_get_header(helper->event, "caller-username"));
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
if (!strcmp(direction, "inbound") && strcmp(sub_to_user, caller)) {
|
||||
// If inbound and the entity is not the caller (i.e. internal to FS), then the direction is reversed
|
||||
// because it is not going through the B2BUA
|
||||
@ -3728,9 +3728,6 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
|
||||
if (to) {
|
||||
to_str = switch_mprintf("sip:%s@%s", to->a_url->url_user, to->a_url->url_host);
|
||||
}
|
||||
|
||||
if (to) {
|
||||
to_user = to->a_url->url_user;
|
||||
to_host = to->a_url->url_host;
|
||||
}
|
||||
@ -3754,14 +3751,12 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
}
|
||||
|
||||
if ((sub_max_deviation_var = profile->sip_subscription_max_deviation)) {
|
||||
if (sub_max_deviation_var > 0) {
|
||||
int sub_deviation;
|
||||
srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) );
|
||||
/* random negative number between 0 and negative sub_max_deviation_var: */
|
||||
sub_deviation = ( rand() % sub_max_deviation_var ) - sub_max_deviation_var;
|
||||
if ( (exp_delta + sub_deviation) > 45 ) {
|
||||
exp_delta += sub_deviation;
|
||||
}
|
||||
int sub_deviation;
|
||||
srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) );
|
||||
/* random negative number between 0 and negative sub_max_deviation_var: */
|
||||
sub_deviation = ( rand() % sub_max_deviation_var ) - sub_max_deviation_var;
|
||||
if ( (exp_delta + sub_deviation) > 45 ) {
|
||||
exp_delta += sub_deviation;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3858,7 +3853,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
}
|
||||
}
|
||||
|
||||
if (!(proto && to_user && to_host)) {
|
||||
if (!(proto && to_host)) {
|
||||
nua_respond(nh, SIP_404_NOT_FOUND, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
|
||||
goto end;
|
||||
}
|
||||
@ -4078,7 +4073,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
}
|
||||
}
|
||||
|
||||
sip_to_tag(nh->nh_home, sip->sip_to, use_to_tag);
|
||||
if (nh && nh->nh_home) {
|
||||
sip_to_tag(nh->nh_home, sip->sip_to, use_to_tag);
|
||||
}
|
||||
|
||||
if (mod_sofia_globals.debug_presence > 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to SUBSCRIBE with 202 Accepted\n");
|
||||
@ -4238,6 +4235,8 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
|
||||
pd_dup = strdup(sip->sip_payload->pl_data);
|
||||
|
||||
switch_assert(pd_dup);
|
||||
|
||||
if ((xml = switch_xml_parse_str(pd_dup, strlen(pd_dup)))) {
|
||||
switch_xml_t device = NULL;
|
||||
|
||||
@ -4503,18 +4502,11 @@ void sofia_presence_handle_sip_r_subscribe(int status,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "status (%d) != 200, updated state to SUB_STATE_FAILED.\n", status);
|
||||
gw_sub_ptr->state = SUB_STATE_FAILED;
|
||||
|
||||
if (!sofia_private) {
|
||||
nua_handle_destroy(nh);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
if (gateway) {
|
||||
sofia_reg_release_gateway(gateway);
|
||||
}
|
||||
sofia_reg_release_gateway(gateway);
|
||||
|
||||
}
|
||||
|
||||
@ -4608,6 +4600,8 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
|
||||
|
||||
pd_dup = strdup(payload->pl_data);
|
||||
|
||||
switch_assert(pd_dup);
|
||||
|
||||
if ((xml = switch_xml_parse_str(pd_dup, strlen(pd_dup)))) {
|
||||
char *open_closed = "", *note_txt = "";
|
||||
|
||||
@ -4775,7 +4769,7 @@ void sofia_presence_handle_sip_i_message(int status,
|
||||
channel = switch_core_session_get_channel(session);
|
||||
}
|
||||
|
||||
if (sofia_test_pflag(profile, PFLAG_AUTH_MESSAGES) && sip){
|
||||
if (sofia_test_pflag(profile, PFLAG_AUTH_MESSAGES)) {
|
||||
sip_authorization_t const *authorization = NULL;
|
||||
auth_res_t auth_res = AUTH_FORBIDDEN;
|
||||
char keybuf[128] = "";
|
||||
|
@ -766,7 +766,7 @@ void sofia_reg_expire_call_id(sofia_profile_t *profile, const char *call_id, int
|
||||
host = dup;
|
||||
}
|
||||
|
||||
if (!host) {
|
||||
if (zstr(host)) {
|
||||
host = "none";
|
||||
}
|
||||
|
||||
@ -978,7 +978,7 @@ void sofia_reg_check_call_id(sofia_profile_t *profile, const char *call_id)
|
||||
host = dup;
|
||||
}
|
||||
|
||||
if (!host) {
|
||||
if (zstr(host)) {
|
||||
host = "none";
|
||||
}
|
||||
|
||||
@ -1614,7 +1614,7 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu
|
||||
( !strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) ||
|
||||
!strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20) ||
|
||||
!strncasecmp(sip->sip_user_agent->g_string, "ADTRAN_Total_Access", 19) )) {
|
||||
if (sip && sip->sip_via) {
|
||||
if (sip->sip_via) {
|
||||
const char *host = sip->sip_via->v_host;
|
||||
const char *c_port = sip->sip_via->v_port;
|
||||
int port = 0;
|
||||
@ -1924,7 +1924,7 @@ uint8_t sofia_reg_handle_register_token(nua_t *nua, sofia_profile_t *profile, nu
|
||||
switch_safe_free(url);
|
||||
switch_safe_free(contact);
|
||||
|
||||
if ((is_wss || is_ws || (sofia_test_pflag(profile, PFLAG_TCP_UNREG_ON_SOCKET_CLOSE) && (is_tcp || is_tls))) && !sofia_private && call_id) {
|
||||
if ((is_wss || is_ws || (sofia_test_pflag(profile, PFLAG_TCP_UNREG_ON_SOCKET_CLOSE) && (is_tcp || is_tls))) && !sofia_private) {
|
||||
char key[256] = "";
|
||||
nua_handle_t *hnh;
|
||||
switch_snprintf(key, sizeof(key), "%s%s%s", call_id, network_ip, network_port_c);
|
||||
@ -2396,11 +2396,11 @@ void sofia_reg_handle_sip_r_register(int status,
|
||||
return;
|
||||
}
|
||||
|
||||
if (sofia_private && !zstr(sofia_private->gateway_name)) {
|
||||
if (!zstr(sofia_private->gateway_name)) {
|
||||
gateway = sofia_reg_find_gateway(sofia_private->gateway_name);
|
||||
}
|
||||
|
||||
if (sofia_private && gateway) {
|
||||
if (gateway) {
|
||||
reg_state_t ostate = gateway->state;
|
||||
char oregister_network_ip[80] = { 0 };
|
||||
char network_ip[80] = { 0 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user