hex/integer value of ipaddr

Linux Chips linux.chips at gmail.com
Wed Dec 20 11:42:01 CET 2017


I am trying to expand an ipaddr typed attribute to hex value.
the man unlang page contains the following :
> e.g. If a request contains "Framed-IP-Address =", the expansion of %{hex:Framed-IP-Address} will yeild "0x7f000001".

but when ever I do that I get empty expansion.

I am configuring the dynamic-clients, and my clients IPs are defined in 
the db as signed int (well, ugly, but I can not change that at the 
moment), the database is mssql, so I do not have those fancy functions 
like INET_ATON()
I can do a SQL stored procedure to handle the conversion, but the 
expansion is much neater and simplifies things a lot.

below is the output of my radiusd -X when trying to make the expansion.

(0) server dynamic_clients {
(0) # Executing section authorize from file 
(0)   authorize {
(0)     if ("%{mssql_rbs: SELECT NASIndex FROM NASConfig WHERE NASIP = 
convert(int, %{hex:Packet-Src-IP-Address}) }") {
(0)     EXPAND %{User-Name}
(0)        -->
(0)     SQL-User-Name set to ''
rlm_sql (mssql_rbs): Reserved connection (0)
(0)     Executing select query:  SELECT NASIndex FROM NASConfig WHERE 
NASIP = convert(int, )
rlm_sql_freetds: unexpected result type from query
(0)     ERROR: rlm_sql_freetds: Server msg from 
"WIN-39JGB9CGE5E\EARTHLINKMSSQL": severity(102), number(15), origin(1), 
layer(1), procedure "none": Incorrect syntax near ')'.
(0)     ERROR: SQL query failed: server error
rlm_sql (mssql_rbs): Released connection (0)
Need 5 more connections to reach 10 spares
rlm_sql (mssql_rbs): Opening additional connection (5), 1 of 27 pending 
slots used
(0)     EXPAND %{mssql_rbs: SELECT NASIndex FROM NASConfig WHERE NASIP = 
convert(int, %{hex:Packet-Src-IP-Address}) }
(0)        -->
(0)     if ("%{mssql_rbs: SELECT NASIndex FROM NASConfig WHERE NASIP = 
convert(int, %{hex:Packet-Src-IP-Address}) }")  -> FALSE
(0)     [ok] = ok
(0)   } # authorize = ok
(0) } # server dynamic_clients
(0) Converting control list to client fields
(0)   ERROR: Cannot add client Required attribute 
"FreeRADIUS-Client-Secret" is missing
Ignoring request to auth address * port 1812 bound to server ELProxy 
from unknown client port 35221 proto udp
Ready to process requests

it is complaining about a syntax error where the "supposed" hex value 
would be (inside the convert function)
I also tried integer instead of hex with the same results

am I missing something here? I can not seam to find any other reference 
to the "hex" expansion online nor in the config/man.


More information about the Freeradius-Devel mailing list