]>
Commit | Line | Data |
---|---|---|
0d6ff71a GS |
1 | /* |
2 | * Copyright (c) 2013 | |
3 | * Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne. | |
4 | */ | |
5 | ||
6 | #include "qemu/osdep.h" | |
7 | #include "slirp.h" | |
8 | #include "ip6_icmp.h" | |
9 | ||
10 | /* | |
11 | * IP initialization: fill in IP protocol switch table. | |
12 | * All protocols not implemented in kernel go to raw IP protocol handler. | |
13 | */ | |
14 | void ip6_init(Slirp *slirp) | |
15 | { | |
16 | icmp6_init(slirp); | |
17 | } | |
18 | ||
19 | void ip6_cleanup(Slirp *slirp) | |
20 | { | |
21 | icmp6_cleanup(slirp); | |
22 | } | |
23 | ||
24 | void ip6_input(struct mbuf *m) | |
25 | { | |
26 | struct ip6 *ip6; | |
0b11c036 ST |
27 | Slirp *slirp = m->slirp; |
28 | ||
29 | if (!slirp->in6_enabled) { | |
30 | goto bad; | |
31 | } | |
0d6ff71a GS |
32 | |
33 | DEBUG_CALL("ip6_input"); | |
34 | DEBUG_ARG("m = %lx", (long)m); | |
35 | DEBUG_ARG("m_len = %d", m->m_len); | |
36 | ||
37 | if (m->m_len < sizeof(struct ip6)) { | |
38 | goto bad; | |
39 | } | |
40 | ||
41 | ip6 = mtod(m, struct ip6 *); | |
42 | ||
43 | if (ip6->ip_v != IP6VERSION) { | |
44 | goto bad; | |
45 | } | |
46 | ||
fc6c9257 YB |
47 | if (ntohs(ip6->ip_pl) > IF_MTU) { |
48 | icmp6_send_error(m, ICMP6_TOOBIG, 0); | |
49 | goto bad; | |
50 | } | |
51 | ||
0d6ff71a GS |
52 | /* check ip_ttl for a correct ICMP reply */ |
53 | if (ip6->ip_hl == 0) { | |
fc6c9257 | 54 | icmp6_send_error(m, ICMP6_TIMXCEED, ICMP6_TIMXCEED_INTRANS); |
0d6ff71a GS |
55 | goto bad; |
56 | } | |
57 | ||
58 | /* | |
59 | * Switch out to protocol's input routine. | |
60 | */ | |
61 | switch (ip6->ip_nh) { | |
62 | case IPPROTO_TCP: | |
3feea444 GS |
63 | NTOHS(ip6->ip_pl); |
64 | tcp_input(m, sizeof(struct ip6), (struct socket *)NULL, AF_INET6); | |
0d6ff71a GS |
65 | break; |
66 | case IPPROTO_UDP: | |
15d62af4 | 67 | udp6_input(m); |
0d6ff71a GS |
68 | break; |
69 | case IPPROTO_ICMPV6: | |
70 | icmp6_input(m); | |
71 | break; | |
72 | default: | |
73 | m_free(m); | |
74 | } | |
75 | return; | |
76 | bad: | |
77 | m_free(m); | |
78 | } |