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