string data expressions (was Re: using option 82 to assign a static ip-address)
Glenn Satchell
glenn.satchell at uniq.com.au
Mon Dec 17 14:44:37 UTC 2012
On Tue, December 18, 2012 1:28 am, perl-list wrote:
> Glenn,
>
> Don't mean to hijack the thread but...
>
> Is that right? I did not know that if you simply do not enclose the match
> text in quotes that it would match binary info!! That de-screws something
> that I have been struggling with! Some option 82 from some manufacturers
> is binary, others it is ASCII. If I simply can match in this manner ...
>
> Does this work for ASCII as well or only binary?
>
> hmmm - what to do if the text that the manufacturer sends is something
> like: VLAN 1 Port 4
>
>> These can all be re-written without the binary-to-ascii and be much
>> clearer:
>
>> match if substring(option agent.remote-id, 2, 7)) = 84:78:ac:84:e5:80
>> and hardware = 1:0:14:2d:40:f:15
>> and substring(option agent.circuit-id, 5, 1)) = e;
You can use a colon list of hexadecimal characters to represent a string.
This is from the dhcp-eval man page:
string
A string, enclosed in quotes, may be specified as a data
expression, and returns the text between the quotes,
encoded in ASCII. The backslash ('\') character is
treated specially, as in C programming: '\t' means TAB,
'\r' means carriage return, '\n' means newline, and '\b'
means bell. Any octal value can be specified with
'\nnn', where nnn is any positive octal number less than
0400. Any hexadecimal value can be specified with '\xnn',
where nn is any positive hexadecimal number less than or
equal to 0xff.
colon-separated hexadecimal list
A list of hexadecimal octet values, separated by colons,
may be specified as a data expression.
So to match something like VLAN 1 Port 4, you could use the string "VLAN 1
Port 4" or encode each character in hex
56:4C:41:4E:20:31:20:50:6F:72:66:20:34
Try man ascii to give you conversion tables.
regards,
-glenn
More information about the dhcp-users
mailing list