mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 05:02:10 +00:00
use switch_snprintf instead of snprintf becuase in insures null termination of strings.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6707 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -1524,7 +1524,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
if ((dest_to = strchr(dest, '^'))) {
|
||||
*dest_to++ = '\0';
|
||||
tech_pvt->dest_to = switch_core_session_alloc(nsession, strlen(dest_to) + 5);
|
||||
snprintf(tech_pvt->dest_to, strlen(dest_to) + 5, "sip:%s", dest_to);
|
||||
switch_snprintf(tech_pvt->dest_to, strlen(dest_to) + 5, "sip:%s", dest_to);
|
||||
}
|
||||
|
||||
if ((host = strchr(dest, '%'))) {
|
||||
@@ -1557,7 +1557,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
||||
}
|
||||
} else {
|
||||
tech_pvt->dest = switch_core_session_alloc(nsession, strlen(dest) + 5);
|
||||
snprintf(tech_pvt->dest, strlen(dest) + 5, "sip:%s", dest);
|
||||
switch_snprintf(tech_pvt->dest, strlen(dest) + 5, "sip:%s", dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -741,7 +741,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
return status;
|
||||
}
|
||||
|
||||
snprintf(url, sizeof(url), "profile=%s", switch_str_nil(profile_name));
|
||||
switch_snprintf(url, sizeof(url), "profile=%s", switch_str_nil(profile_name));
|
||||
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, url))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||
@@ -796,7 +796,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
||||
profile->user_agent = SOFIA_USER_AGENT;
|
||||
|
||||
profile->name = switch_core_strdup(profile->pool, xprofilename);
|
||||
snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename);
|
||||
switch_snprintf(url, sizeof(url), "sofia_reg_%s", xprofilename);
|
||||
|
||||
profile->dbname = switch_core_strdup(profile->pool, url);
|
||||
switch_core_hash_init(&profile->chat_hash, profile->pool);
|
||||
@@ -1457,7 +1457,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
if (switch_test_flag(tech_pvt, TFLAG_NOHUP)) {
|
||||
switch_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
|
||||
} else {
|
||||
snprintf(st, sizeof(st), "%d", status);
|
||||
switch_snprintf(st, sizeof(st), "%d", status);
|
||||
switch_channel_set_variable(channel, "sip_term_status", st);
|
||||
switch_channel_hangup(channel, sofia_glue_sip_cause_to_freeswitch(status));
|
||||
}
|
||||
@@ -2034,7 +2034,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
||||
|
||||
if (sip->sip_max_forwards) {
|
||||
char max_forwards[32];
|
||||
snprintf(max_forwards, sizeof(max_forwards), "%lu", sip->sip_max_forwards->mf_count);
|
||||
switch_snprintf(max_forwards, sizeof(max_forwards), "%lu", sip->sip_max_forwards->mf_count);
|
||||
switch_channel_set_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
||||
|
||||
tech_pvt->session_id++;
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
switch_snprintf(buf, sizeof(buf),
|
||||
"v=0\n"
|
||||
"o=FreeSWITCH %010u %010u IN IP4 %s\n"
|
||||
"s=FreeSWITCH\n"
|
||||
@@ -90,7 +90,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
||||
"m=audio %d RTP/AVP", tech_pvt->owner_id, tech_pvt->session_id, ip, ip, sr, port);
|
||||
|
||||
if (tech_pvt->rm_encoding) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt);
|
||||
} else if (tech_pvt->num_codecs) {
|
||||
int i;
|
||||
int already_did[128] = { 0 };
|
||||
@@ -109,7 +109,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
||||
already_did[imp->ianacode] = 1;
|
||||
}
|
||||
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
|
||||
if (!ptime) {
|
||||
ptime = imp->microseconds_per_frame / 1000;
|
||||
}
|
||||
@@ -117,20 +117,20 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
||||
}
|
||||
|
||||
if (tech_pvt->te > 95) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->te);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->te);
|
||||
}
|
||||
|
||||
if (tech_pvt->cng_pt && use_cng) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->cng_pt);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->cng_pt);
|
||||
}
|
||||
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n");
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n");
|
||||
|
||||
if (tech_pvt->rm_encoding) {
|
||||
rate = tech_pvt->rm_rate;
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", tech_pvt->pt, tech_pvt->rm_encoding, rate);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", tech_pvt->pt, tech_pvt->rm_encoding, rate);
|
||||
if (tech_pvt->fmtp_out) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->pt, tech_pvt->fmtp_out);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->pt, tech_pvt->fmtp_out);
|
||||
}
|
||||
if (tech_pvt->read_codec.implementation && !ptime) {
|
||||
ptime = tech_pvt->read_codec.implementation->microseconds_per_frame / 1000;
|
||||
@@ -159,38 +159,38 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
||||
if (ptime && ptime != imp->microseconds_per_frame / 1000) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ptime %u != advertised ptime %u\n", imp->microseconds_per_frame / 1000, ptime);
|
||||
}
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, rate);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, rate);
|
||||
if (imp->fmtp) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tech_pvt->te > 95) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", tech_pvt->te, tech_pvt->te);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", tech_pvt->te, tech_pvt->te);
|
||||
}
|
||||
if (tech_pvt->cng_pt && use_cng) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d CN/8000\n", tech_pvt->cng_pt);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d CN/8000\n", tech_pvt->cng_pt);
|
||||
if (!tech_pvt->rm_encoding) {
|
||||
tech_pvt->cng_pt = 0;
|
||||
}
|
||||
} else {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=silenceSupp:off - - - -\n");
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=silenceSupp:off - - - -\n");
|
||||
}
|
||||
if (ptime) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
|
||||
}
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding) {
|
||||
sofia_glue_tech_choose_video_port(tech_pvt);
|
||||
if ((v_port = tech_pvt->adv_sdp_video_port)) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "m=video %d RTP/AVP", v_port);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "m=video %d RTP/AVP", v_port);
|
||||
|
||||
sofia_glue_tech_set_video_codec(tech_pvt, 0);
|
||||
|
||||
/*****************************/
|
||||
if (tech_pvt->video_rm_encoding) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->video_pt);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->video_pt);
|
||||
} else if (tech_pvt->num_codecs) {
|
||||
int i;
|
||||
int already_did[128] = { 0 };
|
||||
@@ -208,20 +208,20 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
||||
already_did[imp->ianacode] = 1;
|
||||
}
|
||||
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
|
||||
if (!ptime) {
|
||||
ptime = imp->microseconds_per_frame / 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n");
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n");
|
||||
|
||||
if (tech_pvt->rm_encoding) {
|
||||
rate = tech_pvt->video_rm_rate;
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%ld\n", tech_pvt->video_pt, tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%ld\n", tech_pvt->video_pt, tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate);
|
||||
if (tech_pvt->video_fmtp_out) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->video_pt, tech_pvt->video_fmtp_out);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->video_pt, tech_pvt->video_fmtp_out);
|
||||
}
|
||||
} else if (tech_pvt->num_codecs) {
|
||||
int i;
|
||||
@@ -244,9 +244,9 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
||||
rate = imp->samples_per_second;
|
||||
}
|
||||
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, imp->samples_per_second);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, imp->samples_per_second);
|
||||
if (imp->fmtp) {
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
|
||||
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
|
||||
switch_core_session_set_private(session, tech_pvt);
|
||||
|
||||
|
||||
snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
|
||||
switch_snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
|
||||
switch_channel_set_name(tech_pvt->channel, name);
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt)
|
||||
tech_pvt->adv_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, ip);
|
||||
tech_pvt->adv_sdp_audio_port = sdp_port;
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%d", sdp_port);
|
||||
switch_snprintf(tmp, sizeof(tmp), "%d", sdp_port);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
|
||||
|
||||
@@ -446,7 +446,7 @@ switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt)
|
||||
|
||||
tech_pvt->adv_sdp_video_port = sdp_port;
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%d", sdp_port);
|
||||
switch_snprintf(tmp, sizeof(tmp), "%d", sdp_port);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
|
||||
|
||||
@@ -660,7 +660,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
|
||||
if ((host = strchr(user, '@'))) {
|
||||
*host++ = '\0';
|
||||
}
|
||||
snprintf(hash_key, sizeof(hash_key), "%s%s%s", user, host, cid_num);
|
||||
switch_snprintf(hash_key, sizeof(hash_key), "%s%s%s", user, host, cid_num);
|
||||
|
||||
tech_pvt->chat_from = tech_pvt->from_str;
|
||||
tech_pvt->chat_to = tech_pvt->dest;
|
||||
@@ -991,7 +991,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
|
||||
tech_pvt->agreed_pt,
|
||||
tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
|
||||
switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
|
||||
|
||||
@@ -1358,7 +1358,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
||||
char tmp[80];
|
||||
int num;
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%s@%uk@%ui", near_match->iananame, near_match->samples_per_second, ptime);
|
||||
switch_snprintf(tmp, sizeof(tmp), "%s@%uk@%ui", near_match->iananame, near_match->samples_per_second, ptime);
|
||||
|
||||
prefs[0] = tmp;
|
||||
num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
|
||||
@@ -1385,7 +1385,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
||||
tech_pvt->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
|
||||
tech_pvt->remote_sdp_audio_port = (switch_port_t) m->m_port;
|
||||
tech_pvt->agreed_pt = (switch_payload_t) map->rm_pt;
|
||||
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
|
||||
switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
|
||||
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);
|
||||
|
||||
@@ -1467,7 +1467,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
||||
tech_pvt->video_rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
|
||||
tech_pvt->remote_sdp_video_port = (switch_port_t) m->m_port;
|
||||
tech_pvt->video_agreed_pt = (switch_payload_t) map->rm_pt;
|
||||
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_video_port);
|
||||
switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_video_port);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
|
||||
switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE, tmp);
|
||||
} else {
|
||||
|
||||
@@ -958,7 +958,7 @@ void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip)
|
||||
{
|
||||
url_t *to = sip->sip_to->a_url;
|
||||
url_t *from = sip->sip_from->a_url;
|
||||
snprintf(hash_key, len, "%s%s%s", from->url_user, from->url_host, to->url_user);
|
||||
switch_snprintf(hash_key, len, "%s%s%s", from->url_user, from->url_host, to->url_user);
|
||||
}
|
||||
|
||||
void sofia_presence_handle_sip_i_message(int status,
|
||||
|
||||
@@ -159,7 +159,7 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames
|
||||
char *contact = NULL;
|
||||
char to[128] = "";
|
||||
|
||||
snprintf(to, sizeof(to), "%s@%s", argv[1], argv[2]);
|
||||
switch_snprintf(to, sizeof(to), "%s@%s", argv[1], argv[2]);
|
||||
contact = sofia_glue_get_url_from_contact(argv[3], 1);
|
||||
|
||||
nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(contact), SIPTAG_CONTACT_STR(profile->url), TAG_END());
|
||||
@@ -211,9 +211,9 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
||||
#endif
|
||||
|
||||
if (now) {
|
||||
snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires <= %ld", profile->name, (long) now);
|
||||
switch_snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0 and expires <= %ld", profile->name, (long) now);
|
||||
} else {
|
||||
snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0", profile->name);
|
||||
switch_snprintf(sql, sizeof(sql), "select '%s',* from sip_registrations where expires > 0", profile->name);
|
||||
}
|
||||
|
||||
switch_mutex_lock(profile->ireg_mutex);
|
||||
@@ -224,26 +224,26 @@ void sofia_reg_check_expire(sofia_profile_t *profile, time_t now)
|
||||
sofia_reg_del_callback,
|
||||
NULL);
|
||||
if (now) {
|
||||
snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld", (long) now);
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld", (long) now);
|
||||
} else {
|
||||
snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0");
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0");
|
||||
}
|
||||
sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
|
||||
if (now) {
|
||||
snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld", (long) now);
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld", (long) now);
|
||||
} else {
|
||||
snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0");
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0");
|
||||
}
|
||||
sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
|
||||
if (now) {
|
||||
snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0 and expires <= %ld", (long) now);
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0 and expires <= %ld", (long) now);
|
||||
} else {
|
||||
snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0");
|
||||
switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires > 0");
|
||||
}
|
||||
sofia_glue_execute_sql(profile, SWITCH_TRUE, sql, NULL);
|
||||
|
||||
if (now) {
|
||||
snprintf(sql, sizeof(sql), "select * from sip_registrations where status like '%%NATHACK%%'");
|
||||
switch_snprintf(sql, sizeof(sql), "select * from sip_registrations where status like '%%NATHACK%%'");
|
||||
sofia_glue_execute_sql_callback(profile,
|
||||
SWITCH_TRUE,
|
||||
NULL,
|
||||
@@ -269,9 +269,9 @@ char *sofia_reg_find_reg_url(sofia_profile_t *profile, const char *user, const c
|
||||
cbt.len = len;
|
||||
|
||||
if (host) {
|
||||
snprintf(val, len, "select contact from sip_registrations where sip_user='%s' and sip_host='%s'", user, host);
|
||||
switch_snprintf(val, len, "select contact from sip_registrations where sip_user='%s' and sip_host='%s'", user, host);
|
||||
} else {
|
||||
snprintf(val, len, "select contact from sip_registrations where sip_user='%s'", user);
|
||||
switch_snprintf(val, len, "select contact from sip_registrations where sip_user='%s'", user);
|
||||
}
|
||||
|
||||
|
||||
@@ -385,10 +385,10 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
}
|
||||
|
||||
if (contact->m_url->url_params) {
|
||||
snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%s;%s>",
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%s;%s>",
|
||||
display, contact->m_url->url_user, contact->m_url->url_host, port, contact->m_url->url_params);
|
||||
} else {
|
||||
snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%s>", display, contact->m_url->url_user, contact->m_url->url_host, port);
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%s>", display, contact->m_url->url_user, contact->m_url->url_host, port);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,10 +423,10 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
if ((v_contact_str = switch_event_get_header(*v_event, "sip-force-contact"))) {
|
||||
if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction") || !strcasecmp(v_contact_str, "NDLB-connectile-dysfunction")) {
|
||||
if (contact->m_url->url_params) {
|
||||
snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d;%s>",
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d;%s>",
|
||||
display, contact->m_url->url_user, network_ip, network_port, contact->m_url->url_params);
|
||||
} else {
|
||||
snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>", display, contact->m_url->url_user, network_ip, network_port);
|
||||
switch_snprintf(contact_str, sizeof(contact_str), "%s <sip:%s@%s:%d>", display, contact->m_url->url_user, network_ip, network_port);
|
||||
}
|
||||
cd = 1;
|
||||
exptime = 20;
|
||||
@@ -709,7 +709,7 @@ void sofia_reg_handle_sip_r_challenge(int status,
|
||||
goto cancel;
|
||||
}
|
||||
|
||||
snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, gateway->register_username, gateway->register_password);
|
||||
switch_snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, gateway->register_username, gateway->register_password);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Authenticating '%s' with '%s'.\n", profile->username, authentication);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user