]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move Acct-Delay-Time mangling to unlang
authorAlan T. DeKok <aland@freeradius.org>
Sun, 31 Mar 2019 22:53:41 +0000 (18:53 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 1 Apr 2019 01:19:24 +0000 (21:19 -0400)
raddb/sites-available/detail
src/modules/proto_detail/proto_detail.c

index cff89688042b7c2a5018d017d9e6762d0ac74387..255d43fbb2e77022574b5f31597934b90836923b 100644 (file)
@@ -224,6 +224,9 @@ server detail {
 #  'recv' section.  Note that there is no second name to the section.
 #
 recv {
+       update request {
+               Acct-Delay-Time := "%{expr:%{Acct-Delay-Time} + %l - %{%{Event-Timestamp}:-%{Packet-Original-Timestamp}}"
+       }
 
        #
        #  We handled the packet successfully.  Run the "send ok" section.
index 605864a02af19543cd59cabc73381aaf6b30bf8a..b54e8dc252a00148f430abc1cb369a758c7274a4 100644 (file)
@@ -90,9 +90,6 @@ static fr_dict_attr_t const *attr_packet_src_port;
 static fr_dict_attr_t const *attr_packet_type;
 static fr_dict_attr_t const *attr_protocol;
 
-static fr_dict_attr_t const *attr_event_timestamp;
-static fr_dict_attr_t const *attr_acct_delay_time;
-
 extern fr_dict_attr_autoload_t proto_detail_dict_attr[];
 fr_dict_attr_autoload_t proto_detail_dict_attr[] = {
        { .out = &attr_packet_dst_ip_address, .name = "Packet-Dst-IP-Address", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_freeradius },
@@ -104,8 +101,6 @@ fr_dict_attr_autoload_t proto_detail_dict_attr[] = {
        { .out = &attr_packet_src_port, .name = "Packet-Src-Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius },
        { .out = &attr_protocol, .name = "Protocol", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
 
-       { .out = &attr_acct_delay_time, .name = "Acct-Delay-Time", .type = FR_TYPE_UINT32, .dict = &dict_radius },
-       { .out = &attr_event_timestamp, .name = "Event-Timestamp", .type = FR_TYPE_DATE, .dict = &dict_radius },
        { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
        { NULL }
 };
@@ -367,27 +362,6 @@ static int mod_decode(void const *instance, REQUEST *request, uint8_t *const dat
                while ((p < end) && (*p)) p++;
        }
 
-       /*
-        *      Create / update accounting attributes.
-        */
-       if (request->packet->code == FR_CODE_ACCOUNTING_REQUEST) {
-               /*
-                *      Prefer the Event-Timestamp in the packet, if it
-                *      exists.  That is when the event occurred, whereas the
-                *      "Timestamp" field is when we wrote the packet to the
-                *      detail file, which could have been much later.
-                */
-               vp = fr_pair_find_by_da(request->packet->vps, attr_event_timestamp, TAG_ANY);
-               if (vp) timestamp = vp->vp_uint32;
-
-               /*
-                *      Look for Acct-Delay-Time, and update
-                *      based on Acct-Delay-Time += (time(NULL) - timestamp)
-                */
-               MEM(pair_update_request(&vp, attr_acct_delay_time) >= 0);
-               if (timestamp != 0) vp->vp_uint32 += time(NULL) - timestamp;
-       }
-
        /*
         *      Let the app_io take care of populating additional fields in the request
         */