summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorgeniusgogo <[email protected]>2023-03-10 16:16:41 +0800
committerGitHub <[email protected]>2023-03-10 16:16:41 +0800
commite29dfb75ca3b625e2203b385ba99b359089d3968 (patch)
tree9b2046cd259d6517020d60232d7e59a623f0e91a /components
parentc8b30bf31a2fa75297a791b731a26273eb2f6c3b (diff)
Fix net (#7034)
* fix LWIP_HOOK_IP4_ROUTE_SRC. * fix netdev ping select network card.
Diffstat (limited to 'components')
-rw-r--r--components/net/lwip/port/lwipopts.h2
-rw-r--r--components/net/netdev/src/netdev.c24
2 files changed, 11 insertions, 15 deletions
diff --git a/components/net/lwip/port/lwipopts.h b/components/net/lwip/port/lwipopts.h
index 7f34333247..795ddd06f6 100644
--- a/components/net/lwip/port/lwipopts.h
+++ b/components/net/lwip/port/lwipopts.h
@@ -637,7 +637,7 @@
#endif
#if RT_USING_LWIP_VER_NUM >= 0x20000 /* >= v2.0.0 */
-#define LWIP_HOOK_IP4_ROUTE_SRC(dest, src) lwip_ip4_route_src(dest, src)
+#define LWIP_HOOK_IP4_ROUTE_SRC(src, dest) lwip_ip4_route_src(dest, src)
#include "lwip/ip_addr.h"
struct netif *lwip_ip4_route_src(const ip4_addr_t *dest, const ip4_addr_t *src);
#endif /* RT_USING_LWIP_VER_NUM >= 0x20000 */
diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c
index 09f6c37d9a..44eecea6b8 100644
--- a/components/net/netdev/src/netdev.c
+++ b/components/net/netdev/src/netdev.c
@@ -1013,7 +1013,7 @@ int netdev_dhcp_open(char* netdev_name)
{
rt_kprintf("bad network interface device name(%s).\n", netdev_name);
return -1;
- }
+ }
netdev_dhcp_enabled(netdev,RT_TRUE);
return 0;
}
@@ -1074,15 +1074,15 @@ int netdev_ifconfig(int argc, char **argv)
{
netdev_list_if();
}
-#ifdef RT_LWIP_DHCP
+#ifdef RT_LWIP_DHCP
else if(argc == 3)
{
if (!strcmp(argv[2], "dhcp"))
{
- netdev_dhcp_open(argv[1]);
+ netdev_dhcp_open(argv[1]);
}
}
-#endif
+#endif
else if (argc == 5)
{
rt_kprintf("config : %s\n", argv[1]);
@@ -1094,9 +1094,9 @@ int netdev_ifconfig(int argc, char **argv)
else
{
rt_kprintf("bad parameter! e.g: ifconfig e0 192.168.1.30 192.168.1.1 255.255.255.0\n");
-#ifdef RT_LWIP_DHCP
+#ifdef RT_LWIP_DHCP
rt_kprintf("bad parameter! e.g: ifconfig e0 dhcp\n");
-#endif
+#endif
}
return 0;
@@ -1130,19 +1130,15 @@ int netdev_cmd_ping(char* target_name, char *netdev_name, rt_uint32_t times, rt_
if (netdev_name != RT_NULL)
{
netdev = netdev_get_by_name(netdev_name);
- if (netdev == RT_NULL)
- {
- netdev = netdev_default;
- rt_kprintf("ping: not found specified netif, using default netdev %s.\n", netdev->name);
- }
}
- if (NETDEV_PING_IS_COMMONICABLE(netdev_default))
+ if (netdev == RT_NULL)
{
- /* using default network interface device for ping */
netdev = netdev_default;
+ rt_kprintf("ping: not found specified netif, using default netdev %s.\n", netdev->name);
}
- else
+
+ if (!NETDEV_PING_IS_COMMONICABLE(netdev))
{
/* using first internet up status network interface device */
netdev = netdev_get_first_by_flags(NETDEV_FLAG_LINK_UP);