Hi, May i use cid cast also for NAP-IP-Address ? if (<cidr>&NAS-IP-Address == 192.168.0.0/24) { update request { }
From change log 3.0.x:
One useful thing which i'm not sure Alan has implemented yet is: if (<cidr>&Framed-IP-Address == 192.168.0.0/24) { } I
On 15-04-15 10:29, Peter Balsianok wrote:
Hi,
May i use cid cast also for NAP-IP-Address ?
if (<cidr>&NAS-IP-Address == 192.168.0.0/24) {
From change log 3.0.x:
One useful thing which i'm not sure Alan has implemented yet is:
if (<cidr>&Framed-IP-Address == 192.168.0.0/24) {
I have my doubt about how useful these casts are. If I have just the IP address 192.168.0.1, there is no way to determine if casting to a CIDR would result in 192.168.0.0/24, 192.168.0.0/16 or any other possible value. That means we don't test for equality, but for containment with the == operator. Separate operators for contains/containedby might be a better idea. I know Postgresql has them (http://www.postgresql.org/docs/9.4/interactive/functions-net.html#CIDR-INET-...), but I always have to look them up because I can never remember the syntax. -- Herwin Weststrate
On Apr 15, 2015, at 4:29 AM, Peter Balsianok <balsianok.peter@gmail.com> wrote:
May i use cid cast also for NAP-IP-Address ?
if (<cidr>&NAS-IP-Address == 192.168.0.0/24) { update request {
}
Yes. The left hand side will be cast to a CIDR with the same net mask as the RHS. Alan DeKok.
It doesn`t work. Debug log (v3.0.7): Ready to process requests (0) Received Accounting-Request Id 12 from 127.0.0.1:59308 to 127.0.0.1:1813 length 233 ... (0) NAS-IP-Address = 213.151.231.112 ... (0) # Executing section preacct from file ./sites-enabled/default (0) preacct { (0) [preprocess] = ok (0) policy huntgroup-regexp { (0) if (!&Huntgroup-Name) { (0) if (!&Huntgroup-Name) -> TRUE (0) if (!&Huntgroup-Name) { (0) if (<cidr>&NAS-IP-Address == 213.151.231.0/24) { (0) if (<cidr>&NAS-IP-Address == 213.151.231.0/24) -> FALSE On Wed, Apr 15, 2015 at 2:31 PM, Alan DeKok <aland@deployingradius.com> wrote:
On Apr 15, 2015, at 4:29 AM, Peter Balsianok <balsianok.peter@gmail.com> wrote:
May i use cid cast also for NAP-IP-Address ?
if (<cidr>&NAS-IP-Address == 192.168.0.0/24) { update request {
}
Yes.
The left hand side will be cast to a CIDR with the same net mask as the RHS.
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On Apr 15, 2015, at 9:00 AM, Peter Balsianok <balsianok.peter@gmail.com> wrote:
It doesn`t work.
Ah... the RHS is cast to a network having /32, where the LHS is a /24. So they're not the same. You'll have to do: if (<cidr>&NAS-IP-Address < 213.151.231.0/24) { .. } Which will work. Alan DeKok.
On 15 Apr 2015, at 14:39, Alan DeKok <aland@deployingradius.com> wrote:
On Apr 15, 2015, at 9:00 AM, Peter Balsianok <balsianok.peter@gmail.com> wrote:
It doesn`t work.
Ah... the RHS is cast to a network having /32, where the LHS is a /24. So they're not the same.
You'll have to do:
if (<cidr>&NAS-IP-Address < 213.151.231.0/24) { .. }
Which will work.
Yes, casting an IP address to a subnet creates a /32 or /128 subnet depending on the IP version. Looking through the PostgreSQL operators I don't think they're any cleaner. They've overloaded shift operators to do their subset/superset stuff. If people want to compare IP addresses numerically they can cast to integers and use the integer comparison operators. Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
On 15/04/15 16:19, Arran Cudbard-Bell wrote:
Looking through the PostgreSQL operators I don't think they're any cleaner. They've overloaded shift operators to do their subset/superset stuff.
Well, that's a fairly arbitrary choice that goes back a long way. I suspect they'd use a specific "contains" operator these days, maybe @> for symmetry with the geometric and tsquery types. But you're quite right that Postgres inet/cidr operators have non-obvious edge cases; I use them a lot and still occasionally get bitten. As with many things, explicit is better than implicit magic with anything other than simple datatypes ;o)
participants (5)
-
Alan DeKok -
Arran Cudbard-Bell -
Herwin Weststrate -
Peter Balsianok -
Phil Mayers