cid = generate_pai_str(tech_pvt);
- if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) && tech_pvt->mparams.early_sdp) {
+ if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) && tech_pvt->mparams.early_sdp && tech_pvt->mparams.local_sdp_str) {
char *a, *b;
/* start at the s= line to avoid some devices who update the o= between messages */
rframe->m = 1;
*frame = rframe;
- if (msrp_h_content_type && !strcasecmp(msrp_h_content_type, "message/cpim")) {
+ if (!strcasecmp(msrp_h_content_type, "message/cpim")) {
char *stripped_text = switch_html_strip((char *)rframe->data);
memcpy(rframe->data, stripped_text, strlen(stripped_text)+1);
rframe->datalen = strlen(stripped_text);
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_status_t status = SWITCH_STATUS_SUCCESS;
+ switch_assert(tech_pvt != NULL);
+
if (msg->message_id == SWITCH_MESSAGE_INDICATE_SIGNAL_DATA) {
sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) msg->pointer_arg;
switch_mutex_lock(tech_pvt->sofia_mutex);
}
- if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
+ if (switch_channel_down(channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
status = SWITCH_STATUS_FALSE;
goto end;
}
/* ones that do need to lock sofia mutex */
switch_mutex_lock(tech_pvt->sofia_mutex);
- if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
+ if (switch_channel_down(channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
status = SWITCH_STATUS_FALSE;
goto end_lock;
}
if ( ver_str ) {
char *argv[4] = { 0 };
char *dotted = strdup( ver_str + 1 );
- if ( dotted ) {
- switch_separate_string(dotted, '.', argv, (sizeof(argv) / sizeof(argv[0])));
- if ( argv[0] && argv[1] && argv[2] ) {
- version = ( atoi(argv[0]) * 10000 ) + ( atoi(argv[1]) * 100 ) + atoi(argv[2]);
- }
+ switch_assert(dotted);
+ switch_separate_string(dotted, '.', argv, (sizeof(argv) / sizeof(argv[0])));
+ if ( argv[0] && argv[1] && argv[2] ) {
+ version = ( atoi(argv[0]) * 10000 ) + ( atoi(argv[1]) * 100 ) + atoi(argv[2]);
}
switch_safe_free( dotted );
}
end:
- if (switch_channel_down(channel) || !tech_pvt || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
+ if (switch_channel_down(channel) || sofia_test_flag(tech_pvt, TFLAG_BYE)) {
status = SWITCH_STATUS_FALSE;
}
cb.profile = profile;
cb.stream = stream;
- if (!sql && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
+ if (argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
"network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host,ping_status,ping_time"
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
stream->write_function(stream, "</gateways>\n");
-
- } else if (argc == 1 && !strcasecmp(argv[0], "profile")) {
} else if (!strcasecmp(argv[0], "gateway")) {
if ((gp = sofia_reg_find_gateway(argv[1]))) {
switch_assert(gp->state < REG_STATE_LAST);
cb.profile = profile;
cb.stream = stream;
- if (!sql && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
+ if (argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
"rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
stream->write_function(stream, "-ERR Unknown command!\n");
done:
- if (profile) {
- sofia_glue_release_profile(profile);
- }
+ sofia_glue_release_profile(profile);
return SWITCH_STATUS_SUCCESS;
}
profile_name = domain;
}
- if (user && profile_name) {
+ if (profile_name) {
char *sql;
if (!(profile = sofia_glue_find_profile(profile_name))) {
profile_name = domain;
}
- if (user && profile_name) {
+ if (profile_name) {
char *sql;
if (!(profile = sofia_glue_find_profile(profile_name))) {
domain = dup_domain;
}
- if (!user) goto end;
-
if (zstr(profile_name) || strcmp(profile_name, "*") || zstr(domain)) {
if (!zstr(profile_name)) {
profile = sofia_glue_find_profile(profile_name);
reply = (char *) mystream.data;
- end:
-
if (zstr(reply)) {
reply = "error/user_not_registered";
} else if (end_of(reply) == ',') {
*concat++ = '\0';
}
} else {
- if ((concat = strchr(user, '/'))) {
+ if (user && (concat = strchr(user, '/'))) {
*concat++ = '\0';
}
}
goto error;
}
- if (profile && sofia_test_pflag(profile, PFLAG_STANDBY)) {
+ if (sofia_test_pflag(profile, PFLAG_STANDBY)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "System Paused\n");
cause = SWITCH_CAUSE_SYSTEM_SHUTDOWN;
goto error;
nua_notify(nh,
NUTAG_NEWSUB(1), TAG_IF(sip_sub_st, SIPTAG_SUBSCRIPTION_STATE_STR(sip_sub_st)),
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),
- SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
+ SIPTAG_EVENT_STR(es), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_END());
return;
}
- if (to_uri && from_uri && ct && es) {
+ if (to_uri && from_uri) {
sofia_destination_t *dst = NULL;
nua_handle_t *nh;
char *route_uri = NULL;
nua_notify(nh,
NUTAG_NEWSUB(1), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
- SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
+ SIPTAG_EVENT_STR(es), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_END());
} else {
if (local_user_full) {
local_dup = strdup(local_user_full);
+ switch_assert(local_dup);
local_user = local_dup;
if ((local_host = strchr(local_user, '@'))) {
*local_host++ = '\0';
}
- if (!local_user || !local_host || !sofia_reg_find_reg_url(profile, local_user, local_host, buf, sizeof(buf))) {
+ if (!local_host || !sofia_reg_find_reg_url(profile, local_user, local_host, buf, sizeof(buf))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find local user\n");
goto done;
}
nua_handle_unref(nh);
}
- if (profile) {
- sofia_glue_release_profile(profile);
- }
+ sofia_glue_release_profile(profile);
done:
ringcount = switch_event_get_header(event, "ringCount");
}
- if (fwdtype) {
- stream.write_function(&stream, " <forwardingType>%s</forwardingType>\n", fwdtype);
- }
+ stream.write_function(&stream, " <forwardingType>%s</forwardingType>\n", fwdtype);
if (fwdstatus) {
stream.write_function(&stream, " <forwardStatus>%s</forwardStatus>\n", fwdstatus);
}
if (end_of(t) == '"') {
r = strdup(t);
+ switch_assert(r);
end_of(r) = '\0';
}
}
int status_val = 0;
if ((p = strchr(sip->sip_payload->pl_data, ' '))) {
p++;
- if (p) {
- status_val = atoi(p);
- }
+ status_val = atoi(p);
}
if (!status_val || status_val >= 200) {
switch_channel_set_variable(channel, "sip_refer_reply", sip->sip_payload->pl_data);
switch_snprintf(st, sizeof(st), "sip:%d", status);
switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
- if (phrase) {
- switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
- }
+ switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
switch_snprintf(st, sizeof(st), "%d", cause);
switch_channel_set_variable(channel, "sip_term_cause", st);
}
if (!zstr(passerted->paid_display)) {
dup = strdup(passerted->paid_display);
+ switch_assert(dup);
if (*dup == '"') {
name = dup + 1;
} else {
}
if (!zstr(rpid->rpid_display)) {
dup = strdup(rpid->rpid_display);
+ switch_assert(dup);
if (*dup == '"') {
name = dup + 1;
} else {
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Expired propagated registration for %s@%s->%s\n", from_user, from_host, contact_str);
- if (profile) {
- sofia_glue_release_profile(profile);
- }
+ sofia_glue_release_profile(profile);
} else if ((subclass = switch_event_get_header_nil(event, "orig-event-subclass")) && !strcasecmp(subclass, MY_EVENT_REGISTER)) {
char *from_user = switch_event_get_header_nil(event, "orig-from-user");
char *from_host = switch_event_get_header_nil(event, "orig-from-host");
}
- if (profile) {
- sofia_glue_release_profile(profile);
- }
+ sofia_glue_release_profile(profile);
end:
switch_safe_free(fixed_contact_str);
switch_safe_free(dup_mwi_account);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Propagating sip_user_state for %s@%s. Ping-Status: %s\n", from_user, from_host, ping_status);
}
- if (profile) {
- sofia_glue_release_profile(profile);
- }
+ sofia_glue_release_profile(profile);
}
}
}
done:
- if (profile) sofia_glue_release_profile(profile);
+ sofia_glue_release_profile(profile);
if (xml) switch_xml_free(xml);
switch_event_destroy(¶ms);
profile->record_template = switch_core_strdup(profile->pool, val);
} else if (!strcasecmp(var, "record-path")) {
profile->record_path = switch_core_strdup(profile->pool, val);
- } else if ((!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media"))) {
+ } else if (!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media")) {
if (switch_true(val)) {
sofia_set_flag(profile, TFLAG_INB_NOMEDIA);
} else {
if ((p = strrchr(profile->ws_ip, ':'))) {
*p++ = '\0';
- if (p && (tmp = atol(p)) && tmp > 0) {
+ if ((tmp = atol(p)) && tmp > 0) {
profile->ws_port = (switch_port_t) tmp;
}
}
if ((p = strrchr(profile->wss_ip, ':'))) {
*p++ = '\0';
- if (p && (tmp = atol(p)) && tmp > 0) {
+ if ((tmp = atol(p)) && tmp > 0) {
profile->wss_port = (switch_port_t) tmp;
}
}
if ((switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_PROFILE_START) == SWITCH_STATUS_SUCCESS)) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "module_name", "mod_sofia");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_name", profile->name);
- if (profile) {
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_uri", profile->url);
- }
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile_uri", profile->url);
switch_event_fire(&s_event);
}
} else {
state = "progressing";
}
- if (sip &&
- sip->sip_from && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
+ if (sip->sip_from && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
sip->sip_to && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host) {
sql =
switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 and hostname='%q' and event='call-info' and "
}
- if (channel && sip && (status == 300 || status == 301 || status == 302 || status == 305) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
+ if (channel && (status == 300 || status == 301 || status == 302 || status == 305) && switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
sip_contact_t *p_contact = sip->sip_contact;
int i = 0;
char var_name[80];
free(invite_contact);
i++;
}
- if (home) {
- su_home_unref(home);
- home = NULL;
- }
+ su_home_unref(home);
+ home = NULL;
switch_snprintf(var_name, sizeof(var_name), "sip:%d", status);
switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, var_name);
switch_channel_hangup(channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
free(invite_contact);
}
- if (home) {
- su_home_unref(home);
- home = NULL;
- }
+ su_home_unref(home);
+ home = NULL;
free(stream.data);
tech_pvt->redirected = switch_core_session_strdup(session, invite_contact);
free(invite_contact);
-
- if (home) {
- su_home_unref(home);
- home = NULL;
- }
+ su_home_unref(home);
+ home = NULL;
}
}
}
if (r_sdp) {
- if (switch_channel_test_flag(channel, CF_PROXY_MODE) && r_sdp) {
+ if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
char ibuf[35] = "", pbuf[35] = "";
const char *ptr;
uint8_t match = 0;
int is_ok = 1;
+ if (!tech_pvt) goto done;
+
if (tech_pvt->mparams.num_codecs) {
match = sofia_media_negotiate_sdp(session, r_sdp, SDP_TYPE_RESPONSE);
}
}
}
}
- if (b_session) {
- switch_core_session_rwunlock(b_session);
- }
+ switch_core_session_rwunlock(b_session);
}
nua_handle_unref(bnh);
} else { /* the other channel is on a different box, we have to go find them */
"REFER from %s replaces %s (%s@%s) with %s on another server\n",
switch_core_session_get_uuid(session), rep, exten, (char *) refer_to->r_url->url_host, br_a);
- if (refer_to && refer_to->r_url->url_port) {
+ if (refer_to->r_url->url_port) {
port = refer_to->r_url->url_port;
}
return SWITCH_STATUS_FALSE;
}
- if (sip && sip->sip_content_type) {
+ if (sip->sip_content_type) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "SIP-Content-Type", sip->sip_content_type->c_type);
}
other_tech_pvt = (private_object_t *) switch_core_session_get_private(other_session);
- if (sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
+ if (sip && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
ct = sip->sip_content_type->c_type;
}
other_tech_pvt = (private_object_t *) switch_core_session_get_private(other_session);
- if (sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
+ if (sip && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype) {
ct = sip->sip_content_type->c_type;
}
- if (!strncasecmp(sip->sip_content_type->c_type, "application", 11) && !strcasecmp(sip->sip_content_type->c_subtype, "media_control+xml")) {
+ if (sip && sip->sip_content_type->c_type && !strncasecmp(sip->sip_content_type->c_type, "application", 11) && !strcasecmp(sip->sip_content_type->c_subtype, "media_control+xml")) {
if (switch_channel_test_flag(channel, CF_VIDEO)) {
switch_core_media_gen_key_frame(session);
switch_channel_set_flag(channel, CF_VIDEO_REFRESH_REQ);
switch_stream_handle_t stream = { 0 };
switch_status_t status;
+ switch_assert(cmd);
SWITCH_STANDARD_STREAM(stream);
switch_assert(stream.data);
tech_pvt = switch_core_session_get_private(session);
- if (sip->sip_payload && sip->sip_payload->pl_data) {
+ if (sip && sip->sip_payload && sip->sip_payload->pl_data) {
tech_pvt->mparams.last_sdp_str = switch_core_session_strdup(session, sip->sip_payload->pl_data);
}
}
switch_core_recovery_track(session);
}
- if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
+ if (profile && sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
if (channel && sip->sip_call_info) {
char *p;
if ((call_info = sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_call_info))) {
switch_channel_get_name(tech_pvt->channel), network_ip, network_port, switch_version_full_human());
- if (sip && sip->sip_via && sip->sip_via->v_protocol && switch_stristr("sip/2.0/ws", sip->sip_via->v_protocol)) {
+ if (sip->sip_via && sip->sip_via->v_protocol && switch_stristr("sip/2.0/ws", sip->sip_via->v_protocol)) {
is_nat = "websockets";
}
sip->sip_user_agent->g_string &&
(!strncasecmp(sip->sip_user_agent->g_string, "Polycom", 7) || !strncasecmp(sip->sip_user_agent->g_string, "KIRK Wireless Server", 20)))
) {
- if (sip && sip->sip_via) {
+ if (sip->sip_via) {
const char *port = sip->sip_via->v_port;
const char *host = sip->sip_via->v_host;
char *last_acl = NULL;
const char *contact_host = NULL;
- if (sip) {
- if (sip->sip_via && sip->sip_via->v_host) {
- contact_host = sip->sip_via->v_host;
- } else if (sip->sip_contact) {
- contact_host = sip->sip_contact->m_url->url_host;
- }
+ if (sip->sip_via && sip->sip_via->v_host) {
+ contact_host = sip->sip_via->v_host;
+ } else if (sip->sip_contact) {
+ contact_host = sip->sip_contact->m_url->url_host;
}
if (!zstr(contact_host)) {
calling_myself++;
}
- if (sip && sip->sip_from) {
+ if (sip->sip_from) {
user = switch_core_session_sprintf(session, "%s@%s", sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host);
blind_result = sofia_locate_user(user, session, sip, &x_user);
}
}
}
- if (sip->sip_via || sip->sip_contact) {
+ if (sip->sip_via) {
char tmp[35] = "";
const char *ipv6 = strchr(tech_pvt->mparams.remote_ip, ':');
switch_channel_set_variable(channel, "sip_received_ip", tech_pvt->mparams.remote_ip);
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->mparams.remote_port);
switch_channel_set_variable(channel, "sip_received_port", tmp);
- }
-
- if (sip->sip_via) {
switch_channel_set_variable(channel, "sip_via_protocol", sofia_glue_transport2str(sofia_glue_via2transport(sip->sip_via)));
}
nua_set_hparams(nh, SIPTAG_VIA_STR(tech_pvt->user_via), TAG_END());
}
- if (sip->sip_contact) {
- url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
- }
+ url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
if (sip->sip_referred_by) {
referred_by_user = sip->sip_referred_by->b_url->url_user;
char *sql;
char *state = "progressing";
- if (sip &&
- sip->sip_from && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
+ if (sip->sip_from && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
sip->sip_to && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host) {
sql =
switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 and hostname='%q' and event='call-info' and "
switch_channel_set_variable(channel, "sip_gateway", gateway->name);
if (!zstr(extension)) {
- if (!strcasecmp(extension, "auto_to_user")) {
+ if (!strcasecmp(extension, "auto_to_user") && sip->sip_to) {
destination_number = sip->sip_to->a_url->url_user;
} else if (!strcasecmp(extension, "auto")) {
- if (gw_name) {
+ if (gw_name && sip->sip_to) {
destination_number = sip->sip_to->a_url->url_user;
}
} else {
destination_number = switch_core_session_strdup(session, extension);
}
- } else if (!gw_param_name) {
+ } else if (!gw_param_name && sip->sip_to) {
destination_number = sip->sip_to->a_url->url_user;
}
}
}
- if (sip && sip->sip_replaces) {
+ if (sip->sip_replaces) {
msg_common_t *rp_common = sip->sip_replaces->rp_common;
switch_channel_set_variable(channel, "sip_replaces_call_id", sip->sip_replaces->rp_call_id);
- if (rp_common && rp_common->h_class->hc_params) {
+ if (rp_common->h_class->hc_params) {
int i, n;
msg_param_t const *params = * (msg_param_t const **) ((char *)rp_common + rp_common->h_class->hc_params);
for (i = 0; params[i]; i++) {
}
}
nua_handle_unref(bnh);
- } else if (sip && sip->sip_replaces && sip->sip_replaces->rp_call_id) {
+ } else if (sip->sip_replaces && sip->sip_replaces->rp_call_id) {
switch_core_session_t *b_session = NULL;
if ((b_session = switch_core_session_locate((char*) sip->sip_replaces->rp_call_id))) {
switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
if (sip->sip_from) {
from = sip->sip_from->a_url;
}
- if (sip->sip_contact) {
- contact = sip->sip_contact->m_url;
- }
+ contact = sip->sip_contact->m_url;
if (sip->sip_user_agent) {
user_agent = switch_str_nil(sip->sip_user_agent->g_string);
from_tag = switch_str_nil(sip->sip_from->a_tag);
}
- if (contact) {
- contact_user = switch_str_nil(contact->url_user);
- contact_host = switch_str_nil(contact->url_host);
- }
+ contact_user = switch_str_nil(contact->url_user);
+ contact_host = switch_str_nil(contact->url_host);
if (profile->pres_type) {
const char *presence_data = switch_channel_get_variable(channel, "presence_data");
char *p = NULL;
time_t now;
- if (sip->sip_contact) {
- full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
- }
+ full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
if (call_info_str && switch_stristr("appearance", call_info_str)) {
switch_channel_set_variable(channel, "presence_call_info_full", call_info_str);
switch_caller_profile_t *orig_cp, *cp;
//const char *sent_name, *sent_number;
orig_cp = switch_channel_get_caller_profile(b_channel);
- tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_name);
- tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_number);
-
- if (!call_info) {
- tech_pvt->caller_profile->caller_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_name);
- tech_pvt->caller_profile->caller_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
- }
if (orig_cp) {
+ tech_pvt->caller_profile->callee_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_name);
+ tech_pvt->caller_profile->callee_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->callee_id_number);
+
+ if (!call_info) {
+ tech_pvt->caller_profile->caller_id_name = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_name);
+ tech_pvt->caller_profile->caller_id_number = switch_core_strdup(tech_pvt->caller_profile->pool, orig_cp->caller_id_number);
+ }
+
cp = switch_caller_profile_dup(tech_pvt->caller_profile->pool, orig_cp);
switch_channel_set_originator_caller_profile(channel, cp);
}
switch_event_t *event = NULL;
if (switch_channel_var_true(channel, "sip_replaces_a-leg")) {
switch_channel_mark_hold(b_channel, SWITCH_FALSE);
- tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", sip->sip_replaces->rp_call_id);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s picked up on a-leg\n", sip->sip_replaces->rp_call_id);
- if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
- && sip && sip->sip_call_id
- && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
- switch_channel_event_set_data(b_channel, event);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
- switch_event_fire(&event);
+ if (sip) {
+ tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", sip->sip_replaces->rp_call_id);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s picked up on a-leg\n", sip->sip_replaces->rp_call_id);
+ if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
+ && sip->sip_call_id
+ && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(b_channel, event);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
+ switch_event_fire(&event);
+ }
}
} else {
- if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-For"))) {
- switch_channel_set_variable(b_channel, "transfer_refer_for", nightmare_xfer_uuid);
- }
- if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-From"))) {
- switch_channel_set_variable(b_channel, "transfer_refer_from", nightmare_xfer_uuid);
+ if (sip) {
+ if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-For"))) {
+ switch_channel_set_variable(b_channel, "transfer_refer_for", nightmare_xfer_uuid);
+ }
+ if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-From"))) {
+ switch_channel_set_variable(b_channel, "transfer_refer_from", nightmare_xfer_uuid);
+ }
}
if (!zstr(bridge_uuid)) {
- if (sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id && switch_channel_test_flag(b_channel, CF_BRIDGED) &&
+ if (sip && sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id && switch_channel_test_flag(b_channel, CF_BRIDGED) &&
switch_true(switch_find_parameter(*(sip->sip_replaces->rp_params), "early-only", switch_core_session_get_pool(session)))) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercept rejected\n", bridge_uuid);
tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "hangup:CALL_REJECTED");
} else {
- switch_channel_mark_hold(b_channel, SWITCH_FALSE);
- tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercepted\n", bridge_uuid);
- if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
- && sip && sip->sip_call_id
- && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
- switch_channel_event_set_data(b_channel, event);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
- switch_event_fire(&event);
- }
+ switch_channel_mark_hold(b_channel, SWITCH_FALSE);
+ tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s intercepted\n", bridge_uuid);
+ if (sofia_test_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS)
+ && sip && sip->sip_call_id
+ && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INTERCEPTED) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(b_channel, event);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "intercepted_by", sip->sip_call_id->i_id);
+ switch_event_fire(&event);
+ }
}
} else {
const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nNobody to send to: Profile %s\n", proto, from, to,
- body ? body : "[no body]", prof ? prof : "NULL");
+ body ? body : "[no body]", prof);
// emit no recipient event
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ERROR) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Error-Type", "chat");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Error-Reason", "no recipient");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-To", to);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-From", from);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-Profile", prof ? prof : "NULL");
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Chat-Send-Profile", prof);
switch_event_add_body(event, "%s", body);
switch_event_fire(&event);
}
dup_dest = strdup(dst->to);
}
+ switch_assert(dup_dest);
remote_host = strdup(dup_dest);
if (!zstr(remote_host)) {
status = SWITCH_STATUS_SUCCESS;
- if (dup_dest && (p = strstr(dup_dest, ";fs_"))) {
+ if ((p = strstr(dup_dest, ";fs_"))) {
*p = '\0';
}
switch_safe_free(stream.data);
switch_safe_free(dup_account);
-
- if (profile) {
- sofia_glue_release_profile(profile);
- }
+ sofia_glue_release_profile(profile);
}
static int sofia_presence_dialog_callback(void *pArg, int argc, char **argv, char **columnNames)
probe_euser = (p + 1);
}
- if (probe_euser && probe_host &&
+ if (probe_host &&
((profile = sofia_glue_find_profile(probe_host)) || (profile_name && (profile = sofia_glue_find_profile(profile_name))))) {
sql = switch_mprintf("select state,status,rpid,presence_id,uuid from sip_dialogs "
"where hostname='%q' and profile_name='%q' and call_info_state != 'seized' and "
probe_euser = (p + 1);
}
- if (probe_euser && probe_host) {
+ if (probe_host) {
char *sub_call_id = switch_event_get_header(event, "sub-call-id");
char *profile_name = switch_event_get_header(event, "sip_profile");
sofia_profile_t *profile = sofia_glue_find_profile(probe_host);
presence_id = argv[12];
free_me = strdup(presence_id);
+ switch_assert(free_me);
if ((p = strchr(free_me, '@'))) *p = '\0';
user = free_me;
}
strcpy(dst, "");
if (strchr(in, '<') && strchr(in, '>')) {
buf = strdup(in);
+ switch_assert(buf);
p = strchr(buf, '<');
*p = '\0';
if (!zstr(buf)) {
if (*p == '"') {
if (end_of(p+1) == '"') {
char *q = strdup(p + 1);
+ switch_assert(q);
end_of(q) = '\0';
strcpy(dst, q);
switch_safe_free(q);
free_me = strdup(presence_id);
+ switch_assert(free_me);
+
if ((p = strchr(free_me, '@'))) {
*p = '\0';
}
free(buf);
#endif
- if (is_dialog) {
- SWITCH_STANDARD_STREAM(stream);
- }
-
if (is_dialog) {
// Usually we report the dialogs FROM the probed user. The exception is when the monitored endpoint is internal,
// and its presence_id is set in the dialplan. Reverse the direction if this is not a registered entity.
const char *caller = switch_str_nil(switch_event_get_header(helper->event, "caller-username"));
+ SWITCH_STANDARD_STREAM(stream);
if (!strcmp(direction, "inbound") && strcmp(sub_to_user, caller)) {
// If inbound and the entity is not the caller (i.e. internal to FS), then the direction is reversed
// because it is not going through the B2BUA
if (to) {
to_str = switch_mprintf("sip:%s@%s", to->a_url->url_user, to->a_url->url_host);
- }
-
- if (to) {
to_user = to->a_url->url_user;
to_host = to->a_url->url_host;
}
}
if ((sub_max_deviation_var = profile->sip_subscription_max_deviation)) {
- if (sub_max_deviation_var > 0) {
- int sub_deviation;
- srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) );
- /* random negative number between 0 and negative sub_max_deviation_var: */
- sub_deviation = ( rand() % sub_max_deviation_var ) - sub_max_deviation_var;
- if ( (exp_delta + sub_deviation) > 45 ) {
- exp_delta += sub_deviation;
- }
+ int sub_deviation;
+ srand( (unsigned) ( (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now() ) );
+ /* random negative number between 0 and negative sub_max_deviation_var: */
+ sub_deviation = ( rand() % sub_max_deviation_var ) - sub_max_deviation_var;
+ if ( (exp_delta + sub_deviation) > 45 ) {
+ exp_delta += sub_deviation;
}
}
}
}
- if (!(proto && to_user && to_host)) {
+ if (!(proto && to_host)) {
nua_respond(nh, SIP_404_NOT_FOUND, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
goto end;
}
}
}
- sip_to_tag(nh->nh_home, sip->sip_to, use_to_tag);
+ if (nh && nh->nh_home) {
+ sip_to_tag(nh->nh_home, sip->sip_to, use_to_tag);
+ }
if (mod_sofia_globals.debug_presence > 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to SUBSCRIBE with 202 Accepted\n");
pd_dup = strdup(sip->sip_payload->pl_data);
+ switch_assert(pd_dup);
+
if ((xml = switch_xml_parse_str(pd_dup, strlen(pd_dup)))) {
switch_xml_t device = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "status (%d) != 200, updated state to SUB_STATE_FAILED.\n", status);
gw_sub_ptr->state = SUB_STATE_FAILED;
- if (!sofia_private) {
- nua_handle_destroy(nh);
- }
-
break;
}
end:
-
- if (gateway) {
- sofia_reg_release_gateway(gateway);
- }
+ sofia_reg_release_gateway(gateway);
}
pd_dup = strdup(payload->pl_data);
+ switch_assert(pd_dup);
+
if ((xml = switch_xml_parse_str(pd_dup, strlen(pd_dup)))) {
char *open_closed = "", *note_txt = "";
channel = switch_core_session_get_channel(session);
}
- if (sofia_test_pflag(profile, PFLAG_AUTH_MESSAGES) && sip){
+ if (sofia_test_pflag(profile, PFLAG_AUTH_MESSAGES)) {
sip_authorization_t const *authorization = NULL;
auth_res_t auth_res = AUTH_FORBIDDEN;
char keybuf[128] = "";