public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock
@ 2016-02-16 23:51 Dominik Heidler
  2016-02-17  8:10 ` Sven Eckelmann
  2016-02-17  8:39 ` Sven Eckelmann
  0 siblings, 2 replies; 5+ messages in thread
From: Dominik Heidler @ 2016-02-16 23:51 UTC (permalink / raw)
  To: b.a.t.m.a.n

The server will only overwrite the mac if it is zero.

Signed-off-by: Dominik Heidler <dominik@heidler.eu>
---

The alfred client sets the mac to zero by default
so this shouldn't break existing behaviour.


 unix_sock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/unix_sock.c b/unix_sock.c
index 3c7e583..12a10e6 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -119,7 +119,9 @@ 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));
+	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.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-11 15:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 23:51 [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock Dominik Heidler
2016-02-17  8:10 ` Sven Eckelmann
2016-02-17  8:39 ` Sven Eckelmann
2016-02-17 10:36   ` Dominik Heidler
2016-03-11 15:27     ` Simon Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox