The server will only overwrite the mac if it is zero.
Ths allows acting in place of (non-alfred) legacy clients
by injecting their data with the correct source mac.
Signed-off-by: Dominik Heidler <dominik(a)heidler.eu>
---
unix_sock.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/unix_sock.c b/unix_sock.c
index 3c7e583..d7578a3 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -119,7 +119,13 @@ static int unix_sock_add_data(struct globals *globals,
data = push->data;
data_len = ntohs(data->header.length);
- memcpy(data->source, &interface->hwaddr, sizeof(interface->hwaddr));
+
+ /* clients should set the source mac to 00:00:00:00:00:00
+ * to make the server set the source for them
+ */
+ static const char zero[ETH_ALEN] = { 0 };
+ if (!memcmp(zero, data->source, sizeof(data->source)))
+ memcpy(data->source, &interface->hwaddr, sizeof(interface->hwaddr));
if ((int)(data_len + sizeof(*data)) > len)
goto err;
--
2.7.2