aboutsummaryrefslogtreecommitdiff
path: root/slirp/src/ip6_input.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2019-02-12 17:25:21 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2019-03-07 12:46:31 +0100
commitc2d63650d962612cfa1b21302782d4cd12142c74 (patch)
tree13f97c3ecbf6a6588f579e9f7c2ab9cb5f3ce5ec /slirp/src/ip6_input.c
parent5a4af0d4ee6084fdfde0125c45181fa0e6f48a17 (diff)
slirp: move sources to src/ subdirectory
Prepare for making slirp/ a standalone project. Remove some useless includes while at it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190212162524.31504-5-marcandre.lureau@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp/src/ip6_input.c')
-rw-r--r--slirp/src/ip6_input.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/slirp/src/ip6_input.c b/slirp/src/ip6_input.c
new file mode 100644
index 0000000000..1b8c003c66
--- /dev/null
+++ b/slirp/src/ip6_input.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013
+ * Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne.
+ */
+
+#include "slirp.h"
+#include "ip6_icmp.h"
+
+/*
+ * IP initialization: fill in IP protocol switch table.
+ * All protocols not implemented in kernel go to raw IP protocol handler.
+ */
+void ip6_init(Slirp *slirp)
+{
+ icmp6_init(slirp);
+}
+
+void ip6_cleanup(Slirp *slirp)
+{
+ icmp6_cleanup(slirp);
+}
+
+void ip6_input(struct mbuf *m)
+{
+ struct ip6 *ip6;
+ Slirp *slirp = m->slirp;
+
+ if (!slirp->in6_enabled) {
+ goto bad;
+ }
+
+ DEBUG_CALL("ip6_input");
+ DEBUG_ARG("m = %p", m);
+ DEBUG_ARG("m_len = %d", m->m_len);
+
+ if (m->m_len < sizeof(struct ip6)) {
+ goto bad;
+ }
+
+ ip6 = mtod(m, struct ip6 *);
+
+ if (ip6->ip_v != IP6VERSION) {
+ goto bad;
+ }
+
+ if (ntohs(ip6->ip_pl) > IF_MTU) {
+ icmp6_send_error(m, ICMP6_TOOBIG, 0);
+ goto bad;
+ }
+
+ /* check ip_ttl for a correct ICMP reply */
+ if (ip6->ip_hl == 0) {
+ icmp6_send_error(m, ICMP6_TIMXCEED, ICMP6_TIMXCEED_INTRANS);
+ goto bad;
+ }
+
+ /*
+ * Switch out to protocol's input routine.
+ */
+ switch (ip6->ip_nh) {
+ case IPPROTO_TCP:
+ NTOHS(ip6->ip_pl);
+ tcp_input(m, sizeof(struct ip6), (struct socket *)NULL, AF_INET6);
+ break;
+ case IPPROTO_UDP:
+ udp6_input(m);
+ break;
+ case IPPROTO_ICMPV6:
+ icmp6_input(m);
+ break;
+ default:
+ m_free(m);
+ }
+ return;
+bad:
+ m_free(m);
+}