add calls count and failed calls count to sofia profile sorted by direction
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13103 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c253d41d75
commit
131be776f1
|
@ -512,6 +512,7 @@ SWITCH_DECLARE(void) switch_channel_set_app_flag(switch_channel_t *channel, uint
|
|||
SWITCH_DECLARE(void) switch_channel_clear_app_flag(switch_channel_t *channel, uint32_t flags);
|
||||
SWITCH_DECLARE(int) switch_channel_test_app_flag(switch_channel_t *channel, uint32_t flags);
|
||||
SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel);
|
||||
SWITCH_DECLARE(switch_call_direction_t) switch_channel_direction(switch_channel_t *channel);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -273,6 +273,14 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
|
|||
|
||||
switch_mutex_lock(tech_pvt->sofia_mutex);
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
|
||||
if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
|
||||
tech_pvt->profile->ob_failed_calls++;
|
||||
} else {
|
||||
tech_pvt->profile->ib_failed_calls++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!((use_my_cause = switch_channel_get_variable(channel, "sip_ignore_remote_cause")) && switch_true(use_my_cause))) {
|
||||
ps_cause = switch_channel_get_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE);
|
||||
}
|
||||
|
@ -1664,6 +1672,10 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
|||
stream->write_function(stream, "AGGRESSIVENAT \t%s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
|
||||
stream->write_function(stream, "STUN_ENABLED \t%s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
|
||||
stream->write_function(stream, "STUN_AUTO_DISABLE\t%s\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
|
||||
stream->write_function(stream, "CallsIN \t%d\n", profile->ib_calls);
|
||||
stream->write_function(stream, "FailedCallsIN \t%d\n", profile->ib_failed_calls);
|
||||
stream->write_function(stream, "CallsOUT \t%d\n", profile->ob_calls);
|
||||
stream->write_function(stream, "FailedCallsOUT \t%d\n", profile->ob_failed_calls);
|
||||
}
|
||||
stream->write_function(stream, "\nRegistrations:\n%s\n", line);
|
||||
|
||||
|
@ -1796,8 +1808,8 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
|
|||
stream->write_function(stream, " <pingfreq>%d</pingfreq>\n", gp->ping_freq);
|
||||
stream->write_function(stream, " <state>%s</state>\n", sofia_state_names[gp->state]);
|
||||
stream->write_function(stream, " <status>%s%s</status>\n", status_names[gp->status], gp->pinging ? " (ping)" : "");
|
||||
stream->write_function(stream, " <callsin>%d</callsin>\n", gp->ib_calls);
|
||||
stream->write_function(stream, " <callsout>%d</callsout>\n", gp->ob_calls);
|
||||
stream->write_function(stream, " <calls-in>%d</calls-in>\n", gp->ib_calls);
|
||||
stream->write_function(stream, " <calls-out>%d</calls-out>\n", gp->ob_calls);
|
||||
|
||||
stream->write_function(stream, " </gateway>\n");
|
||||
sofia_reg_release_gateway(gp);
|
||||
|
@ -1845,9 +1857,15 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
|
|||
stream->write_function(stream, " <nomedia>%s</nomedia>\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
|
||||
stream->write_function(stream, " <late-neg>%s</late-neg>\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
|
||||
stream->write_function(stream, " <proxy-media>%s</proxy-media>\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
|
||||
stream->write_function(stream, " <aggressivenat>%s</aggressive-nat>\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
|
||||
stream->write_function(stream, " <aggressivenat>%s</aggressive-nat>\n",
|
||||
sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
|
||||
stream->write_function(stream, " <stun-enabled>%s</stun-enabled>\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
|
||||
stream->write_function(stream, " <stun-auto-disable>%s</stun-auto-disable>\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
|
||||
stream->write_function(stream, " <stun-auto-disable>%s</stun-auto-disable>\n",
|
||||
sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
|
||||
stream->write_function(stream, " <calls-in>%s</calls-in>\n", profile->ib_calls);
|
||||
stream->write_function(stream, " <calls-out>%s</calls-out>\n", profile->ob_calls);
|
||||
stream->write_function(stream, " <failed-calls-in>%s</failed-calls-in>\n", profile->ib_failed_calls);
|
||||
stream->write_function(stream, " <failed-calls-out>%s</failed-calls-out>\n", profile->ob_failed_calls);
|
||||
|
||||
}
|
||||
stream->write_function(stream, " </profile-info>\n");
|
||||
|
@ -2694,6 +2712,11 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
|
|||
done:
|
||||
|
||||
if (profile) {
|
||||
if (cause == SWITCH_CAUSE_SUCCESS) {
|
||||
profile->ob_calls++;
|
||||
} else {
|
||||
profile->ob_failed_calls++;
|
||||
}
|
||||
sofia_glue_release_profile(profile);
|
||||
}
|
||||
return cause;
|
||||
|
|
|
@ -469,6 +469,10 @@ struct sofia_profile {
|
|||
sofia_media_options_t media_options;
|
||||
uint32_t force_subscription_expires;
|
||||
switch_rtp_bug_flag_t auto_rtp_bugs;
|
||||
uint32_t ib_calls;
|
||||
uint32_t ob_calls;
|
||||
uint32_t ib_failed_calls;
|
||||
uint32_t ob_failed_calls;
|
||||
};
|
||||
|
||||
struct private_object {
|
||||
|
|
|
@ -1473,6 +1473,10 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
|
|||
profile->rport_level = 1; /* default setting */
|
||||
profile->acl_count = 0;
|
||||
sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
|
||||
profile->ib_calls = 0;
|
||||
profile->ob_calls = 0;
|
||||
profile->ib_failed_calls = 0;
|
||||
profile->ob_failed_calls = 0;
|
||||
|
||||
if (xprofiledomain) {
|
||||
profile->domain_name = switch_core_strdup(profile->pool, xprofiledomain);
|
||||
|
@ -4124,21 +4128,23 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
char *is_nat = NULL;
|
||||
char acl_token[512] = "";
|
||||
|
||||
profile->ib_calls++;
|
||||
|
||||
if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING)) {
|
||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received an invalid packet!\n");
|
||||
nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END());
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(sip->sip_contact && sip->sip_contact->m_url)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO CONTACT!\n");
|
||||
nua_respond(nh, 400, "Missing Contact Header", TAG_END());
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr, my_addrinfo->ai_addrlen);
|
||||
|
@ -4209,7 +4215,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
if (!sofia_test_pflag(profile, PFLAG_AUTH_CALLS)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by acl \"%s\"\n", network_ip, switch_str_nil(last_acl));
|
||||
nua_respond(nh, SIP_403_FORBIDDEN, TAG_END());
|
||||
return;
|
||||
goto fail;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IP %s Rejected by acl \"%s\". Falling back to Digest auth.\n",
|
||||
network_ip, switch_str_nil(last_acl));
|
||||
|
@ -4226,6 +4232,11 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
if (v_event) {
|
||||
switch_event_destroy(&v_event);
|
||||
}
|
||||
|
||||
if (sip->sip_authorization || sip->sip_proxy_authorization) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -4242,14 +4253,14 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
|
||||
if (!session) {
|
||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
|
||||
nua_respond(nh, SIP_503_SERVICE_UNAVAILABLE, TAG_END());
|
||||
switch_core_session_destroy(&session);
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4860,6 +4871,12 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
|
|||
sofia_private_free(sofia_private);
|
||||
switch_core_session_destroy(&session);
|
||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||
return;
|
||||
|
||||
fail:
|
||||
profile->ib_failed_calls++;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void sofia_handle_sip_i_options(int status,
|
||||
|
|
|
@ -212,6 +212,11 @@ SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(switch
|
|||
return times;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_call_direction_t) switch_channel_direction(switch_channel_t *channel)
|
||||
{
|
||||
return channel->direction;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel, switch_call_direction_t direction, switch_memory_pool_t *pool)
|
||||
{
|
||||
switch_assert(pool != NULL);
|
||||
|
|
Loading…
Reference in New Issue