vcc.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_CR 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. #define REQ_SIZE 512
  42. #define USRNAME_SIZE 32
  43. /* we'll not warn you anyway. */
  44. #define PASSWD_SIZE 64
  45. #define MSG_SIZE (REQ_SIZE - 4 * sizeof(int) - USRNAME_SIZE)
  46. struct vcc_request {
  47. int magic;
  48. int reqtype;
  49. /* to make server easy and fast */
  50. int uid;
  51. int session;
  52. char usrname[USRNAME_SIZE];
  53. char msg[MSG_SIZE];
  54. };
  55. #define to_boolean(c) (!!(c))
  56. #define likely(c) __builtin_expect(to_boolean(c), 1)
  57. #define unlikely(c) __builtin_expect(to_boolean(c), 0)
  58. #endif