Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
AdRainty
rt-thread
提交
126fa9b5
R
rt-thread
项目概览
AdRainty
/
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,发现更多精彩内容 >>
提交
126fa9b5
编写于
4月 23, 2019
作者:
Lawlieta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[net][netdev] Improve netdev DNS setting function
上级
ca7ebe61
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
27 addition
and
21 deletion
+27
-21
components/net/lwip-1.4.1/src/netif/ethernetif.c
components/net/lwip-1.4.1/src/netif/ethernetif.c
+5
-5
components/net/lwip-2.0.2/src/netif/ethernetif.c
components/net/lwip-2.0.2/src/netif/ethernetif.c
+5
-5
components/net/lwip-2.1.0/src/netif/ethernetif.c
components/net/lwip-2.1.0/src/netif/ethernetif.c
+5
-5
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
+11
-5
未找到文件。
components/net/lwip-1.4.1/src/netif/ethernetif.c
浏览文件 @
126fa9b5
...
@@ -144,10 +144,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i
...
@@ -144,10 +144,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i
}
}
#ifdef RT_LWIP_DNS
#ifdef RT_LWIP_DNS
static
int
lwip_netdev_set_dns_server
(
struct
netdev
*
netif
,
ip_addr_t
*
dns_server
)
static
int
lwip_netdev_set_dns_server
(
struct
netdev
*
netif
,
uint8_t
dns_num
,
ip_addr_t
*
dns_server
)
{
{
extern
void
set_dns
(
char
*
dns_server
);
extern
void
set_dns
(
uint8_t
dns_num
,
char
*
dns_server
);
set_dns
(
ipaddr_ntoa
(
dns_server
));
set_dns
(
dns_num
,
ipaddr_ntoa
(
dns_server
));
return
ERR_OK
;
return
ERR_OK
;
}
}
#endif
/* RT_LWIP_DNS */
#endif
/* RT_LWIP_DNS */
...
@@ -729,13 +729,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address);
...
@@ -729,13 +729,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address);
#if LWIP_DNS
#if LWIP_DNS
#include <lwip/dns.h>
#include <lwip/dns.h>
void
set_dns
(
char
*
dns_server
)
void
set_dns
(
uint8_t
dns_num
,
char
*
dns_server
)
{
{
struct
ip_addr
addr
;
struct
ip_addr
addr
;
if
((
dns_server
!=
RT_NULL
)
&&
ipaddr_aton
(
dns_server
,
&
addr
))
if
((
dns_server
!=
RT_NULL
)
&&
ipaddr_aton
(
dns_server
,
&
addr
))
{
{
dns_setserver
(
0
,
&
addr
);
dns_setserver
(
dns_num
,
&
addr
);
}
}
}
}
FINSH_FUNCTION_EXPORT
(
set_dns
,
set
DNS
server
address
);
FINSH_FUNCTION_EXPORT
(
set_dns
,
set
DNS
server
address
);
...
...
components/net/lwip-2.0.2/src/netif/ethernetif.c
浏览文件 @
126fa9b5
...
@@ -152,10 +152,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i
...
@@ -152,10 +152,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i
}
}
#ifdef RT_LWIP_DNS
#ifdef RT_LWIP_DNS
static
int
lwip_netdev_set_dns_server
(
struct
netdev
*
netif
,
ip_addr_t
*
dns_server
)
static
int
lwip_netdev_set_dns_server
(
struct
netdev
*
netif
,
uint8_t
dns_num
,
ip_addr_t
*
dns_server
)
{
{
extern
void
set_dns
(
char
*
dns_server
);
extern
void
set_dns
(
uint8_t
dns_num
,
char
*
dns_server
);
set_dns
(
ipaddr_ntoa
(
dns_server
));
set_dns
(
dns_num
,
ipaddr_ntoa
(
dns_server
));
return
ERR_OK
;
return
ERR_OK
;
}
}
#endif
/* RT_LWIP_DNS */
#endif
/* RT_LWIP_DNS */
...
@@ -758,13 +758,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address);
...
@@ -758,13 +758,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address);
#if LWIP_DNS
#if LWIP_DNS
#include <lwip/dns.h>
#include <lwip/dns.h>
void
set_dns
(
char
*
dns_server
)
void
set_dns
(
uint8_t
dns_num
,
char
*
dns_server
)
{
{
ip_addr_t
addr
;
ip_addr_t
addr
;
if
((
dns_server
!=
RT_NULL
)
&&
ipaddr_aton
(
dns_server
,
&
addr
))
if
((
dns_server
!=
RT_NULL
)
&&
ipaddr_aton
(
dns_server
,
&
addr
))
{
{
dns_setserver
(
0
,
&
addr
);
dns_setserver
(
dns_num
,
&
addr
);
}
}
}
}
FINSH_FUNCTION_EXPORT
(
set_dns
,
set
DNS
server
address
);
FINSH_FUNCTION_EXPORT
(
set_dns
,
set
DNS
server
address
);
...
...
components/net/lwip-2.1.0/src/netif/ethernetif.c
浏览文件 @
126fa9b5
...
@@ -153,10 +153,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i
...
@@ -153,10 +153,10 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i
}
}
#ifdef RT_LWIP_DNS
#ifdef RT_LWIP_DNS
static
int
lwip_netdev_set_dns_server
(
struct
netdev
*
netif
,
ip_addr_t
*
dns_server
)
static
int
lwip_netdev_set_dns_server
(
struct
netdev
*
netif
,
uint8_t
dns_num
,
ip_addr_t
*
dns_server
)
{
{
extern
void
set_dns
(
char
*
dns_server
);
extern
void
set_dns
(
uint8_t
dns_num
,
char
*
dns_server
);
set_dns
(
ipaddr_ntoa
(
dns_server
));
set_dns
(
dns_num
,
ipaddr_ntoa
(
dns_server
));
return
ERR_OK
;
return
ERR_OK
;
}
}
#endif
/* RT_LWIP_DNS */
#endif
/* RT_LWIP_DNS */
...
@@ -762,13 +762,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address);
...
@@ -762,13 +762,13 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address);
#if LWIP_DNS
#if LWIP_DNS
#include <lwip/dns.h>
#include <lwip/dns.h>
void
set_dns
(
char
*
dns_server
)
void
set_dns
(
uint8_t
dns_num
,
char
*
dns_server
)
{
{
ip_addr_t
addr
;
ip_addr_t
addr
;
if
((
dns_server
!=
RT_NULL
)
&&
ipaddr_aton
(
dns_server
,
&
addr
))
if
((
dns_server
!=
RT_NULL
)
&&
ipaddr_aton
(
dns_server
,
&
addr
))
{
{
dns_setserver
(
0
,
&
addr
);
dns_setserver
(
dns_num
,
&
addr
);
}
}
}
}
FINSH_FUNCTION_EXPORT
(
set_dns
,
set
DNS
server
address
);
FINSH_FUNCTION_EXPORT
(
set_dns
,
set
DNS
server
address
);
...
...
components/net/netdev/include/netdev.h
浏览文件 @
126fa9b5
...
@@ -119,7 +119,7 @@ struct netdev_ops
...
@@ -119,7 +119,7 @@ struct netdev_ops
/* set network interface device address information operations */
/* set network interface device address information operations */
int
(
*
set_addr_info
)(
struct
netdev
*
netdev
,
ip_addr_t
*
ip_addr
,
ip_addr_t
*
netmask
,
ip_addr_t
*
gw
);
int
(
*
set_addr_info
)(
struct
netdev
*
netdev
,
ip_addr_t
*
ip_addr
,
ip_addr_t
*
netmask
,
ip_addr_t
*
gw
);
int
(
*
set_dns_server
)(
struct
netdev
*
netdev
,
ip_addr_t
*
dns_server
);
int
(
*
set_dns_server
)(
struct
netdev
*
netdev
,
uint8_t
dns_num
,
ip_addr_t
*
dns_server
);
int
(
*
set_dhcp
)(
struct
netdev
*
netdev
,
rt_bool_t
is_enabled
);
int
(
*
set_dhcp
)(
struct
netdev
*
netdev
,
rt_bool_t
is_enabled
);
/* set network interface device common network interface device operations */
/* set network interface device common network interface device operations */
...
...
components/net/netdev/src/netdev.c
浏览文件 @
126fa9b5
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
*/
*/
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <rtthread.h>
#include <rtthread.h>
#include <rthw.h>
#include <rthw.h>
...
@@ -510,7 +511,7 @@ int netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_
...
@@ -510,7 +511,7 @@ int netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_
}
}
/* execute network interface device set DNS server address operations */
/* execute network interface device set DNS server address operations */
return
netdev
->
ops
->
set_dns_server
(
netdev
,
(
ip_addr_t
*
)
dns_server
);
return
netdev
->
ops
->
set_dns_server
(
netdev
,
dns_num
,
(
ip_addr_t
*
)
dns_server
);
}
}
/**
/**
...
@@ -1028,7 +1029,7 @@ static void netdev_list_dns(void)
...
@@ -1028,7 +1029,7 @@ static void netdev_list_dns(void)
rt_hw_interrupt_enable
(
level
);
rt_hw_interrupt_enable
(
level
);
}
}
static
void
netdev_set_dns
(
char
*
netdev_name
,
char
*
dns_server
)
static
void
netdev_set_dns
(
char
*
netdev_name
,
uint8_t
dns_num
,
char
*
dns_server
)
{
{
struct
netdev
*
netdev
=
RT_NULL
;
struct
netdev
*
netdev
=
RT_NULL
;
ip_addr_t
dns_addr
;
ip_addr_t
dns_addr
;
...
@@ -1041,7 +1042,7 @@ static void netdev_set_dns(char *netdev_name, char *dns_server)
...
@@ -1041,7 +1042,7 @@ static void netdev_set_dns(char *netdev_name, char *dns_server)
}
}
inet_aton
(
dns_server
,
&
dns_addr
);
inet_aton
(
dns_server
,
&
dns_addr
);
netdev_set_dns_server
(
netdev
,
0
,
&
dns_addr
);
netdev_set_dns_server
(
netdev
,
dns_num
,
&
dns_addr
);
rt_kprintf
(
"set network interface device(%s) dns server #0: %s
\n
"
,
netdev_name
,
dns_server
);
rt_kprintf
(
"set network interface device(%s) dns server #0: %s
\n
"
,
netdev_name
,
dns_server
);
}
}
...
@@ -1054,11 +1055,16 @@ int netdev_dns(int argc, char **argv)
...
@@ -1054,11 +1055,16 @@ int netdev_dns(int argc, char **argv)
}
}
else
if
(
argc
==
3
)
else
if
(
argc
==
3
)
{
{
netdev_set_dns
(
argv
[
1
],
argv
[
2
]);
netdev_set_dns
(
argv
[
1
],
0
,
argv
[
2
]);
}
else
if
(
argc
==
4
)
{
netdev_set_dns
(
argv
[
1
],
atoi
(
argv
[
2
]),
argv
[
3
]);
}
}
else
else
{
{
rt_kprintf
(
"bad parameter! e.g: dns name 114.114.114.114
\n
"
);
rt_kprintf
(
"bad parameter! input: dns <netdev_name> [dns_num] <dns_server>
\n
"
);
return
-
1
;
}
}
return
0
;
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录