Only update lastseen time for sender, not recipient.
authorEmil Mikulic <emikulic@gmail.com>
Tue, 21 Jun 2011 12:38:13 +0000 (22:38 +1000)
committerEmil Mikulic <emikulic@gmail.com>
Tue, 21 Jun 2011 12:38:13 +0000 (22:38 +1000)
Suggested by: Madhu

acct.c
hosts_db.c

diff --git a/acct.c b/acct.c
index d431299..27f48ac 100644 (file)
--- a/acct.c
+++ b/acct.c
@@ -220,7 +220,10 @@ acct_for(const struct pktsummary * const sm)
    hd->in    += sm->len;
    hd->total += sm->len;
    memcpy(hd->u.host.mac_addr, sm->dst_mac, sizeof(sm->dst_mac));
-   hd->u.host.lastseen = now;
+   /*
+    * Don't update recipient's last seen time, we don't know that
+    * they received successfully.
+    */
 
    /* Protocols. */
    if (sm->proto != IPPROTO_INVALID) {
index 1907651..bd94ab3 100644 (file)
@@ -237,7 +237,7 @@ make_func_host(const void *key)
    MAKE_BUCKET(b, h, host);
    h->addr = CASTKEY(struct addr);
    h->dns = NULL;
-   h->lastseen = now;
+   h->lastseen = 0;
    memset(&h->mac_addr, 0, sizeof(h->mac_addr));
    h->ports_tcp = NULL;
    h->ports_udp = NULL;
@@ -346,18 +346,21 @@ format_row_host(struct str *buf, const struct bucket *b,
 
    if (opt_want_lastseen) {
       time_t last_t = b->u.host.lastseen;
-      struct str *lastseen = NULL;
+      struct str *last_str = NULL;
 
-      if (now >= last_t)
-         lastseen = length_of_time(now - last_t);
+      if ((now >= last_t) && (last_t > 0))
+         last_str = length_of_time(now - last_t);
 
       str_append(buf,
          " <td class=\"num\">");
-      if (lastseen == NULL)
-         str_append(buf, "(clock error)");
-      else {
-         str_appendstr(buf, lastseen);
-         str_free(lastseen);
+      if (last_str == NULL) {
+         if (last_t == 0)
+            str_append(buf, "(never)");
+         else
+            str_append(buf, "(clock error)");
+      } else {
+         str_appendstr(buf, last_str);
+         str_free(last_str);
       }
       str_append(buf,
          "</td>");