Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have need to give a windows dhcp server a vendor specific option. In ISC DHCP, I do this: option pxelinux.pathprefix "http://raidtest.hos.anvin.org/tftpboot/"; For Windows, I need something that looks like this:
option vendor-encapsulated-options d0:04:f1:00:74:73: d2:23:68:74:74:70:3a:2f:2f:72:61:69:64:74:65:73:74:2e: 61:6e:76:69:6e:2e:6f:72:67:2f:74:66:74:70:62:6f: 6f:74:2f: d3:04:00:00:00:1e;
(example taken from http://syslinux.zytor.com/wiki/index.php/PXELINUX#using_vendor_options) How can I convert from the ISC format to this hexishness?

Replies are listed 'Best First'.
Re: dhcp vendor encapsulated options in perl
by shmem (Chancellor) on Nov 17, 2008 at 11:58 UTC

    d0, d2 and d3 are the option numbers 208, 210 and 211 (in hex). Next byte in hex is the length of the option string. To convert "http://raidtest.anvin.org/tftpboot/" into that hex representation, you could e.g.

    print join ":", map { sprintf "%x", ord $_ } split //, "http://raidtes +t.anvin.org/tftpboot/";

    See ord, hex, split, join, sprintf and map. Counting bytes with len and putting together the whole thing is left as an exercise to the reader. See also Net::DHCP::Options.

      Excellent, got it working now. Thanks :)
Re: dhcp vendor encapsulated options in perl
by bingos (Vicar) on Nov 17, 2008 at 11:14 UTC

    Nope, no matter how many times I look at this, I fail to see the relevance to perl