Updates to autotools for library detection
[distributedratelimiting.git] / drl / zk_drl.h
1 /* See the DRL-LICENSE file for this file's software license. */
2
3 #ifndef _ZK_DRL_
4 #define _ZK_DRL_
5
6 #define _XOPEN_SOURCE 600
7
8 #include <inttypes.h>
9 #include <pthread.h>
10 #include <sys/types.h>
11
12 #include <zookeeper.h>
13
14 static const uint16_t UNSUREACK = 3;
15 static const uint16_t NACK = 4;
16
17 typedef struct zkdrlcontext {
18     /** The host string that should be passed to zookeeper_init when using
19      * zookeeper.  This consists of comma-separated ipaddr:port pairs. Example:
20      * "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002" */
21     char *zk_host;
22
23     pthread_rwlock_t *limiter_lock;
24     comm_t *comm;
25     uint32_t id;
26     in_addr_t local_addr;
27     
28     zhandle_t *zkhandle;
29 } zkdrlcontext_t;
30
31 int zk_drl_init(comm_t *comm, uint32_t id, limiter_t *limiter, ident_config *config);
32
33 int zk_drl_close(comm_t *comm);
34
35 int zk_drl_recv(comm_t *comm, uint32_t id, int sock, remote_limiter_t *remote, message_t *msg);
36
37 void zk_drl_restart(comm_t *comm, int32_t view_number);
38
39 #endif  /* _ZK_DRL_ */