Dump annoucements periodically
This commit is contained in:
parent
09eb0b8179
commit
a59cdb3ef3
1 changed files with 26 additions and 5 deletions
|
@ -115,7 +115,7 @@ typedef struct _ffvisd_orig_t {
|
||||||
typedef struct _ffvisd_announce_t {
|
typedef struct _ffvisd_announce_t {
|
||||||
struct _ffvisd_announce_t *next;
|
struct _ffvisd_announce_t *next;
|
||||||
|
|
||||||
struct timeval received;
|
struct timespec received;
|
||||||
ffvisd_packet_server_announce_t announce;
|
ffvisd_packet_server_announce_t announce;
|
||||||
} ffvisd_announce_t;
|
} ffvisd_announce_t;
|
||||||
|
|
||||||
|
@ -341,6 +341,24 @@ static void join_mcast(const ffvisd_iface_t *iface, void *arg) {
|
||||||
fprintf(stderr, "warning: setsockopt: %m\n");
|
fprintf(stderr, "warning: setsockopt: %m\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void pr_announcement(const ffvisd_announce_t *announce) {
|
||||||
|
if (!announce->received.tv_sec) {
|
||||||
|
printf("local, ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
struct timespec tv;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &tv);
|
||||||
|
printf("age: %.1fs, ", timespec_diff(&tv, &announce->received)/1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t *e = announce->announce.eth_address.address, *a = announce->announce.address.address;
|
||||||
|
|
||||||
|
printf("seqno: %u, ether: %02x:%02x:%02x:%02x:%02x:%02x, address: fe80::%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
|
||||||
|
announce->announce.seqno,
|
||||||
|
e[0], e[1], e[2], e[3], e[4], e[5],
|
||||||
|
a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]);
|
||||||
|
}
|
||||||
|
|
||||||
static bool check_config() {
|
static bool check_config() {
|
||||||
if (!iface_is_mesh(mesh)) {
|
if (!iface_is_mesh(mesh)) {
|
||||||
fprintf(stderr, "error: configured interface is no mesh\n");
|
fprintf(stderr, "error: configured interface is no mesh\n");
|
||||||
|
@ -410,10 +428,6 @@ static bool init_announcements() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[INET6_ADDRSTRLEN];
|
|
||||||
inet_ntop(AF_INET6, addr, buf, sizeof(buf));
|
|
||||||
puts(buf);
|
|
||||||
|
|
||||||
memcpy(announce->announce.address.address, addr->s6_addr+8, 8);
|
memcpy(announce->announce.address.address, addr->s6_addr+8, 8);
|
||||||
free(addr);
|
free(addr);
|
||||||
|
|
||||||
|
@ -436,6 +450,7 @@ int main() {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
ffvisd_iface_foreach(pr_iface_info, NULL);
|
ffvisd_iface_foreach(pr_iface_info, NULL);
|
||||||
|
puts("");
|
||||||
|
|
||||||
if (!init_socket())
|
if (!init_socket())
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -448,6 +463,12 @@ int main() {
|
||||||
|
|
||||||
maintenance();
|
maintenance();
|
||||||
|
|
||||||
|
puts("Dumping announcements...");
|
||||||
|
ffvisd_announce_t *announce;
|
||||||
|
for(announce = announcements; announce; announce = announce->next)
|
||||||
|
pr_announcement(announce);
|
||||||
|
puts("");
|
||||||
|
|
||||||
usleep(ANNOUNCE_INTERVAL*1000);
|
usleep(ANNOUNCE_INTERVAL*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue