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 v2] alfred: Allow setting the source mac via unix sock
@ 2016-03-11 17:02 Dominik Heidler
  2016-03-11 17:19 ` Simon Wunderlich
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Heidler @ 2016-03-11 17:02 UTC (permalink / raw)
  To: b.a.t.m.a.n

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(-)

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


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

* Re: [B.A.T.M.A.N.] [PATCH v2] alfred: Allow setting the source mac via unix sock
  2016-03-11 17:02 [B.A.T.M.A.N.] [PATCH v2] alfred: Allow setting the source mac via unix sock Dominik Heidler
@ 2016-03-11 17:19 ` Simon Wunderlich
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Wunderlich @ 2016-03-11 17:19 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-11 17:02 [B.A.T.M.A.N.] [PATCH v2] alfred: Allow setting the source mac via unix sock Dominik Heidler
2016-03-11 17:19 ` Simon Wunderlich

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