浏览代码

[components][dfs] AND [components][net][sal] 适配 LWIP210

Signed-off-by: MurphyZhao <d2014zjt@163.com>
MurphyZhao 6 年之前
父节点
当前提交
58a6b51236

+ 7 - 2
components/dfs/include/dfs_poll.h

@@ -15,6 +15,7 @@
 #ifdef RT_USING_POSIX
 #include <sys/time.h> /* for struct timeval */
 
+#if !defined(POLLIN) && !defined(POLLOUT)
 #define POLLIN          (0x01)
 #define POLLRDNORM      (0x01)
 #define POLLRDBAND      (0x01)
@@ -40,6 +41,10 @@ struct pollfd
 };
 
 int poll(struct pollfd *fds, nfds_t nfds, int timeout);
-#endif
+#else /* !defined(POLLIN) && !defined(POLLOUT) */
+#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
+int poll(struct pollfd *fds, nfds_t nfds, int timeout);
+#endif /* !defined(POLLIN) && !defined(POLLOUT) */
+#endif /* RT_USING_POSIX */
 
-#endif
+#endif /* DFS_POLL_H__ */

+ 21 - 2
components/net/sal_socket/impl/af_inet_lwip.c

@@ -33,6 +33,15 @@
 #ifdef SAL_USING_LWIP
 
 #ifdef SAL_USING_POSIX
+
+#if LWIP_VERSION >= 0x20100ff
+#include <lwip/priv/sockets_priv.h>
+
+#if LWIP_NETCONN_FULLDUPLEX
+#error "Not support"
+#endif
+
+#else /* LWIP_VERSION < 0x20100ff */
 /*
  * Re-define lwip socket
  *
@@ -64,6 +73,7 @@ struct lwip_sock {
 
     rt_wqueue_t wait_head;
 };
+#endif /* LWIP_VERSION >= 0x20100ff */
 
 extern struct lwip_sock *lwip_tryget_socket(int s);
 
@@ -136,7 +146,11 @@ static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len
         break;
     }
 
-    if (sock->lastdata || sock->rcvevent > 0)
+#if LWIP_VERSION >= 0x20100ff
+    if ((void*)(sock->lastdata.pbuf) || (sock->rcvevent > 0))
+#else
+    if ((void*)(sock->lastdata) || (sock->rcvevent > 0))
+#endif
         event |= POLLIN;
     if (sock->sendevent)
         event |= POLLOUT;
@@ -226,7 +240,12 @@ static int inet_poll(struct dfs_fd *file, struct rt_pollreq *req)
         rt_poll_add(&sock->wait_head, req);
 
         level = rt_hw_interrupt_disable();
-        if (sock->lastdata || sock->rcvevent)
+
+#if LWIP_VERSION >= 0x20100ff
+        if ((void*)(sock->lastdata.pbuf) || sock->rcvevent)
+#else
+        if ((void*)(sock->lastdata) || sock->rcvevent)
+#endif
         {
             mask |= POLLIN;
         }

+ 5 - 0
components/net/sal_socket/include/sal.h

@@ -51,8 +51,13 @@ struct proto_ops
     int (*listen)     (int s, int backlog);
     int (*connect)    (int s, const struct sockaddr *name, socklen_t namelen);
     int (*accept)     (int s, struct sockaddr *addr, socklen_t *addrlen);
+#if LWIP_VERSION >= 0x20100ff
+    ssize_t (*sendto)     (int s, const void *data, size_t size, int flags, const struct sockaddr *to, socklen_t tolen);
+    ssize_t (*recvfrom)   (int s, void *mem, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
+#else
     int (*sendto)     (int s, const void *data, size_t size, int flags, const struct sockaddr *to, socklen_t tolen);
     int (*recvfrom)   (int s, void *mem, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
+#endif
     int (*getsockopt) (int s, int level, int optname, void *optval, socklen_t *optlen);
     int (*setsockopt) (int s, int level, int optname, const void *optval, socklen_t optlen);
     int (*shutdown)   (int s, int how);