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