string data expressions (was Re: using option 82 to assign a static ip-address)

Simon Hobson dhcp1 at thehobsons.co.uk
Mon Dec 17 16:22:47 UTC 2012


At Mon, 17 Dec 2012 10:03:45 -0500 (EST), perl-list wrote:
> So the best solution is to convert everything to binary? 

No, the best solution is to use whatever is best for your situation.

When dealing with "text" data it's probably easier to deal with text, eg if your device sends a value that is a text string, then do a text comparison <something> ="VLAN 1 Port 4". Similarly for other "text" values such as hostnames, domain names, etc.

When dealing with "binary" data (such as MAC addresses), it's probably easier to use hex. Eg, <something> = 00:11:22:33:44:55.

There's no "conversion" involved. To the program, values are collections of bytes - it doesn't care if it's something us humans usually deal with as text, or something that's "not text", it's just a collection of bytes. When specifying a string to match against in the config file, then we have a choice of syntax to use - in either case there's a conversion from the textual representation we use in the config file into a list of bytes. If we use "Text" then the program will convert that text into four bytes, if instead we use 54:65:78:74 then we still end up with the same four bytes after the program has parsed our config.

-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.


More information about the dhcp-users mailing list