#ifndef LC6_COMMON_H #define LC6_COMMON_H #include #include #include "../inc/libchat6.h" #include "../inc/lc6_helpers.h" #ifdef LC6_DEBUG #include "../inc/lc6_debug.h" #endif typedef struct LC6_NODE { unsigned char *pub_key; unsigned char *priv_key; } LC6_NODE; typedef struct LC6_USER { struct LC6_USER *prev; struct LC6_USER *next; unsigned char nickname[256]; unsigned char pub_key[32]; unsigned char priv_key[32]; uint8_t status; } LC6_USER; typedef struct LC6_FRIEND { struct LC6_FRIEND *prev; struct LC6_FRIEND *next; unsigned char nickname[256]; unsigned char pub_key[32]; uint8_t status; } LC6_FRIEND; typedef struct LC6_MSG_TLV { int type; int length; unsigned char *value; } LC6_MSG_TLV; typedef struct LC6_MSG { uint64_t timestamp; int type; LC6_MSG_TLV **tlv; } LC6_MSG; enum LC6_MSG_TYPE_ENUM { LC6_MSG_TYPE_CLIENT_ONLINE, LC6_MSG_TYPE_CLIENT_UPDATE, LC6_MSG_TYPE_CLIENT_OFFLINE, LC6_MSG_TYPE_KEEPALIVE_QUERY, LC6_MSG_TYPE_KEEPALIVE_RESPONSE, LC6_MSG_TYPE_FRIEND_REQUEST, LC6_MSG_TYPE_FRIEND_CONFIRM, LC6_MSG_TYPE_MESSAGE_SEND, LC6_MSG_TYPE_MESSAGE_RECV, LC6_MSG_TYPE_MESSAGE_READ, LC6_MSG_TYPE_NEIGHBOURS_REQUEST, LC6_MSG_TYPE_NEIGHBOURS_RESPONSE }; enum LC6_MSG_TLV_ENUM { LC6_MSG_TLV_NICKNAME, LC6_MSG_TLV_KEY, LC6_MSG_TLV_NONCE, LC6_MSG_TLV_ICON, LC6_MSG_TLV_METRIC, LC6_MSG_TLV_MSGID, LC6_MSG_TLV_CHATID, LC6_MSG_TLV_NEIGHBOUR }; enum LC6_MSG_TLV_TYPE_ENUM { LC6_MSG_TLV_TYPE_UTF8, LC6_MSG_TLV_TYPE_BINARY, LC6_MSG_TLV_TYPE_INTEGER, LC6_MSG_TLV_TYPE_UUID, LC6_MSG_TLV_TYPE_IPPORT }; #define LC6_CONFIG_BOOTSTRAP "bootstrap.bin" #define LC6_CONFIG_USER "user.bin" #define LC6_CONFIG_FRIEND "friends.bin" #define LC6_CONFIG_MAXLEN 50 typedef struct LC6_IPADDR { uint8_t af; union addr { uint32_t inet; unsigned char inet6[16]; } addr; } LC6_IPADDR; typedef struct LC6_BOOTSTRAP { struct LC6_BOOTSTRAP *prev; struct LC6_BOOTSTRAP *next; uint64_t last_contact; LC6_IPADDR ip; } LC6_BOOTSTRAP; typedef struct LC6_CTX { char path[MAXPATHLEN-LC6_CONFIG_MAXLEN]; LC6_USER *user; LC6_USER *node; LC6_FRIEND *friend; LC6_BOOTSTRAP *bootstrap; } LC6_CTX; extern int LC6_MSG_TLV_TYPE_INT[8]; extern unsigned char LC6_MSG_TYPE_STR[13][30]; extern unsigned char LC6_MSG_TLV_STR[8][20]; #endif