New feature in v3: cast!

Alan DeKok aland at
Sun May 12 22:58:23 CEST 2013

Brian Candler wrote:
> Certainly. I'd hope this would raise a type-mismatch error, rather than a
> Perl-style "guess how to convert the value".

  It's more possible now that the conditions are parsed at startup.

> As I see it, the problem is that the value is a string, but you want to
> treat it as something else.  So I would be inclined to make the value
> conversion explicit:

  Well, that's what it does now.

	if (<cdir>&Framed-IP-Address < "%{sql: ...}") {

  Casts the LHS to a CIDR.  It has to be the LHS, for reasons you
outline below.

> Typed values are pretty easy to handle. The thing which makes RADIUS special
> is the need to handle cases where the RHS is an enumerated value dependent
> on the dictionary type of the LHS:
>     Framed-Protocol == PPP
> So things like
>     PPP == Framed-Protocol
> or
>     Tmp-Integer-0 == PPP
> are unlikely to work. (And hence the == operator is non-commutative anyway).

  Exactly.  It could be made to work, but it would involve lots of
butchering of the server internals.

  I've already done that for the new condition && xlat code.  There's
less code, with more comments, that is clearer, with more test cases,
and more functionality.  I'd like to get it running for a while before
changing ti yet again.

  Alan DeKok.

More information about the Freeradius-Devel mailing list