-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
*
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II <anthm@freeswitch.org>
* Ken Rice <krice@freeswitch.org>
* Paul D. Tinsley <pdt at jackhammer.org>
if (status == 481 && sip && !sip->sip_retry_after && sip->sip_call_id && (!sofia_private || !sofia_private->is_call)) {
char *sql;
-
+
sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", sip->sip_call_id->i_id);
switch_assert(sql != NULL);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
if (sip->sip_route) {
if ((full = sip_header_as_string(nh->nh_home, (void *) sip->sip_route))) {
const char *v = switch_channel_get_variable(channel, "sip_full_route");
- if (!v) {
+ if (!v) {
switch_channel_set_variable(channel, "sip_full_route", full);
}
su_free(nh->nh_home, full);
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
char *tmp[128] = { 0 };
int y = 0;
-
+
for(rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) {
char *rr = sip_header_as_string(nh->nh_home, (void *) rrp);
tmp[y++] = rr;
if (y == 127) break;
}
-
+
y--;
while(y >= 0) {
} else {
for(rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) {
char *rr = sip_header_as_string(nh->nh_home, (void *) rrp);
-
+
stream.write_function(&stream, x == 0 ? "%s" : ",%s", rr);
su_free(nh->nh_home, rr);
-
+
x++;
}
}
-
+
switch_channel_set_variable(channel, "sip_invite_record_route", (char *)stream.data);
free(stream.data);
}
int x = 0;
SWITCH_STANDARD_STREAM(stream);
-
+
for(vp = sip->sip_via; vp; vp = vp->v_next) {
char *v = sip_header_as_string(nh->nh_home, (void *) vp);
-
+
stream.write_function(&stream, x == 0 ? "%s" : ",%s", v);
su_free(nh->nh_home, v);
-
+
x++;
}
-
+
switch_channel_set_variable(channel, "sip_full_via", (char *)stream.data);
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND || switch_stristr("TCP", (char *)stream.data)) {
}
free(stream.data);
-
+
}
-
+
if (sip->sip_from) {
char *p = strip_quotes(sip->sip_from->a_display);
sip->sip_event->o_type);
}
goto error;
- }
+ }
/* find the corresponding gateway subscription (if any) */
if (!(gw_sub_ptr = sofia_find_gateway_subscription(sofia_private->gateway, sip->sip_event->o_type))) {
if (sip->sip_to && sip->sip_to->a_url && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host
&& sip->sip_payload && sip->sip_payload->pl_data ) {
- sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), NULL);
+ sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), NULL);
for (x = 0; x < profile->acl_count; x++) {
last_acl = profile->acl[x];
if (!(acl_ok = switch_check_network_list_ip(network_ip, last_acl))) {
if (!zstr(other_uuid) && (other_session = switch_core_session_locate(other_uuid))) {
switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
-
+
switch_mutex_lock(profile->ireg_mutex);
if (switch_ivr_eavesdrop_pop_eavesdropper(session, &new_session) == SWITCH_STATUS_SUCCESS) {
switch_channel_t *new_channel = switch_core_session_get_channel(new_session);
switch_channel_set_variable(new_channel, SWITCH_SIGNAL_BOND_VARIABLE, NULL);
switch_channel_set_flag(other_channel, CF_REDIRECT);
-
+
switch_channel_set_state(new_channel, CS_RESET);
-
+
switch_ivr_uuid_bridge(new_uuid, other_uuid);
cmd = switch_core_session_sprintf(session, "sleep:500,sofia_sla:%s inline", new_uuid);
-
- switch_channel_clear_flag(other_channel, CF_REDIRECT);
+
+ switch_channel_clear_flag(other_channel, CF_REDIRECT);
switch_core_session_rwunlock(new_session);
}
switch_mutex_unlock(profile->ireg_mutex);
-
+
switch_core_session_rwunlock(other_session);
}
extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX);
sofia_glue_set_extra_headers(session, sip, SOFIA_SIP_BYE_HEADER_PREFIX);
- if (!(vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) || switch_true(vval)) {
- switch_core_session_t *nsession = NULL;
-
- switch_core_session_get_partner(session, &nsession);
-
- if (nsession) {
- switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_BYE_HEADER_PREFIX_T);
- switch_core_session_rwunlock(nsession);
- }
- }
+ if (!(vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) || switch_true(vval)) {
+ switch_core_session_t *nsession = NULL;
+
+ switch_core_session_get_partner(session, &nsession);
+
+ if (nsession) {
+ switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_BYE_HEADER_PREFIX_T);
+ switch_core_session_rwunlock(nsession);
+ }
+ }
switch_channel_hangup(channel, cause);
if (zstr(name)) {
name = caller_profile->caller_id_name;
}
-
+
if (zstr(number)) {
number = caller_profile->caller_id_number;
}
-
+
if (zstr(name)) {
name = number;
}
-
+
if (zstr(number)) {
name = number = "UNKNOWN";
}
if (zstr(name)) {
name = caller_profile->callee_id_name;
}
-
+
if (zstr(number)) {
number = caller_profile->callee_id_number;
}
-
+
if (zstr(name)) {
name = number;
}
-
+
if (zstr(number)) {
number = caller_profile->destination_number;
}
number = (char *) switch_channel_get_variable(channel, num_var);
name = (char *) switch_channel_get_variable(channel, name_var);
-
+
if (zstr(number) && sip->sip_to) {
number = sip->sip_to->a_url->url_user;
}
check_decode(name, session);
fs++;
}
-
+
if ((val = sofia_glue_get_unknown_header(sip, "X-FS-Lazy-Attended-Transfer"))) {
lazy = switch_true(val);
fs++;
}
}
}
-
+
if (zstr(number)) {
if ((tmp = switch_channel_get_variable(channel, num_var)) && !zstr(tmp)) {
}
} else {
-
+
if (!strcmp(caller_profile->callee_id_name, name) && !strcmp(caller_profile->callee_id_number, number)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "%s Same Callee ID \"%s\" <%s>\n", switch_channel_get_name(channel), name, number);
send = 0;
caller_profile->callee_id_name = switch_sanitize_number(switch_core_strdup(caller_profile->pool, name));
caller_profile->callee_id_number = switch_sanitize_number(switch_core_strdup(caller_profile->pool, number));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s Update Callee ID to \"%s\" <%s>\n", switch_channel_get_name(channel), name, number);
-
+
if (lazy || (att && !switch_channel_get_partner_uuid(channel))) {
switch_channel_flip_cid(channel);
}
if (sofia_test_pflag(tech_pvt->profile, PFLAG_TRACK_CALLS)) {
const char *invite_full_via = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_via");
- const char *invite_route_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_route_uri");
-
- nua_ack(nh,
+ const char *invite_route_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_route_uri");
+
+ nua_ack(nh,
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
TAG_IF((zstr(tech_pvt->user_via) && !zstr(invite_full_via)), SIPTAG_VIA_STR(invite_full_via)),
TAG_IF(!zstr(invite_route_uri), SIPTAG_ROUTE_STR(invite_route_uri)),
TAG_END());
-
-
+
+
} else {
- nua_ack(nh,
+ nua_ack(nh,
TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
- TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
+ TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
TAG_END());
}
profile->last_sip_event = switch_time_now();
- /* sofia_private will be == &mod_sofia_globals.keep_private whenever a request is done with a new handle that has to be
+ /* sofia_private will be == &mod_sofia_globals.keep_private whenever a request is done with a new handle that has to be
freed whenever the request is done */
if (nh && sofia_private == &mod_sofia_globals.keep_private) {
if (status >= 300) {
return;
}
}
-
+
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) {
if ((gateway = sofia_private->gateway)) {
}
}
}
-
+
if (sofia_test_pflag(profile, PFLAG_AUTH_ALL) && tech_pvt && tech_pvt->key && sip && (event < nua_r_set_params || event > nua_r_authenticate)) {
sip_authorization_t const *authorization = NULL;
if (sip->sip_reason) {
char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason);
-
+
if (!zstr(reason_header)) {
switch_channel_set_variable_partner(channel, "sip_reason", reason_header);
}
if (sofia_test_flag(tech_pvt, TFLAG_PASS_ACK)) {
switch_core_session_t *other_session;
-
+
sofia_clear_flag(tech_pvt, TFLAG_PASS_ACK);
tech_send_ack(other_tech_pvt->nh, other_tech_pvt);
}
switch_core_session_rwunlock(other_session);
- }
-
+ }
+
}
}
-
+
if (!method) {
method = strdup("INVITE");
}
referred_by = sofia_glue_get_url_from_contact(sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_referred_by), 0);
ref_by_user = sip->sip_referred_by->b_url->url_user;
}
- else if(sip->sip_to && sip->sip_to->a_url)
- {
+ else if(sip->sip_to && sip->sip_to->a_url)
+ {
referred_by = sofia_glue_get_url_from_contact(sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_to), 0);
- ref_by_user = sip->sip_to->a_url->url_user;
- }
+ ref_by_user = sip->sip_to->a_url->url_user;
+ }
if (sip->sip_to && sip->sip_to->a_url) {
req_user = sip->sip_to->a_url->url_user;
if (sip->sip_call_id && sip->sip_call_id->i_id) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Request-Call-ID", sip->sip_call_id->i_id);
}
-
+
if (!zstr(referred_by)) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Request-Sender", "sofia/%s/%s", profile->name, referred_by);
}
np.fs_path = 1;
contact_str = sofia_glue_gen_contact_str(profile, sip, nh, de, &np);
-
+
call_id = sip->sip_call_id->i_id;
full_from = sip_header_as_string(nh->nh_home, (void *) sip->sip_from);
full_to = sip_header_as_string(nh->nh_home, (void *) sip->sip_to);
full_via = sip_header_as_string(nh->nh_home, (void *) sip->sip_via);
full_agent = sip_header_as_string(nh->nh_home, (void *) sip->sip_user_agent);
-
+
switch_stun_random_string(to_tag, 12, NULL);
if (sip->sip_from) {
to_user = "n/a";
to_host = "n/a";
}
-
+
sql = switch_mprintf("insert into sip_subscriptions "
"(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip,version,orig_proto, full_to) "
proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : "",
event_str, contact_str, call_id, full_from, full_via,
(long) switch_epoch_time_now(NULL) + 60,
- full_agent, accept, profile->name, mod_sofia_globals.hostname,
+ full_agent, accept, profile->name, mod_sofia_globals.hostname,
np.network_port, np.network_ip, orig_proto, full_to, to_tag);
-
+
switch_assert(sql != NULL);
-
-
+
+
if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%s REFER SUBSCRIBE %s@%s %s@%s\n%s\n",
profile->name, from_user, from_host, to_user, to_host, sql);
}
-
-
+
+
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
sip_to_tag(nh->nh_home, sip->sip_to, to_tag);
}
-
+
nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_TO(sip->sip_to), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
switch_safe_free(method);
switch_safe_free(full_url);
sql = switch_mprintf("delete from sip_registrations where call_id='%q' and network_ip='%q' and network_port='%q'",
sofia_private->call_id, sofia_private->network_ip, sofia_private->network_port);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "SOCKET DISCONNECT: %s %s:%s\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "SOCKET DISCONNECT: %s %s:%s\n",
sofia_private->call_id, sofia_private->network_ip, sofia_private->network_port);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
nua_handle_destroy(nh);
}
}
-
+
break;
default:
if (status > 100) {
switch_mutex_lock(mod_sofia_globals.mutex);
DE_THREAD_CNT++;
- switch_mutex_unlock(mod_sofia_globals.mutex);
+ switch_mutex_unlock(mod_sofia_globals.mutex);
if (de) {
pool = de->pool;
switch_mutex_lock(mod_sofia_globals.mutex);
DE_THREAD_CNT--;
- switch_mutex_unlock(mod_sofia_globals.mutex);
+ switch_mutex_unlock(mod_sofia_globals.mutex);
return NULL;
}
void sofia_process_dispatch_event_in_thread(sofia_dispatch_event_t **dep)
{
- sofia_dispatch_event_t *de = *dep;
+ sofia_dispatch_event_t *de = *dep;
switch_memory_pool_t *pool;
//sofia_profile_t *profile = (*dep)->profile;
switch_thread_data_t *td;
sofia_private_t *sofia_private = nua_handle_magic(de->nh);
*dep = NULL;
- our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
+ our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile,
de->nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags);
- nua_destroy_event(de->event);
+ nua_destroy_event(de->event);
su_free(nh->nh_home, de);
switch_mutex_lock(profile->flag_mutex);
break;
}
}
-
- switch_mutex_lock(mod_sofia_globals.mutex);
+
+ switch_mutex_lock(mod_sofia_globals.mutex);
msg_queue_threads++;
- switch_mutex_unlock(mod_sofia_globals.mutex);
+ switch_mutex_unlock(mod_sofia_globals.mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "MSG Thread %d Started\n", my_id);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "MSG Thread Ended\n");
- switch_mutex_lock(mod_sofia_globals.mutex);
+ switch_mutex_lock(mod_sofia_globals.mutex);
msg_queue_threads--;
- switch_mutex_unlock(mod_sofia_globals.mutex);
+ switch_mutex_unlock(mod_sofia_globals.mutex);
- return NULL;
+ return NULL;
}
void sofia_msg_thread_start(int idx)
{
- if (idx >= mod_sofia_globals.max_msg_queues ||
+ if (idx >= mod_sofia_globals.max_msg_queues ||
idx >= SOFIA_MAX_MSG_QUEUE || (idx < mod_sofia_globals.msg_queue_len && mod_sofia_globals.msg_queue_thread[idx])) {
return;
}
switch_mutex_lock(mod_sofia_globals.mutex);
-
+
if (idx >= mod_sofia_globals.msg_queue_len) {
int i;
mod_sofia_globals.msg_queue_len = idx + 1;
switch_threadattr_create(&thd_attr, mod_sofia_globals.pool);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
//switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
- switch_thread_create(&mod_sofia_globals.msg_queue_thread[i],
- thd_attr,
- sofia_msg_thread_run,
- mod_sofia_globals.msg_queue,
+ switch_thread_create(&mod_sofia_globals.msg_queue_thread[i],
+ thd_attr,
+ sofia_msg_thread_run,
+ mod_sofia_globals.msg_queue,
mod_sofia_globals.pool);
}
}
}
- if (de->profile && sofia_test_pflag(de->profile, PFLAG_THREAD_PER_REG) &&
+ if (de->profile && sofia_test_pflag(de->profile, PFLAG_THREAD_PER_REG) &&
de->data->e_event == nua_i_register && DE_THREAD_CNT < mod_sofia_globals.max_reg_threads) {
sofia_process_dispatch_event_in_thread(&de);
return;
switch(event) {
case nua_i_terminated:
- if ((status == 401 || status == 407 || status == 403) && sofia_private && sofia_private->uuid) {
+ if ((status == 401 || status == 407 || status == 403) && sofia_private && sofia_private->uuid) {
switch_core_session_t *session;
if ((session = switch_core_session_locate(sofia_private->uuid))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
int end = 0;
-
+
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND && !switch_channel_test_flag(channel, CF_ANSWERED)) {
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_channel_hangup(channel, SWITCH_CAUSE_CALL_REJECTED);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "detaching session %s\n", sofia_private->uuid);
-
+
if (!zstr(tech_pvt->call_id)) {
tech_pvt->sofia_private = NULL;
tech_pvt->nh = NULL;
case nua_i_options:
case nua_i_notify:
case nua_i_info:
-
+
if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING) || !switch_core_ready_inbound()) {
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), NUTAG_WITH_THIS(nua), TAG_END());
goto end;
}
-
+
if (switch_queue_size(mod_sofia_globals.msg_queue) > critical) {
nua_respond(nh, 503, "System Busy", SIPTAG_RETRY_AFTER_STR("300"), NUTAG_WITH_THIS(nua), TAG_END());
goto end;
}
-
+
if (sofia_test_pflag(profile, PFLAG_STANDBY)) {
nua_respond(nh, 503, "System Paused", NUTAG_WITH_THIS(nua), TAG_END());
goto end;
default:
break;
-
+
}
switch_mutex_lock(profile->flag_mutex);
}
}
}
-
+
if (!sip || !sip->sip_call_id || zstr(sip->sip_call_id->i_id)) {
nua_respond(nh, 503, "INVALID INVITE", TAG_END());
- nua_destroy_event(de->event);
+ nua_destroy_event(de->event);
su_free(nh->nh_home, de);
-
+
switch_mutex_lock(profile->flag_mutex);
profile->queued_events--;
switch_mutex_unlock(profile->flag_mutex);
-
+
nua_handle_unref(nh);
nua_stack_unref(nua);
-
+
goto end;
}
if (sip->sip_referred_by) {
channel_name = url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by);
}
-
+
sofia_glue_attach_private(session, profile, tech_pvt, channel_name);
set_call_id(tech_pvt, sip);
} else {
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
- nua_destroy_event(de->event);
+ nua_destroy_event(de->event);
su_free(nh->nh_home, de);
-
+
switch_mutex_lock(profile->flag_mutex);
profile->queued_events--;
switch_mutex_unlock(profile->flag_mutex);
-
+
nua_handle_unref(nh);
nua_stack_unref(nua);
goto end;
}
-
+
if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
char *uuid;
switch_core_session_queue_signal_data(session, de);
goto end;
}
-
+
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) {
switch_core_session_t *session;
goto end;
}
}
-
+
sofia_queue_message(de);
end:
/* we cannot use switch_event_fire, or otherwise we'll start an endless loop */
sofia_presence_event_handler(pevent);
return;
- } else {
+ } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nCannot inject PRESENCE_IN event\n");
return;
}
}
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);
+ 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);
switch_find_local_ip(guess_ip4, sizeof(guess_ip4), NULL, AF_INET);
sql = switch_mprintf("insert into sip_registrations "
"(call_id, sip_user, sip_host, presence_hosts, contact, status, rpid, expires,"
- "user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm,"
+ "user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm,"
"mwi_user, mwi_host, orig_server_host, orig_hostname) "
"values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
call_id, from_user, from_host, presence_hosts, contact_str, rpid, expires, user_agent, to_user, guess_ip4,
sofia_set_pflag_locked(profile, PFLAG_WORKER_RUNNING);
while ((mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING))) {
-
+
if (profile->watchdog_enabled) {
uint32_t event_diff = 0, step_diff = 0, event_fail = 0, step_fail = 0;
-
+
if (profile->step_timeout) {
step_diff = (uint32_t) ((switch_time_now() - profile->last_root_step) / 1000);
-
+
if (step_diff > profile->step_timeout) {
step_fail = 1;
}
}
-
+
if (profile->event_timeout) {
event_diff = (uint32_t) ((switch_time_now() - profile->last_sip_event) / 1000);
-
+
if (event_diff > profile->event_timeout) {
event_fail = 1;
}
}
-
+
if (step_fail && profile->event_timeout && !event_fail) {
step_fail = 0;
}
-
+
if (event_fail || step_fail) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Profile %s: SIP STACK FAILURE DETECTED BY WATCHDOG!\n"
"GOODBYE CRUEL WORLD, I'M LEAVING YOU TODAY....GOODBYE, GOODBYE, GOOD BYE\n", profile->name);
sofia_reg_check_expire(profile, now, 0);
ireg_loops = 0;
}
-
+
if (++gateway_loops >= GATEWAY_SECONDS) {
sofia_reg_check_gateway(profile, switch_epoch_time_now(NULL));
gateway_loops = 0;
}
-
+
sofia_sub_check_gateway(profile, time(NULL));
}
switch_yield(1000000);
-
+
}
sofia_clear_pflag_locked(profile, PFLAG_WORKER_RUNNING);
switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS);
switch_assert(params);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", profile->name);
-
+
if (!(xml = switch_xml_open_cfg(cf, &cfg, params))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
goto end;
const char *dname = switch_xml_attr_soft(domain_tag, "name");
const char *parse = switch_xml_attr_soft(domain_tag, "parse");
const char *alias = switch_xml_attr_soft(domain_tag, "alias");
-
+
if (!zstr(dname)) {
if (!strcasecmp(dname, "all")) {
switch_xml_t xml_root, x_domains;
}
}
}
-
+
switch_event_destroy(&xml_params);
}
/* We have to init the verify_subjects here as during config stage profile->home isn't setup, it should be freed when profile->home is freed */
if ( (profile->tls_verify_policy & TPTLS_VERIFY_SUBJECTS_IN) && profile->tls_verify_in_subjects_str && ! profile->tls_verify_in_subjects) {
profile->tls_verify_in_subjects = su_strlst_dup_split((su_home_t *)profile->nua, profile->tls_verify_in_subjects_str, "|");
- }
+ }
profile->nua = nua_create(profile->s_root, /* Event loop */
sofia_event_callback, /* Callback for processing events */
TAG_IF(sofia_test_pflag(profile, PFLAG_TCP_PING2PONG),
TPTAG_PINGPONG(profile->tcp_ping2pong)),
TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV503),
- NTATAG_SRV_503(0)),
+ NTATAG_SRV_503(0)),
TAG_IF(sofia_test_pflag(profile, PFLAG_TCP_KEEPALIVE),
- TPTAG_KEEPALIVE(profile->tcp_keepalive)),
+ TPTAG_KEEPALIVE(profile->tcp_keepalive)),
NTATAG_DEFAULT_PROXY(profile->outbound_proxy),
NTATAG_SERVER_RPORT(profile->server_rport_level),
NTATAG_CLIENT_RPORT(profile->client_rport_level),
TAG_IF(sofia_test_pflag(profile, PFLAG_NO_CONNECTION_REUSE),
TPTAG_REUSE(0)),
TAG_END()); /* Last tag should always finish the sequence */
-
+
if (!profile->nua) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s (%s)\n"
"The likely causes for this are:\n" "1) Another application is already listening on the specified address.\n"
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created agent for %s\n", profile->name);
-
+
nua_set_params(profile->nua,
SIPTAG_ALLOW_STR("INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO"),
NUTAG_AUTOANSWER(0),
TAG_IF(profile->pres_type, NUTAG_ALLOW("SUBSCRIBE")),
TAG_IF(profile->pres_type, NUTAG_ENABLEMESSAGE(1)),
TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("presence")),
+ TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("as-feature-event")),
TAG_IF((profile->pres_type || sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)), NUTAG_ALLOW_EVENTS("dialog")),
TAG_IF((profile->pres_type || sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)), NUTAG_ALLOW_EVENTS("line-seize")),
TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("call-info")),
}
}
-
+
config_sofia_profile_urls(profile);
}
break;
}
}
-
+
sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
sofia_clear_pflag_locked(profile, PFLAG_SHUTDOWN);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for worker thread\n");
switch_core_hash_destroy(&profile->chat_hash);
switch_core_hash_destroy(&profile->reg_nh_hash);
switch_core_hash_destroy(&profile->mwi_debounce_hash);
-
+
switch_thread_rwlock_unlock(profile->rwlock);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write unlock %s\n", profile->name);
if (sofia_test_pflag(profile, PFLAG_RESPAWN)) {
config_sofia(SOFIA_CONFIG_RESPAWN, profile->name);
}
-
+
sofia_profile_destroy(profile);
end:
return NULL;
}
-void sofia_profile_destroy(sofia_profile_t *profile)
+void sofia_profile_destroy(sofia_profile_t *profile)
{
if (!profile->inuse) {
switch_memory_pool_t *pool = profile->pool;
su_guid_generate(guid);
su_guid_sprintf(str_guid, su_guid_strlen + 1, guid);
str_rfc_5626 = switch_core_sprintf(gateway->pool, ";reg-id=%s;+sip.instance=\"<urn:uuid:%s>\"",reg_id,str_guid);
- }
+ }
if (zstr(realm)) {
if (zstr(proxy)) {
}
gateway->retry_seconds = atoi(retry_seconds);
-
+
if (gateway->retry_seconds < 5) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid retry-seconds of %d on gateway %s, using the value of 30 instead.\n",
gateway->retry_seconds, name);
if (!zstr(from_domain)) {
gateway->from_domain = switch_core_strdup(gateway->pool, from_domain);
}
-
+
if (!zstr(register_transport) && !switch_stristr("transport=", proxy)) {
gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s;transport=%s", proxy, register_transport);
} else {
if ((gw_subs_tag = switch_xml_child(gateway_tag, "subscriptions"))) {
parse_gateway_subscriptions(profile, gateway, gw_subs_tag);
}
-
+
sofia_reg_add_gateway(profile, gateway->name, gateway);
-
+
}
skip:
profile->contact_user, ipv6 ? "[" : "", profile->sipip, ipv6 ? "]" : "", profile->sip_port);
profile->bindurl = profile->url;
}
-
+
profile->tcp_contact = switch_core_sprintf(profile->pool, "<%s;transport=tcp>", profile->url);
-
+
if (profile->public_url) {
profile->tcp_public_contact = switch_core_sprintf(profile->pool, "<%s;transport=tcp>", profile->public_url);
}
-
+
if (profile->bind_params) {
char *bindurl = profile->bindurl;
if (!switch_stristr("transport=", profile->bind_params)) {
profile->bindurl = switch_core_sprintf(profile->pool, "%s;%s", bindurl, profile->bind_params);
} else {
char *bindurl = profile->bindurl;
- profile->bindurl = switch_core_sprintf(profile->pool, "%s;transport=udp,tcp", bindurl);
+ profile->bindurl = switch_core_sprintf(profile->pool, "%s;transport=udp,tcp", bindurl);
}
if (!profile->tls_sip_port && !sofia_test_pflag(profile, PFLAG_AUTO_ASSIGN_TLS_PORT)) {
profile->tls_sip_port = (switch_port_t) atoi(SOFIA_DEFAULT_TLS_PORT);
}
-
+
if (profile->extsipip) {
char *ipv6 = strchr(profile->extsipip, ':');
profile->tls_public_url = switch_core_sprintf(profile->pool,
profile->contact_user,
ipv6 ? "[" : "", profile->extsipip, ipv6 ? "]" : "", profile->tls_sip_port);
}
-
+
if (profile->extsipip && !sofia_test_pflag(profile, PFLAG_AUTO_NAT)) {
char *ipv6 = strchr(profile->extsipip, ':');
profile->tls_url =
"sips:%s@%s%s%s:%d",
profile->contact_user, ipv6 ? "[" : "", profile->sipip, ipv6 ? "]" : "", profile->tls_sip_port);
}
-
+
if (profile->tls_bind_params) {
char *tls_bindurl = profile->tls_bindurl;
profile->tls_bindurl = switch_core_sprintf(profile->pool, "%s;%s", tls_bindurl, profile->tls_bind_params);
if (profile->tls_public_url) {
profile->tls_public_contact = switch_core_sprintf(profile->pool, "<%s;transport=tls>", profile->tls_public_url);
}
-
-
+
+
}
}
tv->tv_sec = ((uint32_t) (now / 1000000)) + 2208988800UL;
tv->tv_usec = (uint32_t) (now % 1000000);
}
-
+
}
#endif
#ifdef HAVE_SOFIA_STUN
su_log_redirect(stun_log, logger, NULL);
#endif
-
+
return SWITCH_STATUS_SUCCESS;
}
if (x > 0) {
mod_sofia_globals.max_reg_threads = x;
}
-
+
} else if (!strcasecmp(var, "auto-restart")) {
mod_sofia_globals.auto_restart = switch_true(val);
} else if (!strcasecmp(var, "reg-deny-binding-fetch-and-no-lookup")) { /* backwards compatibility */
mod_sofia_globals.reg_deny_binding_fetch_and_no_lookup = switch_true(val); /* remove when noone complains about the extra lookup */
if (switch_true(val)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Enabling reg-deny-binding-fetch-and-no-lookup - this functionality is "
- "deprecated and will be removed - let FS devs know if you think it should stay\n");
+ "deprecated and will be removed - let FS devs know if you think it should stay\n");
}
} else if (!strcasecmp(var, "rewrite-multicasted-fs-path")) {
if( (!strcasecmp(val, "to_host")) || (!strcasecmp(val, "1")) ) {
/* old behaviour */
- mod_sofia_globals.rewrite_multicasted_fs_path = 1;
+ mod_sofia_globals.rewrite_multicasted_fs_path = 1;
} else if (!strcasecmp(val, "original_server_host")) {
- mod_sofia_globals.rewrite_multicasted_fs_path = 2;
+ mod_sofia_globals.rewrite_multicasted_fs_path = 2;
} else if (!strcasecmp(val, "original_hostname")) {
- mod_sofia_globals.rewrite_multicasted_fs_path = 3;
+ mod_sofia_globals.rewrite_multicasted_fs_path = 3;
} else {
mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE;
}
profile_found = 1;
}
}
-
+
if (!profile_already_started) {
/* Setup the pool */
sofia_profile_start_failure(NULL, xprofilename);
goto done;
}
-
+
if (!(profile = (sofia_profile_t *) switch_core_alloc(pool, sizeof(*profile)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
sofia_profile_start_failure(NULL, xprofilename);
goto done;
}
-
+
profile->tls_verify_policy = TPTLS_VERIFY_NONE;
/* lib default */
profile->tls_verify_depth = 2;
sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
sofia_set_pflag(profile, PFLAG_SEND_DISPLAY_UPDATE);
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
- //sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
+ //sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
profile->shutdown_type = "false";
profile->local_network = "localnet.auto";
sofia_set_flag(profile, TFLAG_TPORT_LOG);
} else if (!strcasecmp(var, "sip-capture") && switch_true(val)) {
sofia_set_flag(profile, TFLAG_CAPTURE);
- nua_set_params(profile->nua, TPTAG_CAPT(mod_sofia_globals.capture_server), TAG_END());
+ nua_set_params(profile->nua, TPTAG_CAPT(mod_sofia_globals.capture_server), TAG_END());
} else if (!strcasecmp(var, "tcp-keepalive") && !zstr(val)) {
profile->tcp_keepalive = atoi(val);
sofia_set_pflag(profile, PFLAG_TCP_KEEPALIVE);
} else {
sofia_clear_pflag(profile, PFLAG_CID_IN_1XX);
}
-
+
} else if (!strcasecmp(var, "disable-hold")) {
if (switch_true(val)) {
sofia_set_media_flag(profile, SCMF_DISABLE_HOLD);
sofia_set_pflag(profile, PFLAG_MULTIREG);
} else if (!strcasecmp(val, "sylantro")) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Sylantro support has been removed.\n"
"It was incomplete anyway, and we fully support the broadsoft SCA shared line spec.");
}
} else if (!strcasecmp(var, "disable-srv503")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_DISABLE_SRV503);
- }
+ }
} else if (!strcasecmp(var, "unregister-on-options-fail")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL);
sofia_clear_pflag(profile, PFLAG_NAT_OPTIONS_PING);
sofia_clear_pflag(profile, PFLAG_UDP_NAT_OPTIONS_PING);
}
- } else if (!strcasecmp(var, "all-reg-options-ping")) {
+ } else if (!strcasecmp(var, "all-reg-options-ping")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_ALL_REG_OPTIONS_PING);
} else {
} else {
profile->timer_t4 = 4000;
}
- } else if (!strcasecmp(var, "sip-options-respond-503-on-busy")) {
- if (switch_true(val)) {
- sofia_set_pflag(profile, PFLAG_OPTIONS_RESPOND_503_ON_BUSY);
- } else {
- sofia_clear_pflag(profile, PFLAG_OPTIONS_RESPOND_503_ON_BUSY);
- }
+ } else if (!strcasecmp(var, "sip-options-respond-503-on-busy")) {
+ if (switch_true(val)) {
+ sofia_set_pflag(profile, PFLAG_OPTIONS_RESPOND_503_ON_BUSY);
+ } else {
+ sofia_clear_pflag(profile, PFLAG_OPTIONS_RESPOND_503_ON_BUSY);
+ }
} else if (!strcasecmp(var, "sip-force-expires")) {
int32_t sip_force_expires = atoi(val);
if (sip_force_expires >= 0) {
if (!profile->rtpip[0]) {
profile->rtpip[profile->rtpip_index++] = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
}
-
+
if (switch_nat_get_type()) {
char *ip = switch_core_get_variable_dup("nat_public_addr");
if (ip && !strchr(profile->sipip, ':')) {
profile->extsipip = switch_core_strdup(profile->pool, mod_sofia_globals.guess_ip);
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "we're configured to provision to [%s] on profile [%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "we're configured to provision to [%s] on profile [%s]\n",
profile->pnp_prov_url, profile->pnp_notify_profile);
}
}
}
}
-
+
} else {
switch_xml_t aliases_tag, alias_tag;
switch_channel_clear_flag(channel, CF_REQ_MEDIA);
if (status >= 900) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s status %d received.\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s status %d received.\n",
switch_channel_get_name(channel), status);
return;
}
if (status >= 400 && sip->sip_reason && sip->sip_reason->re_protocol && (!strcasecmp(sip->sip_reason->re_protocol, "Q.850")
|| !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH")
|| !strcasecmp(sip->sip_reason->re_protocol, profile->sdp_username)) && sip->sip_reason->re_cause) {
- tech_pvt->q850_cause = atoi(sip->sip_reason->re_cause);
+ tech_pvt->q850_cause = atoi(sip->sip_reason->re_cause);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote Reason: %d\n", tech_pvt->q850_cause);
- }
+ }
sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port);
if (mod_sofia_globals.debug_sla > 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "QUERY SQL %s\n", sql);
}
-
+
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Auto-Fixing Broken SLA [<sip:%s>;%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Auto-Fixing Broken SLA [<sip:%s>;%s]\n",
sip->sip_from->a_url->url_host, buf);
switch_channel_set_variable_printf(channel, "presence_call_info_full", "<sip:%s>;%s", sip->sip_from->a_url->url_host, buf);
switch_channel_set_variable(channel, "presence_call_info", buf);
}
- }
+ }
}
}
#if 0
- if (status == 200 && switch_channel_test_flag(channel, CF_PROXY_MEDIA) &&
+ if (status == 200 && switch_channel_test_flag(channel, CF_PROXY_MEDIA) &&
sip->sip_payload && sip->sip_payload->pl_data && !strcasecmp(tech_pvt->iananame, "PROXY")) {
switch_core_session_t *other_session;
-
+
switch_core_media_proxy_codec(session, sip->sip_payload->pl_data);
-
+
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
switch_core_media_proxy_codec(other_session, sip->sip_payload->pl_data);
if (!(vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) || switch_true(vval)) {
switch_core_session_t *other_session;
-
+
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (status > 199) {
switch_ivr_transfer_variable(session, other_session, SOFIA_SIP_RESPONSE_HEADER_PREFIX_T);
} else if (sip->sip_server && sip->sip_server->g_string) {
switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string);
}
-
+
sofia_update_callee_id(session, profile, sip, SWITCH_FALSE);
if (sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_TIMING) || sofia_test_media_flag(tech_pvt->profile, SCMF_AUTOFIX_PT)) {
char *invite_contact;
const char *br;
const char *v;
-
+
if ((v = switch_channel_get_variable(channel, "outbound_redirect_fatal")) && switch_true(v)) {
switch_channel_hangup(channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
goto end;
}
redirect_dialstring = stream.data;
-
- switch_channel_set_variable_printf(channel, "sip_redirect_count", "%d", i);
+
+ switch_channel_set_variable_printf(channel, "sip_redirect_count", "%d", i);
switch_channel_set_variable(channel, "sip_redirect_dialstring", redirect_dialstring);
switch_channel_set_variable(a_channel, "sip_redirect_dialstring", redirect_dialstring);
if (sip->sip_payload && sip->sip_payload->pl_data && switch_stristr("m=image", sip->sip_payload->pl_data)) {
has_t38 = 1;
}
-
+
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
switch_channel_clear_flag(tech_pvt->channel, CF_T38_PASSTHRU);
has_t38 = 0;
if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && has_t38) {
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_udptl_mode(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO);
-
+
if ((uuid = switch_channel_get_partner_uuid(channel)) && (other_session = switch_core_session_locate(uuid))) {
if (switch_core_session_compare(session, other_session)) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
switch_core_session_rwunlock(other_session);
}
}
-
+
has_t38 = 0;
}
- if (status > 199 && (switch_channel_test_flag(channel, CF_PROXY_MODE) ||
- switch_channel_test_flag(channel, CF_PROXY_MEDIA) ||
+ if (status > 199 && (switch_channel_test_flag(channel, CF_PROXY_MODE) ||
+ switch_channel_test_flag(channel, CF_PROXY_MEDIA) ||
(switch_channel_test_flag(tech_pvt->channel, CF_T38_PASSTHRU) && (has_t38 || status > 299)))) {
if (sofia_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
r_sdp = tech_pvt->mparams.remote_sdp_str;
switch_core_media_proxy_remote_addr(session, NULL);
}
-
+
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n", status, phrase);
if (status == 491 && (switch_channel_test_flag(tech_pvt->channel, CF_T38_PASSTHRU) ||
switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL);
} else if (status == 200 && switch_channel_test_flag(tech_pvt->channel, CF_T38_PASSTHRU) && has_t38 && sip->sip_payload && sip->sip_payload->pl_data) {
switch_t38_options_t *t38_options = switch_core_media_extract_t38_options(session, sip->sip_payload->pl_data);
-
+
if (!t38_options) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Could not parse T.38 options from sdp.\n");
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "T.38 NEGOTIATION ERROR");
msg->pointer_arg = switch_core_session_strdup(other_session, r_sdp);
msg->pointer_arg_size = strlen(r_sdp);
}
-
+
if (status == 200 && switch_channel_test_flag(tech_pvt->channel, CF_T38_PASSTHRU) && has_t38) {
- if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) &&
+ if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) &&
switch_core_media_ready(other_tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_channel_clear_flag(tech_pvt->channel, CF_NOTIMER_DURING_BRIDGE);
switch_core_media_udptl_mode(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO);
char *full_contact = NULL;
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);
}
if (call_info && (p = strchr(call_info, ';'))) {
p++;
}
-
+
now = switch_epoch_time_now(NULL);
-
+
sql = switch_mprintf("insert into sip_dialogs "
"(call_id,uuid,sip_to_user,sip_to_host,sip_to_tag,sip_from_user,sip_from_host,sip_from_tag,contact_user,"
"contact_host,state,direction,user_agent,profile_name,hostname,contact,presence_id,presence_data,"
switch_yield(250000);
switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
-
+
switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE);
if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
const char *uvar1, *dvar1, *uvar2, *dvar2;
channel = switch_core_session_get_channel(session);
-
+
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND) {
uvar1 = "sip_from_user";
dvar1 = "sip_from_host";
dvar1 = "sip_to_host";
}
-
+
if ((br_b_session = switch_core_session_locate(br_b)) ) {
switch_channel_t *br_b_channel = switch_core_session_get_channel(br_b_session);
switch_caller_profile_t *cp = switch_channel_get_caller_profile(br_b_channel);
switch_channel_get_variable(channel, dvar1),
switch_channel_get_variable(br_a_channel, uvar2),
switch_channel_get_variable(br_a_channel, dvar2));
-
+
switch_channel_add_variable_var_check(br_a_channel, SWITCH_TRANSFER_HISTORY_VARIABLE, cp->transfer_source, SWITCH_FALSE, SWITCH_STACK_PUSH);
switch_channel_set_variable(br_a_channel, SWITCH_TRANSFER_SOURCE_VARIABLE, cp->transfer_source);
switch_core_session_rwunlock(br_a_session);
}
-
-
+
+
}
if ((sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND)) {
switch_core_media_set_sdp_codec_string(session, r_sdp);
}
-
+
sofia_glue_pass_sdp(tech_pvt, (char *) r_sdp);
sofia_set_flag(tech_pvt, TFLAG_NEW_SDP);
-
+
}
}
}
if (channel && (status == 180 || status == 183) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
const char *val;
if ((val = switch_channel_get_variable(channel, "sip_auto_answer")) && switch_true(val)) {
- nua_notify(nh, NUTAG_NEWSUB(1), NUTAG_WITH_THIS_MSG(de->data->e_msg),
+ nua_notify(nh, NUTAG_NEWSUB(1), NUTAG_WITH_THIS_MSG(de->data->e_msg),
NUTAG_SUBSTATE(nua_substate_terminated),SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), SIPTAG_EVENT_STR("talk"), TAG_END());
}
}
if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
const char *wait_for_ack = switch_channel_get_variable(channel, "sip_wait_for_aleg_ack");
-
+
if (switch_true(wait_for_ack)) {
switch_core_session_t *other_session;
-
+
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
private_object_t *other_tech_pvt = switch_core_session_get_private(other_session);
ss_state = nua_callstate_ready;
goto state_process;
}
-
+
}
goto done;
case nua_callstate_received:
an earlier call to nua_invite silently failed.
So we reject the incoming invite with a 491 and redo the failed outgoing invite. */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"Other leg already handling a reinvite, so responding with 491\n");
nua_respond(tech_pvt->nh, SIP_491_REQUEST_PENDING, TAG_END());
const char *br_b = switch_channel_get_partner_uuid(channel);
char *br_a = b_private->uuid;
-
+
if (br_b) {
- switch_core_session_t *tmp;
-
+ switch_core_session_t *tmp;
+
if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer")) &&
(tmp = switch_core_session_locate(br_a))) {
switch_core_media_bug_transfer_recordings(session, tmp);
if (switch_stristr("m=image", r_sdp)) {
is_t38 = 1;
}
-
+
if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
switch_core_session_message_t *msg;
}
}
}
-
+
if (!switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE);
}
}
- other_tech_pvt = switch_core_session_get_private(other_session);
+ other_tech_pvt = switch_core_session_get_private(other_session);
if(sofia_test_flag(other_tech_pvt, TFLAG_REINVITED)) {
/* The other leg won the reinvite race */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Other leg already handling reinvite, so responding with 491\n");
if (tech_pvt->mparams.num_codecs) {
match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_REQUEST);
}
-
+
if (match && sofia_test_flag(tech_pvt, TFLAG_NOREPLY)) {
sofia_clear_flag(tech_pvt, TFLAG_NOREPLY);
goto done;
if (switch_core_media_choose_port(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO, 0) != SWITCH_STATUS_SUCCESS) {
goto done;
}
-
+
switch_core_media_gen_local_sdp(session, NULL, 0, NULL, 0);
if (sofia_media_activate_rtp(tech_pvt) != SWITCH_STATUS_SUCCESS) {
}
break;
case nua_callstate_ready:
- if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && !switch_channel_test_flag(channel, CF_PROXY_MEDIA) &&
+ if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && !switch_channel_test_flag(channel, CF_PROXY_MEDIA) &&
r_sdp && (!is_dup_sdp || sofia_test_flag(tech_pvt, TFLAG_NEW_SDP)) && switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO) && !sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
/* sdp changed since 18X w sdp, we're supposed to ignore it but we, of course, were pressured into supporting it */
uint8_t match = 0;
if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp);
}
-
+
if (sofia_test_flag(tech_pvt, TFLAG_3PCC) && sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my ACK\n");
sofia_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, r_sdp);
}
-
+
//switch_channel_answer(other_channel);
switch_core_session_queue_indication(other_session, SWITCH_MESSAGE_INDICATE_ANSWER);
if (tech_pvt->sofia_private) {
tech_pvt->sofia_private = NULL;
}
-
+
tech_pvt->nh = NULL;
if (nh) {
}
done:
-
+
if ((enum nua_callstate) ss_state == nua_callstate_ready && channel && session && tech_pvt) {
sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY);
if ((status = switch_ivr_originate(NULL, &tsession, &cause, nhelper->exten_with_params, timeout, NULL, NULL, NULL,
switch_channel_get_caller_profile(channel_a), nhelper->vars, SOF_NONE, NULL)) == SWITCH_STATUS_SUCCESS) {
if (switch_channel_up(channel_a)) {
-
+
if (switch_true(switch_channel_get_variable(channel_a, "recording_follow_transfer"))) {
switch_core_media_bug_transfer_recordings(session, a_session);
}
-
+
tuuid_str = switch_core_session_get_uuid(tsession);
switch_channel_set_variable_printf(channel_a, "transfer_to", "att:%s", tuuid_str);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Process REFER to [%s@%s]\n", exten, (char *) refer_to->r_url->url_host);
switch_channel_set_variable(tech_pvt->channel, "transfer_disposition", "recv_replace");
-
+
if (refer_to->r_url && refer_to->r_url->url_headers) {
rep = (char *) switch_stristr("Replaces=", refer_to->r_url->url_headers);
if ((tmp = switch_core_session_locate(br_b))) {
switch_channel_t *tchannel = switch_core_session_get_channel(tmp);
-
+
if ((profile->media_options & MEDIA_OPT_BYPASS_AFTER_ATT_XFER)) {
switch_channel_set_flag(tchannel, CF_BYPASS_MEDIA_AFTER_BRIDGE);
}
}
- if (switch_true(switch_channel_get_variable(channel_a, "recording_follow_transfer")) &&
+ if (switch_true(switch_channel_get_variable(channel_a, "recording_follow_transfer")) &&
(tmp = switch_core_session_locate(br_a))) {
switch_channel_set_variable(switch_core_session_get_channel(tmp), "transfer_disposition", "bridge");
switch_core_media_bug_transfer_recordings(session, tmp);
}
- if (switch_true(switch_channel_get_variable(channel_b, "recording_follow_transfer")) &&
+ if (switch_true(switch_channel_get_variable(channel_b, "recording_follow_transfer")) &&
(tmp = switch_core_session_locate(br_b))) {
switch_core_media_bug_transfer_recordings(b_session, tmp);
switch_core_session_rwunlock(tmp);
}
switch_channel_set_variable_printf(channel_a, "transfer_to", "att:%s", br_b);
-
+
mark_transfer_record(session, br_a, br_b);
-
+
switch_ivr_uuid_bridge(br_a, br_b);
switch_channel_set_variable(channel_b, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
switch_channel_set_variable(t_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
}
-
+
if (switch_true(switch_channel_get_variable(hup_channel, "recording_follow_transfer"))) {
switch_core_media_bug_transfer_recordings(hup_session, t_session);
}
switch_core_session_t *b_session;
switch_channel_set_variable_printf(channel, "transfer_to", "blind:%s", br ? br : exten);
-
+
if (!zstr(br) && (b_session = switch_core_session_locate(br))) {
const char *var;
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
if (!zstr(full_ref_to)) {
switch_channel_set_variable(b_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
}
-
+
if (switch_true(switch_channel_get_variable(channel, "recording_follow_transfer"))) {
switch_core_media_bug_transfer_recordings(session, b_session);
}
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "BLIND_TRANSFER");
-
- if (((var = switch_channel_get_variable(channel, "confirm_blind_transfer")) && switch_true(var)) ||
+
+ if (((var = switch_channel_get_variable(channel, "confirm_blind_transfer")) && switch_true(var)) ||
sofia_test_pflag(profile, PFLAG_CONFIRM_BLIND_TRANSFER)) {
switch_channel_set_state_flag(b_channel, CF_CONFIRM_BLIND_TRANSFER);
} else {
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
NUTAG_SUBSTATE(nua_substate_terminated),
- SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
+ SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END());
}
-
+
switch_ivr_session_transfer(b_session, exten, NULL, NULL);
switch_core_session_rwunlock(b_session);
} else {
switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
NUTAG_SUBSTATE(nua_substate_terminated),
- SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
+ SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END());
}
}
static switch_status_t create_info_event(sip_t const *sip,
- nua_handle_t *nh, switch_event_t **revent)
+ nua_handle_t *nh, switch_event_t **revent)
{
sip_alert_info_t *alert_info = sip_alert_info(sip);
switch_event_t *event;
if (!(sip && switch_event_create(&event, SWITCH_EVENT_RECV_INFO) == SWITCH_STATUS_SUCCESS)) {
return SWITCH_STATUS_FALSE;
}
-
+
if (sip && sip->sip_content_type) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "SIP-Content-Type", sip->sip_content_type->c_type);
}
-
+
if (sip->sip_from && sip->sip_from->a_url) {
if (sip->sip_from->a_url->url_user) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "SIP-From-User", sip->sip_from->a_url->url_user);
if (sofia_test_pflag(profile, PFLAG_EXTENDED_INFO_PARSING)) {
if (sip && sip->sip_content_type && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype &&
- sip->sip_payload && sip->sip_payload->pl_data) {
-
+ sip->sip_payload && sip->sip_payload->pl_data) {
+
if (!strncasecmp(sip->sip_content_type->c_type, "freeswitch", 10)) {
if (!strcasecmp(sip->sip_content_type->c_subtype, "session-event")) {
if (session) {
- if (create_info_event(sip, nh, &event) == SWITCH_STATUS_SUCCESS) {
+ if (create_info_event(sip, nh, &event) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_queue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "queued freeswitch event for INFO\n");
nua_respond(nh, SIP_200_OK, SIPTAG_CONTENT_TYPE_STR("freeswitch/session-event-response"),
- SIPTAG_PAYLOAD_STR("+OK MESSAGE QUEUED"), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
+ SIPTAG_PAYLOAD_STR("+OK MESSAGE QUEUED"), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
} else {
switch_event_destroy(&event);
nua_respond(nh, SIP_200_OK, SIPTAG_CONTENT_TYPE_STR("freeswitch/session-event-response"),
- SIPTAG_PAYLOAD_STR("-ERR MESSAGE NOT QUEUED"), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
+ SIPTAG_PAYLOAD_STR("-ERR MESSAGE NOT QUEUED"), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
}
}
-
+
} else {
nua_respond(nh, SIP_200_OK, SIPTAG_CONTENT_TYPE_STR("freeswitch/session-event-response"),
- SIPTAG_PAYLOAD_STR("-ERR INVALID SESSION"), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
-
+ SIPTAG_PAYLOAD_STR("-ERR INVALID SESSION"), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
+
}
return;
char *arg;
switch_stream_handle_t stream = { 0 };
switch_status_t status;
-
+
SWITCH_STANDARD_STREAM(stream);
switch_assert(stream.data);
-
+
if ((arg = strchr(cmd, ':'))) {
*arg++ = '\0';
}
if ((status = switch_api_execute(cmd, arg, NULL, &stream)) == SWITCH_STATUS_SUCCESS) {
- nua_respond(nh, SIP_200_OK, SIPTAG_CONTENT_TYPE_STR("freeswitch/api-response"),
- SIPTAG_PAYLOAD_STR(stream.data), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
+ nua_respond(nh, SIP_200_OK, SIPTAG_CONTENT_TYPE_STR("freeswitch/api-response"),
+ SIPTAG_PAYLOAD_STR(stream.data), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
} else {
nua_respond(nh, SIP_200_OK, SIPTAG_CONTENT_TYPE_STR("freeswitch/api-response"),
- SIPTAG_PAYLOAD_STR("-ERR INVALID COMMAND"), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
+ SIPTAG_PAYLOAD_STR("-ERR INVALID COMMAND"), NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
}
-
+
switch_safe_free(stream.data);
switch_safe_free(cmd);
return;
}
- nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
+ nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
return;
}
if (sip && sip->sip_content_type && sip->sip_content_type->c_type && !strcasecmp(sip->sip_content_type->c_type, "freeswitch/data")) {
char *data = NULL;
-
+
if (sip->sip_payload && sip->sip_payload->pl_data) {
data = sip->sip_payload->pl_data;
}
- if ((vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) && switch_true(vval)) {
- switch_core_session_t *nsession = NULL;
-
- switch_core_session_get_partner(session, &nsession);
-
- if (nsession) {
+ if ((vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) && switch_true(vval)) {
+ switch_core_session_t *nsession = NULL;
+
+ switch_core_session_get_partner(session, &nsession);
+
+ if (nsession) {
switch_core_session_message_t *msg;
-
- switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_INFO_HEADER_PREFIX_T);
+
+ switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_INFO_HEADER_PREFIX_T);
msg = switch_core_session_alloc(nsession, sizeof(*msg));
MESSAGE_STAMP_FFL(msg);
msg->message_id = SWITCH_MESSAGE_INDICATE_INFO;
-
+
msg->string_array_arg[2] = switch_core_session_strdup(nsession, data);
-
+
msg->from = __FILE__;
switch_core_session_queue_message(nsession, msg);
-
+
switch_core_session_rwunlock(nsession);
- }
- }
+ }
+ }
}
-
+
if (sip && sip->sip_content_type && sip->sip_content_type->c_subtype && sip->sip_content_type->c_type &&
!strncasecmp(sip->sip_content_type->c_type, "message", 7) &&
!strcasecmp(sip->sip_content_type->c_subtype, "update_display")) {
sofia_update_callee_id(session, profile, sip, SWITCH_TRUE);
goto end;
}
-
+
if (sip && sip->sip_content_type && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype &&
sip->sip_payload && sip->sip_payload->pl_data) {
if (!strncasecmp(sip->sip_content_type->c_type, "application", 11) && !strcasecmp(sip->sip_content_type->c_subtype, "media_control+xml")) {
switch_core_session_t *other_session;
-
+
if (switch_channel_test_flag(channel, CF_VIDEO)) {
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
sofia_glue_build_vid_refresh_message(other_session, sip->sip_payload->pl_data);
}
if (dtmf.digit) {
- if (tech_pvt->mparams.dtmf_type == DTMF_INFO ||
+ if (tech_pvt->mparams.dtmf_type == DTMF_INFO ||
sofia_test_pflag(tech_pvt->profile, PFLAG_LIBERAL_DTMF) || switch_channel_test_flag(tech_pvt->channel, CF_LIBERAL_DTMF)) {
/* queue it up */
switch_channel_queue_dtmf(channel, &dtmf);
/* Send 200 OK response */
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
"IGNORE INFO DTMF(%c) (This channel was not configured to use INFO DTMF!)\n", dtmf.digit);
}
}
end:
- if (create_info_event(sip, nh, &event) == SWITCH_STATUS_SUCCESS) {
+ if (create_info_event(sip, nh, &event) == SWITCH_STATUS_SUCCESS) {
if (channel) {
switch_channel_event_set_data(channel, event);
}
switch_channel_set_variable_printf(channel, "sip_network_port", "%d", network_port);
switch_channel_set_variable_printf(channel, "sip_recieved_port", "%d", network_port);
switch_channel_set_variable_printf(channel, "sip_via_rport", "%d", network_port);
-
+
switch_core_recovery_track(session);
}
nua_respond(nh, 400, "Missing Contact Header", TAG_END());
goto fail;
}
-
+
sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port);
if (sip && sip->sip_via && sip->sip_via->v_protocol && switch_stristr("sip/2.0/ws", sip->sip_via->v_protocol)) {
if (!zstr(contact_host)) {
/* NAT mode double check logic and examples.
- Example 1: the contact_host is 192.168.1.100 and the network_ip is also 192.168.1.100 the end point
+ Example 1: the contact_host is 192.168.1.100 and the network_ip is also 192.168.1.100 the end point
is most likely behind nat with us so we need to veto that decision to turn on nat processing.
Example 2: the contact_host is 192.168.1.100 and the network_ip is 192.0.2.100 which is a public internet ip
- the remote endpoint is likely behind a remote nat traversing the public internet.
+ the remote endpoint is likely behind a remote nat traversing the public internet.
This secondary check is here to double check the conclusion of nat settigs to ensure we don't set net
- in cases where we don't really need to be doing this.
+ in cases where we don't really need to be doing this.
Why would you want to do this? Well if your FreeSWITCH is behind nat and you want to talk to endpoints behind
remote NAT over the public internet in addition to endpoints behind nat with you. This simplifies that process.
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IP %s Approved by acl \"%s[%s]\". Access Granted.\n",
network_ip, switch_str_nil(last_acl), acl_token);
switch_set_string(sip_acl_authed_by, last_acl);
- switch_set_string(sip_acl_token, acl_token);
+ switch_set_string(sip_acl_token, acl_token);
is_auth = 1;
}
} else {
proxied_client_ip, switch_str_nil(last_acl), acl_token);
switch_set_string(sip_acl_authed_by, last_acl);
switch_set_string(sip_acl_token, acl_token);
-
+
is_auth = 1;
}
} else {
transport = sofia_glue_url2transport(sip->sip_contact->m_url);
}
-
+
tech_pvt->record_route =
switch_core_session_sprintf(session,
"sip:%s%s%s:%d;transport=%s",
- ipv6 ? "[" : "", tech_pvt->mparams.remote_ip, ipv6 ? "]" : "",
+ ipv6 ? "[" : "", tech_pvt->mparams.remote_ip, ipv6 ? "]" : "",
tech_pvt->mparams.remote_port, sofia_glue_transport2str(transport));
switch_channel_set_variable(channel, "sip_received_ip", tech_pvt->mparams.remote_ip);
ruser = switch_event_get_header(v_event, "username");
rdomain = switch_event_get_header(v_event, "domain_name");
-
+
switch_channel_set_variable(channel, "requested_user_name", ruser);
switch_channel_set_variable(channel, "requested_domain_name", rdomain);
}
if (!user) user = ruser;
if (!domain) domain = rdomain;
-
+
switch_ivr_set_user_xml(session, NULL, user, domain, x_user);
switch_xml_free(x_user);
x_user = NULL;
if (sip->sip_multipart) {
msg_multipart_t *mp;
-
+
for (mp = sip->sip_multipart; mp; mp = mp->mp_next) {
if (mp->mp_payload && mp->mp_payload->pl_data && mp->mp_content_type && mp->mp_content_type->c_type) {
char *val = switch_core_session_sprintf(session, "%s:%s", mp->mp_content_type->c_type, mp->mp_payload->pl_data);
if ((call_info = sip_call_info(sip))) {
call_info_str = sip_header_as_string(nh->nh_home, (void *) call_info);
-
+
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE) && switch_stristr("appearance", call_info_str)) {
char *p;
switch_channel_set_variable(channel, "presence_call_info", p);
}
}
-
+
if (call_info->ci_params && (msg_params_find(call_info->ci_params, "answer-after=0"))) {
switch_channel_set_variable(channel, "sip_auto_answer_detected", "true");
}
char buf[128] = "";
char *sql;
char *state = "progressing";
-
+
if (sip &&
sip->sip_from && sip->sip_from->a_url && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
sip->sip_to && sip->sip_to->a_url && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host) {
"sub_to_user='%q' and sub_to_host='%q'", mod_sofia_globals.hostname, sip->sip_to->a_url->url_user,
sip->sip_from->a_url->url_host);
sofia_glue_execute_sql2str(profile, profile->dbh_mutex, sql, buf, sizeof(buf));
-
+
if (mod_sofia_globals.debug_sla > 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "QUERY SQL %s [%s]\n", sql, buf);
}
free(sql);
-
+
if (!zstr(buf)) {
sql = switch_mprintf("update sip_dialogs set call_info='%q',call_info_state='%q' "
"where uuid='%q'", buf, state, switch_core_session_get_uuid(session));
if (mod_sofia_globals.debug_sla > 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "QUERY SQL %s\n", sql);
}
-
+
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Auto-Fixing Broken SLA [<sip:%s>;%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Auto-Fixing Broken SLA [<sip:%s>;%s]\n",
sip->sip_from->a_url->url_host, buf);
switch_channel_set_variable_printf(channel, "presence_call_info_full", "<sip:%s>;%s", sip->sip_from->a_url->url_host, buf);
switch_channel_set_variable(channel, "presence_call_info", buf);
call_info_str = switch_core_session_sprintf(session, "<sip:%s>;%s", sip->sip_from->a_url->url_host, buf);
}
- }
+ }
}
free(sql);
}
- }
+ }
check_decode(displayname, session);
tech_pvt->caller_profile->caller_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
-#if 0
+#if 0
sent_name = switch_channel_get_variable(b_channel, "last_sent_callee_id_name");
sent_number = switch_channel_get_variable(b_channel, "last_sent_callee_id_number");
} else {
olu = b_private->uuid;
}
-
+
if ((os = switch_core_session_locate(olu))) {
switch_core_session_get_real_read_impl(os, &read_impl);
switch_core_session_rwunlock(os);
- codec_str = switch_core_session_sprintf(session, "set:absolute_codec_string=%s@%di,", read_impl.iananame,
+ codec_str = switch_core_session_sprintf(session, "set:absolute_codec_string=%s@%di,", read_impl.iananame,
read_impl.microseconds_per_packet / 1000);
}
if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) {
- tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
+ tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
"%sanswer,intercept:%s", codec_str, bridge_uuid);
} else {
const char *name = NULL, *num = NULL;
switch_caller_profile_t *bcp = switch_channel_get_caller_profile(b_channel);
-
+
if (switch_channel_test_flag(b_channel, CF_BRIDGE_ORIGINATOR) || !switch_channel_test_flag(b_channel, CF_BRIDGED)) {
name = bcp->callee_id_name;
num = bcp->callee_id_number;
} else {
name = bcp->caller_id_name;
num = bcp->caller_id_number;
- }
-
+ }
+
tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, name);
tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, num);
- tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
+ tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool,
"%sanswer,sofia_sla:%s", codec_str, b_private->uuid);
}
} else {
} else {
const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
const char *b_data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
-
+
if (b_data && b_app) {
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s:%s", b_app, b_data);
} else if (b_app) {
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s", b_app);
}
-
+
switch_channel_hangup(b_channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
}
}
-
+
switch_core_session_rwunlock(b_session);
}
}
(sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING) || !switch_core_ready_inbound())) {
nua_respond(nh, 503, "Maximum Calls In Progress", NUTAG_WITH_THIS_MSG(de->data->e_msg), SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
} else {
- nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg),
+ nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg),
TAG_IF(sip->sip_record_route, SIPTAG_RECORD_ROUTE(sip->sip_record_route)), TAG_END());
}
* mbid=201
*
* The a_params list is parsed and the lvalue is used to create the channel variable name while the
- * rvalue is used to create the channel variable value.
+ * rvalue is used to create the channel variable value.
*
* If no equal (=) sign is found during parsing, a channel variable name is created with the param and
* the value is set to NULL.
*
* Pointers are used for copying the sip_header_name for performance reasons. There are no calls to
* any string functions and no memory is allocated/dealocated. The only limiter is the size of the
- * sip_header_name array.
+ * sip_header_name array.
*/
static void set_variable_sip_param(switch_channel_t *channel, char *header_type, sip_param_t const *params)
{