diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2015-01-14 14:47:40 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2015-01-14 14:47:40 -0600 |
commit | 0892d0d061228e30acddf08810029ee7e5b63452 (patch) | |
tree | ed35f60d649cdc63f7e845ddea16804a854dcacb /nuttx/net/icmp | |
parent | 98de3817d981aa12f7bf903f65f4c918b794dfff (diff) | |
download | px4-nuttx-0892d0d061228e30acddf08810029ee7e5b63452.tar.gz px4-nuttx-0892d0d061228e30acddf08810029ee7e5b63452.tar.bz2 px4-nuttx-0892d0d061228e30acddf08810029ee7e5b63452.zip |
Networking: Remove all logic conditioned upon IPv6 from the net/icmp/directory
Diffstat (limited to 'nuttx/net/icmp')
-rw-r--r-- | nuttx/net/icmp/icmp_input.c | 114 | ||||
-rw-r--r-- | nuttx/net/icmp/icmp_ping.c | 5 | ||||
-rw-r--r-- | nuttx/net/icmp/icmp_send.c | 21 |
3 files changed, 3 insertions, 137 deletions
diff --git a/nuttx/net/icmp/icmp_input.c b/nuttx/net/icmp/icmp_input.c index 154bd384f..ea3d543c1 100644 --- a/nuttx/net/icmp/icmp_input.c +++ b/nuttx/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 <gnutt@nuttx.org> * * 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/nuttx/net/icmp/icmp_ping.c b/nuttx/net/icmp/icmp_ping.c index 953081735..efcf64256 100644 --- a/nuttx/net/icmp/icmp_ping.c +++ b/nuttx/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/nuttx/net/icmp/icmp_send.c b/nuttx/net/icmp/icmp_send.c index 243b05d60..e7326e242 100644 --- a/nuttx/net/icmp/icmp_send.c +++ b/nuttx/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; |