aboutsummaryrefslogtreecommitdiffstats
path: root/libglouglou/libggnet.h
diff options
context:
space:
mode:
Diffstat (limited to 'libglouglou/libggnet.h')
-rw-r--r--libglouglou/libggnet.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/libglouglou/libggnet.h b/libglouglou/libggnet.h
new file mode 100644
index 0000000..17be7e8
--- /dev/null
+++ b/libglouglou/libggnet.h
@@ -0,0 +1,70 @@
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#if defined(__OpenBSD__)
+#include <sys/queue.h>
+#else
+#include <bsd/sys/queue.h>
+#endif
+
+#define GGNET_NULL_HDRLEN 4 // XXX portable ?
+#define GGNET_NODE_MAX_WITHOUT_TIMEOUT 1000
+#define GGNET_NODE_TIMEOUT 300 // XXX conf ?
+#define GGNET_CONN_TIMEOUT 300 // XXX conf ?
+#define GGNET_CONN_TIMEOUT_UDP 20 // XXX conf ?
+#define GGNET_CONN_TIMEOUT_ICMP 10 // XXX conf ?
+#define GGNET_CONN_FREEIDS_COUNT 65536 /* 2^16 as freeids are u_int16_t */
+#define GGNET_CONNTIMER 5 // XXX conf ?
+
+struct ggnet_node {
+ LIST_ENTRY(ggnet_node) entry;
+ struct in_addr addr;
+ time_t lastseen;
+ int used;
+ short namelen;
+#define NODENAME_WAITING -1
+#define NODENAME_FAILED -2
+ char *name;
+};
+
+enum ggnet_connstate {
+ CONNSTATE_ESTABLISHED,
+ CONNSTATE_TCPFIN,
+ CONNSTATE_TCPFIN2
+};
+
+struct ggnet_conn {
+ LIST_ENTRY(ggnet_conn) entry;
+ u_int id;
+ enum ggnet_connstate state;
+ struct ggnet_node *src;
+ u_int src_port;
+ struct ggnet_node *dst;
+ u_int dst_port;
+ u_int proto;
+ u_int size;
+ time_t lastseen;
+};
+
+struct ggnet {
+ LIST_HEAD(, ggnet_conn) conn_list;
+ LIST_HEAD(, ggnet_node) node_list;
+ int conn_count;
+ int node_count;
+ u_int16_t conn_freeids[GGNET_CONN_FREEIDS_COUNT];
+ int conn_freeids_ptr;
+ time_t time;
+};
+
+struct ggnet *ggnet_new(void);
+void ggnet_free(struct ggnet *);
+struct ggnet_node *ggnet_node_add(struct ggnet *, struct in_addr *);
+void ggnet_node_del(struct ggnet *, struct ggnet_node *);
+struct ggnet_node *ggnet_node_find(struct ggnet *, struct in_addr *);
+struct ggnet_conn *ggnet_conn_add(struct ggnet *, struct in_addr *, int,
+ struct in_addr *, int, int, int);
+void ggnet_conn_data(struct ggnet *, struct ggnet_conn *,
+ int, int);
+void ggnet_conn_del(struct ggnet *, struct ggnet_conn *);
+struct ggnet_conn *ggnet_conn_find(struct ggnet *, struct in_addr *);
+void ggnet_time_update(struct ggnet *, time_t);