3db28fba7d2cd0e4fe2cce8e1820f3bbebf6d1c3
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)
11 # define __HOSTS_DB_H 1
13 #include <sys/types.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
33 struct hashtable
*ports_tcp
, *ports_udp
, *ip_protos
;
51 uint64_t in
, out
, total
;
54 struct port_tcp port_tcp
;
55 struct port_udp port_udp
;
56 struct ip_proto ip_proto
;
60 enum sort_dir
{ IN
, OUT
, TOTAL
};
62 extern int show_mac_addrs
;
65 * Table reduction - when the number of entries is about to exceed <max>, we
66 * reduce the table to the top <keep> entries.
68 extern unsigned int hosts_max
, hosts_keep
, ports_max
, ports_keep
;
70 void hosts_db_init(void);
71 void hosts_db_reduce(void);
72 void hosts_db_reset(void);
73 void hosts_db_free(void);
74 int hosts_db_import(const int fd
);
75 int hosts_db_export(const int fd
);
77 struct bucket
*host_find(const struct addr46
*const ip
); /* can return NULL */
78 struct bucket
*host_get(const struct addr46
*const ip
);
79 struct bucket
*host_get_port_tcp(struct bucket
*host
, const uint16_t port
);
80 struct bucket
*host_get_port_udp(struct bucket
*host
, const uint16_t port
);
81 struct bucket
*host_get_ip_proto(struct bucket
*host
, const uint8_t proto
);
84 struct str
*html_hosts(const char *uri
, const char *query
);
87 void qsort_buckets(const struct bucket
**a
, size_t n
,
88 size_t left
, size_t right
, const enum sort_dir d
);
90 #endif /* !__HOSTS_DB_H */
91 /* vim:set ts=3 sw=3 tw=78 expandtab: */