target/ppc: Flush the TLB locally when the LPIDR is written
[qemu/kevin.git] / slirp / ip6_input.c
blob1b8c003c660cb5be0beb06df1309b7ae3a3e6e1d
1 /*
2 * Copyright (c) 2013
3 * Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne.
4 */
6 #include "slirp.h"
7 #include "ip6_icmp.h"
9 /*
10 * IP initialization: fill in IP protocol switch table.
11 * All protocols not implemented in kernel go to raw IP protocol handler.
13 void ip6_init(Slirp *slirp)
15 icmp6_init(slirp);
18 void ip6_cleanup(Slirp *slirp)
20 icmp6_cleanup(slirp);
23 void ip6_input(struct mbuf *m)
25 struct ip6 *ip6;
26 Slirp *slirp = m->slirp;
28 if (!slirp->in6_enabled) {
29 goto bad;
32 DEBUG_CALL("ip6_input");
33 DEBUG_ARG("m = %p", m);
34 DEBUG_ARG("m_len = %d", m->m_len);
36 if (m->m_len < sizeof(struct ip6)) {
37 goto bad;
40 ip6 = mtod(m, struct ip6 *);
42 if (ip6->ip_v != IP6VERSION) {
43 goto bad;
46 if (ntohs(ip6->ip_pl) > IF_MTU) {
47 icmp6_send_error(m, ICMP6_TOOBIG, 0);
48 goto bad;
51 /* check ip_ttl for a correct ICMP reply */
52 if (ip6->ip_hl == 0) {
53 icmp6_send_error(m, ICMP6_TIMXCEED, ICMP6_TIMXCEED_INTRANS);
54 goto bad;
58 * Switch out to protocol's input routine.
60 switch (ip6->ip_nh) {
61 case IPPROTO_TCP:
62 NTOHS(ip6->ip_pl);
63 tcp_input(m, sizeof(struct ip6), (struct socket *)NULL, AF_INET6);
64 break;
65 case IPPROTO_UDP:
66 udp6_input(m);
67 break;
68 case IPPROTO_ICMPV6:
69 icmp6_input(m);
70 break;
71 default:
72 m_free(m);
74 return;
75 bad:
76 m_free(m);