block: m25p80: Dummy cycles for N25Q256/512
[qemu.git] / slirp / ip6_input.c
blobc0b11e73cd57b1391ba1fad59aa3f46c3184ce9d
1 /*
2 * Copyright (c) 2013
3 * Guillaume Subiron, Yann Bordenave, Serigne Modou Wagne.
4 */
6 #include "qemu/osdep.h"
7 #include "slirp.h"
8 #include "ip6_icmp.h"
11 * IP initialization: fill in IP protocol switch table.
12 * All protocols not implemented in kernel go to raw IP protocol handler.
14 void ip6_init(Slirp *slirp)
16 icmp6_init(slirp);
19 void ip6_cleanup(Slirp *slirp)
21 icmp6_cleanup(slirp);
24 void ip6_input(struct mbuf *m)
26 struct ip6 *ip6;
28 DEBUG_CALL("ip6_input");
29 DEBUG_ARG("m = %lx", (long)m);
30 DEBUG_ARG("m_len = %d", m->m_len);
32 if (m->m_len < sizeof(struct ip6)) {
33 goto bad;
36 ip6 = mtod(m, struct ip6 *);
38 if (ip6->ip_v != IP6VERSION) {
39 goto bad;
42 if (ntohs(ip6->ip_pl) > IF_MTU) {
43 icmp6_send_error(m, ICMP6_TOOBIG, 0);
44 goto bad;
47 /* check ip_ttl for a correct ICMP reply */
48 if (ip6->ip_hl == 0) {
49 icmp6_send_error(m, ICMP6_TIMXCEED, ICMP6_TIMXCEED_INTRANS);
50 goto bad;
54 * Switch out to protocol's input routine.
56 switch (ip6->ip_nh) {
57 case IPPROTO_TCP:
58 NTOHS(ip6->ip_pl);
59 tcp_input(m, sizeof(struct ip6), (struct socket *)NULL, AF_INET6);
60 break;
61 case IPPROTO_UDP:
62 udp6_input(m);
63 break;
64 case IPPROTO_ICMPV6:
65 icmp6_input(m);
66 break;
67 default:
68 m_free(m);
70 return;
71 bad:
72 m_free(m);