Problems with reference '&' in switch #1240

Closed
jpereira opened this Issue Sep 16, 2015 · 7 comments

Projects

None yet

3 participants

@jpereira
Contributor

Hi,

Maybe we have a bug with reference in switch

e.g:

This works fine

 switch "%{proxy-reply:Packet-Type}" {
.....
 switch "%{Packet-Type}" {

but, not with &

 switch &proxy-reply:Packet-Type {
....
 switch &Packet-Type {
@alandekok
Member

The Packet-Type is a virtual attribute... you can only refer to it via %{...} expansion.

This is a known issue...

@arr2036
Member
arr2036 commented Sep 16, 2015

Yeah, it's an absolute PITA to produce virtual values using attribute references. It's not going to get fixed any time soon. It would ugly up the code a lot.

@alandekok
Member

There is code in there to turn:

"%{User-Name}" --> &User-Name

and warn about it, in the modcall pass2 code.

There could also be checks for &...VIRTUAL-Attr, and change that to "%{...Virtual-Attr}"

which is annoying for the code, but nice for the admin

@arr2036
Member
arr2036 commented Sep 16, 2015

The whole point of attribute refs, is they're about as fast a access you can get to string values. They avoid all the expansion crap and copying to intermediary buffers, you get a pointer directly to the attributes value buffer if you use tmpl_expand.

@arr2036
Member
arr2036 commented Sep 16, 2015

yes I agree

@jpereira
Contributor

in the if() works fine.

Wed Sep 16 15:18:03 2015 : Debug: (3)     post-proxy {
Wed Sep 16 15:18:03 2015 : Debug: (3)       if (&proxy-reply:Packet-Type != CoA-ACK && &proxy-reply:Packet-Type != Disconnect-ACK) {
Wed Sep 16 15:18:03 2015 : Debug: (3)       EXPAND TMPL XLAT STRUCT
Wed Sep 16 15:18:03 2015 : Debug: (3)       EXPAND &proxy-reply:Packet-Type
Wed Sep 16 15:18:03 2015 : Debug: (3)          --> CoA-NAK
Wed Sep 16 15:18:03 2015 : Debug: (3)       EXPAND TMPL XLAT STRUCT
Wed Sep 16 15:18:03 2015 : Debug: (3)       EXPAND &proxy-reply:Packet-Type
Wed Sep 16 15:18:03 2015 : Debug: (3)          --> CoA-NAK
@alandekok
Member

yes, if you look at that, the &proxy-reply:Packet-Type has been changed to an xlat. :)

@alandekok alandekok closed this in cb99c01 Sep 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment