[v2] alfred: Allow setting the source mac via unix sock
Commit Message
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@heidler.eu>
---
unix_sock.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Comments
On Friday 11 March 2016 18:02:48 Dominik Heidler wrote:
> 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@heidler.eu>
Thanks! I've did some style changes (declaration up, !memcmp -> memcmp() == 0)
and applied it in revision 58e1099
Thank you!
Simon
@@ -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;