blob: a93822f511cdaa2da66f5415c3075e6caef7e469 [file] [log] [blame]
Philippe Reynesb43ea1b2020-09-18 14:13:00 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
4 */
5
Tom Rinid678a592024-05-18 20:20:43 -06006#include <common.h>
Philippe Reynesb43ea1b2020-09-18 14:13:00 +02007#include <net.h>
8#include <net/udp.h>
9
10static struct udp_ops *udp_ops;
11
12int 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
22int udp_start(void)
23{
24 return udp_ops->start(udp_ops->data);
25}
26
27int 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}