Repository : ssh://git@open-mesh.org/alfred
On branch : master
commit 2be2ffeb1b2e39cdc15089caa9e0005e529a39ee Author: Sven Eckelmann sven@open-mesh.com Date: Fri Jan 4 09:38:02 2013 +0100
alfred: Allow to specify batman-adv interface
Alfred uses the batman-adv interface to translate mac addresses and to query the tq values for server selection. Therefore it has to know which batman-adv interface it has to use when multiple interfaces exist. This is also necessary when it wasn't started directly on that interface and instead on a virtual interface which uses the batman-adv device as its slave.
Alfred assumes by default that the interface is called bat0. This name can be changed using the parameter -b followed by the name of the interface. It is also possible to disable the batman-adv support completely by using the special interface name "none". This special mode is only for debugging and should not be used in production setups.
Signed-off-by: Sven Eckelmann sven@open-mesh.com
2be2ffeb1b2e39cdc15089caa9e0005e529a39ee alfred.h | 1 + main.c | 8 +++++++- recv.c | 16 ++++++++++------ server.c | 3 ++- 4 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/alfred.h b/alfred.h index 6310f40..82c997d 100644 --- a/alfred.h +++ b/alfred.h @@ -96,6 +96,7 @@ struct globals { uint8_t hwaddr[ETH_ALEN]; struct server *best_server; /* NULL if we are a server ourselves */ char *interface; + char *mesh_iface; enum opmode opmode; enum clientmode clientmode; int clientmode_arg; diff --git a/main.c b/main.c index ccb72cd..1f92938 100644 --- a/main.c +++ b/main.c @@ -42,6 +42,8 @@ void alfred_usage(void) printf("\n"); printf("server mode options:\n"); printf(" -i, --interface specify the interface to listen on\n"); + printf(" -b specify the batman-adv interface configured on the system (default: bat0)\n"); + printf(" use 'none' to disable the batman-adv based best server selection\n"); printf(" -m, --master start up the daemon in master mode, which\n"); printf(" accepts data from slaves and synces it with\n"); printf(" other masters\n"); @@ -77,8 +79,9 @@ struct globals *alfred_init(int argc, char *argv[]) globals->interface = NULL; globals->best_server = NULL; globals->clientmode_version = 0; + globals->mesh_iface = "bat0";
- while ((opt = getopt_long(argc, argv, "ms:r:hi:vV:", long_options, + while ((opt = getopt_long(argc, argv, "ms:r:hi:b:vV:", long_options, &opt_ind)) != -1) { switch (opt) { case 'r': @@ -106,6 +109,9 @@ struct globals *alfred_init(int argc, char *argv[]) case 'i': globals->interface = strdup(optarg); break; + case 'b': + globals->mesh_iface = strdup(optarg); + break; case 'V': i = atoi(optarg); if (i < 0 || i > 255) { diff --git a/recv.c b/recv.c index bbb6313..e99acdc 100644 --- a/recv.c +++ b/recv.c @@ -126,12 +126,16 @@ int process_alfred_announce_master(struct globals *globals, }
server->last_seen = time(NULL); - macaddr = translate_mac(globals->interface, - (struct ether_addr *)server->address); - if (macaddr) - server->tq = get_tq(globals->interface, macaddr); - else - server->tq = 0; + if (strcmp(globals->mesh_iface, "none") != 0) { + macaddr = translate_mac(globals->mesh_iface, + (struct ether_addr *)server->address); + if (macaddr) + server->tq = get_tq(globals->mesh_iface, macaddr); + else + server->tq = 0; + } else { + server->tq = 255; + }
if (globals->opmode == OPMODE_SLAVE) set_best_server(globals); diff --git a/server.c b/server.c index 55844c2..7218630 100644 --- a/server.c +++ b/server.c @@ -170,7 +170,8 @@ int alfred_server(struct globals *globals) return -1; }
- if (batadv_interface_check(globals->interface) < 0) + if (strcmp(globals->mesh_iface, "none") != 0 && + batadv_interface_check(globals->mesh_iface) < 0) return -1;
if (netsock_open(globals))