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)
10 #include <sys/types.h>
11 #include <netinet/in.h>
25 struct hashtable
*ports_tcp
, *ports_udp
, *ip_protos
;
43 uint64_t in
, out
, total
;
46 struct port_tcp port_tcp
;
47 struct port_udp port_udp
;
48 struct ip_proto ip_proto
;
52 enum sort_dir
{ IN
, OUT
, TOTAL
};
54 extern int show_mac_addrs
;
57 * Table reduction - when the number of entries is about to exceed <max>, we
58 * reduce the table to the top <keep> entries.
60 extern unsigned int hosts_max
, hosts_keep
, ports_max
, ports_keep
;
62 void hosts_db_init(void);
63 void hosts_db_reduce(void);
64 void hosts_db_reset(void);
65 void hosts_db_free(void);
66 int hosts_db_import(const int fd
);
67 int hosts_db_export(const int fd
);
69 struct bucket
*host_find(const in_addr_t ip
); /* can return NULL */
70 struct bucket
*host_get(const in_addr_t ip
);
71 struct bucket
*host_get_port_tcp(struct bucket
*host
, const uint16_t port
);
72 struct bucket
*host_get_port_udp(struct bucket
*host
, const uint16_t port
);
73 struct bucket
*host_get_ip_proto(struct bucket
*host
, const uint8_t proto
);
76 struct str
*html_hosts(const char *uri
, const char *query
);
79 void qsort_buckets(const struct bucket
**a
, size_t n
,
80 size_t left
, size_t right
, const enum sort_dir d
);
82 /* vim:set ts=3 sw=3 tw=78 expandtab: */