udp.c 673 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
  4. */
  5. #include <common.h>
  6. #include <net.h>
  7. #include <net/udp.h>
  8. static struct udp_ops *udp_ops;
  9. int udp_prereq(void)
  10. {
  11. int ret = 0;
  12. if (udp_ops->prereq)
  13. ret = udp_ops->prereq(udp_ops->data);
  14. return ret;
  15. }
  16. int udp_start(void)
  17. {
  18. return udp_ops->start(udp_ops->data);
  19. }
  20. int udp_loop(struct udp_ops *ops)
  21. {
  22. int ret = -1;
  23. if (!ops) {
  24. printf("%s: ops should not be null\n", __func__);
  25. goto out;
  26. }
  27. if (!ops->start) {
  28. printf("%s: no start function defined\n", __func__);
  29. goto out;
  30. }
  31. udp_ops = ops;
  32. ret = net_loop(UDP);
  33. out:
  34. return ret;
  35. }