diff mbox series

[2/5] New function to append raw hardware addr to string

Message ID c954322f2524b74671c5a7589f86df99675418be.1587059223.git.weeksd2@rpi.edu
State New
Headers show
Series IB netboot 3/3: IB interface bring up | expand

Commit Message

Daniel M. Weeks April 16, 2020, 6:02 p.m. UTC
It may be necessary to append a raw hardware address to another string.
For example, the defacto standard for identifying hosts during DHCP over
IB involves appending the IB adapter GUID to a particular prefix.

Signed-off-by: Daniel M. Weeks <weeksd2@rpi.edu>
---
 discover/network.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/discover/network.c b/discover/network.c
index ad7eced..bb76109 100644
--- a/discover/network.c
+++ b/discover/network.c
@@ -72,6 +72,13 @@  struct network {
 	bool			dry_run;
 };
 
+static void append_hwaddr_str(uint8_t *hwaddr, size_t hwaddr_len, char *dest)
+{
+	size_t i;
+	for (i = 0; i < hwaddr_len; i++)
+		sprintf(dest + (i * 2), "%02x", hwaddr[i]);
+}
+
 static char *mac_bytes_to_string(void *ctx, uint8_t *addr, int len)
 {
 	const int l = strlen("xx:");