cidr cast

Arran Cudbard-Bell a.cudbardb at freeradius.org
Wed Apr 15 17:19:22 CEST 2015


> On 15 Apr 2015, at 14:39, Alan DeKok <aland at deployingradius.com> wrote:
> 
> On Apr 15, 2015, at 9:00 AM, Peter Balsianok <balsianok.peter at 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 at freeradius.org>
FreeRADIUS development team

FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 872 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20150415/d47cdf8f/attachment.sig>


More information about the Freeradius-Users mailing list