diff --git a/libs/esl/src/esl_event.c b/libs/esl/src/esl_event.c
index 910180f47e..163d35cc6c 100644
--- a/libs/esl/src/esl_event.c
+++ b/libs/esl/src/esl_event.c
@@ -98,6 +98,8 @@ static const char *EVENT_NAMES[] = {
"MESSAGE",
"PRESENCE_IN",
"NOTIFY_IN",
+ "PHONE_FEATURE",
+ "PHONE_FEATURE_SUBSCRIBE",
"PRESENCE_OUT",
"PRESENCE_PROBE",
"MESSAGE_WAITING",
diff --git a/src/include/switch_types.h b/src/include/switch_types.h
index 9728062d4c..04bec8c27a 100644
--- a/src/include/switch_types.h
+++ b/src/include/switch_types.h
@@ -1681,6 +1681,8 @@ typedef uint32_t switch_io_flag_t;
SWITCH_EVENT_RE_SCHEDULE - Something scheduled has been rescheduled
SWITCH_EVENT_RELOADXML - XML registry has been reloaded
SWITCH_EVENT_NOTIFY - Notification
+ SWITCH_EVENT_PHONE_FEATURE - Notification (DND/CFWD/etc)
+ SWITCH_EVENT_PHONE_FEATURE_SUBSCRIBE - Phone feature subscription
SWITCH_EVENT_SEND_MESSAGE - Message
SWITCH_EVENT_RECV_MESSAGE - Message
SWITCH_EVENT_NAT - NAT Management (new/del/status)
@@ -1748,6 +1750,8 @@ typedef enum {
SWITCH_EVENT_RE_SCHEDULE,
SWITCH_EVENT_RELOADXML,
SWITCH_EVENT_NOTIFY,
+ SWITCH_EVENT_PHONE_FEATURE,
+ SWITCH_EVENT_PHONE_FEATURE_SUBSCRIBE,
SWITCH_EVENT_SEND_MESSAGE,
SWITCH_EVENT_RECV_MESSAGE,
SWITCH_EVENT_REQUEST_PARAMS,
diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c
index 1f1e090a1b..7c146f41ba 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.c
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c
@@ -4582,6 +4582,70 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
return cause;
}
+static int notify_csta_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+ nua_handle_t *nh;
+ sofia_profile_t *ext_profile = NULL, *profile = (sofia_profile_t *) pArg;
+ int i = 0;
+ char *user = argv[i++];
+ char *host = argv[i++];
+ char *contact_in = argv[i++];
+ char *profile_name = argv[i++];
+ char *call_id = argv[i++];
+ char *full_from = argv[i++];
+ char *full_to = argv[i++];
+ int expires = atoi(argv[i++]);
+ char *body = argv[i++];
+ char *ct = argv[i++];
+ char *id = NULL;
+ char *contact;
+ sofia_destination_t *dst = NULL;
+ char *route_uri = NULL;
+
+ time_t epoch_now = switch_epoch_time_now(NULL);
+ time_t expires_in = (expires - epoch_now);
+ char *extra_headers = switch_mprintf("Subscription-State: active, %d\r\n", expires_in);
+
+ if (profile_name && strcasecmp(profile_name, profile->name)) {
+ if ((ext_profile = sofia_glue_find_profile(profile_name))) {
+ profile = ext_profile;
+ }
+ }
+
+ id = switch_mprintf("sip:%s@%s", user, host);
+ switch_assert(id);
+ contact = sofia_glue_get_url_from_contact(contact_in, 1);
+
+
+ dst = sofia_glue_get_destination((char *) contact);
+
+ if (dst->route_uri) {
+ route_uri = sofia_glue_strip_uri(dst->route_uri);
+ }
+
+ //nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END());
+ nh = nua_handle(profile->nua, NULL, NUTAG_URL(dst->contact), SIPTAG_FROM_STR(full_from), SIPTAG_TO_STR(full_to), SIPTAG_CONTACT_STR(profile->url), TAG_END());
+
+ nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
+
+ nua_notify(nh, NUTAG_NEWSUB(1),
+ TAG_IF(dst->route_uri, NUTAG_PROXY(route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),
+ SIPTAG_EVENT_STR("as-feature-event"), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END());
+
+
+
+ switch_safe_free(route_uri);
+ sofia_glue_free_destination(dst);
+
+ free(id);
+ free(contact);
+
+ if (ext_profile) {
+ sofia_glue_release_profile(ext_profile);
+ }
+
+ return 0;
+}
static int notify_callback(void *pArg, int argc, char **argv, char **columnNames)
{
@@ -4655,22 +4719,69 @@ static void general_event_handler(switch_event_t *event)
const char *to_uri = switch_event_get_header(event, "to-uri");
const char *from_uri = switch_event_get_header(event, "from-uri");
const char *extra_headers = switch_event_get_header(event, "extra-headers");
+ const char *contact_uri = switch_event_get_header(event, "contact-uri");
+ const char *no_sub_state = switch_event_get_header(event, "no-sub-state");
sofia_profile_t *profile;
+ if (contact_uri) {
+ if (!es) {
+ es = "message-summary";
+ }
- if (to_uri || from_uri) {
+ if (!ct) {
+ ct = "application/simple-message-summary";
+ }
- if (!to_uri) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To-URI header\n");
+ if (!profile_name) {
+ profile_name = "default";
+ }
+
+ if (!(profile = sofia_glue_find_profile(profile_name))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name);
return;
}
- if (!from_uri) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\n");
- return;
+ if (to_uri && from_uri) {
+ sofia_destination_t *dst = NULL;
+ nua_handle_t *nh;
+ char *route_uri = NULL;
+ char *sip_sub_st = NULL;
+
+ dst = sofia_glue_get_destination((char *) contact_uri);
+
+ if (dst->route_uri) {
+ route_uri = sofia_glue_strip_uri(dst->route_uri);
+ }
+
+ nh = nua_handle(profile->nua,
+ NULL,
+ NUTAG_URL(dst->contact),
+ SIPTAG_FROM_STR(from_uri),
+ SIPTAG_TO_STR(to_uri),
+ SIPTAG_CONTACT_STR(profile->url),
+ TAG_END());
+
+ nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
+
+ if (!switch_true(no_sub_state)) {
+ sip_sub_st = "terminated;reason=noresource";
+ }
+
+ nua_notify(nh,
+ NUTAG_NEWSUB(1), TAG_IF(sip_sub_st, SIPTAG_SUBSCRIPTION_STATE_STR(sip_sub_st)),
+ TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),
+ SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
+ TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
+
+ switch_safe_free(route_uri);
+ sofia_glue_free_destination(dst);
+
+ sofia_glue_release_profile(profile);
}
+ return;
+ } else if (to_uri || from_uri) {
if (!es) {
es = "message-summary";
}
@@ -4770,6 +4881,96 @@ static void general_event_handler(switch_event_t *event)
}
break;
+ case SWITCH_EVENT_PHONE_FEATURE:
+ {
+ const char *profile_name = switch_event_get_header(event, "profile");
+ const char *user = switch_event_get_header(event, "user");
+ const char *host = switch_event_get_header(event, "host");
+ const char *call_id = switch_event_get_header(event, "call-id");
+ const char *csta_event = switch_event_get_header(event, "csta-event");
+
+ char *ct = "application/x-as-feature-event+xml";
+
+ sofia_profile_t *profile;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Phone Feature NOTIFY\n");
+ if (profile_name && user && host && (profile = sofia_glue_find_profile(profile_name))) {
+ char *sql;
+ switch_stream_handle_t stream = { 0 };
+ SWITCH_STANDARD_STREAM(stream);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "we have all required vars\n");
+
+ if (csta_event) {
+ if (!strcmp(csta_event, "init")) {
+ char *boundary_string = "UniqueFreeSWITCHBoundary";
+ switch_stream_handle_t dnd_stream = { 0 };
+ char *header_name = NULL;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending multipart with DND and CFWD\n");
+
+ if ((header_name = switch_event_get_header(event, "forward_immediate"))) {
+ switch_stream_handle_t fwdi_stream = { 0 };
+ SWITCH_STANDARD_STREAM(fwdi_stream);
+ write_csta_xml_chunk(event, fwdi_stream, "ForwardingEvent", "forwardImmediate");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] is %d bytes long\n", (char *)fwdi_stream.data, (int)strlen(fwdi_stream.data));
+ stream.write_function(&stream, "--%s\nContent-Type: application/x-as-feature-event+xml\nContent-Length:%d\nContent-ID:<%s@%s>\n\n%s", boundary_string, strlen(fwdi_stream.data), user, host, fwdi_stream.data);
+ switch_safe_free(fwdi_stream.data);
+ }
+ if ((header_name = switch_event_get_header(event, "forward_busy"))) {
+ switch_stream_handle_t fwdb_stream = { 0 };
+ SWITCH_STANDARD_STREAM(fwdb_stream);
+ write_csta_xml_chunk(event, fwdb_stream, "ForwardingEvent", "forwardBusy");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] is %d bytes long\n", (char *)fwdb_stream.data, (int)strlen(fwdb_stream.data));
+ stream.write_function(&stream, "--%s\nContent-Type: application/x-as-feature-event+xml\nContent-Length:%d\nContent-ID:<%s@%s>\n\n%s", boundary_string, strlen(fwdb_stream.data), user, host, fwdb_stream.data);
+ switch_safe_free(fwdb_stream.data);
+ }
+ if ((header_name = switch_event_get_header(event, "forward_no_answer"))) {
+ switch_stream_handle_t fwdna_stream = { 0 };
+ SWITCH_STANDARD_STREAM(fwdna_stream);
+ write_csta_xml_chunk(event, fwdna_stream, "ForwardingEvent", "forwardNoAns");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] is %d bytes long\n", (char *)fwdna_stream.data, (int)strlen(fwdna_stream.data));
+ stream.write_function(&stream, "--%s\nContent-Type: application/x-as-feature-event+xml\nContent-Length:%d\nContent-ID:<%s@%s>\n\n%s", boundary_string, strlen(fwdna_stream.data), user, host, fwdna_stream.data);
+ switch_safe_free(fwdna_stream.data);
+ }
+
+ SWITCH_STANDARD_STREAM(dnd_stream);
+ write_csta_xml_chunk(event, dnd_stream, "DoNotDisturbEvent", NULL);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] is %d bytes long\n", (char *)dnd_stream.data, (int)strlen(dnd_stream.data));
+ stream.write_function(&stream, "--%s\nContent-Type:application/x-as-feature-event+xml\nContent-Length:%d\nContent-ID:<%s@%s>\n\n%s", boundary_string, strlen(dnd_stream.data), user, host, dnd_stream.data);
+ switch_safe_free(dnd_stream.data);
+
+ stream.write_function(&stream, "--%s--\n", boundary_string);
+
+ ct = switch_mprintf("multipart/mixed; boundary=\"%s\"", boundary_string);
+ } else {
+ // this will need some work to handle the different types of forwarding events
+ write_csta_xml_chunk(event, stream, csta_event, NULL);
+ }
+ }
+
+ if (call_id) {
+ sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,call_id,full_from,full_to,expires,'%q', '%q' "
+ "from sip_subscriptions where event='as-feature-event' and call_id='%q'", stream.data, ct, call_id);
+ } else {
+ sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,call_id,full_from,full_to,expires,'%q', '%q' "
+ "from sip_subscriptions where event='as-feature-event' and sip_user='%s' and sip_host='%q'", stream.data, ct, switch_str_nil(user), switch_str_nil(host)
+ );
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Query: %s\n", sql);
+ switch_safe_free(stream.data);
+ switch_mutex_lock(profile->ireg_mutex);
+ sofia_glue_execute_sql_callback(profile, NULL, sql, notify_csta_callback, profile);
+ switch_mutex_unlock(profile->ireg_mutex);
+ sofia_glue_release_profile(profile);
+
+ free(sql);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "missing something\n");
+ }
+ }
+ break;
case SWITCH_EVENT_SEND_MESSAGE:
{
const char *profile_name = switch_event_get_header(event, "profile");
@@ -5024,6 +5225,57 @@ static void general_event_handler(switch_event_t *event)
}
}
+void write_csta_xml_chunk(switch_event_t *event, switch_stream_handle_t stream, const char *csta_event, char *fwdtype)
+{
+ const char *device = switch_event_get_header(event, "device");
+
+ if (csta_event) {
+ stream.write_function(&stream, "\n<%s xmlns=\"http://www.ecma-international.org/standards/ecma-323/csta/ed3\">\n", csta_event);
+ }
+
+ if (device) {
+ stream.write_function(&stream, " %s\n", device);
+ }
+
+ if (!strcmp(csta_event, "DoNotDisturbEvent")) {
+ const char *dndstatus = switch_event_get_header(event, "doNotDisturbOn");
+
+ if (dndstatus) {
+ stream.write_function(&stream, " %s\n", dndstatus);
+ }
+ } else if(!strcmp(csta_event, "ForwardingEvent")) {
+ const char *fwdstatus = switch_event_get_header(event, "forwardStatus");
+ const char *fwdto = NULL;
+ const char *ringcount = NULL;
+
+ if (strcmp("forwardImmediate", fwdtype)) {
+ fwdto = switch_event_get_header(event, "forward_immediate");
+ } else if (strcmp("forwardBusy", fwdtype)) {
+ fwdto = switch_event_get_header(event, "forward_busy");
+ } else if (strcmp("fowardNoAns", fwdtype)) {
+ fwdto = switch_event_get_header(event, "forward_no_answer");
+ ringcount = switch_event_get_header(event, "ringCount");
+ }
+
+ if (fwdtype) {
+ stream.write_function(&stream, " %s\n", fwdtype);
+ }
+ if (fwdstatus) {
+ stream.write_function(&stream, " %s\n", fwdstatus);
+ }
+ if (fwdto) {
+ stream.write_function(&stream, " %s\n", fwdto);
+ }
+ if (ringcount) {
+ stream.write_function(&stream, " %s\n", ringcount);
+ }
+ }
+
+ if (csta_event) {
+ stream.write_function(&stream, "%s>\n", csta_event);
+ }
+}
+
switch_status_t list_profiles_full(const char *line, const char *cursor, switch_console_callback_match_t **matches, switch_bool_t show_aliases)
{
sofia_profile_t *profile = NULL;
@@ -5287,6 +5539,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
return SWITCH_STATUS_GENERR;
}
+ if (switch_event_bind(modname, SWITCH_EVENT_PHONE_FEATURE, SWITCH_EVENT_SUBCLASS_ANY, general_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
+ return SWITCH_STATUS_GENERR;
+ }
+
if (switch_event_bind(modname, SWITCH_EVENT_SEND_MESSAGE, SWITCH_EVENT_SUBCLASS_ANY, general_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
return SWITCH_STATUS_GENERR;
diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h
index a2f85806b4..c27fcb55a3 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.h
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.h
@@ -1,4 +1,4 @@
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II
*
@@ -22,14 +22,14 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II
* Ken Rice
* Paul D. Tinsley
* Bret McDanel
* Marcel Barbulescu
* Raymond Chandler
- * Emmanuel Schmidbauer
+ * Emmanuel Schmidbauer
*
*
* mod_sofia.h -- SOFIA SIP Endpoint
@@ -149,9 +149,9 @@ typedef enum {
typedef struct sofia_dispatch_event_s {
nua_saved_event_t event[1];
- nua_handle_t *nh;
- nua_event_data_t const *data;
- su_time_t when;
+ nua_handle_t *nh;
+ nua_event_data_t const *data;
+ su_time_t when;
sip_t *sip;
nua_t *nua;
sofia_profile_t *profile;
@@ -353,7 +353,7 @@ struct mod_sofia_globals {
int reg_deny_binding_fetch_and_no_lookup; /* backwards compatibility */
int auto_nat;
int tracelevel;
- char *capture_server;
+ char *capture_server;
int rewrite_multicasted_fs_path;
int presence_flush;
switch_thread_t *presence_thread;
@@ -511,10 +511,10 @@ typedef enum {
} sofia_media_options_t;
typedef enum {
- PAID_DEFAULT = 0,
- PAID_USER,
- PAID_USER_DOMAIN,
- PAID_VERBATIM
+ PAID_DEFAULT = 0,
+ PAID_USER,
+ PAID_USER_DOMAIN,
+ PAID_VERBATIM
} sofia_paid_type_t;
#define MAX_RTPIP 50
@@ -619,7 +619,7 @@ struct sofia_profile {
char *pre_trans_execute;
char *post_trans_execute;
char *inner_pre_trans_execute;
- char *inner_post_trans_execute;
+ char *inner_post_trans_execute;
switch_sql_queue_manager_t *qm;
char *acl[SOFIA_MAX_ACL];
char *acl_pass_context[SOFIA_MAX_ACL];
@@ -678,7 +678,7 @@ struct sofia_profile {
sofia_paid_type_t paid_type;
uint32_t rtp_digit_delay;
switch_queue_t *event_queue;
- switch_thread_t *thread;
+ switch_thread_t *thread;
switch_core_media_vflag_t vflags;
char *ws_ip;
switch_port_t ws_port;
@@ -851,7 +851,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
sofia_dispatch_event_t *de, tagi_t tags[]);
void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, sofia_dispatch_event_t *de, tagi_t tags[]);
-
+
void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t **sofia_private, sip_t const *sip,
sofia_dispatch_event_t *de,
@@ -868,9 +868,9 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
void launch_sofia_profile_thread(sofia_profile_t *profile);
switch_status_t sofia_presence_chat_send(switch_event_t *message_event);
-
+
/*
- * \brief Sets the "ep_codec_string" channel variable, parsing r_sdp and taing codec_string in consideration
+ * \brief Sets the "ep_codec_string" channel variable, parsing r_sdp and taing codec_string in consideration
* \param channel Current channel
* \param codec_string The profile's codec string or NULL if inexistant
* \param sdp The parsed SDP content
@@ -935,7 +935,7 @@ switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
void sofia_glue_do_xfer_invite(switch_core_session_t *session);
uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
sofia_dispatch_event_t *de,
- sofia_regtype_t regtype, char *key,
+ sofia_regtype_t regtype, char *key,
uint32_t keylen, switch_event_t **v_event, const char *is_nat, sofia_private_t **sofia_private_p, switch_xml_t *user_xml);
extern switch_endpoint_interface_t *sofia_endpoint_interface;
void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip);
@@ -1044,7 +1044,7 @@ void sofia_glue_restart_all_profiles(void);
const char *sofia_state_string(int state);
void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout);
-/*
+/*
* Logging control functions
*/
@@ -1117,6 +1117,7 @@ switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, char **i
void sofia_reg_check_socket(sofia_profile_t *profile, const char *call_id, const char *network_addr, const char *network_ip);
void sofia_reg_close_handles(sofia_profile_t *profile);
+void write_csta_xml_chunk(switch_event_t *event, switch_stream_handle_t stream, const char *csta_event, char *fwd_type);
/* For Emacs:
* Local Variables:
* mode:c
diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
index a7e3818603..c0fb9e720e 100644
--- a/src/mod/endpoints/mod_sofia/sofia.c
+++ b/src/mod/endpoints/mod_sofia/sofia.c
@@ -1,4 +1,4 @@
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II
*
@@ -22,7 +22,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II
* Ken Rice
* Paul D. Tinsley
@@ -91,7 +91,7 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status,
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);
@@ -179,7 +179,7 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
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);
@@ -204,13 +204,13 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
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) {
@@ -223,14 +223,14 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
} 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);
}
@@ -241,16 +241,16 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
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)) {
@@ -258,9 +258,9 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip,
}
free(stream.data);
-
+
}
-
+
if (sip->sip_from) {
char *p = strip_quotes(sip->sip_from->a_display);
@@ -451,7 +451,7 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
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))) {
@@ -523,7 +523,7 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
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))) {
@@ -623,7 +623,7 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
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);
@@ -637,18 +637,18 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
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);
}
@@ -700,16 +700,16 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
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);
@@ -795,15 +795,15 @@ void sofia_send_callee_id(switch_core_session_t *session, const char *name, cons
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";
}
@@ -811,15 +811,15 @@ void sofia_send_callee_id(switch_core_session_t *session, const char *name, cons
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;
}
@@ -872,7 +872,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
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;
}
@@ -887,7 +887,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
check_decode(name, session);
fs++;
}
-
+
if ((val = sofia_glue_get_unknown_header(sip, "X-FS-Lazy-Attended-Transfer"))) {
lazy = switch_true(val);
fs++;
@@ -916,7 +916,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
}
}
}
-
+
if (zstr(number)) {
if ((tmp = switch_channel_get_variable(channel, num_var)) && !zstr(tmp)) {
@@ -956,7 +956,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
}
} 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;
@@ -964,7 +964,7 @@ void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *pro
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);
}
@@ -998,22 +998,22 @@ static void tech_send_ack(nua_handle_t *nh, private_object_t *tech_pvt)
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());
}
@@ -1037,7 +1037,7 @@ static void our_sofia_event_callback(nua_event_t event,
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) {
@@ -1046,7 +1046,7 @@ static void our_sofia_event_callback(nua_event_t event,
return;
}
}
-
+
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) {
if ((gateway = sofia_private->gateway)) {
@@ -1093,7 +1093,7 @@ static void our_sofia_event_callback(nua_event_t event,
}
}
}
-
+
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;
@@ -1151,7 +1151,7 @@ static void our_sofia_event_callback(nua_event_t event,
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);
}
@@ -1193,7 +1193,7 @@ static void our_sofia_event_callback(nua_event_t event,
if (sofia_test_flag(tech_pvt, TFLAG_PASS_ACK)) {
switch_core_session_t *other_session;
-
+
sofia_clear_flag(tech_pvt, TFLAG_PASS_ACK);
@@ -1203,8 +1203,8 @@ static void our_sofia_event_callback(nua_event_t event,
tech_send_ack(other_tech_pvt->nh, other_tech_pvt);
}
switch_core_session_rwunlock(other_session);
- }
-
+ }
+
}
@@ -1320,7 +1320,7 @@ static void our_sofia_event_callback(nua_event_t event,
}
-
+
if (!method) {
method = strdup("INVITE");
}
@@ -1337,11 +1337,11 @@ static void our_sofia_event_callback(nua_event_t event,
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;
@@ -1364,7 +1364,7 @@ static void our_sofia_event_callback(nua_event_t event,
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);
}
@@ -1387,14 +1387,14 @@ static void our_sofia_event_callback(nua_event_t event,
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) {
@@ -1412,7 +1412,7 @@ static void our_sofia_event_callback(nua_event_t event,
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) "
@@ -1420,23 +1420,23 @@ static void our_sofia_event_callback(nua_event_t event,
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);
@@ -1457,7 +1457,7 @@ static void our_sofia_event_callback(nua_event_t event,
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);
@@ -1477,7 +1477,7 @@ static void our_sofia_event_callback(nua_event_t event,
nua_handle_destroy(nh);
}
}
-
+
break;
default:
if (status > 100) {
@@ -1572,7 +1572,7 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run_once(switch_thread_t *thread, void
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;
@@ -1586,14 +1586,14 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run_once(switch_thread_t *thread, void
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;
@@ -1620,10 +1620,10 @@ void sofia_process_dispatch_event(sofia_dispatch_event_t **dep)
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);
@@ -1651,10 +1651,10 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run(switch_thread_t *thread, void *obj
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);
@@ -1676,23 +1676,23 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run(switch_thread_t *thread, void *obj
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;
@@ -1704,10 +1704,10 @@ void sofia_msg_thread_start(int idx)
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);
}
}
@@ -1727,7 +1727,7 @@ void sofia_queue_message(sofia_dispatch_event_t *de)
}
- 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;
@@ -1770,13 +1770,13 @@ void sofia_event_callback(nua_event_t event,
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);
@@ -1785,7 +1785,7 @@ void sofia_event_callback(nua_event_t event,
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;
@@ -1813,18 +1813,18 @@ void sofia_event_callback(nua_event_t event,
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;
@@ -1833,7 +1833,7 @@ void sofia_event_callback(nua_event_t event,
default:
break;
-
+
}
switch_mutex_lock(profile->flag_mutex);
@@ -1894,19 +1894,19 @@ void sofia_event_callback(nua_event_t event,
}
}
}
-
+
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;
}
@@ -1929,26 +1929,26 @@ void sofia_event_callback(nua_event_t event,
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;
@@ -1975,7 +1975,7 @@ void sofia_event_callback(nua_event_t event,
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;
@@ -1985,7 +1985,7 @@ void sofia_event_callback(nua_event_t event,
goto end;
}
}
-
+
sofia_queue_message(de);
end:
@@ -2037,7 +2037,7 @@ void event_handler(switch_event_t *event)
/* 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;
}
@@ -2075,7 +2075,7 @@ void event_handler(switch_event_t *event)
}
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Expired propagated registration for %s@%s->%s\n", from_user, from_host, contact_str);
+ 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);
@@ -2181,7 +2181,7 @@ void event_handler(switch_event_t *event)
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,
@@ -2254,30 +2254,30 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
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);
@@ -2293,17 +2293,17 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
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);
@@ -2326,7 +2326,7 @@ switch_thread_t *launch_sofia_worker_thread(sofia_profile_t *profile)
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;
@@ -2351,7 +2351,7 @@ switch_thread_t *launch_sofia_worker_thread(sofia_profile_t *profile)
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;
@@ -2369,7 +2369,7 @@ switch_thread_t *launch_sofia_worker_thread(sofia_profile_t *profile)
}
}
}
-
+
switch_event_destroy(&xml_params);
}
@@ -2447,7 +2447,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
/* 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 */
@@ -2493,9 +2493,9 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
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),
@@ -2511,7 +2511,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
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"
@@ -2522,7 +2522,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
}
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),
@@ -2554,6 +2554,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
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")),
@@ -2583,7 +2584,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
}
}
-
+
config_sofia_profile_urls(profile);
}
@@ -2687,7 +2688,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
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");
@@ -2756,14 +2757,14 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
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:
@@ -2774,7 +2775,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
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;
@@ -3130,7 +3131,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
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=\"\"",reg_id,str_guid);
- }
+ }
if (zstr(realm)) {
if (zstr(proxy)) {
@@ -3194,7 +3195,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
}
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);
@@ -3238,7 +3239,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
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 {
@@ -3347,9 +3348,9 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
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:
@@ -3414,13 +3415,13 @@ static void config_sofia_profile_urls(sofia_profile_t * profile)
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)) {
@@ -3429,7 +3430,7 @@ static void config_sofia_profile_urls(sofia_profile_t * profile)
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);
}
@@ -3460,7 +3461,7 @@ static void config_sofia_profile_urls(sofia_profile_t * profile)
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,
@@ -3468,7 +3469,7 @@ static void config_sofia_profile_urls(sofia_profile_t * profile)
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 =
@@ -3491,7 +3492,7 @@ static void config_sofia_profile_urls(sofia_profile_t * profile)
"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);
@@ -3501,8 +3502,8 @@ static void config_sofia_profile_urls(sofia_profile_t * profile)
if (profile->tls_public_url) {
profile->tls_public_contact = switch_core_sprintf(profile->pool, "<%s;transport=tls>", profile->tls_public_url);
}
-
-
+
+
}
}
@@ -3517,7 +3518,7 @@ static void sofia_time(su_time_t *tv)
tv->tv_sec = ((uint32_t) (now / 1000000)) + 2208988800UL;
tv->tv_usec = (uint32_t) (now % 1000000);
}
-
+
}
#endif
@@ -3547,7 +3548,7 @@ switch_status_t sofia_init(void)
#ifdef HAVE_SOFIA_STUN
su_log_redirect(stun_log, logger, NULL);
#endif
-
+
return SWITCH_STATUS_SUCCESS;
}
@@ -3609,23 +3610,23 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
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;
}
@@ -3656,7 +3657,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
profile_found = 1;
}
}
-
+
if (!profile_already_started) {
/* Setup the pool */
@@ -3665,13 +3666,13 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
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;
@@ -3719,7 +3720,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
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";
@@ -3769,7 +3770,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
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);
@@ -3923,7 +3924,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} 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);
@@ -4268,7 +4269,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
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.");
}
@@ -4283,7 +4284,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} 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);
@@ -4368,7 +4369,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
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 {
@@ -4670,12 +4671,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
} 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) {
@@ -4735,7 +4736,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
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, ':')) {
@@ -4795,7 +4796,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
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);
}
@@ -4891,7 +4892,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
}
}
}
-
+
} else {
switch_xml_t aliases_tag, alias_tag;
@@ -5057,7 +5058,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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;
}
@@ -5076,9 +5077,9 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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);
@@ -5149,25 +5150,25 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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 [;%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Auto-Fixing Broken SLA [;%s]\n",
sip->sip_from->a_url->url_host, buf);
switch_channel_set_variable_printf(channel, "presence_call_info_full", ";%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);
@@ -5191,7 +5192,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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);
@@ -5217,7 +5218,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
} 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)) {
@@ -5235,7 +5236,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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;
@@ -5317,8 +5318,8 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
}
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);
@@ -5392,7 +5393,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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;
@@ -5401,7 +5402,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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);
@@ -5412,12 +5413,12 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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)) {
@@ -5435,7 +5436,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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) ||
@@ -5453,7 +5454,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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");
@@ -5478,9 +5479,9 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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);
@@ -5553,7 +5554,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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);
}
@@ -5561,9 +5562,9 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
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,"
@@ -5634,7 +5635,7 @@ void *SWITCH_THREAD_FUNC media_on_hold_thread_run(switch_thread_t *thread, void
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)) {
@@ -5672,7 +5673,7 @@ static void mark_transfer_record(switch_core_session_t *session, const char *br_
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";
@@ -5681,7 +5682,7 @@ static void mark_transfer_record(switch_core_session_t *session, const char *br_
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);
@@ -5731,14 +5732,14 @@ static void mark_transfer_record(switch_core_session_t *session, const char *br_
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);
}
-
-
+
+
}
@@ -5846,10 +5847,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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);
-
+
}
}
}
@@ -5886,7 +5887,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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());
}
}
@@ -5972,10 +5973,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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);
@@ -6009,7 +6010,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
ss_state = nua_callstate_ready;
goto state_process;
}
-
+
}
goto done;
case nua_callstate_received:
@@ -6024,7 +6025,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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());
@@ -6093,10 +6094,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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);
@@ -6221,7 +6222,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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;
@@ -6248,7 +6249,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
}
}
-
+
if (!switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
switch_core_media_prepare_codecs(tech_pvt->session, SWITCH_FALSE);
@@ -6292,7 +6293,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
}
- 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");
@@ -6353,7 +6354,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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;
@@ -6363,7 +6364,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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) {
@@ -6408,7 +6409,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
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;
@@ -6455,7 +6456,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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);
@@ -6556,7 +6557,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
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);
@@ -6647,7 +6648,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
if (tech_pvt->sofia_private) {
tech_pvt->sofia_private = NULL;
}
-
+
tech_pvt->nh = NULL;
if (nh) {
@@ -6660,7 +6661,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
}
done:
-
+
if ((enum nua_callstate) ss_state == nua_callstate_ready && channel && session && tech_pvt) {
sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY);
@@ -6700,11 +6701,11 @@ void *SWITCH_THREAD_FUNC nightmare_xfer_thread_run(switch_thread_t *thread, void
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);
@@ -6866,7 +6867,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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);
@@ -7061,7 +7062,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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);
}
@@ -7079,7 +7080,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
}
- 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);
@@ -7087,16 +7088,16 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
}
- 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"),
@@ -7150,7 +7151,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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);
}
@@ -7306,7 +7307,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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);
@@ -7319,14 +7320,14 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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);
@@ -7339,10 +7340,10 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
} 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 {
@@ -7360,7 +7361,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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());
}
}
@@ -7378,7 +7379,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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;
@@ -7386,11 +7387,11 @@ static switch_status_t create_info_event(sip_t const *sip,
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);
@@ -7461,28 +7462,28 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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;
@@ -7492,28 +7493,28 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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;
}
@@ -7532,46 +7533,46 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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);
@@ -7626,7 +7627,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
}
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);
@@ -7653,7 +7654,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
/* 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);
}
}
@@ -7708,7 +7709,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
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);
}
@@ -7752,7 +7753,7 @@ void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
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);
}
@@ -7845,7 +7846,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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)) {
@@ -7881,14 +7882,14 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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.
@@ -7947,7 +7948,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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 {
@@ -8011,7 +8012,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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;
}
@@ -8091,12 +8092,12 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
} 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);
@@ -8146,14 +8147,14 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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;
@@ -8458,7 +8459,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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);
@@ -8499,7 +8500,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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;
@@ -8509,7 +8510,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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");
}
@@ -8529,7 +8530,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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) {
@@ -8538,12 +8539,12 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
"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));
@@ -8551,18 +8552,18 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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 [;%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Auto-Fixing Broken SLA [;%s]\n",
sip->sip_from->a_url->url_host, buf);
switch_channel_set_variable_printf(channel, "presence_call_info_full", ";%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, ";%s", sip->sip_from->a_url->url_host, buf);
}
- }
+ }
}
@@ -8684,7 +8685,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
free(sql);
}
- }
+ }
check_decode(displayname, session);
@@ -8724,7 +8725,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
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");
@@ -8761,34 +8762,34 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
} 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 {
@@ -8798,18 +8799,18 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
} 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);
}
}
@@ -9025,7 +9026,7 @@ void sofia_handle_sip_i_options(int status,
(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());
}
@@ -9045,14 +9046,14 @@ void sofia_handle_sip_i_options(int status,
* 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)
{
diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c
index 197a02df6a..6f3ba5c8a4 100644
--- a/src/mod/endpoints/mod_sofia/sofia_presence.c
+++ b/src/mod/endpoints/mod_sofia/sofia_presence.c
@@ -3658,6 +3658,39 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_snprintf(exp_delta_str, sizeof(exp_delta_str), "%ld", exp_delta);
+ if (!strcmp("as-feature-event", event)) {
+ sip_authorization_t const *authorization = NULL;
+ auth_res_t auth_res = AUTH_FORBIDDEN;
+ char key[128] = "";
+ switch_event_t *v_event = NULL;
+
+
+ if (sip->sip_authorization) {
+ authorization = sip->sip_authorization;
+ } else if (sip->sip_proxy_authorization) {
+ authorization = sip->sip_proxy_authorization;
+ }
+
+ if (authorization) {
+ char network_ip[80];
+ sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), NULL);
+ auth_res = sofia_reg_parse_auth(profile, authorization, sip, de,
+ (char *) sip->sip_request->rq_method_name, key, sizeof(key), network_ip, &v_event, 0,
+ REG_REGISTER, to_user, NULL, NULL, NULL);
+ } else if ( sofia_reg_handle_register(nua, profile, nh, sip, de, REG_REGISTER, key, sizeof(key), &v_event, NULL, NULL, NULL)) {
+ if (v_event) {
+ switch_event_destroy(&v_event);
+ }
+
+ goto end;
+ }
+
+ if ((auth_res != AUTH_OK && auth_res != AUTH_RENEWED)) {
+ nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
+ goto end;
+ }
+ }
+
if (to_user && strchr(to_user, '+')) {
char *h;
if ((proto = (d_user = strdup(to_user)))) {
@@ -3991,7 +4024,24 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_safe_free(sstr);
- if (!strcasecmp(event, "message-summary")) {
+ if (!strcasecmp(event, "as-feature-event")) {
+ switch_event_t *event;
+ char sip_cseq[40] = "";
+ switch_snprintf(sip_cseq, sizeof(sip_cseq), "%d", sip->sip_cseq->cs_seq);
+ switch_event_create(&event, SWITCH_EVENT_PHONE_FEATURE_SUBSCRIBE);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "user", from_user);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "host", from_host);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "contact", contact_str);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-id", call_id);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "expires", exp_delta_str);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "cseq", sip_cseq);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "profile_name", profile->name);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hostname", mod_sofia_globals.hostname);
+ if (sip->sip_payload) {
+ switch_event_add_body(event, "%s", sip->sip_payload->pl_data);
+ }
+ switch_event_fire(&event);
+ } else if (!strcasecmp(event, "message-summary")) {
if ((sql = switch_mprintf("select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name,network_ip"
" from sip_subscriptions where hostname='%q' and profile_name='%q' and "
diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c
index 3a3e3e1d0a..d0f7dec837 100644
--- a/src/mod/endpoints/mod_sofia/sofia_reg.c
+++ b/src/mod/endpoints/mod_sofia/sofia_reg.c
@@ -1240,10 +1240,12 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
to_host = to->a_url->url_host;
}
- if (!to_user)
+ if (!to_user) {
to_user = from_user;
- if (!to_host)
+ }
+ if (!to_host) {
to_host = from_host;
+ }
if (!to_user || !to_host) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete header in REGISTER request from %s:%d\n",
diff --git a/src/switch_event.c b/src/switch_event.c
index 20262677e1..b3ef5f0cc2 100644
--- a/src/switch_event.c
+++ b/src/switch_event.c
@@ -1,4 +1,4 @@
-/*
+/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2012, Anthony Minessale II
*
@@ -22,11 +22,12 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
- *
+ *
* Anthony Minessale II
* Michael Jerris
* Paul D. Tinsley
* William King
+ * Raymond Chandler
*
* switch_event.c -- Event System
*
@@ -153,6 +154,8 @@ static char *EVENT_NAMES[] = {
"MESSAGE",
"PRESENCE_IN",
"NOTIFY_IN",
+ "PHONE_FEATURE",
+ "PHONE_FEATURE_SUBSCRIBE",
"PRESENCE_OUT",
"PRESENCE_PROBE",
"MESSAGE_WAITING",
@@ -263,7 +266,7 @@ static void *SWITCH_THREAD_FUNC switch_event_dispatch_thread(switch_thread_t *th
EVENT_DISPATCH_QUEUE_RUNNING[my_id] = 1;
switch_mutex_unlock(EVENT_QUEUE_MUTEX);
-
+
for (;;) {
void *pop = NULL;
@@ -308,11 +311,11 @@ static switch_status_t switch_event_queue_dispatch_event(switch_event_t **eventp
if (!SYSTEM_RUNNING) {
return SWITCH_STATUS_FALSE;
}
-
+
while (event) {
int launch = 0;
-
- switch_mutex_lock(EVENT_QUEUE_MUTEX);
+
+ switch_mutex_lock(EVENT_QUEUE_MUTEX);
if (!PENDING && switch_queue_size(EVENT_DISPATCH_QUEUE) > (unsigned int)(DISPATCH_QUEUE_LEN * DISPATCH_THREAD_COUNT)) {
if (SOFT_MAX_DISPATCH + 1 > MAX_DISPATCH) {
@@ -322,7 +325,7 @@ static switch_status_t switch_event_queue_dispatch_event(switch_event_t **eventp
}
switch_mutex_unlock(EVENT_QUEUE_MUTEX);
-
+
if (launch) {
if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
switch_event_launch_dispatch_threads(SOFT_MAX_DISPATCH + 1);
@@ -336,9 +339,9 @@ static switch_status_t switch_event_queue_dispatch_event(switch_event_t **eventp
*eventp = NULL;
switch_queue_push(EVENT_DISPATCH_QUEUE, event);
event = NULL;
-
+
}
-
+
return SWITCH_STATUS_SUCCESS;
}
@@ -579,12 +582,12 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool)
{
//switch_threadattr_t *thd_attr;
- /*
+ /*
This statement doesn't do anything commenting it out for now.
switch_assert(switch_arraylen(EVENT_NAMES) == SWITCH_EVENT_ALL + 1);
*/
-
+
/* don't need any more dispatch threads than we have CPU's*/
MAX_DISPATCH = (switch_core_cpu_count() / 2) + 1;
if (MAX_DISPATCH < 2) {
@@ -751,7 +754,7 @@ SWITCH_DECLARE(char *) switch_event_get_header_idx(switch_event_t *event, const
}
}
- return hp->value;
+ return hp->value;
} else if (!strcmp(header_name, "_body")) {
return event->body;
}
@@ -802,7 +805,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_del_header_val(switch_event_t *even
}
FREE(hp->value);
-
+
memset(hp, 0, sizeof(*hp));
#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, hp) != SWITCH_STATUS_SUCCESS) {
@@ -834,7 +837,7 @@ static switch_event_header_t *new_header(const char *header_name)
switch_assert(header);
#ifdef SWITCH_EVENT_RECYCLE
}
-#endif
+#endif
memset(header, 0, sizeof(*header));
header->name = DUP(header_name);
@@ -870,15 +873,15 @@ SWITCH_DECLARE(int) switch_event_add_array(switch_event_t *event, const char *va
}
data = strdup(val + 7);
-
+
len = (sizeof(char *) * max) + 1;
switch_assert(len);
array = malloc(len);
memset(array, 0, len);
-
+
switch_separate_string_string(data, "|:", array, max);
-
+
for(i = 0; i < max; i++) {
switch_event_add_header_string(event, SWITCH_STACK_PUSH, var, array[i]);
}
@@ -914,20 +917,20 @@ static switch_status_t switch_event_base_add_header(switch_event_t *event, switc
}
if (index_ptr || (stack & SWITCH_STACK_PUSH) || (stack & SWITCH_STACK_UNSHIFT)) {
-
+
if (!(header = switch_event_get_header_ptr(event, header_name)) && index_ptr) {
-
+
header = new_header(header_name);
-
+
if (switch_test_flag(event, EF_UNIQ_HEADERS)) {
switch_event_del_header(event, header_name);
}
fly++;
}
-
+
if (header || (header = switch_event_get_header_ptr(event, header_name))) {
-
+
if (index_ptr) {
if (index > -1 && index <= 4000) {
if (index < header->idx) {
@@ -936,7 +939,7 @@ static switch_status_t switch_event_base_add_header(switch_event_t *event, switc
} else {
int i;
char **m;
-
+
m = realloc(header->array, sizeof(char *) * (index + 1));
switch_assert(m);
header->array = m;
@@ -986,7 +989,7 @@ static switch_status_t switch_event_base_add_header(switch_event_t *event, switc
header = new_header(header_name);
}
-
+
if ((stack & SWITCH_STACK_PUSH) || (stack & SWITCH_STACK_UNSHIFT)) {
char **m = NULL;
switch_size_t len = 0;
@@ -1004,7 +1007,7 @@ static switch_status_t switch_event_base_add_header(switch_event_t *event, switc
}
i = header->idx + 1;
- m = realloc(header->array, sizeof(char *) * i);
+ m = realloc(header->array, sizeof(char *) * i);
switch_assert(m);
if ((stack & SWITCH_STACK_PUSH)) {
@@ -1016,7 +1019,7 @@ static switch_status_t switch_event_base_add_header(switch_event_t *event, switc
m[0] = data;
}
- header->idx++;
+ header->idx++;
header->array = m;
redraw:
@@ -1118,7 +1121,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_set_body(switch_event_t *event, con
if (body) {
event->body = DUP(body);
}
-
+
return SWITCH_STATUS_SUCCESS;
}
@@ -1170,7 +1173,7 @@ SWITCH_DECLARE(void) switch_event_destroy(switch_event_t **event)
FREE(this->name);
FREE(this->value);
-
+
#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, this) != SWITCH_STATUS_SUCCESS) {
@@ -1200,13 +1203,13 @@ SWITCH_DECLARE(void) switch_event_destroy(switch_event_t **event)
SWITCH_DECLARE(void) switch_event_merge(switch_event_t *event, switch_event_t *tomerge)
{
switch_event_header_t *hp;
-
+
switch_assert(tomerge && event);
for (hp = tomerge->headers; hp; hp = hp->next) {
if (hp->idx) {
int i;
-
+
for(i = 0; i < hp->idx; i++) {
switch_event_add_header_string(event, SWITCH_STACK_PUSH, hp->name, hp->array[i]);
}
@@ -1232,7 +1235,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_
if (todup->subclass_name && !strcmp(hp->name, "Event-Subclass")) {
continue;
}
-
+
if (hp->idx) {
int i;
for (i = 0; i < hp->idx; i++) {
@@ -1270,11 +1273,11 @@ SWITCH_DECLARE(switch_status_t) switch_event_dup_reply(switch_event_t **event, s
for (hp = todup->headers; hp; hp = hp->next) {
char *name = hp->name, *value = hp->value;
-
+
if (todup->subclass_name && !strcmp(hp->name, "Event-Subclass")) {
continue;
}
-
+
if (!strncasecmp(hp->name, "from_", 5)) {
p = hp->name + 5;
switch_snprintf(hname, sizeof(hname), "to_%s", p);
@@ -1288,7 +1291,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_dup_reply(switch_event_t **event, s
} else if (!strcasecmp(name, "from")) {
name = "to";
}
-
+
if (hp->idx) {
int i;
for (i = 0; i < hp->idx; i++) {
@@ -1379,13 +1382,13 @@ SWITCH_DECLARE(switch_status_t) switch_event_binary_serialize(switch_event_t *ev
tn = tpl_map(SWITCH_SERIALIZED_EVENT_MAP, &e, &sh);
tpl_pack(tn, 0);
-
+
for (eh = event->headers; eh; eh = eh->next) {
if (eh->idx) continue; // no arrays yet
-
+
sh.name = eh->name;
sh.value = eh->value;
-
+
tpl_pack(tn, 1);
}
@@ -1427,7 +1430,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
/*
* grab enough memory to store 3x the string (url encode takes one char and turns it into %XX)
* so we could end up with a string that is 3 times the originals length, unlikely but rather
- * be safe than destroy the string, also add one for the null. And try to be smart about using
+ * be safe than destroy the string, also add one for the null. And try to be smart about using
* the memory, allocate and only reallocate if we need more. This avoids an alloc, free CPU
* destroying loop.
*/
@@ -1522,11 +1525,11 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_array_pair(switch_event_t **
char *name, *val;
switch_event_create(event, SWITCH_EVENT_CLONE);
-
+
for (r = 0; r < len; r++) {
val = switch_str_nil(vals[r]);
name = names[r];
-
+
if (zstr(name)) {
name = "Unknown";
}
@@ -1535,7 +1538,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_array_pair(switch_event_t **
}
return SWITCH_STATUS_SUCCESS;
-
+
}
SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a, char b, char c, switch_event_t **event, char **new_data, switch_bool_t dup)
@@ -1555,17 +1558,17 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
}
end = switch_find_end_paren(vdata, a, b);
-
+
check_a = end;
-
+
while (check_a && (check_b = switch_strchr_strict(check_a, a, " "))) {
if ((check_b = switch_find_end_paren(check_b, a, b))) {
check_a = check_b;
}
}
-
+
if (check_a) end = check_a;
-
+
if (end) {
next = end;
vdata++;
@@ -1576,12 +1579,12 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
}
return SWITCH_STATUS_FALSE;
}
-
+
if (!e) {
switch_event_create_plain(&e, SWITCH_EVENT_CHANNEL_DATA);
}
-
+
for (;;) {
if (next) {
char *pnext;
@@ -1595,7 +1598,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
vnext = switch_find_end_paren(next, a, b);
next = NULL;
}
-
+
if (vdata) {
if (*vdata == '^' && *(vdata + 1) == '^') {
@@ -1603,7 +1606,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
c = *vdata++;
}
}
-
+
if ((var_count = switch_separate_string(vdata, c, var_array, (sizeof(var_array) / sizeof(var_array[0]))))) {
int x = 0;
for (x = 0; x < var_count; x++) {
@@ -1635,7 +1638,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
} else {
*new_data = end;
}
-
+
return SWITCH_STATUS_SUCCESS;
}
@@ -1687,7 +1690,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_json(switch_event_t **event,
}
}
}
-
+
cJSON_Delete(cj);
*event = new_event;
return SWITCH_STATUS_SUCCESS;
@@ -1699,7 +1702,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize_json(switch_event_t *even
cJSON *cj;
*str = NULL;
-
+
cj = cJSON_CreateObject();
for (hp = event->headers; hp; hp = hp->next) {
@@ -1710,9 +1713,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize_json(switch_event_t *even
for(i = 0; i < hp->idx; i++) {
cJSON_AddItemToArray(a, cJSON_CreateString(hp->array[i]));
}
-
+
cJSON_AddItemToObject(cj, hp->name, a);
-
+
} else {
cJSON_AddItemToObject(cj, hp->name, cJSON_CreateString(hp->value));
}
@@ -1730,7 +1733,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize_json(switch_event_t *even
*str = cJSON_Print(cj);
cJSON_Delete(cj);
-
+
return SWITCH_STATUS_SUCCESS;
}
@@ -1901,7 +1904,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, swit
if (node) {
*node = NULL;
}
-
+
if (subclass_name) {
if (!(subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) {
switch_event_reserve_subclass_detailed(id, subclass_name);
@@ -2066,9 +2069,9 @@ char *dp;\
olen += (len + l + block);\
cpos = c - data;\
if ((dp = realloc(data, olen))) {\
- data = dp;\
- c = data + cpos;\
- memset(c, 0, olen - cpos);\
+ data = dp;\
+ c = data + cpos;\
+ memset(c, 0, olen - cpos);\
}} \
SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur)
@@ -2223,7 +2226,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
int ooffset = 0;
char *ptr;
int idx = -1;
-
+
if ((expanded = switch_event_expand_headers_check(event, (char *) vname, var_list, api_list, recur+1)) == vname) {
expanded = NULL;
} else {
@@ -2266,7 +2269,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
switch_assert(cloned_sub_val);
sub_val = cloned_sub_val;
}
-
+
if (offset >= 0) {
sub_val += offset;
} else if ((size_t) abs(offset) <= strlen(sub_val)) {
@@ -2278,7 +2281,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
*ptr = '\0';
}
}
-
+
switch_safe_free(expanded);
} else {
@@ -2477,7 +2480,7 @@ SWITCH_DECLARE(int) switch_event_check_permission_list(switch_event_t *list, con
r = default_allow;
}
- return r;
+ return r;
}
SWITCH_DECLARE(void) switch_event_add_presence_data_cols(switch_channel_t *channel, switch_event_t *event, const char *prefix)
@@ -2485,7 +2488,7 @@ SWITCH_DECLARE(void) switch_event_add_presence_data_cols(switch_channel_t *chann
const char *data;
if (!prefix) prefix = "";
-
+
if ((data = switch_channel_get_variable(channel, "presence_data_cols"))) {
char *cols[128] = { 0 };
char header_name[128] = "";
@@ -2493,17 +2496,17 @@ SWITCH_DECLARE(void) switch_event_add_presence_data_cols(switch_channel_t *chann
char *data_copy = NULL;
data_copy = strdup(data);
-
+
col_count = switch_split(data_copy, ':', cols);
-
+
for (i = 0; i < col_count; i++) {
const char *val = NULL;
switch_snprintf(header_name, sizeof(header_name), "%s%s", prefix, cols[i]);
-
+
val = switch_channel_get_variable(channel, cols[i]);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, val);
}
-
+
switch_safe_free(data_copy);
}