mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
datastorage: refactor to support scalability testing
This commit is contained in:
parent
3a6ef89998
commit
50d347c233
11 changed files with 609 additions and 378 deletions
|
|
@ -1,5 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "datastorage.h"
|
||||
#include "utils.h"
|
||||
#include "ubus.h"
|
||||
|
||||
int string_is_greater(uint8_t *str, uint8_t *str_2) {
|
||||
|
||||
|
|
@ -39,30 +42,37 @@ int hwaddr_aton(const char *txt, uint8_t *addr) {
|
|||
b = hex_to_bin(*txt++);
|
||||
if (b < 0) return -1;
|
||||
*addr++ = (a << 4) | b;
|
||||
if (i < 5 && *txt++ != ':') return -1;
|
||||
// TODO: Should NUL terminator be checked for? Is aa:bb:cc:dd:ee:ff00 valid input?
|
||||
if (i < (ETH_ALEN - 1) && *txt++ != ':') return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: Never called in DAWN code. Remove?
|
||||
#if 0
|
||||
/* Convert badly formed MAC addresses with single digit element to double digit
|
||||
** eg 11:2:33:4:55:6 to 11:02:33:04:55:06 */`
|
||||
int convert_mac(char *in, char *out) {
|
||||
int i, j = 0;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (in[j + 1] != ':' && in[j + 1] != '\0') {
|
||||
out[3 * i] = toupper(in[j]);
|
||||
out[(3 * i) + 1] = toupper(in[j + 1]);
|
||||
out[(3 * i) + 2] = in[j + 2];
|
||||
j += 3;
|
||||
} else {
|
||||
for (i = 0; i < ETH_ALEN; i++) {
|
||||
/* Do we have a single-digit element? */
|
||||
if (in[j + 1] == ':' || in[j + 1] == '\0') {
|
||||
out[3 * i] = '0';
|
||||
out[(3 * i) + 1] = toupper(in[j]);
|
||||
out[(3 * i) + 2] = toupper(in[j + 1]);
|
||||
j += 2;
|
||||
} else {
|
||||
out[3 * i] = toupper(in[j]);
|
||||
out[(3 * i) + 1] = toupper(in[j + 1]);
|
||||
out[(3 * i) + 2] = in[j + 2];
|
||||
j += 3;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void write_mac_to_file(char *path, uint8_t addr[]) {
|
||||
FILE *f = fopen(path, "a");
|
||||
|
|
@ -82,4 +92,4 @@ void write_mac_to_file(char *path, uint8_t addr[]) {
|
|||
int rcpi_to_rssi(int rcpi)
|
||||
{
|
||||
return rcpi / 2 - 110;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue