4b324baf01354811b4172307894b4ecbb6dfe4fb
2 * copyright (c) 2001-2008 Emil Mikulic.
4 * hosts_db.h: database of hosts, ports, protocols.
6 * You may use, modify and redistribute this file under the terms of the
7 * GNU General Public License version 2. (see COPYING.GPL)
9 #ifndef __DARKSTAT_HOSTS_DB_H
10 #define __DARKSTAT_HOSTS_DB_H
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <netinet/in.h>
32 struct hashtable
*ports_tcp
, *ports_udp
, *ip_protos
;
50 uint64_t in
, out
, total
;
53 struct port_tcp port_tcp
;
54 struct port_udp port_udp
;
55 struct ip_proto ip_proto
;
59 enum sort_dir
{ IN
, OUT
, TOTAL
, LASTSEEN
};
61 extern int show_mac_addrs
;
64 * Table reduction - when the number of entries is about to exceed <max>, we
65 * reduce the table to the top <keep> entries.
67 extern unsigned int hosts_max
, hosts_keep
, ports_max
, ports_keep
;
69 void hosts_db_init(void);
70 void hosts_db_reduce(void);
71 void hosts_db_reset(void);
72 void hosts_db_free(void);
73 int hosts_db_import(const int fd
);
74 int hosts_db_export(const int fd
);
76 struct bucket
*host_find(const struct addr46
*const ip
); /* can return NULL */
77 struct bucket
*host_get(const struct addr46
*const ip
);
78 struct bucket
*host_get_port_tcp(struct bucket
*host
, const uint16_t port
);
79 struct bucket
*host_get_port_udp(struct bucket
*host
, const uint16_t port
);
80 struct bucket
*host_get_ip_proto(struct bucket
*host
, const uint8_t proto
);
83 struct str
*html_hosts(const char *uri
, const char *query
);
86 void qsort_buckets(const struct bucket
**a
, size_t n
,
87 size_t left
, size_t right
, const enum sort_dir d
);
89 #endif /* __DARKSTAT_HOSTS_DB_H */
90 /* vim:set ts=3 sw=3 tw=78 expandtab: */