FramingIface.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef FramingIface_H
  16. #define FramingIface_H
  17. #include "interface/Iface.h"
  18. #include "memory/Allocator.h"
  19. #include "util/Linker.h"
  20. Linker_require("interface/FramingIface.c");
  21. struct FramingIface
  22. {
  23. struct Iface messageIf;
  24. struct Iface streamIf;
  25. };
  26. /**
  27. * Framed message format:
  28. * [4 bytes length][ <length> bytes content ....... ]
  29. * The length is of only the content, not including the beginning 4 bytes
  30. * which represents the length itself.
  31. *
  32. * @param maxMessageSize how large of a framed message to allow
  33. * @param padding the amount of padding to apply to each full frame when it comes in, for outgoing
  34. * messages the message has no added padding, it is just sent across the wire as it
  35. * is.
  36. * @param alloc
  37. */
  38. struct FramingIface* FramingIface_new(uint32_t maxMessageSize,
  39. uint32_t padding,
  40. struct Allocator* alloc);
  41. #endif