Updates to "unlang"
Matthew Newton
mcn4 at leicester.ac.uk
Fri Dec 11 17:31:46 CET 2015
On Fri, Dec 11, 2015 at 10:31:57AM -0500, Alan DeKok wrote:
> On Dec 11, 2015, at 9:54 AM, Matthew Newton <mcn4 at leicester.ac.uk> wrote:
> > It's much the same way as you use parameters for C functions, but
> > behind the scenes those values get put into CPU registers. The
> > parameters are much easier to comprehend (assuming the syntax is
> > sane).
>
> Do you have suggestions for syntax?
Haven't really thought about it much before. Maybe for starters
passing things in just simply something like this, to save the
extraneous update{} beforehand?
policy:
to_lower(Tmp-String-0) {
update reply {
Tmp-String-1 := "%{tolower:%{Tmp-String-0}}"
}
}
i.e. list of control attributes that are set when the
policy/module is called.
server:
# request:Calling-Station-Id contains AABBCCDDEEFF
to_lower(&Calling-Station-Id)
# control:Tmp-String-0 now contains AABBCCDDEEFF
# reply:Tmp-String-1 now contains aabbccddeeff
A development could then be to have a param list as well as
request/control/reply, so "parameters" don't mess up any of the
existing attribute lists. But that could get messy when one policy
calls another policy unless it was somehow nested, which I think
would be more undesireable.
An alternative would be to have everything within a policy work on
a separate param list created just for that policy, which is
discarded at the end of the policy, essentially local variables.
The above policy could then become the following (very forced
example):
policy:
to_lower(Tmp-String-0) {
update param {
Tmp-String-1 := "%{tolower:%{param:Tmp-String-0}}"
}
update reply {
Tmp-String-1 := ¶m:Tmp-String-1
}
}
i.e. list of control attributes that are set when the
policy/module is called.
server:
# request:Calling-Station-Id contains AABBCCDDEEFF
to_lower(&Calling-Station-Id)
# reply:Tmp-String-1 now contains aabbccddeeff
So control:Tmp-String-0 isn't messed up in the calling context.
I imagine the first of these isn't too hard to do and would save
quite a lot of messy updates-before-policies - but adding a
separate parameter list for each policy call might be more tricky.
And maybe it should be called "local" rather than "param" as well.
Matthew
--
Matthew Newton, Ph.D. <mcn4 at le.ac.uk>
Systems Specialist, Infrastructure Services,
I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom
For IT help contact helpdesk extn. 2253, <ithelp at le.ac.uk>
More information about the Freeradius-Devel
mailing list