socketd.H 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * socketd.H
  3. *
  4. * Created on: Feb 4, 2013
  5. * Author: xaxaxa
  6. */
  7. /*
  8. This program is free software: you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation, either version 3 of the License, or
  11. (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. * */
  19. #ifndef SOCKETD_H_
  20. #define SOCKETD_H_
  21. #define SOCKETD_PROT_VERSION 1
  22. #define SOCKETD_MAX_HEADERLEN 1024
  23. namespace socketd
  24. {
  25. struct protocolHeader
  26. {
  27. int version;
  28. enum
  29. {
  30. none = 0, handleConnection, ackConnection, shutdown, attach, attachResponse
  31. } type;
  32. protocolHeader() :
  33. version(SOCKETD_PROT_VERSION), type(none) {
  34. }
  35. };
  36. struct prot_handleConnection
  37. {
  38. int64_t id;
  39. int32_t d;
  40. int32_t t;
  41. int32_t p;
  42. int32_t bufferLen;
  43. };
  44. struct prot_ackConnection
  45. {
  46. int64_t id;
  47. bool success;
  48. };
  49. struct prot_attach
  50. {
  51. int64_t id;
  52. int namelen;
  53. int authTokenLen;
  54. ///char name[namelen];
  55. ///char authToken[authTokenLen];
  56. };
  57. struct prot_attachResponse
  58. {
  59. int64_t id;
  60. bool success;
  61. };
  62. }
  63. #endif /* SOCKETD_H_ */