vcc.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /* client -> server. create a new session */
  34. #define REQ_CTL_NEWSE 5
  35. /* client -> server: request (get sessions present).
  36. * server -> client: response */
  37. #define REQ_CTL_SESS 6
  38. #define REQ_SIZE 512
  39. #define USRNAME_SIZE 32
  40. /* we'll not warn you anyway. */
  41. #define PASSWD_SIZE 64
  42. #define MSG_SIZE (REQ_SIZE - 4 * sizeof(int) - USRNAME_SIZE)
  43. struct vcc_request {
  44. int magic;
  45. int reqtype;
  46. /* to make server easy and fast */
  47. int uid;
  48. int session;
  49. char usrname[USRNAME_SIZE];
  50. char msg[MSG_SIZE];
  51. };
  52. #define to_boolean(c) (!!(c))
  53. #define likely(c) __builtin_expect(to_boolean(c), 1)
  54. #define unlikely(c) __builtin_expect(to_boolean(c), 0)
  55. #endif