summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorViacheslav Mitrofanov <v.v.mitrofanov@yadro.com>2022-12-02 12:18:01 +0300
committerTom Rini <trini@konsulko.com>2022-12-05 20:47:16 +0300
commitc6610e1d90ea56711204b4d7a773f8e38976c87b (patch)
treeb0718e78bc82d6f299727ceb3c0d29c3fd8b71f3 /include
parent1dfa4ef14d4c223c5f1f7cac142b5b270560ab25 (diff)
downloadu-boot-c6610e1d90ea56711204b4d7a773f8e38976c87b.tar.xz
net: ipv6: Add Neighbor Discovery Protocol (NDP)
Implement basic of NDP. It doesn't include such things as Router Solicitation, Router Advertisement and Redirect. It just has Neighbor Solicitation and Neighbor Advertisement. Only these two features are used in u-boot IPv6. Implementation of some NDP functions uses API that was exposed in "net: ipv6: Add IPv6 basic primitives". Also this patch inlcudes update in Makefile to build NDP. Series-changes: 3 - Added structures and functions descriptions - Fixed style problems Series-changes: 4 - Fixed structures and functions description style Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/ndisc.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/include/ndisc.h b/include/ndisc.h
new file mode 100644
index 0000000000..f6f8eb6507
--- /dev/null
+++ b/include/ndisc.h
@@ -0,0 +1,102 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2013 Allied Telesis Labs NZ
+ * Chris Packham, <judge.packham@gmail.com>
+ *
+ * Copyright (C) 2022 YADRO
+ * Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
+ */
+
+#ifndef __NDISC_H__
+#define __NDISC_H__
+
+#include <ndisc.h>
+
+/* struct nd_msg - ICMPv6 Neighbour Discovery message format */
+struct nd_msg {
+ struct icmp6hdr icmph;
+ struct in6_addr target;
+ __u8 opt[0];
+};
+
+/* struct echo_msg - ICMPv6 echo request/reply message format */
+struct echo_msg {
+ struct icmp6hdr icmph;
+ __u16 id;
+ __u16 sequence;
+};
+
+/* Neigbour Discovery option types */
+enum {
+ __ND_OPT_PREFIX_INFO_END = 0,
+ ND_OPT_SOURCE_LL_ADDR = 1,
+ ND_OPT_TARGET_LL_ADDR = 2,
+ ND_OPT_PREFIX_INFO = 3,
+ ND_OPT_REDIRECT_HDR = 4,
+ ND_OPT_MTU = 5,
+ __ND_OPT_MAX
+};
+
+/* IPv6 destination address of packet waiting for ND */
+extern struct in6_addr net_nd_sol_packet_ip6;
+/* MAC destination address of packet waiting for ND */
+extern uchar *net_nd_packet_mac;
+/* pointer to packet waiting to be transmitted after ND is resolved */
+extern uchar *net_nd_tx_packet;
+/* size of packet waiting to be transmitted */
+extern int net_nd_tx_packet_size;
+/* the timer for ND resolution */
+extern ulong net_nd_timer_start;
+/* the number of requests we have sent so far */
+extern int net_nd_try;
+
+#ifdef CONFIG_IPV6
+/**
+ * ndisc_init() - Make initial steps for ND state machine.
+ * Usually move variables into initial state.
+ */
+void ndisc_init(void);
+
+/**
+ * ndisc_receive() - Handle ND packet
+ *
+ * @et: pointer to incoming packet
+ * @ip6: pointer to IPv6 header
+ * @len: incoming packet length
+ * Return: 0 if handle successfully, -1 if unsupported/unknown ND packet type
+ */
+int ndisc_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len);
+
+/**
+ * ndisc_request() - Send ND request
+ */
+void ndisc_request(void);
+
+/**
+ * ndisc_init() - Check ND response timeout
+ *
+ * Return: 0 if no timeout, -1 otherwise
+ */
+int ndisc_timeout_check(void);
+#else
+static inline void ndisc_init(void)
+{
+}
+
+static inline int
+ndisc_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len)
+{
+ return -1;
+}
+
+static inline void ndisc_request(void)
+{
+}
+
+static inline int ndisc_timeout_check(void)
+{
+ return 0;
+}
+#endif
+
+#endif /* __NDISC_H__ */