diff options
Diffstat (limited to 'ecp/server/dir.h')
-rw-r--r-- | ecp/server/dir.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ecp/server/dir.h b/ecp/server/dir.h new file mode 100644 index 0000000..cbc0c87 --- /dev/null +++ b/ecp/server/dir.h @@ -0,0 +1,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); |