gluon-radv-filterd: Update originators only if one is unknown
This commit is contained in:
parent
f963e054df
commit
e3b4dc5031
@ -3,6 +3,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -300,12 +301,18 @@ static void update_tqs() {
|
|||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint8_t tq;
|
uint8_t tq;
|
||||||
|
bool update_originators = false;
|
||||||
|
int i;
|
||||||
macaddr_t mac_a, mac_b;
|
macaddr_t mac_a, mac_b;
|
||||||
|
|
||||||
// reset values
|
// reset TQs
|
||||||
foreach(router, G.routers) {
|
foreach(router, G.routers) {
|
||||||
router->tq = 0;
|
router->tq = 0;
|
||||||
memset(router->originator, 0, sizeof(macaddr_t));
|
for (i = 0; i < 6; i++)
|
||||||
|
if (router->originator[i] != 0)
|
||||||
|
break;
|
||||||
|
if (i >= 6)
|
||||||
|
update_originators = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Currently, we iterate over the whole list of routers all the
|
// TODO: Currently, we iterate over the whole list of routers all the
|
||||||
@ -314,22 +321,24 @@ static void update_tqs() {
|
|||||||
// could abort as soon as we hit the first router with the current
|
// could abort as soon as we hit the first router with the current
|
||||||
// information filled in.
|
// information filled in.
|
||||||
|
|
||||||
// translate all router's MAC addresses to originators simultaneously
|
if (update_originators) {
|
||||||
snprintf(path, PATH_MAX, TRANSTABLE_GLOBAL, G.mesh_iface);
|
// translate all router's MAC addresses to originators simultaneously
|
||||||
f = fopen(path, "r");
|
snprintf(path, PATH_MAX, TRANSTABLE_GLOBAL, G.mesh_iface);
|
||||||
while (getline(&line, &len, f) != -1) {
|
f = fopen(path, "r");
|
||||||
if (sscanf(line, " * " F_MAC " (%*3u) via " F_MAC " (%*3u) (0x%*4x) [%*3c]",
|
while (getline(&line, &len, f) != -1) {
|
||||||
F_MAC_VAR(&mac_a), F_MAC_VAR(&mac_b)) != 12)
|
if (sscanf(line, " * " F_MAC " (%*3u) via " F_MAC " (%*3u) (0x%*4x) [%*3c]",
|
||||||
continue;
|
F_MAC_VAR(&mac_a), F_MAC_VAR(&mac_b)) != 12)
|
||||||
|
continue;
|
||||||
|
|
||||||
foreach(router, G.routers) {
|
foreach(router, G.routers) {
|
||||||
if (!memcmp(router->src, mac_a, sizeof(macaddr_t))) {
|
if (!memcmp(router->src, mac_a, sizeof(macaddr_t))) {
|
||||||
memcpy(router->originator, mac_b, sizeof(macaddr_t));
|
memcpy(router->originator, mac_b, sizeof(macaddr_t));
|
||||||
break; // foreach
|
break; // foreach
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fclose(f);
|
||||||
}
|
}
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
// look up TQs of originators
|
// look up TQs of originators
|
||||||
G.max_tq = 0;
|
G.max_tq = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user