mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
Add NSH ping command
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@870 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+33
-23
@@ -46,33 +46,43 @@
|
||||
#include <net/uip/uip.h>
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
|
||||
boolean uiplib_ipaddrconv(const char *addrstr, ubyte *ipaddr)
|
||||
{
|
||||
unsigned char tmp;
|
||||
char c;
|
||||
unsigned char i, j;
|
||||
unsigned char i;
|
||||
unsigned char j;
|
||||
|
||||
tmp = 0;
|
||||
|
||||
for(i = 0; i < 4; ++i) {
|
||||
j = 0;
|
||||
do {
|
||||
c = *addrstr;
|
||||
++j;
|
||||
if(j > 4) {
|
||||
return 0;
|
||||
}
|
||||
if(c == '.' || c == 0) {
|
||||
*ipaddr = tmp;
|
||||
++ipaddr;
|
||||
tmp = 0;
|
||||
} else if(c >= '0' && c <= '9') {
|
||||
tmp = (tmp * 10) + (c - '0');
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
++addrstr;
|
||||
} while(c != '.' && c != 0);
|
||||
}
|
||||
return 1;
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
j = 0;
|
||||
do
|
||||
{
|
||||
c = *addrstr;
|
||||
++j;
|
||||
if (j > 4)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (c == '.' || c == 0)
|
||||
{
|
||||
*ipaddr = tmp;
|
||||
++ipaddr;
|
||||
tmp = 0;
|
||||
}
|
||||
else if(c >= '0' && c <= '9')
|
||||
{
|
||||
tmp = (tmp * 10) + (c - '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
++addrstr;
|
||||
}
|
||||
while(c != '.' && c != 0);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user