summaryrefslogtreecommitdiff
path: root/components/net/sal_socket/impl
diff options
context:
space:
mode:
authorchenyong <[email protected]>2018-08-27 19:50:37 +0800
committerchenyong <[email protected]>2018-08-27 19:50:37 +0800
commit6d702e579f533179e5b158a5daae6a6e78ca2d70 (patch)
tree5136c29fb8ab6d35820bd1110d17493a0cd01614 /components/net/sal_socket/impl
parent2d894b41026e4253efd3a60184c3e5e0c17d6883 (diff)
[net][sal] Remove DFS dependencies in the SAL
Diffstat (limited to 'components/net/sal_socket/impl')
-rw-r--r--components/net/sal_socket/impl/af_inet_at.c4
-rw-r--r--components/net/sal_socket/impl/af_inet_lwip.c23
2 files changed, 16 insertions, 11 deletions
diff --git a/components/net/sal_socket/impl/af_inet_at.c b/components/net/sal_socket/impl/af_inet_at.c
index 3337af4194..f921e721eb 100644
--- a/components/net/sal_socket/impl/af_inet_at.c
+++ b/components/net/sal_socket/impl/af_inet_at.c
@@ -22,6 +22,8 @@
* 2018-06-06 ChenYong First version
*/
+#include <rtthread.h>
+
#include <netdb.h>
#include <sal.h>
@@ -91,8 +93,6 @@ static const struct proto_ops at_inet_stream_ops =
#ifdef SAL_USING_POSIX
at_poll,
-#else
- NULL,
#endif /* SAL_USING_POSIX */
};
diff --git a/components/net/sal_socket/impl/af_inet_lwip.c b/components/net/sal_socket/impl/af_inet_lwip.c
index c45e39e39e..563f8947d0 100644
--- a/components/net/sal_socket/impl/af_inet_lwip.c
+++ b/components/net/sal_socket/impl/af_inet_lwip.c
@@ -44,6 +44,7 @@
#endif
#endif
+#ifdef SAL_USING_POSIX
/*
* Re-define lwip socket
*
@@ -73,9 +74,7 @@ struct lwip_sock {
/** counter of how many threads are waiting for this socket using select */
SELWAIT_T select_waiting;
-#ifdef SAL_USING_POSIX
rt_wqueue_t wait_head;
-#endif
};
extern struct lwip_sock *lwip_tryget_socket(int s);
@@ -160,14 +159,14 @@ static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len
if (event)
{
-#ifdef SAL_USING_POSIX
rt_wqueue_wakeup(&sock->wait_head, (void*) event);
-#endif
}
}
+#endif /* SAL_USING_POSIX */
static int inet_socket(int domain, int type, int protocol)
{
+#ifdef SAL_USING_POSIX
int socket;
socket = lwip_socket(domain, type, protocol);
@@ -178,17 +177,18 @@ static int inet_socket(int domain, int type, int protocol)
lwsock = lwip_tryget_socket(socket);
lwsock->conn->callback = event_callback;
-#ifdef SAL_USING_POSIX
rt_wqueue_init(&lwsock->wait_head);
-#endif
-
}
return socket;
+#else
+ return lwip_socket(domain, type, protocol);
+#endif /* SAL_USING_POSIX */
}
static int inet_accept(int socket, struct sockaddr *addr, socklen_t *addrlen)
{
+#ifdef SAL_USING_POSIX
int new_socket;
new_socket = lwip_accept(socket, addr, addrlen);
@@ -198,12 +198,13 @@ static int inet_accept(int socket, struct sockaddr *addr, socklen_t *addrlen)
lwsock = lwip_tryget_socket(new_socket);
-#ifdef SAL_USING_POSIX
rt_wqueue_init(&lwsock->wait_head);
-#endif
}
return new_socket;
+#else
+ return lwip_accept(socket, addr, addrlen);
+#endif /* SAL_USING_POSIX */
}
static int inet_getsockname(int socket, struct sockaddr *name, socklen_t *namelen)
@@ -216,6 +217,7 @@ static int inet_getsockname(int socket, struct sockaddr *name, socklen_t *namele
return lwip_getsockname(socket, name, namelen);
}
+#ifdef SAL_USING_POSIX
static int inet_poll(struct dfs_fd *file, struct rt_pollreq *req)
{
int mask = 0;
@@ -253,6 +255,7 @@ static int inet_poll(struct dfs_fd *file, struct rt_pollreq *req)
return mask;
}
+#endif
static const struct proto_ops lwip_inet_stream_ops = {
inet_socket,
@@ -270,7 +273,9 @@ static const struct proto_ops lwip_inet_stream_ops = {
lwip_getpeername,
inet_getsockname,
lwip_ioctl,
+#ifdef SAL_USING_POSIX
inet_poll,
+#endif
};
static int inet_create(struct sal_socket *socket, int type, int protocol)