Module: kamailio
Branch: master
Commit: 139997826c8c3205504a0c799d7aa98b979e1185
URL:
https://github.com/kamailio/kamailio/commit/139997826c8c3205504a0c799d7aa98…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-10-26T21:38:52+01:00
Merge pull request #378 from ycaner06/patch-7
acc_radius : added radius time mode
---
Modified: modules/acc_radius/acc_radius_mod.c
Modified: modules/acc_radius/doc/acc_radius_admin.xml
---
Diff:
https://github.com/kamailio/kamailio/commit/139997826c8c3205504a0c799d7aa98…
Patch:
https://github.com/kamailio/kamailio/commit/139997826c8c3205504a0c799d7aa98…
---
diff --git a/modules/acc_radius/acc_radius_mod.c b/modules/acc_radius/acc_radius_mod.c
index 5a660d6..3820339 100644
--- a/modules/acc_radius/acc_radius_mod.c
+++ b/modules/acc_radius/acc_radius_mod.c
@@ -74,6 +74,7 @@ static char *radius_config = 0;
int radius_flag = -1;
int radius_missed_flag = -1;
static int service_type = -1;
+int rad_time_mode=0;
void *rh;
/* rad extra variables */
static char *rad_extra_str = 0;
@@ -91,11 +92,12 @@ static cmd_export_t cmds[] = {
static param_export_t params[] = {
- {"radius_config", PARAM_STRING, &radius_config },
+ {"radius_config", PARAM_STRING, &radius_config },
{"radius_flag", INT_PARAM, &radius_flag },
{"radius_missed_flag", INT_PARAM, &radius_missed_flag },
{"service_type", INT_PARAM, &service_type },
- {"radius_extra", PARAM_STRING, &rad_extra_str },
+ {"radius_extra", PARAM_STRING, &rad_extra_str },
+ {"rad_time_mode", INT_PARAM, &rad_time_mode },
{0,0,0}
};
@@ -328,6 +330,8 @@ int acc_radius_send_request(struct sip_msg *req, acc_info_t *inf)
int m=0;
int o=0;
int rc_result=-1;
+ double tsecmicro;
+ char smicrosec[18];
send=NULL;
@@ -347,9 +351,18 @@ int acc_radius_send_request(struct sip_msg *req, acc_info_t *inf)
av_type = req->REQ_METHOD; /* method */
ADD_RAD_AVPAIR( RA_SIP_METHOD, &av_type, -1);
- /* unix time */
- av_type = (uint32_t)inf->env->ts;
- ADD_RAD_AVPAIR( RA_TIME_STAMP, &av_type, -1);
+ // Event Time Stamp with Microseconds
+ if(rad_time_mode==1){
+ gettimeofday(&inf->env->tv, NULL);
+
tsecmicro=inf->env->tv.tv_sec+((double)inf->env->tv.tv_usec/1000000.0);
+ //radius client doesn t support double so convert it
+ sprintf(smicrosec,"%17.6f",tsecmicro);
+ ADD_RAD_AVPAIR(RA_TIME_STAMP, &smicrosec, -1);
+ }else{
+ av_type = (uint32_t)inf->env->ts;
+ ADD_RAD_AVPAIR(RA_TIME_STAMP, &av_type, -1);
+ }
+
/* add extra also */
o = accb.get_extra_attrs(rad_extra, req, inf->varr+attr_cnt,
diff --git a/modules/acc_radius/doc/acc_radius_admin.xml
b/modules/acc_radius/doc/acc_radius_admin.xml
index 17ebd2c..f439457 100644
--- a/modules/acc_radius/doc/acc_radius_admin.xml
+++ b/modules/acc_radius/doc/acc_radius_admin.xml
@@ -166,6 +166,39 @@ modparam("acc_radius", "radius_extra",
"via=$hdr(Via[*]); email=$avp(s:email)")
</programlisting>
</example>
</section>
+ <section>
+ <title><varname>rad_time_mode</varname>(integer)</title>
+ <para>
+ Radius Event-Timestamp for accounting.
+ </para>
+ <para>
+ Values can be:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>0</emphasis> - (default), format is only unix
+ timestamp for Event-Timestamp (For example: 1445590624)</para>
+ </listitem>
+ <listitem>
+ <para><emphasis>1</emphasis> - format is unix timestamp with
microseconds
+ in Addition, it needs to change Event-Timestamp attribute type in dictionary to
string
+ both radius server and client
+ (For example: 1445590624.377372) </para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ Default value is 0 (Unix timestamp).
+ </para>
+ <example>
+ <title>rad_time_mode example</title>
+ <programlisting format="linespecific">
+...
+modparam("acc_radius", "rad_time_mode", 1)
+...
+</programlisting>
+ </example>
+</section>
</section>
<section>