A library for a decentralised peer-to-peer chat over IPv6 only.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

lc6_common.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef LC6_COMMON_H
  2. #define LC6_COMMON_H
  3. #include <sys/param.h>
  4. #include <arpa/inet.h>
  5. #include "../inc/libchat6.h"
  6. #include "../inc/lc6_helpers.h"
  7. #ifdef LC6_DEBUG
  8. #define malloc(x) lc6helpers_malloc(x, __FILE__, __func__, __LINE__)
  9. #define realloc(x,y) lc6helpers_realloc(x, y, __FILE__, __func__, __LINE__)
  10. #define free(x) lc6helpers_free(x, __FILE__, __func__, __LINE__)
  11. #endif
  12. typedef struct LC6_NODE {
  13. unsigned char *pub_key;
  14. unsigned char *priv_key;
  15. } LC6_NODE;
  16. typedef struct LC6_USER {
  17. struct LC6_USER *prev;
  18. struct LC6_USER *next;
  19. unsigned char nickname[256];
  20. unsigned char pub_key[32];
  21. unsigned char priv_key[32];
  22. uint8_t status;
  23. } LC6_USER;
  24. typedef struct LC6_FRIEND {
  25. struct LC6_FRIEND *prev;
  26. struct LC6_FRIEND *next;
  27. unsigned char nickname[256];
  28. unsigned char pub_key[32];
  29. uint8_t status;
  30. } LC6_FRIEND;
  31. #define LC6_CONFIG_BOOTSTRAP "bootstrap.bin"
  32. #define LC6_CONFIG_USER "user.bin"
  33. #define LC6_CONFIG_FRIEND "friends.bin"
  34. #define LC6_CONFIG_MAXLEN 50
  35. typedef struct LC6_BOOTSTRAP {
  36. struct LC6_BOOTSTRAP *prev;
  37. struct LC6_BOOTSTRAP *next;
  38. uint64_t last_contact;
  39. uint8_t af;
  40. union addr {
  41. uint32_t inet;
  42. unsigned char inet6[16];
  43. } addr;
  44. } LC6_BOOTSTRAP;
  45. typedef struct LC6_CTX {
  46. char path[MAXPATHLEN-LC6_CONFIG_MAXLEN];
  47. LC6_USER *user;
  48. LC6_USER *node;
  49. LC6_FRIEND *friend;
  50. LC6_BOOTSTRAP *bootstrap;
  51. } LC6_CTX;
  52. #endif