Dealing with possible list of numeric option values (pxe-system-type)
dhcp1 at thehobsons.co.uk
Mon Nov 16 12:44:18 UTC 2020
Glenn.Satchell at uniq.com.au wrote:
> Lists are encoded as a byte stream of concatenated values, so a list of int32 would be groups of 4 bytes, int16 as groups of 2 bytes, etc.
> You might be able to use the regex match to pick a value in the subsequent byte stream, regex is defined in dhcp-eval as
> data-expression-1 ~= data-expression-2
> such as
> if option pxe-system-type ~= 00:07 then ...
> I haven't tested this, so you may want to verify my suggestion.
It may be fine in this case, but in the general case you need to be careful not to have false matches across options. E.g. if there were two options of (say) ff:00 and 07:1f (in that order) then neither option is 00:07, but if you do an unconstrained regex match then it would detect 00:07.
I suppose one way would be to do a match along the lines of :
substr(option,0,2)=00:07 or substr(option,2,2)=00:07 or ... or substr(option,2n,2)=00:07
But then you can quickly get into a bit of a mess, and are still hardcoding a specific limit in number of values you will search through.
There is a bigger issue if an option is not made up of elements that are all the same set length - and I think that would need external processing to split out individual elements.
More information about the dhcp-users