diff --git a/net/icmp/icmp_input.c b/net/icmp/icmp_input.c index 154bd384ffb..ea3d543c16d 100644 --- a/net/icmp/icmp_input.c +++ b/net/icmp/icmp_input.c @@ -2,7 +2,7 @@ * net/icmp/icmp_input.c * Handling incoming ICMP/ICMP6 input * - * Copyright (C) 2007-2009, 2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Adapted for NuttX from logic in uIP which also has a BSD-like license: @@ -114,9 +114,6 @@ void icmp_input(FAR struct net_driver_s *dev) g_netstats.icmp.recv++; #endif -#ifndef CONFIG_NET_IPv6 - /* ICMPv4 processing code follows. */ - /* ICMP echo (i.e., ping) processing. This is simple, we only change the * ICMP type from ECHO to ECHO_REPLY and adjust the ICMP checksum before * we return the packet. @@ -207,115 +204,6 @@ typeerr: g_netstats.icmp.drop++; #endif dev->d_len = 0; - -#else /* !CONFIG_NET_IPv6 */ - - /* If we get a neighbor solicitation for our address we should send - * a neighbor advertisement message back. - */ - - if (picmp->type == ICMP6_NEIGHBOR_SOLICITATION) - { - if (net_ipaddr_cmp(picmp->icmp6data, dev->d_ipaddr)) - { - if (picmp->options[0] == ICMP6_OPTION_SOURCE_LINK_ADDRESS) - { - /* Save the sender's address in our neighbor list. */ - - net_neighbor_add(picmp->srcipaddr, &(picmp->options[2])); - } - - /* We should now send a neighbor advertisement back to where the - * neighbor solicitation came from. - */ - - picmp->type = ICMP6_NEIGHBOR_ADVERTISEMENT; - picmp->flags = ICMP6_FLAG_S; /* Solicited flag. */ - - picmp->reserved1 = picmp->reserved2 = picmp->reserved3 = 0; - - net_ipaddr_hdrcopy(picmp->destipaddr, picmp->srcipaddr); - net_ipaddr_hdrcopy(picmp->srcipaddr, &dev->d_ipaddr); - picmp->options[0] = ICMP6_OPTION_TARGET_LINK_ADDRESS; - picmp->options[1] = 1; /* Options length, 1 = 8 bytes. */ - memcpy(&(picmp->options[2]), &dev->d_mac, IFHWADDRLEN); - picmp->icmpchksum = 0; - picmp->icmpchksum = ~icmp_6chksum(dev); - } - else - { - goto drop; - } - } - else if (picmp->type == ICMP6_ECHO_REQUEST) - { - /* ICMP echo (i.e., ping) processing. This is simple, we only - * change the ICMP type from ECHO to ECHO_REPLY and update the - * ICMP checksum before we return the packet. - */ - - picmp->type = ICMP6_ECHO_REPLY; - - net_ipaddr_hdrcopy(picmp->destipaddr, picmp->srcipaddr); - net_ipaddr_hdrcopy(picmp->srcipaddr, &dev->d_ipaddr); - picmp->icmpchksum = 0; - picmp->icmpchksum = ~icmp_6chksum(dev); - } - - /* If an ICMP echo reply is received then there should also be - * a thread waiting to received the echo response. - */ - -#ifdef CONFIG_NET_ICMP_PING - else if (picmp->type == ICMP6_ECHO_REPLY && g_echocallback) - { - uint16_t flags = ICMP_ECHOREPLY; - - if (g_echocallback) - { - /* Dispatch the ECHO reply to the waiting thread */ - - flags = devif_callback_execute(dev, picmp, flags, g_echocallback); - } - - /* If the ECHO reply was not handled, then drop the packet */ - - if (flags == ICMP_ECHOREPLY) - { - /* The ECHO reply was not handled */ - - goto drop; - } - } -#endif - - else - { - nlldbg("Unknown ICMP6 cmd: %d\n", picmp->type); - goto typeerr; - } - - nllvdbg("Outgoing ICMP6 packet length: %d (%d)\n", - dev->d_len, (picmp->len[0] << 8) | picmp->len[1]); - -#ifdef CONFIG_NET_STATISTICS - g_netstats.icmp.sent++; - g_netstats.ip.sent++; -#endif - return; - -typeerr: -#ifdef CONFIG_NET_STATISTICS - g_netstats.icmp.typeerr++; -#endif - -drop: -#ifdef CONFIG_NET_STATISTICS - g_netstats.icmp.drop++; -#endif - dev->d_len = 0; - -#endif /* !CONFIG_NET_IPv6 */ } #endif /* CONFIG_NET_ICMP */ diff --git a/net/icmp/icmp_ping.c b/net/icmp/icmp_ping.c index 9530817357e..efcf6425645 100644 --- a/net/icmp/icmp_ping.c +++ b/net/icmp/icmp_ping.c @@ -218,12 +218,9 @@ static uint16_t ping_interrupt(FAR struct net_driver_s *dev, FAR void *conn, picmp->type = ICMP_ECHO_REQUEST; picmp->icode = 0; -#ifndef CONFIG_NET_IPv6 picmp->id = htons(pstate->png_id); picmp->seqno = htons(pstate->png_seqno); -#else -# error "IPv6 ECHO Request not implemented" -#endif + /* Add some easily verifiable data */ for (i = 0, ptr = ICMPDAT; i < pstate->png_datlen; i++) diff --git a/net/icmp/icmp_send.c b/net/icmp/icmp_send.c index 243b05d6069..e7326e242db 100644 --- a/net/icmp/icmp_send.c +++ b/net/icmp/icmp_send.c @@ -110,24 +110,7 @@ void icmp_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr) dev->d_sndlen += ICMP_HDRLEN; - /* Initialize the IP header. Note that for IPv6, the IP length field - * does not include the IPv6 IP header length. - */ - -#ifdef CONFIG_NET_IPv6 - - picmp->vtc = 0x60; - picmp->tcf = 0x00; - picmp->flow = 0x00; - picmp->len[0] = (dev->d_sndlen >> 8); - picmp->len[1] = (dev->d_sndlen & 0xff); - picmp->nexthdr = IP_PROTO_ICMP; - picmp->hoplimit = IP_TTL; - - net_ipaddr_copy(picmp->srcipaddr, &dev->d_ipaddr); - net_ipaddr_copy(picmp->destipaddr, destaddr); - -#else /* CONFIG_NET_IPv6 */ + /* Initialize the IP header. */ picmp->vhl = 0x45; picmp->tos = 0; @@ -149,8 +132,6 @@ void icmp_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr) picmp->ipchksum = 0; picmp->ipchksum = ~(ip_chksum(dev)); -#endif /* CONFIG_NET_IPv6 */ - /* Calculate the ICMP checksum. */ picmp->icmpchksum = 0;