Updates to autotools for library detection
[distributedratelimiting.git] / drl / zk_drl.h
diff --git a/drl/zk_drl.h b/drl/zk_drl.h
new file mode 100644 (file)
index 0000000..12ac936
--- /dev/null
@@ -0,0 +1,39 @@
+/* See the DRL-LICENSE file for this file's software license. */
+
+#ifndef _ZK_DRL_
+#define _ZK_DRL_
+
+#define _XOPEN_SOURCE 600
+
+#include <inttypes.h>
+#include <pthread.h>
+#include <sys/types.h>
+
+#include <zookeeper.h>
+
+static const uint16_t UNSUREACK = 3;
+static const uint16_t NACK = 4;
+
+typedef struct zkdrlcontext {
+    /** The host string that should be passed to zookeeper_init when using
+     * zookeeper.  This consists of comma-separated ipaddr:port pairs. Example:
+     * "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002" */
+    char *zk_host;
+
+    pthread_rwlock_t *limiter_lock;
+    comm_t *comm;
+    uint32_t id;
+    in_addr_t local_addr;
+    
+    zhandle_t *zkhandle;
+} zkdrlcontext_t;
+
+int zk_drl_init(comm_t *comm, uint32_t id, limiter_t *limiter, ident_config *config);
+
+int zk_drl_close(comm_t *comm);
+
+int zk_drl_recv(comm_t *comm, uint32_t id, int sock, remote_limiter_t *remote, message_t *msg);
+
+void zk_drl_restart(comm_t *comm, int32_t view_number);
+
+#endif  /* _ZK_DRL_ */