summaryrefslogtreecommitdiff
path: root/ecp/server/dir.h
blob: cbc0c87a243df4f7422c0d601a6c270ec86135b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define MAX_DIR_ITEM        30
#define MAX_EXPIRE_CNT      100
#define MAX_ANNOUNCE_CNT    100

#define NODE_EXP_TIME       86400

typedef struct DirNode {
    ECPDirItem dir_item;
    int refcount;
    int zombie;
    ecp_sts_t access_ts;
    pthread_mutex_t mutex;
} DirNode;

typedef struct DirList {
    unsigned char msg[ECP_MAX_PLD];
    uint16_t count;
} DirList;

ssize_t dir_send_ann(ECPConnection *conn);
ssize_t dir_send_shadow(ECPConnection *conn);
ssize_t dir_send_online(ECPConnection *conn);
ssize_t dir_handle_ann(ECPConnection *conn, unsigned char *msg, size_t msg_size);
ssize_t dir_handle_req(ECPConnection *conn, unsigned char *msg, size_t msg_size);
ssize_t dir_handle_shadow(ECPConnection *conn, unsigned char *msg, size_t msg_size);
ssize_t dir_handle_msg(struct ECPConnection *conn, ecp_seq_t seq, unsigned char mtype, unsigned char *msg, size_t msg_size, struct ECP2Buffer *b);
int dir_handle_open(ECPConnection *conn, ECP2Buffer *bufs);
int dir_process_item(ECPDirItem *dir_item, ecp_sts_t access_ts);
DirNode *dir_create_node(ECPDirItem *dir_item, ecp_sts_t access_ts);
void dir_destroy_node(DirNode *node);
int dir_open_conn(ECPSocket *sock, ECPNode *node);
DirNode *dir_search_conn(ECPConnection *conn);
void dir_announce(ECPSocket *sock);
int dir_start_announce(ECPSocket *sock);
int dir_init(ECPContext *ctx);