hex/integer value of ipaddr

Linux Chips linux.chips at gmail.com
Wed Dec 20 14:03:38 CET 2017


On 12/20/2017 02:10 PM, Arran Cudbard-Bell wrote:
> 
> 
>> On 20 Dec 2017, at 10:42, Linux Chips <linux.chips at gmail.com> wrote:
>>
>> 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.
> 
> 
> It's because Packet-Src-IP-Address is a virtual attribute.
> 
> # Insert in the virtual server before you call rlm_sql
> update request {
> 	Tmp-IP-Address-0 := "%{Packet-Src-IP-Address}"
> }
> 
> %{hex:Tmp-IP-Address-0}
> 
> 
> The xlat expansion code was built to work with C strings, this causes issues when working with binary data, which is why the hex
> expansion's input is an attribute reference.
> 
> Attribute references only function with "real" attributes in the request.
> 
> Some attributes never actually exist in the request, they're part of a set of attributes looked for especially in the xlat code
> so they're only accessible as expansions.
> 
> Solution is to access Packet-Src-IP-Address via an expansion, copy that to a real attribute and then pass that attribute to the
> hex expansion.
> 
> It'll be fixed in v4. In the reworked xlat code, it operates on sequences of boxed values instead of strings.
> 
> -Arran
> 
> 
> 
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
> 

thanks for the quick reply, I totally forgot about the virtual attribute 
thing, my bad :D
that tmp-ip trick solved it and all working now.
cheers



More information about the Freeradius-Devel mailing list