[commit] r13103 - in freeswitch/trunk/src: . include mod/endpoints/mod_sofia
Author: anthm Date: Tue Apr 21 12:47:22 2009 New Revision: 13103 Log: add calls count and failed calls count to sofia profile sorted by direction Modified: freeswitch/trunk/src/include/switch_channel.h freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c freeswitch/trunk/src/switch_channel.c Modified: freeswitch/trunk/src/include/switch_channel.h ============================================================================== --- freeswitch/trunk/src/include/switch_channel.h (original) +++ freeswitch/trunk/src/include/switch_channel.h Tue Apr 21 12:47:22 2009 @@ -512,6 +512,7 @@ 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); /** @} */ Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue Apr 21 12:47:22 2009 @@ -273,6 +273,14 @@ 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 @@ 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 @@ 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 @@ 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 @@ done: if (profile) { + if (cause == SWITCH_CAUSE_SUCCESS) { + profile->ob_calls++; + } else { + profile->ob_failed_calls++; + } sofia_glue_release_profile(profile); } return cause; Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Tue Apr 21 12:47:22 2009 @@ -469,6 +469,10 @@ 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 { Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue Apr 21 12:47:22 2009 @@ -1473,6 +1473,10 @@ 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 @@ 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 @@ 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 @@ if (v_event) { switch_event_destroy(&v_event); } + + if (sip->sip_authorization || sip->sip_proxy_authorization) { + goto fail; + } + return; } } @@ -4242,14 +4253,14 @@ 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 @@ 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, Modified: freeswitch/trunk/src/switch_channel.c ============================================================================== --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Tue Apr 21 12:47:22 2009 @@ -212,6 +212,11 @@ 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);
participants (1)
-
FreeSWITCH SVN