summaryrefslogtreecommitdiffstats
path: root/include/tcp.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-08-23 12:11:20 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2009-08-23 12:11:20 +0200
commitcf3be894fcb95adb360425c8482954522e9110d2 (patch)
tree9a6f2a95cd36218bcf6e852ecc300074ba7fef16 /include/tcp.h
parent9d99a7699d7021a1c219d6553e037ac7ba4a5a37 (diff)
conntrackd: add support state-replication based on TCP
This patch adds support for TCP as protocol to replicate state-changes between two daemons. Note that this only makes sense with the notrack mode. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/tcp.h')
-rw-r--r--include/tcp.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/include/tcp.h b/include/tcp.h
new file mode 100644
index 0000000..1b1d391
--- /dev/null
+++ b/include/tcp.h
@@ -0,0 +1,75 @@
+#ifndef _TCP_H_
+#define _TCP_H_
+
+#include <stdint.h>
+#include <netinet/in.h>
+
+struct tcp_conf {
+ int ipproto;
+ int reuseaddr;
+ int checksum;
+ unsigned short port;
+ union {
+ struct {
+ struct in_addr inet_addr;
+ } ipv4;
+ struct {
+ struct in6_addr inet_addr6;
+ int scope_id;
+ } ipv6;
+ } server;
+ union {
+ struct in_addr inet_addr;
+ struct in6_addr inet_addr6;
+ } client;
+ int sndbuf;
+ int rcvbuf;
+};
+
+struct tcp_stats {
+ uint64_t bytes;
+ uint64_t messages;
+ uint64_t error;
+};
+
+enum tcp_sock_state {
+ TCP_SERVER_ACCEPTING,
+ TCP_SERVER_CONNECTED,
+ TCP_CLIENT_DISCONNECTED,
+ TCP_CLIENT_CONNECTED
+};
+
+struct tcp_sock {
+ int state; /* enum tcp_sock_state */
+ int fd;
+ int client_fd; /* only for the server side */
+ union {
+ struct sockaddr_in ipv4;
+ struct sockaddr_in6 ipv6;
+ } addr;
+ socklen_t sockaddr_len;
+ struct tcp_stats stats;
+};
+
+struct tcp_sock *tcp_server_create(struct tcp_conf *conf);
+void tcp_server_destroy(struct tcp_sock *m);
+
+struct tcp_sock *tcp_client_create(struct tcp_conf *conf);
+void tcp_client_destroy(struct tcp_sock *m);
+
+ssize_t tcp_send(struct tcp_sock *m, const void *data, int size);
+ssize_t tcp_recv(struct tcp_sock *m, void *data, int size);
+int tcp_accept(struct tcp_sock *m);
+
+int tcp_get_fd(struct tcp_sock *m);
+int tcp_isset(struct tcp_sock *m, fd_set *readfds);
+int tcp_accept_isset(struct tcp_sock *m, fd_set *readfds);
+
+int tcp_snprintf_stats(char *buf, size_t buflen, char *ifname,
+ struct tcp_sock *s, struct tcp_sock *r);
+
+int tcp_snprintf_stats2(char *buf, size_t buflen, const char *ifname,
+ const char *status, int active,
+ struct tcp_stats *s, struct tcp_stats *r);
+
+#endif