BProto.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @file BProto.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. *
  22. * @section DESCRIPTION
  23. *
  24. * Definitions for BProto serialization.
  25. */
  26. #ifndef BADVPN_BPROTO_BPROTO_H
  27. #define BADVPN_BPROTO_BPROTO_H
  28. #include <stdint.h>
  29. #define BPROTO_TYPE_UINT8 1
  30. #define BPROTO_TYPE_UINT16 2
  31. #define BPROTO_TYPE_UINT32 3
  32. #define BPROTO_TYPE_UINT64 4
  33. #define BPROTO_TYPE_DATA 5
  34. #define BPROTO_TYPE_CONSTDATA 6
  35. struct BProto_header_s {
  36. uint16_t id;
  37. uint16_t type;
  38. } __attribute__((packed));
  39. struct BProto_uint8_s {
  40. uint8_t v;
  41. } __attribute__((packed));
  42. struct BProto_uint16_s {
  43. uint16_t v;
  44. } __attribute__((packed));
  45. struct BProto_uint32_s {
  46. uint32_t v;
  47. } __attribute__((packed));
  48. struct BProto_uint64_s {
  49. uint64_t v;
  50. } __attribute__((packed));
  51. struct BProto_data_header_s {
  52. uint32_t len;
  53. } __attribute__((packed));
  54. #endif