reference packet code in unlang?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi list, we sometimes get Accounting-On/Off tickets that are not meant for us (don't ask... bugyy NASes). I have a filter criterion: the NAS sends in Acct-Session-Id a unique string. When it's meant for us it has a certain value, wehen not, the string is different. I would like to match the packets in unlang in preacct and ACK the packets while not actually processing them (empty accounting{} section). Using the following in preacct threw a parser error. Maybe I'm just blind. I don't see the syntax error: if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ "restena.*")) update control { ~ Proxy-To-Realm := testrealm.lu ~ } (first and second line wrapped) I'm sort of lost... Greetings, Stefan Winter -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFIDdpE+jm90f8eFWYRAgUkAJ9ivmuZk+W50wXkEV2PeMeSH/sJVgCfQBSO 6UK49D6t2Fk1UPagntYa10I= =CSEz -----END PGP SIGNATURE-----
Stefan Winter wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi list,
we sometimes get Accounting-On/Off tickets that are not meant for us (don't ask... bugyy NASes). I have a filter criterion: the NAS sends in Acct-Session-Id a unique string. When it's meant for us it has a certain value, wehen not, the string is different. I would like to match the packets in unlang in preacct and ACK the packets while not actually processing them (empty accounting{} section).
Using the following in preacct threw a parser error. Maybe I'm just blind. I don't see the syntax error:
if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ /restena.*/)) update control { ~ Proxy-To-Realm := testrealm.lu ~ }
(first and second line wrapped)
I'm sort of lost...
if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ /restena.*/)) update control { ~ Proxy-To-Realm := testrealm.lu ~ } Arran
Greetings,
Stefan Winter -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFIDdpE+jm90f8eFWYRAgUkAJ9ivmuZk+W50wXkEV2PeMeSH/sJVgCfQBSO 6UK49D6t2Fk1UPagntYa10I= =CSEz -----END PGP SIGNATURE----- - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Arran Cudbard-Bell (A.Cudbard-Bell@sussex.ac.uk) Authentication, Authorisation and Accounting Officer Infrastructure Services | ENG1 E1-1-08 University Of Sussex, Brighton EXT:01273 873900 | INT: 3900
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 |> if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ |> /restena.*/)) update control { |> ~ Proxy-To-Realm := testrealm.lu |> ~ } You mean, replace " by / ? That didn't do the trick... if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ /restena.*/)) update control { ~ Proxy-To-Realm := testrealm.lu ~ } resulted in Parse error in condition at: Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ /restena.*/)) update control { Greetings, Stefan - - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFIDeLG+jm90f8eFWYRAic9AJwIuRTycJLXPhbmsd5KtgFkkHhU6wCcCzy6 dL/v1IugqQ/c3cWMi4C/ESs= =5y3Y -----END PGP SIGNATURE-----
Stefan Winter wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
|> if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ |> /restena.*/)) update control { |> ~ Proxy-To-Realm := testrealm.lu |> ~ }
You mean, replace " by / ? That didn't do the trick...
if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ /restena.*/)) update control { ~ Proxy-To-Realm := testrealm.lu ~ }
resulted in
Parse error in condition at: Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ /restena.*/)) update control {
Ok I haven't been keeping up with the syntaxical developments... so some of this may be slightly redundant. if (("%{Acct-Status-Type}" == 'Accounting-Off') && !("%{Acct-Session-Id}" =~ /restena.*/)) { update control { Proxy-To-Realm := 'testrealm.lu' } } That should work no matter how stupid the parser is... * Regular expressions have always been <attribute> ~= /<expr>/[<mod>] * Attribute expansion always used to be "%{[<list>:]<attribute>}" but I understand Alan changed that, though I thought he only deprecated the double quotes part not the percent curly braces wrapper... but don't take my word for it. * Strings you don't want to be expanded should be encapsulated in single quotes not double. * You can't do <condition><operation> on the same line * Sub conditions should be encapsulated in parenthesis Thanks, Arran
Greetings,
Stefan - - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFIDeLG+jm90f8eFWYRAic9AJwIuRTycJLXPhbmsd5KtgFkkHhU6wCcCzy6 dL/v1IugqQ/c3cWMi4C/ESs= =5y3Y -----END PGP SIGNATURE----- - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Arran Cudbard-Bell (A.Cudbard-Bell@sussex.ac.uk) Authentication, Authorisation and Accounting Officer Infrastructure Services | ENG1 E1-1-08 University Of Sussex, Brighton EXT:01273 873900 | INT: 3900
Arran Cudbard-Bell wrote:
Stefan Winter wrote: |> if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~
You should have brackets around this: if ((foo == "bar") && ...
Parse error in condition at: Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ /restena.*/)) update control {
Did I mention that the parser is crap?
if (("%{Acct-Status-Type}" == 'Accounting-Off') &&
Brackets are good, but "%{foo}" is not necessary.
* Regular expressions have always been <attribute> ~= /<expr>/[<mod>]
* Attribute expansion always used to be "%{[<list>:]<attribute>}" but I understand Alan changed that, though I thought he only deprecated the double quotes part not the percent curly braces wrapper... but don't take my word for it.
See "man unlang". This is explained.
* Strings you don't want to be expanded should be encapsulated in single quotes not double.
* You can't do <condition><operation> on the same line
* Sub conditions should be encapsulated in parenthesis
That was the original parse error. Alan DeKok.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi folks, |>> * Strings you don't want to be expanded should be encapsulated in single |>> quotes not double. |>> * You can't do <condition><operation> on the same line |>> * Sub conditions should be encapsulated in parenthesis thanks a lot, I finally figured it. Sorry for the noise. For reference, the result is below. Greetings, Stefan Winter if ((Acct-Status-Type == 'Accounting-Off') && !(Acct-Session-Id =~ /restena.*/)) { ~ update control { ~ Proxy-To-Realm := testrealm.lu ~ } } -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFIDtY/+jm90f8eFWYRAttqAJ9NypdrTlqvTqrpNgkh36HI+jXJQACffZnr 8yg9ww4RgMYrFkBuVp5Agg0= =gYAu -----END PGP SIGNATURE-----
Stefan Winter wrote:
Using the following in preacct threw a parser error. Maybe I'm just blind. I don't see the syntax error:
The parse is bad...
if (Acct-Status-Type == "Accounting-Off" && !(Acct-Session-Id =~ "restena.*")) update control { ~ Proxy-To-Realm := testrealm.lu ~ }
(first and second line wrapped)
if ((Acct-Status-Type == "Accounting-Off") && !(Acct-....)) { update control { Proxy-To-Realm... } } Remember, this isn't C. It's a line-based parser. Everything goes on one line, and you can't put "if" and "update" on the same line. Alan DeKok.
participants (3)
-
Alan DeKok -
Arran Cudbard-Bell -
Stefan Winter