using variable

Simon Hobson dhcp at thehobsons.co.uk
Wed Mar 22 08:50:33 UTC 2006


Pierre LEONARD wrote:

>you understood my problem but there is another problem:
>
>/*class "vlan1-clients" { match if <insert conditions here> } ;
>
>*/it's not possible to use my variable instead of "<insert conditions
>here>" and i don't why
>i can just use it like following:
>
>/*set test = "value";
>if test = "value" {<treatement>;}
>*/
>and the treatment cannot be a block subnet, shared-network, pool, class...
>so i'm blocked
>
>
>
>_my complete code:_
>
>#checking vlan
>if (binary-to-ascii (10, 16, "", substring( option agent.circuit-id, 2,
>2))= "10" {
>log(info , "checking vlan");
>
>#checking switch
>if binary-to-ascii(16, 8, ":", substring( option agent.remote-id, 2, 6))
>= "<mac address>") {
>log( info, "checking switch mac address");
>set test = "ok";
>}
>}
>
>#*********************************************class
>definitions**************************************************
>class "port20" {
>match if binary-to-ascii (10, 8, "/", suffix( option agent.circuit-id,
>2)) = "0/19";
># match if test = "ok"; #launch but don't function
>}
>
>class "port21" {
>match if binary-to-ascii (10, 8, "/", suffix (option agent.circuit-id,
>2)) = "0/20";
># match if test = "ok"; #launch but don't function
>}

OK, I can't help with the way you want to do it as I've never gone 
into that detail with the server. But how about :

class "s1p20" {
   match if (substring( option agent.remote-id, 2, 6) = aa:bb:cc:dd:ee:ff)
        and (suffix( option agent.circuit-id, 2) = 00:16) ;
   log (info, "Switch 1, Port 0/20 matched" ) ;
}

Someone please correct me if I'm wrong, but I think you can specify a 
hex string like that instead of using binary-to-ascii. Hence, a 
decrease in size of the config, and a decrease in the processing 
required to evaluate all the possible classes - note that the server 
must evaluate every class definition since (in the general case) any 
client may be a member of more than one class.

Since this sort of thing should be machine generated anyway for 
anything more than a trivial setup, it should be no problem using hex 
like that.

Simon


More information about the dhcp-users mailing list