TR: Encapsulated match if

Olivier Bax de Keating olivier.baxdekeating.external at aastra.com
Tue Mar 4 12:34:29 UTC 2008


I didn’t chech ‘man dhcp-eval’, and that’s done by now :-)

It’s true that need an ‘AND’ operator, but for before testing the second condition, I need to declare the vendor-option-space, like in my example:

    
    #condition1
    match  if  substring    (option  vendor-class-identifier, 0, 15) = "Name of Device1";
    
    # If the device is of the type DEVICE 1, it’s the value of the suboption 3 which is tested
    # I have to declare vendor-option-space as DEVICE1 before checking the second condition
    vendor-option-space DEVICE1;
    
    #condition2
    match  if  substring    (option DEVICE1.suboption1, 0, 4) = "value1");

 

 

 

Would you tell me what do u think about a ‘match if’ in an ‘if’ like in the following proposition ?

class "Device1" {
    if substring    (option  vendor-class-identifier, 0, 15) = "Name of Device1"{
        vendor-option-space DEVICE1;
        match  if  substring    (option DEVICE1.suboption1, 0, 4) = "value1");
    }
}

 

Best regards

 

Olivier

 

 

 

-----Message d'origine-----
De : dhcp-users-bounce at isc.org [mailto:dhcp-users-bounce at isc.org] De la part de Simon Hobson
Envoyé : mardi 4 mars 2008 12:07



 

 

À : dhcp-users at isc.org
Objet : Re: Encapsulated match if

 

Olivier Bax de Keating wrote:

 

>In each classes, I put 2 "match if", and I know 

>that this syntax is probably not correct. I'm 

>searching for the good one, I mean, a way to 

>encapsulate 2 conditions of match, with "if Š" 

>if it exists, or subclasses (but it seems to me 

>that they are not done for that ?)

 

 

Have you checked 'man dhcp-eval' ?

 

Two features you probably want to look at :

 

 

AND : if match if ( condition 1 AND condition 2 )

 

Fairly obvious, matches if both conditions are true.

 

 

match-first-value : match-first-value ( expression 1, expression 2, ... )

 

Function that returns the first non-null value. 

So if expression 1 has a value then it is 

returned, but if it is null then expression 2 is 

returned, and so on. I'm not sure you need this, 

as I'm not entirely sure what the question is !

 

 

________________________________

De : Olivier Bax de Keating 
Envoyé : mardi 4 mars 2008 11:39
À : 'dhcp-users at isc.org'
Objet : Encapsulated match if

 

Hi,

 

I’m new to dhcpd servers, but I’d like to know if it’s possible to filter devices on a vendor suboption, which depends on the vendor-class-identifier.
I give an example of what I’d like in the following lines. 

 

#codes device1
option space DEVICE1;
option DEVICE1.suboption1 code 3 = text;
option DEVICE1.suboption2 code 4 = unsigned integer 16;
 
#codes device2 (la suboption1 est commune aux deux appareils, mais n'a pas le même numéro de code)
option space DEVICE2;
option DEVICE2.suboption1 code 1 = text;
option DEVICE2.suboption3 code 3 = ip-address;
 
class "Device1" {
    match  if  substring    (option  vendor-class-identifier, 0, 15) = "Name of Device1";
    # Si l'appareil est de type DEVICE 1, le c'est le sous code 3 qui est testé
    vendor-option-space DEVICE1;
    match  if  substring    (option DEVICE1.suboption1, 0, 4) = "value1");
}
 
class "Device2" {
    match  if  substring    (option  vendor-class-identifier, 0, 15) = "Name of Device2";
    # Si l'appareil est de type DEVICE 2, le c'est le sous code 1 qui est testé
    vendor-option-space DEVICE2;
    match  if  substring    (option DEVICE2.suboption1, 0, 4) = "value1");
}
 
 
shared-network mynetwork{
    option server.min-lease-time 600000;
    option server.default-lease-time 700000;
    option server.max-lease-time 800000;
 
    subnet 127.0.0.1 netmask 255.255.255.0 {
        option tftp-server-name "localhost";
    }
 
    pool {
        allow members of "Device1";
        allow members of "Device2";
        range 127.0.0.10 127.0.0.40;
    }
}

 

The IPs and domain names are for the example only. In each classes, I put 2 “match if”, and I know that this syntax is probably not correct. I’m searching for the good one, I mean, a way to encapsulate 2 conditions of match, with “if …” if it exists, or subclasses (but it seems to me that they are not done for that ?)

Thx for all

 

Best regards

 

Olivier

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20080304/26ef874a/attachment.html>


More information about the dhcp-users mailing list