mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-17 20:19:37 +00:00
cleanup, null checks. etc.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6735 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
1e0afe2b9d
commit
750af968ec
@ -554,6 +554,10 @@ static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tech_pvt->read_codec.implementation) {
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
|
if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
@ -1371,7 +1375,7 @@ SWITCH_STANDARD_API(sofia_function)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
|
if (!(argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) || !argv[0]) {
|
||||||
stream->write_function(stream, "%s", usage_string);
|
stream->write_function(stream, "%s", usage_string);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||||||
uint32_t ireg_loops = 0;
|
uint32_t ireg_loops = 0;
|
||||||
uint32_t gateway_loops = 0;
|
uint32_t gateway_loops = 0;
|
||||||
switch_event_t *s_event;
|
switch_event_t *s_event;
|
||||||
int tport_log = 0;
|
int tportlog = 0;
|
||||||
|
|
||||||
switch_mutex_lock(mod_sofia_globals.mutex);
|
switch_mutex_lock(mod_sofia_globals.mutex);
|
||||||
mod_sofia_globals.threads++;
|
mod_sofia_globals.threads++;
|
||||||
@ -363,13 +363,13 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (switch_test_flag(profile, TFLAG_TPORT_LOG)) {
|
if (switch_test_flag(profile, TFLAG_TPORT_LOG)) {
|
||||||
tport_log = 1;
|
tportlog = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
profile->nua = nua_create(profile->s_root, /* Event loop */
|
profile->nua = nua_create(profile->s_root, /* Event loop */
|
||||||
sofia_event_callback, /* Callback for processing events */
|
sofia_event_callback, /* Callback for processing events */
|
||||||
profile, /* Additional data to pass to callback */
|
profile, /* Additional data to pass to callback */
|
||||||
NUTAG_URL(profile->bindurl), NTATAG_UDP_MTU(65536), TAG_IF(tport_log,TPTAG_LOG(1)), TAG_END()); /* Last tag should always finish the sequence */
|
NUTAG_URL(profile->bindurl), NTATAG_UDP_MTU(65536), TAG_IF(tportlog,TPTAG_LOG(1)), TAG_END()); /* Last tag should always finish the sequence */
|
||||||
|
|
||||||
if (!profile->nua) {
|
if (!profile->nua) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s\n", profile->name);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s\n", profile->name);
|
||||||
@ -1046,8 +1046,8 @@ switch_status_t config_sofia(int reload, char *profile_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (profile->bind_params) {
|
if (profile->bind_params) {
|
||||||
char *url = profile->bindurl;
|
char *bindurl = profile->bindurl;
|
||||||
profile->bindurl = switch_core_sprintf(profile->pool, "%s;%s", url, profile->bind_params);
|
profile->bindurl = switch_core_sprintf(profile->pool, "%s;%s", bindurl, profile->bind_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -867,6 +867,7 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int
|
|||||||
|
|
||||||
switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
||||||
{
|
{
|
||||||
|
int ms;
|
||||||
|
|
||||||
if (tech_pvt->read_codec.implementation) {
|
if (tech_pvt->read_codec.implementation) {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
@ -901,7 +902,8 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
|||||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
if (switch_core_codec_init(&tech_pvt->write_codec,
|
if (switch_core_codec_init(&tech_pvt->write_codec,
|
||||||
tech_pvt->iananame,
|
tech_pvt->iananame,
|
||||||
tech_pvt->rm_fmtp,
|
tech_pvt->rm_fmtp,
|
||||||
@ -912,10 +914,16 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
|||||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
} else {
|
}
|
||||||
int ms;
|
|
||||||
tech_pvt->read_frame.rate = tech_pvt->rm_rate;
|
tech_pvt->read_frame.rate = tech_pvt->rm_rate;
|
||||||
ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
|
ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
|
||||||
|
|
||||||
|
if (!tech_pvt->read_codec.implementation) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms %d samples\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms %d samples\n",
|
||||||
switch_channel_get_name(tech_pvt->channel), tech_pvt->iananame, tech_pvt->rm_rate, tech_pvt->codec_ms,
|
switch_channel_get_name(tech_pvt->channel), tech_pvt->iananame, tech_pvt->rm_rate, tech_pvt->codec_ms,
|
||||||
tech_pvt->read_codec.implementation->samples_per_frame
|
tech_pvt->read_codec.implementation->samples_per_frame
|
||||||
@ -925,8 +933,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
|||||||
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
|
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
|
||||||
switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
|
switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
|
||||||
tech_pvt->fmtp_out = switch_core_session_strdup(tech_pvt->session, tech_pvt->write_codec.fmtp_out);
|
tech_pvt->fmtp_out = switch_core_session_strdup(tech_pvt->session, tech_pvt->write_codec.fmtp_out);
|
||||||
}
|
|
||||||
}
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,23 +341,23 @@ void sofia_presence_event_handler(switch_event_t *event)
|
|||||||
case SWITCH_EVENT_PRESENCE_PROBE:
|
case SWITCH_EVENT_PRESENCE_PROBE:
|
||||||
if (proto) {
|
if (proto) {
|
||||||
char *to = switch_event_get_header(event, "to");
|
char *to = switch_event_get_header(event, "to");
|
||||||
char *user, *euser, *host, *p;
|
char *probe_user, *probe_euser, *probe_host, *p;
|
||||||
|
|
||||||
if (!to || !(user = strdup(to))) {
|
if (!to || !(probe_user = strdup(to))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((host = strchr(user, '@'))) {
|
if ((probe_host = strchr(probe_user, '@'))) {
|
||||||
*host++ = '\0';
|
*probe_host++ = '\0';
|
||||||
}
|
}
|
||||||
euser = user;
|
probe_euser = probe_user;
|
||||||
if ((p = strchr(euser, '+'))) {
|
if ((p = strchr(probe_euser, '+'))) {
|
||||||
euser = (p + 1);
|
probe_euser = (p + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (euser && host &&
|
if (probe_euser && probe_host &&
|
||||||
(sql = switch_mprintf("select sip_user,sip_host,status,rpid,'' from sip_registrations where sip_user='%q' and sip_host='%q'",
|
(sql = switch_mprintf("select sip_user,sip_host,status,rpid,'' from sip_registrations where sip_user='%q' and sip_host='%q'",
|
||||||
euser, host)) && (profile = sofia_glue_find_profile(host))) {
|
probe_euser, probe_host)) && (profile = sofia_glue_find_profile(probe_host))) {
|
||||||
|
|
||||||
sofia_glue_execute_sql_callback(profile,
|
sofia_glue_execute_sql_callback(profile,
|
||||||
SWITCH_FALSE,
|
SWITCH_FALSE,
|
||||||
@ -725,17 +725,17 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
|||||||
from_host = "n/a";
|
from_host = "n/a";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(to_user, "ext+") || strstr(to_user, "user+")) {
|
if (to_user && (strstr(to_user, "ext+") || strstr(to_user, "user+"))) {
|
||||||
char proto[80];
|
char protocol[80];
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
switch_copy_string(proto, to_user, sizeof(proto));
|
switch_copy_string(protocol, to_user, sizeof(protocol));
|
||||||
if ((p = strchr(proto, '+'))) {
|
if ((p = strchr(protocol, '+'))) {
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "proto", proto);
|
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "proto", protocol);
|
||||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "login", "%s", profile->name);
|
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "login", "%s", profile->name);
|
||||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, to_host);
|
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, to_host);
|
||||||
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "rpid", "active");
|
switch_event_add_header(sevent, SWITCH_STACK_BOTTOM, "rpid", "active");
|
||||||
@ -754,7 +754,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strchr(to_user, '+')) {
|
if (to_user && strchr(to_user, '+')) {
|
||||||
char *h;
|
char *h;
|
||||||
if ((proto = (d_user = strdup(to_user)))) {
|
if ((proto = (d_user = strdup(to_user)))) {
|
||||||
if ((my_to_user = strchr(d_user, '+'))) {
|
if ((my_to_user = strchr(d_user, '+'))) {
|
||||||
|
@ -89,9 +89,8 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
|
|||||||
NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) {
|
NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registering %s\n", gateway_ptr->name);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "registering %s\n", gateway_ptr->name);
|
||||||
|
|
||||||
if (!(gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)))) {
|
gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private));
|
||||||
abort();
|
switch_assert(gateway_ptr->sofia_private);
|
||||||
}
|
|
||||||
memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
|
memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
|
||||||
|
|
||||||
gateway_ptr->sofia_private->gateway = gateway_ptr;
|
gateway_ptr->sofia_private->gateway = gateway_ptr;
|
||||||
@ -881,9 +880,6 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!a1_hash) {
|
if (!a1_hash) {
|
||||||
su_md5_t ctx;
|
|
||||||
char *input;
|
|
||||||
|
|
||||||
input = switch_mprintf("%s:%s:%s", username, realm, passwd);
|
input = switch_mprintf("%s:%s:%s", username, realm, passwd);
|
||||||
su_md5_init(&ctx);
|
su_md5_init(&ctx);
|
||||||
su_md5_strupdate(&ctx, input);
|
su_md5_strupdate(&ctx, input);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user