UDPAddrIface.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 UDPAddrIface_H
  16. #define UDPAddrIface_H
  17. #include "exception/Er.h"
  18. #include "interface/Iface.h"
  19. #include "interface/addressable/AddrIface.h"
  20. #include "memory/Allocator.h"
  21. #include "util/events/EventBase.h"
  22. #include "util/log/Log.h"
  23. #include "util/Linker.h"
  24. Linker_require("util/events/libuv/UDPAddrIface.c")
  25. #include <stdbool.h>
  26. #define UDPAddrIface_PADDING_AMOUNT 512
  27. #define UDPAddrIface_BUFFER_CAP 3496
  28. /** Maximum number of bytes to hold in queue before dropping packets. */
  29. #define UDPAddrIface_MAX_QUEUE 16384
  30. struct UDPAddrIface
  31. {
  32. AddrIface_t generic;
  33. };
  34. /**
  35. * @param base the event loop context.
  36. * @param bindAddr the address/port to bind to.
  37. * @param allocator the memory allocator for this message.
  38. * @param logger
  39. * @return a new UDPInterfaceBase.
  40. */
  41. Er_DEFUN(struct UDPAddrIface* UDPAddrIface_new(struct EventBase* eventBase,
  42. struct Sockaddr* addr,
  43. struct Allocator* alloc,
  44. struct Log* logger));
  45. int UDPAddrIface_setDSCP(struct UDPAddrIface* iface, uint8_t dscp);
  46. int UDPAddrIface_setBroadcast(struct UDPAddrIface* iface, bool enable);
  47. int UDPAddrIface_getFd(struct UDPAddrIface*);
  48. #endif