File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed
TEST_APPS/device/socket_app Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change 19
19
#include " mbed-client-cli/ns_cmdline.h"
20
20
#include " mbed-trace/mbed_trace.h"
21
21
22
+ #include " ip4string.h"
23
+
22
24
#ifndef MBED_CONF_APP_CONNECT_STATEMENT
23
25
#error [NOT_SUPPORTED] No network configuration found for this target.
24
26
#endif
@@ -42,26 +44,16 @@ int cmd_ifconfig(int argc, char *argv[]);
42
44
const char * MAN_IFCONFIG = " ifup interface up\r\n " \
43
45
" ifdown interface down\r\n " ;
44
46
45
- static bool is_ipv4 (const char *str)
46
- {
47
- int dot_count = 0 ;
48
- for (int i = 0 ; str[i]; i++) {
49
- if (str[i] == ' .' && ++dot_count == 3 ) {
50
- return true ;
51
- }
52
- }
53
- return false ;
54
- }
55
-
56
47
static void ifconfig_print ()
57
48
{
58
- if (!net)
49
+ if (!net) {
59
50
cmd_printf (" No interface configured\r\n " );
60
51
return ;
52
+ }
61
53
const char *str = net->get_ip_address ();
62
-
63
54
if (str) {
64
- if (is_ipv4 (str)) {
55
+ uint8_t buf[4 ];
56
+ if (stoip4 (str, strlen (str), buf)) {
65
57
cmd_printf (" IPv4 if addr: %s\r\n " , str);
66
58
} else {
67
59
cmd_printf (" IPv6 if addr:\r\n [0]: %s\r\n " , str);
You can’t perform that action at this time.
0 commit comments