From: Alan T. DeKok Date: Sun, 31 Mar 2019 22:53:41 +0000 (-0400) Subject: move Acct-Delay-Time mangling to unlang X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5da7bbaaee70a59f4989ff56fcaa6b4bc85c384b;p=thirdparty%2Ffreeradius-server.git move Acct-Delay-Time mangling to unlang --- diff --git a/raddb/sites-available/detail b/raddb/sites-available/detail index cff89688042..255d43fbb2e 100644 --- a/raddb/sites-available/detail +++ b/raddb/sites-available/detail @@ -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. diff --git a/src/modules/proto_detail/proto_detail.c b/src/modules/proto_detail/proto_detail.c index 605864a02af..b54e8dc252a 100644 --- a/src/modules/proto_detail/proto_detail.c +++ b/src/modules/proto_detail/proto_detail.c @@ -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 */