vcc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* vccd/include/vcc/vcc.h
  2. *
  3. * This file is part of vccd.
  4. *
  5. * vccd is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * vccd is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with vccd. If not, see <https://www.gnu.org/licenses/>
  17. */
  18. #ifndef __VCC_VCC_H
  19. #define __VCC_VCC_H
  20. /* magic number in vcc_request to check that it's really a vcc package */
  21. #define VCC_MAGIC 0x01328e22
  22. #define VCC_MAGIC_RL 0x01328e36
  23. /* the port that vccd is listening on */
  24. #define VCC_PORT 46
  25. /* client -> server, send a message */
  26. #define REQ_MSG_SEND 1
  27. /* server -> client. sent when received a message */
  28. #define REQ_MSG_NEW 2
  29. /* client -> server. get users logged-in */
  30. #define REQ_CTL_USRS 3
  31. /* client -> server. login with password and username.
  32. * server -> client. login ack */
  33. #define REQ_CTL_LOGIN 4
  34. /* client -> server. create a new session */
  35. #define REQ_CTL_NEWSE 5
  36. /* client -> server: request (get sessions present).
  37. * server -> client: response */
  38. #define REQ_CTL_SESS 6
  39. /* client -> server. join session */
  40. #define REQ_CTL_JOINS 7
  41. /* client -> server. get user info */
  42. #define REQ_CTL_UINFO 8
  43. /* client -> server. increase one's score */
  44. #define REQ_SYS_SCRINC 9
  45. /* client -> server. send new message. */
  46. #define REQ_REL_MSG 10
  47. /* client -> server. intiauth login. */
  48. #define REQ_CTL_IALOG 11
  49. /* server -> client. new message */
  50. #define REQ_REL_NEW 12
  51. /* client -> server. get server info. (root required) */
  52. #define REQ_SYS_INFO 13
  53. #define REQ_MAX 14
  54. #define REQ_SIZE 512
  55. #define USRNAME_SIZE 32
  56. /* we'll not warn you anyway. */
  57. #define PASSWD_SIZE 64
  58. #define MSG_SIZE (REQ_SIZE - 5 * sizeof(int) - USRNAME_SIZE)
  59. #define FLAG_ENCRYPTED 1
  60. struct vcc_request {
  61. int magic;
  62. int reqtype;
  63. /* to make server easy and fast */
  64. int uid;
  65. int session;
  66. int flags;
  67. char usrname[USRNAME_SIZE];
  68. char msg[MSG_SIZE];
  69. };
  70. struct vcc_relay_header {
  71. int magic;
  72. int reqtype;
  73. int size;
  74. int uid;
  75. int session;
  76. char usrname[USRNAME_SIZE];
  77. char visible[USRNAME_SIZE];
  78. };
  79. #define to_boolean(c) (!!(c))
  80. #define likely(c) __builtin_expect(to_boolean(c), 1)
  81. #define unlikely(c) __builtin_expect(to_boolean(c), 0)
  82. #endif