The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 807 - File: showthread.php PHP 7.3.15 (Linux)
File Line Function
/showthread.php 807 errorHandler->error





Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get mac from ipxe in different format (no delimiter at all)
2013-05-04, 12:39 (This post was last modified: 2013-05-04 14:43 by Torgeir.)
Post: #1
get mac from ipxe in different format (no delimiter at all)
Hi!

I found myself in need of getting the mac from iPXE with no delimiter at all.
Sanboot with the MAC address (no delimited), in an embedded script within iPXE.

Usage:
Code:
iPXE> show mac
net0/mac:hex 00:aa:11:bb:22:cc

iPXE> show mac:hexhyp
net0/mac:hexhyp 00-aa-11-bb-22-cc

# hex no delimiter
iPXE> show mac:hexnd
net0/mac:hexnd 00aa11bb22cc

So I made myself a little patch for this (don't know if anyone else would ever need it...), but here it goes.

settings.c.patch
Code:
--- a/src/core/settings.c    2013-05-04 12:41:09.828764000 +0200
+++ b/src/core/settings.cc    2013-05-04 12:39:54.476391000 +0200
@@ -1770,6 +1770,20 @@
    return format_hex_setting ( raw, raw_len, buf, len, "-" );
}

+/**
+ * Format hex string setting value (using no delimiter)
+ *
+ * @v raw        Raw setting value
+ * @v raw_len        Length of raw setting value
+ * @v buf        Buffer to contain formatted value
+ * @v len        Length of buffer
+ * @ret len        Length of formatted value, or negative error
+ */
+static int format_hex_no_delimiter_setting ( const void *raw, size_t raw_len,
+                       char *buf, size_t len ) {
+    return format_hex_setting ( raw, raw_len, buf, len, "" );
+}
+
/** A hex-string setting (colon-delimited) */
struct setting_type setting_type_hex __setting_type = {
    .name = "hex",
@@ -1784,6 +1798,13 @@
    .format = format_hex_hyphen_setting,
};

+/** A hex-string setting (no delimiter) */
+struct setting_type setting_type_hex_no_delimiter __setting_type = {
+    .name = "hexnd",
+    .parse = parse_hex_setting,
+    .format = format_hex_no_delimiter_setting,
+};
+
/**
  * Parse UUID setting value
  *
settings.h.patch
Code:
--- a/src/ipxe/include/settings.h    2013-05-04 12:41:09.928765000 +0200
+++ b/src/ipxe/include/settings.hh    2013-05-04 12:39:21.272226000 +0200
@@ -322,6 +322,7 @@
extern struct setting_type setting_type_uint32 __setting_type;
extern struct setting_type setting_type_hex __setting_type;
extern struct setting_type setting_type_hexhyp __setting_type;
+extern struct setting_type setting_type_hex_no_delimiter __setting_type;
extern struct setting_type setting_type_uuid __setting_type;

extern struct setting ip_setting __setting ( SETTING_IPv4 );

Torgeir
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
get mac from ipxe in different format (no delimiter at all) - Torgeir - 2013-05-04 12:39



User(s) browsing this thread: 1 Guest(s)