]>
Commit | Line | Data |
---|---|---|
b43ea1bf PR |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * Copyright (C) 2020 Philippe Reynes <[email protected]> | |
4 | */ | |
5 | ||
6 | #include <common.h> | |
7 | #include <net.h> | |
8 | #include <net/udp.h> | |
9 | ||
10 | static struct udp_ops *udp_ops; | |
11 | ||
12 | int udp_prereq(void) | |
13 | { | |
14 | int ret = 0; | |
15 | ||
16 | if (udp_ops->prereq) | |
17 | ret = udp_ops->prereq(udp_ops->data); | |
18 | ||
19 | return ret; | |
20 | } | |
21 | ||
22 | int udp_start(void) | |
23 | { | |
24 | return udp_ops->start(udp_ops->data); | |
25 | } | |
26 | ||
27 | int udp_loop(struct udp_ops *ops) | |
28 | { | |
29 | int ret = -1; | |
30 | ||
31 | if (!ops) { | |
32 | printf("%s: ops should not be null\n", __func__); | |
33 | goto out; | |
34 | } | |
35 | ||
36 | if (!ops->start) { | |
37 | printf("%s: no start function defined\n", __func__); | |
38 | goto out; | |
39 | } | |
40 | ||
41 | udp_ops = ops; | |
42 | ret = net_loop(UDP); | |
43 | ||
44 | out: | |
45 | return ret; | |
46 | } |