fragmentation.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2009, 2011 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file src/fragmentation/fragmentation.h
  18. * @brief library to help fragment messages
  19. * @author Christian Grothoff
  20. */
  21. #ifndef FRAGMENTATION_H
  22. #define FRAGMENTATION_H
  23. #include "platform.h"
  24. #include "gnunet_fragmentation_lib.h"
  25. GNUNET_NETWORK_STRUCT_BEGIN
  26. /**
  27. * Header for a message fragment. Followed by the
  28. * original message.
  29. */
  30. struct FragmentHeader
  31. {
  32. /**
  33. * Message header.
  34. */
  35. struct GNUNET_MessageHeader header;
  36. /**
  37. * Unique fragment ID.
  38. */
  39. uint32_t fragment_id GNUNET_PACKED;
  40. /**
  41. * Total message size of the original message.
  42. */
  43. uint16_t total_size GNUNET_PACKED;
  44. /**
  45. * Absolute offset (in bytes) of this fragment in the original
  46. * message. Will be a multiple of the MTU.
  47. */
  48. uint16_t offset GNUNET_PACKED;
  49. };
  50. /**
  51. * Message fragment acknowledgement.
  52. */
  53. struct FragmentAcknowledgement
  54. {
  55. /**
  56. * Message header.
  57. */
  58. struct GNUNET_MessageHeader header;
  59. /**
  60. * Unique fragment ID.
  61. */
  62. uint32_t fragment_id GNUNET_PACKED;
  63. /**
  64. * Bits that are being acknowledged, in big-endian.
  65. * (bits that are set correspond to fragments that
  66. * have not yet been received).
  67. */
  68. uint64_t bits GNUNET_PACKED;
  69. };
  70. GNUNET_NETWORK_STRUCT_END
  71. #endif