summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-15 12:19:44 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-15 12:19:44 -0600
commitc16ad40ac4e49dce5846763d2c31f571c978e355 (patch)
tree9c937d99fd955942764af7212621fa627afe425e
parent413912e8554701cd97f84cd8d98f3e98999cb520 (diff)
downloadpx4-nuttx-c16ad40ac4e49dce5846763d2c31f571c978e355.tar.gz
px4-nuttx-c16ad40ac4e49dce5846763d2c31f571c978e355.tar.bz2
px4-nuttx-c16ad40ac4e49dce5846763d2c31f571c978e355.zip
Networking: Misck IPv6 detanglement
-rw-r--r--nuttx/include/nuttx/net/icmpv6.h24
-rw-r--r--nuttx/include/nuttx/net/igmp.h75
-rw-r--r--nuttx/include/nuttx/net/ip.h58
-rw-r--r--nuttx/include/nuttx/net/netconfig.h7
-rw-r--r--nuttx/include/nuttx/net/netdev.h2
-rw-r--r--nuttx/include/nuttx/net/tcp.h62
-rw-r--r--nuttx/include/nuttx/net/udp.h57
-rw-r--r--nuttx/libc/libc.csv4
-rw-r--r--nuttx/libc/net/lib_inetntoa.c7
-rw-r--r--nuttx/libc/net/lib_inetntop.c170
-rw-r--r--nuttx/libc/net/lib_inetpton.c176
-rw-r--r--nuttx/net/arp/arp_arpin.c6
-rw-r--r--nuttx/net/arp/arp_format.c4
-rw-r--r--nuttx/net/arp/arp_ipin.c2
-rw-r--r--nuttx/net/arp/arp_out.c12
-rw-r--r--nuttx/net/arp/arp_send.c10
-rw-r--r--nuttx/net/arp/arp_table.c4
-rw-r--r--nuttx/net/devif/ipv4_input.c2
-rw-r--r--nuttx/net/icmp/icmp.h2
-rw-r--r--nuttx/net/icmp/icmp_input.c4
-rw-r--r--nuttx/net/icmp/icmp_ping.c24
-rw-r--r--nuttx/net/icmp/icmp_send.c6
-rw-r--r--nuttx/net/icmpv6/icmpv6.h2
-rw-r--r--nuttx/net/icmpv6/icmpv6_input.c2
-rw-r--r--nuttx/net/icmpv6/icmpv6_ping.c22
-rw-r--r--nuttx/net/icmpv6/icmpv6_send.c6
-rw-r--r--nuttx/net/ipv6/ipv6.h6
-rw-r--r--nuttx/net/ipv6/ipv6_neighbor.c16
28 files changed, 480 insertions, 292 deletions
diff --git a/nuttx/include/nuttx/net/icmpv6.h b/nuttx/include/nuttx/net/icmpv6.h
index d0b1e9f66..279498270 100644
--- a/nuttx/include/nuttx/net/icmpv6.h
+++ b/nuttx/include/nuttx/net/icmpv6.h
@@ -114,20 +114,20 @@ struct icmpv6_iphdr_s
{
/* IPv6 Ip header */
- uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
- uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
- uint16_t flow; /* 16-bit flow label (LS) */
- uint8_t len[2]; /* 16-bit Payload length */
- uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
- uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
- net_ip6addr_t srcipaddr; /* 128-bit Source address */
- net_ip6addr_t destipaddr; /* 128-bit Destination address */
+ uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
+ uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
+ uint16_t flow; /* 16-bit flow label (LS) */
+ uint8_t len[2]; /* 16-bit Payload length */
+ uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
+ uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
+ net_ipv6addr_t srcipaddr; /* 128-bit Source address */
+ net_ipv6addr_t destipaddr; /* 128-bit Destination address */
/* ICMPv6 header */
- uint8_t type; /* Defines the format of the ICMP message */
- uint8_t icode; /* Further qualifies the ICMP messsage */
- uint16_t icmpv6chksum; /* Checksum of ICMP header and data */
+ uint8_t type; /* Defines the format of the ICMP message */
+ uint8_t icode; /* Further qualifies the ICMP messages */
+ uint16_t icmpv6chksum; /* Checksum of ICMP header and data */
/* Data following the ICMP header contains the data specific to the
* message type indicated by the Type and Code fields.
@@ -200,7 +200,7 @@ extern "C"
*
****************************************************************************/
-int icmpv6_ping(net_ipaddr_t addr, uint16_t id, uint16_t seqno,
+int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno,
uint16_t datalen, int dsecs);
#undef EXTERN
diff --git a/nuttx/include/nuttx/net/igmp.h b/nuttx/include/nuttx/net/igmp.h
index a6a69c335..68028daee 100644
--- a/nuttx/include/nuttx/net/igmp.h
+++ b/nuttx/include/nuttx/net/igmp.h
@@ -125,37 +125,57 @@
* (0x11); in other messages it is set to 0 and ignored by the receiver.
*/
+#ifdef CONFIG_NET_IPv4
struct igmp_iphdr_s
{
-#ifdef CONFIG_NET_IPv6
+ /* IPv4 IP header */
- /* IPv6 Ip header */
+ uint8_t vhl; /* 8-bit Version (4) and header length (6 with Router Alert) */
+ uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
+ uint8_t len[2]; /* 16-bit Total length */
+ uint8_t ipid[2]; /* 16-bit Identification */
+ uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
+ uint8_t ttl; /* 8-bit Time to Live */
+ uint8_t proto; /* 8-bit Protocol */
+ uint16_t ipchksum; /* 16-bit Header checksum */
+ uint16_t srcipaddr[2]; /* 32-bit Source IP address */
+ uint16_t destipaddr[2]; /* 32-bit Destination IP address */
- uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
- uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
- uint16_t flow; /* 16-bit flow label (LS) */
- uint8_t len[2]; /* 16-bit Payload length */
- uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
- uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
- net_ip6addr_t srcipaddr; /* 128-bit Source address */
- net_ip6addr_t destipaddr; /* 128-bit Destination address */
+ /* Router Alert IP header option */
-#else /* CONFIG_NET_IPv6 */
+ uint16_t ra[2];
- /* IPv4 IP header */
+ /* IGMPv2 header:
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Type | Max Resp Time | Checksum |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Group Address |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
- uint8_t vhl; /* 8-bit Version (4) and header length (6 with Router Alert) */
- uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
- uint8_t len[2]; /* 16-bit Total length */
- uint8_t ipid[2]; /* 16-bit Identification */
- uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
- uint8_t ttl; /* 8-bit Time to Live */
- uint8_t proto; /* 8-bit Protocol */
- uint16_t ipchksum; /* 16-bit Header checksum */
- uint16_t srcipaddr[2]; /* 32-bit Source IP address */
- uint16_t destipaddr[2]; /* 32-bit Destination IP address */
+ uint8_t type; /* 8-bit IGMP packet type */
+ uint8_t maxresp; /* 8-bit Max response time */
+ uint16_t chksum; /* 16-bit Checksum */
+ uint16_t grpaddr[2]; /* 32-bit Group address */
+};
+#endif
-#endif /* CONFIG_NET_IPv6 */
+#ifdef CONFIG_NET_IPv6
+struct igmp_ipv6hdr_s
+{
+ /* IPv6 Ip header */
+
+ uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
+ uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */
+ uint16_t flow; /* 16-bit flow label (LS) */
+ uint8_t len[2]; /* 16-bit Payload length */
+ uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
+ uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
+ net_ipv6addr_t srcipaddr; /* 128-bit Source address */
+ net_ipv6addr_t destipaddr; /* 128-bit Destination address */
/* Router Alert IP header option */
@@ -172,11 +192,12 @@ struct igmp_iphdr_s
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- uint8_t type; /* 8-bit IGMP packet type */
- uint8_t maxresp; /* 8-bit Max response time */
- uint16_t chksum; /* 16-bit Checksum */
- uint16_t grpaddr[2]; /* 32-bit Group address */
+ uint8_t type; /* 8-bit IGMP packet type */
+ uint8_t maxresp; /* 8-bit Max response time */
+ uint16_t chksum; /* 16-bit Checksum */
+ uint16_t grpaddr[2]; /* 32-bit Group address */
};
+#endif
#ifdef CONFIG_NET_STATISTICS
struct igmp_stats_s
diff --git a/nuttx/include/nuttx/net/ip.h b/nuttx/include/nuttx/net/ip.h
index 160e00fa6..eb28fa1c7 100644
--- a/nuttx/include/nuttx/net/ip.h
+++ b/nuttx/include/nuttx/net/ip.h
@@ -92,13 +92,12 @@
/* Representation of an IP address */
-typedef in_addr_t net_ip4addr_t;
-typedef uint16_t net_ip6addr_t[8];
+typedef uint16_t net_ipv6addr_t[8];
#ifdef CONFIG_NET_IPv6
-typedef net_ip6addr_t net_ipaddr_t;
+typedef net_ipv6addr_t net_ipaddr_t;
#else
-typedef net_ip4addr_t net_ipaddr_t;
+typedef in_addr_t net_ipaddr_t;
#endif
#ifdef CONFIG_NET_IPv4
@@ -106,16 +105,16 @@ typedef net_ip4addr_t net_ipaddr_t;
struct net_iphdr_s
{
- uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
- uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
- uint8_t len[2]; /* 16-bit Total length */
- uint8_t ipid[2]; /* 16-bit Identification */
- uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
- uint8_t ttl; /* 8-bit Time to Live */
- uint8_t proto; /* 8-bit Protocol */
- uint16_t ipchksum; /* 16-bit Header checksum */
- uint16_t srcipaddr[2]; /* 32-bit Source IP address */
- uint16_t destipaddr[2]; /* 32-bit Destination IP address */
+ uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
+ uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
+ uint8_t len[2]; /* 16-bit Total length */
+ uint8_t ipid[2]; /* 16-bit Identification */
+ uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
+ uint8_t ttl; /* 8-bit Time to Live */
+ uint8_t proto; /* 8-bit Protocol */
+ uint16_t ipchksum; /* 16-bit Header checksum */
+ uint16_t srcipaddr[2]; /* 32-bit Source IP address */
+ uint16_t destipaddr[2]; /* 32-bit Destination IP address */
};
#endif
@@ -124,14 +123,14 @@ struct net_iphdr_s
struct net_ipv6hdr_s
{
- uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
- uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
- uint16_t flow; /* 16-bit flow label (LS) */
- uint8_t len[2]; /* 16-bit Payload length */
- uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
- uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
- net_ip6addr_t srcipaddr; /* 128-bit Source address */
- net_ip6addr_t destipaddr; /* 128-bit Destination address */
+ uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
+ uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
+ uint16_t flow; /* 16-bit flow label (LS) */
+ uint8_t len[2]; /* 16-bit Payload length */
+ uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
+ uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
+ net_ipv6addr_t srcipaddr; /* 128-bit Source address */
+ net_ipv6addr_t destipaddr; /* 128-bit Destination address */
};
#endif
@@ -229,7 +228,7 @@ struct net_ipv6hdr_s
((uint16_t*)(dest))[1] = ((uint16_t*)(src))[1]; \
} while (0)
-#define net_ipv6addr_copy(dest, src) memcpy(&dest, &src, sizeof(net_ip6addr_t))
+#define net_ipv6addr_copy(dest, src) memcpy(&dest, &src, sizeof(net_ipv6addr_t))
#define net_ipv6addr_hdrcopy(dest, src) net_ipv6addr_copy(dest, src)
#ifndef CONFIG_NET_IPv6
@@ -262,7 +261,7 @@ struct net_ipv6hdr_s
net_ipv4addr_cmp(net_ip4addr_conv32(addr1), net_ip4addr_conv32(addr2))
#define net_ipv6addr_cmp(addr1, addr2) \
- (memcmp(&addr1, &addr2, sizeof(net_ip6addr_t)) == 0)
+ (memcmp(&addr1, &addr2, sizeof(net_ipv6addr_t)) == 0)
#define net_ipv6addr_hdrcmp(addr1, addr2) \
net_ipv6addr_cmp(addr1, addr2)
@@ -297,13 +296,18 @@ struct net_ipv6hdr_s
* mask The netmask.
*/
-#ifndef CONFIG_NET_IPv6
-# define net_ipaddr_maskcmp(addr1, addr2, mask) \
+#define net_ipv4addr_maskcmp(addr1, addr2, mask) \
(((in_addr_t)(addr1) & (in_addr_t)(mask)) == \
((in_addr_t)(addr2) & (in_addr_t)(mask)))
+
+#ifndef CONFIG_NET_IPv6
+# define net_ipaddr_maskcmp(a,b,m) net_ipv4addr_maskcmp(a,b,m)
+
#else
-bool net_ipaddr_maskcmp(net_ipaddr_t addr1, net_ipaddr_t addr2,
+bool net_ipv6addr_maskcmp(net_ipaddr_t addr1, net_ipaddr_t addr2,
net_ipaddr_t mask);
+
+# define net_ipaddr_maskcmp(a,b,m) net_ipv6addr_maskcmp(a,b,m)
#endif
/* Mask out the network part of an IP address, given the address and
diff --git a/nuttx/include/nuttx/net/netconfig.h b/nuttx/include/nuttx/net/netconfig.h
index 247160355..cc582e497 100644
--- a/nuttx/include/nuttx/net/netconfig.h
+++ b/nuttx/include/nuttx/net/netconfig.h
@@ -9,7 +9,7 @@
* Note: Network configuration options the netconfig.h should not be changed,
* but rather the per-project defconfig file.
*
- * Copyright (C) 2007, 2011, 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2011, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This logic was leveraged from uIP which also has a BSD-style license:
@@ -139,9 +139,10 @@
#elif defined(CONFIG_NET_SLIP)
/* There is no link layer header with SLIP */
-# ifdef CONFIG_NET_IPv6
-# error SLIP is not available for IPv6
+# ifdef CONFIG_NET_IPv4
+# error SLIP requires IPv4 support
# endif
+
# define NET_LL_HDRLEN(d) 0
# define NET_DEV_MTU(d) CONFIG_NET_SLIP_MTU
# define MIN_NET_DEV_MTU CONFIG_NET_SLIP_MTU
diff --git a/nuttx/include/nuttx/net/netdev.h b/nuttx/include/nuttx/net/netdev.h
index 4a51f0e44..7d2f31250 100644
--- a/nuttx/include/nuttx/net/netdev.h
+++ b/nuttx/include/nuttx/net/netdev.h
@@ -2,7 +2,7 @@
* include/nuttx/net/netdev.h
* Defines architecture-specific device driver interfaces to the uIP network.
*
- * Copyright (C) 2007, 2009, 2011-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Derived largely from portions of uIP with has a similar BSD-styple license:
diff --git a/nuttx/include/nuttx/net/tcp.h b/nuttx/include/nuttx/net/tcp.h
index 0384f3bc5..146451ce2 100644
--- a/nuttx/include/nuttx/net/tcp.h
+++ b/nuttx/include/nuttx/net/tcp.h
@@ -123,37 +123,50 @@
/* The TCP and IP headers */
+#ifdef CONFIG_NET_IPv4
struct tcp_iphdr_s
{
-#ifdef CONFIG_NET_IPv6
-
- /* IPv6 Ip header */
+ /* IPv4 IP header */
- uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
- uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
- uint16_t flow; /* 16-bit flow label (LS) */
- uint8_t len[2]; /* 16-bit Payload length */
- uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
- uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
- net_ip6addr_t srcipaddr; /* 128-bit Source address */
- net_ip6addr_t destipaddr; /* 128-bit Destination address */
+ uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
+ uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
+ uint8_t len[2]; /* 16-bit Total length */
+ uint8_t ipid[2]; /* 16-bit Identification */
+ uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
+ uint8_t ttl; /* 8-bit Time to Live */
+ uint8_t proto; /* 8-bit Protocol */
+ uint16_t ipchksum; /* 16-bit Header checksum */
+ uint16_t srcipaddr[2]; /* 32-bit Source IP address */
+ uint16_t destipaddr[2]; /* 32-bit Destination IP address */
-#else /* CONFIG_NET_IPv6 */
+ /* TCP header */
- /* IPv4 IP header */
+ uint16_t srcport;
+ uint16_t destport;
+ uint8_t seqno[4];
+ uint8_t ackno[4];
+ uint8_t tcpoffset;
+ uint8_t flags;
+ uint8_t wnd[2];
+ uint16_t tcpchksum;
+ uint8_t urgp[2];
+ uint8_t optdata[4];
+};
+#endif
- uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
- uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
- uint8_t len[2]; /* 16-bit Total length */
- uint8_t ipid[2]; /* 16-bit Identification */
- uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
- uint8_t ttl; /* 8-bit Time to Live */
- uint8_t proto; /* 8-bit Protocol */
- uint16_t ipchksum; /* 16-bit Header checksum */
- uint16_t srcipaddr[2]; /* 32-bit Source IP address */
- uint16_t destipaddr[2]; /* 32-bit Destination IP address */
+#ifdef CONFIG_NET_IPv6
+struct tcp_ipv6hdr_s
+{
+ /* IPv6 IP header */
-#endif /* CONFIG_NET_IPv6 */
+ uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
+ uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
+ uint16_t flow; /* 16-bit flow label (LS) */
+ uint8_t len[2]; /* 16-bit Payload length */
+ uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
+ uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
+ net_ipv6addr_t srcipaddr; /* 128-bit Source address */
+ net_ipv6addr_t destipaddr; /* 128-bit Destination address */
/* TCP header */
@@ -168,6 +181,7 @@ struct tcp_iphdr_s
uint8_t urgp[2];
uint8_t optdata[4];
};
+#endif
/* The structure holding the TCP/IP statistics that are gathered if
* CONFIG_NET_STATISTICS is defined.
diff --git a/nuttx/include/nuttx/net/udp.h b/nuttx/include/nuttx/net/udp.h
index c32120c74..0032034c9 100644
--- a/nuttx/include/nuttx/net/udp.h
+++ b/nuttx/include/nuttx/net/udp.h
@@ -68,39 +68,47 @@
/****************************************************************************
* Public Type Definitions
****************************************************************************/
+
/* The UDP and IP headers */
+#ifdef CONFIG_NET_IPv4
struct udp_iphdr_s
{
-#ifdef CONFIG_NET_IPv6
-
- /* IPv6 Ip header */
+ /* IPv4 header */
- uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
- uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
- uint16_t flow; /* 16-bit flow label (LS) */
- uint8_t len[2]; /* 16-bit Payload length */
- uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
- uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
- net_ip6addr_t srcipaddr; /* 128-bit Source address */
- net_ip6addr_t destipaddr; /* 128-bit Destination address */
+ uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
+ uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
+ uint8_t len[2]; /* 16-bit Total length */
+ uint8_t ipid[2]; /* 16-bit Identification */
+ uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
+ uint8_t ttl; /* 8-bit Time to Live */
+ uint8_t proto; /* 8-bit Protocol */
+ uint16_t ipchksum; /* 16-bit Header checksum */
+ uint16_t srcipaddr[2]; /* 32-bit Source IP address */
+ uint16_t destipaddr[2]; /* 32-bit Destination IP address */
-#else /* CONFIG_NET_IPv6 */
+ /* UDP header */
- /* IPv4 header */
+ uint16_t srcport;
+ uint16_t destport;
+ uint16_t udplen;
+ uint16_t udpchksum;
+};
+#endif
- uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */
- uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */
- uint8_t len[2]; /* 16-bit Total length */
- uint8_t ipid[2]; /* 16-bit Identification */
- uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */
- uint8_t ttl; /* 8-bit Time to Live */
- uint8_t proto; /* 8-bit Protocol */
- uint16_t ipchksum; /* 16-bit Header checksum */
- uint16_t srcipaddr[2]; /* 32-bit Source IP address */
- uint16_t destipaddr[2]; /* 32-bit Destination IP address */
+#ifdef CONFIG_NET_IPv6
+struct udp_ipv6hdr_s
+{
+ /* IPv6 Ip header */
-#endif /* CONFIG_NET_IPv6 */
+ uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */
+ uint8_t tcf; /* Bits 0-3: traffic class (LS), 4-bits: flow label (MS) */
+ uint16_t flow; /* 16-bit flow label (LS) */
+ uint8_t len[2]; /* 16-bit Payload length */
+ uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */
+ uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */
+ net_ipv6addr_t srcipaddr; /* 128-bit Source address */
+ net_ipv6addr_t destipaddr; /* 128-bit Destination address */
/* UDP header */
@@ -109,6 +117,7 @@ struct udp_iphdr_s
uint16_t udplen;
uint16_t udpchksum;
};
+#endif
/* The structure holding the UDP statistics that are gathered if
* CONFIG_NET_STATISTICS is defined.
diff --git a/nuttx/libc/libc.csv b/nuttx/libc/libc.csv
index 1a6e38cac..605989c2a 100644
--- a/nuttx/libc/libc.csv
+++ b/nuttx/libc/libc.csv
@@ -1,4 +1,4 @@
-"_inet_ntoa","arpa/inet.h","!defined(CONFIG_NET_IPv6) && !defined(CONFIG_CAN_PASS_STRUCTS)","FAR char","in_addr_t"
+"_inet_ntoa","arpa/inet.h","defined(CONFIG_NET_IPv4) && !defined(CONFIG_CAN_PASS_STRUCTS)","FAR char","in_addr_t"
"abort","stdlib.h","","void"
"abs","stdlib.h","","int","int"
"aio_error","aio.h","defined(CONFIG_FS_AIO)","int","FAR struct aiocb *"
@@ -56,7 +56,7 @@
"htons","arpa/inet.h","","uint16_t","uint16_t"
"imaxabs","inttypes.h","","intmax_t","intmax_t"
"inet_addr","arpa/inet.h","","in_addr_t","FAR const char "
-"inet_ntoa","arpa/inet.h","!defined(CONFIG_NET_IPv6) && defined(CONFIG_CAN_PASS_STRUCTS)","FAR char","struct in_addr"
+"inet_ntoa","arpa/inet.h","defined(CONFIG_NET_IPv4) && defined(CONFIG_CAN_PASS_STRUCTS)","FAR char","struct in_addr"
"inet_ntop","arpa/inet.h","","FAR const char","int","FAR const void *","FAR char *","socklen_t"
"inet_pton","arpa/inet.h","","int","int","FAR const char *","FAR void *"
"labs","stdlib.h","","long int","long int"
diff --git a/nuttx/libc/net/lib_inetntoa.c b/nuttx/libc/net/lib_inetntoa.c
index f7152d154..f04c3a48f 100644
--- a/nuttx/libc/net/lib_inetntoa.c
+++ b/nuttx/libc/net/lib_inetntoa.c
@@ -1,7 +1,7 @@
/****************************************************************************
* libc/net/lib_inetntoa.c
*
- * Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2008, 2011-2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
-#ifndef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
/****************************************************************************
* Global Functions
@@ -78,5 +78,4 @@ FAR char *_inet_ntoa(in_addr_t in)
return buffer;
}
#endif
-#endif /* !CONFIG_NET_IPv6 */
-
+#endif /* CONFIG_NET_IPv4 */
diff --git a/nuttx/libc/net/lib_inetntop.c b/nuttx/libc/net/lib_inetntop.c
index ffa7ba26d..1f3d33c6f 100644
--- a/nuttx/libc/net/lib_inetntop.c
+++ b/nuttx/libc/net/lib_inetntop.c
@@ -1,7 +1,7 @@
/****************************************************************************
* libc/net/lib_inetntop.c
*
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Includes some logic extracted from hwport_ftpd, written by Jaehyuk Cho
@@ -54,22 +54,20 @@
#include <arpa/inet.h>
/****************************************************************************
- * Public Functions
+ * Private Functions
****************************************************************************/
/****************************************************************************
- * Name: inet_ntop
+ * Name: inet_ipv4_ntop
*
* Description:
- * The inet_ntop() function converts a numeric address into a text string
- * suitable for presentation.
+ * The inet_ipv4_ntop() function converts a numeric IPv4 address into a
+ * text string suitable for presentation.
*
* Input Parameters:
- * af - The af argument specifies the family of the address. This can be
- * AF_INET or AF_INET6.
* src - The src argument points to a buffer holding an address of the
* specified type. The address must be in network byte order.
- * dst - The dst argument points to a buffer where the function stores
+ * dest - The dest argument points to a buffer where the function stores
* the resulting text string; it shall not be NULL.
* size - The size argument specifies the size of this buffer, which must
* be large enough to hold the text string (INET_ADDRSTRLEN
@@ -80,35 +78,57 @@
* if the conversion succeeds. Otherwise, NULL is returned and the errno
* is set to indicate the error. There follow errno values may be set:
*
- * EAFNOSUPPORT - The af argument is invalid.
* ENOSPC - The size of the inet_ntop() result buffer is inadequate
*
****************************************************************************/
-FAR const char *inet_ntop(int af, FAR const void *src, FAR char *dst, socklen_t size)
+#ifdef CONFIG_NET_IPv4
+static int inet_ipv4_ntop(FAR const void *src, FAR char *dest, socklen_t size)
{
- int errval;
-#ifndef CONFIG_NET_IPv6
FAR char *ptr;
- DEBUGASSERT(src && dst);
-
- if (af != AF_INET)
- {
- errval = EAFNOSUPPORT;
- goto errout;
- }
-
if (size < INET_ADDRSTRLEN)
{
- errval = ENOSPC;
- goto errout;
+ return -ENOSPC;
}
ptr = (FAR char*)src;
- sprintf(dst, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);
- return dst;
-#else
+ sprintf(dest, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: inet_ipv6_ntop
+ *
+ * Description:
+ * The inet_ipv6_ntop() function converts a numeric IPv6 address into a
+ * text string suitable for presentation.
+ *
+ * Input Parameters:
+ * af - The af argument specifies the family of the address. This can be
+ * AF_INET or AF_INET6.
+ * src - The src argument points to a buffer holding an address of the
+ * specified type. The address must be in network byte order.
+ * dest - The dest argument points to a buffer where the function stores
+ * the resulting text string; it shall not be NULL.
+ * size - The size argument specifies the size of this buffer, which must
+ * be large enough to hold the text string (INET_ADDRSTRLEN
+ * characters for IPv4, INET6_ADDRSTRLEN characters for IPv6).
+ *
+ * Returned Value:
+ * inet_ntop() returns a pointer to the buffer containing the text string
+ * if the conversion succeeds. Otherwise, NULL is returned and the errno
+ * is set to indicate the error. There follow errno values may be set:
+ *
+ * EAFNOSUPPORT - The af argument is invalid.
+ * ENOSPC - The size of the inet_ntop() result buffer is inadequate
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv6
+static int inet_ipv6_ntop(FAR const void *src, FAR char *dest, socklen_t size)
+{
FAR const struct in6_addr *in6_addr;
uint16_t warray[8];
int offset;
@@ -117,18 +137,9 @@ FAR const char *inet_ntop(int af, FAR const void *src, FAR char *dst, socklen_t
int maxentry;
int maxcount;
- DEBUGASSERT(src && dst);
-
- if (af != AF_INET6)
- {
- errval = EAFNOSUPPORT;
- goto errout;
- }
-
if (size < INET6_ADDRSTRLEN)
{
- errval = ENOSPC;
- goto errout;
+ return -ENOSPC;
}
in6_addr = (FAR const struct in6_addr *)src;
@@ -167,36 +178,105 @@ FAR const char *inet_ntop(int af, FAR const void *src, FAR char *dst, socklen_t
}
offset = 0;
- dst[0] = '\0';
+ dest[0] = '\0';
while (offset < 8)
{
if (offset == maxentry)
{
- size -= snprintf(&dst[strlen(dst)], size, ":");
+ size -= snprintf(&dest[strlen(dest)], size, ":");
offset += maxcount;
if (offset >= 8)
{
- size -= snprintf(&dst[strlen(dst)], size, ":");
+ size -= snprintf(&dest[strlen(dest)], size, ":");
}
}
else
{
if (offset > 0)
{
- size -= snprintf(&dst[strlen(dst)], size, ":");
+ size -= snprintf(&dest[strlen(dest)], size, ":");
}
- size -= snprintf(&dst[strlen(dst)], size, "%x", warray[offset]);
+ size -= snprintf(&dest[strlen(dest)], size, "%x", warray[offset]);
offset++;
}
}
- return dst;
+ return OK;
+}
#endif
-errout:
- set_errno(errval);
- memset(dst, 0, size);
- return NULL;
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: inet_ntop
+ *
+ * Description:
+ * The inet_ntop() function converts a numeric address into a text string
+ * suitable for presentation.
+ *
+ * Input Parameters:
+ * af - The af argument specifies the family of the address. This can be
+ * AF_INET or AF_INET6.
+ * src - The src argument points to a buffer holding an address of the
+ * specified type. The address must be in network byte order.
+ * dest - The dest argument points to a buffer where the function stores
+ * the resulting text string; it shall not be NULL.
+ * size - The size argument specifies the size of this buffer, which must
+ * be large enough to hold the text string (INET_ADDRSTRLEN
+ * characters for IPv4, INET6_ADDRSTRLEN characters for IPv6).
+ *
+ * Returned Value:
+ * inet_ntop() returns a pointer to the buffer containing the text string
+ * if the conversion succeeds. Otherwise, NULL is returned and the errno
+ * is set to indicate the error. There follow errno values may be set:
+ *
+ * EAFNOSUPPORT - The af argument is invalid.
+ * ENOSPC - The size of the inet_ntop() result buffer is inadequate
+ *
+ ****************************************************************************/
+
+FAR const char *inet_ntop(int af, FAR const void *src, FAR char *dest,
+ socklen_t size)
+{
+ int ret;
+
+ DEBUGASSERT(src && dest);
+
+ /* Do the conversion according to the IP version */
+
+ switch (af)
+ {
+#ifdef CONFIG_NET_IPv4
+ case AF_INET:
+ ret = inet_ipv4_ntop(src, dest, size);
+ break;
+#endif
+
+#ifdef CONFIG_NET_IPv6
+ case AF_INET6:
+ ret = inet_ipv6_ntop(src, dest, size);
+ break;
+#endif
+
+ default:
+ ret = -EAFNOSUPPORT;
+ break;
+ }
+
+ /* Handle errors in the conversion */
+
+ if (ret < 0)
+ {
+ set_errno(-ret);
+ memset(dest, 0, size);
+ return NULL;
+ }
+
+ /* Return success */
+
+ return dest;
}
diff --git a/nuttx/libc/net/lib_inetpton.c b/nuttx/libc/net/lib_inetpton.c
index 8b058e044..72229d2f2 100644
--- a/nuttx/libc/net/lib_inetpton.c
+++ b/nuttx/libc/net/lib_inetpton.c
@@ -56,61 +56,33 @@
#include <netinet/in.h>
/****************************************************************************
- * Public Functions
+ * Private Functions
****************************************************************************/
/****************************************************************************
- * Name: inet_pton
+ * Name: inet_ipv4_pton
*
* Description:
- * The inet_pton() function converts an address in its standard text
- * presentation form into its numeric binary form.
- *
- * If the af argument of inet_pton() is AF_INET, the src string will be
- * in the standard IPv4 dotted-decimal form:
- *
- * ddd.ddd.ddd.ddd
- *
- * where "ddd" is a one to three digit decimal number between 0 and 255.
- *
- * If the af argument of inet_pton() is AF_INET6, the src string will be in
- * one of the following standard IPv6 text forms:
- *
- * 1. The preferred form is "x:x:x:x:x:x:x:x", where the 'x' s are the
- * hexadecimal values of the eight 16-bit pieces of the address. Leading
- * zeros in individual fields can be omitted, but there must be at least
- * one numeral in every field.
- *
- * 2. A string of contiguous zero fields in the preferred form can be shown
- * as "::". The "::" can only appear once in an address. Unspecified
- * addresses ( "0:0:0:0:0:0:0:0" ) may be represented simply as "::".
- *
- * 3. A third form that is sometimes more convenient when dealing with a
- * mixed environment of IPv4 and IPv6 nodes is "x:x:x:x:x:x:d.d.d.d",
- * where the 'x' s are the hexadecimal values of the six high-order
- * 16-bit pieces of the address, and the 'd' s are the decimal values
- * of the four low-order 8-bit pieces of the address (standard IPv4
- * representation).
+ * The inet_ipv4_pton() function converts an IPv4 address in its standard
+ * text presentation form into its numeric binary form.
*
* Input Parameters:
- * af - The af argument specifies the family of the address. This can be
- * AF_INET or AF_INET6.
* src - The src argument points to the string being passed in.
- * dst - The dst argument points to a numstr into which the function stores
+ * dest - The dest argument points to a numstr into which the function stores
* the numeric address; this must be large enough to hold the numeric
* address (32 bits for AF_INET, 128 bits for AF_INET6).
*
* Returned Value:
* The inet_pton() function returns 1 if the conversion succeeds, with the
- * address pointed to by dst in network byte order. It will return 0 if the
+ * address pointed to by dest in network byte order. It will return 0 if the
* input is not a valid IPv4 dotted-decimal string or a valid IPv6 address
* string, or -1 with errno set to EAFNOSUPPOR] if the af argument is unknown.
*
****************************************************************************/
-int inet_pton(int af, FAR const char *src, FAR void *dst)
+#ifdef CONFIG_NET_IPv4
+static int inet_ipv4_pton(FAR const char *src, FAR void *dest)
{
-#ifndef CONFIG_NET_IPv6
size_t srcoffset;
size_t numoffset;
int value;
@@ -119,17 +91,9 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
char numstr[4];
uint8_t *ip;
- DEBUGASSERT(src && dst);
-
- if (af != AF_INET)
- {
- set_errno(EAFNOSUPPORT);
- return -1;
- }
-
- (void)memset(dst, 0, sizeof(struct in_addr));
+ (void)memset(dest, 0, sizeof(struct in_addr));
- ip = (uint8_t *)dst;
+ ip = (uint8_t *)dest;
srcoffset = 0;
numoffset = 0;
ndots = 0;
@@ -204,7 +168,33 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
/* Return zero if there is any problem parsing the input */
return 0;
-#else
+}
+#endif
+
+/****************************************************************************
+ * Name: inet_ipv6_pton
+ *
+ * Description:
+ * The inet_ipv6_pton() function converts an IPv6 address in its standard
+ * text presentation form into its numeric binary form.
+ *
+ * Input Parameters:
+ * src - The src argument points to the string being passed in.
+ * dest - The dest argument points to a numstr into which the function stores
+ * the numeric address; this must be large enough to hold the numeric
+ * address (32 bits for AF_INET, 128 bits for AF_INET6).
+ *
+ * Returned Value:
+ * The inet_pton() function returns 1 if the conversion succeeds, with the
+ * address pointed to by dest in network byte order. It will return 0 if the
+ * input is not a valid IPv4 dotted-decimal string or a valid IPv6 address
+ * string, or -1 with errno set to EAFNOSUPPOR] if the af argument is unknown.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv6
+static int inet_ipv6_pton(FAR const char *src, FAR void *dest)
+{
size_t srcoffset;
size_t numoffset;
long value;
@@ -216,15 +206,7 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
uint8_t rip[sizeof(struct in6_addr)];
bool rtime;
- DEBUGASSERT(src && dst);
-
- if (af != AF_INET6)
- {
- set_errno(EAFNOSUPPORT);
- return -1;
- }
-
- (void)memset(dst, 0, sizeof(struct in6_addr));
+ (void)memset(dest, 0, sizeof(struct in6_addr));
srcoffset = 0;
numoffset = 0;
@@ -298,12 +280,12 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
if (nsep > 0)
{
- memcpy(dst, &ip[0], nsep << 1);
+ memcpy(dest, &ip[0], nsep << 1);
}
if (nrsep > 0)
{
- memcpy(dst + (16 - (nrsep << 1)), &rip[0], nrsep << 1);
+ memcpy(dest + (16 - (nrsep << 1)), &rip[0], nrsep << 1);
}
/* Return 1 if the conversion succeeds */
@@ -335,5 +317,83 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
/* Return zero if there is any problem parsing the input */
return 0;
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: inet_pton
+ *
+ * Description:
+ * The inet_pton() function converts an address in its standard text
+ * presentation form into its numeric binary form.
+ *
+ * If the af argument of inet_pton() is AF_INET, the src string will be
+ * in the standard IPv4 dotted-decimal form:
+ *
+ * ddd.ddd.ddd.ddd
+ *
+ * where "ddd" is a one to three digit decimal number between 0 and 255.
+ *
+ * If the af argument of inet_pton() is AF_INET6, the src string will be in
+ * one of the following standard IPv6 text forms:
+ *
+ * 1. The preferred form is "x:x:x:x:x:x:x:x", where the 'x' s are the
+ * hexadecimal values of the eight 16-bit pieces of the address. Leading
+ * zeros in individual fields can be omitted, but there must be at least
+ * one numeral in every field.
+ *
+ * 2. A string of contiguous zero fields in the preferred form can be shown
+ * as "::". The "::" can only appear once in an address. Unspecified
+ * addresses ( "0:0:0:0:0:0:0:0" ) may be represented simply as "::".
+ *
+ * 3. A third form that is sometimes more convenient when dealing with a
+ * mixed environment of IPv4 and IPv6 nodes is "x:x:x:x:x:x:d.d.d.d",
+ * where the 'x' s are the hexadecimal values of the six high-order
+ * 16-bit pieces of the address, and the 'd' s are the decimal values
+ * of the four low-order 8-bit pieces of the address (standard IPv4
+ * representation).
+ *
+ * Input Parameters:
+ * af - The af argument specifies the family of the address. This can be
+ * AF_INET or AF_INET6.
+ * src - The src argument points to the string being passed in.
+ * dest - The dest argument points to a numstr into which the function stores
+ * the numeric address; this must be large enough to hold the numeric
+ * address (32 bits for AF_INET, 128 bits for AF_INET6).
+ *
+ * Returned Value:
+ * The inet_pton() function returns 1 if the conversion succeeds, with the
+ * address pointed to by dest in network byte order. It will return 0 if the
+ * input is not a valid IPv4 dotted-decimal string or a valid IPv6 address
+ * string, or -1 with errno set to EAFNOSUPPORT] if the af argument is
+ * unknown.
+ *
+ ****************************************************************************/
+
+int inet_pton(int af, FAR const char *src, FAR void *dest)
+{
+ DEBUGASSERT(src && dest);
+
+ /* Do the conversion according to the IP version */
+
+ switch (af)
+ {
+#ifdef CONFIG_NET_IPv4
+ case AF_INET:
+ return inet_ipv4_pton(src, dest);
+#endif
+
+#ifdef CONFIG_NET_IPv6
+ case AF_INET6:
+ return inet_ipv6_pton(src, dest);
#endif
+
+ default:
+ set_errno(EAFNOSUPPORT);
+ return ERROR;
+ }
}
diff --git a/nuttx/net/arp/arp_arpin.c b/nuttx/net/arp/arp_arpin.c
index eed1539a6..99ff7ee67 100644
--- a/nuttx/net/arp/arp_arpin.c
+++ b/nuttx/net/arp/arp_arpin.c
@@ -123,7 +123,7 @@ void arp_arpin(FAR struct net_driver_s *dev)
/* ARP request. If it asked for our address, we send out a reply. */
- if (net_ipaddr_cmp(ipaddr, dev->d_ipaddr))
+ if (net_ipv4addr_cmp(ipaddr, dev->d_ipaddr))
{
struct eth_hdr_s *peth = ETHBUF;
@@ -142,7 +142,7 @@ void arp_arpin(FAR struct net_driver_s *dev)
parp->ah_dipaddr[0] = parp->ah_sipaddr[0];
parp->ah_dipaddr[1] = parp->ah_sipaddr[1];
- net_ipaddr_hdrcopy(parp->ah_sipaddr, &dev->d_ipaddr);
+ net_ipv4addr_hdrcopy(parp->ah_sipaddr, &dev->d_ipaddr);
arp_dump(parp);
peth->type = HTONS(ETHTYPE_ARP);
@@ -157,7 +157,7 @@ void arp_arpin(FAR struct net_driver_s *dev)
* for us.
*/
- if (net_ipaddr_cmp(ipaddr, dev->d_ipaddr))
+ if (net_ipv4addr_cmp(ipaddr, dev->d_ipaddr))
{
/* Yes... Insert the address mapping in the ARP table */
diff --git a/nuttx/net/arp/arp_format.c b/nuttx/net/arp/arp_format.c
index 50a3054e1..21cd99d20 100644
--- a/nuttx/net/arp/arp_format.c
+++ b/nuttx/net/arp/arp_format.c
@@ -105,8 +105,8 @@ void arp_format(FAR struct net_driver_s *dev, in_addr_t ipaddr)
memcpy(eth->src, dev->d_mac.ether_addr_octet, ETHER_ADDR_LEN);
memcpy(arp->ah_shwaddr, dev->d_mac.ether_addr_octet, ETHER_ADDR_LEN);
- net_ipaddr_hdrcopy(arp->ah_dipaddr, &ipaddr);
- net_ipaddr_hdrcopy(arp->ah_sipaddr, &dev->d_ipaddr);
+ net_ipv4addr_hdrcopy(arp->ah_dipaddr, &ipaddr);
+ net_ipv4addr_hdrcopy(arp->ah_sipaddr, &dev->d_ipaddr);
arp->ah_opcode = HTONS(ARP_REQUEST);
arp->ah_hwtype = HTONS(ARP_HWTYPE_ETH);
diff --git a/nuttx/net/arp/arp_ipin.c b/nuttx/net/arp/arp_ipin.c
index ddd7102a1..558af73f3 100644
--- a/nuttx/net/arp/arp_ipin.c
+++ b/nuttx/net/arp/arp_ipin.c
@@ -99,7 +99,7 @@ void arp_ipin(FAR struct net_driver_s *dev)
*/
srcipaddr = net_ip4addr_conv32(IPBUF->eh_srcipaddr);
- if (net_ipaddr_maskcmp(srcipaddr, dev->d_ipaddr, dev->d_netmask))
+ if (net_ipv4addr_maskcmp(srcipaddr, dev->d_ipaddr, dev->d_netmask))
{
arp_update(IPBUF->eh_srcipaddr, ETHBUF->src);
}
diff --git a/nuttx/net/arp/arp_out.c b/nuttx/net/arp/arp_out.c
index 6b5b038c7..b5d5af755 100644
--- a/nuttx/net/arp/arp_out.c
+++ b/nuttx/net/arp/arp_out.c
@@ -92,7 +92,7 @@ static const uint16_t g_broadcast_ipaddr[2] = {0xffff, 0xffff};
* The following is the first three octects of the IGMP address:
*/
-#if defined(CONFIG_NET_IGMP) && !defined(CONFIG_NET_IPv6)
+#ifdef CONFIG_NET_IGMP
static const uint8_t g_multicast_ethaddr[3] = {0x01, 0x00, 0x5e};
#endif
@@ -163,12 +163,12 @@ void arp_out(FAR struct net_driver_s *dev)
/* First check if destination is a local broadcast. */
- if (net_ipaddr_hdrcmp(pip->eh_destipaddr, g_broadcast_ipaddr))
+ if (net_ipv4addr_hdrcmp(pip->eh_destipaddr, g_broadcast_ipaddr))
{
memcpy(peth->dest, g_broadcast_ethaddr.ether_addr_octet, ETHER_ADDR_LEN);
}
-#if defined(CONFIG_NET_IGMP) && !defined(CONFIG_NET_IPv6)
+#ifdef CONFIG_NET_IGMP
/* Check if the destination address is a multicast address
*
* - IPv4: multicast addresses lie in the class D group -- The address range
@@ -196,7 +196,7 @@ void arp_out(FAR struct net_driver_s *dev)
/* Check if the destination address is on the local network. */
destipaddr = net_ip4addr_conv32(pip->eh_destipaddr);
- if (!net_ipaddr_maskcmp(destipaddr, dev->d_ipaddr, dev->d_netmask))
+ if (!net_ipv4addr_maskcmp(destipaddr, dev->d_ipaddr, dev->d_netmask))
{
/* Destination address is not on the local network */
@@ -213,14 +213,14 @@ void arp_out(FAR struct net_driver_s *dev)
* destination address when determining the MAC address.
*/
- net_ipaddr_copy(ipaddr, dev->d_draddr);
+ net_ipv4addr_copy(ipaddr, dev->d_draddr);
#endif
}
else
{
/* Else, we use the destination IP address. */
- net_ipaddr_copy(ipaddr, destipaddr);
+ net_ipv4addr_copy(ipaddr, destipaddr);
}
/* Check if we already have this destination address in the ARP table */
diff --git a/nuttx/net/arp/arp_send.c b/nuttx/net/arp/arp_send.c
index b3803d0f1..baa8e4ea3 100644
--- a/nuttx/net/arp/arp_send.c
+++ b/nuttx/net/arp/arp_send.c
@@ -202,7 +202,7 @@ int arp_send(in_addr_t ipaddr)
return OK;
}
-#if defined(CONFIG_NET_IGMP) && !defined(CONFIG_NET_IPv6)
+#ifdef CONFIG_NET_IGMP
/* Check if the destination address is a multicast address
*
* - IPv4: multicast addresses lie in the class D group -- The address range
@@ -250,9 +250,9 @@ int arp_send(in_addr_t ipaddr)
/* Check if the destination address is on the local network. */
- if (!net_ipaddr_maskcmp(ipaddr, dev->d_ipaddr, dev->d_netmask))
+ if (!net_ipv4addr_maskcmp(ipaddr, dev->d_ipaddr, dev->d_netmask))
{
- net_ipaddr_t dripaddr;
+ in_addr_t dripaddr;
/* Destination address is not on the local network */
@@ -270,7 +270,7 @@ int arp_send(in_addr_t ipaddr)
* destination address when determining the MAC address.
*/
- net_ipaddr_copy(dripaddr, dev->d_draddr);
+ net_ipv4addr_copy(dripaddr, dev->d_draddr);
#endif
ipaddr = dripaddr;
}
@@ -338,7 +338,7 @@ int arp_send(in_addr_t ipaddr)
/* Notify the device driver that new TX data is available.
* NOTES: This is in essence what netdev_txnotify() does, which
- * is not possible to call since it expects a net_ipaddr_t as
+ * is not possible to call since it expects a in_addr_t as
* its single argument to lookup the network interface.
*/
diff --git a/nuttx/net/arp/arp_table.c b/nuttx/net/arp/arp_table.c
index c1b356f41..a9e201c73 100644
--- a/nuttx/net/arp/arp_table.c
+++ b/nuttx/net/arp/arp_table.c
@@ -173,7 +173,7 @@ void arp_update(FAR uint16_t *pipaddr, FAR uint8_t *ethaddr)
* the IP address in this ARP table entry.
*/
- if (net_ipaddr_cmp(ipaddr, tabptr->at_ipaddr))
+ if (net_ipv4addr_cmp(ipaddr, tabptr->at_ipaddr))
{
/* An old entry found, update this and return. */
@@ -252,7 +252,7 @@ FAR struct arp_entry *arp_find(in_addr_t ipaddr)
for (i = 0; i < CONFIG_NET_ARPTAB_SIZE; ++i)
{
tabptr = &g_arptable[i];
- if (net_ipaddr_cmp(ipaddr, tabptr->at_ipaddr))
+ if (net_ipv4addr_cmp(ipaddr, tabptr->at_ipaddr))
{
return tabptr;
}
diff --git a/nuttx/net/devif/ipv4_input.c b/nuttx/net/devif/ipv4_input.c
index c15e22f04..e7895d003 100644
--- a/nuttx/net/devif/ipv4_input.c
+++ b/nuttx/net/devif/ipv4_input.c
@@ -425,7 +425,7 @@ int ipv4_input(FAR struct net_driver_s *dev)
if (!net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr), dev->d_ipaddr))
{
#ifdef CONFIG_NET_IGMP
- net_ipv4addr_t destip = net_ip4addr_conv32(pbuf->destipaddr);
+ in_addr_t destip = net_ip4addr_conv32(pbuf->destipaddr);
if (igmp_grpfind(dev, &destip) == NULL)
#endif
{
diff --git a/nuttx/net/icmp/icmp.h b/nuttx/net/icmp/icmp.h
index a5cad2b19..3e55d4c51 100644
--- a/nuttx/net/icmp/icmp.h
+++ b/nuttx/net/icmp/icmp.h
@@ -85,7 +85,7 @@ void icmp_poll(FAR struct net_driver_s *dev);
/* Defined in icmp_send.c ***************************************************/
#ifdef CONFIG_NET_ICMP_PING
-void icmp_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr);
+void icmp_send(FAR struct net_driver_s *dev, FAR in_addr_t *destaddr);
#endif /* CONFIG_NET_ICMP_PING */
#undef EXTERN
diff --git a/nuttx/net/icmp/icmp_input.c b/nuttx/net/icmp/icmp_input.c
index 4539faf13..268742120 100644
--- a/nuttx/net/icmp/icmp_input.c
+++ b/nuttx/net/icmp/icmp_input.c
@@ -139,8 +139,8 @@ void icmp_input(FAR struct net_driver_s *dev)
/* Swap IP addresses. */
- net_ipaddr_hdrcopy(picmp->destipaddr, picmp->srcipaddr);
- net_ipaddr_hdrcopy(picmp->srcipaddr, &dev->d_ipaddr);
+ net_ipv4addr_hdrcopy(picmp->destipaddr, picmp->srcipaddr);
+ net_ipv4addr_hdrcopy(picmp->srcipaddr, &dev->d_ipaddr);
/* Recalculate the ICMP checksum */
diff --git a/nuttx/net/icmp/icmp_ping.c b/nuttx/net/icmp/icmp_ping.c
index efcf64256..ef50fc97c 100644
--- a/nuttx/net/icmp/icmp_ping.c
+++ b/nuttx/net/icmp/icmp_ping.c
@@ -81,15 +81,15 @@ struct icmp_ping_s
{
FAR struct devif_callback_s *png_cb; /* Reference to callback instance */
- sem_t png_sem; /* Use to manage the wait for the response */
- uint32_t png_time; /* Start time for determining timeouts */
- uint32_t png_ticks; /* System clock ticks to wait */
- int png_result; /* 0: success; <0:negated errno on fail */
- net_ipaddr_t png_addr; /* The peer to be ping'ed */
- uint16_t png_id; /* Used to match requests with replies */
- uint16_t png_seqno; /* IN: seqno to send; OUT: seqno recieved */
- uint16_t png_datlen; /* The length of data to send in the ECHO request */
- bool png_sent; /* true... the PING request has been sent */
+ sem_t png_sem; /* Use to manage the wait for the response */
+ uint32_t png_time; /* Start time for determining timeouts */
+ uint32_t png_ticks; /* System clock ticks to wait */
+ int png_result; /* 0: success; <0:negated errno on fail */
+ in_addr_t png_addr; /* The peer to be ping'ed */
+ uint16_t png_id; /* Used to match requests with replies */
+ uint16_t png_seqno; /* IN: seqno to send; OUT: seqno recieved */
+ uint16_t png_datlen; /* The length of data to send in the ECHO request */
+ bool png_sent; /* true... the PING request has been sent */
};
/****************************************************************************
@@ -251,7 +251,7 @@ static uint16_t ping_interrupt(FAR struct net_driver_s *dev, FAR void *conn,
* device.
*/
- if (!net_ipaddr_maskcmp(pstate->png_addr, dev->d_ipaddr, dev->d_netmask))
+ if (!net_ipv4addr_maskcmp(pstate->png_addr, dev->d_ipaddr, dev->d_netmask))
{
/* Destination address was not on the local network served by this
* device. If a timeout occurs, then the most likely reason is
@@ -324,8 +324,8 @@ end_wait:
*
****************************************************************************/
-int icmp_ping(net_ipaddr_t addr, uint16_t id, uint16_t seqno,
- uint16_t datalen, int dsecs)
+int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
+ int dsecs)
{
struct icmp_ping_s state;
net_lock_t save;
diff --git a/nuttx/net/icmp/icmp_send.c b/nuttx/net/icmp/icmp_send.c
index 2ff347ee7..e451e67cb 100644
--- a/nuttx/net/icmp/icmp_send.c
+++ b/nuttx/net/icmp/icmp_send.c
@@ -92,7 +92,7 @@
*
****************************************************************************/
-void icmp_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr)
+void icmp_send(FAR struct net_driver_s *dev, FAR in_addr_t *destaddr)
{
FAR struct icmp_iphdr_s *picmp = ICMPBUF;
@@ -124,8 +124,8 @@ void icmp_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr)
picmp->ttl = IP_TTL;
picmp->proto = IP_PROTO_ICMP;
- net_ipaddr_hdrcopy(picmp->srcipaddr, &dev->d_ipaddr);
- net_ipaddr_hdrcopy(picmp->destipaddr, destaddr);
+ net_ipv4addr_hdrcopy(picmp->srcipaddr, &dev->d_ipaddr);
+ net_ipv4addr_hdrcopy(picmp->destipaddr, destaddr);
/* Calculate IP checksum. */
diff --git a/nuttx/net/icmpv6/icmpv6.h b/nuttx/net/icmpv6/icmpv6.h
index 0e872334b..c5740e8f0 100644
--- a/nuttx/net/icmpv6/icmpv6.h
+++ b/nuttx/net/icmpv6/icmpv6.h
@@ -85,7 +85,7 @@ void icmpv6_poll(FAR struct net_driver_s *dev);
/* Defined in icmpv6_send.c *************************************************/
#ifdef CONFIG_NET_ICMPv6_PING
-void icmpv6_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr);
+void icmpv6_send(FAR struct net_driver_s *dev, FAR net_ipv6addr_t *destaddr);
#endif /* CONFIG_NET_ICMPv6_PING */
#undef EXTERN
diff --git a/nuttx/net/icmpv6/icmpv6_input.c b/nuttx/net/icmpv6/icmpv6_input.c
index 1bc1e4bc3..6b53a13f1 100644
--- a/nuttx/net/icmpv6/icmpv6_input.c
+++ b/nuttx/net/icmpv6/icmpv6_input.c
@@ -122,7 +122,7 @@ void icmpv6_input(FAR struct net_driver_s *dev)
if (picmp->type == ICMPv6_NEIGHBOR_SOLICITATION)
{
- if (net_ipaddr_cmp(picmp->icmpv6data, dev->d_ipaddr))
+ if (net_ipv6addr_cmp(picmp->icmpv6data, dev->d_ipaddr))
{
if (picmp->options[0] == ICMPv6_OPTION_SOURCE_LINK_ADDRESS)
{
diff --git a/nuttx/net/icmpv6/icmpv6_ping.c b/nuttx/net/icmpv6/icmpv6_ping.c
index 46b71d55f..34b71bc7a 100644
--- a/nuttx/net/icmpv6/icmpv6_ping.c
+++ b/nuttx/net/icmpv6/icmpv6_ping.c
@@ -81,15 +81,15 @@ struct icmpv6_ping_s
{
FAR struct devif_callback_s *png_cb; /* Reference to callback instance */
- sem_t png_sem; /* Use to manage the wait for the response */
- uint32_t png_time; /* Start time for determining timeouts */
- uint32_t png_ticks; /* System clock ticks to wait */
- int png_result; /* 0: success; <0:negated errno on fail */
- net_ipaddr_t png_addr; /* The peer to be ping'ed */
- uint16_t png_id; /* Used to match requests with replies */
- uint16_t png_seqno; /* IN: seqno to send; OUT: seqno recieved */
- uint16_t png_datlen; /* The length of data to send in the ECHO request */
- bool png_sent; /* true... the PING request has been sent */
+ sem_t png_sem; /* Use to manage the wait for the response */
+ uint32_t png_time; /* Start time for determining timeouts */
+ uint32_t png_ticks; /* System clock ticks to wait */
+ int png_result; /* 0: success; <0:negated errno on fail */
+ net_ipv6addr_t png_addr; /* The peer to be ping'ed */
+ uint16_t png_id; /* Used to match requests with replies */
+ uint16_t png_seqno; /* IN: seqno to send; OUT: seqno recieved */
+ uint16_t png_datlen; /* The length of data to send in the ECHO request */
+ bool png_sent; /* true... the PING request has been sent */
};
/****************************************************************************
@@ -250,7 +250,7 @@ static uint16_t ping_interrupt(FAR struct net_driver_s *dev, FAR void *conn,
* device.
*/
- if (!net_ipaddr_maskcmp(pstate->png_addr, dev->d_ipaddr, dev->d_netmask))
+ if (!net_ipv6addr_maskcmp(pstate->png_addr, dev->d_ipaddr, dev->d_netmask))
{
/* Destination address was not on the local network served by this
* device. If a timeout occurs, then the most likely reason is
@@ -323,7 +323,7 @@ end_wait:
*
****************************************************************************/
-int icmpv6_ping(net_ipaddr_t addr, uint16_t id, uint16_t seqno,
+int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno,
uint16_t datalen, int dsecs)
{
struct icmpv6_ping_s state;
diff --git a/nuttx/net/icmpv6/icmpv6_send.c b/nuttx/net/icmpv6/icmpv6_send.c
index 3c071ed54..6df8dc26b 100644
--- a/nuttx/net/icmpv6/icmpv6_send.c
+++ b/nuttx/net/icmpv6/icmpv6_send.c
@@ -92,7 +92,7 @@
*
****************************************************************************/
-void icmpv6_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr)
+void icmpv6_send(FAR struct net_driver_s *dev, FAR net_ipv6addr_t *destaddr)
{
FAR struct icmpv6_iphdr_s *picmpv6 = ICMPv6BUF;
@@ -122,8 +122,8 @@ void icmpv6_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr)
picmpv6->nexthdr = IP_PROTO_ICMPv6;
picmpv6->hoplimit = IP_TTL;
- net_ipaddr_copy(picmpv6->srcipaddr, &dev->d_ipaddr);
- net_ipaddr_copy(picmpv6->destipaddr, destaddr);
+ net_ipv6addr_copy(picmpv6->srcipaddr, &dev->d_ipaddr);
+ net_ipv6addr_copy(picmpv6->destipaddr, destaddr);
/* Calculate the ICMPv6 checksum. */
diff --git a/nuttx/net/ipv6/ipv6.h b/nuttx/net/ipv6/ipv6.h
index 7027cc390..9ea1f0d5e 100644
--- a/nuttx/net/ipv6/ipv6.h
+++ b/nuttx/net/ipv6/ipv6.h
@@ -75,9 +75,9 @@ struct net_neighbor_addr_s
****************************************************************************/
void net_neighbor_init(void);
-void net_neighbor_add(net_ipaddr_t ipaddr, struct net_neighbor_addr_s *addr);
-void net_neighbor_update(net_ipaddr_t ipaddr);
-struct net_neighbor_addr_s *net_neighbor_lookup(net_ipaddr_t ipaddr);
+void net_neighbor_add(net_ipv6addr_t ipaddr, struct net_neighbor_addr_s *addr);
+void net_neighbor_update(net_ipv6addr_t ipaddr);
+struct net_neighbor_addr_s *net_neighbor_lookup(net_ipv6addr_t ipaddr);
void net_neighbor_periodic(void);
#endif /* CONFIG_NET_IPv6 */
diff --git a/nuttx/net/ipv6/ipv6_neighbor.c b/nuttx/net/ipv6/ipv6_neighbor.c
index 454a5f0f2..3be02e4c6 100644
--- a/nuttx/net/ipv6/ipv6_neighbor.c
+++ b/nuttx/net/ipv6/ipv6_neighbor.c
@@ -65,7 +65,7 @@
struct neighbor_entry
{
- net_ipaddr_t ipaddr;
+ net_ipv6addr_t ipaddr;
struct net_neighbor_addr_s addr;
uint8_t time;
};
@@ -80,13 +80,13 @@ static struct neighbor_entry entries[ENTRIES];
* Private Functions
****************************************************************************/
-static struct neighbor_entry *find_entry(net_ipaddr_t ipaddr)
+static struct neighbor_entry *find_entry(net_ipv6addr_t ipaddr)
{
int i;
for (i = 0; i < ENTRIES; ++i)
{
- if (net_ipaddr_cmp(entries[i].ipaddr, ipaddr))
+ if (net_ipv6addr_cmp(entries[i].ipaddr, ipaddr))
{
return &entries[i];
}
@@ -122,7 +122,7 @@ void net_neighbor_periodic(void)
}
}
-void net_neighbor_add(net_ipaddr_t ipaddr, struct net_neighbor_addr_s *addr)
+void net_neighbor_add(net_ipv6addr_t ipaddr, struct net_neighbor_addr_s *addr)
{
uint8_t oldest_time;
int oldest;
@@ -145,7 +145,7 @@ void net_neighbor_add(net_ipaddr_t ipaddr, struct net_neighbor_addr_s *addr)
oldest = i;
break;
}
- if (net_ipaddr_cmp(entries[i].ipaddr, addr))
+ if (net_ipv6addr_cmp(entries[i].ipaddr, addr))
{
oldest = i;
break;
@@ -162,11 +162,11 @@ void net_neighbor_add(net_ipaddr_t ipaddr, struct net_neighbor_addr_s *addr)
*/
entries[oldest].time = 0;
- net_ipaddr_copy(entries[oldest].ipaddr, ipaddr);
+ net_ipv6addr_copy(entries[oldest].ipaddr, ipaddr);
memcpy(&entries[oldest].addr, addr, sizeof(struct net_neighbor_addr_s));
}
-void net_neighbor_update(net_ipaddr_t ipaddr)
+void net_neighbor_update(net_ipv6addr_t ipaddr)
{
struct neighbor_entry *e;
@@ -177,7 +177,7 @@ void net_neighbor_update(net_ipaddr_t ipaddr)
}
}
-struct net_neighbor_addr_s *net_neighbor_lookup(net_ipaddr_t ipaddr)
+struct net_neighbor_addr_s *net_neighbor_lookup(net_ipv6addr_t ipaddr)
{
struct neighbor_entry *e;