diff --git a/LICENSE b/LICENSE index 4465d2d0ca..e3c1b831e3 100644 --- a/LICENSE +++ b/LICENSE @@ -1321,10 +1321,6 @@ Files: src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.[ch] Copyright: 1999, 2000, 2002 Aladdin Enterprises. License: zlib/libpng -Files: src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h -Copyright: 2006, Author: Yossi Neiman of Cartis Solutions, Inc. -License: MPL-1.1 - Files: src/mod/say/mod_say_??/mod_say_??.c scripts/c/socket2me/socket2me.c src/mod/xml_int/mod_xml_scgi/xml_scgi_server.pl diff --git a/build/modules.conf.in b/build/modules.conf.in index 798984ffc2..08f1711c37 100755 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -91,7 +91,6 @@ event_handlers/mod_event_socket #event_handlers/mod_fail2ban #event_handlers/mod_format_cdr #event_handlers/mod_json_cdr -#event_handlers/mod_radius_cdr #event_handlers/mod_odbc_cdr #event_handlers/mod_smpp #event_handlers/mod_snmp diff --git a/build/modules.conf.most b/build/modules.conf.most index 18823a0386..e53d58b9ec 100755 --- a/build/modules.conf.most +++ b/build/modules.conf.most @@ -89,7 +89,6 @@ event_handlers/mod_event_multicast event_handlers/mod_event_socket event_handlers/mod_format_cdr event_handlers/mod_json_cdr -#event_handlers/mod_radius_cdr event_handlers/mod_odbc_cdr event_handlers/mod_snmp #event_handlers/mod_event_zmq diff --git a/configure.ac b/configure.ac index be9ce948f8..b71e691434 100755 --- a/configure.ac +++ b/configure.ac @@ -2182,7 +2182,6 @@ AC_CONFIG_FILES([Makefile src/mod/event_handlers/mod_fail2ban/Makefile src/mod/event_handlers/mod_format_cdr/Makefile src/mod/event_handlers/mod_json_cdr/Makefile - src/mod/event_handlers/mod_radius_cdr/Makefile src/mod/event_handlers/mod_odbc_cdr/Makefile src/mod/event_handlers/mod_smpp/Makefile src/mod/event_handlers/mod_snmp/Makefile diff --git a/debian/control-modules b/debian/control-modules index d44af60e36..4522649527 100755 --- a/debian/control-modules +++ b/debian/control-modules @@ -468,10 +468,6 @@ Module: event_handlers/mod_odbc_cdr Description: mod_odbc_cdr Adds mod_odbc_cdr. -Module: event_handlers/mod_radius_cdr -Description: mod_radius_cdr - Adds mod_radius_cdr. - Module: event_handlers/mod_smpp Description: mod_snmp Adds mod_snmp. diff --git a/debian/copyright b/debian/copyright index deedd66566..61669a3e06 100755 --- a/debian/copyright +++ b/debian/copyright @@ -1321,10 +1321,6 @@ Files: src/mod/event_handlers/mod_cdr_mongodb/driver/src/md5.[ch] Copyright: 1999, 2000, 2002 Aladdin Enterprises. License: zlib/libpng -Files: src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h -Copyright: 2006, Author: Yossi Neiman of Cartis Solutions, Inc. -License: MPL-1.1 - Files: src/mod/say/mod_say_??/mod_say_??.c scripts/c/socket2me/socket2me.c src/mod/xml_int/mod_xml_scgi/xml_scgi_server.pl diff --git a/freeswitch.spec b/freeswitch.spec index 1844c37ecf..5d02a33adb 100755 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -871,14 +871,6 @@ Requires: %{name} = %{version}-%{release} %description event-json-cdr JSON CDR Logger for FreeSWITCH. -%package event-radius-cdr -Summary: RADIUS Logger for the FreeSWITCH open source telephony platform -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description event-radius-cdr -RADIUS Logger for the FreeSWITCH open source telephony platform - %package event-snmp Summary: SNMP stats reporter for the FreeSWITCH open source telephony platform Group: System/Libraries @@ -1326,7 +1318,7 @@ ENDPOINTS_MODULES=" \ ###################################################################################################################### EVENT_HANDLERS_MODULES="event_handlers/mod_cdr_csv event_handlers/mod_cdr_pg_csv event_handlers/mod_cdr_sqlite \ event_handlers/mod_cdr_mongodb event_handlers/mod_format_cdr event_handlers/mod_erlang_event event_handlers/mod_event_multicast \ - event_handlers/mod_event_socket event_handlers/mod_json_cdr event_handlers/mod_radius_cdr \ + event_handlers/mod_event_socket event_handlers/mod_json_cdr \ event_handlers/mod_snmp" #### BUILD ISSUES NET RESOLVED FOR RELEASE event_handlers/mod_event_zmq @@ -2075,9 +2067,6 @@ fi %files event-json-cdr %{MODINSTDIR}/mod_json_cdr.so* -%files event-radius-cdr -%{MODINSTDIR}/mod_radius_cdr.so* - %files event-snmp %{MODINSTDIR}/mod_snmp.so* diff --git a/src/mod/event_handlers/mod_radius_cdr/Makefile.am b/src/mod/event_handlers/mod_radius_cdr/Makefile.am deleted file mode 100644 index b8a09eebdc..0000000000 --- a/src/mod/event_handlers/mod_radius_cdr/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_radius_cdr - -RADCLIENT_VERSION=1.1.7 -RADCLIENT=freeradius-client-$(RADCLIENT_VERSION) -RADCLIENT_DIR=$(switch_srcdir)/libs/$(RADCLIENT) -RADCLIENT_BUILDDIR=$(switch_builddir)/libs/$(RADCLIENT) -RADCLIENT_LIBDIR=$(RADCLIENT_BUILDDIR)/lib -RADCLIENT_LA=${RADCLIENT_LIBDIR}/libfreeradius-client.la - -mod_LTLIBRARIES = mod_radius_cdr.la -mod_radius_cdr_la_SOURCES = mod_radius_cdr.c -mod_radius_cdr_la_CFLAGS = $(AM_CFLAGS) -I$(RADCLIENT_DIR)/include -mod_radius_cdr_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(RADCLIENT_LA) -mod_radius_cdr_la_LDFLAGS = -avoid-version -module -no-undefined -shared -BUILT_SOURCES=$(RADCLIENT_LA) - -$(RADCLIENT_DIR): - $(GETLIB) $(RADCLIENT).tar.gz - -$(RADCLIENT_BUILDDIR)/Makefile: $(RADCLIENT_DIR) - mkdir -p $(RADCLIENT_BUILDDIR) - cd $(RADCLIENT_BUILDDIR) && $(DEFAULT_VARS) $(RADCLIENT_DIR)/configure $(DEFAULT_ARGS) --srcdir=$(RADCLIENT_DIR) - $(TOUCH_TARGET) - -$(RADCLIENT_LA): $(RADCLIENT_BUILDDIR)/Makefile - cd $(RADCLIENT_BUILDDIR) && CFLAGS="$(CFLAGS)" $(MAKE) - $(TOUCH_TARGET) - - diff --git a/src/mod/event_handlers/mod_radius_cdr/README b/src/mod/event_handlers/mod_radius_cdr/README deleted file mode 100644 index 1734d6b8fa..0000000000 --- a/src/mod/event_handlers/mod_radius_cdr/README +++ /dev/null @@ -1,98 +0,0 @@ -mod_radius_cdr - A cdr Accounting module for FreeSWITCH. - -cparker at segv dot org - -========================================================================================= - -Currently, this is in it's infancy, and is still being worked on. It is not -yet enabled by default in building. - -Comments, code, patches are always welcome. :) - -========================================================================================= - -Pre-reqs: - -In order to use this module you will need to have the CVS head of the freeradius-client -library installed. - -CVS version as of June 14, 2007 or later will be sufficient. - -Instructions on how to retrieve and install this can be found here: - - http://wiki.freeradius.org/Radiusclient - -========================================================================================= - -Building: - -1) Compile and install freeradius-client library. - -2) Edit the top level 'configure.in'. At approx line 336 you need to add: - ---- -AC_CONFIG_FILES([Makefile - src/Makefile - src/mod/Makefile - src/mod/event_handlers/mod_cdr/Makefile -+ src/mod/event_handlers/mod_radius_cdr/Makefile - src/mod/endpoints/mod_sofia/Makefile - src/include/switch_am_config.h - build/getlib.sh - build/modmake.rules]) ---- - -3) Rerun bootstrap, re-run configure - -4) Edit the top-level 'modules.conf'. Add the following entry: - -... -event_handlers/mod_radius_cdr -... - -5) Run make, and make install. Make sure the module is built and installed. - -6) Configure FreeSWITCH to load mod_radius_cdr - - - Copy the 'mod_radius_cdr.conf.xml' file to the FreeSWITCH conf directory - - Copy the 'radius/' directory to the FreeSWITCH conf directory - - Edit 'conf/modules.conf' to load mod_radius_cdr - - Edit 'conf/freeswitch.xml' to include 'mod_radius_cdr.conf.xml' - -========================================================================================= - -Here's a sample RADIUS transaction ( logged to a detail file via FreeRADIUS server ): - -Fri Jun 8 08:23:10 2007 - Acct-Status-Type = Start - Acct-Session-Id = "d734ff5e-bf04-4045-8cb3-f5744574808b" - Freeswitch-Src = "8478797989" - Freeswitch-CLID = "Chris Parker" - Freeswitch-Dst = "888" - Freeswitch-Dialplan = "XML" - NAS-Port = 0 - Acct-Delay-Time = 0 - NAS-IP-Address = 127.0.0.1 - Client-IP-Address = 127.0.0.1 - Acct-Unique-Session-Id = "4b7754541b5902fa" - Timestamp = 1181308990 - -Fri Jun 8 08:23:31 2007 - Acct-Status-Type = Stop - Acct-Session-Id = "d734ff5e-bf04-4045-8cb3-f5744574808b" - Freeswitch-Hangupcause = Normal-Clearing - Freeswitch-Src = "8478797989" - Freeswitch-CLID = "Chris Parker" - Freeswitch-Dst = "888" - Freeswitch-Dialplan = "XML" - Freeswitch-Lastapp = "bridge" - Freeswitch-Billusec = 21460442 - NAS-Port = 0 - Acct-Delay-Time = 0 - NAS-IP-Address = 127.0.0.1 - Client-IP-Address = 127.0.0.1 - Acct-Unique-Session-Id = "4b7754541b5902fa" - Timestamp = 1181309011 - - - diff --git a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c deleted file mode 100644 index 153ec6252d..0000000000 --- a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c +++ /dev/null @@ -1,892 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2014, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Chris Parker - * Mathieu Rene - * - * - * mod_radius_cdr.c -- RADIUS CDR Module - * - */ - -#include -#include -#include -#include "mod_radius_cdr.h" - -SWITCH_MODULE_LOAD_FUNCTION(mod_radius_cdr_load); -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_radius_cdr_shutdown); -SWITCH_MODULE_DEFINITION(mod_radius_cdr, mod_radius_cdr_load, mod_radius_cdr_shutdown, NULL); - -static struct { - int shutdown; - switch_thread_rwlock_t *rwlock; -} globals = { -0}; - -static char cf[] = "mod_radius_cdr.conf"; -static char my_dictionary[PATH_MAX]; -static char my_seqfile[PATH_MAX]; -static char *my_deadtime; /* 0 */ -static char *my_timeout; /* 5 */ -static char *my_retries; /* 3 */ -static char my_servers[SERVER_MAX][255]; -static const char *my_timezone=""; /* Asia/Tokyo */ - -static rc_handle *my_radius_init(void) -{ - int i = 0; - rc_handle *rad_config; - - rad_config = rc_new(); - - if (rad_config == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[mod_radius_cdr] Error initializing rc_handle!\n"); - return NULL; - } - - rad_config = rc_config_init(rad_config); - - if (rad_config == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error initializing radius config!\n"); - rc_destroy(rad_config); - return NULL; - } - - /* Some hardcoded ( for now ) defaults needed to initialize radius */ - if (rc_add_config(rad_config, "auth_order", "radius", "mod_radius_cdr.c", 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting auth_order = radius failed\n"); - rc_destroy(rad_config); - return NULL; - } - - if (rc_add_config(rad_config, "seqfile", my_seqfile, "mod_radius_cdr.c", 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting seqfile = %s failed\n", my_seqfile); - rc_destroy(rad_config); - return NULL; - } - - - /* Add the module configs to initialize rad_config */ - - for (i = 0; i < SERVER_MAX && my_servers[i][0] != '\0'; i++) { - if (rc_add_config(rad_config, "acctserver", my_servers[i], cf, 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting acctserver = %s failed\n", my_servers[i]); - rc_destroy(rad_config); - return NULL; - } - } - - if (rc_add_config(rad_config, "dictionary", my_dictionary, cf, 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed setting dictionary = %s failed\n", my_dictionary); - rc_destroy(rad_config); - return NULL; - } - - if (rc_add_config(rad_config, "radius_deadtime", my_deadtime, cf, 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting radius_deadtime = %s failed\n", my_deadtime); - rc_destroy(rad_config); - return NULL; - } - - if (rc_add_config(rad_config, "radius_timeout", my_timeout, cf, 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting radius_timeout = %s failed\n", my_timeout); - rc_destroy(rad_config); - return NULL; - } - - if (rc_add_config(rad_config, "radius_retries", my_retries, cf, 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting radius_retries = %s failed\n", my_retries); - rc_destroy(rad_config); - return NULL; - } - - /* Read the dictionary file(s) */ - if (rc_read_dictionary(rad_config, rc_conf_str(rad_config, "dictionary")) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "reading dictionary file(s): %s\n", my_dictionary); - rc_destroy(rad_config); - return NULL; - } - - return rad_config; -} - -static switch_status_t my_on_routing(switch_core_session_t *session) -{ - switch_xml_t cdr = NULL; - switch_channel_t *channel = switch_core_session_get_channel(session); - rc_handle *rad_config; - switch_status_t retval = SWITCH_STATUS_TERM; - VALUE_PAIR *send = NULL; - uint32_t client_port = 0; - uint32_t framed_addr = 0; - uint32_t status_type = PW_STATUS_START; - switch_time_t callstartdate = 0; - switch_time_t callanswerdate = 0; - switch_time_t callenddate = 0; - switch_time_t calltransferdate = 0; - const char *signal_bond = NULL; - - char *uuid_str; - - switch_time_exp_t tm; - switch_time_exp_t requested_tm; - char buffer[32]; - - char *radius_avpair_data; - char *delim; - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Entering my_on_routing\n"); - - if (globals.shutdown) { - return SWITCH_STATUS_FALSE; - } - - if (channel) { - const char *disable_flag = switch_channel_get_variable(channel, "disable_radius_start"); - - if (switch_true(disable_flag)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Not Sending RADIUS Start\n"); - - return SWITCH_STATUS_SUCCESS; - } - } - - switch_thread_rwlock_rdlock(globals.rwlock); - - rad_config = my_radius_init(); - - if (rad_config == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Error initializing radius, Start packet not logged.\n"); - goto end; - } - - if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { - uuid_str = switch_core_session_get_uuid(session); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Error Generating Data!\n"); - goto end; - } - - /* GMT offset may change according daylight saving rules. Evaluating GMT offset each time */ - if (zstr(my_timezone)) { - switch_time_exp_lt(&requested_tm, switch_micro_time_now()); - } else { - switch_time_exp_tz_name(my_timezone, &requested_tm, switch_micro_time_now()); - } - - /* Create the radius packet */ - - /* Set Status Type */ - if (rc_avpair_add(rad_config, &send, PW_ACCT_STATUS_TYPE, &status_type, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Failed setting Acct-Status-Type: Start\n"); - rc_destroy(rad_config); - goto end; - } - - if (rc_avpair_add(rad_config, &send, PW_ACCT_SESSION_ID, uuid_str, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Failed adding Acct-Session-ID: %s\n", uuid_str); - rc_destroy(rad_config); - goto end; - } - - /* Add VSAs */ - - if (channel) { - /*switch_call_cause_t cause; */ - switch_caller_profile_t *profile; - const char *radius_avpair = switch_channel_get_variable(channel, "radius_avpair"); - - /* - cause = switch_channel_get_cause(channel); - if (rc_avpair_add(rad_config, &send, PW_FS_HANGUPCAUSE, &cause, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Hangupcause: %d\n", cause); - rc_destroy(rad_config); - return SWITCH_STATUS_TERM; - } - */ - - if ((signal_bond = switch_channel_get_partner_uuid(channel)) && !zstr(signal_bond)) { - if (rc_avpair_add(rad_config, &send, PW_FS_OTHER_LEG_ID, (void*) signal_bond, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Failed adding Freeswitch-Other-Leg-Id: %s\n", uuid_str); - rc_destroy(rad_config); - goto end; - } - } - - profile = switch_channel_get_caller_profile(channel); - - if (profile) { - - callstartdate = profile->times->created; - callanswerdate = profile->times->answered; - calltransferdate = profile->times->transferred; - callenddate = profile->times->hungup; - - if (profile->username) { - if (rc_avpair_add(rad_config, &send, PW_USER_NAME, (void *) profile->username, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding User-Name: %s\n", profile->username); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->caller_id_number) { - if (rc_avpair_add(rad_config, &send, PW_FS_SRC, (void *) profile->caller_id_number, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Src: %s\n", profile->caller_id_number); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->caller_id_name) { - if (rc_avpair_add(rad_config, &send, PW_FS_CLID, (void *) profile->caller_id_name, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->destination_number) { - if (rc_avpair_add(rad_config, &send, PW_FS_DST, (void *) profile->destination_number, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dst: %s\n", profile->destination_number); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->dialplan) { - if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, (void *) profile->dialplan, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->network_addr) { - inet_pton(AF_INET, (void *) profile->network_addr, &framed_addr); - framed_addr = htonl(framed_addr); - if (rc_avpair_add(rad_config, &send, PW_FRAMED_IP_ADDRESS, &framed_addr, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Framed-IP-Address: %s\n", profile->network_addr); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->rdnis) { - if (rc_avpair_add(rad_config, &send, PW_FS_RDNIS, (void *) profile->rdnis, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-RDNIS: %s\n", profile->rdnis); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->context) { - if (rc_avpair_add(rad_config, &send, PW_FS_CONTEXT, (void *) profile->context, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Context: %s\n", profile->context); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->ani) { - if (rc_avpair_add(rad_config, &send, PW_FS_ANI, (void *) profile->ani, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANI: %s\n", profile->ani); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->aniii) { - if (rc_avpair_add(rad_config, &send, PW_FS_ANIII, (void *) profile->aniii, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANIII: %s\n", profile->aniii); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->source) { - if (rc_avpair_add(rad_config, &send, PW_FS_SOURCE, (void *) profile->source, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Source: %s\n", profile->source); - rc_destroy(rad_config); - goto end; - } - } - - if (callstartdate > 0) { - switch_time_exp_tz(&tm, callstartdate, requested_tm.tm_gmtoff); - switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600); - if (rc_avpair_add(rad_config, &send, PW_FS_CALLSTARTDATE, &buffer, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Callstartdate: %s\n", buffer); - rc_destroy(rad_config); - goto end; - } - } - - if (callanswerdate > 0) { - switch_time_exp_tz(&tm, callanswerdate, requested_tm.tm_gmtoff); - switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600); - if (rc_avpair_add(rad_config, &send, PW_FS_CALLANSWERDATE, &buffer, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Callanswerdate: %s\n", buffer); - rc_destroy(rad_config); - goto end; - } - } - - if (calltransferdate > 0) { - switch_time_exp_tz(&tm, calltransferdate, requested_tm.tm_gmtoff); - switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600); - if (rc_avpair_add(rad_config, &send, PW_FS_CALLTRANSFERDATE, &buffer, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Calltransferdate: %s\n", buffer); - rc_destroy(rad_config); - goto end; - } - } - - if (callenddate > 0) { - switch_time_exp_tz(&tm, callenddate, requested_tm.tm_gmtoff); - switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600); - if (rc_avpair_add(rad_config, &send, PW_FS_CALLENDDATE, &buffer, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Callenddate: %s\n", buffer); - rc_destroy(rad_config); - goto end; - } - } - - if (profile->caller_extension && profile->caller_extension->last_application && profile->caller_extension->last_application->application_name) { - if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP, - (void *) profile->caller_extension->last_application->application_name, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Lastapp: %s\n", profile->source); - rc_destroy(rad_config); - goto end; - } - } - - if (radius_avpair) { - char *radius_avpair_data_tmp = NULL; - - radius_avpair_data = strdup(radius_avpair + (strncmp(radius_avpair, "ARRAY::", 7) ? 0 : 7)); - radius_avpair_data_tmp = radius_avpair_data; - - do { - delim = strstr(radius_avpair_data_tmp, "|:"); - - if (delim) { - *delim = '\0'; - } - - if (rc_avpair_add(rad_config, &send, PW_FS_AVPAIR, (void *)radius_avpair_data_tmp, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-AVPair: %s\n", radius_avpair_data_tmp); - rc_destroy(rad_config); - switch_safe_free(radius_avpair_data); - goto end; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "added Freeswitch-AVPair: %s\n", radius_avpair_data_tmp); - - if (delim) { - radius_avpair_data_tmp = delim + 2; - } - } while (delim); - - switch_safe_free(radius_avpair_data); - } - - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "profile == NULL\n"); - } - } - - if (rc_acct(rad_config, client_port, send) == OK_RC) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] RADIUS Accounting OK\n"); - retval = SWITCH_STATUS_SUCCESS; - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] RADIUS Accounting Failed\n"); - retval = SWITCH_STATUS_TERM; - } - - rc_avpair_free(send); - rc_destroy(rad_config); - end: - switch_xml_free(cdr); - switch_thread_rwlock_unlock(globals.rwlock); - - return (retval); -} - -static switch_status_t my_on_reporting(switch_core_session_t *session) -{ - switch_xml_t cdr = NULL; - switch_channel_t *channel = switch_core_session_get_channel(session); - rc_handle *rad_config; - switch_status_t retval = SWITCH_STATUS_TERM; - VALUE_PAIR *send = NULL; - uint32_t client_port = 0; - uint32_t framed_addr = 0; - uint32_t status_type = PW_STATUS_STOP; - switch_time_t callstartdate = 0; - switch_time_t callanswerdate = 0; - switch_time_t callenddate = 0; - switch_time_t calltransferdate = 0; - switch_time_t billusec = 0; - uint32_t billsec = 0; - char *uuid_str; - - switch_time_exp_t tm; - switch_time_exp_t requested_tm; - - char buffer[32] = ""; - - char *radius_avpair_data; - char *delim; - - if (globals.shutdown) { - return SWITCH_STATUS_FALSE; - } - - - if (channel) { - const char *disable_flag = switch_channel_get_variable(channel, "disable_radius_stop"); - if (switch_true(disable_flag)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Not Sending RADIUS Stop\n"); - return SWITCH_STATUS_SUCCESS; - } - } - - switch_thread_rwlock_rdlock(globals.rwlock); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Entering my_on_reporting\n"); - - rad_config = my_radius_init(); - - if (rad_config == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Error initializing radius, session not logged.\n"); - goto end; - } - - if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) { - uuid_str = switch_core_session_get_uuid(session); - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "[mod_radius_cdr] Error Generating Data!\n"); - goto end; - } - - /* GMT offset may change according daylight saving rules. Evaluating GMT offset each time */ - if (zstr(my_timezone)) { - switch_time_exp_lt(&requested_tm, time(NULL)); - } else { - switch_time_exp_tz_name(my_timezone, &requested_tm, time(NULL)); - } - - /* Create the radius packet */ - - /* Set Status Type */ - if (rc_avpair_add(rad_config, &send, PW_ACCT_STATUS_TYPE, &status_type, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Acct-Session-ID: %s\n", uuid_str); - rc_destroy(rad_config); - goto end; - } - - if (rc_avpair_add(rad_config, &send, PW_ACCT_SESSION_ID, uuid_str, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Acct-Session-ID: %s\n", uuid_str); - rc_destroy(rad_config); - goto end; - } - - /* Add VSAs */ - - if (channel) { - switch_call_cause_t cause; - switch_caller_profile_t *profile; - const char *radius_avpair = switch_channel_get_variable(channel, "radius_avpair"); - - cause = switch_channel_get_cause(channel); - if (rc_avpair_add(rad_config, &send, PW_FS_HANGUPCAUSE, &cause, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Hangupcause: %d\n", cause); - rc_destroy(rad_config); - goto end; - } - - profile = switch_channel_get_caller_profile(channel); - - if (profile) { - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Calculating billable time\n"); - - /* calculate billable time */ - callstartdate = profile->times->created; - callanswerdate = profile->times->answered; - calltransferdate = profile->times->transferred; - callenddate = profile->times->hungup; - - if (switch_channel_test_flag(channel, CF_ANSWERED)) { - if (callstartdate && callanswerdate) { - if (callenddate) - billusec = callenddate - callanswerdate; - else if (calltransferdate) - billusec = calltransferdate - callanswerdate; - } - } else if (switch_channel_test_flag(channel, CF_TRANSFER)) { - if (callanswerdate && calltransferdate) - billusec = calltransferdate - callanswerdate; - } - billsec = (billusec / 1000000); - - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "[mod_radius_cdr] Finished calculating billable time\n"); - - if (profile->username) { - if (rc_avpair_add(rad_config, &send, PW_USER_NAME, (void *) profile->username, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding User-Name: %s\n", profile->username); - rc_destroy(rad_config); - goto end; - } - } - if (profile->caller_id_number) { - if (rc_avpair_add(rad_config, &send, PW_FS_SRC, (void *) profile->caller_id_number, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Src: %s\n", profile->caller_id_number); - rc_destroy(rad_config); - goto end; - } - } - if (profile->caller_id_name) { - if (rc_avpair_add(rad_config, &send, PW_FS_CLID, (void *) profile->caller_id_name, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-CLID: %s\n", profile->caller_id_name); - rc_destroy(rad_config); - goto end; - } - } - if (profile->destination_number) { - if (rc_avpair_add(rad_config, &send, PW_FS_DST, (void *) profile->destination_number, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dst: %s\n", profile->destination_number); - rc_destroy(rad_config); - goto end; - } - } - if (profile->dialplan) { - if (rc_avpair_add(rad_config, &send, PW_FS_DIALPLAN, (void *) profile->dialplan, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Dialplan: %s\n", profile->dialplan); - rc_destroy(rad_config); - goto end; - } - } - if (profile->network_addr) { - inet_pton(AF_INET, (void *) profile->network_addr, &framed_addr); - framed_addr = htonl(framed_addr); - if (rc_avpair_add(rad_config, &send, PW_FRAMED_IP_ADDRESS, &framed_addr, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Framed-IP-Address: %s\n", profile->network_addr); - rc_destroy(rad_config); - goto end; - } - } - if (profile->rdnis) { - if (rc_avpair_add(rad_config, &send, PW_FS_RDNIS, (void *) profile->rdnis, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-RDNIS: %s\n", profile->rdnis); - rc_destroy(rad_config); - goto end; - } - } - if (profile->context) { - if (rc_avpair_add(rad_config, &send, PW_FS_CONTEXT, (void *) profile->context, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Context: %s\n", profile->context); - rc_destroy(rad_config); - goto end; - } - } - if (profile->ani) { - if (rc_avpair_add(rad_config, &send, PW_FS_ANI, (void *) profile->ani, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANI: %s\n", profile->ani); - rc_destroy(rad_config); - goto end; - } - } - if (profile->aniii) { - if (rc_avpair_add(rad_config, &send, PW_FS_ANIII, (void *) profile->aniii, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-ANIII: %s\n", profile->aniii); - rc_destroy(rad_config); - goto end; - } - } - if (profile->source) { - if (rc_avpair_add(rad_config, &send, PW_FS_SOURCE, (void *) profile->source, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Source: %s\n", profile->source); - rc_destroy(rad_config); - goto end; - } - } - if (profile->caller_extension && profile->caller_extension->last_application && profile->caller_extension->last_application->application_name) { - if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP, - (void *) profile->caller_extension->last_application->application_name, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Lastapp: %s\n", profile->source); - rc_destroy(rad_config); - goto end; - } - } - if (rc_avpair_add(rad_config, &send, PW_FS_BILLUSEC, &billusec, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Billusec: %u\n", (uint32_t) billusec); - rc_destroy(rad_config); - goto end; - } - - if (callstartdate > 0) { - switch_time_exp_tz(&tm, callstartdate, requested_tm.tm_gmtoff); - switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600); - if (rc_avpair_add(rad_config, &send, PW_FS_CALLSTARTDATE, &buffer, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Callstartdate: %s\n", buffer); - rc_destroy(rad_config); - goto end; - } - } - - if (callanswerdate > 0) { - switch_time_exp_tz(&tm, callanswerdate, requested_tm.tm_gmtoff); - switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600); - if (rc_avpair_add(rad_config, &send, PW_FS_CALLANSWERDATE, &buffer, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Callanswerdate: %s\n", buffer); - rc_destroy(rad_config); - goto end; - } - } - - if (calltransferdate > 0) { - switch_time_exp_tz(&tm, calltransferdate, requested_tm.tm_gmtoff); - switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600); - if (rc_avpair_add(rad_config, &send, PW_FS_CALLTRANSFERDATE, &buffer, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Calltransferdate: %s\n", buffer); - rc_destroy(rad_config); - goto end; - } - } - - if (callenddate > 0) { - switch_time_exp_tz(&tm, callenddate, requested_tm.tm_gmtoff); - switch_snprintf(buffer, sizeof(buffer), "%04u-%02u-%02uT%02u:%02u:%02u.%06u%+03d%02d", - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_gmtoff / 3600, tm.tm_gmtoff % 3600); - if (rc_avpair_add(rad_config, &send, PW_FS_CALLENDDATE, &buffer, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Callenddate: %s\n", buffer); - rc_destroy(rad_config); - goto end; - } - } - - if (rc_avpair_add(rad_config, &send, PW_ACCT_SESSION_TIME, &billsec, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Acct-Session-Time: %u\n", billsec); - rc_destroy(rad_config); - goto end; - } - - { - const char *direction_str = profile->direction == SWITCH_CALL_DIRECTION_INBOUND ? "inbound" : "outbound"; - - if (rc_avpair_add(rad_config, &send, PW_FS_DIRECTION, (void *) direction_str, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "failed adding Freeswitch-Direction: %s\n", direction_str); - rc_destroy(rad_config); - goto end; - } - } - - if (radius_avpair) { - radius_avpair_data = strdup(radius_avpair + (strncmp(radius_avpair, "ARRAY::", 7) ? 0 : 7)); - do { - delim = strstr(radius_avpair_data, "|:"); - - if (delim) { - *delim = '\0'; - } - - if (rc_avpair_add(rad_config, &send, PW_FS_AVPAIR, (void *) radius_avpair_data, -1, PW_FS_PEC) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-AVPair: %s\n", radius_avpair_data); - rc_destroy(rad_config); - goto end; - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "added Freeswitch-AVPair: %s\n", radius_avpair_data); - - if (delim) { - radius_avpair_data = delim + 2; - } - } while (delim); - } - - } else { /* no profile, can't create data to send */ - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "profile == NULL\n"); - } - } - - if (rc_acct(rad_config, client_port, send) == OK_RC) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "RADIUS Accounting OK\n"); - retval = SWITCH_STATUS_SUCCESS; - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RADIUS Accounting Failed\n"); - retval = SWITCH_STATUS_TERM; - } - rc_avpair_free(send); - rc_destroy(rad_config); - - end: - switch_xml_free(cdr); - switch_thread_rwlock_unlock(globals.rwlock); - return (retval); -} - -static switch_status_t load_config(void) -{ - switch_xml_t cfg, xml, settings, param; - - int num_servers = 0; - int i = 0; - static char *tz_name; - - my_timeout = "5"; - my_retries = "3"; - my_deadtime = "0"; - strncpy(my_seqfile, "/var/run/radius.seq", PATH_MAX - 1); - strncpy(my_dictionary, "/usr/local/freeswitch/conf/radius/dictionary", PATH_MAX - 1); - - for (i = 0; i < SERVER_MAX; i++) { - my_servers[i][0] = '\0'; - } - - if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); - return SWITCH_STATUS_TERM; - } - - if ((settings = switch_xml_child(cfg, "settings"))) { - for (param = switch_xml_child(settings, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if (!strcmp(var, "acctserver")) { - if (num_servers < SERVER_MAX) { - strncpy(my_servers[num_servers], val, 255 - 1); - num_servers++; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "you can only specify %d radius servers, ignoring excess server entry\n", SERVER_MAX); - } - } else if (!strcmp(var, "dictionary")) { - strncpy(my_dictionary, val, PATH_MAX - 1); - } else if (!strcmp(var, "seqfile")) { - strncpy(my_seqfile, val, PATH_MAX - 1); - } else if (!strcmp(var, "radius_timeout")) { - my_timeout = strdup(val); - } else if (!strcmp(var, "radius_retries")) { - my_retries = strdup(val); - } else if (!strcmp(var, "radius_deadtime")) { - my_deadtime = strdup(val); - } else if (!strcmp(var, "timezone")) { - tz_name = strdup(val); - } - } - } - - switch_xml_free(xml); - - if (num_servers < 1) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "you must specify at least 1 radius server\n"); - return SWITCH_STATUS_TERM; - } - - if (!zstr(tz_name)) { - if (switch_lookup_timezone(tz_name)) { - my_timezone= tz_name; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find timezone %s\n, Setting timezone to GMT", tz_name); - my_timezone= "GMT"; - } - } - - /* If we made it this far, we succeeded */ - return SWITCH_STATUS_SUCCESS; -} - -static const switch_state_handler_table_t state_handlers = { - /*.on_init */ NULL, - /*.on_routing */ my_on_routing, - /*.on_execute */ NULL, - /*.on_hangup */ NULL, - /*.on_exchange_media */ NULL, - /*.on_soft_execute */ NULL, - /*.on_consume_media */ NULL, - /*.on_hibernate */ NULL, - /*.on_reset */ NULL, - /*.on_park */ NULL, - /*.on_reporting */ my_on_reporting -}; - -SWITCH_MODULE_LOAD_FUNCTION(mod_radius_cdr_load) -{ - - switch_thread_rwlock_create(&globals.rwlock, pool); - - if (load_config() != SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_TERM; - } - - /* test global state handlers */ - switch_core_add_state_handler(&state_handlers); - - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; -} - - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_radius_cdr_shutdown) -{ - - globals.shutdown = 1; - switch_core_remove_state_handler(&state_handlers); - switch_thread_rwlock_wrlock(globals.rwlock); - switch_thread_rwlock_unlock(globals.rwlock); - - return SWITCH_STATUS_SUCCESS; -} - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.conf.xml b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.conf.xml deleted file mode 100644 index fea5194b81..0000000000 --- a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.conf.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h b/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h deleted file mode 100644 index 0257f61303..0000000000 --- a/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application Call Detail Recorder module - * Copyright 2006, Author: Yossi Neiman of Cartis Solutions, Inc. - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application Call Detail Recorder module - * - * The Initial Developer of the Original Code is - * Chris Parker - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Chris Parker - * - * Description: Contains definitions and structs used by the radius cdr module. - * - * mod_radius_cdr.h - * - */ - -#ifndef MODRADIUSCDR -#define MODRADIUSCDR - -#define PW_FS_PEC 27880 - -#define PW_FS_AVPAIR 1 -#define PW_FS_CLID 2 -#define PW_FS_DIALPLAN 3 -#define PW_FS_SRC 4 -#define PW_FS_DST 5 -#define PW_FS_SRC_CHANNEL 6 -#define PW_FS_DST_CHANNEL 7 -#define PW_FS_ANI 8 -#define PW_FS_ANIII 9 -#define PW_FS_LASTAPP 10 -#define PW_FS_LASTDATA 11 -#define PW_FS_DISPOSITION 12 -#define PW_FS_HANGUPCAUSE 13 -#define PW_FS_BILLUSEC 15 -#define PW_FS_AMAFLAGS 16 -#define PW_FS_RDNIS 17 -#define PW_FS_CONTEXT 18 -#define PW_FS_SOURCE 19 -#define PW_FS_CALLSTARTDATE 20 -#define PW_FS_CALLANSWERDATE 21 -#define PW_FS_CALLTRANSFERDATE 22 -#define PW_FS_CALLENDDATE 23 -#define PW_FS_DIRECTION 24 -#define PW_FS_OTHER_LEG_ID 25 - - -#endif diff --git a/src/mod/event_handlers/mod_radius_cdr/radius/dictionary b/src/mod/event_handlers/mod_radius_cdr/radius/dictionary deleted file mode 100644 index c126e685d4..0000000000 --- a/src/mod/event_handlers/mod_radius_cdr/radius/dictionary +++ /dev/null @@ -1,353 +0,0 @@ -# -# Updated 97/06/13 to livingston-radius-2.01 miquels@cistron.nl -# -# This file contains dictionary translations for parsing -# requests and generating responses. All transactions are -# composed of Attribute/Value Pairs. The value of each attribute -# is specified as one of 4 data types. Valid data types are: -# -# string - 0-253 octets -# ipaddr - 4 octets in network byte order -# integer - 32 bit value in big endian order (high byte first) -# date - 32 bit value in big endian order - seconds since -# 00:00:00 GMT, Jan. 1, 1970 -# -# Enumerated values are stored in the user file with dictionary -# VALUE translations for easy administration. -# -# Example: -# -# ATTRIBUTE VALUE -# --------------- ----- -# Framed-Protocol = PPP -# 7 = 1 (integer encoding) -# - -# -# Following are the proper new names. Use these. -# -ATTRIBUTE User-Name 1 string -ATTRIBUTE Password 2 string -ATTRIBUTE CHAP-Password 3 string -ATTRIBUTE NAS-IP-Address 4 ipaddr -ATTRIBUTE NAS-Port-Id 5 integer -ATTRIBUTE Service-Type 6 integer -ATTRIBUTE Framed-Protocol 7 integer -ATTRIBUTE Framed-IP-Address 8 ipaddr -ATTRIBUTE Framed-IP-Netmask 9 ipaddr -ATTRIBUTE Framed-Routing 10 integer -ATTRIBUTE Filter-Id 11 string -ATTRIBUTE Framed-MTU 12 integer -ATTRIBUTE Framed-Compression 13 integer -ATTRIBUTE Login-IP-Host 14 ipaddr -ATTRIBUTE Login-Service 15 integer -ATTRIBUTE Login-TCP-Port 16 integer -ATTRIBUTE Reply-Message 18 string -ATTRIBUTE Callback-Number 19 string -ATTRIBUTE Callback-Id 20 string -ATTRIBUTE Framed-Route 22 string -ATTRIBUTE Framed-IPX-Network 23 ipaddr -ATTRIBUTE State 24 string -ATTRIBUTE Class 25 string -ATTRIBUTE Vendor-Specific 26 string -ATTRIBUTE Session-Timeout 27 integer -ATTRIBUTE Idle-Timeout 28 integer -ATTRIBUTE Termination-Action 29 integer -ATTRIBUTE Called-Station-Id 30 string -ATTRIBUTE Calling-Station-Id 31 string -ATTRIBUTE NAS-Identifier 32 string -ATTRIBUTE Proxy-State 33 string -ATTRIBUTE Login-LAT-Service 34 string -ATTRIBUTE Login-LAT-Node 35 string -ATTRIBUTE Login-LAT-Group 36 string -ATTRIBUTE Framed-AppleTalk-Link 37 integer -ATTRIBUTE Framed-AppleTalk-Network 38 integer -ATTRIBUTE Framed-AppleTalk-Zone 39 string -ATTRIBUTE Acct-Status-Type 40 integer -ATTRIBUTE Acct-Delay-Time 41 integer -ATTRIBUTE Acct-Input-Octets 42 integer -ATTRIBUTE Acct-Output-Octets 43 integer -ATTRIBUTE Acct-Session-Id 44 string -ATTRIBUTE Acct-Authentic 45 integer -ATTRIBUTE Acct-Session-Time 46 integer -ATTRIBUTE Acct-Input-Packets 47 integer -ATTRIBUTE Acct-Output-Packets 48 integer -ATTRIBUTE Acct-Terminate-Cause 49 integer -ATTRIBUTE Acct-Multi-Session-Id 50 string -ATTRIBUTE Acct-Link-Count 51 integer -ATTRIBUTE Event-Timestamp 55 integer -ATTRIBUTE CHAP-Challenge 60 string -ATTRIBUTE NAS-Port-Type 61 integer -ATTRIBUTE Port-Limit 62 integer -ATTRIBUTE Login-LAT-Port 63 integer -ATTRIBUTE Connect-Info 77 string - -# -# RFC3162 IPv6 attributes -# -ATTRIBUTE NAS-IPv6-Address 95 string -ATTRIBUTE Framed-Interface-Id 96 string -ATTRIBUTE Framed-IPv6-Prefix 97 string -ATTRIBUTE Login-IPv6-Host 98 string -ATTRIBUTE Framed-IPv6-Route 99 string -ATTRIBUTE Framed-IPv6-Pool 100 string - -# -# Experimental Non Protocol Attributes used by Cistron-Radiusd -# -ATTRIBUTE Huntgroup-Name 221 string -ATTRIBUTE User-Category 1029 string -ATTRIBUTE Group-Name 1030 string -ATTRIBUTE Simultaneous-Use 1034 integer -ATTRIBUTE Strip-User-Name 1035 integer -ATTRIBUTE Fall-Through 1036 integer -ATTRIBUTE Add-Port-To-IP-Address 1037 integer -ATTRIBUTE Exec-Program 1038 string -ATTRIBUTE Exec-Program-Wait 1039 string -ATTRIBUTE Hint 1040 string - -# -# Non-Protocol Attributes -# These attributes are used internally by the server -# -ATTRIBUTE Expiration 21 date -ATTRIBUTE Auth-Type 1000 integer -ATTRIBUTE Menu 1001 string -ATTRIBUTE Termination-Menu 1002 string -ATTRIBUTE Prefix 1003 string -ATTRIBUTE Suffix 1004 string -ATTRIBUTE Group 1005 string -ATTRIBUTE Crypt-Password 1006 string -ATTRIBUTE Connect-Rate 1007 integer - -# -# Integer Translations -# - -# User Types - -VALUE Service-Type Login-User 1 -VALUE Service-Type Framed-User 2 -VALUE Service-Type Callback-Login-User 3 -VALUE Service-Type Callback-Framed-User 4 -VALUE Service-Type Outbound-User 5 -VALUE Service-Type Administrative-User 6 -VALUE Service-Type NAS-Prompt-User 7 - -# Framed Protocols - -VALUE Framed-Protocol PPP 1 -VALUE Framed-Protocol SLIP 2 - -# Framed Routing Values - -VALUE Framed-Routing None 0 -VALUE Framed-Routing Broadcast 1 -VALUE Framed-Routing Listen 2 -VALUE Framed-Routing Broadcast-Listen 3 - -# Framed Compression Types - -VALUE Framed-Compression None 0 -VALUE Framed-Compression Van-Jacobson-TCP-IP 1 - -# Login Services - -VALUE Login-Service Telnet 0 -VALUE Login-Service Rlogin 1 -VALUE Login-Service TCP-Clear 2 -VALUE Login-Service PortMaster 3 - -# Status Types - -VALUE Acct-Status-Type Start 1 -VALUE Acct-Status-Type Stop 2 -VALUE Acct-Status-Type Alive 3 -VALUE Acct-Status-Type Accounting-On 7 -VALUE Acct-Status-Type Accounting-Off 8 - -# Authentication Types - -VALUE Acct-Authentic RADIUS 1 -VALUE Acct-Authentic Local 2 -VALUE Acct-Authentic PowerLink128 100 - -# Termination Options - -VALUE Termination-Action Default 0 -VALUE Termination-Action RADIUS-Request 1 - -# NAS Port Types, available in 3.3.1 and later - -VALUE NAS-Port-Type Async 0 -VALUE NAS-Port-Type Sync 1 -VALUE NAS-Port-Type ISDN 2 -VALUE NAS-Port-Type ISDN-V120 3 -VALUE NAS-Port-Type ISDN-V110 4 - -# Acct Terminate Causes, available in 3.3.2 and later - -VALUE Acct-Terminate-Cause User-Request 1 -VALUE Acct-Terminate-Cause Lost-Carrier 2 -VALUE Acct-Terminate-Cause Lost-Service 3 -VALUE Acct-Terminate-Cause Idle-Timeout 4 -VALUE Acct-Terminate-Cause Session-Timeout 5 -VALUE Acct-Terminate-Cause Admin-Reset 6 -VALUE Acct-Terminate-Cause Admin-Reboot 7 -VALUE Acct-Terminate-Cause Port-Error 8 -VALUE Acct-Terminate-Cause NAS-Error 9 -VALUE Acct-Terminate-Cause NAS-Request 10 -VALUE Acct-Terminate-Cause NAS-Reboot 11 -VALUE Acct-Terminate-Cause Port-Unneeded 12 -VALUE Acct-Terminate-Cause Port-Preempted 13 -VALUE Acct-Terminate-Cause Port-Suspended 14 -VALUE Acct-Terminate-Cause Service-Unavailable 15 -VALUE Acct-Terminate-Cause Callback 16 -VALUE Acct-Terminate-Cause User-Error 17 -VALUE Acct-Terminate-Cause Host-Request 18 - -# -# Non-Protocol Integer Translations -# - -VALUE Auth-Type Local 0 -VALUE Auth-Type System 1 -VALUE Auth-Type SecurID 2 -VALUE Auth-Type Crypt-Local 3 -VALUE Auth-Type Reject 4 - -# -# Cistron extensions -# -VALUE Auth-Type Pam 253 -VALUE Auth-Type Accept 254 - -# -# Experimental Non-Protocol Integer Translations for Cistron-Radiusd -# -VALUE Fall-Through No 0 -VALUE Fall-Through Yes 1 -VALUE Add-Port-To-IP-Address No 0 -VALUE Add-Port-To-IP-Address Yes 1 - -# -# Configuration Values -# uncomment these two lines to turn account expiration on -# - -#VALUE Server-Config Password-Expiration 30 -#VALUE Server-Config Password-Warning 5 - -# -*- text -*- -# -# dictionary.freeswitch -# -# cparker@segv.org -# -# Version: $Id: $ -# - -VENDOR Freeswitch 27880 - -# -# Standard attribute -# -BEGIN-VENDOR Freeswitch - -ATTRIBUTE Freeswitch-AVPair 1 string Freeswitch -ATTRIBUTE Freeswitch-CLID 2 string Freeswitch -ATTRIBUTE Freeswitch-Dialplan 3 string Freeswitch -ATTRIBUTE Freeswitch-Src 4 string Freeswitch -ATTRIBUTE Freeswitch-Dst 5 string Freeswitch -ATTRIBUTE Freeswitch-Src-Channel 6 string Freeswitch -ATTRIBUTE Freeswitch-Dst-Channel 7 string Freeswitch -ATTRIBUTE Freeswitch-Ani 8 string Freeswitch -ATTRIBUTE Freeswitch-Aniii 9 string Freeswitch -ATTRIBUTE Freeswitch-Lastapp 10 string Freeswitch -ATTRIBUTE Freeswitch-Lastdata 11 string Freeswitch -ATTRIBUTE Freeswitch-Disposition 12 string Freeswitch -ATTRIBUTE Freeswitch-Hangupcause 13 integer Freeswitch -ATTRIBUTE Freeswitch-Billusec 15 integer Freeswitch -ATTRIBUTE Freeswitch-AMAFlags 16 integer Freeswitch -ATTRIBUTE Freeswitch-RDNIS 17 string Freeswitch -ATTRIBUTE Freeswitch-Context 18 string Freeswitch -ATTRIBUTE Freeswitch-Source 19 string Freeswitch -ATTRIBUTE Freeswitch-Callstartdate 20 string Freeswitch -ATTRIBUTE Freeswitch-Callanswerdate 21 string Freeswitch -ATTRIBUTE Freeswitch-Calltransferdate 22 string Freeswitch -ATTRIBUTE Freeswitch-Callenddate 23 string Freeswitch -ATTRIBUTE Freeswitch-Direction 24 string Freeswitch -ATTRIBUTE Freeswitch-Other-Leg-Id 25 string Freeswitch - -# -# Freeswitch-Hangupcause -# -VALUE Freeswitch-Hangupcause None 0 -VALUE Freeswitch-Hangupcause Unallocated-Number 1 -VALUE Freeswitch-Hangupcause No-Route-Transit-Net 2 -VALUE Freeswitch-Hangupcause No-Route-Destination 3 -VALUE Freeswitch-Hangupcause Channel-Unacceptable 6 -VALUE Freeswitch-Hangupcause Call-Awarded-Delivery 7 -VALUE Freeswitch-Hangupcause Normal-Clearing 16 -VALUE Freeswitch-Hangupcause User-Busy 17 -VALUE Freeswitch-Hangupcause No-User-Response 18 -VALUE Freeswitch-Hangupcause No-Answer 19 -VALUE Freeswitch-Hangupcause Subscriber-Absent 20 -VALUE Freeswitch-Hangupcause Call-Rejected 21 -VALUE Freeswitch-Hangupcause Number-Changed 22 -VALUE Freeswitch-Hangupcause Redirecto-To-New-Destination 23 -VALUE Freeswitch-Hangupcause Exchange-Routing-Error 25 -VALUE Freeswitch-Hangupcause Destination-Out-Of-Order 27 -VALUE Freeswitch-Hangupcause Invalid-Number-Format 28 -VALUE Freeswitch-Hangupcause Facility-Rejected 29 -VALUE Freeswitch-Hangupcause Response-To-Status-Enquiry 30 -VALUE Freeswitch-Hangupcause Normal-Unspecified 31 -VALUE Freeswitch-Hangupcause Normal-Circuit-Congestion 34 -VALUE Freeswitch-Hangupcause Network-Out-Of-Order 38 -VALUE Freeswitch-Hangupcause Normal-Temporary-Failure 41 -VALUE Freeswitch-Hangupcause Switch-Congestion 42 -VALUE Freeswitch-Hangupcause Access-Info-Discarded 43 -VALUE Freeswitch-Hangupcause Requested-Chan-Unavail 44 -VALUE Freeswitch-Hangupcause Pre-Empted 45 -VALUE Freeswitch-Hangupcause Facility-Not-Subscribed 50 -VALUE Freeswitch-Hangupcause Outgoing-Call-Barred 52 -VALUE Freeswitch-Hangupcause Incoming-Call-Barred 54 -VALUE Freeswitch-Hangupcause Bearercapability-Notauth 57 -VALUE Freeswitch-Hangupcause Bearercapability-Notavail 58 -VALUE Freeswitch-Hangupcause Service-Unavailable 63 -VALUE Freeswitch-Hangupcause Bearercapability-Notimpl 65 -VALUE Freeswitch-Hangupcause Chan-Not-Implemented 66 -VALUE Freeswitch-Hangupcause Facility-Not-Implemented 69 -VALUE Freeswitch-Hangupcause Service-Not-Implemented 79 -VALUE Freeswitch-Hangupcause Invalid-Call-Reference 81 -VALUE Freeswitch-Hangupcause Incompatible-Destination 88 -VALUE Freeswitch-Hangupcause Invalid-Msg-Unspecified 95 -VALUE Freeswitch-Hangupcause Mandatory-IE-Missing 96 -VALUE Freeswitch-Hangupcause Message-Type-Nonexist 97 -VALUE Freeswitch-Hangupcause Wrong-Message 98 -VALUE Freeswitch-Hangupcause IE-Nonexist 99 -VALUE Freeswitch-Hangupcause Invalid-IE-Contents 100 -VALUE Freeswitch-Hangupcause Wrong-Call-State 101 -VALUE Freeswitch-Hangupcause Recovery-On-Timer-Expire 102 -VALUE Freeswitch-Hangupcause Mandatory-IE-Length-Error 103 -VALUE Freeswitch-Hangupcause Protocol-Error 111 -VALUE Freeswitch-Hangupcause Interworking 127 -VALUE Freeswitch-Hangupcause Success 142 -VALUE Freeswitch-Hangupcause Originator-Cancel 487 -VALUE Freeswitch-Hangupcause Crash 500 -VALUE Freeswitch-Hangupcause System-Shutdown 501 -VALUE Freeswitch-Hangupcause Lose-Race 502 -VALUE Freeswitch-Hangupcause Manager-Request 503 -VALUE Freeswitch-Hangupcause Blind-Transfer 600 -VALUE Freeswitch-Hangupcause Attended-Transfer 601 -VALUE Freeswitch-Hangupcause Allotted-Timeout 602 -VALUE Freeswitch-Hangupcause User-Challenge 603 -VALUE Freeswitch-Hangupcause Media-Timeout 604 -VALUE Freeswitch-Hangupcause Picked-Off 605 -VALUE Freeswitch-Hangupcause User-Not-Registered 606 - -# -# -# - -END-VENDOR Freeswitch