mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Change config file
This commit is contained in:
parent
64aa9d6629
commit
63a1432652
11 changed files with 154 additions and 25 deletions
|
@ -1,6 +1,17 @@
|
|||
config 'settings' 'dawn'
|
||||
config settings network
|
||||
option broadcast_ip '10.0.0.255'
|
||||
option broadcast_port '1025'
|
||||
option sort_order 'csfb'
|
||||
|
||||
config settings ordering
|
||||
option sort_order 'csfb'
|
||||
|
||||
config settings hostapd
|
||||
option hostapd_dir '/var/run/hostapd'
|
||||
option background '0'
|
||||
|
||||
config settings metric
|
||||
option ht_support '10'
|
||||
option vht_support '10'
|
||||
option vht_support '10'
|
||||
option rssi '10'
|
||||
option freq '10'
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ start_service()
|
|||
local hostapd_dir
|
||||
|
||||
config_load "${NAME}"
|
||||
config_get broadcast_ip dawn broadcast_ip
|
||||
config_get broadcast_port dawn broadcast_port
|
||||
config_get sort_order dawn sort_order
|
||||
config_get hostapd_dir dawn hostapd_dir
|
||||
config_get broadcast_ip network broadcast_ip
|
||||
config_get broadcast_port network broadcast_port
|
||||
config_get sort_order ordering sort_order
|
||||
config_get hostapd_dir hostapd hostapd_dir
|
||||
|
||||
|
||||
procd_open_instance
|
||||
|
|
BIN
files/main
Executable file
BIN
files/main
Executable file
Binary file not shown.
33
files/main.c
Normal file
33
files/main.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libconfig.h>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
config_t cfg;
|
||||
config_setting_t *root, *setting, *movie;
|
||||
|
||||
config_init(&cfg);
|
||||
|
||||
/* Read the file. If there is an error, report it and exit. */
|
||||
if(! config_read_file(&cfg, "dawn.config"))
|
||||
{
|
||||
fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg),
|
||||
config_error_line(&cfg), config_error_text(&cfg));
|
||||
config_destroy(&cfg);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("READ CONFIG!!!\n");
|
||||
|
||||
root = config_root_setting(&cfg);
|
||||
|
||||
int ht_support;
|
||||
if (config_lookup_int(&cfg, "ht_support", &ht_support))
|
||||
printf("Broadcast Port: %d\n\n", ht_support);
|
||||
else
|
||||
fprintf(stderr, "No 'name' setting in configuration file.\n");
|
||||
|
||||
|
||||
}
|
|
@ -29,12 +29,13 @@ SET(SOURCES
|
|||
|
||||
utils/runopts.c
|
||||
include/runopts.h
|
||||
)
|
||||
|
||||
utils/dawn_uci.c include/dawn_uci.h)
|
||||
|
||||
SET(LIBS
|
||||
ubox ubus json-c blobmsg_json config)
|
||||
ubox ubus json-c blobmsg_json config uci)
|
||||
|
||||
ADD_EXECUTABLE(dawn ${SOURCES})
|
||||
ADD_EXECUTABLE(dawn ${SOURCES} utils/dawn_uci.c include/dawn_uci.h)
|
||||
|
||||
TARGET_LINK_LIBRARIES(dawn ${LIBS})
|
||||
|
||||
|
|
|
@ -13,6 +13,18 @@
|
|||
#define ETH_ALEN 6
|
||||
#endif
|
||||
|
||||
struct probe_metric_s dawn_metric;
|
||||
|
||||
struct probe_metric_s
|
||||
{
|
||||
int ht_support;
|
||||
int vht_support;
|
||||
int n_ht_support;
|
||||
int n_vht_support;
|
||||
int rssi;
|
||||
int freq;
|
||||
};
|
||||
|
||||
#define SORT_NUM 5
|
||||
#define TIME_THRESHOLD 30 // every minute
|
||||
|
||||
|
|
6
src/include/dawn_uci.h
Normal file
6
src/include/dawn_uci.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef DAWN_UCI_H
|
||||
#define DAWN_UCI_H
|
||||
|
||||
struct probe_metric_s uci_get_dawn_metric();
|
||||
|
||||
#endif //DAWN_UCI_H_H
|
|
@ -4,6 +4,7 @@
|
|||
#include "datastorage.h"
|
||||
#include "networksocket.h"
|
||||
#include "ubus.h"
|
||||
#include "dawn_uci.h"
|
||||
|
||||
#define BUFSIZE 17
|
||||
#define BUFSIZE_DIR 255
|
||||
|
|
|
@ -28,16 +28,6 @@ void remove_old_client_entries(time_t current_time, long long int threshold);
|
|||
|
||||
int eval_probe_metric(struct client_s client_entry, struct probe_entry_s probe_entry);
|
||||
|
||||
struct probe_metric_s
|
||||
{
|
||||
int ht_support;
|
||||
int vht_support;
|
||||
int n_ht_support;
|
||||
int n_vht_support;
|
||||
int rssi;
|
||||
int freq;
|
||||
};
|
||||
|
||||
int kick_client(struct client_s client_entry);
|
||||
|
||||
int probe_entry_last = -1;
|
||||
|
@ -45,7 +35,7 @@ int client_entry_last = -1;
|
|||
|
||||
int eval_probe_metric(struct client_s client_entry, struct probe_entry_s probe_entry) {
|
||||
|
||||
struct probe_metric_s metric = {
|
||||
/*struct probe_metric_s metric = {
|
||||
.ht_support = 0,
|
||||
.vht_support = 0,
|
||||
.n_ht_support = 0,
|
||||
|
@ -53,6 +43,8 @@ int eval_probe_metric(struct client_s client_entry, struct probe_entry_s probe_e
|
|||
.rssi = 0,
|
||||
.freq = 100}; // this is for testing
|
||||
|
||||
*/
|
||||
|
||||
int score = 0;
|
||||
|
||||
uint8_t client_supports_ht;
|
||||
|
@ -79,13 +71,13 @@ int eval_probe_metric(struct client_s client_entry, struct probe_entry_s probe_e
|
|||
printf("AAAHHHHHHHHHHH IDEAL!!!\n");
|
||||
}
|
||||
|
||||
score += client_supports_vht ? metric.vht_support : metric.n_vht_support;
|
||||
score += client_supports_ht ? metric.ht_support : metric.n_ht_support;
|
||||
score += client_supports_vht ? dawn_metric.vht_support : dawn_metric.n_vht_support;
|
||||
score += client_supports_ht ? dawn_metric.ht_support : dawn_metric.n_ht_support;
|
||||
|
||||
//score += !client_supports_vht ? metric.n_vht_support : 0;
|
||||
//score += !client_supports_ht ? metric.n_ht_support : 0;
|
||||
|
||||
score += (probe_entry.freq > 5000) ? metric.freq : 0;
|
||||
score += (probe_entry.freq > 5000) ? dawn_metric.freq : 0;
|
||||
|
||||
//score += (client_entry.signal > -60) ? metric.freq : 0;
|
||||
|
||||
|
|
60
src/utils/dawn_uci.c
Normal file
60
src/utils/dawn_uci.c
Normal 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;
|
||||
}
|
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue