[Kea-users] If statements in flex_id

Allan Tinker allan at m33access.com
Tue Oct 26 15:43:37 UTC 2021


This ended up doing the trick.

Turns out I needed to just do an ifelse() statement.

I append “GrandStream” in front of the devices MAC address. 
If it's not a Grandsream that I use, then I use the circuit ID. 

"identifier-expression": "ifelse(substring(option[60].hex,0,18) == 'HT8XX dslforum.org' or substring(option[60].hex,0,18) == 'HT802 dslforum.org' or substring(option[60].hex,0,18) == 'HT812 dslforum.org','GrandStream ' + relay4[2].hex,relay4[1].hex)”,

Thanks! 

- Allan

> On Oct 26, 2021, at 10:49 AM, Allan Tinker <allan at m33access.com> wrote:
> 
> In IPv4 Im trying to use the circuit ID as the identifier to restrict IPv4 leases to one IP address at bridged clients. 
> 
> However, some clients have phone service and we put a GrandStream ATA as a bridge after their ONU but before the router. 
> The ATA does pull from its own shared pool for IP leases, but it grabs that circuit ID and stores it in the lease table, not allowing anything else past it to obtain an IP address
> 
> Im trying to do an if statement in the “identifier-expression” under the flex_id hook to swap it out. 
> 
> This is what I have.. Im sure it's a syntax issue or something along those lines. But Im hoping that it's possible to do something like this:
> 
>     {
>     "library": "/usr/local/lib/kea/hooks/libdhcp_flex_id.so",
>         "parameters": { 
>     //  "identifier-expression": "relay4[1].hex",
>         "identifier-expression": "if (substring(option[60].hex,0,18) == 'HT8XX dslforum.org <http://dslforum.org/>' or substring(option[60].hex,0,18) == 'HT802 dslforum.org <http://dslforum.org/>' or substring(option[60].hex,0,18) == 'HT812 dslforum.org <http://dslforum.org/>') {option[60].hex,0,18} else {relay4[1].hex}",
>         "replace-client-id": true
>         }
>     },
> 
> Any help would be great
> 
> Thanks! 
> 
> - Allan
> _______________________________________________
> ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.
> 
> To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.
> 
> Kea-users mailing list
> Kea-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/kea-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/kea-users/attachments/20211026/c874a1db/attachment.htm>


More information about the Kea-users mailing list