hex/integer value of ipaddr

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


Hi,

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 = 127.0.0.1", 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 
/etc/raddb/sites-enabled/dynamic-clients
(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 172.31.4.6: Required attribute 
"FreeRADIUS-Client-Secret" is missing
Ignoring request to auth address * port 1812 bound to server ELProxy 
from unknown client 172.31.4.6 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.

thanks
Ali


More information about the Freeradius-Devel mailing list