mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 11:23:34 +08:00
Add interfaces flags, extend ifconfig, add ifup and ifdown commands (Darcy Gong
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5308 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user