Change config file

This commit is contained in:
PolynomialDivision 2017-07-31 19:59:20 +02:00
parent 64aa9d6629
commit 63a1432652
11 changed files with 154 additions and 25 deletions

60
src/utils/dawn_uci.c Normal file
View file

@ -0,0 +1,60 @@
#include <uci.h>
#include <stdlib.h>
#include <datastorage.h>
#include "dawn_uci.h"
/*
dawn.metric.ht_support
dawn.metric.vht_support'
dawn.metric.rssi
dawn.metric.freq
*/
struct probe_metric_s uci_get_dawn_metric()
{
struct probe_metric_s ret;
struct uci_context *c;
struct uci_ptr ptr;
c = uci_alloc_context ();
char tmp_ht_support[] = "dawn.metric.ht_support";
if (uci_lookup_ptr (c, &ptr, tmp_ht_support, 1) != UCI_OK) {
uci_perror(c, "uci_get_daw_metric Error");
return ret;
}
if(ptr.o->type == UCI_TYPE_STRING)
ret.ht_support = atoi(ptr.o->v.string);
char tmp_vht_support[] = "dawn.metric.vht_support";
if (uci_lookup_ptr (c, &ptr, tmp_vht_support, 1) != UCI_OK) {
uci_perror(c, "uci_get_daw_metric Error");
return ret;
}
if(ptr.o->type == UCI_TYPE_STRING)
ret.vht_support = atoi(ptr.o->v.string);
char tmp_rssi[] = "dawn.metric.freq";
if (uci_lookup_ptr (c, &ptr, tmp_rssi, 1) != UCI_OK) {
uci_perror(c, "uci_get_daw_metric Error");
return ret;
}
if(ptr.o->type == UCI_TYPE_STRING)
ret.rssi = atoi(ptr.o->v.string);
char tmp_freq[] = "dawn.metric.freq";
if (uci_lookup_ptr (c, &ptr, tmp_freq, 1) != UCI_OK) {
uci_perror(c, "uci_get_daw_metric Error");
return ret;
}
if(ptr.o->type == UCI_TYPE_STRING)
ret.freq = atoi(ptr.o->v.string);
uci_free_context (c);
return ret;
}

View file

@ -12,6 +12,7 @@
#include "networksocket.h"
#include "utils.h"
#include "dawn_uci.h"
static struct ubus_context *ctx;
static struct ubus_context *ctx_clients; /* own ubus conext otherwise strange behavior... */
@ -227,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;
@ -269,6 +270,9 @@ int dawn_init_ubus(const char *ubus_socket, char *hostapd_dir) {
ubus_add_uloop(ctx);
// set dawn metric
dawn_metric = uci_get_dawn_metric();
subscribe_to_hostapd_interfaces(hostapd_dir);
uloop_run();
@ -411,6 +415,10 @@ static int ubus_get_clients() {
struct dirent *entry;
dirp = opendir(hostapd_dir_glob); // error handling?
if(!dirp) {
fprintf(stderr, "No hostapd sockets!\n");
return -1;
}
while ((entry = readdir(dirp)) != NULL) {
if (entry->d_type == DT_SOCK) {
char hostapd_iface[256];
@ -480,6 +488,11 @@ 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)
{
fprintf(stderr, "No hostapd sockets!\n");
return;
}
while ((entry = readdir(dirp)) != NULL) {
if (entry->d_type == DT_SOCK) {
char hostapd_iface[256];