Change folderstructure

This commit is contained in:
PolynomialDivision 2017-07-12 18:03:22 +02:00
parent f69b1841b3
commit 1cefa5b4b8
10 changed files with 787 additions and 1 deletions

30
src/include/utils.h Normal file
View file

@ -0,0 +1,30 @@
#ifndef __DAWN_UTILS_H
#define __DAWN_UTILS_H
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
static int hex_to_bin(char ch) {
if ((ch >= '0') && (ch <= '9')) return ch - '0';
ch = tolower(ch);
if ((ch >= 'a') && (ch <= 'f')) return ch - 'a' + 10;
return -1;
}
static int hwaddr_aton(const char *txt, uint8_t *addr) {
int i;
for (i = 0; i < ETH_ALEN; i++) {
int a, b;
a = hex_to_bin(*txt++);
if (a < 0) return -1;
b = hex_to_bin(*txt++);
if (b < 0) return -1;
*addr++ = (a << 4) | b;
if (i < 5 && *txt++ != ':') return -1;
}
return 0;
}
#endif