]>
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; | |
27 | ||
28 | DEBUG_CALL("ip6_input"); | |
29 | DEBUG_ARG("m = %lx", (long)m); | |
30 | DEBUG_ARG("m_len = %d", m->m_len); | |
31 | ||
32 | if (m->m_len < sizeof(struct ip6)) { | |
33 | goto bad; | |
34 | } | |
35 | ||
36 | ip6 = mtod(m, struct ip6 *); | |
37 | ||
38 | if (ip6->ip_v != IP6VERSION) { | |
39 | goto bad; | |
40 | } | |
41 | ||
fc6c9257 YB |
42 | if (ntohs(ip6->ip_pl) > IF_MTU) { |
43 | icmp6_send_error(m, ICMP6_TOOBIG, 0); | |
44 | goto bad; | |
45 | } | |
46 | ||
0d6ff71a GS |
47 | /* check ip_ttl for a correct ICMP reply */ |
48 | if (ip6->ip_hl == 0) { | |
fc6c9257 | 49 | icmp6_send_error(m, ICMP6_TIMXCEED, ICMP6_TIMXCEED_INTRANS); |
0d6ff71a GS |
50 | goto bad; |
51 | } | |
52 | ||
53 | /* | |
54 | * Switch out to protocol's input routine. | |
55 | */ | |
56 | switch (ip6->ip_nh) { | |
57 | case IPPROTO_TCP: | |
3feea444 GS |
58 | NTOHS(ip6->ip_pl); |
59 | tcp_input(m, sizeof(struct ip6), (struct socket *)NULL, AF_INET6); | |
0d6ff71a GS |
60 | break; |
61 | case IPPROTO_UDP: | |
15d62af4 | 62 | udp6_input(m); |
0d6ff71a GS |
63 | break; |
64 | case IPPROTO_ICMPV6: | |
65 | icmp6_input(m); | |
66 | break; | |
67 | default: | |
68 | m_free(m); | |
69 | } | |
70 | return; | |
71 | bad: | |
72 | m_free(m); | |
73 | } |