summaryrefslogtreecommitdiff
path: root/ecp/src/ecp/dir/dir.h
blob: 5db33f17cba802fa4b7b99a91d35cd7f9b48fa92 (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
#define ECP_MAX_DIR_ITEM_IN_MSG ((ECP_MAX_PLD - ECP_SIZE_PLD((2 + sizeof(uint16_t)), ECP_MTYPE_DIR_REP)) / ECP_SIZE_DIR_ITEM)
#define ECP_SIZE_DIR_ITEM       40

#define ECP_MTYPE_DIR_REQ       0x00
#define ECP_MTYPE_DIR_REP       (0x01 | ECP_MTYPE_FLAG_FRAG)

#define ECP_CTYPE_DIR           (0x00 | ECP_CTYPE_FLAG_SYS)

#define ECP_ROLE_DIR            0x01
#define ECP_ROLE_VCONN          0x02

typedef struct ECPDirItem {
    ECPNode node;
    uint8_t region;
    uint8_t roles;
} ECPDirItem;

ssize_t ecp_dir_parse_msg(unsigned char *msg, size_t msg_size, unsigned char *count, unsigned char *region, uint16_t *serial);
size_t ecp_dir_parse_item(ECPDirItem *item, unsigned char *buf);
size_t ecp_dir_serialize_item(ECPDirItem *item, unsigned char *buf);
int ecp_dir_item_eq(ECPDirItem *item1, ECPDirItem *item2);

int ecp_dir_handle_open(ECPConnection *conn, ECP2Buffer *b);
ssize_t ecp_dir_send_req(ECPConnection *conn, unsigned char region);

void ecp_dir_conn_init(ECPConnection *conn, ECPSocket *sock);
int ecp_dir_request(ECPConnection *conn, ECPNode *node, unsigned char region);