Encapsulated match if

Olivier Bax de Keating olivier.baxdekeating.external at aastra.com
Wed Mar 5 15:04:48 UTC 2008


Hello Glenn,
Thx for your proposition.

Isn't the "request" command from the client traduced in an option 55 in dhcpcd ?
My goal isn't to send option 67 if asked (in which case defining a subnet would be enough), but to discriminate devices between those which request option 67 and those which don't. I think your proposition with execute is the way to do this. I'll try do it.

Thx a lot

Olivier


-----Message d'origine-----
De : dhcp-users-bounce at isc.org [mailto:dhcp-users-bounce at isc.org] De la part de Glenn Satchell
Envoyé : mercredi 5 mars 2008 15:52
À : dhcp-users at isc.org
Objet : RE: Encapsulated match if

What about just defining option 67 in an appropriate scope (maybe
subnet, global or group for example). If the client requested option
67, then it will be sent and if they don't request it, it won't be
sent, so no harm done?

Or just had this stroke of inspiration using execute to run an external
command:

  match if execute("expr",
    binary-to-ascii(10, 8, "-", option dhcp-parameter-request-list),
    ":", ".*-67");

You could also do something with awk or perl perhaps in a one-liner.

execute() is in 3.1.0, maybe 3.0.6? but not in 3.0.5.

man dhcp-eval

     execute (command-path [, data-expr1, ... data-exprN]);

       The execute statement runs an external command.  The first
       argument  is  a string literal containing the name or path
       of the command to run.  The other arguments,  if  present,
       are  either  string  literals  or  data- expressions which
       evaluate to text strings, to  be  passed  as  command-line
       arguments to the command.

regards,
-glenn

>Subject: RE: Encapsulated match if
>Date: Wed, 5 Mar 2008 14:38:52 +0100
>From: "Olivier Bax de Keating" <olivier.baxdekeating.external at aastra.com>
>To: <dhcp-users at isc.org>
>
>Hi,
>
>I wanted to know if it's possible for dhcpd to check if a given parameter is 
requested by the client, this means : if a given option code is in the option 55 
(Options Request List parameter). I can't use substring because I don't know in 
which order the options will appear)
>
>Examples :
>Option 55 presented by device 1: {1,3,60,66,67}
>Option 55 presented by device 2: {1,3,60,67}
>
>If I want to make a class of devices which request option 67, I don't know 
which function to use to do this, and if it's possible.
>
>If an isInArray function existed, here is what I'd like to do.
>
>class "Device1" {
>    match  if isInArray(option dhcp-parameter-request-list, 67);
>}
>
>If you've got any ideas ...
>
>Thx For all
>
>Olivier
>
>PS :
>
>For my previous pb, I'm gonna try smthg like that : 
>
>class "Device1" {
>    if substring    (option  vendor-class-identifier, 0, 15) = "Name of 
Device1"{
>	       #tells the DHCP server to use options in the DEVICE1 option space
>		vendor-option-space DEVICE1;
>    }
>    match  if  substring    (option DEVICE1.suboption1, 0, 4) = "value1");
>}
>
>
>-----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 !
>
>



More information about the dhcp-users mailing list