[svn-commits] branch oej/cdr_radius r11686 - in
/team/oej/cdr_radius: ./ cdr/
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Fri Mar 3 03:32:01 MST 2006
Author: oej
Date: Fri Mar 3 04:31:58 2006
New Revision: 11686
URL: http://svn.digium.com/view/asterisk?rev=11686&view=rev
Log:
Adding Philippe's patches and new CDR driver
Added:
team/oej/cdr_radius/cdr/cdr_radius.c (with props)
Modified:
team/oej/cdr_radius/ (props changed)
team/oej/cdr_radius/cdr/Makefile
Propchange: team/oej/cdr_radius/
------------------------------------------------------------------------------
svnmerge-integrated = /trunk:1-11683
Modified: team/oej/cdr_radius/cdr/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/cdr_radius/cdr/Makefile?rev=11686&r1=11685&r2=11686&view=diff
==============================================================================
--- team/oej/cdr_radius/cdr/Makefile (original)
+++ team/oej/cdr_radius/cdr/Makefile Fri Mar 3 04:31:58 2006
@@ -28,6 +28,10 @@
ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/tds.h $(CROSS_COMPILE_TARGET)/usr/local/include/tds.h $(CROSS_COMPILE_TARGET)/usr/include/freetds/tds.h),)
MODS:=$(filter-out cdr_tds.so,$(MODS))
NOTDS=1
+endif
+
+ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/radiusclient-ng.h $(CROSS_COMPILE_TARGET)/usr/local/include/radiusclient-ng.h),)
+ MODS:=$(filter-out cdr_radius.so,$(MODS))
endif
ifeq (${OSARCH},CYGWIN)
@@ -131,6 +135,9 @@
cdr_sqlite.so: cdr_sqlite.o
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lsqlite $(MLFLAGS)
+cdr_radius.so: cdr_radius.o
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lradiusclient-ng $(MLFLAGS)
+
depend: .depend
.depend:
Added: team/oej/cdr_radius/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/team/oej/cdr_radius/cdr/cdr_radius.c?rev=11686&view=auto
==============================================================================
--- team/oej/cdr_radius/cdr/cdr_radius.c (added)
+++ team/oej/cdr_radius/cdr/cdr_radius.c Fri Mar 3 04:31:58 2006
@@ -1,0 +1,211 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2005, Digium, Inc.
+ *
+ * Mark Spencer <markster at digium.com>
+ *
+ * Includes code and algorithms from the Zapata library.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief RADIUS CDR Support
+ *
+ *
+ * \arg See also \ref AstCDR
+ * \ingroup cdr_drivers
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <radiusclient-ng.h>
+
+#define RC_CONFIG_FILE "/usr/local/etc/radiusclient-ng/radiusclient.conf"
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Rev$")
+
+#include "asterisk/channel.h"
+#include "asterisk/cdr.h"
+#include "asterisk/module.h"
+#include "asterisk/logger.h"
+#include "asterisk/utils.h"
+
+#define DATE_FORMAT "%Y-%m-%d %T"
+
+static char *desc = "RADIUS CDR Backend";
+
+static char *name = "radius";
+
+AST_MUTEX_DEFINE_STATIC(rc_lock);
+
+static rc_handle *rh = NULL;
+
+
+static int build_radius_record(VALUE_PAIR **send, struct ast_cdr *cdr)
+{
+
+ int aux;
+ char buf[253];
+
+
+ aux = PW_STATUS_STOP;
+ if (!rc_avpair_add(rh, send, PW_ACCT_STATUS_TYPE, &aux, 0, 0)) {
+ ast_log(LOG_WARNING, "Failed to add VALUE PAIR. RADIUS CDR not recorded!\n");
+ return -1;
+ }
+
+
+/* /\* Account code *\/ */
+/* append_string(buf, cdr->accountcode, bufsize); */
+ /* Source */
+ ast_copy_string(buf, cdr->src, sizeof(buf));
+ if (!rc_avpair_add(rh, send, PW_CALLING_STATION_ID, &buf, strlen(buf), 0)) {
+ ast_log(LOG_WARNING, "Failed to add VALUE PAIR. RADIUS CDR not recorded!\n");
+ return -1;
+ }
+
+ /* Destination */
+ ast_copy_string(buf, cdr->dst, sizeof(buf));
+ if (!rc_avpair_add(rh, send, PW_CALLED_STATION_ID, &buf, strlen(buf), 0)) {
+ ast_log(LOG_WARNING, "Failed to add VALUE PAIR. RADIUS CDR not recorded!\n");
+ return -1;
+ }
+
+/* /\* Destination context *\/ */
+/* append_string(buf, cdr->dcontext, bufsize); */
+/* /\* Caller*ID *\/ */
+/* append_string(buf, cdr->clid, bufsize); */
+/* /\* Channel *\/ */
+/* append_string(buf, cdr->channel, bufsize); */
+/* /\* Destination Channel *\/ */
+/* append_string(buf, cdr->dstchannel, bufsize); */
+/* /\* Last Application *\/ */
+/* append_string(buf, cdr->lastapp, bufsize); */
+/* /\* Last Data *\/ */
+/* append_string(buf, cdr->lastdata, bufsize); */
+/* /\* Start Time *\/ */
+/* append_date(buf, cdr->start, bufsize); */
+/* /\* Answer Time *\/ */
+/* append_date(buf, cdr->answer, bufsize); */
+/* /\* End Time *\/ */
+/* append_date(buf, cdr->end, bufsize); */
+
+ /* Duration */
+ aux = cdr->duration;
+ if (!rc_avpair_add(rh, send, PW_ACCT_SESSION_TIME, &cdr->duration, 0, 0)) {
+ ast_log(LOG_WARNING, "Failed to add VALUE PAIR. RADIUS CDR not recorded!\n");
+ return -1;
+ }
+
+/* /\* Billable seconds *\/ */
+/* append_int(buf, cdr->billsec, bufsize); */
+/* /\* Disposition *\/ */
+/* append_string(buf, ast_cdr_disp2str(cdr->disposition), bufsize); */
+/* /\* AMA Flags *\/ */
+/* append_string(buf, ast_cdr_flags2str(cdr->amaflags), bufsize); */
+
+/* #ifdef CSV_LOGUNIQUEID */
+/* /\* Unique ID *\/ */
+/* append_string(buf, cdr->uniqueid, bufsize); */
+/* #endif */
+/* #ifdef CSV_LOGUSERFIELD */
+/* /\* append the user field *\/ */
+/* append_string(buf, cdr->userfield,bufsize); */
+/* #endif */
+ return 1;
+}
+
+static int radius_log(struct ast_cdr *cdr)
+{
+ int result = ERROR_RC;
+ VALUE_PAIR *send = NULL;
+
+ ast_mutex_lock(&rc_lock);
+
+ if (!build_radius_record(&send, cdr)) {
+ ast_log(LOG_WARNING, "Unable to create RADIUS record. CDR not recorded!\n");
+ }
+
+ result = rc_acct(rh, 0, send);
+ if (result == OK_RC) {
+ ast_log(LOG_NOTICE, "RADIUS CDR recorded.\n");
+ }
+ else {
+ ast_log(LOG_NOTICE, "Failed to record CDR.\n");
+ }
+
+ ast_mutex_unlock(&rc_lock);
+
+ return result;
+}
+
+char *description(void)
+{
+ return desc;
+}
+
+int unload_module(void)
+{
+ ast_cdr_unregister(name);
+ return 0;
+}
+
+int load_module(void)
+{
+ int res;
+
+ /* start logging */
+ rc_openlog("asterisk");
+
+ /* read radiusclient-ng config file */
+ if ((rh = rc_read_config(RC_CONFIG_FILE)) == NULL) {
+ ast_log(LOG_NOTICE, "Cannot load radiusclient-ng configuration file %s.\n", RC_CONFIG_FILE);
+ return -1;
+ }
+
+ /* read radiusclient-ng dictionaries */
+ if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) {
+ ast_log(LOG_NOTICE, "Cannot load radiusclient-ng dictionary file.\n");
+ return -1;
+ }
+
+ res = ast_cdr_register(name, desc, radius_log);
+ if (res) {
+ ast_log(LOG_ERROR, "Unable to register RADIUS CDR handling\n");
+ }
+ return res;
+}
+
+int reload(void)
+{
+ return 0;
+}
+
+int usecount(void)
+{
+ return 0;
+}
+
+char *key()
+{
+ return ASTERISK_GPL_KEY;
+}
Propchange: team/oej/cdr_radius/cdr/cdr_radius.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/oej/cdr_radius/cdr/cdr_radius.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/oej/cdr_radius/cdr/cdr_radius.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the svn-commits
mailing list