diff options
| author | MurphyZhao <[email protected]> | 2018-11-01 18:20:03 +0800 |
|---|---|---|
| committer | MurphyZhao <[email protected]> | 2018-11-01 18:21:41 +0800 |
| commit | 58a6b51236498de0bf8cbdb6ee7b172ebc442314 (patch) | |
| tree | 4adb5031a25f3403b3027c42db54cc8189da10f8 | |
| parent | f08039ff6fc0c833bc7b257685e796e21482cc58 (diff) | |
[components][dfs] AND [components][net][sal] 适配 LWIP210
Signed-off-by: MurphyZhao <[email protected]>
| -rw-r--r-- | components/dfs/include/dfs_poll.h | 9 | ||||
| -rw-r--r-- | components/net/sal_socket/impl/af_inet_lwip.c | 23 | ||||
| -rw-r--r-- | components/net/sal_socket/include/sal.h | 5 |
3 files changed, 33 insertions, 4 deletions
diff --git a/components/dfs/include/dfs_poll.h b/components/dfs/include/dfs_poll.h index 3728b86248..066363d6fc 100644 --- a/components/dfs/include/dfs_poll.h +++ b/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__ */ diff --git a/components/net/sal_socket/impl/af_inet_lwip.c b/components/net/sal_socket/impl/af_inet_lwip.c index 41ea9ac968..b1e04373c6 100644 --- a/components/net/sal_socket/impl/af_inet_lwip.c +++ b/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; } diff --git a/components/net/sal_socket/include/sal.h b/components/net/sal_socket/include/sal.h index 68248742d6..ba5589c734 100644 --- a/components/net/sal_socket/include/sal.h +++ b/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); |
