summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-16 12:30:18 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-16 12:30:18 -0600
commit80ea43c7c968cd7f9617ab8a69892b4214e6664c (patch)
tree0fd0ccd53493c12a7cd79a322e48680763715228
parent9d7bd7674895cf2d6f21501396f6945a14231e7b (diff)
downloadnuttx-80ea43c7c968cd7f9617ab8a69892b4214e6664c.tar.gz
nuttx-80ea43c7c968cd7f9617ab8a69892b4214e6664c.tar.bz2
nuttx-80ea43c7c968cd7f9617ab8a69892b4214e6664c.zip
Networking: Replace all references to net_ipaddr_t with either in_addr_t on net_ipv6addr_t. The goal is to support both IPv4 and IPv6 simultaneously. This requires that the two types be distinct and not conditionally typedef'ed to net_ipaddr_t.
-rw-r--r--apps/include/netutils/smtp.h4
-rw-r--r--apps/netutils/smtp/smtp.c9
-rw-r--r--apps/nshlib/nsh_netcmds.c22
-rw-r--r--nuttx/include/nuttx/net/icmp.h2
-rw-r--r--nuttx/include/nuttx/net/ip.h14
-rw-r--r--nuttx/net/arp/arp_send.c6
-rw-r--r--nuttx/net/devif/devif.h11
-rw-r--r--nuttx/net/devif/devif_initialize.c26
-rw-r--r--nuttx/net/devif/ipv4_input.c5
-rw-r--r--nuttx/net/devif/ipv6_input.c4
-rw-r--r--nuttx/net/icmp/icmp_ping.c4
-rw-r--r--nuttx/net/icmpv6/icmpv6_ping.c4
-rw-r--r--nuttx/net/igmp/igmp.h18
-rw-r--r--nuttx/net/igmp/igmp_group.c6
-rw-r--r--nuttx/net/igmp/igmp_initialize.c14
-rw-r--r--nuttx/net/igmp/igmp_input.c8
-rw-r--r--nuttx/net/igmp/igmp_join.c2
-rw-r--r--nuttx/net/igmp/igmp_leave.c2
-rw-r--r--nuttx/net/igmp/igmp_mcastmac.c6
-rw-r--r--nuttx/net/igmp/igmp_poll.c4
-rw-r--r--nuttx/net/igmp/igmp_send.c2
-rw-r--r--nuttx/net/netdev/netdev.h48
-rw-r--r--nuttx/net/netdev/netdev_findbyaddr.c16
-rw-r--r--nuttx/net/netdev/netdev_ioctl.c260
-rw-r--r--nuttx/net/netdev/netdev_rxnotify.c62
-rw-r--r--nuttx/net/netdev/netdev_txnotify.c63
-rw-r--r--nuttx/net/pkt/pkt_send.c6
-rw-r--r--nuttx/net/route/net_addroute.c5
-rw-r--r--nuttx/net/route/net_delroute.c8
-rw-r--r--nuttx/net/route/net_router.c156
-rw-r--r--nuttx/net/route/netdev_router.c167
-rw-r--r--nuttx/net/route/route.h91
-rw-r--r--nuttx/net/socket/net_close.c6
-rw-r--r--nuttx/net/socket/net_sendfile.c4
-rw-r--r--nuttx/net/socket/recvfrom.c8
-rw-r--r--nuttx/net/socket/sendto.c4
-rw-r--r--nuttx/net/tcp/tcp_conn.c15
-rw-r--r--nuttx/net/tcp/tcp_send_buffered.c4
-rw-r--r--nuttx/net/tcp/tcp_send_unbuffered.c4
-rw-r--r--nuttx/net/udp/udp_conn.c27
-rw-r--r--nuttx/net/utils/net_chksum.c2
41 files changed, 803 insertions, 326 deletions
diff --git a/apps/include/netutils/smtp.h b/apps/include/netutils/smtp.h
index 2ca7f1e8c..684864c44 100644
--- a/apps/include/netutils/smtp.h
+++ b/apps/include/netutils/smtp.h
@@ -2,7 +2,7 @@
* apps/include/netutils/smtp.h
* SMTP header file
*
- * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Heavily leveraged from uIP 1.0 which also has a BSD-like license:
@@ -69,7 +69,7 @@ extern "C"
void *smtp_open(void);
void smtp_configure(FAR void *handle, FAR const char *localhostname,
- FAR const net_ipaddr_t *paddr);
+ FAR const in_addr_t *paddr);
int smtp_send(FAR void *handle, FAR const char *to, FAR const char *cc,
FAR const char *from, FAR const char *subject,
FAR const char *msg, int msglen);
diff --git a/apps/netutils/smtp/smtp.c b/apps/netutils/smtp/smtp.c
index 095a1c495..f33183ff6 100644
--- a/apps/netutils/smtp/smtp.c
+++ b/apps/netutils/smtp/smtp.c
@@ -2,7 +2,7 @@
* apps/netutitls/smtp/smtp.c
* smtp SMTP E-mail sender
*
- * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Heavily leveraged from uIP 1.0 which also has a BSD-like license:
@@ -63,7 +63,7 @@
#include <apps/netutils/smtp.h>
/****************************************************************************
- * Definitions
+ * Pre-processor Definitions
****************************************************************************/
#define SMTP_INPUT_BUFFER_SIZE 512
@@ -89,7 +89,7 @@ struct smtp_state
uint8_t state;
bool connected;
sem_t sem;
- net_ipaddr_t smtpserver;
+ in_addr_t smtpserver;
const char *localhostname;
const char *to;
const char *cc;
@@ -286,7 +286,7 @@ static inline int smtp_send_message(int sockfd, struct smtp_state *psmtp)
*/
void smtp_configure(FAR void *handle, FAR const char *lhostname,
- FAR const net_ipaddr_t *paddr)
+ FAR const in_addr_t *paddr)
{
FAR struct smtp_state *psmtp = (FAR struct smtp_state *)handle;
psmtp->localhostname = lhostname;
@@ -364,6 +364,7 @@ void *smtp_open(void)
memset(psmtp, 0, sizeof(struct smtp_state));
(void)sem_init(&psmtp->sem, 0, 0);
}
+
return (void*)psmtp;
}
diff --git a/apps/nshlib/nsh_netcmds.c b/apps/nshlib/nsh_netcmds.c
index 798879b55..7b902f9b5 100644
--- a/apps/nshlib/nsh_netcmds.c
+++ b/apps/nshlib/nsh_netcmds.c
@@ -455,6 +455,7 @@ int tftpc_parseargs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv,
{
goto errout;
}
+
args->allocated = true;
}
@@ -797,8 +798,9 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
handle = dhcpc_open(&mac, IFHWADDRLEN);
- /* Get an IP address. Note that there is no logic for renewing the IP address in this
- * example. The address should be renewed in ds.lease_time/2 seconds.
+ /* Get an IP address. Note that there is no logic for renewing the IP
+ * address in this example. The address should be renewed in
+ * ds.lease_time/2 seconds.
*/
if (handle)
@@ -843,7 +845,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
FAR const char *fmt = g_fmtarginvalid;
const char *staddr;
- net_ipaddr_t ipaddr;
+ in_addr_t ipaddr;
uint32_t start;
uint32_t next;
uint32_t dsec = 10;
@@ -899,7 +901,9 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
}
}
- /* If a bad argument was encountered, then return without processing the command */
+ /* If a bad argument was encountered, then return without processing the
+ * command
+ */
if (badarg)
{
@@ -931,8 +935,8 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
id = ping_newid();
- /* The maximum wait for a response will be the larger of the inter-ping time and
- * the configured maximum round-trip time.
+ /* The maximum wait for a response will be the larger of the inter-ping
+ * time and the configured maximum round-trip time.
*/
maxwait = MAX(dsec, CONFIG_NSH_MAX_ROUNDTRIP);
@@ -960,7 +964,7 @@ int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
/* Get the elapsed time from the time that the request was
* sent until the response was received. If we got a response
- * to an earlier request, then fudge the elpased time.
+ * to an earlier request, then fudge the elapsed time.
*/
elapsed = TICK2MSEC(clock_systimer() - next);
@@ -1091,7 +1095,9 @@ int cmd_wget(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
}
}
- /* If a bad argument was encountered, then return without processing the command */
+ /* If a bad argument was encountered, then return without processing the
+ * command
+ */
if (badarg)
{
diff --git a/nuttx/include/nuttx/net/icmp.h b/nuttx/include/nuttx/net/icmp.h
index ec912f4b9..f64895afc 100644
--- a/nuttx/include/nuttx/net/icmp.h
+++ b/nuttx/include/nuttx/net/icmp.h
@@ -189,7 +189,7 @@ extern "C"
*
****************************************************************************/
-int icmp_ping(net_ipaddr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
+int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
int dsecs);
#undef EXTERN
diff --git a/nuttx/include/nuttx/net/ip.h b/nuttx/include/nuttx/net/ip.h
index c401e6a0d..ffce6af98 100644
--- a/nuttx/include/nuttx/net/ip.h
+++ b/nuttx/include/nuttx/net/ip.h
@@ -94,12 +94,6 @@
typedef uint16_t net_ipv6addr_t[8];
-#ifdef CONFIG_NET_IPv6
-typedef net_ipv6addr_t net_ipaddr_t;
-#else
-typedef in_addr_t net_ipaddr_t;
-#endif
-
/* Describes and address in either the IPv4 or IPv6 domain */
union ip_addr_u
@@ -192,7 +186,7 @@ struct net_ipv6hdr_s
*
* This function constructs an IPv4 address in network byte order.
*
- * addr A pointer to a net_ipaddr_t variable that will be
+ * addr A pointer to a in_addr_t variable that will be
* filled in with the IPv4 address.
* addr0 The first octet of the IPv4 address.
* addr1 The second octet of the IPv4 address.
@@ -255,7 +249,7 @@ struct net_ipv6hdr_s
*
* Example:
*
- * net_ipaddr_t ipaddr1, ipaddr2;
+ * in_addr_t ipaddr1, ipaddr2;
*
* net_ipaddr(&ipaddr1, 192,16,1,2);
* net_ipaddr_copy(&ipaddr2, &ipaddr1);
@@ -289,7 +283,7 @@ struct net_ipv6hdr_s
*
* Example:
*
- * net_ipaddr_t ipaddr1, ipaddr2;
+ * in_addr_t ipaddr1, ipaddr2;
*
* net_ipaddr(&ipaddr1, 192,16,1,2);
* if (net_ipaddr_cmp(ipaddr2, ipaddr1))
@@ -362,7 +356,7 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
*
* Example:
*
- * net_ipaddr_t ipaddr1, ipaddr2, netmask;
+ * in_addr_t ipaddr1, ipaddr2, netmask;
*
* net_ipaddr(&ipaddr1, 192,16,1,2);
* net_ipaddr(&netmask, 255,255,255,0);
diff --git a/nuttx/net/arp/arp_send.c b/nuttx/net/arp/arp_send.c
index e0d29c9df..1ff716278 100644
--- a/nuttx/net/arp/arp_send.c
+++ b/nuttx/net/arp/arp_send.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/arp/arp_send.c
*
- * Copyright (C) 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -223,7 +223,7 @@ int arp_send(in_addr_t ipaddr)
/* Get the device that can route this request */
#ifdef CONFIG_NET_MULTILINK
- dev = netdev_findby_ipv4addr(g_allzeroaddr, ipaddr);
+ dev = netdev_findby_ipv4addr(g_ipv4_allzeroaddr, ipaddr);
#else
dev = netdev_findby_ipv4addr(ipaddr);
#endif
@@ -337,7 +337,7 @@ int arp_send(in_addr_t ipaddr)
state.snd_cb->event = arp_send_interrupt;
/* Notify the device driver that new TX data is available.
- * NOTES: This is in essence what netdev_txnotify() does, which
+ * NOTES: This is in essence what netdev_ipv4_txnotify() does, which
* 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/devif/devif.h b/nuttx/net/devif/devif.h
index ce303562d..58b43887e 100644
--- a/nuttx/net/devif/devif.h
+++ b/nuttx/net/devif/devif.h
@@ -165,8 +165,15 @@ struct devif_callback_s
* Public Data
****************************************************************************/
-extern const net_ipaddr_t g_alloneaddr;
-extern const net_ipaddr_t g_allzeroaddr;
+#ifdef CONFIG_NET_IPv4
+extern const in_addr_t g_ipv4_alloneaddr;
+extern const in_addr_t g_ipv4_allzeroaddr;
+#endif
+
+#ifdef CONFIG_NET_IPv6
+extern const net_ipv6addr_t g_ipv6_alloneaddr;
+extern const net_ipv6addr_t g_ipv6_allzeroaddr;
+#endif
/* Increasing number used for the IP ID field. */
diff --git a/nuttx/net/devif/devif_initialize.c b/nuttx/net/devif/devif_initialize.c
index 5da9aa27f..30ee976df 100644
--- a/nuttx/net/devif/devif_initialize.c
+++ b/nuttx/net/devif/devif_initialize.c
@@ -69,25 +69,23 @@ struct net_stats_s g_netstats;
uint16_t g_ipid;
-const net_ipaddr_t g_alloneaddr =
-#ifdef CONFIG_NET_IPv6
- {0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
-#else
- 0xffffffff;
-#endif
-
-const net_ipaddr_t g_allzeroaddr =
-#ifdef CONFIG_NET_IPv6
- {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000};
-#else
- 0x00000000;
-#endif
+#ifdef CONFIG_NET_IPv4
+const in_addr_t g_ipv4_alloneaddr = 0xffffffff;
+const in_addr_t g_ipv4_allzeroaddr = 0x00000000;
/* Reassembly timer (units: deci-seconds) */
-#if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6)
+#ifdef CONFIG_NET_TCP_REASSEMBLY
uint8_t g_reassembly_timer;
#endif
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+const net_ipv6addr_t g_ipv6_alloneaddr =
+ {0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
+const net_ipv6addr_t g_ipv6_allzeroaddr =
+ {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000};
+#endif /* CONFIG_NET_IPv4 */
/****************************************************************************
* Private Variables
diff --git a/nuttx/net/devif/ipv4_input.c b/nuttx/net/devif/ipv4_input.c
index f10cfc68a..589e685ba 100644
--- a/nuttx/net/devif/ipv4_input.c
+++ b/nuttx/net/devif/ipv4_input.c
@@ -381,7 +381,8 @@ int ipv4_input(FAR struct net_driver_s *dev)
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
if (pbuf->proto == IP_PROTO_UDP &&
- net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr), g_alloneaddr))
+ net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr),
+ g_ipv4_alloneaddr))
{
return udp_ipv4_input(dev);
}
@@ -394,7 +395,7 @@ int ipv4_input(FAR struct net_driver_s *dev)
else
#endif
#ifdef CONFIG_NET_ICMP
- if (net_ipv4addr_cmp(dev->d_ipaddr, g_allzeroaddr))
+ if (net_ipv4addr_cmp(dev->d_ipaddr, g_ipv4_allzeroaddr))
{
/* If we are configured to use ping IP address configuration and
* hasn't been assigned an IP address yet, we accept all ICMP
diff --git a/nuttx/net/devif/ipv6_input.c b/nuttx/net/devif/ipv6_input.c
index 43a14a946..c9b3741b7 100644
--- a/nuttx/net/devif/ipv6_input.c
+++ b/nuttx/net/devif/ipv6_input.c
@@ -196,7 +196,7 @@ int ipv6_input(FAR struct net_driver_s *dev)
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
if (pbuf->proto == IP_PROTO_UDP &&
- net_ipv6addr_cmp(pbuf->destipaddr, g_alloneaddr))
+ net_ipv6addr_cmp(pbuf->destipaddr, g_ipv6_alloneaddr))
{
return udp_ipv6_input(dev);
}
@@ -209,7 +209,7 @@ int ipv6_input(FAR struct net_driver_s *dev)
else
#endif
#ifdef CONFIG_NET_ICMPv6
- if (net_ipv6addr_cmp(dev->d_ipv6addr, g_allzeroaddr))
+ if (net_ipv6addr_cmp(dev->d_ipv6addr, g_ipv6_allzeroaddr))
{
/* If we are configured to use ping IP address configuration and
* hasn't been assigned an IP address yet, we accept all ICMP
diff --git a/nuttx/net/icmp/icmp_ping.c b/nuttx/net/icmp/icmp_ping.c
index ef50fc97c..f7c84a072 100644
--- a/nuttx/net/icmp/icmp_ping.c
+++ b/nuttx/net/icmp/icmp_ping.c
@@ -369,9 +369,9 @@ int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
/* Notify the device driver of the availability of TX data */
#ifdef CONFIG_NET_MULTILINK
- netdev_txnotify(g_allzeroaddr, state.png_addr);
+ netdev_ipv4_txnotify(g_ipv4_allzeroaddr, state.png_addr);
#else
- netdev_txnotify(state.png_addr);
+ netdev_ipv4_txnotify(state.png_addr);
#endif
/* Wait for either the full round trip transfer to complete or
diff --git a/nuttx/net/icmpv6/icmpv6_ping.c b/nuttx/net/icmpv6/icmpv6_ping.c
index 34b71bc7a..9de346703 100644
--- a/nuttx/net/icmpv6/icmpv6_ping.c
+++ b/nuttx/net/icmpv6/icmpv6_ping.c
@@ -368,9 +368,9 @@ int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno,
/* Notify the device driver of the availability of TX data */
#ifdef CONFIG_NET_MULTILINK
- netdev_txnotify(g_allzeroaddr, state.png_addr);
+ netdev_ipv6_txnotify(g_ipv6_allzeroaddr, state.png_addr);
#else
- netdev_txnotify(state.png_addr);
+ netdev_ipv6_txnotify(state.png_addr);
#endif
/* Wait for either the full round trip transfer to complete or
diff --git a/nuttx/net/igmp/igmp.h b/nuttx/net/igmp/igmp.h
index 795478413..ae785e5af 100644
--- a/nuttx/net/igmp/igmp.h
+++ b/nuttx/net/igmp/igmp.h
@@ -101,7 +101,7 @@ typedef FAR struct wdog_s *WDOG_ID;
struct igmp_group_s
{
struct igmp_group_s *next; /* Implements a singly-linked list */
- net_ipaddr_t grpaddr; /* Group IP address */
+ in_addr_t grpaddr; /* Group IPv4 address */
WDOG_ID wdog; /* WDOG used to detect timeouts */
sem_t sem; /* Used to wait for message transmission */
volatile uint8_t flags; /* See IGMP_ flags definitions */
@@ -120,8 +120,8 @@ extern "C"
# define EXTERN extern
#endif
-EXTERN net_ipaddr_t g_allsystems;
-EXTERN net_ipaddr_t g_allrouters;
+EXTERN in_addr_t g_ipv4_allsystems;
+EXTERN in_addr_t g_ipv4_allrouters;
/****************************************************************************
* Public Function Prototypes
@@ -188,7 +188,7 @@ void igmp_grpinit(void);
****************************************************************************/
FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
- FAR const net_ipaddr_t *addr);
+ FAR const in_addr_t *addr);
/****************************************************************************
* Name: igmp_grpfind
@@ -202,7 +202,7 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
****************************************************************************/
FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
- FAR const net_ipaddr_t *addr);
+ FAR const in_addr_t *addr);
/****************************************************************************
* Name: igmp_grpallocfind
@@ -217,7 +217,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
****************************************************************************/
FAR struct igmp_group_s *igmp_grpallocfind(FAR struct net_driver_s *dev,
- FAR const net_ipaddr_t *addr);
+ FAR const in_addr_t *addr);
/****************************************************************************
* Name: igmp_grpfree
@@ -304,7 +304,7 @@ void igmp_poll(FAR struct net_driver_s *dev);
****************************************************************************/
void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
- FAR net_ipaddr_t *dest);
+ FAR in_addr_t *dest);
/* Defined in igmp_join.c ***************************************************/
/****************************************************************************
@@ -405,7 +405,7 @@ bool igmp_cmptimer(FAR struct igmp_group_s *group, int maxticks);
*
****************************************************************************/
-void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip);
+void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR in_addr_t *ip);
/****************************************************************************
* Name: igmp_removemcastmac
@@ -415,7 +415,7 @@ void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip);
*
****************************************************************************/
-void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip);
+void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR in_addr_t *ip);
#undef EXTERN
#ifdef __cplusplus
diff --git a/nuttx/net/igmp/igmp_group.c b/nuttx/net/igmp/igmp_group.c
index 89034c68d..613c0fddf 100644
--- a/nuttx/net/igmp/igmp_group.c
+++ b/nuttx/net/igmp/igmp_group.c
@@ -221,7 +221,7 @@ void igmp_grpinit(void)
****************************************************************************/
FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
- FAR const net_ipaddr_t *addr)
+ FAR const in_addr_t *addr)
{
FAR struct igmp_group_s *group;
net_lock_t flags;
@@ -284,7 +284,7 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
****************************************************************************/
FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
- FAR const net_ipaddr_t *addr)
+ FAR const in_addr_t *addr)
{
FAR struct igmp_group_s *group;
net_lock_t flags;
@@ -325,7 +325,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
****************************************************************************/
FAR struct igmp_group_s *igmp_grpallocfind(FAR struct net_driver_s *dev,
- FAR const net_ipaddr_t *addr)
+ FAR const in_addr_t *addr)
{
FAR struct igmp_group_s *group = igmp_grpfind(dev, addr);
diff --git a/nuttx/net/igmp/igmp_initialize.c b/nuttx/net/igmp/igmp_initialize.c
index 1d51f4522..1a92cb3ec 100644
--- a/nuttx/net/igmp/igmp_initialize.c
+++ b/nuttx/net/igmp/igmp_initialize.c
@@ -67,8 +67,8 @@
* Public Data
****************************************************************************/
-net_ipaddr_t g_allsystems;
-net_ipaddr_t g_allrouters;
+in_addr_t g_ipv4_allsystems;
+in_addr_t g_ipv4_allrouters;
/****************************************************************************
* Public Functions
@@ -86,8 +86,8 @@ void igmp_initialize(void)
{
nvdbg("IGMP initializing\n");
- net_ipaddr(g_allrouters, 224, 0, 0, 2);
- net_ipaddr(g_allsystems, 224, 0, 0, 1);
+ net_ipaddr(g_ipv4_allrouters, 224, 0, 0, 2);
+ net_ipaddr(g_ipv4_allsystems, 224, 0, 0, 1);
/* Initialize the group allocation logic */
@@ -110,12 +110,12 @@ void igmp_devinit(struct net_driver_s *dev)
/* Add the all systems address to the group */
- (void)igmp_grpalloc(dev, &g_allsystems);
+ (void)igmp_grpalloc(dev, &g_ipv4_allsystems);
/* Allow the IGMP messages at the MAC level */
- igmp_addmcastmac(dev, &g_allrouters);
- igmp_addmcastmac(dev, &g_allsystems);
+ igmp_addmcastmac(dev, &g_ipv4_allrouters);
+ igmp_addmcastmac(dev, &g_ipv4_allsystems);
}
#endif /* CONFIG_NET_IGMP */
diff --git a/nuttx/net/igmp/igmp_input.c b/nuttx/net/igmp/igmp_input.c
index 14bd531ef..5024c472b 100644
--- a/nuttx/net/igmp/igmp_input.c
+++ b/nuttx/net/igmp/igmp_input.c
@@ -117,8 +117,8 @@
void igmp_input(struct net_driver_s *dev)
{
FAR struct igmp_group_s *group;
- net_ipaddr_t destipaddr;
- net_ipaddr_t grpaddr;
+ in_addr_t destipaddr;
+ in_addr_t grpaddr;
unsigned int ticks;
nllvdbg("IGMP message: %04x%04x\n", IGMPBUF->destipaddr[1], IGMPBUF->destipaddr[0]);
@@ -165,7 +165,7 @@ void igmp_input(struct net_driver_s *dev)
/* Check if the query was sent to all systems */
- if (net_ipaddr_cmp(destipaddr, g_allsystems))
+ if (net_ipaddr_cmp(destipaddr, g_ipv4_allsystems))
{
/* Yes... Now check the if this this is a general or a group
* specific query.
@@ -206,7 +206,7 @@ void igmp_input(struct net_driver_s *dev)
{
/* Skip over the all systems group entry */
- if (!net_ipaddr_cmp(member->grpaddr, g_allsystems))
+ if (!net_ipaddr_cmp(member->grpaddr, g_ipv4_allsystems))
{
ticks = net_dsec2tick((int)IGMPBUF->maxresp);
if (IS_IDLEMEMBER(member->flags) ||
diff --git a/nuttx/net/igmp/igmp_join.c b/nuttx/net/igmp/igmp_join.c
index 5a97e2df6..2eb454d1d 100644
--- a/nuttx/net/igmp/igmp_join.c
+++ b/nuttx/net/igmp/igmp_join.c
@@ -152,7 +152,7 @@ int igmp_joingroup(struct net_driver_s *dev, FAR const struct in_addr *grpaddr)
/* Add the group (MAC) address to the ether drivers MAC filter list */
- igmp_addmcastmac(dev, (FAR net_ipaddr_t *)&grpaddr->s_addr);
+ igmp_addmcastmac(dev, (FAR in_addr_t *)&grpaddr->s_addr);
return OK;
}
diff --git a/nuttx/net/igmp/igmp_leave.c b/nuttx/net/igmp/igmp_leave.c
index 521a437e4..20a36ef00 100644
--- a/nuttx/net/igmp/igmp_leave.c
+++ b/nuttx/net/igmp/igmp_leave.c
@@ -174,7 +174,7 @@ int igmp_leavegroup(struct net_driver_s *dev, FAR const struct in_addr *grpaddr)
/* And remove the group address from the ethernet drivers MAC filter set */
- igmp_removemcastmac(dev, (FAR net_ipaddr_t *)&grpaddr->s_addr);
+ igmp_removemcastmac(dev, (FAR in_addr_t *)&grpaddr->s_addr);
return OK;
}
diff --git a/nuttx/net/igmp/igmp_mcastmac.c b/nuttx/net/igmp/igmp_mcastmac.c
index 62df7e72c..ceee9101b 100644
--- a/nuttx/net/igmp/igmp_mcastmac.c
+++ b/nuttx/net/igmp/igmp_mcastmac.c
@@ -72,7 +72,7 @@
*
****************************************************************************/
-static void igmp_mcastmac(net_ipaddr_t *ip, FAR uint8_t *mac)
+static void igmp_mcastmac(in_addr_t *ip, FAR uint8_t *mac)
{
/* This mapping is from the IETF IN RFC 1700 */
@@ -99,7 +99,7 @@ static void igmp_mcastmac(net_ipaddr_t *ip, FAR uint8_t *mac)
*
****************************************************************************/
-void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip)
+void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR in_addr_t *ip)
{
uint8_t mcastmac[6];
@@ -119,7 +119,7 @@ void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip)
*
****************************************************************************/
-void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip)
+void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR in_addr_t *ip)
{
uint8_t mcastmac[6];
diff --git a/nuttx/net/igmp/igmp_poll.c b/nuttx/net/igmp/igmp_poll.c
index cb20a81c0..7cc1cfb9c 100644
--- a/nuttx/net/igmp/igmp_poll.c
+++ b/nuttx/net/igmp/igmp_poll.c
@@ -82,7 +82,7 @@
static inline void igmp_sched_send(FAR struct net_driver_s *dev,
FAR struct igmp_group_s *group)
{
- net_ipaddr_t *dest;
+ in_addr_t *dest;
/* Check what kind of message we need to send. There are only two
* possibilities:
@@ -99,7 +99,7 @@ static inline void igmp_sched_send(FAR struct net_driver_s *dev,
else
{
DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
- dest = &g_allrouters;
+ dest = &g_ipv4_allrouters;
nllvdbg("Send IGMP_LEAVE_GROUP, dest=%08x flags=%02x\n",
*dest, group->flags);
IGMP_STATINCR(g_netstats.igmp.leave_sched);
diff --git a/nuttx/net/igmp/igmp_send.c b/nuttx/net/igmp/igmp_send.c
index 87c70b53c..c19c690c2 100644
--- a/nuttx/net/igmp/igmp_send.c
+++ b/nuttx/net/igmp/igmp_send.c
@@ -122,7 +122,7 @@ static uint16_t igmp_chksum(FAR uint8_t *buffer, int buflen)
****************************************************************************/
void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
- FAR net_ipaddr_t *destipaddr)
+ FAR in_addr_t *destipaddr)
{
nllvdbg("msgid: %02x destipaddr: %08x\n", group->msgid, (int)*destipaddr);
diff --git a/nuttx/net/netdev/netdev.h b/nuttx/net/netdev/netdev.h
index b25cda598..28dbf83f1 100644
--- a/nuttx/net/netdev/netdev.h
+++ b/nuttx/net/netdev/netdev.h
@@ -122,27 +122,61 @@ FAR struct net_driver_s *netdev_default(void);
/* netdev_txnotify.c *********************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
+#ifdef CONFIG_NET_IPv4
# ifdef CONFIG_NET_MULTILINK
-void netdev_txnotify(const net_ipaddr_t lipaddr, const net_ipaddr_t ripaddr);
+void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr);
# else
-void netdev_txnotify(const net_ipaddr_t ripaddr);
+void netdev_ipv4_txnotify(in_addr_t ripaddr);
# endif
-#endif
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+# ifdef CONFIG_NET_MULTILINK
+void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
+ FAR const net_ipv6addr_t ripaddr);
+# else
+void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr);
+# endif
+#endif /* CONFIG_NET_IPv6 */
+#endif /* CONFIG_NSOCKET_DESCRIPTORS > 0 */
/* netdev_rxnotify.c *********************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL)
+
+#ifdef CONFIG_NET_IPv4
# ifdef CONFIG_NET_MULTILINK
-void netdev_rxnotify(const net_ipaddr_t lipaddr, const net_ipaddr_t ripaddr);
+void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr);
# else
-void netdev_rxnotify(const net_ipaddr_t ripaddr);
+void netdev_ipv4_rxnotify(in_addr_t ripaddr);
# endif
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+# ifdef CONFIG_NET_MULTILINK
+void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
+ FAR const net_ipv6addr_t ripaddr);
+# else
+void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr);
+# endif
+#endif /* CONFIG_NET_IPv6 */
+
#else
+#ifdef CONFIG_NET_IPv4
+# ifdef CONFIG_NET_MULTILINK
+# define netdev_ipv4_rxnotify(lipaddr,ripaddr)
+# else
+# define netdev_ipv4_rxnotify(ripaddr)
+# endif
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
# ifdef CONFIG_NET_MULTILINK
-# define netdev_rxnotify(lipaddr,ripaddr)
+# define netdev_ipv6_rxnotify(lipaddr,ripaddr)
# else
-# define netdev_rxnotify(ripaddr)
+# define netdev_ipv6_rxnotify(ripaddr)
# endif
+#endif /* CONFIG_NET_IPv6 */
#endif
/* netdev_count.c ************************************************************/
diff --git a/nuttx/net/netdev/netdev_findbyaddr.c b/nuttx/net/netdev/netdev_findbyaddr.c
index 8dd48d380..f9a61d724 100644
--- a/nuttx/net/netdev/netdev_findbyaddr.c
+++ b/nuttx/net/netdev/netdev_findbyaddr.c
@@ -211,18 +211,18 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
{
struct net_driver_s *dev;
#ifdef CONFIG_NET_ROUTE
- net_ipaddr_t router;
+ in_addr_t router;
int ret;
#endif
/* First, check if this is the broadcast IP address */
- if (net_ipv4addr_cmp(ripaddr, g_alloneaddr))
+ if (net_ipv4addr_cmp(ripaddr, g_ipv4_alloneaddr))
{
#ifdef CONFIG_NET_MULTILINK
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
- if (net_ipv4addr_cmp(lipaddr, g_allzeroaddr))
+ if (net_ipv4addr_cmp(lipaddr, g_ipv4_allzeroaddr))
{
/* Yes.. In this case, I think we are supposed to send the
* broadcast packet out ALL local networks. I am not sure
@@ -262,7 +262,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
* address of a router that can forward packets to the external network.
*/
- ret = net_router(ripaddr, &router);
+ ret = net_ipv4_router(ripaddr, &router);
if (ret >= 0)
{
/* Success... try to find the network device associated with the local
@@ -329,18 +329,18 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
{
struct net_driver_s *dev;
#ifdef CONFIG_NET_ROUTE
- net_ipaddr_t router;
+ net_ipv6addr_t router;
int ret;
#endif
/* First, check if this is the broadcast IP address */
- if (net_ipv6addr_cmp(ripaddr, g_alloneaddr))
+ if (net_ipv6addr_cmp(ripaddr, g_ipv6_alloneaddr))
{
#ifdef CONFIG_NET_MULTILINK
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
- if (net_ipv6addr_cmp(lipaddr, g_allzeroaddr))
+ if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
{
/* Yes.. In this case, I think we are supposed to send the
* broadcast packet out ALL local networks. I am not sure
@@ -380,7 +380,7 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
* address of a router that can forward packets to the external network.
*/
- ret = net_router(ripaddr, router);
+ ret = net_ipv6_router(ripaddr, router);
if (ret >= 0)
{
/* Success... try to find the network device associated with the local
diff --git a/nuttx/net/netdev/netdev_ioctl.c b/nuttx/net/netdev/netdev_ioctl.c
index 93bae2f18..0f5ffa702 100644
--- a/nuttx/net/netdev/netdev_ioctl.c
+++ b/nuttx/net/netdev/netdev_ioctl.c
@@ -83,6 +83,144 @@
****************************************************************************/
/****************************************************************************
+ * Name: ioctl_addipv4route
+ *
+ * Description:
+ * Add an IPv4 route to the routing table.
+ *
+ * Input Parameters:
+ * rentry - Describes the route to be added
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv4)
+static int ioctl_addipv4route(FAR struct rtentry *rtentry)
+{
+ FAR struct sockaddr_in *addr;
+ in_addr_t target;
+ in_addr_t netmask;
+ in_addr_t router;
+
+ addr = (FAR struct sockaddr_in *)rtentry->rt_target;
+ target = (in_addr_t)addr->sin_addr.s_addr;
+
+ addr = (FAR struct sockaddr_in *)rtentry->rt_netmask;
+ netmask = (in_addr_t)addr->sin_addr.s_addr;
+
+ /* The router is an optional argument */
+
+ if (rtentry->rt_router)
+ {
+ addr = (FAR struct sockaddr_in *)rtentry->rt_router;
+ router = (in_addr_t)addr->sin_addr.s_addr;
+ }
+ else
+ {
+ router = 0;
+ }
+
+ return net_addroute(target, netmask, router);
+}
+#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv4 */
+
+/****************************************************************************
+ * Name: ioctl_addipv6route
+ *
+ * Description:
+ * Add an IPv6 route to the routing table.
+ *
+ * Input Parameters:
+ * rentry - Describes the route to be added
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv6)
+static int ioctl_addipv6route(FAR struct rtentry *rtentry)
+{
+ FAR struct sockaddr_in6 *addr;
+ net_ipv6addr_t target;
+ net_ipv6addr_t netmask;
+ net_ipv6addr_t router;
+
+ addr = (FAR struct sockaddr_in6 *)rtentry->rt_target;
+ target = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
+
+ addr = (FAR struct sockaddr_in6 *)rtentry->rt_netmask;
+ netmask = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
+
+ /* The router is an optional argument */
+
+ if (rtentry->rt_router)
+ {
+ addr = (FAR struct sockaddr_in6 *)rtentry->rt_router;
+ router = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
+ }
+ else
+ {
+ router = NULL;
+ }
+
+ return net_addroute(target, netmask, router);
+}
+#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv6 */
+
+/****************************************************************************
+ * Name: ioctl_delipv4route
+ *
+ * Description:
+ * Delete an IPv4 route to the routing table.
+ *
+ * Input Parameters:
+ * rentry - Describes the route to be deleted
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv4)
+static int ioctl_delipv4route(FAR struct rtentry *rtentry)
+{
+ FAR struct sockaddr_in *addr;
+ in_addr_t target;
+ in_addr_t netmask;
+
+ addr = (FAR struct sockaddr_in *)rtentry->rt_target;
+ target = (in_addr_t)addr->sin_addr.s_addr;
+
+ addr = (FAR struct sockaddr_in *)rtentry->rt_netmask;
+ netmask = (in_addr_t)addr->sin_addr.s_addr;
+
+ return net_delroute(target, netmask);
+}
+#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv4 */
+
+/****************************************************************************
+ * Name: ioctl_delipv6route
+ *
+ * Description:
+ * Delete an IPv6 route to the routing table.
+ *
+ * Input Parameters:
+ * rentry - Describes the route to be deleted
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv6)
+static int ioctl_delipv6route(FAR struct rtentry *rtentry)
+{
+ FAR struct sockaddr_in6 *addr;
+ net_ipv6addr_t target;
+ net_ipv6addr_t netmask;
+
+ addr = (FAR struct sockaddr_in6 *)rtentry->rt_target;
+ target = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
+
+ addr = (FAR struct sockaddr_in6 *)rtentry->rt_netmask;
+ netmask = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
+
+ return net_delroute(target, netmask);
+}
+#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv6 */
+
+/****************************************************************************
* Name: ioctl_getipv4addr
*
* Description:
@@ -90,7 +228,7 @@
*
* Input Parameters:
* outaddr - Pointer to the user-provided memory to receive the address.
- * inaddr - The source IP adress in the device structure.
+ * inaddr - The source IP address in the device structure.
*
****************************************************************************/
@@ -741,99 +879,67 @@ static int netdev_rtioctl(FAR struct socket *psock, int cmd,
{
case SIOCADDRT: /* Add an entry to the routing table */
{
- if (rtentry)
- {
- net_ipaddr_t target;
- net_ipaddr_t netmask;
- net_ipaddr_t router;
-#ifdef CONFIG_NET_IPv6
- FAR struct sockaddr_in6 *addr;
-#else
- FAR struct sockaddr_in *addr;
+#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
+ FAR struct sockaddr_in *addr;
#endif
- /* The target address and the netmask are required value */
-
- if (!rtentry->rt_target || !rtentry->rt_netmask)
- {
- return -EINVAL;
- }
-
-#ifdef CONFIG_NET_IPv6
- addr = (FAR struct sockaddr_in6 *)rtentry->rt_target;
- target = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
+ /* The target address and the netmask are required values */
- addr = (FAR struct sockaddr_in6 *)rtentry->rt_netmask;
- netmask = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
+ if (!retentry || !rtentry->rt_target || !rtentry->rt_netmask)
+ {
+ return -EINVAL;
+ }
- /* The router is an optional argument */
+#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
+ addr = (FAR struct sockaddr_in *)rtentry->rt_target;
+ if (addr->sin_family == AF_INET)
+ {
+ ret = ioctl_addipv4route(rtentry);
+ }
+ else
+ {
+ ret = ioctl_addipv6route(rtentry);
+ }
- if (rtentry->rt_router)
- {
- addr = (FAR struct sockaddr_in6 *)rtentry->rt_router;
- router = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
- }
- else
- {
- router = NULL;
- }
+#elif defined(CONFIG_NET_IPv4)
+ ret = ioctl_addipv4route(rtentry);
+#elif defined(CONFIG_NET_IPv6)
+ ret = ioctl_addipv6route(rtentry);
#else
- addr = (FAR struct sockaddr_in *)rtentry->rt_target;
- target = (net_ipaddr_t)addr->sin_addr.s_addr;
-
- addr = (FAR struct sockaddr_in *)rtentry->rt_netmask;
- netmask = (net_ipaddr_t)addr->sin_addr.s_addr;
-
- /* The router is an optional argument */
-
- if (rtentry->rt_router)
- {
- addr = (FAR struct sockaddr_in *)rtentry->rt_router;
- router = (net_ipaddr_t)addr->sin_addr.s_addr;
- }
- else
- {
- router = 0;
- }
+ ret = -EAFNOSUPPORT;
#endif
- ret = net_addroute(target, netmask, router);
- }
}
break;
case SIOCDELRT: /* Delete an entry from the routing table */
{
- if (rtentry)
- {
- net_ipaddr_t target;
- net_ipaddr_t netmask;
-#ifdef CONFIG_NET_IPv6
- FAR struct sockaddr_in6 *addr;
-#else
- FAR struct sockaddr_in *addr;
+#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
+ FAR struct sockaddr_in *addr;
#endif
+ /* The target address and the netmask are required values */
- /* The target address and the netmask are required value */
-
- if (!rtentry->rt_target || !rtentry->rt_netmask)
- {
- return -EINVAL;
- }
+ if (!retentry || !rtentry->rt_target || !rtentry->rt_netmask)
+ {
+ return -EINVAL;
+ }
-#ifdef CONFIG_NET_IPv6
- addr = (FAR struct sockaddr_in6 *)rtentry->rt_target;
- target = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
+#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
+ addr = (FAR struct sockaddr_in *)rtentry->rt_target;
+ if (addr->sin_family == AF_INET)
+ {
+ ret = ioctl_delipv4route(rtentry);
+ }
+ else
+ {
+ ret = ioctl_delipv6route(rtentry);
+ }
- addr = (FAR struct sockaddr_in6 *)rtentry->rt_netmask;
- netmask = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
+#elif defined(CONFIG_NET_IPv4)
+ ret = ioctl_delipv4route(rtentry);
+#elif defined(CONFIG_NET_IPv6)
+ ret = ioctl_delipv6route(rtentry);
#else
- addr = (FAR struct sockaddr_in *)rtentry->rt_target;
- target = (net_ipaddr_t)addr->sin_addr.s_addr;
-
- addr = (FAR struct sockaddr_in *)rtentry->rt_netmask;
- netmask = (net_ipaddr_t)addr->sin_addr.s_addr;
+ ret = -EAFNOSUPPORT;
#endif
- ret = net_delroute(target, netmask);
- }
}
break;
diff --git a/nuttx/net/netdev/netdev_rxnotify.c b/nuttx/net/netdev/netdev_rxnotify.c
index a859d8178..9289bf59c 100644
--- a/nuttx/net/netdev/netdev_rxnotify.c
+++ b/nuttx/net/netdev/netdev_rxnotify.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/netdev/netdev_rxnotify.c
*
- * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -75,13 +75,15 @@
****************************************************************************/
/****************************************************************************
- * Function: netdev_rxnotify
+ * Function: netdev_ipv4_rxnotify
*
* Description:
- * Notify the device driver that the application waits for RX data.
+ * Notify the device driver that forwards the IPv4 address that the
+ * application waits for RX data.
*
* Parameters:
- * ripaddr - The remote address to send the data
+ * lipaddr - The local board IPv6 address of the socket
+ * ripaddr - The remote IPv4 address to send the data
*
* Returned Value:
* None
@@ -91,10 +93,11 @@
*
****************************************************************************/
+#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_MULTILINK
-void netdev_rxnotify(const net_ipaddr_t lipaddr, const net_ipaddr_t ripaddr)
+void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr)
#else
-void netdev_rxnotify(const net_ipaddr_t ripaddr)
+void netdev_ipv4_rxnotify(in_addr_t ripaddr)
#endif
{
FAR struct net_driver_s *dev;
@@ -114,5 +117,52 @@ void netdev_rxnotify(const net_ipaddr_t ripaddr)
(void)dev->d_rxavail(dev);
}
}
+#endif /* CONFIG_NET_IPv4 */
+
+/****************************************************************************
+ * Function: netdev_ipv6_rxnotify
+ *
+ * Description:
+ * Notify the device driver that forwards the IPv6 address that the
+ * application waits for RX data.
+ *
+ * Parameters:
+ * lipaddr - The local board IPv6 address of the socket
+ * ripaddr - The remote IPv6 address to send the data
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Called from normal user mode
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_MULTILINK
+void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
+ FAR const net_ipv6addr_t ripaddr)
+#else
+void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr)
+#endif
+{
+ FAR struct net_driver_s *dev;
+
+ /* Find the device driver that serves the subnet of the remote address */
+
+#ifdef CONFIG_NET_MULTILINK
+ dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
+#else
+ dev = netdev_findby_ipv6addr(ripaddr);
+#endif
+
+ if (dev && dev->d_rxavail)
+ {
+ /* Notify the device driver that new RX data is available. */
+
+ (void)dev->d_rxavail(dev);
+ }
+}
+#endif /* CONFIG_NET_IPv6 */
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS && CONFIG_NET_RXAVAIL */
diff --git a/nuttx/net/netdev/netdev_txnotify.c b/nuttx/net/netdev/netdev_txnotify.c
index 1e9a80c47..1c95cade2 100644
--- a/nuttx/net/netdev/netdev_txnotify.c
+++ b/nuttx/net/netdev/netdev_txnotify.c
@@ -75,12 +75,14 @@
****************************************************************************/
/****************************************************************************
- * Function: netdev_txnotify
+ * Function: netdev_ipv4_txnotify
*
* Description:
- * Notify the device driver that new TX data is available.
+ * Notify the device driver that forwards the IPv4 address that new TX
+ * data is available.
*
* Parameters:
+ * lipaddr - The local address bound to the socket
* ripaddr - The remote address to send the data
*
* Returned Value:
@@ -91,10 +93,58 @@
*
****************************************************************************/
+#ifdef CONFIG_NET_IPv4
+# ifdef CONFIG_NET_MULTILINK
+void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
+# else
+void netdev_ipv4_txnotify(in_addr_t ripaddr)
+# endif
+{
+ FAR struct net_driver_s *dev;
+
+ /* Find the device driver that serves the subnet of the remote address */
+
#ifdef CONFIG_NET_MULTILINK
-void netdev_txnotify(const net_ipaddr_t lipaddr, const net_ipaddr_t ripaddr)
+ dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
#else
-void netdev_txnotify(const net_ipaddr_t ripaddr)
+ dev = netdev_findby_ipv4addr(ripaddr);
+#endif
+
+ if (dev && dev->d_txavail)
+ {
+ /* Notify the device driver that new TX data is available. */
+
+ (void)dev->d_txavail(dev);
+ }
+}
+#endif /* CONFIG_NET_IPv4 */
+
+
+/****************************************************************************
+ * Function: netdev_ipv6_txnotify
+ *
+ * Description:
+ * Notify the device driver that forwards the IPv4 address that new TX
+ * data is available.
+ *
+ * Parameters:
+ * lipaddr - The local address bound to the socket
+ * ripaddr - The remote address to send the data
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Called from normal user mode
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_MULTILINK
+void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
+ FAR const net_ipv6addr_t ripaddr)
+#else
+void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr)
#endif
{
FAR struct net_driver_s *dev;
@@ -102,9 +152,9 @@ void netdev_txnotify(const net_ipaddr_t ripaddr)
/* Find the device driver that serves the subnet of the remote address */
#ifdef CONFIG_NET_MULTILINK
- dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
+ dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
#else
- dev = netdev_findby_ipv4addr(ripaddr);
+ dev = netdev_findby_ipv6addr(ripaddr);
#endif
if (dev && dev->d_txavail)
@@ -114,5 +164,6 @@ void netdev_txnotify(const net_ipaddr_t ripaddr)
(void)dev->d_txavail(dev);
}
}
+#endif /* CONFIG_NET_IPv6 */
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
diff --git a/nuttx/net/pkt/pkt_send.c b/nuttx/net/pkt/pkt_send.c
index c136c45a1..5c352e850 100644
--- a/nuttx/net/pkt/pkt_send.c
+++ b/nuttx/net/pkt/pkt_send.c
@@ -267,14 +267,14 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
dev = netdev_findbyname("eth0");
/* 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
+ * NOTES: This is in essence what netdev_ipv4_txnotify() does,
+ * which is not possible to call since it expects a in_addr_t as
* its single argument to lookup the network interface.
*/
dev->d_txavail(dev);
- /* Wait for the send to complete or an error to occure: NOTES: (1)
+ /* Wait for the send to complete or an error to occur: NOTES: (1)
* net_lockedwait will also terminate if a signal is received, (2)
* interrupts may be disabled! They will be re-enabled while the
* task sleeps and automatically re-enabled when the task restarts.
diff --git a/nuttx/net/route/net_addroute.c b/nuttx/net/route/net_addroute.c
index 7053ffb98..8af1cf182 100644
--- a/nuttx/net/route/net_addroute.c
+++ b/nuttx/net/route/net_addroute.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/route/net_addroute.c
*
- * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -78,8 +78,7 @@
*
****************************************************************************/
-int net_addroute(net_ipaddr_t target, net_ipaddr_t netmask,
- net_ipaddr_t router)
+int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router)
{
FAR struct net_route_s *route;
net_lock_t save;
diff --git a/nuttx/net/route/net_delroute.c b/nuttx/net/route/net_delroute.c
index a585a4dc1..6ebd3d6c0 100644
--- a/nuttx/net/route/net_delroute.c
+++ b/nuttx/net/route/net_delroute.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/route/net_delroute.c
*
- * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -56,8 +56,8 @@
struct route_match_s
{
FAR struct net_route_s *prev; /* Predecessor in the list */
- net_ipaddr_t target; /* The target IP address to match */
- net_ipaddr_t netmask; /* The network mask to match */
+ in_addr_t target; /* The target IP address to match */
+ in_addr_t netmask; /* The network mask to match */
};
/****************************************************************************
@@ -134,7 +134,7 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
*
****************************************************************************/
-int net_delroute(net_ipaddr_t target, net_ipaddr_t netmask)
+int net_delroute(in_addr_t target, in_addr_t netmask)
{
struct route_match_s match;
diff --git a/nuttx/net/route/net_router.c b/nuttx/net/route/net_router.c
index 1f24edfc0..993cc08bd 100644
--- a/nuttx/net/route/net_router.c
+++ b/nuttx/net/route/net_router.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/route/net_router.c
*
- * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -54,21 +54,31 @@
* Public Types
****************************************************************************/
-struct route_match_s
+#ifdef CONFIG_NET_IPv4
+struct route_ipv4_match_s
{
- net_ipaddr_t target; /* The target IP address on an external network to match */
- net_ipaddr_t router; /* The IP address of the router on one of our networks*/
+ in_addr_t target; /* Target IPv4 address on an external network to match */
+ in_addr_t router; /* IPv4 address of the router on one of our networks*/
};
+#endif
+
+#ifdef CONFIG_NET_IPv6
+struct route_ipv6_match_s
+{
+ net_ipv6addr_t target; /* arget IPv6 address on an external network to match */
+ net_ipv6addr_t router; /* IPv6 address of the router on one of our networks*/
+};
+#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
- * Function: net_match
+ * Function: net_ipv4_match
*
* Description:
- * Return 1 if the route is available
+ * Return 1 if the IPv4 route is available
*
* Parameters:
* route - The next route to examine
@@ -79,16 +89,17 @@ struct route_match_s
*
****************************************************************************/
-static int net_match(FAR struct net_route_s *route, FAR void *arg)
+#ifdef CONFIG_NET_IPv4
+static int net_ipv4_match(FAR struct net_route_s *route, FAR void *arg)
{
- FAR struct route_match_s *match = (FAR struct route_match_s *)arg;
+ FAR struct route_ipv4_match_s *match = (FAR struct route_ipv4_match_s *)arg;
/* To match, the masked target addresses must be the same. In the event
* of multiple matches, only the first is returned. There is not (yet) any
* concept for the precedence of networks.
*/
- if (net_ipaddr_maskcmp(route->target, match->target, route->netmask))
+ if (net_ipv4addr_maskcmp(route->target, match->target, route->netmask))
{
/* They match.. Copy the router address */
@@ -98,25 +109,122 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
return 0;
}
+#endif /* CONFIG_NET_IPv4 */
+
+/****************************************************************************
+ * Function: net_ipv6_match
+ *
+ * Description:
+ * Return 1 if the IPv6 route is available
+ *
+ * Parameters:
+ * route - The next route to examine
+ * arg - The match values (cast to void*)
+ *
+ * Returned Value:
+ * 0 if the entry is not a match; 1 if the entry matched and was cleared.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv6
+static int net_ipv6_match(FAR struct net_route_s *route, FAR void *arg)
+{
+#if 1
+# warning Missing logic
+#else
+ FAR struct route_ipv4_match_s *match = (FAR struct route_ipv4_match_s *)arg;
+
+ /* To match, the masked target addresses must be the same. In the event
+ * of multiple matches, only the first is returned. There is not (yet) any
+ * concept for the precedence of networks.
+ */
+
+ if (net_ipv6ddr_maskcmp(route->target, match->target, route->netmask))
+ {
+ /* They match.. Copy the router address */
+
+ net_ipaddr_copy(match->router, route->router);
+ return 1;
+ }
+#endif
+
+ return 0;
+}
+#endif /* CONFIG_NET_IPv6 */
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Function: net_router
+ * Function: net_ipv4_router
*
* Description:
- * Given an IP address on a external network, return the address of the
+ * Given an IPv4 address on a external network, return the address of the
* router on a local network that can forward to the external network.
*
* Parameters:
- * target - An IP address on a remote network to use in the lookup.
+ * target - An IPv4 address on a remote network to use in the lookup.
* router - The address of router on a local network that can forward our
* packets to the target.
*
- * NOTE: For IPv6, router will be an array, for IPv4 it will be a scalar
- * value. Hence, the change in the function signature.
+ * Returned Value:
+ * OK on success; Negated errno on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv4
+int net_ipv4_router(in_addr_t target, FAR in_addr_t *router)
+{
+ struct route_ipv4_match_s match;
+ int ret;
+
+ /* Do not route the special broadcast IP address */
+
+ if (net_ipaddr_cmp(target, g_ipv4_alloneaddr))
+ {
+ return -ENOENT;
+ }
+
+ /* Set up the comparison structure */
+
+ memset(&match, 0, sizeof(struct route_ipv4_match_s));
+ net_ipaddr_copy(match.target, target);
+
+ /* Find an router entry with the routing table that can forward to this
+ * address
+ */
+
+ ret = net_foreachroute(net_ipv4_match, &match);
+ if (ret > 0)
+ {
+ /* We found a route. Return the router address. */
+
+ net_ipv4addr_copy(*router, match.router);
+ ret = OK;
+ }
+ else
+ {
+ /* There is no route for this address */
+
+ ret = -ENOENT;
+ }
+
+ return ret;
+}
+#endif /* CONFIG_NET_IPv4 */
+
+/****************************************************************************
+ * Function: net_ipv6_router
+ *
+ * Description:
+ * Given an IPv6 address on a external network, return the address of the
+ * router on a local network that can forward to the external network.
+ *
+ * Parameters:
+ * target - An IPv6 address on a remote network to use in the lookup.
+ * router - The address of router on a local network that can forward our
+ * packets to the target.
*
* Returned Value:
* OK on success; Negated errno on failure.
@@ -124,40 +232,33 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
****************************************************************************/
#ifdef CONFIG_NET_IPv6
-int net_router(net_ipaddr_t target, net_ipaddr_t router)
-#else
-int net_router(net_ipaddr_t target, FAR net_ipaddr_t *router)
-#endif
+int net_ipv6_router(net_ipv6addr_t target, net_ipv6addr_t router)
{
- struct route_match_s match;
+ struct route_ipv6_match_s match;
int ret;
/* Do not route the special broadcast IP address */
- if (net_ipaddr_cmp(target, g_alloneaddr))
+ if (net_ipaddr_cmp(target, g_ipv6_alloneaddr))
{
return -ENOENT;
}
/* Set up the comparison structure */
- memset(&match, 0, sizeof(struct route_match_s));
+ memset(&match, 0, sizeof(struct route_ipv6_match_s));
net_ipaddr_copy(match.target, target);
/* Find an router entry with the routing table that can forward to this
* address
*/
- ret = net_foreachroute(net_match, &match);
+ ret = net_foreachroute(net_ipv6_match, &match);
if (ret > 0)
{
/* We found a route. Return the router address. */
-#ifdef CONFIG_NET_IPv6
- net_ipaddr_copy(router, match.router);
-#else
- net_ipaddr_copy(*router, match.router);
-#endif
+ net_ipv6addr_copy(router, match.router);
ret = OK;
}
else
@@ -169,5 +270,6 @@ int net_router(net_ipaddr_t target, FAR net_ipaddr_t *router)
return ret;
}
+#endif /* CONFIG_NET_IPv6 */
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
diff --git a/nuttx/net/route/netdev_router.c b/nuttx/net/route/netdev_router.c
index 67e49c67f..65a65cab0 100644
--- a/nuttx/net/route/netdev_router.c
+++ b/nuttx/net/route/netdev_router.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/route/netdev_router.c
*
- * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -55,22 +55,24 @@
* Public Types
****************************************************************************/
-struct route_devmatch_s
+#ifdef CONFIG_NET_IPv4
+struct route_ipv4_devmatch_s
{
FAR struct net_driver_s *dev; /* The route must use this device */
- net_ipaddr_t target; /* The target IP address on an external network to match */
- net_ipaddr_t router; /* The IP address of the router on one of our networks*/
+ in_addr_t target; /* Target IPv4 address on an external network to match */
+ in_addr_t router; /* IPv6 address of the router on one of our networks*/
};
+#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
- * Function: net_devmatch
+ * Function: net_ipv4_devmatch
*
* Description:
- * Return 1 if the route is available on the device's network.
+ * Return 1 if the IPv4 route is available on the device's network.
*
* Parameters:
* route - The next route to examine
@@ -81,9 +83,10 @@ struct route_devmatch_s
*
****************************************************************************/
-static int net_devmatch(FAR struct net_route_s *route, FAR void *arg)
+#ifdef CONFIG_NET_IPv4
+static int net_ipv4_devmatch(FAR struct net_route_s *route, FAR void *arg)
{
- FAR struct route_devmatch_s *match = (FAR struct route_devmatch_s *)arg;
+ FAR struct route_ipv4_devmatch_s *match = (FAR struct route_ipv4_devmatch_s *)arg;
FAR struct net_driver_s *dev = match->dev;
/* To match, (1) the masked target addresses must be the same, and (2) the
@@ -93,59 +96,156 @@ static int net_devmatch(FAR struct net_route_s *route, FAR void *arg)
* not (yet) any concept for the precedence of networks.
*/
- if (net_ipaddr_maskcmp(route->target, match->target, route->netmask) &&
- net_ipaddr_maskcmp(route->router, dev->d_ipaddr, dev->d_netmask))
+ if (net_ipv4addr_maskcmp(route->target, match->target, route->netmask) &&
+ net_ipv4addr_maskcmp(route->router, dev->d_ipaddr, dev->d_netmask))
{
/* They match.. Copy the router address */
- net_ipaddr_copy(match->router, route->router);
+ net_ipv4addr_copy(match->router, route->router);
return 1;
}
return 0;
}
+#endif /* CONFIG_NET_IPv4 */
+
+/****************************************************************************
+ * Function: net_ipv6_devmatch
+ *
+ * Description:
+ * Return 1 if the IPv6 route is available on the device's network.
+ *
+ * Parameters:
+ * route - The next route to examine
+ * arg - The match values (cast to void*)
+ *
+ * Returned Value:
+ * 0 if the entry is not a match; 1 if the entry matched and was cleared.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv6
+static int net_ipv6_devmatch(FAR struct net_route_s *route, FAR void *arg)
+{
+#if 1
+# warning Missing logic
+#else
+ FAR struct route_ipv6_devmatch_s *match = (FAR struct route_ipv6_devmatch_s *)arg;
+ FAR struct net_driver_s *dev = match->dev;
+
+ /* To match, (1) the masked target addresses must be the same, and (2) the
+ * router address must like on the network provided by the device.
+ *
+ * In the event of multiple matches, only the first is returned. There
+ * not (yet) any concept for the precedence of networks.
+ */
+
+ if (net_ipv6addr_maskcmp(route->target, match->target, route->netmask) &&
+ net_ipv6addr_maskcmp(route->router, dev->d_ipaddr, dev->d_netmask))
+ {
+ /* They match.. Copy the router address */
+
+ net_ipv6addr_copy(match->router, route->router);
+ return 1;
+ }
+#endif
+
+ return 0;
+}
+#endif /* CONFIG_NET_IPv6 */
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Function: netdev_router
+ * Function: netdev_ipv4_router
*
* Description:
- * Given an IP address on a external network, return the address of the
+ * Given an IPv4 address on a external network, return the address of the
* router on a local network that can forward to the external network.
- * This is similar to net_router(). However, the set of routers is
+ * This is similar to net_ipv4_router(). However, the set of routers is
* constrained to those accessible by the specific device
*
* Parameters:
* dev - We are committed to using this device.
- * target - An IP address on a remote network to use in the lookup.
+ * target - An IPv4 address on a remote network to use in the lookup.
* router - The address of router on a local network that can forward our
* packets to the target.
*
- * NOTE: For IPv6, router will be an array, for IPv4 it will be a scalar
- * value. Hence, the change in the function signature.
+ * Returned Value:
+ * A router address is always returned (which may just be, perhaps,
+ * device's default router address)
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv4
+void netdev_ipv4_router(FAR struct net_driver_s *dev, in_addr_t target,
+ FAR in_addr_t *router)
+{
+ struct route_ipv4_devmatch_s match;
+ int ret;
+
+ /* Set up the comparison structure */
+
+ memset(&match, 0, sizeof(struct route_ipv4_devmatch_s));
+ match.dev = dev;
+ net_ipaddr_copy(match.target, target);
+
+ /* Find an router entry with the routing table that can forward to this
+ * address using this device.
+ */
+
+ ret = net_foreachroute(net_ipv4_devmatch, &match);
+ if (ret > 0)
+ {
+ /* We found a route. Return the router address. */
+
+ net_ipv4addr_copy(*router, match.target);
+ }
+ else
+ {
+ /* There isn't a matching route.. fallback and use the default router
+ * of the device.
+ */
+
+ net_ipv4addr_copy(*router, dev->d_draddr);
+ }
+}
+#endif
+
+/****************************************************************************
+ * Function: netdev_ipv6_router
+ *
+ * Description:
+ * Given an IPv6 address on a external network, return the address of the
+ * router on a local network that can forward to the external network.
+ * This is similar to net_ipv6_router(). However, the set of routers is
+ * constrained to those accessible by the specific device
+ *
+ * Parameters:
+ * dev - We are committed to using this device.
+ * target - An IPv6 address on a remote network to use in the lookup.
+ * router - The address of router on a local network that can forward our
+ * packets to the target.
*
* Returned Value:
- * None
+ * A router address is always returned (which may just be, perhaps,
+ * device's default router address)
*
****************************************************************************/
#ifdef CONFIG_NET_IPv6
-void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
- net_ipaddr_t router)
-#else
-void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
- FAR net_ipaddr_t *router)
-#endif
+void netdev_ipv6_router(FAR struct net_driver_s *dev,
+ FAR const net_ipv6addr_t target,
+ FAR net_ipv6addr_t router)
{
- struct route_devmatch_s match;
+ struct route_ipv6_devmatch_s match;
int ret;
/* Set up the comparison structure */
- memset(&match, 0, sizeof(struct route_devmatch_s));
+ memset(&match, 0, sizeof(struct route_ipv6_devmatch_s));
match.dev = dev;
net_ipaddr_copy(match.target, target);
@@ -153,16 +253,12 @@ void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
* address using this device.
*/
- ret = net_foreachroute(net_devmatch, &match);
+ ret = net_foreachroute(net_ipv6_devmatch, &match);
if (ret > 0)
{
/* We found a route. Return the router address. */
-#ifdef CONFIG_NET_IPv6
- net_ipaddr_copy(router, match.target);
-#else
- net_ipaddr_copy(*router, match.target);
-#endif
+ net_ipv6addr_copy(router, match.target);
}
else
{
@@ -170,12 +266,9 @@ void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
* of the device.
*/
-#ifdef CONFIG_NET_IPv6
- net_ipaddr_copy(router, dev->d_draddr);
-#else
- net_ipaddr_copy(*router, dev->d_draddr);
-#endif
+ net_ipv6addr_copy(router, dev->d_draddr);
}
}
+#endif
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
diff --git a/nuttx/net/route/route.h b/nuttx/net/route/route.h
index 046a7e9de..6df13b124 100644
--- a/nuttx/net/route/route.h
+++ b/nuttx/net/route/route.h
@@ -67,9 +67,9 @@
struct net_route_s
{
FAR struct net_route_s *flink; /* Supports a singly linked list */
- net_ipaddr_t target; /* The destination network */
- net_ipaddr_t netmask; /* The network address mask */
- net_ipaddr_t router; /* Route packets via this router */
+ in_addr_t target; /* The destination network */
+ in_addr_t netmask; /* The network address mask */
+ in_addr_t router; /* Route packets via this router */
};
/* Type of the call out function pointer provided to net_foreachroute() */
@@ -162,8 +162,8 @@ void net_freeroute(FAR struct net_route_s *route);
*
****************************************************************************/
-int net_addroute(net_ipaddr_t target, net_ipaddr_t netmask,
- net_ipaddr_t router);
+int net_addroute(in_addr_t target, in_addr_t netmask,
+ in_addr_t router);
/****************************************************************************
* Function: net_delroute
@@ -178,22 +178,40 @@ int net_addroute(net_ipaddr_t target, net_ipaddr_t netmask,
*
****************************************************************************/
-int net_delroute(net_ipaddr_t target, net_ipaddr_t netmask);
+int net_delroute(in_addr_t target, in_addr_t netmask);
/****************************************************************************
- * Function: net_router
+ * Function: net_ipv4_router
*
* Description:
- * Given an IP address on a external network, return the address of the
+ * Given an IPv4 address on a external network, return the address of the
* router on a local network that can forward to the external network.
*
* Parameters:
- * target - An IP address on a remote network to use in the lookup.
+ * target - An IPv4 address on a remote network to use in the lookup.
* router - The address of router on a local network that can forward our
* packets to the target.
*
- * NOTE: For IPv6, router will be an array, for IPv4 it will be a scalar
- * value. Hence, the change in the function signature.
+ * Returned Value:
+ * OK on success; Negated errno on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IPv4
+int net_ipv4_router(in_addr_t target, FAR in_addr_t *router);
+#endif
+
+/****************************************************************************
+ * Function: net_ipv6_router
+ *
+ * Description:
+ * Given an IPv6 address on a external network, return the address of the
+ * router on a local network that can forward to the external network.
+ *
+ * Parameters:
+ * target - An IPv6 address on a remote network to use in the lookup.
+ * router - The address of router on a local network that can forward our
+ * packets to the target.
*
* Returned Value:
* OK on success; Negated errno on failure.
@@ -201,43 +219,62 @@ int net_delroute(net_ipaddr_t target, net_ipaddr_t netmask);
****************************************************************************/
#ifdef CONFIG_NET_IPv6
-int net_router(net_ipaddr_t target, net_ipaddr_t router);
-#else
-int net_router(net_ipaddr_t target, FAR net_ipaddr_t *router);
+int net_ipv6_router(net_ipv6addr_t target, net_ipv6addr_t router);
#endif
/****************************************************************************
- * Function: netdev_router
+ * Function: netdev_ipv4_router
*
* Description:
- * Given an IP address on a external network, return the address of the
+ * Given an IPv4 address on a external network, return the address of the
* router on a local network that can forward to the external network.
- * This is similar to net_router(). However, the set of routers is
+ * This is similar to net_ipv4_router(). However, the set of routers is
* constrained to those accessible by the specific device
*
* Parameters:
* dev - We are committed to using this device.
- * target - An IP address on a remote network to use in the lookup.
+ * target - An IPv4 address on a remote network to use in the lookup.
* router - The address of router on a local network that can forward our
* packets to the target.
*
- * NOTE: For IPv6, router will be an array, for IPv4 it will be a scalar
- * value. Hence, the change in the function signature.
- *
* Returned Value:
- * None, a router address is always returned (which may just be, perhaps,
+ * A router address is always returned (which may just be, perhaps,
* device's default router address)
*
****************************************************************************/
+#ifdef CONFIG_NET_IPv4
struct net_driver_s;
+void netdev_ipv4_router(FAR struct net_driver_s *dev, in_addr_t target,
+ FAR in_addr_t *router);
+#endif
+
+/****************************************************************************
+ * Function: netdev_ipv6_router
+ *
+ * Description:
+ * Given an IPv6 address on a external network, return the address of the
+ * router on a local network that can forward to the external network.
+ * This is similar to net_ipv6_router(). However, the set of routers is
+ * constrained to those accessible by the specific device
+ *
+ * Parameters:
+ * dev - We are committed to using this device.
+ * target - An IPv6 address on a remote network to use in the lookup.
+ * router - The address of router on a local network that can forward our
+ * packets to the target.
+ *
+ * Returned Value:
+ * A router address is always returned (which may just be, perhaps,
+ * device's default router address)
+ *
+ ****************************************************************************/
#ifdef CONFIG_NET_IPv6
-void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
- net_ipaddr_t router);
-#else
-void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
- FAR net_ipaddr_t *router);
+struct net_driver_s;
+void netdev_ipv6_router(FAR struct net_driver_s *dev,
+ FAR const net_ipv6addr_t target,
+ FAR net_ipv6addr_t router);
#endif
/****************************************************************************
diff --git a/nuttx/net/socket/net_close.c b/nuttx/net/socket/net_close.c
index a66fe8ff1..618c1f7f5 100644
--- a/nuttx/net/socket/net_close.c
+++ b/nuttx/net/socket/net_close.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/socket/net_close.c
*
- * Copyright (C) 2007-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -358,9 +358,9 @@ static inline int netclose_disconnect(FAR struct socket *psock)
/* Notify the device driver of the availability of TX data */
#ifdef CONFIG_NET_MULTILINK
- netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
#else
- netdev_txnotify(conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.raddr);
#endif
#ifdef CONFIG_NET_SOLINGER
diff --git a/nuttx/net/socket/net_sendfile.c b/nuttx/net/socket/net_sendfile.c
index 5ec1ead07..17f7b5478 100644
--- a/nuttx/net/socket/net_sendfile.c
+++ b/nuttx/net/socket/net_sendfile.c
@@ -565,9 +565,9 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
/* Notify the device driver of the availability of TX data */
#ifdef CONFIG_NET_MULTILINK
- netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
#else
- netdev_txnotify(conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.raddr);
#endif
net_lockedwait(&state.snd_sem);
}
diff --git a/nuttx/net/socket/recvfrom.c b/nuttx/net/socket/recvfrom.c
index 88d8e455e..0079ca85c 100644
--- a/nuttx/net/socket/recvfrom.c
+++ b/nuttx/net/socket/recvfrom.c
@@ -1097,9 +1097,9 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
#if 0 /* No */
#ifdef CONFIG_NET_MULTILINK
- netdev_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+ netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
#else
- netdev_rxnotify(conn->u.ipv4.raddr);
+ netdev_ipv4_rxnotify(conn->u.ipv4.raddr);
#endif
#endif
@@ -1196,9 +1196,9 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
/* Notify the device driver of the receive call */
#ifdef CONFIG_NET_MULTILINK
- netdev_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+ netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
#else
- netdev_rxnotify(conn->u.ipv4.raddr);
+ netdev_ipv4_rxnotify(conn->u.ipv4.raddr);
#endif
/* Wait for either the receive to complete or for an error/timeout to occur.
diff --git a/nuttx/net/socket/sendto.c b/nuttx/net/socket/sendto.c
index 151487555..7576d7427 100644
--- a/nuttx/net/socket/sendto.c
+++ b/nuttx/net/socket/sendto.c
@@ -420,9 +420,9 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
/* Notify the device driver of the availability of TX data */
#ifdef CONFIG_NET_MULTILINK
- netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
#else
- netdev_txnotify(conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.raddr);
#endif
/* Wait for either the receive to complete or for an error/timeout to occur.
diff --git a/nuttx/net/tcp/tcp_conn.c b/nuttx/net/tcp/tcp_conn.c
index 1ce526560..f23694c5e 100644
--- a/nuttx/net/tcp/tcp_conn.c
+++ b/nuttx/net/tcp/tcp_conn.c
@@ -104,8 +104,7 @@ static uint16_t g_last_tcp_port;
****************************************************************************/
#ifdef CONFIG_NETDEV_MULTINIC
-static FAR struct tcp_conn_s *tcp_listener(net_ipaddr_t ipaddr,
- uint16_t portno)
+static FAR struct tcp_conn_s *tcp_listener(in_addr_t ipaddr, uint16_t portno)
#else
static FAR struct tcp_conn_s *tcp_listener(uint16_t portno)
#endif
@@ -132,11 +131,11 @@ static FAR struct tcp_conn_s *tcp_listener(uint16_t portno)
* with INADDR_ANY.
*/
- if (net_ipaddr_cmp(conn->u.ipv4.laddr, ipaddr) ||
+ if (net_ipv4addr_cmp(conn->u.ipv4.laddr, ipaddr) ||
#ifdef CONFIG_NET_IPv6
- net_ipaddr_cmp(conn->u.ipv4.laddr, g_allzeroaddr))
+ net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr))
#else
- net_ipaddr_cmp(conn->u.ipv4.laddr, INADDR_ANY))
+ net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY))
#endif
#endif
{
@@ -176,7 +175,7 @@ static FAR struct tcp_conn_s *tcp_listener(uint16_t portno)
****************************************************************************/
#ifdef CONFIG_NETDEV_MULTINIC
-static int tcp_selectport(net_ipaddr_t ipaddr, uint16_t portno)
+static int tcp_selectport(in_addr_t ipaddr, uint16_t portno)
#else
static int tcp_selectport(uint16_t portno)
#endif
@@ -525,7 +524,7 @@ FAR struct tcp_conn_s *tcp_active(FAR struct net_driver_s *dev,
tcp->destport == conn->lport &&
tcp->srcport == conn->rport &&
#ifdef CONFIG_NETDEV_MULTINIC
- (net_ipaddr_cmp(conn->u.ipv4.laddr, g_allzeroaddr) ||
+ (net_ipaddr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr) ||
net_ipaddr_cmp(destipaddr, conn->u.ipv4.laddr)) &&
#endif
net_ipaddr_cmp(srcipaddr, conn->u.ipv4.raddr))
@@ -668,7 +667,7 @@ int tcp_bind(FAR struct tcp_conn_s *conn,
net_lock_t flags;
int port;
#ifdef CONFIG_NETDEV_MULTINIC
- net_ipaddr_t ipaddr;
+ in_addr_t ipaddr;
#endif
/* Verify or select a local port and address */
diff --git a/nuttx/net/tcp/tcp_send_buffered.c b/nuttx/net/tcp/tcp_send_buffered.c
index 66a983190..fdf875cc0 100644
--- a/nuttx/net/tcp/tcp_send_buffered.c
+++ b/nuttx/net/tcp/tcp_send_buffered.c
@@ -829,9 +829,9 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
/* Notify the device driver of the availability of TX data */
#ifdef CONFIG_NET_MULTILINK
- netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
#else
- netdev_txnotify(conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.raddr);
#endif
result = len;
}
diff --git a/nuttx/net/tcp/tcp_send_unbuffered.c b/nuttx/net/tcp/tcp_send_unbuffered.c
index 90380640b..5649d3aa1 100644
--- a/nuttx/net/tcp/tcp_send_unbuffered.c
+++ b/nuttx/net/tcp/tcp_send_unbuffered.c
@@ -597,9 +597,9 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
/* Notify the device driver of the availability of TX data */
#ifdef CONFIG_NET_MULTILINK
- netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
#else
- netdev_txnotify(conn->u.ipv4.raddr);
+ netdev_ipv4_txnotify(conn->u.ipv4.raddr);
#endif
/* Wait for the send to complete or an error to occur: NOTES: (1)
diff --git a/nuttx/net/udp/udp_conn.c b/nuttx/net/udp/udp_conn.c
index f50057255..33c779aeb 100644
--- a/nuttx/net/udp/udp_conn.c
+++ b/nuttx/net/udp/udp_conn.c
@@ -127,8 +127,7 @@ static inline void _udp_semtake(FAR sem_t *sem)
****************************************************************************/
#ifdef CONFIG_NETDEV_MULTINIC
-static FAR struct udp_conn_s *udp_find_conn(net_ipaddr_t ipaddr,
- uint16_t portno)
+static FAR struct udp_conn_s *udp_find_conn(in_addr_t ipaddr, uint16_t portno)
#else
static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
#endif
@@ -150,11 +149,11 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
*/
if (conn->lport == portno &&
- (net_ipaddr_cmp(conn->u.ipv4.laddr, ipaddr) ||
+ (net_ipv4addr_cmp(conn->u.ipv4.laddr, ipaddr) ||
#ifdef CONFIG_NET_IPv6
- net_ipaddr_cmp(conn->u.ipv4.laddr, g_allzeroaddr)))
+ net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr)))
#else
- net_ipaddr_cmp(conn->u.ipv4.laddr, INADDR_ANY)))
+ net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY)))
#endif
{
return conn;
@@ -195,7 +194,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
****************************************************************************/
#ifdef CONFIG_NETDEV_MULTINIC
-static uint16_t udp_select_port(net_ipaddr_t ipaddr)
+static uint16_t udp_select_port(in_addr_t ipaddr)
#else
static uint16_t udp_select_port(void)
#endif
@@ -381,13 +380,13 @@ FAR struct udp_conn_s *udp_active(FAR struct net_driver_s *dev,
if (conn->lport != 0 && udp->destport == conn->lport &&
(conn->rport == 0 || udp->srcport == conn->rport) &&
#ifdef CONFIG_NETDEV_MULTINIC
- (net_ipaddr_cmp(conn->u.ipv4.laddr, g_allzeroaddr) ||
- net_ipaddr_cmp(conn->u.ipv4.laddr, g_alloneaddr) ||
- net_ipaddr_hdrcmp(ip->destipaddr, &conn->u.ipv4.laddr)) &&
+ (net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr) ||
+ net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_alloneaddr) ||
+ net_ipv4addr_hdrcmp(ip->destipaddr, &conn->u.ipv4.laddr)) &&
#endif
- (net_ipaddr_cmp(conn->u.ipv4.raddr, g_allzeroaddr) ||
- net_ipaddr_cmp(conn->u.ipv4.raddr, g_alloneaddr) ||
- net_ipaddr_hdrcmp(ip->srcipaddr, &conn->u.ipv4.raddr)))
+ (net_ipv4addr_cmp(conn->u.ipv4.raddr, g_ipv4_allzeroaddr) ||
+ net_ipv4addr_cmp(conn->u.ipv4.raddr, g_ipv4_alloneaddr) ||
+ net_ipv4addr_hdrcmp(ip->srcipaddr, &conn->u.ipv4.raddr)))
{
/* Matching connection found.. return a reference to it */
@@ -448,7 +447,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
int ret;
#ifdef CONFIG_NETDEV_MULTINIC
- net_ipaddr_t ipaddr;
+ in_addr_t ipaddr;
#ifdef CONFIG_NET_IPv6
/* Get the IPv6 address that we are binding to */
@@ -569,7 +568,7 @@ int udp_connect(FAR struct udp_conn_s *conn,
else
{
conn->rport = 0;
- net_ipaddr_copy(conn->u.ipv4.raddr, g_allzeroaddr);
+ net_ipv4addr_copy(conn->u.ipv4.raddr, g_ipv4_allzeroaddr);
}
conn->ttl = IP_TTL;
diff --git a/nuttx/net/utils/net_chksum.c b/nuttx/net/utils/net_chksum.c
index b77e10569..ac42d805e 100644
--- a/nuttx/net/utils/net_chksum.c
+++ b/nuttx/net/utils/net_chksum.c
@@ -143,7 +143,7 @@ static uint16_t upper_layer_chksum(FAR struct net_driver_s *dev,
/* Sum IP source and destination addresses. */
- sum = chksum(sum, (uint8_t *)&pbuf->srcipaddr, 2 * sizeof(net_ipaddr_t));
+ sum = chksum(sum, (uint8_t *)&pbuf->srcipaddr, 2 * sizeof(in_addr_t));
/* Sum TCP header and data. */