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:
patacongo
2008-09-02 23:04:10 +00:00
parent db24d24ac2
commit 4dd12b73af
13 changed files with 245 additions and 37 deletions
+33 -23
View File
@@ -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;
}