Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PHPmihuan
rt-thread
提交
4de0533a
R
rt-thread
项目概览
PHPmihuan
/
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,发现更多精彩内容 >>
提交
4de0533a
编写于
5月 10, 2019
作者:
Lawlieta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[net][sal][netdev] Delete the link_up status judgment in the send/recv interface
Signed-off-by:
chenyong
<
1521761801@qq.com
>
上级
9eef6441
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
26 deletion
+28
-26
components/net/netdev/include/netdev.h
components/net/netdev/include/netdev.h
+1
-1
components/net/netdev/src/netdev.c
components/net/netdev/src/netdev.c
+7
-5
components/net/sal_socket/src/sal_socket.c
components/net/sal_socket/src/sal_socket.c
+20
-20
未找到文件。
components/net/netdev/include/netdev.h
浏览文件 @
4de0533a
...
...
@@ -133,7 +133,7 @@ int netdev_register(struct netdev *netdev, const char *name, void *user_data);
int
netdev_unregister
(
struct
netdev
*
netdev
);
/* Get network interface device object */
struct
netdev
*
netdev_get_first_
link_up
(
void
);
struct
netdev
*
netdev_get_first_
by_flags
(
uint16_t
flags
);
struct
netdev
*
netdev_get_by_ipaddr
(
ip_addr_t
*
ip_addr
);
struct
netdev
*
netdev_get_by_name
(
const
char
*
name
);
#ifdef RT_USING_SAL
...
...
components/net/netdev/src/netdev.c
浏览文件 @
4de0533a
...
...
@@ -134,12 +134,14 @@ int netdev_unregister(struct netdev *netdev)
/**
* This function will get the first network interface device
* with the link_up status in network interface device list.
* with the flags in network interface device list.
*
* @param flags the network interface device flags
*
* @return != NULL: network interface device object
* NULL: get failed
*/
struct
netdev
*
netdev_get_first_
link_up
(
void
)
struct
netdev
*
netdev_get_first_
by_flags
(
uint16_t
flags
)
{
rt_base_t
level
;
rt_slist_t
*
node
=
RT_NULL
;
...
...
@@ -155,7 +157,7 @@ struct netdev *netdev_get_first_link_up(void)
for
(
node
=
&
(
netdev_list
->
list
);
node
;
node
=
rt_slist_next
(
node
))
{
netdev
=
rt_slist_entry
(
node
,
struct
netdev
,
list
);
if
(
netdev
&&
netdev_is_up
(
netdev
)
&&
netdev_is_link_up
(
netdev
)
)
if
(
netdev
&&
(
netdev
->
flags
&
flags
)
!=
0
)
{
rt_hw_interrupt_enable
(
level
);
return
netdev
;
...
...
@@ -679,7 +681,7 @@ static void netdev_auto_change_default(struct netdev *netdev)
if
(
rt_memcmp
(
netdev
,
netdev_default
,
sizeof
(
struct
netdev
))
==
0
)
{
new_netdev
=
netdev_get_first_
link_up
(
);
new_netdev
=
netdev_get_first_
by_flags
(
NETDEV_FLAG_LINK_UP
);
if
(
new_netdev
)
{
netdev_set_default
(
new_netdev
);
...
...
@@ -964,7 +966,7 @@ static int netdev_cmd_ping(char* target_name, rt_uint32_t times, rt_size_t size)
else
{
/* using first internet up status network interface device */
netdev
=
netdev_get_first_
link_up
(
);
netdev
=
netdev_get_first_
by_flags
(
NETDEV_FLAG_LINK_UP
);
if
(
netdev
==
RT_NULL
||
NETDEV_PING_IS_COMMONICABLE
(
netdev
)
==
0
)
{
rt_kprintf
(
"ping: network interface device get error.
\n
"
);
...
...
components/net/sal_socket/src/sal_socket.c
浏览文件 @
4de0533a
...
...
@@ -70,9 +70,9 @@ do {
} \
}while(0) \
#define SAL_NETDEV_IS_
COMMONICABLE(netdev)
\
#define SAL_NETDEV_IS_
UP(netdev)
\
do { \
if (!netdev_is_up(netdev)
|| !netdev_is_link_up(netdev)){
\
if (!netdev_is_up(netdev)
) {
\
return -1; \
} \
}while(0) \
...
...
@@ -86,9 +86,9 @@ do {
}while(0) \
#define SAL_NETDEV_NETDBOPS_VALID(netdev, pf, ops) \
((netdev) && netdev_is_up(netdev) && netdev_is_link_up(netdev) &&
\
((netdev) && netdev_is_up(netdev) &&
\
((pf) = (struct sal_proto_family *) (netdev)->sal_user_data) != RT_NULL && \
(pf)->netdb_ops->ops)
\
(pf)->netdb_ops->ops)
\
/**
* SAL (Socket Abstraction Layer) initialize.
...
...
@@ -748,8 +748,8 @@ int sal_connect(int socket, const struct sockaddr *name, socklen_t namelen)
/* get the socket object by socket descriptor */
SAL_SOCKET_OBJ_GET
(
sock
,
socket
);
/* check the network interface is
commonicable
*/
SAL_NETDEV_IS_
COMMONICABLE
(
sock
->
netdev
);
/* check the network interface is
up status
*/
SAL_NETDEV_IS_
UP
(
sock
->
netdev
);
/* check the network interface socket opreation */
SAL_NETDEV_SOCKETOPS_VALID
(
sock
->
netdev
,
pf
,
connect
);
...
...
@@ -792,8 +792,8 @@ int sal_recvfrom(int socket, void *mem, size_t len, int flags,
/* get the socket object by socket descriptor */
SAL_SOCKET_OBJ_GET
(
sock
,
socket
);
/* check the network interface is
commonicable
*/
SAL_NETDEV_IS_
COMMONICABLE
(
sock
->
netdev
);
/* check the network interface is
up status
*/
SAL_NETDEV_IS_
UP
(
sock
->
netdev
);
/* check the network interface socket opreation */
SAL_NETDEV_SOCKETOPS_VALID
(
sock
->
netdev
,
pf
,
recvfrom
);
...
...
@@ -826,8 +826,8 @@ int sal_sendto(int socket, const void *dataptr, size_t size, int flags,
/* get the socket object by socket descriptor */
SAL_SOCKET_OBJ_GET
(
sock
,
socket
);
/* check the network interface is
commonicable
*/
SAL_NETDEV_IS_
COMMONICABLE
(
sock
->
netdev
);
/* check the network interface is
up status
*/
SAL_NETDEV_IS_
UP
(
sock
->
netdev
);
/* check the network interface socket opreation */
SAL_NETDEV_SOCKETOPS_VALID
(
sock
->
netdev
,
pf
,
sendto
);
...
...
@@ -965,8 +965,8 @@ int sal_poll(struct dfs_fd *file, struct rt_pollreq *req)
/* get the socket object by socket descriptor */
SAL_SOCKET_OBJ_GET
(
sock
,
socket
);
/* check the network interface is
commonicable
*/
SAL_NETDEV_IS_
COMMONICABLE
(
sock
->
netdev
);
/* check the network interface is
up status
*/
SAL_NETDEV_IS_
UP
(
sock
->
netdev
);
/* check the network interface socket opreation */
SAL_NETDEV_SOCKETOPS_VALID
(
sock
->
netdev
,
pf
,
poll
);
...
...
@@ -985,8 +985,8 @@ struct hostent *sal_gethostbyname(const char *name)
}
else
{
/* get the first network interface device with
the link
up status */
netdev
=
netdev_get_first_
link_up
(
);
/* 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
,
gethostbyname
))
{
return
pf
->
netdb_ops
->
gethostbyname
(
name
);
...
...
@@ -1008,8 +1008,8 @@ int sal_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
}
else
{
/* get the first network interface device with
the link
up status */
netdev
=
netdev_get_first_
link_up
(
);
/* 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
,
gethostbyname_r
))
{
return
pf
->
netdb_ops
->
gethostbyname_r
(
name
,
ret
,
buf
,
buflen
,
result
,
h_errnop
);
...
...
@@ -1033,8 +1033,8 @@ int sal_getaddrinfo(const char *nodename,
}
else
{
/* get the first network interface device with
the link
up status */
netdev
=
netdev_get_first_
link_up
(
);
/* 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
,
getaddrinfo
))
{
return
pf
->
netdb_ops
->
getaddrinfo
(
nodename
,
servname
,
hints
,
res
);
...
...
@@ -1055,8 +1055,8 @@ void sal_freeaddrinfo(struct addrinfo *ai)
}
else
{
/* get the first network interface device with
the link
up status */
netdev
=
netdev_get_first_
link_up
(
);
/* 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
))
{
pf
->
netdb_ops
->
freeaddrinfo
(
ai
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录