[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gnu-radius] Cisco-AVPair rewrite function
From: |
Sergey Poznyakoff |
Subject: |
Re: [Help-gnu-radius] Cisco-AVPair rewrite function |
Date: |
Thu, 20 Jun 2002 15:44:12 +0300 |
> With this function in rewrite.full I wanted only to log AVPairs but =
> nothing was logged.=20
Notice that raddb/rewrite.full is not read by the server. It is provided as
an example of various rewrite functions. The file that _is_ read is
raddb/rewrite. Make sure you place the function there.
> I wonder if someone have a rewriting rule for extracting data from =
> Cisco-AVPair. I can't figure out how to handle those infos from radius =
You will need the patch to version 0.96.3 that extends the rewrite
syntax enabling it to address a single attribute from the set
of repeating attributes. The patch is available from:
http://savannah.gnu.org/patch/?func=detailpatch&patch_id=366&group_id=92
After applying the patch you will be able to access nth Cisco-AVPair
attribute using notation %[Cisco-AVPair](n).
Now, the rewriting function will be (make sure the file dict/cisco is
included by your raddb/dictionary):
integer
rewrite_avpair(string s)
{
if (s =~ "disc-cause-ext=\(.*\)") {
%[Acct-Terminate-Cause] = \1;
} else if (s =~ "pre-bytes-in=\(.*\)") {
%[Acct-Input-Octets] = %[Acct-Input-Octets] + (integer) \1;
} /* else ... -- add whatever attribute values you wish to handle */
return 0;
}
integer
cisco_av()
{
integer num;
while (*%[Cisco-AVPair](num)) {
rewrite_avpair(%[Cisco-AVPair](num));
num = num + 1;
}
return 0;
}
Using this patch it is also possible to delete all or one of the
matching atrributes. The delete statement is
delete %[Attr];
(deletes all occurrences of the attribute Attr from the packet)
or
delete %[Attr](n);
(deletes only nth attribute Attr)
Regards,
Sergey