From a59cdb3ef307b546b6ced9d3c1be2f78196128d9 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 29 Aug 2012 03:09:50 +0200 Subject: Dump annoucements periodically --- ffvisd/ffvisd.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/ffvisd/ffvisd.c b/ffvisd/ffvisd.c index 851ab3c..91f6764 100644 --- a/ffvisd/ffvisd.c +++ b/ffvisd/ffvisd.c @@ -115,7 +115,7 @@ typedef struct _ffvisd_orig_t { typedef struct _ffvisd_announce_t { struct _ffvisd_announce_t *next; - struct timeval received; + struct timespec received; ffvisd_packet_server_announce_t announce; } ffvisd_announce_t; @@ -341,6 +341,24 @@ static void join_mcast(const ffvisd_iface_t *iface, void *arg) { 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() { if (!iface_is_mesh(mesh)) { fprintf(stderr, "error: configured interface is no mesh\n"); @@ -410,10 +428,6 @@ static bool init_announcements() { 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); free(addr); @@ -436,6 +450,7 @@ int main() { return 1; ffvisd_iface_foreach(pr_iface_info, NULL); + puts(""); if (!init_socket()) return 1; @@ -448,6 +463,12 @@ int main() { maintenance(); + puts("Dumping announcements..."); + ffvisd_announce_t *announce; + for(announce = announcements; announce; announce = announce->next) + pr_announcement(announce); + puts(""); + usleep(ANNOUNCE_INTERVAL*1000); } -- cgit v1.2.3