projects
/
darkstat-debian
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Pull in darkstat-3.0.718
[darkstat-debian]
/
hosts_db.c
diff --git
a/hosts_db.c
b/hosts_db.c
index
c2d7ae4
..
3058d65
100644
(file)
--- a/
hosts_db.c
+++ b/
hosts_db.c
@@
-1,5
+1,5
@@
/* darkstat 3
/* darkstat 3
- * copyright (c) 2001-201
1
Emil Mikulic.
+ * copyright (c) 2001-201
4
Emil Mikulic.
*
* hosts_db.c: database of hosts, ports, protocols.
*
*
* hosts_db.c: database of hosts, ports, protocols.
*
@@
-20,7
+20,7
@@
#include "opt.h"
#include "str.h"
#include "opt.h"
#include "str.h"
-#include <netdb.h>
/* struct addrinfo */
+#include <netdb.h> /* struct addrinfo */
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
@@
-342,10
+342,12
@@
format_row_host(struct str *buf, const struct bucket *b,
" <td class=\"num\">%'qu</td>\n"
" <td class=\"num\">%'qu</td>\n"
" <td class=\"num\">%'qu</td>\n",
" <td class=\"num\">%'qu</td>\n"
" <td class=\"num\">%'qu</td>\n"
" <td class=\"num\">%'qu</td>\n",
- b->in, b->out, b->total);
+ (qu)b->in,
+ (qu)b->out,
+ (qu)b->total);
if (opt_want_lastseen) {
if (opt_want_lastseen) {
-
long
last = b->u.host.last_seen_mono;
+
time_t
last = b->u.host.last_seen_mono;
struct str *last_str = NULL;
if ((now_mono() >= last) && (last > 0))
struct str *last_str = NULL;
if ((now_mono() >= last) && (last > 0))
@@
-356,7
+358,9
@@
format_row_host(struct str *buf, const struct bucket *b,
if (last == 0)
str_append(buf, "(never)");
else
if (last == 0)
str_append(buf, "(never)");
else
- str_append(buf, "(clock error)");
+ str_appendf(buf, "(clock error: now = %qu, last = %qu)",
+ (qu)now_mono(),
+ (qu)last);
} else {
str_appendstr(buf, last_str);
str_free(last_str);
} else {
str_appendstr(buf, last_str);
str_free(last_str);
@@
-403,7
+407,12
@@
format_row_port_tcp(struct str *buf, const struct bucket *b,
" <td class=\"num\">%'qu</td>\n"
"</tr>\n",
css_class,
" <td class=\"num\">%'qu</td>\n"
"</tr>\n",
css_class,
- p->port, getservtcp(p->port), b->in, b->out, b->total, p->syn
+ p->port,
+ getservtcp(p->port),
+ (qu)b->in,
+ (qu)b->out,
+ (qu)b->total,
+ (qu)p->syn
);
}
);
}
@@
-437,7
+446,11
@@
format_row_port_udp(struct str *buf, const struct bucket *b,
" <td class=\"num\">%'qu</td>\n"
"</tr>\n",
css_class,
" <td class=\"num\">%'qu</td>\n"
"</tr>\n",
css_class,
- p->port, getservudp(p->port), b->in, b->out, b->total
+ p->port,
+ getservudp(p->port),
+ (qu)b->in,
+ (qu)b->out,
+ (qu)b->total
);
}
);
}
@@
-471,8
+484,11
@@
format_row_ip_proto(struct str *buf, const struct bucket *b,
" <td class=\"num\">%'qu</td>\n"
"</tr>\n",
css_class,
" <td class=\"num\">%'qu</td>\n"
"</tr>\n",
css_class,
- p->proto, getproto(p->proto),
- b->in, b->out, b->total
+ p->proto,
+ getproto(p->proto),
+ (qu)b->in,
+ (qu)b->out,
+ (qu)b->total
);
}
);
}
@@
-1027,7
+1043,7
@@
static struct str *html_hosts_detail(const char *ip) {
struct str *buf, *ls_len;
char ls_when[100];
const char *canonical;
struct str *buf, *ls_len;
char ls_when[100];
const char *canonical;
- time_t last_real;
+ time_t last_
seen_
real;
h = host_search(ip);
if (h == NULL)
h = host_search(ip);
if (h == NULL)
@@
-1065,9
+1081,9
@@
static struct str *html_hosts_detail(const char *ip) {
"<p>\n"
"<b>Last seen:</b> ");
"<p>\n"
"<b>Last seen:</b> ");
- last_real = mono_to_real(h->u.host.last_seen_mono);
+ last_
seen_
real = mono_to_real(h->u.host.last_seen_mono);
if (strftime(ls_when, sizeof(ls_when),
if (strftime(ls_when, sizeof(ls_when),
- "%Y-%m-%d %H:%M:%S %Z%z", localtime(&last_real)) != 0)
+ "%Y-%m-%d %H:%M:%S %Z%z", localtime(&last_
seen_
real)) != 0)
str_append(buf, ls_when);
if (h->u.host.last_seen_mono <= now_mono()) {
str_append(buf, ls_when);
if (h->u.host.last_seen_mono <= now_mono()) {
@@
-1087,7
+1103,9
@@
static struct str *html_hosts_detail(const char *ip) {
" <b>Out:</b> %'qu<br>\n"
" <b>Total:</b> %'qu<br>\n"
"</p>\n",
" <b>Out:</b> %'qu<br>\n"
" <b>Total:</b> %'qu<br>\n"
"</p>\n",
- h->in, h->out, h->total);
+ (qu)h->in,
+ (qu)h->out,
+ (qu)h->total);
str_append(buf, "<h3>TCP ports</h3>\n");
format_table(buf, h->u.host.ports_tcp, 0,TOTAL,0);
str_append(buf, "<h3>TCP ports</h3>\n");
format_table(buf, h->u.host.ports_tcp, 0,TOTAL,0);