summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorPhilippe Reynes <philippe.reynes@softathome.com>2020-09-18 15:13:00 +0300
committerTom Rini <trini@konsulko.com>2020-09-30 23:55:03 +0300
commitb43ea1bf18bf4ba5eeec7131c1a19d864399e422 (patch)
tree5ae63ab33c462f8c016a61f31eea62c8240dd6e5 /include/net
parentcafaa301c98aa8f1b81cf61a91d22d5d68b4b1d3 (diff)
downloadu-boot-b43ea1bf18bf4ba5eeec7131c1a19d864399e422.tar.xz
net: add a generic udp protocol
This commit adds a generic udp protocol framework in the network loop. So protocol based on udp may be implemented without modifying the network loop (for example custom wait magic packet). Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/udp.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/net/udp.h b/include/net/udp.h
new file mode 100644
index 0000000000..2ae56e8447
--- /dev/null
+++ b/include/net/udp.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2020 Philippe Reynes <philippe.reynes@softathome.com>
+ */
+
+#ifndef __UDP
+#define __UDP
+
+/**
+ * struct udp_ops - function to handle udp packet
+ *
+ * This structure provides the function to handle udp packet in
+ * the network loop.
+ *
+ * @prereq: callback called to check the requirement
+ * @start: callback called to start the protocol/feature
+ * @data: pointer to store private data (used by prereq and start)
+ */
+struct udp_ops {
+ int (*prereq)(void *data);
+ int (*start)(void *data);
+ void *data;
+};
+
+int udp_prereq(void);
+
+int udp_start(void);
+
+/**
+ * udp_loop() - network loop for udp protocol
+ *
+ * Launch a network loop for udp protocol and use callbacks
+ * provided in parameter @ops to initialize the loop, and then
+ * to handle udp packet.
+ *
+ * @ops: udp callback
+ * @return: 0 if success, otherwise < 0 on error
+ */
+int udp_loop(struct udp_ops *ops);
+
+#endif