From a455ffac663bff0d48766ef2124d70584620c9ea Mon Sep 17 00:00:00 2001 From: Pawel Baldysiak Date: Wed, 4 Sep 2024 09:42:07 -0400 Subject: [PATCH] bfpxe: Improve MAC address parsing Currently "bfmac=" param expects MAC address to follow "aa-bb-cc-dd-ee-ff" format, however standard defines that it might also be "aa:bb:cc:dd:ee:ff". Change the way how "bfmac=" param is parsed, so it accepts both formats. Signed-off-by: Pawel Baldysiak --- bfpxe | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bfpxe b/bfpxe index e7aca10..36ce104 100755 --- a/bfpxe +++ b/bfpxe @@ -61,10 +61,10 @@ create_net() { ifnet=$(echo $bfnet | cut -d: -f3) fi if [ -n "$bfmac" ]; then - realbfmac=$(echo $bfmac | cut -d: -f1 | tr '-' ':') + realbfmac=$(echo $bfmac | cut -b1-17 | tr '-' ':') ifname=$(grep $realbfmac /sys/class/net/*/address | awk -F\/ {'print $5'}) - ifaddr=$(echo $bfmac | cut -d: -f2) - ifnet=$(echo $bfmac | cut -d: -f3) + ifaddr=$(echo $bfmac | awk -F: '{print $(NF-1) }') + ifnet=$(echo $bfmac | awk -F: '{print $(NF) }') fi # vlan check if echo "$ifname" | grep -q -E ".+\..+" >/dev/null; then