summaryrefslogtreecommitdiffstats
path: root/ffvisd
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-08-29 03:09:50 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-08-29 03:09:50 +0200
commita59cdb3ef307b546b6ced9d3c1be2f78196128d9 (patch)
treeeccfefc8d1a79dab590f5fecc3136c856a709d05 /ffvisd
parent09eb0b81799380b302ed0e8c8252202525f1a14d (diff)
downloadffd-a59cdb3ef307b546b6ced9d3c1be2f78196128d9.tar
ffd-a59cdb3ef307b546b6ced9d3c1be2f78196128d9.zip
Dump annoucements periodically
Diffstat (limited to 'ffvisd')
-rw-r--r--ffvisd/ffvisd.c31
1 files 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);
}