udp.h 930 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
  4. */
  5. #ifndef __UDP
  6. #define __UDP
  7. /**
  8. * struct udp_ops - function to handle udp packet
  9. *
  10. * This structure provides the function to handle udp packet in
  11. * the network loop.
  12. *
  13. * @prereq: callback called to check the requirement
  14. * @start: callback called to start the protocol/feature
  15. * @data: pointer to store private data (used by prereq and start)
  16. */
  17. struct udp_ops {
  18. int (*prereq)(void *data);
  19. int (*start)(void *data);
  20. void *data;
  21. };
  22. int udp_prereq(void);
  23. int udp_start(void);
  24. /**
  25. * udp_loop() - network loop for udp protocol
  26. *
  27. * Launch a network loop for udp protocol and use callbacks
  28. * provided in parameter @ops to initialize the loop, and then
  29. * to handle udp packet.
  30. *
  31. * @ops: udp callback
  32. * @return: 0 if success, otherwise < 0 on error
  33. */
  34. int udp_loop(struct udp_ops *ops);
  35. #endif