Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
6d702e57
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d702e57
编写于
8月 27, 2018
作者:
Lawlieta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[net][sal] Remove DFS dependencies in the SAL
上级
2d894b41
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
66 addition
and
22 deletion
+66
-22
components/net/Kconfig
components/net/Kconfig
+12
-3
components/net/lwip-2.0.2/SConscript
components/net/lwip-2.0.2/SConscript
+1
-1
components/net/sal_socket/SConscript
components/net/sal_socket/SConscript
+3
-2
components/net/sal_socket/impl/af_inet_at.c
components/net/sal_socket/impl/af_inet_at.c
+2
-2
components/net/sal_socket/impl/af_inet_lwip.c
components/net/sal_socket/impl/af_inet_lwip.c
+14
-9
components/net/sal_socket/include/sal.h
components/net/sal_socket/include/sal.h
+8
-1
components/net/sal_socket/include/socket/sys_socket/sys/socket.h
...nts/net/sal_socket/include/socket/sys_socket/sys/socket.h
+24
-4
components/net/sal_socket/src/sal_socket.c
components/net/sal_socket/src/sal_socket.c
+2
-0
未找到文件。
components/net/Kconfig
浏览文件 @
6d702e57
...
...
@@ -5,7 +5,6 @@ menu "Socket abstraction layer"
config RT_USING_SAL
bool "Enable socket abstraction layer"
default n
select RT_USING_DFS
if RT_USING_SAL
...
...
@@ -28,14 +27,24 @@ config RT_USING_SAL
config SAL_USING_POSIX
bool "Enable BSD socket operated by file system API"
default y if RT_USING_POSIX
default n
select RT_USING_DFS
select RT_USING_LIBC
select RT_USING_POSIX
default n
help
Let BSD socket operated by file system API, such as read/write and involveed in select/poll POSIX APIs.
if !SAL_USING_POSIX
config SAL_SOCKETS_NUM
int "the maximum number of sockets"
default 16
endif
config SAL_PROTO_FAMILIES_NUM
int "the
number of protocol family
"
int "the
maximum number of protocol families
"
default 4
endif
...
...
components/net/lwip-2.0.2/SConscript
浏览文件 @
6d702e57
...
...
@@ -67,7 +67,7 @@ path = [GetCurrentDir() + '/src',
GetCurrentDir
()
+
'/src/arch/include'
,
GetCurrentDir
()
+
'/src/include/netif'
]
if
not
GetDepend
(
'RT_USING_
POSIX'
)
or
not
GetDepend
(
'SAL_USING_POSIX
'
):
if
not
GetDepend
(
'RT_USING_
SAL
'
):
path
+=
[
GetCurrentDir
()
+
'/src/include/posix'
]
if
GetDepend
([
'RT_LWIP_SNMP'
]):
...
...
components/net/sal_socket/SConscript
浏览文件 @
6d702e57
...
...
@@ -5,10 +5,9 @@ from building import *
cwd
=
GetCurrentDir
()
src
=
Glob
(
'src/*.c'
)
src
+=
Glob
(
'socket/
*
.c'
)
src
+=
Glob
(
'socket/
net_netdb
.c'
)
CPPPATH
=
[
cwd
+
'/include'
]
CPPPATH
+=
[
cwd
+
'/include/dfs_net'
]
CPPPATH
+=
[
cwd
+
'/include/socket'
]
if
GetDepend
(
'SAL_USING_LWIP'
):
...
...
@@ -21,6 +20,8 @@ if GetDepend('SAL_USING_LWIP') or GetDepend('SAL_USING_AT'):
CPPPATH
+=
[
cwd
+
'/impl'
]
if
GetDepend
(
'SAL_USING_POSIX'
):
CPPPATH
+=
[
cwd
+
'/include/dfs_net'
]
src
+=
Glob
(
'socket/net_sockets.c'
)
src
+=
Glob
(
'dfs_net/*.c'
)
if
not
GetDepend
(
'HAVE_SYS_SELECT_H'
):
...
...
components/net/sal_socket/impl/af_inet_at.c
浏览文件 @
6d702e57
...
...
@@ -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 */
};
...
...
components/net/sal_socket/impl/af_inet_lwip.c
浏览文件 @
6d702e57
...
...
@@ -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
)
...
...
components/net/sal_socket/include/sal.h
浏览文件 @
6d702e57
...
...
@@ -25,9 +25,12 @@
#ifndef SAL_H__
#define SAL_H__
#include <dfs_file.h>
#include <rtdevice.h>
#ifdef SAL_USING_POSIX
#include <dfs_file.h>
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -40,7 +43,9 @@ typedef uint32_t socklen_t;
#define SAL_SOCKET_MAGIC 0x5A10
/* The maximum number of sockets structure */
#ifndef SAL_SOCKETS_NUM
#define SAL_SOCKETS_NUM DFS_FD_MAX
#endif
/* The maximum number of protocol families */
#ifndef SAL_PROTO_FAMILIES_NUM
...
...
@@ -68,7 +73,9 @@ struct proto_ops
int
(
*
getpeername
)(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
);
int
(
*
getsockname
)(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
);
int
(
*
ioctlsocket
)(
int
s
,
long
cmd
,
void
*
arg
);
#ifdef SAL_USING_POSIX
int
(
*
poll
)
(
struct
dfs_fd
*
file
,
struct
rt_pollreq
*
req
);
#endif
};
struct
sal_socket
...
...
components/net/sal_socket/include/socket/sys_socket/sys/socket.h
浏览文件 @
6d702e57
...
...
@@ -26,19 +26,21 @@
#ifndef SYS_SOCKET_H_
#define SYS_SOCKET_H_
#include <rtthread.h>
#include <sal_socket.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef SAL_USING_POSIX
int
accept
(
int
s
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
);
int
bind
(
int
s
,
const
struct
sockaddr
*
name
,
socklen_t
namelen
);
int
shutdown
(
int
s
,
int
how
);
int
getpeername
(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
);
int
getsockname
(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
);
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
getpeername
(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
);
int
getsockname
(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
);
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
connect
(
int
s
,
const
struct
sockaddr
*
name
,
socklen_t
namelen
);
int
listen
(
int
s
,
int
backlog
);
int
recv
(
int
s
,
void
*
mem
,
size_t
len
,
int
flags
);
...
...
@@ -50,6 +52,24 @@ int sendto(int s, const void *dataptr, size_t size, int flags,
int
socket
(
int
domain
,
int
type
,
int
protocol
);
int
closesocket
(
int
s
);
int
ioctlsocket
(
int
s
,
long
cmd
,
void
*
arg
);
#else
#define accept(s, addr, addrlen) sal_accept(s, addr, addrlen)
#define bind(s, name, namelen) sal_bind(s, name, namelen)
#define shutdown(s, how) sal_shutdown(s, how)
#define getpeername(s, name, namelen) sal_getpeername(s, name, namelen)
#define getsockname(s, name, namelen) sal_getsockname(s, name, namelen)
#define getsockopt(s, level, optname, optval, optlen) sal_getsockopt(s, level, optname, optval, optlen)
#define setsockopt(s, level, optname, optval, optlen) sal_setsockopt(s, level, optname, optval, optlen)
#define connect(s, name, namelen) sal_connect(s, name, namelen)
#define listen(s, backlog) sal_listen(s, backlog)
#define recv(s, mem, len, flags) sal_recvfrom(s, mem, len, flags, NULL, NULL)
#define recvfrom(s, mem, len, flags, from, fromlen) sal_recvfrom(s, mem, len, flags, from, fromlen)
#define send(s, dataptr, size, flags) sal_sendto(s, dataptr, size, flags, NULL, NULL)
#define sendto(s, dataptr, size, flags, to, tolen) sal_sendto(s, dataptr, size, flags, to, tolen)
#define socket(domain, type, protocol) sal_socket(domain, type, protocol)
#define closesocket(s) sal_closesocket(s)
#define ioctlsocket(s, cmd, arg) sal_ioctlsocket(s, cmd, arg)
#endif
/* SAL_USING_POSIX */
#ifdef __cplusplus
}
...
...
components/net/sal_socket/src/sal_socket.c
浏览文件 @
6d702e57
...
...
@@ -705,6 +705,7 @@ int sal_ioctlsocket(int socket, long cmd, void *arg)
return
sock
->
ops
->
ioctlsocket
((
int
)
sock
->
user_data
,
cmd
,
arg
);
}
#ifdef SAL_USING_POSIX
int
sal_poll
(
struct
dfs_fd
*
file
,
struct
rt_pollreq
*
req
)
{
struct
sal_socket
*
sock
;
...
...
@@ -723,6 +724,7 @@ int sal_poll(struct dfs_fd *file, struct rt_pollreq *req)
return
sock
->
ops
->
poll
(
file
,
req
);
}
#endif
struct
hostent
*
sal_gethostbyname
(
const
char
*
name
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录