diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-11-04 18:54:04 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-11-04 18:54:04 +0000 |
commit | 08a0eae6371ad7d6af7c0d941381fa1e11370a86 (patch) | |
tree | 7a3a8ae8e2b29e3832a17a7def5b0531383172bb /apps/netutils/uiplib/uiplib.c | |
parent | 813efa266bb67269669e532b5ce6f00ee2097948 (diff) | |
download | nuttx-08a0eae6371ad7d6af7c0d941381fa1e11370a86.tar.gz nuttx-08a0eae6371ad7d6af7c0d941381fa1e11370a86.tar.bz2 nuttx-08a0eae6371ad7d6af7c0d941381fa1e11370a86.zip |
Add interfaces flags, extend ifconfig, add ifup and ifdown commands (Darcy Gong
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5308 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/netutils/uiplib/uiplib.c')
-rw-r--r-- | apps/netutils/uiplib/uiplib.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/netutils/uiplib/uiplib.c b/apps/netutils/uiplib/uiplib.c index f863b7343..32ffaeb06 100644 --- a/apps/netutils/uiplib/uiplib.c +++ b/apps/netutils/uiplib/uiplib.c @@ -45,10 +45,12 @@ #include <stdint.h> #include <stdbool.h> +#include <debug.h> #include <nuttx/net/uip/uip.h> #include <apps/netutils/uiplib.h> + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -93,3 +95,58 @@ bool uiplib_ipaddrconv(const char *addrstr, uint8_t *ipaddr) } return true; } + +bool uiplib_hwmacconv(const char *hwstr, uint8_t *hw) +{ + unsigned char tmp; + char c; + unsigned char i; + unsigned char j; + + if (strlen(hwstr)!=17) + { + return false; + } + + tmp = 0; + + for (i = 0; i < 6; ++i) + { + j = 0; + do + { + c = *hwstr; + ++j; + if (j > 3) + { + return false; + } + if (c == ':' || c == 0) + { + *hw = tmp; + nvdbg("HWMAC[%d]%0.2X\n",i,tmp); + ++hw; + tmp = 0; + } + else if(c >= '0' && c <= '9') + { + tmp = (tmp << 4) + (c - '0'); + } + else if(c >= 'a' && c <= 'f') + { + tmp = (tmp << 4) + (c - 'a' + 10); + } + else if(c >= 'A' && c <= 'F') + { + tmp = (tmp << 4) + (c - 'A' + 10); + } + else + { + return false; + } + ++hwstr; + } + while(c != ':' && c != 0); + } + return true; +} |