Repository : ssh://git@open-mesh.org/alfred
On branch : master
commit 58e109973bbe8b6974a8f5d13777d949fd7054d1 Author: Dominik Heidler dominik@heidler.eu Date: Fri Mar 11 18:02:48 2016 +0100
alfred: Allow setting the source mac via unix sock
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 [sw@simonwunderlich.de: applied some style changes] Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
58e109973bbe8b6974a8f5d13777d949fd7054d1 unix_sock.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/unix_sock.c b/unix_sock.c index 3c7e583..a0ccc13 100644 --- a/unix_sock.c +++ b/unix_sock.c @@ -97,6 +97,7 @@ static int unix_sock_add_data(struct globals *globals, struct alfred_push_data_v0 *push, int client_sock) { + static const char zero[ETH_ALEN] = { 0 }; struct alfred_data *data; struct dataset *dataset; int len, data_len, ret = -1; @@ -119,7 +120,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 + */ + if (memcmp(zero, data->source, sizeof(data->source)) == 0) + memcpy(data->source, &interface->hwaddr, + sizeof(interface->hwaddr));
if ((int)(data_len + sizeof(*data)) > len) goto err;