[PATCH rtems-lwip v1 2/5] lwip: Finish cleaning up source imports

Kinsey Moore kinsey.moore at oarcorp.com
Thu Aug 25 19:43:29 UTC 2022


This removes all changes that weren't gated properly on __rtems__
including moving getaddrinfo to rtemslwip/. The imported lwip source is
now ready to be updated when necessary.
---
 lwip/src/api/api_msg.c            |  2 --
 lwip/src/api/netdb.c              | 41 ------------------------------
 lwip/src/api/sockets.c            |  9 -------
 lwip/src/core/memp.c              |  2 +-
 lwip/src/core/netif.c             |  2 +-
 lwip/src/core/tcp.c               |  2 --
 lwip/src/include/lwip/opt.h       |  2 ++
 lwip/src/include/lwip/sockets.h   |  2 +-
 lwip/src/include/lwip/sys.h       |  1 -
 lwip/src/netif/ethernet.c         |  2 +-
 rtemslwip/common/network_compat.c | 42 +++++++++++++++++++++++++++++++
 11 files changed, 48 insertions(+), 59 deletions(-)

diff --git a/lwip/src/api/api_msg.c b/lwip/src/api/api_msg.c
index ce485d5..3953102 100644
--- a/lwip/src/api/api_msg.c
+++ b/lwip/src/api/api_msg.c
@@ -54,8 +54,6 @@
 #include "lwip/mld6.h"
 #include "lwip/priv/tcpip_priv.h"
 
-#include "arch/sys_arch.h"
-
 #include <string.h>
 
 /* netconns are polled once per second (e.g. continue write on memory error) */
diff --git a/lwip/src/api/netdb.c b/lwip/src/api/netdb.c
index 5217602..8771425 100644
--- a/lwip/src/api/netdb.c
+++ b/lwip/src/api/netdb.c
@@ -45,7 +45,6 @@
 #include "lwip/ip_addr.h"
 #include "lwip/api.h"
 #include "lwip/dns.h"
-#include "lwip/sockets.h"
 
 #include <string.h> /* memset */
 #include <stdlib.h> /* atoi */
@@ -412,44 +411,4 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
   return 0;
 }
 
-int
-getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node,
-    size_t nodelen, char *service, size_t servicelen, int flags)
-{
-    int af; 
-    const struct sockaddr_in *sa_in = (const struct sockaddr_in *)sa;
-
-    (void) salen;
-
-    af = sa->sa_family;
-    if (af != AF_INET) {
-        return EAI_FAMILY;
-    }   
-
-    if ((flags & NI_NAMEREQD) != 0) {
-        return EAI_NONAME;
-    }   
-
-    /* FIXME: This return just the address value. Try resolving instead. */
-    if (node != NULL && nodelen > 0) {
-        if (lwip_inet_ntop(af, &sa_in->sin_addr, node, nodelen) == NULL) {
-            return EAI_FAIL;
-        }
-    }   
-
-    if (service != NULL && servicelen > 0) {
-        in_port_t port = ntohs(sa_in->sin_port);
-        int rv; 
-
-        rv = snprintf(service, servicelen, "%u", port);
-        if (rv <= 0) {
-            return EAI_FAIL;
-        } else if ((unsigned)rv >= servicelen) {
-            return EAI_OVERFLOW;
-        }
-    }   
-
-    return 0;
-}
-
 #endif /* LWIP_DNS && LWIP_SOCKET */
diff --git a/lwip/src/api/sockets.c b/lwip/src/api/sockets.c
index f47e68e..cb7df91 100644
--- a/lwip/src/api/sockets.c
+++ b/lwip/src/api/sockets.c
@@ -54,7 +54,6 @@
 #include "lwip/netif.h"
 #include "lwip/priv/tcpip_priv.h"
 #include "lwip/mld6.h"
-#include "arch/sys_arch.h"
 #if LWIP_CHECKSUM_ON_COPY
 #include "lwip/inet_chksum.h"
 #endif
@@ -3274,14 +3273,6 @@ lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t opt
   return err ? -1 : 0;
 }
 
-/*
-int
-setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
-{
-    return lwip_setsockopt(s, level, optname, optval, optlen);
-}
-*/
-
 #if !LWIP_TCPIP_CORE_LOCKING
 /** lwip_setsockopt_callback: only used without CORE_LOCKING
  * to get into the tcpip_thread
diff --git a/lwip/src/core/memp.c b/lwip/src/core/memp.c
index 1917826..352ce5a 100644
--- a/lwip/src/core/memp.c
+++ b/lwip/src/core/memp.c
@@ -327,7 +327,7 @@ memp_malloc_pool_fn(const struct memp_desc *desc, const char *file, const int li
 
 /**
  * Get an element from a specific pool.
-                1 *
+ *
  * @param type the pool to get an element from
  *
  * @return a pointer to the allocated memory or a NULL pointer on error
diff --git a/lwip/src/core/netif.c b/lwip/src/core/netif.c
index e432823..15200a2 100644
--- a/lwip/src/core/netif.c
+++ b/lwip/src/core/netif.c
@@ -72,7 +72,7 @@
 #endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
 #endif /* ENABLE_LOOPBACK */
 
-#include <netif/ethernet.h>
+#include "netif/ethernet.h"
 
 #if LWIP_AUTOIP
 #include "lwip/autoip.h"
diff --git a/lwip/src/core/tcp.c b/lwip/src/core/tcp.c
index 2996ee7..bd7d64e 100644
--- a/lwip/src/core/tcp.c
+++ b/lwip/src/core/tcp.c
@@ -724,14 +724,12 @@ tcp_bind(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
 #endif /* SO_REUSE */
           {
             /* @todo: check accept_any_ip_version */
-#if 0
             if ((IP_IS_V6(ipaddr) == IP_IS_V6_VAL(cpcb->local_ip)) &&
                 (ip_addr_isany(&cpcb->local_ip) ||
                  ip_addr_isany(ipaddr) ||
                  ip_addr_cmp(&cpcb->local_ip, ipaddr))) {
               return ERR_USE;
             }
-#endif /* 0 */
           }
         }
       }
diff --git a/lwip/src/include/lwip/opt.h b/lwip/src/include/lwip/opt.h
index b19922f..38edf41 100644
--- a/lwip/src/include/lwip/opt.h
+++ b/lwip/src/include/lwip/opt.h
@@ -923,9 +923,11 @@
 #define LWIP_DHCP                       0
 #endif /* !LWIP_IPV4 */
 
+#ifdef __rtems__
 #ifndef LWIP_DHCP_TIMEOUT
 #define LWIP_DHCP_TIMEOUT               100
 #endif
+#endif
 
 /**
  * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address.
diff --git a/lwip/src/include/lwip/sockets.h b/lwip/src/include/lwip/sockets.h
index be94852..705ae46 100644
--- a/lwip/src/include/lwip/sockets.h
+++ b/lwip/src/include/lwip/sockets.h
@@ -53,6 +53,7 @@
 #undef TCP_MSS
 #endif
 
+#include <sys/socket.h>
 #endif /* __rtems__ */
 
 #include "lwip/opt.h"
@@ -64,7 +65,6 @@
 #include "lwip/err.h"
 #include "lwip/inet.h"
 #include "lwip/errno.h"
-#include <sys/socket.h>
 
 #include <string.h>
 
diff --git a/lwip/src/include/lwip/sys.h b/lwip/src/include/lwip/sys.h
index 1933590..168e465 100644
--- a/lwip/src/include/lwip/sys.h
+++ b/lwip/src/include/lwip/sys.h
@@ -38,7 +38,6 @@
 #define LWIP_HDR_SYS_H
 
 #include "lwip/opt.h"
-#include "arch/sys_arch.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/lwip/src/netif/ethernet.c b/lwip/src/netif/ethernet.c
index bd32201..dd171e2 100644
--- a/lwip/src/netif/ethernet.c
+++ b/lwip/src/netif/ethernet.c
@@ -40,7 +40,7 @@
 
 #include "lwip/opt.h"
 
-#ifdef LWIP_ETHERNET
+#if LWIP_ARP || LWIP_ETHERNET
 
 #include "netif/ethernet.h"
 #include "lwip/def.h"
diff --git a/rtemslwip/common/network_compat.c b/rtemslwip/common/network_compat.c
index e13c56a..c072d54 100644
--- a/rtemslwip/common/network_compat.c
+++ b/rtemslwip/common/network_compat.c
@@ -29,6 +29,8 @@
 #include <arpa/inet.h>
 #include <lwip/ip4_addr.h>
 #include <lwip/ip6_addr.h>
+#include <lwip/sockets.h>
+#include <lwip/netdb.h>
 
 in_addr_t inet_addr(const char *cp)
 {
@@ -55,3 +57,43 @@ uint16_t htons(uint16_t x)
 {
   return lwip_htons(x);
 }
+
+int
+getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node,
+    size_t nodelen, char *service, size_t servicelen, int flags)
+{
+    int af;
+    const struct sockaddr_in *sa_in = (const struct sockaddr_in *)sa;
+
+    (void) salen;
+
+    af = sa->sa_family;
+    if (af != AF_INET) {
+        return EAI_FAMILY;
+    }
+
+    if ((flags & NI_NAMEREQD) != 0) {
+        return EAI_NONAME;
+    }
+
+    /* FIXME: This return just the address value. Try resolving instead. */
+    if (node != NULL && nodelen > 0) {
+        if (lwip_inet_ntop(af, &sa_in->sin_addr, node, nodelen) == NULL) {
+            return EAI_FAIL;
+        }
+    }
+
+    if (service != NULL && servicelen > 0) {
+        in_port_t port = ntohs(sa_in->sin_port);
+        int rv;
+
+        rv = snprintf(service, servicelen, "%u", port);
+        if (rv <= 0) {
+            return EAI_FAIL;
+        } else if ((unsigned)rv >= servicelen) {
+            return EAI_OVERFLOW;
+        }
+    }
+
+    return 0;
+}
-- 
2.30.2



More information about the devel mailing list