vcc.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /* the port that vccd is listening on */
  23. #define VCC_PORT 46
  24. /* client -> server, send a message */
  25. #define REQ_MSG_SEND 1
  26. /* server -> client. sent when received a message */
  27. #define REQ_MSG_NEW 2
  28. /* client -> server. get users logged-in */
  29. #define REQ_CTL_USRS 3
  30. /* client -> server. login with password and username.
  31. * server -> client. login ack */
  32. #define REQ_CTL_LOGIN 4
  33. #define REQ_SIZE 1024
  34. #define USRNAME_SIZE 32
  35. #define MSG_SIZE (REQ_SIZE - 3 * sizeof(int) - USRNAME_SIZE)
  36. struct vcc_request {
  37. int magic;
  38. int reqtype;
  39. /* to make server easy and fast */
  40. int uid;
  41. char usrname[USRNAME_SIZE];
  42. char msg[MSG_SIZE];
  43. };
  44. #define to_boolean(c) (!!(c))
  45. #define likely(c) __builtin_expect(to_boolean(c), 1)
  46. #define unlikely(c) __builtin_expect(to_boolean(c), 0)
  47. #endif