]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add Event-Timestamp for accounting packets
authorAlan T. DeKok <aland@freeradius.org>
Wed, 18 Jul 2012 21:30:10 +0000 (17:30 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 18 Jul 2012 21:32:09 +0000 (17:32 -0400)
src/modules/rlm_preprocess/rlm_preprocess.c

index fed42ad23800477ebb14f1065578e86abc53c32b..ba271dcc16809ad7bffd5a9152253c2f8811ea4d 100644 (file)
@@ -682,6 +682,7 @@ static int preprocess_authorize(void *instance, REQUEST *request)
 static int preprocess_preaccounting(void *instance, REQUEST *request)
 {
        int r;
+       VALUE_PAIR *vp;
        rlm_preprocess_t *data = (rlm_preprocess_t *) instance;
 
        /*
@@ -723,6 +724,23 @@ static int preprocess_preaccounting(void *instance, REQUEST *request)
 
        hints_setup(data->hints, request);
 
+       /*
+        *      Add an event timestamp.  This means that the rest of
+        *      the server can use it, rather than various error-prone
+        *      manual calculations.
+        */
+       vp = pairfind(request->packet->vps, PW_EVENT_TIMESTAMP, 0);
+       if (!vp) {
+               VALUE_PAIR *delay;
+
+               vp = radius_paircreate(request, &request->packet->vps,
+                                      PW_EVENT_TIMESTAMP, 0,
+                                      PW_TYPE_DATE);
+               vp->vp_date = request->packet->timestamp.tv_sec;
+               delay = pairfind(request->packet->vps, PW_ACCT_DELAY_TIME, 0);
+               if (delay) vp->vp_date -= delay->vp_integer;
+       }
+
        if ((r = huntgroup_access(request,
                                  data->huntgroups)) != RLM_MODULE_OK) {
                char buf[1024];