diff --git a/LICENSE b/LICENSE index 5e21ee41bc..4762129004 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 2fca547d53..a403af6d93 100755 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -32,7 +32,6 @@ applications/mod_httapi #applications/mod_oreka #applications/mod_osp #applications/mod_prefix -#applications/mod_rad_auth applications/mod_signalwire applications/mod_sms #applications/mod_snapshot @@ -90,7 +89,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 @@ -118,7 +116,6 @@ loggers/mod_console #loggers/mod_graylog2 loggers/mod_logfile loggers/mod_syslog -#loggers/mod_raven #say/mod_say_de say/mod_say_en #say/mod_say_es @@ -142,7 +139,6 @@ say/mod_say_en xml_int/mod_xml_cdr #xml_int/mod_xml_curl #xml_int/mod_xml_ldap -#xml_int/mod_xml_radius xml_int/mod_xml_rpc xml_int/mod_xml_scgi diff --git a/build/modules.conf.most b/build/modules.conf.most index 204170ec74..3f0248e039 100755 --- a/build/modules.conf.most +++ b/build/modules.conf.most @@ -32,7 +32,6 @@ applications/mod_nibblebill applications/mod_oreka #applications/mod_osp applications/mod_prefix -#applications/mod_rad_auth applications/mod_signalwire applications/mod_sms applications/mod_snapshot @@ -88,7 +87,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 @@ -136,6 +134,5 @@ timers/mod_timerfd xml_int/mod_xml_cdr xml_int/mod_xml_curl xml_int/mod_xml_ldap -#xml_int/mod_xml_radius xml_int/mod_xml_rpc xml_int/mod_xml_scgi diff --git a/conf/vanilla/autoload_configs/modules.conf.xml b/conf/vanilla/autoload_configs/modules.conf.xml index 0c3c99c710..8f7fa9285f 100755 --- a/conf/vanilla/autoload_configs/modules.conf.xml +++ b/conf/vanilla/autoload_configs/modules.conf.xml @@ -16,7 +16,6 @@ - diff --git a/configure.ac b/configure.ac index df5f7e2e07..fdfffd481f 100755 --- a/configure.ac +++ b/configure.ac @@ -2118,7 +2118,6 @@ AC_CONFIG_FILES([Makefile src/mod/applications/mod_oreka/Makefile src/mod/applications/mod_osp/Makefile src/mod/applications/mod_prefix/Makefile - src/mod/applications/mod_rad_auth/Makefile src/mod/applications/mod_random/Makefile src/mod/applications/mod_skel/Makefile src/mod/applications/mod_signalwire/Makefile @@ -2181,7 +2180,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 @@ -2209,7 +2207,6 @@ AC_CONFIG_FILES([Makefile src/mod/loggers/mod_graylog2/Makefile src/mod/loggers/mod_logfile/Makefile src/mod/loggers/mod_syslog/Makefile - src/mod/loggers/mod_raven/Makefile src/mod/say/mod_say_de/Makefile src/mod/say/mod_say_en/Makefile src/mod/say/mod_say_es/Makefile @@ -2233,7 +2230,6 @@ AC_CONFIG_FILES([Makefile src/mod/xml_int/mod_xml_cdr/Makefile src/mod/xml_int/mod_xml_curl/Makefile src/mod/xml_int/mod_xml_ldap/Makefile - src/mod/xml_int/mod_xml_radius/Makefile src/mod/xml_int/mod_xml_rpc/Makefile src/mod/xml_int/mod_xml_scgi/Makefile src/mod/applications/mod_av/Makefile diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index 6c0ea0b7b7..e59092b9f3 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -36,7 +36,6 @@ avoid_mods=( applications/mod_limit applications/mod_mongo applications/mod_osp - applications/mod_rad_auth applications/mod_skel applications/mod_cluechoo codecs/mod_com_g729 @@ -52,7 +51,6 @@ avoid_mods=( formats/mod_webm sdk/autotools xml_int/mod_xml_ldap - xml_int/mod_xml_radius ) avoid_mods_armhf=( languages/mod_v8 @@ -81,17 +79,14 @@ avoid_mods_wheezy=( ) avoid_mods_trusty=( event_handlers/mod_amqp - loggers/mod_raven ) avoid_mods_utopic=( directories/mod_ldap - loggers/mod_raven ) avoid_mods_xenial=( event_handlers/mod_ldap event_handlers/mod_amqp asr_tts/mod_flite - loggers/mod_raven ) manual_pkgs=( freeswitch-all diff --git a/debian/control-modules b/debian/control-modules index b07499cbad..bcb3558622 100755 --- a/debian/control-modules +++ b/debian/control-modules @@ -164,10 +164,6 @@ Description: Longest prefix match search This module provides a data store with fast lookups by the longest prefix match (LPM) rule. -Module: applications/mod_rad_auth -Description: RADIUS AA - This module implements RADIUS Authentication and Authorization. - Module: applications/mod_random Description: Entropy extraction This module extracts entropy from FreeSWITCH and feeds it into @@ -463,10 +459,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. @@ -705,10 +697,6 @@ Description: mod_xml_ldap Adds mod_xml_ldap. Build-Depends: libldap2-dev, libsasl2-dev -Module: xml_int/mod_xml_radius -Description: mod_xml_radius - Adds mod_xml_radius - Module: xml_int/mod_xml_rpc Description: mod_xml_rpc Adds mod_xml_rpc. diff --git a/debian/copyright b/debian/copyright index 80bb23c70f..6a63ab7383 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/debian/util.sh b/debian/util.sh index dab53b1d47..c82e681d23 100755 --- a/debian/util.sh +++ b/debian/util.sh @@ -105,7 +105,6 @@ getlibs () { getlib http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz #getlib http://download.zeromq.org/zeromq-2.1.9.tar.gz \ # || getlib http://download.zeromq.org/historic/zeromq-2.1.9.tar.gz - getlib http://files.freeswitch.org/downloads/libs/freeradius-client-1.1.7.tar.gz #getlib http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2 } diff --git a/freeswitch.spec b/freeswitch.spec index 67f4a93046..fce2403ba4 100755 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -110,10 +110,9 @@ Vendor: http://www.freeswitch.org/ # ###################################################################################################################### Source0: http://files.freeswitch.org/%{name}-%{nonparsedversion}.tar.bz2 -Source1: http://files.freeswitch.org/downloads/libs/freeradius-client-1.1.7.tar.gz -Source2: http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz -Source3: http://files.freeswitch.org/downloads/libs/pocketsphinx-0.8.tar.gz -Source4: http://files.freeswitch.org/downloads/libs/sphinxbase-0.8.tar.gz +Source1: http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz +Source2: http://files.freeswitch.org/downloads/libs/pocketsphinx-0.8.tar.gz +Source3: http://files.freeswitch.org/downloads/libs/sphinxbase-0.8.tar.gz Prefix: %{prefix} @@ -451,14 +450,6 @@ Provides FreeSWITCH mod_nibblebill, provides a credit/debit module for FreeSWITCH to allow real-time debiting of credit or cash from a database while calls are in progress. -%package application-rad_auth -Summary: FreeSWITCH mod_rad_auth -Group: System/Libraries -Requires: %{name} = %{version}-%{release} - -%description application-rad_auth -Provides FreeSWITCH mod_rad_auth, authentication via RADIUS protocol from FreeSWITCH dialplan - %package application-signalwire Summary: FreeSWITCH mod_signalwire Group: System/Libraries @@ -862,14 +853,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 @@ -1251,7 +1234,8 @@ APPLICATION_MODULES_DE+="applications/mod_esl" APPLICATION_MODULES_FR="applications/mod_fifo applications/mod_fsk applications/mod_fsv applications/mod_hash \ applications/mod_httapi applications/mod_http_cache applications/mod_lcr applications/mod_limit \ - applications/mod_memcache applications/mod_mongo applications/mod_nibblebill applications/mod_rad_auth" + applications/mod_memcache applications/mod_mongo applications/mod_nibblebill" + APPLICATION_MODULES_SZ="applications/mod_signalwire applications/mod_sms applications/mod_snapshot \ applications/mod_spandsp applications/mod_spy \ @@ -1316,7 +1300,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 @@ -1898,9 +1882,6 @@ fi %files application-nibblebill %{MODINSTDIR}/mod_nibblebill.so* -%files application-rad_auth -%{MODINSTDIR}/mod_rad_auth.so* - %files application-signalwire %{MODINSTDIR}/mod_signalwire.so* @@ -2062,9 +2043,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/libs/.gitignore b/libs/.gitignore index d2cbc6b7df..def72ad13e 100644 --- a/libs/.gitignore +++ b/libs/.gitignore @@ -57,7 +57,6 @@ opal /esl/Debug/ /esl/Release/ /flite-*/ -/freeradius-client-*/ /ilbc/config-h.in /ilbc/doc/Makefile /ilbc/doc/Makefile.in diff --git a/src/mod/applications/mod_rad_auth/Makefile.am b/src/mod/applications/mod_rad_auth/Makefile.am deleted file mode 100644 index 05f7155a80..0000000000 --- a/src/mod/applications/mod_rad_auth/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_rad_auth - -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_rad_auth.la -mod_rad_auth_la_SOURCES = mod_rad_auth.c -mod_rad_auth_la_CFLAGS = $(AM_CFLAGS) -I$(RADCLIENT_DIR)/include -mod_rad_auth_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(RADCLIENT_LA) -mod_rad_auth_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/applications/mod_rad_auth/mod_rad_auth.c b/src/mod/applications/mod_rad_auth/mod_rad_auth.c deleted file mode 100644 index a4d43d545d..0000000000 --- a/src/mod/applications/mod_rad_auth/mod_rad_auth.c +++ /dev/null @@ -1,936 +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): -* -* Anthony Minessale II -* Neal Horman -* Tihomir Culjaga -* -* mod_rad_auth.c -- module for radius authorization/authentication -* -*/ -#include -#include - -#define RC_CONFIG_FILE "/usr/local/etc/radiusclient/radiusclient.conf" -#define EMBENDED_CONFIG 1 - -#define STR_LENGTH 512 -char* rc_config_file = NULL; - -struct config_vsas -{ - char* name; - int id; - char* value; - int pec; - int expr; - int direction; - - struct config_vsas *pNext; -}; - -struct config_client -{ - char* name; - char* value; - - struct config_client *pNext; -}; - -typedef struct config_vsas CONFIG_VSAS; -typedef struct config_client CONFIG_CLIENT; - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rad_authshutdown); -SWITCH_MODULE_RUNTIME_FUNCTION(mod_rad_authruntime); -SWITCH_MODULE_LOAD_FUNCTION(mod_rad_authload); -SWITCH_MODULE_DEFINITION(mod_rad_auth, mod_rad_authload, mod_rad_authshutdown, NULL /*mod_rad_authruntime*/); - -CONFIG_VSAS* CONFIGVSAS; -CONFIG_CLIENT* CONFIGCLIENT; - -void free_radius_auth_value_pair(VALUE_PAIR *send, VALUE_PAIR *received, rc_handle *rh) -{ - if (send) - rc_avpair_free(send); - - if (received) - rc_avpair_free(received); - - if (rh) - rc_destroy(rh); - rh = NULL; -} - -char* extract_in_variable(char* invar) -{ - char *var = NULL; - if (strlen(invar) < 4) - return NULL; - - while (invar[0] == ' ') - invar++; - - if (invar[0] != 'i' && invar[0] != 'I' && invar[1] != 'n' && invar[1] - != 'N' && invar[2] != ' ' && invar[2] != ' ') - { - return NULL; - } - - var = strchr(invar, ' '); - - while (var[0] == ' ') - var++; - - return var; -} - -char* extract_out_variable(char* outvar) -{ - char *var = NULL; - if (strlen(outvar) < 5) - return NULL; - - while (outvar[0] == ' ') - outvar++; - - if (outvar[0] != 'o' && outvar[0] != 'O' && outvar[1] != 'u' && outvar[1] - != 'U' && outvar[2] != 't' && outvar[2] != 'T' && outvar[3] != ' ' - && outvar[3] != ' ') - { - return NULL; - } - - var = strchr(outvar, ' '); - - while (var[0] == ' ') - { - var++; - } - - return var; -} - - -CONFIG_VSAS* GetVSAS(char* key) -{ - CONFIG_VSAS* PCONFIGVSAS = CONFIGVSAS; - - while(PCONFIGVSAS) - { - if (strcmp(key, PCONFIGVSAS->name) == 0) - { - return PCONFIGVSAS; - } - - PCONFIGVSAS = PCONFIGVSAS->pNext; - } - - return NULL; -} - -char* GetValue(switch_channel_t *channel, CONFIG_VSAS* VSAS, char* value) -{ - if (VSAS == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal Error : VSAS is null object.\n"); - return ""; - } - - if (VSAS->value == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal Error : VSAS->value is null object.\n"); - return ""; - } - - if (VSAS->expr == 1) - { - const char* v = switch_channel_get_variable(channel, VSAS->value); - - if (v != NULL) - { - strcpy(value, v); - return value; - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Undefined channel variable: %s.\n", VSAS->value); - strcpy(value, ""); - return value; - } - } - else - { - strcpy(value, VSAS->value); - return value; - } -} - -int radius_auth_test(switch_channel_t *channel, char* username1, char* passwd1, char* auth_result, char* biling_model, char* credit_amount, char* currency, char* preffered_lang) -{ - int result; - char username[128]; - char passwd[AUTH_PASS_LEN + 1]; - VALUE_PAIR *send, *received; - uint32_t service; - char msg[4096], username_realm[256]; - char *default_realm; - rc_handle *rh; - - strcpy(username, "123"); - strcpy(passwd, "123"); - - if ((rh = rc_read_config(RC_CONFIG_FILE)) == NULL) - return ERROR_RC; - - if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) - return ERROR_RC; - - default_realm = rc_conf_str(rh, "default_realm"); - - - send = NULL; - - /* - * Fill in User-Name - */ - - strncpy(username_realm, username, sizeof(username_realm)); - - /* Append default realm */ - if ((strchr(username_realm, '@') == NULL) && default_realm && - (*default_realm != '\0')) - { - strncat(username_realm, "@", sizeof(username_realm)-strlen(username_realm)-1); - strncat(username_realm, default_realm, sizeof(username_realm)-strlen(username_realm)-1); - } - - if (rc_avpair_add(rh, &send, PW_USER_NAME, username_realm, -1, 0) == NULL) - return ERROR_RC; - - /* - * Fill in User-Password - */ - - if (rc_avpair_add(rh, &send, PW_USER_PASSWORD, passwd, -1, 0) == NULL) - return ERROR_RC; - - /* - * Fill in Service-Type - */ - - service = PW_AUTHENTICATE_ONLY; - if (rc_avpair_add(rh, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) - return ERROR_RC; - - result = rc_auth(rh, 0, send, &received, msg); - - if (result == OK_RC) - { - fprintf(stderr, "\"%s\" RADIUS Authentication OK\n", username); - } - else - { - fprintf(stderr, "\"%s\" RADIUS Authentication failure (RC=%i)\n", username, result); - } - - return result; - -} - -int radius_auth(switch_channel_t *channel, char* called_number, char* username, char* password , char* auth_result/*, char* biling_model, char* credit_amount, char* currency, char* preffered_lang*/) -{ - int result = OK_RC; - VALUE_PAIR *send = NULL; - VALUE_PAIR *received = NULL; - VALUE_PAIR *service_vp; - DICT_ATTR *pda; - CONFIG_VSAS* PCONFIGVSAS = NULL; - char *default_realm = NULL; - rc_handle *rh = NULL; - int attrid =0; - - char msg[STR_LENGTH * 10 + 1]; - char username_realm[STR_LENGTH + 1]; - char value[STR_LENGTH + 1]; - int integer; - - memset(msg, 0, STR_LENGTH * 10); - memset(username_realm, 0, STR_LENGTH); - - send = NULL; - - - - do - { - -#if EMBENDED_CONFIG - - CONFIG_CLIENT* PCONFIGCLIENT = CONFIGCLIENT; - - rh = rc_new(); - if (rh == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Failed to allocate initial structure.\n"); - result = ERROR_RC; - break; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "allocate initial structure.\n"); - - /* Initialize the config structure */ - - rh = rc_config_init(rh); - if (rh == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"ERROR: Failed to initialze configuration.\n"); - result = ERROR_RC; - break; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"initialzed configuration.\n"); - - while(PCONFIGCLIENT) - { - //if (rc_add_config(rh, "auth_order", "radius", "config", 0) != 0) - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "set %s := %s.\n", PCONFIGCLIENT->name, PCONFIGCLIENT->value); - if (rc_add_config(rh, PCONFIGCLIENT->name, PCONFIGCLIENT->value, "config", 0) != 0) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: Unable to set %s := %s.\n", PCONFIGCLIENT->name, PCONFIGCLIENT->value); - - result = ERROR_RC; - break; - } - - PCONFIGCLIENT = PCONFIGCLIENT->pNext; - } - - if (result == ERROR_RC) - break; - - -#else - if ((rh = rc_read_config(!rc_config_file ? RC_CONFIG_FILE : rc_config_file)) == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading radius config file\n"); - - result = ERROR_RC; - break; - } - -#endif - - if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading radius dictionary\n"); - - result = ERROR_RC; - break; - } - - default_realm = rc_conf_str(rh, "default_realm"); - if (default_realm == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "default_realm is null object.\n"); - result = ERROR_RC; - break; - } - - strncpy(username_realm, username, sizeof(username_realm)); - - if ((strchr(username_realm, '@') == NULL) && default_realm && - (*default_realm != '\0')) - { - strncat(username_realm, "@", sizeof(username_realm)-strlen(username_realm)-1); - strncat(username_realm, default_realm, sizeof(username_realm)-strlen(username_realm)-1); - } - - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "... radius: User-Name: %s\n", username); - if (rc_avpair_add(rh, &send, PW_USER_NAME, username_realm, -1, 0)== NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : username\n"); - result = ERROR_RC; - break; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "... radius: User-Password: %s\n", password); - if (rc_avpair_add(rh, &send, PW_USER_PASSWORD, password, -1, 0) == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : password\n"); - result = ERROR_RC; - break; - } - - if (!called_number || strcmp(called_number, "") == 0) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "... radius: Called-station-Id is empty, ignoring...\n"); - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "... radius: Called-station-Id: %s\n", called_number); - if (rc_avpair_add(rh, &send, 30, called_number, -1, 0) == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : Called-station-Id\n"); - result = ERROR_RC; - break; - } - } - - - PCONFIGVSAS = CONFIGVSAS; - - while(PCONFIGVSAS) - { - if (PCONFIGVSAS->direction == 1) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle attribute: %s\n", PCONFIGVSAS->name ); - - memset(value, 0, STR_LENGTH); - GetValue(channel, PCONFIGVSAS, value); - - if (PCONFIGVSAS->pec != 0) - attrid = PCONFIGVSAS->id | (PCONFIGVSAS->pec << 16); - else - attrid = PCONFIGVSAS->id ; - - pda = rc_dict_getattr(rh, attrid); - - if (pda == NULL) - { - result = ERROR_RC; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown attribute: key:%s, not found in dictionary\n", PCONFIGVSAS->name); - break; - } - - if (PCONFIGVSAS->pec != 0 && rc_dict_getvend(rh, PCONFIGVSAS->pec) == NULL) - { - result = ERROR_RC; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown vendor specific id: key:%s, id:%dnot found in dictionary\n", PCONFIGVSAS->name, PCONFIGVSAS->pec); - break; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... dictionary data: id:%d, vendor id:%d, attr type:%d, attr name:%s (%d)\n", PCONFIGVSAS->id, PCONFIGVSAS->pec, pda->type, pda->name, attrid); - - switch(pda->type) - { - case PW_TYPE_STRING: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... radius: key:%s, value:%s (%s) as string\n", PCONFIGVSAS->name, PCONFIGVSAS->value, value); - if (rc_avpair_add(rh, &send, PCONFIGVSAS->id, value, -1, PCONFIGVSAS->pec) == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : %s\n", PCONFIGVSAS->name); - result = ERROR_RC; - break; - } - break; - - //case PW_TYPE_DATE: - case PW_TYPE_INTEGER: - integer = atoi(value); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... radius: key:%s, value:%s (%d) as integer\n", PCONFIGVSAS->name, PCONFIGVSAS->value, integer); - - - if (rc_avpair_add(rh, &send, PCONFIGVSAS->id, &integer, -1, PCONFIGVSAS->pec) == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : %s\n", PCONFIGVSAS->name); - result = ERROR_RC; - break; - } - break; - case PW_TYPE_IPADDR: - integer = rc_get_ipaddr(value); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "... radius: key:%s, value:%s (%d) as ipaddr\n", PCONFIGVSAS->name, PCONFIGVSAS->value, integer); - - - if (rc_avpair_add(rh, &send, PCONFIGVSAS->id, &integer, -1, PCONFIGVSAS->pec) == NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "An Error occured during rc_avpair_add : %s\n", PCONFIGVSAS->name); - result = ERROR_RC; - break; - } - break; - - default: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown attribute type: key:%s, type %d\n", PCONFIGVSAS->name, pda->type); - break; - } - } - - PCONFIGVSAS = PCONFIGVSAS->pNext; - } - - - if (result != ERROR_RC) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "sending radius packet ...\n" ); - result = rc_auth(rh, 0, send, &received, msg); - - - if (result == OK_RC) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "RADIUS Authentication OK\n"); - - strcpy(auth_result, "OK"); - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - " RADIUS Authentication failure (RC=%d)\n", - result); - - strcpy(auth_result, "NOK"); - } - - - - PCONFIGVSAS = CONFIGVSAS; - - while(PCONFIGVSAS) - { - if (PCONFIGVSAS->direction == 0) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handle attribute: %s\n", PCONFIGVSAS->name ); - if ((service_vp = rc_avpair_get(received, PCONFIGVSAS->id, PCONFIGVSAS->pec)) != NULL) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tattribute (%s) found in radius packet\n", PCONFIGVSAS->name); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tset variable %s := %s\n", PCONFIGVSAS->value, service_vp->strvalue); - - switch_channel_set_variable(channel, PCONFIGVSAS->value, service_vp->strvalue); - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\tNo found out attribute id: %d, pec:%d, (%s)\n", PCONFIGVSAS->id, PCONFIGVSAS->pec, PCONFIGVSAS->name ); - } - } - - PCONFIGVSAS = PCONFIGVSAS->pNext; - } - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "abort sending radius packet.\n" ); - break; - } - - } while(1 == 0); - - if (result == ERROR_RC) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "An error occured during RADIUS Authentication(RC=%d)\n", - result); - } - - free_radius_auth_value_pair(send, received, rh); - - return result; -} - -SWITCH_STANDARD_APP(auth_function) -{ - char* in_called_number = NULL; - char *in_username = NULL; - char *in_password = NULL; - - char *out_auth_result = NULL; - /*char *out_biling_model = NULL; - char *out_credit_amount = NULL; - char *out_currency = NULL; - char *out_preffered_lang = NULL;*/ - - char auth_result[STR_LENGTH + 1]; - /*char biling_model[STR_LENGTH + 1]; - char credit_amount[STR_LENGTH + 1]; - char currency[STR_LENGTH + 1]; - char preffered_lang[STR_LENGTH + 1];*/ - - switch_channel_t *channel = switch_core_session_get_channel(session); - - memset(auth_result, 0, STR_LENGTH); - /*memset(biling_model, 0, STR_LENGTH); - memset(credit_amount, 0, STR_LENGTH); - memset(currency, 0, STR_LENGTH); - memset(preffered_lang, 0, STR_LENGTH);*/ - - if (switch_strlen_zero(data)) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "No variable name specified.\n"); - } - else - { - - char *in_called_number_expanded = NULL; - char *in_username_expanded = NULL; - char *in_password_expanded = NULL; - - - in_called_number = switch_core_session_strdup(session, data); - - in_username = strchr(in_called_number, ','); - - if (in_username) - { - *in_username++ = '\0'; - if (switch_strlen_zero(in_username)) - { - in_username = NULL; - } - } - - in_password = strchr(in_username, ','); - - if (in_password) - { - *in_password++ = '\0'; - if (switch_strlen_zero(in_password)) - { - in_password = NULL; - } - } - - out_auth_result = strchr(in_password, ','); - - if (out_auth_result) - { - *out_auth_result++ = '\0'; - if (switch_strlen_zero(out_auth_result)) - { - out_auth_result = NULL; - } - } - - /*out_biling_model = strchr(out_auth_result, ','); - - if (out_biling_model) - { - *out_biling_model++ = '\0'; - if (switch_strlen_zero(out_biling_model)) - { - out_biling_model = NULL; - } - } - - out_credit_amount = strchr(out_biling_model, ','); - - if (out_credit_amount) - { - *out_credit_amount++ = '\0'; - if (switch_strlen_zero(out_credit_amount)) - { - out_credit_amount = NULL; - } - } - - out_currency = strchr(out_credit_amount, ','); - - if (out_currency) - { - *out_currency++ = '\0'; - if (switch_strlen_zero(out_currency)) - { - out_currency = NULL; - } - } - - out_preffered_lang = strchr(out_currency, ','); - - if (out_preffered_lang) - { - *out_preffered_lang++ = '\0'; - if (switch_strlen_zero(out_preffered_lang)) - { - out_preffered_lang = NULL; - } - }*/ - - if (in_called_number) - in_called_number = extract_in_variable(in_called_number); - - in_username = extract_in_variable(in_username); - in_password = extract_in_variable(in_password); - out_auth_result = extract_out_variable(out_auth_result); - /*out_biling_model = extract_out_variable(out_biling_model); - out_credit_amount = extract_out_variable(out_credit_amount); - out_currency = extract_out_variable(out_currency); - out_preffered_lang = extract_out_variable(out_preffered_lang);*/ - - if (!in_username || !in_password) - { - //todo: throw Exception - switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Syntax error.\n" ); - return; - } - - if (in_called_number) - in_called_number_expanded = switch_channel_expand_variables(channel, in_called_number); - - in_username_expanded = switch_channel_expand_variables(channel, in_username); - in_password_expanded = switch_channel_expand_variables(channel, in_password); - - - if (radius_auth(channel, in_called_number_expanded, in_username_expanded, in_password_expanded , - auth_result/*, biling_model, credit_amount, currency, preffered_lang*/) != OK_RC) - { - switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "An error occured during radius authorization.\n"); - } - - - switch_channel_set_variable(channel, out_auth_result, auth_result); - - /*switch_channel_set_variable(channel, out_biling_model, biling_model); - switch_channel_set_variable(channel, out_credit_amount, credit_amount); - switch_channel_set_variable(channel, out_currency, currency); - switch_channel_set_variable(channel, out_preffered_lang, preffered_lang);*/ - - if (in_called_number && in_called_number_expanded && in_called_number_expanded != in_called_number) - { - switch_safe_free(in_called_number_expanded); - } - - if (in_username_expanded && in_username_expanded != in_username) - { - switch_safe_free(in_username_expanded); - } - - if (in_password_expanded && in_password_expanded != in_password) - { - switch_safe_free(in_password_expanded); - } - } -} - - - - -switch_status_t load_config() -{ - CONFIG_VSAS* PCONFIGVSAS = NULL; - CONFIG_CLIENT* PCONFIGCLIENT = NULL; - - char *cf = "rad_auth.conf"; - switch_xml_t cfg, xml, settings, param; - switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_event_t *params = NULL; - - char *name; - char *id; - char *value; - char *pec; - char *expr; - char* direction; - - CONFIGVSAS = NULL; - CONFIGCLIENT = NULL; - - switch_event_create(¶ms, SWITCH_EVENT_MESSAGE); - switch_assert(params); - switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "profile", - "profile_rad_auth"); - - //vsas - - if (!(xml = switch_xml_open_cfg(cf, &cfg, params))) - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "open of %s failed\n", cf); - status = SWITCH_STATUS_FALSE; - return status; - } - - if ((settings = switch_xml_child(cfg, "settings"))) - { - for (param = switch_xml_child(settings, "param"); param; param - = param->next) - { - name = (char *) switch_xml_attr_soft(param, "name"); - value = (char *) switch_xml_attr_soft(param, "value"); - - if (strcmp(name, "radius_config") == 0) - { - if (rc_config_file == NULL) - rc_config_file = malloc(STR_LENGTH + 1); - strcpy(rc_config_file, value); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "radius config: %s\n", value); - } - } - } - - if ((settings = switch_xml_child(cfg, "vsas"))) - { - for (param = switch_xml_child(settings, "param"); param; param - = param->next) - { - if (CONFIGVSAS == NULL) - { - CONFIGVSAS = malloc(sizeof(CONFIG_VSAS)); - PCONFIGVSAS = CONFIGVSAS; - } - else - { - PCONFIGVSAS->pNext = malloc(sizeof(CONFIG_VSAS)); - PCONFIGVSAS = PCONFIGVSAS->pNext; - } - - name = (char *) switch_xml_attr_soft(param, "name"); - id = (char *) switch_xml_attr_soft(param, "id"); - value = (char *) switch_xml_attr_soft(param, "value"); - pec = (char *) switch_xml_attr_soft(param, "pec"); - expr = (char *) switch_xml_attr_soft(param, "expr"); - direction = (char *) switch_xml_attr_soft(param, "direction"); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "config attr: %s, %s, %s, %s, %s, %s\n", name, id, value, pec, expr, direction); - - PCONFIGVSAS->name = (char*) malloc(STR_LENGTH + 1); - PCONFIGVSAS->value = (char*) malloc(STR_LENGTH + 1); - - strncpy(PCONFIGVSAS->name, name, STR_LENGTH); - strncpy(PCONFIGVSAS->value, value, STR_LENGTH); - PCONFIGVSAS->id = atoi(id); - PCONFIGVSAS->pec = atoi(pec); - PCONFIGVSAS->expr = atoi(expr); - if(strcmp(direction, "in") == 0) - PCONFIGVSAS->direction = 1; - else - PCONFIGVSAS->direction = 0; - PCONFIGVSAS->pNext = NULL; - } - } - - - if ((settings = switch_xml_child(cfg, "client"))) - { - for (param = switch_xml_child(settings, "param"); param; param - = param->next) - { - if (CONFIGCLIENT == NULL) - { - CONFIGCLIENT = malloc(sizeof(CONFIG_CLIENT)); - PCONFIGCLIENT = CONFIGCLIENT; - } - else - { - PCONFIGCLIENT->pNext = malloc(sizeof(CONFIG_CLIENT)); - PCONFIGCLIENT = PCONFIGCLIENT->pNext; - } - - name = (char *) switch_xml_attr_soft(param, "name"); - value = (char *) switch_xml_attr_soft(param, "value"); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "config client: %s, %s\n", name, value); - - PCONFIGCLIENT->name = (char*) malloc(STR_LENGTH + 1); - PCONFIGCLIENT->value = (char*) malloc(STR_LENGTH + 1); - - strncpy(PCONFIGCLIENT->name, name, STR_LENGTH); - strncpy(PCONFIGCLIENT->value, value, STR_LENGTH); - - PCONFIGCLIENT->pNext = NULL; - } - } - - switch_xml_free(xml); - return status; -} - - - - -SWITCH_MODULE_LOAD_FUNCTION(mod_rad_authload) -{ - switch_application_interface_t *app_interface; - - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - - SWITCH_ADD_APP(app_interface, "auth_function", NULL, NULL, auth_function, "in , in , out , out , out , out , out ", SAF_SUPPORT_NOMEDIA); - - load_config(); - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "mod rad_auth services is loaded.\n"); - - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_RUNTIME_FUNCTION(mod_rad_authruntime) -{ - return SWITCH_STATUS_TERM; -} - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rad_authshutdown) -{ - CONFIG_VSAS* PCONFIGVSAS = CONFIGVSAS; - CONFIG_CLIENT* PCONFIGCLIENT = CONFIGCLIENT; - - CONFIG_VSAS* tmpVSAS = NULL; - CONFIG_CLIENT* tmpCLIENT = NULL; - - while(PCONFIGVSAS) - { - if (PCONFIGVSAS->name) - free(PCONFIGVSAS->name); - PCONFIGVSAS->name = NULL; - - if (PCONFIGVSAS->value) - free(PCONFIGVSAS->value); - PCONFIGVSAS->value = NULL; - - tmpVSAS = PCONFIGVSAS; - PCONFIGVSAS = PCONFIGVSAS->pNext; - - free(tmpVSAS); - } - - CONFIGVSAS = NULL; - - - while(PCONFIGCLIENT) - { - if (PCONFIGCLIENT->name) - free(PCONFIGCLIENT->name); - PCONFIGCLIENT->name = NULL; - - if (PCONFIGCLIENT->value) - free(PCONFIGCLIENT->value); - PCONFIGCLIENT->value = NULL; - - tmpCLIENT = PCONFIGCLIENT; - PCONFIGCLIENT = PCONFIGCLIENT->pNext; - - free(tmpCLIENT); - } - - CONFIGCLIENT = NULL; - - return SWITCH_STATUS_SUCCESS; -} - - 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 diff --git a/src/mod/loggers/mod_raven/Makefile.am b/src/mod/loggers/mod_raven/Makefile.am deleted file mode 100644 index f62beb9081..0000000000 --- a/src/mod/loggers/mod_raven/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_raven - -mod_LTLIBRARIES = mod_raven.la -mod_raven_la_SOURCES = mod_raven.c -mod_raven_la_CFLAGS = $(AM_CFLAGS) -mod_raven_la_LIBADD = $(switch_builddir)/libfreeswitch.la -mod_raven_la_LDFLAGS = -avoid-version -module -no-undefined -shared diff --git a/src/mod/loggers/mod_raven/conf/autoload_configs/raven.conf.xml b/src/mod/loggers/mod_raven/conf/autoload_configs/raven.conf.xml deleted file mode 100644 index 95125e9e85..0000000000 --- a/src/mod/loggers/mod_raven/conf/autoload_configs/raven.conf.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/mod/loggers/mod_raven/mod_raven.c b/src/mod/loggers/mod_raven/mod_raven.c deleted file mode 100644 index 335294673c..0000000000 --- a/src/mod/loggers/mod_raven/mod_raven.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2010, James Martelletti - * - * 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 - * James Martelletti - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Tamas Cseke - * - * mod_raven.c -- Raven Logging - * - */ -#include -#include -#include - -#define RAVEN_ZLIB_CHUNK 16384 -#define RAVEN_VERSION "5" -#define RAVEN_UA "freeswitch-raven/1.0" - -SWITCH_MODULE_LOAD_FUNCTION(mod_raven_load); -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_raven_shutdown); -SWITCH_MODULE_DEFINITION(mod_raven, mod_raven_load, mod_raven_shutdown, NULL); - -static switch_status_t load_config(void); - -static struct { - char *uri; - char *key; - char *secret; - char *project; - switch_bool_t log_uuid; - switch_log_level_t log_level; -} globals; - -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_uri, globals.uri); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_key, globals.key); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_secret, globals.secret); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_project, globals.project); - -static switch_loadable_module_interface_t raven_module_interface = { - /*.module_name */ modname, - /*.endpoint_interface */ NULL, - /*.timer_interface */ NULL, - /*.dialplan_interface */ NULL, - /*.codec_interface */ NULL, - /*.application_interface */ NULL, - /*.api_interface */ NULL, - /*.file_interface */ NULL, - /*.speech_interface */ NULL, - /*.directory_interface */ NULL -}; - -static switch_status_t encode(const char *raw, int raw_len, char **encoded_out) -{ - z_stream stream; - unsigned char *encoded = NULL, *compressed = NULL; - int ret; - switch_size_t compressed_size = 0, compressed_len = 0, need_bytes; - - stream.zalloc = Z_NULL; - stream.zfree = Z_NULL; - stream.opaque = Z_NULL; - ret = deflateInit(&stream, Z_DEFAULT_COMPRESSION); - if (ret != Z_OK) { - return SWITCH_STATUS_FALSE; - } - - stream.next_in = (unsigned char *)raw; - stream.avail_in = raw_len; - - do { - compressed_size += RAVEN_ZLIB_CHUNK; - compressed = realloc(compressed, compressed_size + 1); - switch_assert(compressed != NULL); - - stream.avail_out = compressed_size - compressed_len; - stream.next_out = compressed + compressed_len; - - ret = deflate(&stream, Z_FINISH); - assert(ret != Z_STREAM_ERROR); - compressed_len = compressed_size - stream.avail_out; - } while (stream.avail_in != 0); - - deflateEnd(&stream); - - need_bytes = compressed_len * 3 + 1; - encoded = malloc(need_bytes); - switch_assert(encoded); - memset(encoded, 0, need_bytes); - switch_b64_encode(compressed, compressed_len, encoded, need_bytes); - - switch_safe_free(compressed); - - *encoded_out = (char *)encoded; - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t raven_capture(const char *userdata, const char *message, const char *level, const char *file, const char *func, int line) -{ - cJSON* json, *fingerprint; - char *raw_body; - char *encoded_body = NULL; - switch_time_t timestamp = switch_micro_time_now(); - switch_status_t status = SWITCH_STATUS_SUCCESS; - char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1]; - - switch_uuid_str(uuid, sizeof(uuid)); - json = cJSON_CreateObject(); - cJSON_AddStringToObject(json, "event_id", (const char *)uuid); - cJSON_AddNumberToObject(json, "timestamp", timestamp); - cJSON_AddStringToObject(json, "platform", RAVEN_UA); - cJSON_AddStringToObject(json, "project", globals.project); - cJSON_AddStringToObject(json, "server_name", switch_core_get_hostname()); - cJSON_AddStringToObject(json, "level", level); - - if (globals.log_uuid && !zstr(userdata)) { - cJSON_AddItemToObject(json, "message", cJSON_CreateStringPrintf("%s %s", userdata, message)); - } else { - cJSON_AddStringToObject(json, "message", message); - } - - fingerprint = cJSON_CreateArray(); - cJSON_AddItemToArray(fingerprint, cJSON_CreateString(file)); - cJSON_AddItemToArray(fingerprint, cJSON_CreateString(func)); - cJSON_AddItemToArray(fingerprint, cJSON_CreateNumber(line)); - cJSON_AddItemToObject(json, "fingerprint", fingerprint); - - raw_body = cJSON_PrintUnformatted(json); - - if ((status = encode(raw_body, strlen(raw_body), &encoded_body)) == SWITCH_STATUS_SUCCESS) { - int response; - CURL *curl_handle = switch_curl_easy_init(); - switch_curl_slist_t * list = NULL; - char *auth_header = switch_mprintf("X-Sentry-Auth: Sentry sentry_version=%s," - " sentry_client=%s," - " sentry_timestamp=%d," - " sentry_key=%s," - " sentry_secret=%s", - RAVEN_VERSION, RAVEN_UA, - timestamp, globals.key, globals.secret); - - char *url = switch_mprintf( "%s/api/%s/store/", globals.uri, globals.project); - switch_curl_easy_setopt(curl_handle, CURLOPT_URL,url); - switch_curl_easy_setopt(curl_handle, CURLOPT_POST, 1); - switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); - switch_curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, encoded_body); - switch_curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, strlen(encoded_body)); - - switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, RAVEN_UA); - - list = switch_curl_slist_append(list, auth_header); - list = switch_curl_slist_append(list, "Content-Type: application/octet-stream"); - switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, list); - - if (!strncasecmp(globals.uri, "https", 5)) { - switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); - switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); - } - - switch_curl_easy_perform(curl_handle); - switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &response); - - if (response != 200) { - status = SWITCH_STATUS_FALSE; - } - - switch_curl_easy_cleanup(curl_handle); - switch_curl_slist_free_all(list); - switch_safe_free(url); - switch_safe_free(auth_header); - } - - switch_safe_free(raw_body); - switch_safe_free(encoded_body); - cJSON_Delete(json); - - return status; -} - - -static switch_status_t mod_raven_logger(const switch_log_node_t *node, switch_log_level_t level) -{ - switch_status_t status = SWITCH_STATUS_SUCCESS; - - if (level != SWITCH_LOG_CONSOLE && !zstr(node->data)) { - const char * raven_level; - - switch (level) { - case SWITCH_LOG_DEBUG: - raven_level = "debug"; - break; - case SWITCH_LOG_INFO: - raven_level = "info"; - break; - case SWITCH_LOG_NOTICE: - case SWITCH_LOG_WARNING: - raven_level = "warning"; - break; - case SWITCH_LOG_ERROR: - raven_level = "error"; - break; - case SWITCH_LOG_CRIT: - case SWITCH_LOG_ALERT: - raven_level = "fatal"; - break; - default: - raven_level = "debug"; - break; - } - - status = raven_capture(node->userdata, node->data, raven_level, node->file, node->func, node->line); - } - - return status; -} - -static switch_status_t load_config(void) -{ - char *cf = "raven.conf"; - switch_xml_t cfg, xml, settings, param; - - globals.log_level = SWITCH_LOG_WARNING; - globals.log_uuid = SWITCH_TRUE; - - 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_FALSE; - } - - 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, "uri")) { - set_global_uri(val); - } else if (!strcmp(var, "key")) { - set_global_key(val); - } else if (!strcmp(var, "secret")) { - set_global_secret(val); - } else if (!strcmp(var, "project")) { - set_global_project(val); - } else if (!strcasecmp(var, "loglevel") && !zstr(val)) { - globals.log_level = switch_log_str2level(val); - if (globals.log_level == SWITCH_LOG_INVALID) { - globals.log_level = SWITCH_LOG_WARNING; - } - } else if (!strcasecmp(var, "uuid")) { - globals.log_uuid = switch_true(val); - } - } - } - switch_xml_free(xml); - - if (zstr(globals.uri) || zstr(globals.project) || zstr(globals.key) || zstr(globals.secret)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing parameter\n"); - return SWITCH_STATUS_FALSE; - } - - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_LOAD_FUNCTION(mod_raven_load) -{ - switch_status_t status; - *module_interface = &raven_module_interface; - - memset(&globals, 0, sizeof(globals)); - - if ((status = load_config()) != SWITCH_STATUS_SUCCESS) { - return status; - } - - switch_log_bind_logger(mod_raven_logger, globals.log_level, SWITCH_FALSE); - - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_raven_shutdown) -{ - switch_safe_free(globals.uri); - switch_safe_free(globals.key); - switch_safe_free(globals.secret); - switch_safe_free(globals.project); - - switch_log_unbind_logger(mod_raven_logger); - - 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/xml_int/mod_xml_radius/.gitignore b/src/mod/xml_int/mod_xml_radius/.gitignore deleted file mode 100644 index bb7ad3d288..0000000000 --- a/src/mod/xml_int/mod_xml_radius/.gitignore +++ /dev/null @@ -1 +0,0 @@ -freeradius-client* \ No newline at end of file diff --git a/src/mod/xml_int/mod_xml_radius/00_dialplan_auth.xml b/src/mod/xml_int/mod_xml_radius/00_dialplan_auth.xml deleted file mode 100644 index 2e17abbfdd..0000000000 --- a/src/mod/xml_int/mod_xml_radius/00_dialplan_auth.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/xml_int/mod_xml_radius/Makefile.am b/src/mod/xml_int/mod_xml_radius/Makefile.am deleted file mode 100644 index bfac0040c1..0000000000 --- a/src/mod/xml_int/mod_xml_radius/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_xml_radius - -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_xml_radius.la -mod_xml_radius_la_SOURCES = mod_xml_radius.c -mod_xml_radius_la_CFLAGS = $(AM_CFLAGS) -I$(RADCLIENT_DIR)/include -mod_xml_radius_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(RADCLIENT_LA) -mod_xml_radius_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/xml_int/mod_xml_radius/config.c.diff b/src/mod/xml_int/mod_xml_radius/config.c.diff deleted file mode 100644 index 962c1e5844..0000000000 --- a/src/mod/xml_int/mod_xml_radius/config.c.diff +++ /dev/null @@ -1,50 +0,0 @@ ---- ../../../../libs/freeradius-client-1.1.6/lib/config.c 2012-08-18 22:13:13.000000000 -0700 -+++ ./config.c 2012-08-18 22:14:08.000000000 -0700 -@@ -301,6 +301,8 @@ - int i; - SERVER *authservers; - SERVER *acctservers; -+ OPTION *acct; -+ OPTION *auth; - - rh->config_options = malloc(sizeof(config_options_default)); - if (rh->config_options == NULL) -@@ -311,8 +313,8 @@ - } - memcpy(rh->config_options, &config_options_default, sizeof(config_options_default)); - -- authservers = rc_conf_srv(rh, "authserver"); -- acctservers = rc_conf_srv(rh, "acctserver"); -+ acct = find_option(rh, "acctserver", OT_ANY); -+ auth = find_option(rh, "authserver", OT_ANY); - authservers = malloc(sizeof(SERVER)); - acctservers = malloc(sizeof(SERVER)); - -@@ -334,6 +336,8 @@ - acctservers->name[i] = NULL; - acctservers->secret[i] = NULL; - } -+ acct->val = acctservers; -+ auth->val = authservers; - return rh; - } - -@@ -894,11 +898,15 @@ - continue; - if (rh->config_options[i].type == OT_SRV) { - serv = (SERVER *)rh->config_options[i].val; -- for (j = 0; j < serv->max; j++) -+ for (j = 0; j < serv->max; j++) { - free(serv->name[j]); -- free(serv); -- } else { -+ free(serv->secret[j]); -+ } - free(rh->config_options[i].val); -+ rh->config_options[i].val = NULL; -+ -+ } else { -+ free(rh->config_options[i].val); - } - } - free(rh->config_options); diff --git a/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary b/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary deleted file mode 100644 index 431d92c544..0000000000 --- a/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary +++ /dev/null @@ -1,244 +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. -# -$INCLUDE /usr/local/src/freeswitch/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary.cisco -$INCLUDE /usr/local/src/freeswitch/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary.rfc5090 - -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 - - diff --git a/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary.cisco b/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary.cisco deleted file mode 100644 index b61c9d27cc..0000000000 --- a/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary.cisco +++ /dev/null @@ -1,161 +0,0 @@ -# -*- text -*- -# -# dictionary.cisco -# -# Accounting VSAs originally by -# "Marcelo M. Sosa Lugones" -# -# Version: $Id$ -# -# For documentation on Cisco RADIUS attributes, see: -# -# http://www.cisco.com/univercd/cc/td/doc/product/access/acs_serv/vapp_dev/vsaig3.htm -# -# For general documentation on Cisco RADIUS configuration, see: -# -# http://www.cisco.com/en/US/partner/tech/tk583/tk547/tsd_technology_support_sub-protocol_home.html -# - -VENDOR Cisco 9 - -# -# Standard attribute -# -#BEGIN-VENDOR Cisco - -ATTRIBUTE Cisco-AVPair 1 string vendor=Cisco -ATTRIBUTE Cisco-NAS-Port 2 string vendor=Cisco - -# -# T.37 Store-and-Forward attributes. -# -ATTRIBUTE Cisco-Fax-Account-Id-Origin 3 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Msg-Id 4 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Pages 5 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Coverpage-Flag 6 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Modem-Time 7 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Connect-Speed 8 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Recipient-Count 9 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Process-Abort-Flag 10 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Dsn-Address 11 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Dsn-Flag 12 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Mdn-Address 13 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Mdn-Flag 14 string vendor=Cisco -ATTRIBUTE Cisco-Fax-Auth-Status 15 string vendor=Cisco -ATTRIBUTE Cisco-Email-Server-Address 16 string vendor=Cisco -ATTRIBUTE Cisco-Email-Server-Ack-Flag 17 string vendor=Cisco -ATTRIBUTE Cisco-Gateway-Id 18 string vendor=Cisco -ATTRIBUTE Cisco-Call-Type 19 string vendor=Cisco -ATTRIBUTE Cisco-Port-Used 20 string vendor=Cisco -ATTRIBUTE Cisco-Abort-Cause 21 string vendor=Cisco - -# -# Voice over IP attributes. -# -ATTRIBUTE h323-remote-address 23 string vendor=Cisco -ATTRIBUTE h323-conf-id 24 string vendor=Cisco -ATTRIBUTE h323-setup-time 25 string vendor=Cisco -ATTRIBUTE h323-call-origin 26 string vendor=Cisco -ATTRIBUTE h323-call-type 27 string vendor=Cisco -ATTRIBUTE h323-connect-time 28 string vendor=Cisco -ATTRIBUTE h323-disconnect-time 29 string vendor=Cisco -ATTRIBUTE h323-disconnect-cause 30 string vendor=Cisco -ATTRIBUTE h323-voice-quality 31 string vendor=Cisco -ATTRIBUTE h323-gw-id 33 string vendor=Cisco -ATTRIBUTE h323-incoming-conf-id 35 string vendor=Cisco - -ATTRIBUTE Cisco-Policy-Up 37 string vendor=Cisco -ATTRIBUTE Cisco-Policy-Down 38 string vendor=Cisco - -ATTRIBUTE sip-conf-id 100 string vendor=Cisco -ATTRIBUTE h323-credit-amount 101 string vendor=Cisco -ATTRIBUTE h323-credit-time 102 string vendor=Cisco -ATTRIBUTE h323-return-code 103 string vendor=Cisco -ATTRIBUTE h323-prompt-id 104 string vendor=Cisco -ATTRIBUTE h323-time-and-day 105 string vendor=Cisco -ATTRIBUTE h323-redirect-number 106 string vendor=Cisco -ATTRIBUTE h323-preferred-lang 107 string vendor=Cisco -ATTRIBUTE h323-redirect-ip-address 108 string vendor=Cisco -ATTRIBUTE h323-billing-model 109 string vendor=Cisco -ATTRIBUTE h323-currency 110 string vendor=Cisco -ATTRIBUTE subscriber 111 string vendor=Cisco -ATTRIBUTE gw-rxd-cdn 112 string vendor=Cisco -ATTRIBUTE gw-final-xlated-cdn 113 string vendor=Cisco -ATTRIBUTE remote-media-address 114 string vendor=Cisco -ATTRIBUTE release-source 115 string vendor=Cisco -ATTRIBUTE gw-rxd-cgn 116 string vendor=Cisco -ATTRIBUTE gw-final-xlated-cgn 117 string vendor=Cisco - -# SIP Attributes -ATTRIBUTE call-id 141 string vendor=Cisco -ATTRIBUTE session-protocol 142 string vendor=Cisco -ATTRIBUTE method 143 string vendor=Cisco -ATTRIBUTE prev-hop-via 144 string vendor=Cisco -ATTRIBUTE prev-hop-ip 145 string vendor=Cisco -ATTRIBUTE incoming-req-uri 146 string vendor=Cisco -ATTRIBUTE outgoing-req-uri 147 string vendor=Cisco -ATTRIBUTE next-hop-ip 148 string vendor=Cisco -ATTRIBUTE next-hop-dn 149 string vendor=Cisco -ATTRIBUTE sip-hdr 150 string vendor=Cisco - -# -# Extra attributes sent by the Cisco, if you configure -# "radius-server vsa accounting" (requires IOS11.2+). -# -ATTRIBUTE Cisco-Multilink-ID 187 integer vendor=Cisco -ATTRIBUTE Cisco-Num-In-Multilink 188 integer vendor=Cisco -ATTRIBUTE Cisco-Pre-Input-Octets 190 integer vendor=Cisco -ATTRIBUTE Cisco-Pre-Output-Octets 191 integer vendor=Cisco -ATTRIBUTE Cisco-Pre-Input-Packets 192 integer vendor=Cisco -ATTRIBUTE Cisco-Pre-Output-Packets 193 integer vendor=Cisco -ATTRIBUTE Cisco-Maximum-Time 194 integer vendor=Cisco -ATTRIBUTE Cisco-Disconnect-Cause 195 integer vendor=Cisco -ATTRIBUTE Cisco-Data-Rate 197 integer vendor=Cisco -ATTRIBUTE Cisco-PreSession-Time 198 integer vendor=Cisco -ATTRIBUTE Cisco-PW-Lifetime 208 integer vendor=Cisco -ATTRIBUTE Cisco-IP-Direct 209 integer vendor=Cisco -ATTRIBUTE Cisco-PPP-VJ-Slot-Comp 210 integer vendor=Cisco -ATTRIBUTE Cisco-PPP-Async-Map 212 integer vendor=Cisco -ATTRIBUTE Cisco-IP-Pool-Definition 217 string vendor=Cisco -ATTRIBUTE Cisco-Assign-IP-Pool 218 integer vendor=Cisco -ATTRIBUTE Cisco-Route-IP 228 integer vendor=Cisco -ATTRIBUTE Cisco-Link-Compression 233 integer vendor=Cisco -ATTRIBUTE Cisco-Target-Util 234 integer vendor=Cisco -ATTRIBUTE Cisco-Maximum-Channels 235 integer vendor=Cisco -ATTRIBUTE Cisco-Data-Filter 242 integer vendor=Cisco -ATTRIBUTE Cisco-Call-Filter 243 integer vendor=Cisco -ATTRIBUTE Cisco-Idle-Limit 244 integer vendor=Cisco -ATTRIBUTE Cisco-Subscriber-Password 249 string vendor=Cisco -ATTRIBUTE Cisco-Account-Info 250 string vendor=Cisco -ATTRIBUTE Cisco-Service-Info 251 string vendor=Cisco -ATTRIBUTE Cisco-Command-Code 252 string vendor=Cisco -ATTRIBUTE Cisco-Control-Info 253 string vendor=Cisco -ATTRIBUTE Cisco-Xmit-Rate 255 integer vendor=Cisco - -VALUE Cisco-Disconnect-Cause Unknown 2 -VALUE Cisco-Disconnect-Cause CLID-Authentication-Failure 4 -VALUE Cisco-Disconnect-Cause No-Carrier 10 -VALUE Cisco-Disconnect-Cause Lost-Carrier 11 -VALUE Cisco-Disconnect-Cause No-Detected-Result-Codes 12 -VALUE Cisco-Disconnect-Cause User-Ends-Session 20 -VALUE Cisco-Disconnect-Cause Idle-Timeout 21 -VALUE Cisco-Disconnect-Cause Exit-Telnet-Session 22 -VALUE Cisco-Disconnect-Cause No-Remote-IP-Addr 23 -VALUE Cisco-Disconnect-Cause Exit-Raw-TCP 24 -VALUE Cisco-Disconnect-Cause Password-Fail 25 -VALUE Cisco-Disconnect-Cause Raw-TCP-Disabled 26 -VALUE Cisco-Disconnect-Cause Control-C-Detected 27 -VALUE Cisco-Disconnect-Cause EXEC-Program-Destroyed 28 -VALUE Cisco-Disconnect-Cause Timeout-PPP-LCP 40 -VALUE Cisco-Disconnect-Cause Failed-PPP-LCP-Negotiation 41 -VALUE Cisco-Disconnect-Cause Failed-PPP-PAP-Auth-Fail 42 -VALUE Cisco-Disconnect-Cause Failed-PPP-CHAP-Auth 43 -VALUE Cisco-Disconnect-Cause Failed-PPP-Remote-Auth 44 -VALUE Cisco-Disconnect-Cause PPP-Remote-Terminate 45 -VALUE Cisco-Disconnect-Cause PPP-Closed-Event 46 -VALUE Cisco-Disconnect-Cause Session-Timeout 100 -VALUE Cisco-Disconnect-Cause Session-Failed-Security 101 -VALUE Cisco-Disconnect-Cause Session-End-Callback 102 -VALUE Cisco-Disconnect-Cause Invalid-Protocol 120 - -#END-VENDOR Cisco diff --git a/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary.rfc5090 b/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary.rfc5090 deleted file mode 100644 index 4feda43628..0000000000 --- a/src/mod/xml_int/mod_xml_radius/dictionaries/dictionary.rfc5090 +++ /dev/null @@ -1,27 +0,0 @@ -# -*- text -*- -# -# Attributes and values defined in RFC 5090. -# http://www.ietf.org/rfc/rfc5090.txt -# -# $Id$ -# -ATTRIBUTE Digest-Response 103 string -ATTRIBUTE Digest-Realm 104 string -ATTRIBUTE Digest-Nonce 105 string -ATTRIBUTE Digest-Response-Auth 106 string -ATTRIBUTE Digest-Nextnonce 107 string -ATTRIBUTE Digest-Method 108 string -ATTRIBUTE Digest-URI 109 string -ATTRIBUTE Digest-Qop 110 string -ATTRIBUTE Digest-Algorithm 111 string -ATTRIBUTE Digest-Entity-Body-Hash 112 string -ATTRIBUTE Digest-CNonce 113 string -ATTRIBUTE Digest-Nonce-Count 114 string -ATTRIBUTE Digest-Username 115 string -ATTRIBUTE Digest-Opaque 116 string -ATTRIBUTE Digest-Auth-Param 117 string -ATTRIBUTE Digest-AKA-Auts 118 string -ATTRIBUTE Digest-Domain 119 string -ATTRIBUTE Digest-Stale 120 string -ATTRIBUTE Digest-HA1 121 string -ATTRIBUTE SIP-AOR 122 string diff --git a/src/mod/xml_int/mod_xml_radius/mod_xml_radius.c b/src/mod/xml_int/mod_xml_radius/mod_xml_radius.c deleted file mode 100644 index f35966145f..0000000000 --- a/src/mod/xml_int/mod_xml_radius/mod_xml_radius.c +++ /dev/null @@ -1,1237 +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): - * - * William King - * - * mod_xml_radius.c -- Radius authentication and authorization - * - */ -#include -#include - -static struct { - switch_memory_pool_t *pool; - switch_xml_t auth_invite_configs; - switch_xml_t auth_reg_configs; - switch_xml_t auth_app_configs; - switch_xml_t acct_start_configs; - switch_xml_t acct_end_configs; - /* xml read write lock */ -} globals = {0}; - -SWITCH_MODULE_LOAD_FUNCTION(mod_xml_radius_load); -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_radius_shutdown); -SWITCH_MODULE_DEFINITION(mod_xml_radius, mod_xml_radius_load, mod_xml_radius_shutdown, NULL); - -int GLOBAL_DEBUG = 0; -/* - * Time format 0: - * 20:16:33.479 UTC Thu May 02 2013 - * - * Time format 1: - * 2013-05-03T00:53:26.139798+0400 - * - */ -int GLOBAL_TIME_FORMAT = 0; -char *GLOBAL_TIME_ZONE = "UTC"; -static char radattrdays[7][4] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" -}; -static char radattrmonths[12][4] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; - -switch_status_t mod_xml_radius_new_handle(rc_handle **new_handle, switch_xml_t xml) { - switch_xml_t server, param; - - if ( (*new_handle = rc_new()) == NULL ) { - goto err; - } - - if ( rc_config_init(*new_handle) == NULL ) { - *new_handle = NULL; - goto err; - } - - if (rc_add_config(*new_handle, "auth_order", "radius", "mod_radius_cdr.c", 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding auth_order\n"); - goto err; - } - - if ((server = switch_xml_child(xml, "connection")) == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section in config file.\n"); - goto err; - } - - for (param = switch_xml_child(server, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - char *val = (char *) switch_xml_attr_soft(param, "value"); - - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Attempting to add param '%s' with value '%s' \n", var, val); - } - - if (strncmp(var, "dictionary", 10) == 0) { - if ( rc_read_dictionary(*new_handle, val) != 0) { - goto err; - } - } else if (rc_add_config(*new_handle, var, val, "mod_xml_radius", 0) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error adding param '%s' with value '%s' \n", var, val); - goto err; - } - } - - return SWITCH_STATUS_SUCCESS; - - err: - if ( *new_handle ) { - rc_destroy( *new_handle ); - *new_handle = NULL; - } - return SWITCH_STATUS_GENERR; -} - -switch_status_t do_config() -{ - char *conf = "xml_radius.conf"; - switch_xml_t xml, cfg, tmp, server, param; - int serv, timeout, deadtime, retries, dict, seq; - - /* TODO: - 1. Fix read/write lock on configs - a. read new configs - b. Create replacement xml and vas objects - c. Get the write lock. - d. Replace xml and vas objects - e. unlock and return. - 2. Don't manually check for proper configs. Use the function in the client library - 3. Add api that would reload configs - */ - - if (!(xml = switch_xml_open_cfg(conf, &cfg, NULL))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", conf); - goto err; - } - - serv = timeout = deadtime = retries = dict = seq = 0; - if ((tmp = switch_xml_dup(switch_xml_child(cfg, "auth_invite"))) != NULL ) { - if ( (server = switch_xml_child(tmp, "connection")) != NULL) { - for (param = switch_xml_child(server, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - if ( strncmp(var, "authserver", 10) == 0 ) { - serv = 1; - } else if ( strncmp(var, "radius_timeout", 14) == 0 ) { - timeout = 1; - } else if ( strncmp(var, "radius_deadtime", 15) == 0 ) { - deadtime = 1; - } else if ( strncmp(var, "radius_retries", 14) == 0 ) { - retries = 1; - } else if ( strncmp(var, "dictionary", 10) == 0 ) { - dict = 1; - } else if ( strncmp(var, "seqfile", 7) == 0 ) { - seq = 1; - } - } - - if ( serv && timeout && deadtime && retries && dict && seq ) { - globals.auth_invite_configs = tmp; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing a require section for radius connections\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_invite\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_invite' section in config file.\n"); - } - - serv = timeout = deadtime = retries = dict = seq = 0; - if ((tmp = switch_xml_dup(switch_xml_child(cfg, "auth_reg"))) != NULL ) { - if ( (server = switch_xml_child(tmp, "connection")) != NULL) { - for (param = switch_xml_child(server, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - if ( strncmp(var, "authserver", 10) == 0 ) { - serv = 1; - } else if ( strncmp(var, "radius_timeout", 14) == 0 ) { - timeout = 1; - } else if ( strncmp(var, "radius_deadtime", 15) == 0 ) { - deadtime = 1; - } else if ( strncmp(var, "radius_retries", 14) == 0 ) { - retries = 1; - } else if ( strncmp(var, "dictionary", 10) == 0 ) { - dict = 1; - } else if ( strncmp(var, "seqfile", 7) == 0 ) { - seq = 1; - } - } - - if ( serv && timeout && deadtime && retries && dict && seq ) { - globals.auth_reg_configs = tmp; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing a require section for radius connections\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_invite\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_reg' section in config file.\n"); - } - - if ((tmp = switch_xml_child(cfg, "global")) != NULL ) { - for (param = switch_xml_child(tmp, "param"); param; param = param->next) { - char *name = (char *) switch_xml_attr_soft(param, "name"); - char *value = (char *) switch_xml_attr_soft(param, "value"); - if ( strncmp(name, "time_format", 11) == 0 && value != NULL ) { - GLOBAL_TIME_FORMAT = atoi(value); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Time format changed to %d\n", GLOBAL_TIME_FORMAT); - } - if ( strncmp(name, "time_zone", 9) == 0 && value != NULL ) { - GLOBAL_TIME_ZONE = value; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Time zone changed to %s\n", GLOBAL_TIME_ZONE); - } - if ( strncmp(name, "debug", 5) == 0 && value != NULL ) { - GLOBAL_DEBUG = atoi(value); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Debug changed to %d\n", GLOBAL_DEBUG); - } - } - } - - serv = timeout = deadtime = retries = dict = seq = 0; - if ((tmp = switch_xml_dup(switch_xml_child(cfg, "auth_app"))) != NULL ) { - if ( (server = switch_xml_child(tmp, "connection")) != NULL) { - for (param = switch_xml_child(server, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - if ( strncmp(var, "authserver", 10) == 0 ) { - serv = 1; - } else if ( strncmp(var, "radius_timeout", 14) == 0 ) { - timeout = 1; - } else if ( strncmp(var, "radius_deadtime", 15) == 0 ) { - deadtime = 1; - } else if ( strncmp(var, "radius_retries", 14) == 0 ) { - retries = 1; - } else if ( strncmp(var, "dictionary", 10) == 0 ) { - dict = 1; - } else if ( strncmp(var, "seqfile", 7) == 0 ) { - seq = 1; - } - } - - if ( serv && timeout && deadtime && retries && dict && seq ) { - globals.auth_app_configs = tmp; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing a require section for radius connections\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for auth_app\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'auth_app' section in config file.\n"); - } - - serv = timeout = deadtime = retries = dict = seq = 0; - if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_start"))) != NULL ) { - if ( (server = switch_xml_child(tmp, "connection")) != NULL) { - for (param = switch_xml_child(server, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - if ( strncmp(var, "acctserver", 10) == 0 ) { - serv = 1; - } else if ( strncmp(var, "radius_timeout", 14) == 0 ) { - timeout = 1; - } else if ( strncmp(var, "radius_deadtime", 15) == 0 ) { - deadtime = 1; - } else if ( strncmp(var, "radius_retries", 14) == 0 ) { - retries = 1; - } else if ( strncmp(var, "dictionary", 10) == 0 ) { - dict = 1; - } else if ( strncmp(var, "seqfile", 7) == 0 ) { - seq = 1; - } - } - - if ( serv && timeout && deadtime && retries && dict && seq ) { - globals.acct_start_configs = tmp; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing a require section for radius connections\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for acct_start\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_start' section in config file.\n"); - } - - serv = timeout = deadtime = retries = dict = seq = 0; - if (( tmp = switch_xml_dup(switch_xml_child(cfg, "acct_end"))) != NULL ) { - if ( (server = switch_xml_child(tmp, "connection")) != NULL) { - for (param = switch_xml_child(server, "param"); param; param = param->next) { - char *var = (char *) switch_xml_attr_soft(param, "name"); - if ( strncmp(var, "acctserver", 10) == 0 ) { - serv = 1; - } else if ( strncmp(var, "radius_timeout", 14) == 0 ) { - timeout = 1; - } else if ( strncmp(var, "radius_deadtime", 15) == 0 ) { - deadtime = 1; - } else if ( strncmp(var, "radius_retries", 14) == 0 ) { - retries = 1; - } else if ( strncmp(var, "dictionary", 10) == 0 ) { - dict = 1; - } else if ( strncmp(var, "seqfile", 7) == 0 ) { - seq = 1; - } - } - - if ( serv && timeout && deadtime && retries && dict && seq ) { - globals.acct_end_configs = tmp; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing a require section for radius connections\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'connection' section for acct_end\n"); - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Could not find 'acct_end' section in config file.\n"); - } - - if ( xml ) { - switch_xml_free(xml); - xml = NULL; - } - - return SWITCH_STATUS_SUCCESS; - - err: - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Configuration error\n"); - if ( xml ) { - switch_xml_free(xml); - xml = NULL; - } - - return SWITCH_STATUS_GENERR; -} - -switch_status_t mod_xml_radius_add_params(switch_core_session_t *session, switch_event_t *params, rc_handle *handle, VALUE_PAIR **send, switch_xml_t fields) -{ - switch_xml_t param; - void *av_value = NULL; - - if ( (param = switch_xml_child(fields, "param")) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a param under the fields section\n"); - goto err; - } - - for (; param; param = param->next) { - DICT_ATTR *attribute = NULL; - DICT_VENDOR *vendor = NULL; - int attr_num = 0, vend_num = 0; - - char *var = (char *) switch_xml_attr(param, "name"); - char *vend = (char *) switch_xml_attr(param, "vendor"); - char *variable = (char *) switch_xml_attr(param, "variable"); - char *variable_secondary = (char *) switch_xml_attr(param, "variable_secondary"); - char *val_default = (char *) switch_xml_attr(param, "default"); - char *skip_if_set = (char *) switch_xml_attr(param, "skip_if_set"); - char *format = (char *) switch_xml_attr(param, "format"); - char *other_leg = (char *) switch_xml_attr(param, "other_leg"); - char *regex = (char *) switch_xml_attr(param, "regex"); - - attribute = rc_dict_findattr(handle, var); - - if ( attribute == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Could not locate attribute '%s' in the configured dictionary\n", var); - goto err; - } - - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict attr '%s' value '%d' type '%d'\n", - attribute->name, attribute->value, attribute->type); - } - - attr_num = attribute->value; - - if ( vend ) { - vendor = rc_dict_findvend(handle, vend); - - if ( vendor == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Could not locate vendor '%s' in the configured dictionary %p\n", - vend, vend); - goto err; - } - - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: dict vend name '%s' vendorpec '%d'\n", - vendor->vendorname, vendor->vendorpec); - } - - vend_num = vendor->vendorpec; - } - - if ( var ) { - if ( session ) { - switch_channel_t *channel = switch_core_session_get_channel(session); - if ( skip_if_set && switch_channel_get_variable(channel, skip_if_set) ) { - goto end_loop; - } - - /* Accounting only */ - if ( strncmp( var, "h323-setup-time", 15) == 0 ) { - switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel); - switch_time_t time = profile->times->created; - switch_time_exp_t tm; - - if ( !time ) { - goto end_loop; - } - - switch_time_exp_lt(&tm, time); - - if ( GLOBAL_TIME_FORMAT == 1 ) { - av_value = switch_mprintf("%02u:%02u:%02u.%03u %s %s %s %02u %04u", - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec/1000, - GLOBAL_TIME_ZONE, radattrdays[tm.tm_wday], radattrmonths[tm.tm_mon], - tm.tm_mday, tm.tm_year + 1900); - } else { - av_value = switch_mprintf("%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(handle, send, attr_num, av_value, -1, vend_num) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto err; - } - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value); - } - } else if ( strncmp( var, "h323-connect-time", 17) == 0 ) { - switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel); - switch_time_t time = profile->times->answered; - switch_time_exp_t tm; - - if ( !time ) { - goto end_loop; - } - - switch_time_exp_lt(&tm, time); - - if ( GLOBAL_TIME_FORMAT == 1 ) { - av_value = switch_mprintf("%02u:%02u:%02u.%03u %s %s %s %02u %04u", - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec/1000, - GLOBAL_TIME_ZONE, radattrdays[tm.tm_wday], radattrmonths[tm.tm_mon], - tm.tm_mday, tm.tm_year + 1900); - } else { - av_value = switch_mprintf("%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(handle, send, attr_num, av_value, -1, vend_num) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto err; - } - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value); - } - } else if ( strncmp( var, "h323-disconnect-time", 20) == 0 ) { - switch_caller_profile_t *profile = switch_channel_get_caller_profile(channel); - switch_time_t time = profile->times->hungup; - switch_time_exp_t tm; - - if ( !time ) { - if ( variable_secondary != NULL && strncmp(variable_secondary, "now", 3) == 0 ) { - time = switch_time_now(); - } else { - goto end_loop; - } - } - - switch_time_exp_lt(&tm, time); - - if ( GLOBAL_TIME_FORMAT == 1 ) { - av_value = switch_mprintf("%02u:%02u:%02u.%03u %s %s %s %02u %04u", - tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec/1000, - GLOBAL_TIME_ZONE, radattrdays[tm.tm_wday], radattrmonths[tm.tm_mon], - tm.tm_mday, tm.tm_year + 1900); - } else { - av_value = switch_mprintf("%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(handle, send, attr_num, av_value, -1, vend_num) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto err; - } - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value); - } - } else if ( strncmp( var, "h323-disconnect-cause", 21) == 0 ) { - switch_call_cause_t cause = switch_channel_get_cause(channel); - av_value = switch_mprintf("h323-disconnect-cause=%x", cause); - if (rc_avpair_add(handle, send, 30, av_value, -1, 9) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add disconnect cause \n"); - goto err; - } - - } else { - if ( format == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing format attribute for %s variable\n", variable); - goto err; - } - - if ( attribute->type == 0 ) { - const char *val = NULL; - - if ( other_leg ) { - val = switch_channel_get_variable_partner(channel, variable); - if ( val == NULL && variable_secondary != NULL) { - val = switch_channel_get_variable_partner(channel, variable_secondary); - } - } else { - val = switch_channel_get_variable(channel, variable); - if ( val == NULL && variable_secondary != NULL) { - val = switch_channel_get_variable(channel, variable_secondary); - } - } - - if ( regex && val ) { - switch_regex_t *re = NULL; - int ovector[30]; - int proceed; - char replace[1024] = ""; - proceed = 0; - proceed = switch_regex_perform(val, regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])); - if ( proceed > 0 ) { - switch_regex_copy_substring(val, ovector, proceed, proceed - 1, replace, sizeof(replace)); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "original value: %s, regex: %s, result: %s\n", val, regex, replace); - val = replace; - } - else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "original value: %s, regex: %s, result: nomatch, value left intact\n", val, regex); - } - switch_regex_safe_free(re); - } - - if ( val == NULL && val_default != NULL) { - av_value = switch_mprintf(format, val_default); - } else { - av_value = switch_mprintf(format, val); - } - - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: value: %s\n", (char *) av_value); - } - - if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "mod_xml_radius: failed to add option with val '%s' to handle\n", (char *) av_value); - goto err; - } - } else if ( attribute->type == 1 ) { - const char *data = switch_channel_get_variable(channel, variable); - int number = 0; - - if ( data ) { - number = atoi(data); - } - - if (rc_avpair_add(handle, send, attr_num, &number, -1, vend_num) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "mod_xml_radius: failed to add option with value '%d' to handle\n", number); - goto err; - } - } - } - } else if ( params ) { - /* Auth only */ - char *tmp = switch_event_get_header(params, variable); - - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: param var '%s' val: %s\n", variable, tmp); - } - - if ( tmp == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Unable to locate '%s' on the event\n", variable); - goto err; - } - - av_value = switch_mprintf(format, tmp); - if (rc_avpair_add(handle, send, attr_num, av_value, -1, vend_num) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto err; - } - } else { - goto err; - } - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: all params must have a name attribute\n"); - goto err; - } - - end_loop: - if ( av_value != NULL ) { - free(av_value); - av_value = NULL; - } - } - - return SWITCH_STATUS_SUCCESS; - err: - if ( av_value != NULL ) { - free(av_value); - av_value = NULL; - } - return SWITCH_STATUS_GENERR; - -} - -/* static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream) */ -SWITCH_STANDARD_API(mod_xml_radius_debug_api) -{ - if ( !strncmp(cmd, "on", 2) ) { - GLOBAL_DEBUG = 1; - } else if ( !strncmp(cmd, "off", 3)){ - GLOBAL_DEBUG = 0; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Valid options are [yes|no]\n" ); - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "debug is %s\n", (GLOBAL_DEBUG ? "on" : "off") ); - return SWITCH_STATUS_SUCCESS; -} - -switch_xml_t mod_xml_radius_auth_invite(switch_event_t *params) { - int result = 0, param_idx = 0; - VALUE_PAIR *send = NULL, *recv = NULL, *service_vp = NULL; - char msg[512 * 10 + 1] = {0}; - uint32_t service = PW_AUTHENTICATE_ONLY; - rc_handle *new_handle = NULL; - switch_xml_t fields, xml, dir, dom, usr, vars, var; - char name[512], value[512], *strtmp; - - if (GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting invite authentication\n"); - } - - if ( mod_xml_radius_new_handle(&new_handle, globals.auth_invite_configs) != SWITCH_STATUS_SUCCESS ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle for digest invite authentication\n"); - goto err; - } - - if ( new_handle == NULL ) { - goto err; - } - - if ((fields = switch_xml_child(globals.auth_invite_configs, "fields")) == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n"); - goto err; - } - - if ( mod_xml_radius_add_params(NULL, params, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n"); - goto err; - } - - if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto err; - } - - result = rc_auth(new_handle, 0, send, &recv, msg); - - if ( GLOBAL_DEBUG ){ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg); - } - - if ( result != 0 ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to authenticate\n"); - goto err; - } - - xml = switch_xml_new("document"); - switch_xml_set_attr_d(xml, "type", "freeswitch/xml"); - dir = switch_xml_add_child_d(xml, "section", 0); - switch_xml_set_attr_d(dir, "name", "directory"); - dom = switch_xml_add_child_d(dir, "domain", 0); - switch_xml_set_attr_d(dom, "name", switch_event_get_header(params, "domain")); - usr = switch_xml_add_child_d(dom, "user", 0); - vars = switch_xml_add_child_d(usr, "variables", 0); - - switch_xml_set_attr_d(usr, "id", switch_event_get_header(params, "user")); - - var = switch_xml_add_child_d(vars, "variable", param_idx++); - switch_xml_set_attr_d(var, "name", "radius_auth_result"); - switch_xml_set_attr_d(var, "value", "0"); - - service_vp = recv; - while (service_vp != NULL) { - rc_avpair_tostr(new_handle, service_vp, name, 512, value, 512); - if ( GLOBAL_DEBUG ) - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\tattribute (%s)[%s] found in radius packet\n", name, value); - var = switch_xml_add_child_d(vars, "variable", param_idx++); - strtmp = strdup(name); - switch_xml_set_attr_d(var, "name", strtmp); - free(strtmp); - strtmp = strdup(value); - switch_xml_set_attr_d(var, "value", strtmp); - free(strtmp); - service_vp = service_vp->next; - } - - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML: %s \n", switch_xml_toxml(xml, 1)); - } - - if ( recv ) { - rc_avpair_free(recv); - recv = NULL; - } - if ( send ) { - rc_avpair_free(send); - send = NULL; - } - if ( new_handle ) { - rc_destroy(new_handle); - new_handle = NULL; - } - return xml; - err: - if ( recv ) { - rc_avpair_free(recv); - recv = NULL; - } - if ( send ) { - rc_avpair_free(send); - send = NULL; - } - if ( new_handle ) { - rc_destroy(new_handle); - new_handle = NULL; - } - - return NULL; -} - -switch_xml_t mod_xml_radius_auth_reg(switch_event_t *params) { - int result = 0, param_idx = 0; - VALUE_PAIR *send = NULL, *recv = NULL, *service_vp = NULL; - char msg[512 * 10 + 1] = {0}; - uint32_t service = PW_AUTHENTICATE_ONLY; - rc_handle *new_handle = NULL; - switch_xml_t fields, xml, dir, dom, usr, vars, var; - char name[512], value[512], *strtmp; - - if (GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting registration authentication\n"); - } - - if ( mod_xml_radius_new_handle(&new_handle, globals.auth_reg_configs) != SWITCH_STATUS_SUCCESS ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load radius handle for registration authentication\n"); - goto err; - } - - if ( new_handle == NULL ) { - goto err; - } - - if ((fields = switch_xml_child(globals.auth_reg_configs, "fields")) == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n"); - goto err; - } - - if ( mod_xml_radius_add_params(NULL, params, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n"); - goto err; - } - - if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto err; - } - - result = rc_auth(new_handle, 0, send, &recv, msg); - - if ( GLOBAL_DEBUG ){ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg); - } - - if ( result != 0 ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to authenticate\n"); - goto err; - } - - xml = switch_xml_new("document"); - switch_xml_set_attr_d(xml, "type", "freeswitch/xml"); - dir = switch_xml_add_child_d(xml, "section", 0); - switch_xml_set_attr_d(dir, "name", "directory"); - dom = switch_xml_add_child_d(dir, "domain", 0); - switch_xml_set_attr_d(dom, "name", switch_event_get_header(params, "domain")); - usr = switch_xml_add_child_d(dom, "user", 0); - vars = switch_xml_add_child_d(usr, "variables", 0); - - switch_xml_set_attr_d(usr, "id", switch_event_get_header(params, "user")); - - service_vp = recv; - while (service_vp != NULL) { - rc_avpair_tostr(new_handle, service_vp, name, 512, value, 512); - if ( GLOBAL_DEBUG ) - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\tattribute (%s)[%s] found in radius packet\n", name, value); - var = switch_xml_add_child_d(vars, "variable", param_idx++); - strtmp = strdup(name); - switch_xml_set_attr_d(var, "name", strtmp); - free(strtmp); - strtmp = strdup(value); - switch_xml_set_attr_d(var, "value", strtmp); - free(strtmp); - service_vp = service_vp->next; - } - - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML: %s \n", switch_xml_toxml(xml, 1)); - } - - if ( recv ) { - rc_avpair_free(recv); - recv = NULL; - } - if ( send ) { - rc_avpair_free(send); - send = NULL; - } - if ( new_handle ) { - rc_destroy(new_handle); - new_handle = NULL; - } - - return xml; - err: - if ( recv ) { - rc_avpair_free(recv); - recv = NULL; - } - if ( send ) { - rc_avpair_free(send); - send = NULL; - } - if ( new_handle ) { - rc_destroy(new_handle); - new_handle = NULL; - } - - return NULL; -} - -static switch_xml_t mod_xml_radius_directory_search(const char *section, const char *tag_name, const char *key_name, const char *key_value, - switch_event_t *params, void *user_data) -{ - char *event_buf = NULL; - switch_xml_t xml = NULL; - char *auth_method = switch_event_get_header(params,"sip_auth_method"); - - - if ( GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting authentication\n"); - switch_event_serialize(params, &event_buf, SWITCH_TRUE); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Event: %s \n", event_buf); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\nSection: %s \nTag: %s\nKey_name: %s\nKey_value: %s\n", - section, tag_name, key_name, key_value); - } - - if ( auth_method == NULL) { - return NULL; - } - - if ( strncmp( "INVITE", auth_method, 6) == 0) { - xml = mod_xml_radius_auth_invite(params); - } else if ( strncmp( "REGISTER", auth_method, 8) == 0) { - xml = mod_xml_radius_auth_reg(params); - } else { - xml = NULL; - } - - return xml; -} - -switch_status_t mod_xml_radius_check_conditions(switch_channel_t *channel, switch_xml_t conditions) { - switch_xml_t condition, param; - char *channel_var = NULL; - const char *channel_val = NULL; - char *regex = NULL; - char *anti = NULL; - int all_matched = 1; - int result = 0; - - if ( (condition = switch_xml_child(conditions, "condition")) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a condition under the conditions section\n"); - return SWITCH_STATUS_FALSE; - } - - for (; condition; condition = condition->next) { - - if ( (param = switch_xml_child(condition, "param")) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to locate a param under this condition\n"); - return SWITCH_STATUS_FALSE; - } - - all_matched = 1; - for (; param && all_matched; param = param->next) { - channel_var = (char *) switch_xml_attr(param, "var"); - regex = (char *) switch_xml_attr(param, "regex"); - anti = (char *) switch_xml_attr(param, "anti"); - - if ( channel_var == NULL || regex == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Improperly constructed mod_radius condition: %s %s\n", channel_var, regex); - continue; - } - - if ( ( channel_val = switch_channel_get_variable(channel, channel_var) ) == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Improperly constructed mod_radius condition, no such channel variable: %s %s\n", channel_var, regex); - continue; - } - - result = ( switch_regex_match( channel_val, regex) != SWITCH_STATUS_SUCCESS); - if (( anti == NULL && result ) || ( anti != NULL && !result ) ){ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Didn't match: %s == %s \n", switch_channel_get_variable(channel, channel_var), regex); - all_matched = 0; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Result of %s match: %s == %s \n", - anti, switch_channel_get_variable(channel, channel_var), regex); - } - } - - if ( all_matched ) { - return SWITCH_STATUS_SUCCESS; - } - } - - return SWITCH_STATUS_FALSE; -} - -switch_status_t mod_xml_radius_accounting_start(switch_core_session_t *session){ - VALUE_PAIR *send = NULL; - uint32_t service = PW_STATUS_START; - rc_handle *new_handle = NULL; - switch_xml_t fields, conditions; - switch_channel_t *channel = switch_core_session_get_channel(session); - - if (GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting accounting start\n"); - switch_core_session_execute_application(session, "info", NULL); - } - - /* If there are conditions defined, and none of them pass, then skip this accounting */ - if ((conditions = switch_xml_child(globals.acct_start_configs, "conditions")) != NULL && - mod_xml_radius_check_conditions(channel, conditions) != SWITCH_STATUS_SUCCESS ) { - goto end; - } - - if ( mod_xml_radius_new_handle(&new_handle, globals.acct_start_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new accounting_start handle for call: %s\n", - switch_channel_get_variable(channel, "uuid")); - goto end; - } - - if ((fields = switch_xml_child(globals.acct_start_configs, "fields")) == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n"); - goto end; - } - - if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n"); - goto end; - } - - if (rc_avpair_add(new_handle, &send, PW_ACCT_STATUS_TYPE, &service, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto end; - } - - if (rc_acct(new_handle, 0, send) == OK_RC) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "mod_xml_radius: Accounting Start success\n"); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Accounting Start failed\n"); - } - - end: - if ( send ) { - rc_avpair_free(send); - send = NULL; - } - if ( new_handle ) { - rc_destroy(new_handle); - new_handle = NULL; - } - - return SWITCH_STATUS_SUCCESS; -} - -switch_status_t mod_xml_radius_accounting_end(switch_core_session_t *session){ - VALUE_PAIR *send = NULL; - uint32_t service = PW_STATUS_STOP; - rc_handle *new_handle = NULL; - switch_xml_t fields = NULL, conditions = NULL; - switch_channel_t *channel = switch_core_session_get_channel(session); - - if (GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting accounting stop\n"); - switch_core_session_execute_application(session, "info", NULL); - } - - /* If there are conditions defined, and none of them pass, then skip this accounting */ - if ((conditions = switch_xml_child(globals.acct_end_configs, "conditions")) != NULL && - mod_xml_radius_check_conditions(channel, conditions) != SWITCH_STATUS_SUCCESS ) { - goto end; - } - - if ( mod_xml_radius_new_handle(&new_handle, globals.acct_end_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new accounting_end handle for call: %s\n", - switch_channel_get_variable(channel, "uuid")); - goto end; - } - - if ((fields = switch_xml_child(globals.acct_end_configs, "fields")) == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n"); - goto end; - } - - if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n"); - goto end; - } - - if (rc_avpair_add(new_handle, &send, PW_ACCT_STATUS_TYPE, &service, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto end; - } - - if (rc_acct(new_handle, 0, send) == OK_RC) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "mod_xml_radius: Accounting Stop success\n"); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Accounting Stop failed\n"); - } - - end: - if ( send ) { - rc_avpair_free(send); - send = NULL; - } - if ( new_handle) { - rc_destroy(new_handle); - new_handle = NULL; - } - - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_STANDARD_APP(radius_auth_handle) -{ - switch_channel_t *channel = switch_core_session_get_channel(session); - int result = 0; - VALUE_PAIR *send = NULL, *recv = NULL, *service_vp = NULL; - char msg[512 * 10 + 1] = {0}; - uint32_t service = PW_AUTHENTICATE_ONLY; - rc_handle *new_handle = NULL; - switch_xml_t fields; - char name[512], value[512], *temp = NULL; - - if (GLOBAL_DEBUG ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting app authentication\n"); - } - - if ( mod_xml_radius_new_handle(&new_handle, globals.auth_app_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new authentication handle for call: %s\n", - switch_channel_get_variable(channel, "uuid")); - goto err; - } - - if ((fields = switch_xml_child(globals.auth_app_configs, "fields")) == NULL ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n"); - goto err; - } - - if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n"); - goto err; - } - - if (rc_avpair_add(new_handle, &send, PW_SERVICE_TYPE, &service, -1, 0) == NULL) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n"); - goto err; - } - - result = rc_auth(new_handle, 0, send, &recv, msg); - - if ( GLOBAL_DEBUG ){ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: result(RC=%d) %s \n", result, msg); - } - temp = switch_mprintf("%d",result); - switch_channel_set_variable(channel, "radius_auth_result", temp); - free(temp); - temp = NULL; - - if ( result != 0 ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to authenticate, authentication result: %d \n", result); - goto err; - } - - - service_vp = recv; - while (service_vp != NULL) { - rc_avpair_tostr(new_handle, service_vp, name, 512, value, 512); - if ( GLOBAL_DEBUG ) - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "\tattribute (%s)[%s] found in radius packet\n", name, value); - - switch_channel_set_variable(channel, name, value); - service_vp = service_vp->next; - } - - if ( recv ) { - rc_avpair_free(recv); - recv = NULL; - } - if ( send ) { - rc_avpair_free(send); - send = NULL; - } - if ( new_handle ) { - rc_destroy(new_handle); - new_handle = NULL; - } - - return; - err: - if ( recv ) { - rc_avpair_free(recv); - recv = NULL; - } - if ( send ) { - rc_avpair_free(send); - send = NULL; - } - if ( new_handle ) { - rc_destroy(new_handle); - new_handle = NULL; - } - return; -} - -static const switch_state_handler_table_t state_handlers = { - /*.on_init */ NULL, - /*.on_routing */ mod_xml_radius_accounting_start, - /*.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 */ mod_xml_radius_accounting_end -}; - - -/* switch_status_t name (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */ -SWITCH_MODULE_LOAD_FUNCTION(mod_xml_radius_load) -{ - switch_api_interface_t *mod_xml_radius_api_interface; - switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_application_interface_t *app_interface; - - /* connect my internal structure to the blank pointer passed to me */ - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - - memset(&globals, 0, sizeof(globals)); - globals.pool = pool; - - if ( GLOBAL_DEBUG != 0 ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: loading\n"); - } - - if ( (status = do_config()) != SWITCH_STATUS_SUCCESS ) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Failed to load configs\n"); - return SWITCH_STATUS_TERM; - } - - if ( globals.auth_invite_configs && globals.auth_reg_configs ) { - status = switch_xml_bind_search_function(mod_xml_radius_directory_search, switch_xml_parse_section_string("directory"), NULL); - } - - SWITCH_ADD_API(mod_xml_radius_api_interface, "xml_radius_debug", "mod_xml_radius toggle debug", mod_xml_radius_debug_api, NULL); - - switch_core_add_state_handler(&state_handlers); - - SWITCH_ADD_APP(app_interface, "radius_auth", NULL, NULL, radius_auth_handle, "radius_auth", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); - - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_radius_shutdown) -{ - switch_core_remove_state_handler(&state_handlers); - switch_xml_unbind_search_function_ptr(mod_xml_radius_directory_search); - - if ( globals.auth_invite_configs ) { - switch_xml_free(globals.auth_invite_configs); - } - if ( globals.auth_reg_configs ) { - switch_xml_free(globals.auth_reg_configs); - } - if ( globals.auth_app_configs ) { - switch_xml_free(globals.auth_app_configs); - } - if ( globals.acct_start_configs ) { - switch_xml_free(globals.acct_start_configs); - } - if ( globals.acct_end_configs ) { - switch_xml_free(globals.acct_end_configs); - } - 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/xml_int/mod_xml_radius/xml_radius.conf.xml b/src/mod/xml_int/mod_xml_radius/xml_radius.conf.xml deleted file mode 100644 index 028ace286a..0000000000 --- a/src/mod/xml_int/mod_xml_radius/xml_radius.conf.xml +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -