Browse Source

acc_radius(k): new module for RADIUS accounting

- the modules is built out of acc module radius part
- acc module still has the RADIUS accounting inside, available with
  RAD_ACC define like so far - subject to be removed if everyone agrees
- this module can be used together with acc avoiding to recompile acc
  module to enable RAD_ACC, making at least packaging easier
- same cfg parameters and functions used for radius accounting in acc
  module are available in acc_radius
Daniel-Constantin Mierla 15 years ago
parent
commit
d4031fa7e9

+ 20 - 0
modules_k/acc_radius/Makefile

@@ -0,0 +1,20 @@
+# $Id$
+#
+# acc_radius module makefile
+#
+#
+# WARNING: do not run this directly, it should be run by the master Makefile
+
+include ../../Makefile.defs
+auto_gen=
+NAME=acc_radius.so
+LIBS=
+
+include ../../Makefile.radius
+
+DEFS+=-DOPENSER_MOD_INTERFACE
+
+SERLIBPATH=../../lib
+SER_LIBS+=$(SERLIBPATH)/kcore/kcore
+
+include ../../Makefile.modules

+ 195 - 0
modules_k/acc_radius/README

@@ -0,0 +1,195 @@
+AACC_RADIUS Module
+
+Juha Heinanen
+
+   <[email protected]>
+
+Daniel-Constantin Mierla
+
+   asipto.com
+   <[email protected]>
+
+Edited by
+
+Daniel-Constantin Mierla
+
+   asipto.com
+   <[email protected]>
+
+   Copyright © 2002, 2003 FhG FOKUS
+     __________________________________________________________________
+
+   Table of Contents
+
+   1. Admin Guide
+
+        1. Overview
+        2. Dependencies
+
+              2.1. Kamailio Modules
+              2.2. External Libraries or Applications
+
+        3. Exported Parameters
+
+              3.1. radius_config (string)
+              3.2. radius_flag (integer)
+              3.3. radius_missed_flag (integer)
+              3.4. service_type (integer)
+              3.5. radius_extra (string)
+
+        4. Exported Functions
+
+              4.1. acc_rad_request(comment)
+
+   List of Examples
+
+   1.1. radius_config example
+   1.2. radius_flag example
+   1.3. radius_missed_flag example
+   1.4. service_type example
+   1.5. radius_extra example
+   1.6. acc_rad_request usage
+
+Chapter 1. Admin Guide
+
+   Table of Contents
+
+   1. Overview
+   2. Dependencies
+
+        2.1. Kamailio Modules
+        2.2. External Libraries or Applications
+
+   3. Exported Parameters
+
+        3.1. radius_config (string)
+        3.2. radius_flag (integer)
+        3.3. radius_missed_flag (integer)
+        3.4. service_type (integer)
+        3.5. radius_extra (string)
+
+   4. Exported Functions
+
+        4.1. acc_rad_request(comment)
+
+1. Overview
+
+   ACC_RADIUS module is used to account transaction information to RADIUS
+   server. It binds to ACC module API and uses the same accounting
+   mechanisms as for other backends.
+
+   Therefore you need this module just to send accounting data to a RADIUS
+   server - for more documentation regarding accounting, see the ACC
+   readme.
+
+2. Dependencies
+
+   2.1. Kamailio Modules
+   2.2. External Libraries or Applications
+
+2.1. Kamailio Modules
+
+   The module depends on the following modules (in the other words the
+   listed modules must be loaded before this module):
+     * acc - accounting module
+
+2.2. External Libraries or Applications
+
+   The following libraries or applications must be installed before
+   running Kamailio with this module loaded:
+     * radiusclient-ng 0.5.0 or higher. See
+       http://developer.berlios.de/projects/radiusclient-ng/.
+
+3. Exported Parameters
+
+   3.1. radius_config (string)
+   3.2. radius_flag (integer)
+   3.3. radius_missed_flag (integer)
+   3.4. service_type (integer)
+   3.5. radius_extra (string)
+
+3.1. radius_config (string)
+
+   This parameter is radius specific. Path to radius client configuration
+   file, set the referred config file correctly and specify there address
+   of server, shared secret (should equal that in
+   /usr/local/etc/raddb/clients for freeRadius servers) and dictionary,
+   see etc for an example of config file and dictionary.
+
+   If the parameter is set to empty string, the RADIUS accounting support
+   will be disabled (even if compiled).
+
+   Default value is “NULL”.
+
+   Example 1.1. radius_config example
+...
+modparam("acc_radius", "radius_config", "/etc/radiusclient/radiusclient.conf")
+...
+
+3.2. radius_flag (integer)
+
+   Request flag which needs to be set to account a transaction -- RADIUS
+   specific.
+
+   Default value is not-set (no flag).
+
+   Example 1.2. radius_flag example
+...
+modparam("acc_radius", "radius_flag", 2)
+...
+
+3.3. radius_missed_flag (integer)
+
+   Request flag which needs to be set to account missed calls -- RADIUS
+   specific.
+
+   Default value is not-set (no flag).
+
+   Example 1.3. radius_missed_flag example
+...
+modparam("acc_radius", "radius_missed_flag", 3)
+...
+
+3.4. service_type (integer)
+
+   Radius service type used for accounting.
+
+   Default value is 15 (SIP).
+
+   Example 1.4. service_type example
+...
+modparam("acc_radius", "service_type", 16)
+...
+
+3.5. radius_extra (string)
+
+   Extra values to be logged via RADIUS - RADIUS specific.
+
+   Default value is NULL.
+
+   Example 1.5. radius_extra example
+...
+modparam("acc_radius", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)")
+...
+
+4. Exported Functions
+
+   4.1. acc_rad_request(comment)
+
+4.1.  acc_rad_request(comment)
+
+   Like acc_log_request of acc module, acc_rad_request reports on a SIP
+   request event. It reports to radius server as configured in
+   “radius_config”.
+
+   Meaning of the parameters is as follows:
+     * comment - Comment to be appended.
+
+   This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+
+   Example 1.6. acc_rad_request usage
+...
+acc_rad_request("Some comment");
+...
+acc_rad_request("200 From Config");
+...

+ 416 - 0
modules_k/acc_radius/acc_radius_mod.c

@@ -0,0 +1,416 @@
+/*
+ * $Id$
+ * 
+ * Accounting module
+ *
+ * Copyright (C) 2001-2003 FhG Fokus
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * -------
+ * 2010-07-28 - moved out radius account out of acc module (daniel)
+ */
+
+/*! \file
+ * \ingroup acc_radius
+ * \brief Acc_radius:: Core module interface
+ *
+ * - Module: \ref acc_radius
+ */
+
+/*! \defgroup acc_radius ACC_RADIUS :: The Kamailio RADIUS accounting Module
+ *            
+ * The ACC_RADIUS module is used to account transactions information to
+ *  RADIUS            
+ */ 
+
+#include <stdio.h>
+#include <string.h>
+
+#include "../../sr_module.h"
+#include "../../dprint.h"
+#include "../../mem/mem.h"
+#include "../../parser/parse_to.h"
+#include "../../lib/kcore/radius.h"
+#include "../../modules_k/acc/acc_api.h"
+#include "acc_radius_mod.h"
+
+MODULE_VERSION
+
+static int mod_init(void);
+static void destroy(void);
+static int child_init(int rank);
+
+int acc_radius_init(acc_init_info_t *inf);
+int acc_radius_send_request(struct sip_msg *req, acc_info_t *inf);
+
+static int w_acc_radius_request(struct sip_msg *rq, char *comment, char *foo);
+static int acc_api_fixup(void** param, int param_no);
+static int free_acc_api_fixup(void** param, int param_no);
+
+int init_acc_rad(acc_extra_t *leg_info, char *rad_cfg, int srv_type);
+int extra2attrs(struct acc_extra *extra, struct attr *attrs, int offset);
+
+/*! ACC API structure */
+acc_api_t accb;
+acc_engine_t _acc_radius_engine;
+
+/* ----- RADIUS acc variables ----------- */
+/*! \name AccRadiusVariables  Radius Variables */     
+/*@{*/
+
+static char *radius_config = 0;
+int radius_flag = -1;
+int radius_missed_flag = -1;
+static int service_type = -1;
+void *rh;
+/* rad extra variables */
+static char *rad_extra_str = 0;
+acc_extra_t *rad_extra = 0;
+/*@}*/
+
+
+static cmd_export_t cmds[] = {
+	{"acc_rad_request", (cmd_function)w_acc_radius_request, 1,
+		acc_api_fixup, free_acc_api_fixup,
+		REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
+	{0, 0, 0, 0, 0, 0}
+};
+
+
+
+static param_export_t params[] = {
+	{"radius_config",        STR_PARAM, &radius_config        },
+	{"radius_flag",          INT_PARAM, &radius_flag          },
+	{"radius_missed_flag",   INT_PARAM, &radius_missed_flag   },
+	{"service_type",         INT_PARAM, &service_type         },
+	{"radius_extra",         STR_PARAM, &rad_extra_str        },
+	{0,0,0}
+};
+
+
+struct module_exports exports= {
+	"acc_radius",
+	DEFAULT_DLFLAGS, /* dlopen flags */
+	cmds,       /* exported functions */
+	params,     /* exported params */
+	0,          /* exported statistics */
+	0,          /* exported MI functions */
+	0,          /* exported pseudo-variables */
+	0,          /* extra processes */
+	mod_init,   /* initialization module */
+	0,          /* response function */
+	destroy,    /* destroy function */
+	child_init  /* per-child init function */
+};
+
+
+
+/************************** INTERFACE functions ****************************/
+
+static int mod_init( void )
+{
+	if (radius_config==NULL || radius_config[0]=='\0')
+		return 0;
+	
+	/* bind the ACC API */
+	if (acc_load_api(&accb)<0) {
+		LM_ERR("cannot bind to ACC API\n");
+		return -1;
+	}
+
+	/* parse the extra string, if any */
+	if (rad_extra_str && (rad_extra=accb.parse_extra(rad_extra_str))==0 ) {
+		LM_ERR("failed to parse rad_extra param\n");
+		return -1;
+	}
+		
+	memset(&_acc_radius_engine, 0, sizeof(acc_engine_t));
+
+	if(radius_flag != -1)
+		_acc_radius_engine.acc_flag	   = 1<<radius_flag;
+	if(radius_missed_flag != -1)
+		_acc_radius_engine.missed_flag = 1<<radius_missed_flag;
+	_acc_radius_engine.acc_req     = acc_radius_send_request;
+	_acc_radius_engine.acc_init    = acc_radius_init;
+	memcpy(_acc_radius_engine.name, "radius", 6);
+	if(accb.register_engine(&_acc_radius_engine)<0)
+	{
+		LM_ERR("cannot register ACC RADIUS engine\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+
+static int child_init(int rank)
+{
+	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
+		return 0; /* do nothing for the main process */
+
+	return 0;
+}
+
+
+static void destroy(void)
+{
+}
+
+static int acc_api_fixup(void** param, int param_no)
+{
+	struct acc_param *accp;
+	char *p;
+
+	p = (char*)*param;
+	if (p==0 || p[0]==0) {
+		LM_ERR("first parameter is empty\n");
+		return E_SCRIPT;
+	}
+
+	if (param_no == 1) {
+		accp = (struct acc_param*)pkg_malloc(sizeof(struct acc_param));
+		if (!accp) {
+			LM_ERR("no more pkg mem\n");
+			return E_OUT_OF_MEM;
+		}
+		memset( accp, 0, sizeof(struct acc_param));
+		accp->reason.s = p;
+		accp->reason.len = strlen(p);
+		/* any code? */
+		if (accp->reason.len>=3 && isdigit((int)p[0])
+		&& isdigit((int)p[1]) && isdigit((int)p[2]) ) {
+			accp->code = (p[0]-'0')*100 + (p[1]-'0')*10 + (p[2]-'0');
+			accp->code_s.s = p;
+			accp->code_s.len = 3;
+			accp->reason.s += 3;
+			for( ; isspace((int)accp->reason.s[0]) ; accp->reason.s++ );
+			accp->reason.len = strlen(accp->reason.s);
+		}
+		*param = (void*)accp;
+#ifdef SQL_ACC
+	} else if (param_no == 2) {
+		/* only for db acc - the table name */
+		if (db_url.s==0) {
+			pkg_free(p);
+			*param = 0;
+		}
+#endif
+	}
+	return 0;
+}
+
+static int free_acc_api_fixup(void** param, int param_no)
+{
+	if(*param)
+	{
+		pkg_free(*param);
+		*param = 0;
+	}
+	return 0;
+}
+
+
+enum { RA_ACCT_STATUS_TYPE=0, RA_SERVICE_TYPE, RA_SIP_RESPONSE_CODE,
+	RA_SIP_METHOD, RA_TIME_STAMP, RA_STATIC_MAX};
+enum {RV_STATUS_START=0, RV_STATUS_STOP, RV_STATUS_ALIVE, RV_STATUS_FAILED,
+	RV_SIP_SESSION, RV_STATIC_MAX};
+static struct attr
+	rd_attrs[RA_STATIC_MAX+ACC_CORE_LEN-2+MAX_ACC_EXTRA+MAX_ACC_LEG];
+static struct val rd_vals[RV_STATIC_MAX];
+
+int init_acc_rad(acc_extra_t *leg_info, char *rad_cfg, int srv_type)
+{
+	int n;
+
+	memset(rd_attrs, 0, sizeof(rd_attrs));
+	memset(rd_vals, 0, sizeof(rd_vals));
+	rd_attrs[RA_ACCT_STATUS_TYPE].n  = "Acct-Status-Type";
+	rd_attrs[RA_SERVICE_TYPE].n      = "Service-Type";
+	rd_attrs[RA_SIP_RESPONSE_CODE].n = "Sip-Response-Code";
+	rd_attrs[RA_SIP_METHOD].n        = "Sip-Method";
+	rd_attrs[RA_TIME_STAMP].n        = "Event-Timestamp";
+	n = RA_STATIC_MAX;
+	/* caution: keep these aligned to core acc output */
+	rd_attrs[n++].n                  = "Sip-From-Tag";
+	rd_attrs[n++].n                  = "Sip-To-Tag";
+	rd_attrs[n++].n                  = "Acct-Session-Id";
+
+	rd_vals[RV_STATUS_START].n        = "Start";
+	rd_vals[RV_STATUS_STOP].n         = "Stop";
+	rd_vals[RV_STATUS_ALIVE].n        = "Alive";
+	rd_vals[RV_STATUS_FAILED].n       = "Failed";
+	rd_vals[RV_SIP_SESSION].n         = "Sip-Session";
+
+	/* add and count the extras as attributes */
+	n += extra2attrs( rad_extra, rd_attrs, n);
+	/* add and count the legs as attributes */
+	n += extra2attrs( leg_info, rd_attrs, n);
+
+	/* read config */
+	if ((rh = rc_read_config(rad_cfg)) == NULL) {
+		LM_ERR("failed to open radius config file: %s\n", rad_cfg );
+		return -1;
+	}
+	/* read dictionary */
+	if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary"))!=0) {
+		LM_ERR("failed to read radius dictionary\n");
+		return -1;
+	}
+
+	INIT_AV(rh, rd_attrs, n, rd_vals, RV_STATIC_MAX, "acc", -1, -1);
+
+	if (srv_type != -1)
+		rd_vals[RV_SIP_SESSION].v = srv_type;
+
+	return 0;
+}
+
+
+int acc_radius_init(acc_init_info_t *inf)
+{
+	if (radius_config && radius_config[0]) {
+		if (init_acc_rad(inf->leg_info, radius_config, service_type)!=0 ) {
+			LM_ERR("failed to init radius\n");
+			return -1;
+		}
+	}
+	return 0;
+}
+
+static inline UINT4 rad_status( struct sip_msg *req, int code )
+{
+        str tag;
+        unsigned int in_dialog_req = 0;
+
+        tag = get_to(req)->tag_value;
+        if(tag.s!=0 && tag.len!=0)
+		in_dialog_req = 1;
+
+	if (req->REQ_METHOD==METHOD_INVITE && in_dialog_req == 0
+	            && code>=200 && code<300)
+ 		return rd_vals[RV_STATUS_START].v;
+ 	if ((req->REQ_METHOD==METHOD_BYE || req->REQ_METHOD==METHOD_CANCEL))
+ 		return rd_vals[RV_STATUS_STOP].v;
+	if (in_dialog_req != 0)
+		return rd_vals[RV_STATUS_ALIVE].v;
+ 	return rd_vals[RV_STATUS_FAILED].v;
+ }
+
+#define ADD_RAD_AVPAIR(_attr,_val,_len)		\
+    do {								\
+	if (!rc_avpair_add(rh, &send, rd_attrs[_attr].v, _val, _len, 0)) { \
+	    LM_ERR("failed to add %s, %d\n", rd_attrs[_attr].n, _attr);	\
+	    goto error;							\
+	} \
+    }while(0)
+
+int acc_radius_send_request(struct sip_msg *req, acc_info_t *inf)
+{
+	int attr_cnt;
+	VALUE_PAIR *send;
+	UINT4 av_type;
+	int offset;
+	int i;
+
+	send=NULL;
+
+	attr_cnt = accb.get_core_attrs( req, inf->varr, inf->iarr, inf->tarr );
+	/* not interested in the last 2 values */
+	attr_cnt -= 2;
+
+	av_type = rad_status( req, inf->env->code); /* RADIUS status */
+	ADD_RAD_AVPAIR( RA_ACCT_STATUS_TYPE, &av_type, -1);
+
+	av_type = rd_vals[RV_SIP_SESSION].v; /* session*/
+	ADD_RAD_AVPAIR( RA_SERVICE_TYPE, &av_type, -1);
+
+	av_type = (UINT4)inf->env->code; /* status=integer */
+	ADD_RAD_AVPAIR( RA_SIP_RESPONSE_CODE, &av_type, -1);
+
+	av_type = req->REQ_METHOD; /* method */
+	ADD_RAD_AVPAIR( RA_SIP_METHOD, &av_type, -1);
+
+	/* unix time */
+	av_type = (UINT4)inf->env->ts;
+	ADD_RAD_AVPAIR( RA_TIME_STAMP, &av_type, -1);
+
+	/* add extra also */
+	attr_cnt += accb.get_extra_attrs(rad_extra, req, inf->varr+attr_cnt,
+				inf->iarr+attr_cnt, inf->tarr+attr_cnt);
+
+	/* add the values for the vector - start from 1 instead of
+	 * 0 to skip the first value which is the METHOD as string */
+	offset = RA_STATIC_MAX-1;
+	for( i=1; i<attr_cnt; i++) {
+	    switch (inf->tarr[i]) {
+	    case TYPE_STR:
+		ADD_RAD_AVPAIR(offset+i, inf->varr[i].s, inf->varr[i].len);
+		break;
+	    case TYPE_INT:
+		ADD_RAD_AVPAIR(offset+i, &(inf->iarr[i]), -1);
+		break;
+	    default:
+		break;
+	    }
+	}
+
+	/* call-legs attributes also get inserted */
+	if ( inf->leg_info ) {
+		offset += attr_cnt;
+		attr_cnt = accb.get_leg_attrs(inf->leg_info,req,inf->varr,inf->iarr,inf->tarr,1);
+		do {
+			for (i=0; i<attr_cnt; i++)
+				ADD_RAD_AVPAIR( offset+i, inf->varr[i].s, inf->varr[i].len );
+		}while ( (attr_cnt=accb.get_leg_attrs(inf->leg_info,req,inf->varr,inf->iarr,
+					      inf->tarr, 0))!=0 );
+	}
+
+	if (rc_acct(rh, SIP_PORT, send)!=OK_RC) {
+		LM_ERR("radius-ing failed\n");
+		goto error;
+	}
+	rc_avpair_free(send);
+	return 1;
+
+error:
+	rc_avpair_free(send);
+	return -1;
+}
+
+/*! \brief extra name is moved as string part of an attribute; str.len will contain an
+ * index to the corresponding attribute
+ */
+int extra2attrs(struct acc_extra *extra, struct attr *attrs, int offset)
+{
+	int i;
+
+	for(i=0 ; extra ; i++, extra=extra->next) {
+		attrs[offset+i].n = extra->name.s;
+	}
+	return i;
+}
+
+/**
+ *
+ */
+static int w_acc_radius_request(struct sip_msg *rq, char *comment, char *foo)
+{
+	return accb.exec(rq, &_acc_radius_engine, (acc_param_t*)comment);
+}
+

+ 39 - 0
modules_k/acc_radius/acc_radius_mod.h

@@ -0,0 +1,39 @@
+/*
+ * $Id$
+ *
+ * RADIUS Accounting module
+ *
+ * Copyright (C) 2001-2003 FhG Fokus
+ *
+ * This file is part of Kamailio, a free SIP server.
+ *
+ * Kamailio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * Kamailio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * ---------
+ */
+
+/*! \file
+ * \ingroup acc_radius
+ * \brief Acc_radius::  Core module
+ *
+ * - \ref acc_radius_mod.c
+ * - Module: \ref acc_radius
+ */
+
+#ifndef _ACC_RADIUS_MOD_H_
+#define _ACC_RADIUS_MOD_H_
+
+#endif

+ 4 - 0
modules_k/acc_radius/doc/Makefile

@@ -0,0 +1,4 @@
+docs = acc_radius.xml
+
+docbook_dir = ../../../docbook
+include $(docbook_dir)/Makefile.module

+ 43 - 0
modules_k/acc_radius/doc/acc_radius.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
+%docentities;
+
+]>
+
+<book xmlns:xi="http://www.w3.org/2001/XInclude">
+	<bookinfo>
+	<title>AACC_RADIUS Module</title>
+	<productname class="trade">&kamailio;</productname>
+	<authorgroup>
+        <author>
+        <firstname>Juha</firstname>
+        <surname>Heinanen</surname>
+        <email>[email protected]</email>
+        </author>
+		<author>
+		<firstname>Daniel-Constantin</firstname>
+		<surname>Mierla</surname>
+		<affiliation><orgname>asipto.com</orgname></affiliation>
+		<email>[email protected]</email>
+		</author>
+		<editor>
+		<firstname>Daniel-Constantin</firstname>
+		<surname>Mierla</surname>
+		<affiliation><orgname>asipto.com</orgname></affiliation>
+		<email>[email protected]</email>
+		</editor>
+	</authorgroup>
+	<copyright>
+		<year>2002</year>
+		<year>2003</year>
+		<holder>FhG FOKUS</holder>
+	</copyright>
+	</bookinfo>
+	<toc></toc>
+
+	<xi:include href="acc_radius_admin.xml"/>
+</book>

+ 199 - 0
modules_k/acc_radius/doc/acc_radius_admin.xml

@@ -0,0 +1,199 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
+%docentities;
+
+]>
+
+<!-- Acc Module User's Guide -->
+
+<chapter>
+	
+	<title>&adminguide;</title>
+	
+	<section>
+	<title>Overview</title>
+	<para>
+		ACC_RADIUS module is used to account transaction information to 
+		<acronym>RADIUS</acronym> server. It binds to ACC module API and uses the
+		same accounting mechanisms as for other backends.
+	</para>
+	<para>
+		Therefore you need this module just to send accounting data to a
+		RADIUS server - for more documentation regarding accounting, see the ACC
+		readme. 
+	</para>
+	</section>
+
+	<section>
+		<title>Dependencies</title>
+		<section>
+			<title>&kamailio; Modules</title>
+			<para>
+			The module depends on the following modules (in the other words 
+			the listed modules must be loaded before this module):
+			<itemizedlist>
+				<listitem>
+				<para><emphasis>acc</emphasis> - accounting module</para>
+				</listitem>
+			</itemizedlist>
+			</para>
+		</section>
+		<section>
+			<title>External Libraries or Applications</title>
+			<para>
+			The following libraries or applications must be installed 
+			before running &kamailio; with this module loaded:
+			</para>
+			<itemizedlist>
+				<listitem>
+				<para><emphasis>radiusclient-ng</emphasis> 0.5.0 or higher.
+				See <ulink 
+				url='http://developer.berlios.de/projects/radiusclient-ng/'>
+				http://developer.berlios.de/projects/radiusclient-ng/</ulink>.
+				</para>
+				</listitem>
+			</itemizedlist>
+		</section>
+	</section>
+
+	<section id="ACC-param-id">
+	<title>Exported Parameters</title>
+	<section>
+		<title><varname>radius_config</varname> (string)</title>
+		<para>
+		<emphasis>This parameter is radius specific.</emphasis> Path to 
+		radius client configuration file, set the referred config file 
+		correctly and specify there address of server, shared secret 
+		(should equal that in /usr/local/etc/raddb/clients for
+		freeRadius servers) and dictionary, see etc for an example of 
+		config file and dictionary.
+		</para>
+		<para>
+		If the parameter is set to empty string, the RADIUS accounting support
+		will be disabled (even if compiled).
+		</para>
+		<para>
+		Default value is <quote>NULL</quote>.
+		</para>
+		<example>
+		<title>radius_config example</title>
+		<programlisting format="linespecific">
+...
+modparam("acc_radius", "radius_config", "/etc/radiusclient/radiusclient.conf")
+...
+</programlisting>
+		</example>
+	</section>
+	<section>
+		<title><varname>radius_flag</varname> (integer)</title>
+		<para>
+		Request flag which needs to be set to account a 
+		transaction -- RADIUS specific.
+		</para>
+		<para>
+		Default value is not-set (no flag).
+		</para>
+		<example>
+		<title>radius_flag example</title>
+		<programlisting format="linespecific">
+...
+modparam("acc_radius", "radius_flag", 2)
+...
+</programlisting>
+		</example>
+	</section>
+	<section>
+		<title><varname>radius_missed_flag</varname> (integer)</title>
+		<para>
+		Request flag which needs to be set to account missed 
+		calls -- RADIUS specific.
+		</para>
+		<para>
+		Default value is not-set (no flag).
+		</para>
+		<example>
+		<title>radius_missed_flag example</title>
+		<programlisting format="linespecific">
+...
+modparam("acc_radius", "radius_missed_flag", 3)
+...
+</programlisting>
+		</example>
+	</section>
+	<section>
+		<title><varname>service_type</varname> (integer)</title>
+		<para>
+		Radius service type used for accounting.
+		</para>
+		<para>
+		Default value is 15 (SIP).
+		</para>
+		<example>
+		<title>service_type example</title>
+		<programlisting format="linespecific">
+...
+modparam("acc_radius", "service_type", 16)
+...
+</programlisting>
+		</example>
+	</section>
+	<section>
+		<title><varname>radius_extra</varname> (string)</title>
+		<para>
+		Extra values to be logged via RADIUS - RADIUS specific.
+		</para>
+		<para>
+		Default value is NULL.
+		</para>
+		<example>
+		<title>radius_extra example</title>
+		<programlisting format="linespecific">
+...
+modparam("acc_radius", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)")
+...
+</programlisting>
+		</example>
+	</section>
+	</section>
+
+	<section>
+	<title>Exported Functions</title>
+	<section>
+		<title>
+			<function moreinfo="none">acc_rad_request(comment)</function>
+		</title>
+		<para>
+		Like <function moreinfo="none">acc_log_request</function> of acc module, 
+		<function moreinfo="none">acc_rad_request</function> reports on 
+		a SIP request event. It reports to radius server as configured in 
+		<quote>radius_config</quote>.
+		</para>
+		<para>
+		Meaning of the parameters is as follows:</para>
+		<itemizedlist>
+		<listitem>
+			<para><emphasis>comment</emphasis> - Comment to be appended.
+			</para>
+		</listitem>
+		</itemizedlist>
+		<para>
+		This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
+		</para>
+		<example>
+		<title>acc_rad_request usage</title>
+		<programlisting format="linespecific">
+...
+acc_rad_request("Some comment");
+...
+acc_rad_request("200 From Config");
+...
+</programlisting>
+		</example>
+	</section>
+	</section>
+</chapter>
+