]> git.ipfire.org Git - telemetry.git/commitdiff
sources: hostapd: Zero-pad MAC addresses
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 20 Oct 2025 14:23:02 +0000 (14:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 20 Oct 2025 14:23:02 +0000 (14:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/sources/hostapd.c

index d5ab2e44186ce6b8e06e9e9267a33efff7b4d6d0..85c42a8d4ddb3ccc5efd13f791440d230cee9f95 100644 (file)
@@ -26,6 +26,7 @@
 #include "../ctx.h"
 #include "../file.h"
 #include "../source.h"
+#include "../string.h"
 #include "hostapd.h"
 
 typedef struct hostapd_station {
@@ -80,17 +81,20 @@ static int ether_is_zero(const struct ether_addr* address) {
 
 static int hostapd_submit_station(td_ctx* ctx, hostapd_station* station) {
        char address[ETHER_MAX_LEN];
-       char* p = NULL;
+       int r;
 
        // Skip if we don't have a MAC address
        if (ether_is_zero(&station->address))
                return 0;
 
        // Format the address
-       p = ether_ntoa_r(&station->address, address);
-       if (!p) {
-               DEBUG(ctx, "Failed to format MAC address: %m\n");
-               return -errno;
+       r = td_string_format(address, "%02x:%02x:%02x:%02x:%02x:%02x",
+               station->address.ether_addr_octet[0], station->address.ether_addr_octet[1],
+               station->address.ether_addr_octet[2], station->address.ether_addr_octet[3],
+               station->address.ether_addr_octet[4], station->address.ether_addr_octet[5]);
+       if (r < 0) {
+               DEBUG(ctx, "Failed to format MAC address: %s\n", strerror(-r));
+               return r;
        }
 
        // Submit the station