From b756df982d44f12ca2308c346a4c5b1632565dea Mon Sep 17 00:00:00 2001
From: Gregory Nutt <gnutt@nuttx.org>
Date: Mon, 9 Feb 2015 18:15:34 -0600
Subject: [PATCH] net/:  Lots of build problems introduced into multiple NIC
 support.  Many places where conditional logic based on CONFIG_NETDEV_MULTINIC
 is confused with CONFIG_NET_MULTILINK.  Lots of code changed with IPv6 that
 was never compiled with MULTINIC enabled.  Still some problem with parameter
 passing.

---
 net/arp/arp_send.c             |  2 +-
 net/icmp/icmp_ping.c           |  2 +-
 net/icmpv6/icmpv6_autoconfig.c |  1 +
 net/icmpv6/icmpv6_neighbor.c   |  2 +-
 net/icmpv6/icmpv6_ping.c       |  2 +-
 net/icmpv6/icmpv6_rnotify.c    |  6 +++---
 net/netdev/netdev.h            | 16 ++++++++--------
 net/netdev/netdev_findbyaddr.c | 16 ++++++++--------
 net/netdev/netdev_rxnotify.c   |  8 ++++----
 net/netdev/netdev_txnotify.c   |  8 ++++----
 net/socket/net_close.c         |  4 ++--
 net/socket/net_sendfile.c      |  4 ++--
 net/socket/recvfrom.c          |  4 ++--
 net/tcp/tcp_conn.c             | 14 ++++++++++----
 net/tcp/tcp_send_buffered.c    |  4 ++--
 net/tcp/tcp_send_unbuffered.c  |  4 ++--
 net/udp/udp_conn.c             |  4 ++--
 net/udp/udp_sendto.c           |  4 ++--
 18 files changed, 56 insertions(+), 49 deletions(-)

diff --git a/net/arp/arp_send.c b/net/arp/arp_send.c
index e14513df75..dfd38dbcb7 100644
--- a/net/arp/arp_send.c
+++ b/net/arp/arp_send.c
@@ -222,7 +222,7 @@ int arp_send(in_addr_t ipaddr)
 
   /* Get the device that can route this request */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   dev = netdev_findby_ipv4addr(g_ipv4_allzeroaddr, ipaddr);
 #else
   dev = netdev_findby_ipv4addr(ipaddr);
diff --git a/net/icmp/icmp_ping.c b/net/icmp/icmp_ping.c
index 8158f2ab4f..76d7e8a61e 100644
--- a/net/icmp/icmp_ping.c
+++ b/net/icmp/icmp_ping.c
@@ -369,7 +369,7 @@ 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
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv4_txnotify(g_ipv4_allzeroaddr, state.png_addr);
 #else
       netdev_ipv4_txnotify(state.png_addr);
diff --git a/net/icmpv6/icmpv6_autoconfig.c b/net/icmpv6/icmpv6_autoconfig.c
index 082e17ab18..22a570c766 100644
--- a/net/icmpv6/icmpv6_autoconfig.c
+++ b/net/icmpv6/icmpv6_autoconfig.c
@@ -354,6 +354,7 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev)
       return -ENOSYS;
     }
 #endif
+
   /* The interface should be in the down state */
 
  save = net_lock();
diff --git a/net/icmpv6/icmpv6_neighbor.c b/net/icmpv6/icmpv6_neighbor.c
index 794b02d673..b27a0bfb19 100644
--- a/net/icmpv6/icmpv6_neighbor.c
+++ b/net/icmpv6/icmpv6_neighbor.c
@@ -225,7 +225,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr)
 
   /* Get the device that can route this request */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   dev = netdev_findby_ipv6addr(g_ipv6_allzeroaddr, ipaddr);
 #else
   dev = netdev_findby_ipv6addr(ipaddr);
diff --git a/net/icmpv6/icmpv6_ping.c b/net/icmpv6/icmpv6_ping.c
index 8f8ec37c63..4072cce953 100644
--- a/net/icmpv6/icmpv6_ping.c
+++ b/net/icmpv6/icmpv6_ping.c
@@ -439,7 +439,7 @@ 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
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv6_txnotify(g_ipv6_allzeroaddr, state.png_addr);
 #else
       netdev_ipv6_txnotify(state.png_addr);
diff --git a/net/icmpv6/icmpv6_rnotify.c b/net/icmpv6/icmpv6_rnotify.c
index a605dc5772..174c8c16a5 100644
--- a/net/icmpv6/icmpv6_rnotify.c
+++ b/net/icmpv6/icmpv6_rnotify.c
@@ -159,7 +159,7 @@ static void icmpv6_setaddresses(FAR struct net_driver_s *dev,
 void icmpv6_rwait_setup(FAR struct net_driver_s *dev,
                         FAR struct icmpv6_rnotify_s *notify)
 {
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   irqstate_t flags;
 
   /* Initialize the wait structure */
@@ -206,7 +206,7 @@ void icmpv6_rwait_setup(FAR struct net_driver_s *dev,
 
 int icmpv6_rwait_cancel(FAR struct icmpv6_rnotify_s *notify)
 {
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   FAR struct icmpv6_rnotify_s *curr;
   FAR struct icmpv6_rnotify_s *prev;
   irqstate_t flags;
@@ -332,7 +332,7 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify,
 void icmpv6_rnotify(FAR struct net_driver_s *dev, const net_ipv6addr_t draddr,
                     const net_ipv6addr_t prefix, unsigned int preflen)
 {
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   FAR struct icmpv6_rnotify_s *curr;
 
   nvdbg("Notified\n");
diff --git a/net/netdev/netdev.h b/net/netdev/netdev.h
index d0083723bb..3a1c0908b2 100644
--- a/net/netdev/netdev.h
+++ b/net/netdev/netdev.h
@@ -100,7 +100,7 @@ FAR struct net_driver_s *netdev_findbyname(FAR const char *ifname);
 
 #if CONFIG_NSOCKET_DESCRIPTORS > 0
 #ifdef CONFIG_NET_IPv4
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
 FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
                                                 in_addr_t ripaddr);
 #else
@@ -109,7 +109,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr);
 #endif
 
 #ifdef CONFIG_NET_IPv6
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
 FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
                                                 const net_ipv6addr_t ripaddr);
 #else
@@ -128,7 +128,7 @@ FAR struct net_driver_s *netdev_default(void);
 
 #if CONFIG_NSOCKET_DESCRIPTORS > 0
 #ifdef CONFIG_NET_IPv4
-#  ifdef CONFIG_NET_MULTILINK
+#  ifdef CONFIG_NETDEV_MULTINIC
 void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr);
 #  else
 void netdev_ipv4_txnotify(in_addr_t ripaddr);
@@ -136,7 +136,7 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr);
 #endif /* CONFIG_NET_IPv4 */
 
 #ifdef CONFIG_NET_IPv6
-#  ifdef CONFIG_NET_MULTILINK
+#  ifdef CONFIG_NETDEV_MULTINIC
 void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
                           FAR const net_ipv6addr_t ripaddr);
 #  else
@@ -150,7 +150,7 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr);
 #if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL)
 
 #ifdef CONFIG_NET_IPv4
-#  ifdef CONFIG_NET_MULTILINK
+#  ifdef CONFIG_NETDEV_MULTINIC
 void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr);
 #  else
 void netdev_ipv4_rxnotify(in_addr_t ripaddr);
@@ -158,7 +158,7 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr);
 #endif /* CONFIG_NET_IPv4 */
 
 #ifdef CONFIG_NET_IPv6
-#  ifdef CONFIG_NET_MULTILINK
+#  ifdef CONFIG_NETDEV_MULTINIC
 void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
                           FAR const net_ipv6addr_t ripaddr);
 #  else
@@ -168,7 +168,7 @@ void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr);
 
 #else
 #ifdef CONFIG_NET_IPv4
-#  ifdef CONFIG_NET_MULTILINK
+#  ifdef CONFIG_NETDEV_MULTINIC
 #    define netdev_ipv4_rxnotify(lipaddr,ripaddr)
 #  else
 #    define netdev_ipv4_rxnotify(ripaddr)
@@ -176,7 +176,7 @@ void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr);
 #endif /* CONFIG_NET_IPv4 */
 
 #ifdef CONFIG_NET_IPv6
-#  ifdef CONFIG_NET_MULTILINK
+#  ifdef CONFIG_NETDEV_MULTINIC
 #    define netdev_ipv6_rxnotify(lipaddr,ripaddr)
 #  else
 #    define netdev_ipv6_rxnotify(ripaddr)
diff --git a/net/netdev/netdev_findbyaddr.c b/net/netdev/netdev_findbyaddr.c
index 14b2845632..f7ba9de73f 100644
--- a/net/netdev/netdev_findbyaddr.c
+++ b/net/netdev/netdev_findbyaddr.c
@@ -192,7 +192,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
  *
  * Parameters:
  *   lipaddr - Local, bound address of a connection.  Used only if ripaddr
- *     is the broadcast address.  Used only if CONFIG_NET_MULTILINK.
+ *     is the broadcast address.  Used only if CONFIG_NETDEV_MULTINIC.
  *   ripaddr - Remote address of a connection to use in the lookup
  *
  * Returned Value:
@@ -204,7 +204,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
  ****************************************************************************/
 
 #ifdef CONFIG_NET_IPv4
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
 FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
                                                 in_addr_t ripaddr)
 #else
@@ -221,7 +221,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
 
   if (net_ipv4addr_cmp(ripaddr, g_ipv4_alloneaddr))
     {
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       /* Yes.. Check the local, bound address.  Is it INADDR_ANY? */
 
       if (net_ipv4addr_cmp(lipaddr, g_ipv4_allzeroaddr))
@@ -283,7 +283,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
    * out subnet to a router and there is no routing information.
    */
 
-#ifndef CONFIG_NET_MULTILINK
+#ifndef CONFIG_NETDEV_MULTINIC
    /* If there is only a single, registered network interface, then the
     * decision is pretty easy.  Use that device and its default router
     * address.
@@ -310,7 +310,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
  *
  * Parameters:
  *   lipaddr - Local, bound address of a connection.  Used only if ripaddr
- *     is the broadcast address.  Used only if CONFIG_NET_MULTILINK.
+ *     is the broadcast address.  Used only if CONFIG_NETDEV_MULTINIC.
  *   ripaddr - Remote address of a connection to use in the lookup
  *
  * Returned Value:
@@ -322,7 +322,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
  ****************************************************************************/
 
 #ifdef CONFIG_NET_IPv6
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
 FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
                                                 const net_ipv6addr_t ripaddr)
 #else
@@ -339,7 +339,7 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
 
   if (net_ipv6addr_cmp(ripaddr, g_ipv6_alloneaddr))
     {
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       /* Yes.. Check the local, bound address.  Is it INADDR_ANY? */
 
       if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
@@ -401,7 +401,7 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
    * out subnet to a router and there is no routing information.
    */
 
-#ifndef CONFIG_NET_MULTILINK
+#ifndef CONFIG_NETDEV_MULTINIC
    /* If there is only a single, registered network interface, then the
     * decision is pretty easy.  Use that device and its default router
     * address.
diff --git a/net/netdev/netdev_rxnotify.c b/net/netdev/netdev_rxnotify.c
index 89e690c1c6..824c78f89c 100644
--- a/net/netdev/netdev_rxnotify.c
+++ b/net/netdev/netdev_rxnotify.c
@@ -94,7 +94,7 @@
  ****************************************************************************/
 
 #ifdef CONFIG_NET_IPv4
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
 void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr)
 #else
 void netdev_ipv4_rxnotify(in_addr_t ripaddr)
@@ -104,7 +104,7 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr)
 
   /* Find the device driver that serves the subnet of the remote address */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
 #else
   dev = netdev_findby_ipv4addr(ripaddr);
@@ -139,7 +139,7 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr)
  ****************************************************************************/
 
 #ifdef CONFIG_NET_IPv6
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
 void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
                           FAR const net_ipv6addr_t ripaddr)
 #else
@@ -150,7 +150,7 @@ void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr)
 
   /* Find the device driver that serves the subnet of the remote address */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
 #else
   dev = netdev_findby_ipv6addr(ripaddr);
diff --git a/net/netdev/netdev_txnotify.c b/net/netdev/netdev_txnotify.c
index d06064b3f1..9346d58a26 100644
--- a/net/netdev/netdev_txnotify.c
+++ b/net/netdev/netdev_txnotify.c
@@ -94,7 +94,7 @@
  ****************************************************************************/
 
 #ifdef CONFIG_NET_IPv4
-#  ifdef CONFIG_NET_MULTILINK
+#  ifdef CONFIG_NETDEV_MULTINIC
 void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
 #  else
 void netdev_ipv4_txnotify(in_addr_t ripaddr)
@@ -104,7 +104,7 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr)
 
   /* Find the device driver that serves the subnet of the remote address */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
 #else
   dev = netdev_findby_ipv4addr(ripaddr);
@@ -140,7 +140,7 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr)
  ****************************************************************************/
 
 #ifdef CONFIG_NET_IPv6
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
 void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
                           FAR const net_ipv6addr_t ripaddr)
 #else
@@ -151,7 +151,7 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr)
 
   /* Find the device driver that serves the subnet of the remote address */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
   dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
 #else
   dev = netdev_findby_ipv6addr(ripaddr);
diff --git a/net/socket/net_close.c b/net/socket/net_close.c
index ce87fcc9a4..2ae8e606d5 100644
--- a/net/socket/net_close.c
+++ b/net/socket/net_close.c
@@ -289,7 +289,7 @@ static inline void netclose_txnotify(FAR struct socket *psock,
     {
       /* Notify the device driver that send data is available */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
 #else
       netdev_ipv4_txnotify(conn->u.ipv4.raddr);
@@ -305,7 +305,7 @@ static inline void netclose_txnotify(FAR struct socket *psock,
       /* Notify the device driver that send data is available */
 
       DEBUGASSERT(psock->s_domain == PF_INET6);
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
 #else
       netdev_ipv6_txnotify(conn->u.ipv6.raddr);
diff --git a/net/socket/net_sendfile.c b/net/socket/net_sendfile.c
index 036aa7103a..52daf62036 100644
--- a/net/socket/net_sendfile.c
+++ b/net/socket/net_sendfile.c
@@ -492,7 +492,7 @@ static inline void sendfile_txnotify(FAR struct socket *psock,
     {
       /* Notify the device driver that send data is available */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
 #else
       netdev_ipv4_txnotify(conn->u.ipv4.raddr);
@@ -508,7 +508,7 @@ static inline void sendfile_txnotify(FAR struct socket *psock,
       /* Notify the device driver that send data is available */
 
       DEBUGASSERT(psock->s_domain == PF_INET6);
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
 #else
       netdev_ipv6_txnotify(conn->u.ipv6.raddr);
diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c
index 7f10853e80..d9e4f42c3e 100644
--- a/net/socket/recvfrom.c
+++ b/net/socket/recvfrom.c
@@ -1225,7 +1225,7 @@ static inline void recvfrom_udp_rxnotify(FAR struct socket *psock,
     {
       /* Notify the device driver of the receive ready */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
 #else
       netdev_ipv4_rxnotify(conn->u.ipv4.raddr);
@@ -1241,7 +1241,7 @@ static inline void recvfrom_udp_rxnotify(FAR struct socket *psock,
       /* Notify the device driver of the receive ready */
 
       DEBUGASSERT(psock->s_domain == PF_INET6);
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv6_rxnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
 #else
       netdev_ipv6_rxnotify(conn->u.ipv6.raddr);
diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c
index 32a5b7e25f..d7a8070676 100644
--- a/net/tcp/tcp_conn.c
+++ b/net/tcp/tcp_conn.c
@@ -104,7 +104,7 @@ static uint16_t g_last_tcp_port;
  ****************************************************************************/
 
 #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NETDEV_MULTINIC)
-static inline FAR struct tcp_conn_s *tcp_ipv4_listener(inaddr_t ipaddr,
+static inline FAR struct tcp_conn_s *tcp_ipv4_listener(in_addr_t ipaddr,
                                                        uint16_t portno)
 {
   FAR struct tcp_conn_s *conn;
@@ -207,7 +207,7 @@ static inline FAR struct tcp_conn_s *tcp_ipv6_ listener(net_ipv6addr_t ipaddr,
 
 #ifdef CONFIG_NETDEV_MULTINIC
 static FAR struct tcp_conn_s *
-  tcp_listener(uint8_t domain, FAR const union ip_binding_u *ipaddr,
+  tcp_listener(uint8_t domain, FAR const union ip_addr_u *ipaddr,
                uint16_t portno)
 {
 #ifdef CONFIG_NET_IPv4
@@ -521,7 +521,7 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn,
 
 #ifdef CONFIG_NETDEV_MULTINIC
   port = tcp_selectport(PF_INET,
-                       (FAR const union ip_addr_u ipaddr *)&addr->sin_addr.s_addr,
+                       (FAR const union ip_addr_u *)&addr->sin_addr.s_addr,
                         ntohs(addr->sin_port));
 #else
   port = tcp_selectport(ntohs(addr->sin_port));
@@ -539,7 +539,7 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn,
   conn->lport = addr->sin_port;
 
 #ifdef CONFIG_NETDEV_MULTINIC
-  net_ipv4addr_copy(conn->u.ipv4.laddr, ipaddr);
+  net_ipv4addr_copy(conn->u.ipv4.laddr, addr->sin_addr.s_addr);
 #endif
 
   return OK;
@@ -1100,7 +1100,13 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
 
   flags = net_lock();
 #ifdef CONFIG_NETDEV_MULTINIC
+#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
   port = tcp_selectport(conn->domain, &conn->u, ntohs(conn->lport));
+#elif defined(CONFIG_NET_IPv4)
+  port = tcp_selectport(PF_INET, &conn->u, ntohs(conn->lport));
+#else
+  port = tcp_selectport(PF_INET6, &conn->u, ntohs(conn->lport));
+#endif
 #else
   port = tcp_selectport(ntohs(conn->lport));
 #endif
diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c
index f8c0b02c18..db814cfb64 100644
--- a/net/tcp/tcp_send_buffered.c
+++ b/net/tcp/tcp_send_buffered.c
@@ -829,7 +829,7 @@ static inline void send_txnotify(FAR struct socket *psock,
     {
       /* Notify the device driver that send data is available */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
 #else
       netdev_ipv4_txnotify(conn->u.ipv4.raddr);
@@ -845,7 +845,7 @@ static inline void send_txnotify(FAR struct socket *psock,
       /* Notify the device driver that send data is available */
 
       DEBUGASSERT(psock->s_domain == PF_INET6);
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
 #else
       netdev_ipv6_txnotify(conn->u.ipv6.raddr);
diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c
index 0d4efbc1c3..9d7de805b2 100644
--- a/net/tcp/tcp_send_unbuffered.c
+++ b/net/tcp/tcp_send_unbuffered.c
@@ -615,7 +615,7 @@ static inline void send_txnotify(FAR struct socket *psock,
     {
       /* Notify the device driver that send data is available */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
 #else
       netdev_ipv4_txnotify(conn->u.ipv4.raddr);
@@ -631,7 +631,7 @@ static inline void send_txnotify(FAR struct socket *psock,
       /* Notify the device driver that send data is available */
 
       DEBUGASSERT(psock->s_domain == PF_INET6);
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
 #else
       netdev_ipv6_txnotify(conn->u.ipv6.raddr);
diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c
index a720043184..2592aa7dca 100644
--- a/net/udp/udp_conn.c
+++ b/net/udp/udp_conn.c
@@ -596,7 +596,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr)
        * interfaces for receiving (Sending will use the default port).
        */
 
-      net_ipv4addr_copy(conn->u.ipv4.laddr, inaddr->sin_addr.s_addr;);
+      net_ipv4addr_copy(conn->u.ipv4.laddr, inaddr->sin_addr.s_addr);
 #endif /* CONFIG_NETDEV_MULTINIC */
     }
 #endif /* CONFIG_NET_IPv4 */
@@ -646,7 +646,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr)
       /* Is any other UDP connection already bound to this address and port? */
 
 #ifdef CONFIG_NETDEV_MULTINIC
-      if (!udp_find_conn(conn->domain, &config->u, portno))
+      if (!udp_find_conn(conn->domain, &conn->u, portno))
 #else
       if (!udp_find_conn(portno))
 #endif
diff --git a/net/udp/udp_sendto.c b/net/udp/udp_sendto.c
index 3af854cb88..289cc87c49 100644
--- a/net/udp/udp_sendto.c
+++ b/net/udp/udp_sendto.c
@@ -320,7 +320,7 @@ static inline void sendto_txnotify(FAR struct socket *psock,
     {
       /* Notify the device driver that send data is available */
 
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
 #else
       netdev_ipv4_txnotify(conn->u.ipv4.raddr);
@@ -336,7 +336,7 @@ static inline void sendto_txnotify(FAR struct socket *psock,
       /* Notify the device driver that send data is available */
 
       DEBUGASSERT(psock->s_domain == PF_INET6);
-#ifdef CONFIG_NET_MULTILINK
+#ifdef CONFIG_NETDEV_MULTINIC
       netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
 #else
       netdev_ipv6_txnotify(conn->u.ipv6.raddr);