[ipxe-devel] Patch: Add ${mac/hexnone} settings type

Michael Brown mbrown at fensystems.co.uk
Fri Sep 28 09:46:34 UTC 2012


On Thursday 27 Sep 2012 11:20:10 Jeppe Toustrup wrote:
> storef_ok ( &test_settings, &test_hexnone_setting,
>     "113322", RAW ( 0x11, 0x33, 0x22 ) );
> 
> If I change the expected "113322" string to "11-33-22" instead, the
> test works fine. I don't get why that is, and would like some help on
> it. The fetchf_ok() test just below works fine though.
> 
> Note: I am by no means a C programmer, I just simply made this patch
> from my general source code knowledge and hoped that it would work.
> The feature itself also seems to work, at least from what I can see,
> but I don't understand why this test is failing.

You'll be able to observe an equivalent failure if you try

  set foo:hexnone 113322
  show foo

The problem is that parse_hex_setting() relies on having a non-hexdigit 
character to terminate each byte.  (It therefore allows syntax such as "1:2:3" 
rather than "01:02:03").

It might be easiest to use the base16_encode() and base16_decode() functions, 
in which case the setting type could sensibly be called "base16" and, by 
extension, it might be worth also adding the type "base64".

Michael



More information about the ipxe-devel mailing list