Combining Classes

Glenn Satchell Glenn.Satchell at
Mon Mar 5 14:36:16 UTC 2007

>Subject: Combining Classes
>Date: Mon, 5 Mar 2007 14:50:10 +0100
>From: "Lars Jacobsen" <lj at>
>To: <dhcp-users at>
>Hi all.
>I have tried several thing to acomplish combing two casses into one -
>wihtout any luck so far.
>Dos anyone have succeded in this, using only the already defined classes
>I mean without making any class match validation again.
>class "one" {
>            match substring (hardware, 1, 3);
>                    }
>        subclass "one" 00:11:22; # 
>class "two" {
>         match if  substring ( (option agent.circuit-id) , 0,4)= "1234"
>So far a have tried with combinations like these, but none of them work:
>### Combined ###
>class "combined" {
>         match if  ( (class = "one") AND (class = "two") );
>### Combined ###
>class "combined" { match if  ( ("one") AND ("two") );
>### Combined ###
>class "combined" {
>         match if  ( (members of "one") AND (members of "two") );
>### Combined ###
>class "combined" {
>         members of  ( ("one") AND ("two") );
>### Combined ###
>class "combined" {
>         ( (members of "one") and (members of "two") );
>Reason I want to do it this way instead of adding the complete
>validation syntax to the "combined" class, is because a have thousands
>of classes already defined based on more complex equations than the
>above example, and I don't want to do them all over again just because I
>want to do a combination match.

Hi Lars

I don't think it is possible to do what you are trying to do.

man dhcp-eval says

     The if statement and the elsif continuation  statement  both
     take boolean expressions as their arguments.   That is, they
     take expressions that, when  evaluated,  produce  a  boolean

Then follows a list of boolean expressions

     data-expression-1 = data-expression-2
     boolean-expression-1 and boolean-expression-2
     boolean-expression-1 or boolean-expression-2
     not boolean-expression
     exists option-name

man dhcpd.conf says

     When declaring permit lists for  address  allocation  pools,
     the following syntaxes are recognized following the allow or
     deny keywords:

     members of "class";
     etc, etc.
Note that allow and deny take a permit list, not a boolean value. Thus
'member of "one"' is not a boolean value, so it is not valid in an if

I think the only way is going to be to recalculate the values in the
match statement. Some careful use of sub-classes may make this more

class "combined" {
  match concat (substring (hardware, 1, 3), substring (option agent.circuit-id, 

subclass "combined" 00:11:22:31:32:33:34;

Yes it's ugly!

One other thought - when you try to do something that turns out to be
quite tricky it sometimes helps to explain the result you're trying to
achieve. There may be an entirely different way to achieve that result.
So perhaps if you can explain what it is you want to achieve the
collective wisdom of the list may come up with an elegant solution.



More information about the dhcp-users mailing list