Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
天中雨水
rt-thread
提交
86756c0d
R
rt-thread
项目概览
天中雨水
/
rt-thread
该项目与 Fork 源项目分叉
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
86756c0d
编写于
12月 09, 2020
作者:
B
Bernard Xiong
提交者:
GitHub
12月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4065 from longtengmcu/master
fix at socket and sal_socket bug
上级
3123e626
962acc33
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
34 deletion
+77
-34
components/net/at/at_socket/at_socket.c
components/net/at/at_socket/at_socket.c
+9
-16
components/net/netdev/src/netdev.c
components/net/netdev/src/netdev.c
+10
-4
components/net/sal_socket/src/sal_socket.c
components/net/sal_socket/src/sal_socket.c
+58
-14
未找到文件。
components/net/at/at_socket/at_socket.c
浏览文件 @
86756c0d
...
...
@@ -821,24 +821,17 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
goto
__exit
;
}
else
{
if
(
sock
->
state
==
AT_SOCKET_CONNECT
)
{
/* get receive buffer to receiver ring buffer */
rt_mutex_take
(
sock
->
recv_lock
,
RT_WAITING_FOREVER
);
recv_len
=
at_recvpkt_get
(
&
(
sock
->
recvpkt_list
),
(
char
*
)
mem
,
len
);
rt_mutex_release
(
sock
->
recv_lock
);
if
(
recv_len
>
0
)
{
break
;
}
}
else
{
/* get receive buffer to receiver ring buffer */
rt_mutex_take
(
sock
->
recv_lock
,
RT_WAITING_FOREVER
);
recv_len
=
at_recvpkt_get
(
&
(
sock
->
recvpkt_list
),
(
char
*
)
mem
,
len
);
rt_mutex_release
(
sock
->
recv_lock
);
if
(
recv_len
>
0
)
{
LOG_D
(
"received data exit, current socket (%d) is closed by remote."
,
socket
);
result
=
0
;
goto
__exit
;
break
;
}
}
}
...
...
components/net/netdev/src/netdev.c
浏览文件 @
86756c0d
...
...
@@ -856,7 +856,7 @@ void netdev_low_level_set_dhcp_status(struct netdev *netdev, rt_bool_t is_enable
static
void
netdev_list_if
(
void
)
{
#define NETDEV_IFCONFIG_MAC_MAX_LEN 6
#define NETDEV_IFCONFIG_I
EM
I_MAX_LEN 8
#define NETDEV_IFCONFIG_I
ME
I_MAX_LEN 8
rt_ubase_t
index
;
rt_slist_t
*
node
=
RT_NULL
;
...
...
@@ -894,9 +894,15 @@ static void netdev_list_if(void)
{
/* two numbers are displayed at one time*/
if
(
netdev
->
hwaddr
[
index
]
<
10
&&
index
!=
netdev
->
hwaddr_len
-
1
)
rt_kprintf
(
"0"
);
rt_kprintf
(
"%d"
,
netdev
->
hwaddr
[
index
]);
{
rt_kprintf
(
"%02d"
,
netdev
->
hwaddr
[
index
]);
}
else
{
rt_kprintf
(
"%d"
,
netdev
->
hwaddr
[
index
]);
}
}
}
...
...
components/net/sal_socket/src/sal_socket.c
浏览文件 @
86756c0d
...
...
@@ -41,6 +41,13 @@ struct sal_socket_table
struct
sal_socket
**
sockets
;
};
/* record the netdev and res table*/
struct
sal_netdev_res_table
{
struct
addrinfo
*
res
;
struct
netdev
*
netdev
;
};
#ifdef SAL_USING_TLS
/* The global TLS protocol options */
static
struct
sal_proto_tls
*
proto_tls
;
...
...
@@ -50,6 +57,7 @@ static struct sal_proto_tls *proto_tls;
static
struct
sal_socket_table
socket_table
;
static
struct
rt_mutex
sal_core_lock
;
static
rt_bool_t
init_ok
=
RT_FALSE
;
static
struct
sal_netdev_res_table
sal_dev_res_tbl
[
SAL_SOCKETS_NUM
];
#define IS_SOCKET_PROTO_TLS(sock) (((sock)->protocol == PROTOCOL_TLS) || \
((sock)->protocol == PROTOCOL_DTLS))
...
...
@@ -90,6 +98,11 @@ do {
((pf) = (struct sal_proto_family *) (netdev)->sal_user_data) != RT_NULL && \
(pf)->netdb_ops->ops) \
#define SAL_NETDBOPS_VALID(netdev, pf, ops) \
((netdev) && \
((pf) = (struct sal_proto_family *) (netdev)->sal_user_data) != RT_NULL && \
(pf)->netdb_ops->ops) \
/**
* SAL (Socket Abstraction Layer) initialize.
*
...
...
@@ -116,6 +129,9 @@ int sal_init(void)
return
-
1
;
}
/*init the dev_res table */
rt_memset
(
sal_dev_res_tbl
,
0
,
sizeof
(
sal_dev_res_tbl
));
/* create sal socket lock */
rt_mutex_init
(
&
sal_core_lock
,
"sal_lock"
,
RT_IPC_FLAG_FIFO
);
...
...
@@ -1087,10 +1103,12 @@ int sal_getaddrinfo(const char *nodename,
{
struct
netdev
*
netdev
=
netdev_default
;
struct
sal_proto_family
*
pf
;
int
ret
=
0
;
rt_uint32_t
i
=
0
;
if
(
SAL_NETDEV_NETDBOPS_VALID
(
netdev
,
pf
,
getaddrinfo
))
{
ret
urn
pf
->
netdb_ops
->
getaddrinfo
(
nodename
,
servname
,
hints
,
res
);
ret
=
pf
->
netdb_ops
->
getaddrinfo
(
nodename
,
servname
,
hints
,
res
);
}
else
{
...
...
@@ -1098,30 +1116,56 @@ int sal_getaddrinfo(const char *nodename,
netdev
=
netdev_get_first_by_flags
(
NETDEV_FLAG_UP
);
if
(
SAL_NETDEV_NETDBOPS_VALID
(
netdev
,
pf
,
getaddrinfo
))
{
return
pf
->
netdb_ops
->
getaddrinfo
(
nodename
,
servname
,
hints
,
res
);
ret
=
pf
->
netdb_ops
->
getaddrinfo
(
nodename
,
servname
,
hints
,
res
);
}
else
{
ret
=
-
1
;
}
}
return
-
1
;
if
(
ret
==
RT_EOK
)
{
/*record the netdev and res*/
for
(
i
=
0
;
i
<
SAL_SOCKETS_NUM
;
i
++
)
{
if
(
sal_dev_res_tbl
[
i
].
res
==
RT_NULL
)
{
sal_dev_res_tbl
[
i
].
res
=
*
res
;
sal_dev_res_tbl
[
i
].
netdev
=
netdev
;
break
;
}
}
RT_ASSERT
((
i
<
SAL_SOCKETS_NUM
));
}
return
ret
;
}
void
sal_freeaddrinfo
(
struct
addrinfo
*
ai
)
{
struct
netdev
*
netdev
=
netdev_default
;
struct
sal_proto_family
*
pf
;
struct
netdev
*
netdev
=
RT_NULL
;
struct
sal_proto_family
*
pf
=
RT_NULL
;
rt_uint32_t
i
=
0
;
if
(
SAL_NETDEV_NETDBOPS_VALID
(
netdev
,
pf
,
freeaddrinfo
))
{
pf
->
netdb_ops
->
freeaddrinfo
(
ai
);
}
else
/*when use the multi netdev, it must free the ai use the getaddrinfo netdev */
for
(
i
=
0
;
i
<
SAL_SOCKETS_NUM
;
i
++
)
{
/* get the first network interface device with up status */
netdev
=
netdev_get_first_by_flags
(
NETDEV_FLAG_UP
);
if
(
SAL_NETDEV_NETDBOPS_VALID
(
netdev
,
pf
,
freeaddrinfo
))
if
(
sal_dev_res_tbl
[
i
].
res
==
ai
)
{
pf
->
netdb_ops
->
freeaddrinfo
(
ai
);
netdev
=
sal_dev_res_tbl
[
i
].
netdev
;
sal_dev_res_tbl
[
i
].
res
=
RT_NULL
;
sal_dev_res_tbl
[
i
].
netdev
=
RT_NULL
;
break
;
}
}
RT_ASSERT
((
i
<
SAL_SOCKETS_NUM
));
if
(
SAL_NETDBOPS_VALID
(
netdev
,
pf
,
freeaddrinfo
))
{
pf
->
netdb_ops
->
freeaddrinfo
(
ai
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录