mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Add base64 encoding (own lib)
This commit is contained in:
parent
7ba1f28f6b
commit
b45b120773
8 changed files with 196 additions and 60 deletions
|
|
@ -31,13 +31,13 @@ enum {
|
|||
};
|
||||
|
||||
static const struct blobmsg_policy prob_policy[__PROB_MAX] = {
|
||||
[PROB_BSSID_ADDR] = {.name = "bssid", .type = BLOBMSG_TYPE_STRING},
|
||||
[PROB_CLIENT_ADDR] = {.name = "address", .type = BLOBMSG_TYPE_STRING},
|
||||
[PROB_TARGET_ADDR] = {.name = "target", .type = BLOBMSG_TYPE_STRING},
|
||||
[PROB_SIGNAL] = {.name = "signal", .type = BLOBMSG_TYPE_INT32},
|
||||
[PROB_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32},
|
||||
//[PROB_HT_SUPPORT] = {.name = "ht_support", .type = BLOBMSG_TYPE_INT8},
|
||||
//[PROB_VHT_SUPPORT] = {.name = "vht_support", .type = BLOBMSG_TYPE_INT8},
|
||||
[PROB_BSSID_ADDR] = {.name = "bssid", .type = BLOBMSG_TYPE_STRING},
|
||||
[PROB_CLIENT_ADDR] = {.name = "address", .type = BLOBMSG_TYPE_STRING},
|
||||
[PROB_TARGET_ADDR] = {.name = "target", .type = BLOBMSG_TYPE_STRING},
|
||||
[PROB_SIGNAL] = {.name = "signal", .type = BLOBMSG_TYPE_INT32},
|
||||
[PROB_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32},
|
||||
//[PROB_HT_SUPPORT] = {.name = "ht_support", .type = BLOBMSG_TYPE_INT8},
|
||||
//[PROB_VHT_SUPPORT] = {.name = "vht_support", .type = BLOBMSG_TYPE_INT8},
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -50,11 +50,11 @@ enum {
|
|||
};
|
||||
|
||||
static const struct blobmsg_policy client_table_policy[__CLIENT_TABLE_MAX] = {
|
||||
[CLIENT_TABLE] = {.name = "clients", .type = BLOBMSG_TYPE_TABLE},
|
||||
[CLIENT_TABLE_BSSID] = {.name = "bssid", .type = BLOBMSG_TYPE_STRING},
|
||||
[CLIENT_TABLE_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32},
|
||||
[CLIENT_TABLE_HT] = {.name = "ht_supported", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_TABLE_VHT] = {.name = "vht_supported", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_TABLE] = {.name = "clients", .type = BLOBMSG_TYPE_TABLE},
|
||||
[CLIENT_TABLE_BSSID] = {.name = "bssid", .type = BLOBMSG_TYPE_STRING},
|
||||
[CLIENT_TABLE_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32},
|
||||
[CLIENT_TABLE_HT] = {.name = "ht_supported", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_TABLE_VHT] = {.name = "vht_supported", .type = BLOBMSG_TYPE_INT8},
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -73,17 +73,17 @@ enum {
|
|||
};
|
||||
|
||||
static const struct blobmsg_policy client_policy[__CLIENT_MAX] = {
|
||||
[CLIENT_AUTH] = {.name = "auth", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_ASSOC] = {.name = "assoc", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_AUTHORIZED] = {.name = "authorized", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_PREAUTH] = {.name = "preauth", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_WDS] = {.name = "wds", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_WMM] = {.name = "wmm", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_HT] = {.name = "ht", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_VHT] = {.name = "vht", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_WPS] = {.name = "wps", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_MFP] = {.name = "mfp", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_AID] = {.name = "aid", .type = BLOBMSG_TYPE_INT32},
|
||||
[CLIENT_AUTH] = {.name = "auth", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_ASSOC] = {.name = "assoc", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_AUTHORIZED] = {.name = "authorized", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_PREAUTH] = {.name = "preauth", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_WDS] = {.name = "wds", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_WMM] = {.name = "wmm", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_HT] = {.name = "ht", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_VHT] = {.name = "vht", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_WPS] = {.name = "wps", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_MFP] = {.name = "mfp", .type = BLOBMSG_TYPE_INT8},
|
||||
[CLIENT_AID] = {.name = "aid", .type = BLOBMSG_TYPE_INT32},
|
||||
};
|
||||
|
||||
/* Function Definitions */
|
||||
|
|
@ -228,7 +228,7 @@ static int add_subscriber(char *name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int subscribe_to_hostapd_interfaces(char *hostapd_dir) {
|
||||
static int subscribe_to_hostapd_interfaces(char *hostapd_dir) {
|
||||
DIR *dirp;
|
||||
struct dirent *entry;
|
||||
|
||||
|
|
@ -239,8 +239,7 @@ static int subscribe_to_hostapd_interfaces(char *hostapd_dir) {
|
|||
}
|
||||
|
||||
dirp = opendir(hostapd_dir); // error handling?
|
||||
if(!dirp)
|
||||
{
|
||||
if (!dirp) {
|
||||
fprintf(stderr, "No hostapd sockets!\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -387,7 +386,7 @@ int parse_to_clients(struct blob_attr *msg, int do_kick, uint32_t id) {
|
|||
uint8_t bssid[ETH_ALEN];
|
||||
hwaddr_aton(blobmsg_data(tb[CLIENT_TABLE_BSSID]), bssid);
|
||||
|
||||
if(do_kick){
|
||||
if (do_kick) {
|
||||
printf("[CLIENTS] : Kick Clients\n");
|
||||
kick_clients(bssid, id);
|
||||
printf("[CLIENTS] : KickED Clients\n");
|
||||
|
|
@ -416,7 +415,7 @@ static int ubus_get_clients() {
|
|||
struct dirent *entry;
|
||||
|
||||
dirp = opendir(hostapd_dir_glob); // error handling?
|
||||
if(!dirp) {
|
||||
if (!dirp) {
|
||||
fprintf(stderr, "No hostapd sockets!\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -490,8 +489,7 @@ void del_client_all_interfaces(const uint8_t *client_addr, uint32_t reason, uint
|
|||
DIR *dirp;
|
||||
struct dirent *entry;
|
||||
dirp = opendir(hostapd_dir_glob); // error handling?
|
||||
if(!dirp)
|
||||
{
|
||||
if (!dirp) {
|
||||
fprintf(stderr, "No hostapd sockets!\n");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
26
src/utils/utils.c
Normal file
26
src/utils/utils.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#include "utils.h"
|
||||
#include "ubus.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue