advice for breaking an array of vendor attributes into local attributes and updating a database

Matt Zagrabelny mzagrabe at
Tue Feb 16 23:53:46 CET 2021

Greetings FR-users,


I receive an accounting packet from a Cisco NAS. It has an array of
Cisco-AVPair tuples that FR processes. I am hoping to break out the various
Cisco-AVPair tuples into key-value pairs to insert into a database. I am
starting with a single (and specific) Cisco-AVPair.

Snippets of freeradius -X follows...

Here is the AVP in the accounting packet...
(23)   Cisco-AVPair = "mdm-tlv=device-platform-version=10.0.18363 "

Here is my unlang...
(23)       elsif ("%{Foreach-Variable-0}" =~
/^mdm-tlv=device-platform-version=(.*?) *$/)  {
(23)         update reply {

(23)           EXPAND %{1}

(23)              --> 10.0.18363

(23)           &Local-MDM-TLV-Device-Platform-Version := 10.0.18363

(23)         } # update reply = noop

Here is the SQL...
(23) sql_netdb: EXPAND UPDATE radius_accounting SET [...]
cisco_device_platform_version =
NULLIF('%{Local-MDM-TLV-Device-Platform-Version}', '') [...] WHERE
AcctUniqueId = '%{Acct-Unique-Session-Id}' AND AcctStopTime IS NULL

(23) sql_netdb:    --> UPDATE radius_accounting SET [...]
cisco_device_platform_version = NULLIF('', '') [...] WHERE AcctUniqueId =

You can see the attribute Local-MDM-TLV-Device-Platform-Version is the
empty string in the SQL.

I am having success with the foreach statement and a regex. In my default

accounting {
    foreach Cisco-AVPair {
        if ("%{Foreach-Variable-0}" =~
/^mdm-tlv=device-platform-version=(.*?) *$/) {
            update reply {
                &Local-MDM-TLV-Device-Platform-Version := "%{1}"

My dictionary looks like:

ATTRIBUTE       Local-MDM-TLV-Device-Platform-Version  7772    string

Am I using the wrong section in my default site for attempting to set a
local (internal) attribute?

I know that I am using "update reply" in my unlang. That doesn't feel
correct for accounting unlang, but I'll need correction or confirmation in
that area.

Any advice for breaking an array of vendor attributes into local attributes
and then updating a database with those local attributes?

Thank you for any help or hints!


More information about the Freeradius-Users mailing list