mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Give hostapd dir as parameter
This commit is contained in:
parent
29fe04b1f0
commit
976f90efc3
5 changed files with 23 additions and 9 deletions
|
@ -2,4 +2,5 @@ config 'settings' 'dawn'
|
|||
option broadcast_ip '192.186.1.255'
|
||||
option broadcast_port '1025'
|
||||
option sort_order 'cfsb'
|
||||
option hostapd_dir '/var/run/hostapd'
|
||||
option background '0'
|
|
@ -14,11 +14,15 @@ start_service()
|
|||
|
||||
local broadcast_ip
|
||||
local broadcast_port
|
||||
local sort_order
|
||||
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
|
||||
|
||||
|
||||
procd_open_instance
|
||||
echo "$PROG -p $broadcast_port -i $broadcast_ip -o $sort_order"
|
||||
|
@ -26,7 +30,7 @@ start_service()
|
|||
procd_append_param command -p "${broadcast_port}"
|
||||
procd_append_param command -i "${broadcast_ip}"
|
||||
procd_append_param command -o "${sort_order}"
|
||||
|
||||
procd_append_param command -h "${hostapd_dir}"
|
||||
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
|
|
12
src/main.c
12
src/main.c
|
@ -6,6 +6,8 @@
|
|||
#include "networksocket.h"
|
||||
|
||||
#define BUFSIZE 17
|
||||
#define BUFSIZE_DIR 255
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
@ -14,8 +16,9 @@ int main(int argc, char **argv)
|
|||
|
||||
char opt_broadcast_ip[BUFSIZE];
|
||||
char opt_broadcast_port[BUFSIZE];
|
||||
char opt_hostapd_dir[BUFSIZE_DIR];
|
||||
|
||||
while ((ch = getopt(argc, argv, "cs:p:i:b:o:")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "cs:p:i:b:o:h:")) != -1) {
|
||||
switch (ch) {
|
||||
case 's':
|
||||
ubus_socket = optarg;
|
||||
|
@ -31,10 +34,14 @@ int main(int argc, char **argv)
|
|||
case 'o':
|
||||
snprintf(sort_string,SORT_NUM,"%s",optarg);
|
||||
printf("sort string: %s\n", sort_string);
|
||||
case 'h':
|
||||
snprintf(opt_hostapd_dir,BUFSIZE_DIR,"%s",optarg);
|
||||
printf("hostapd dir: %s\n", opt_hostapd_dir);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
|
@ -53,7 +60,8 @@ int main(int argc, char **argv)
|
|||
|
||||
pthread_mutex_destroy(&list_mutex);
|
||||
|
||||
dawn_init_ubus(ubus_socket);
|
||||
|
||||
dawn_init_ubus(ubus_socket, opt_hostapd_dir);
|
||||
|
||||
return 0;
|
||||
}
|
11
src/ubus.c
11
src/ubus.c
|
@ -39,7 +39,7 @@ static int hostapd_notify(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
struct blob_attr *msg);
|
||||
static int add_subscriber(char* name);
|
||||
//int parse_to_probe_req(struct blob_attr *msg, probe_entry* prob_req);
|
||||
static int subscribe_to_hostapd_interfaces();
|
||||
static int subscribe_to_hostapd_interfaces(char* hostapd_dir);
|
||||
|
||||
static int decide_function(probe_entry* prob_req)
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ static int add_subscriber(char* name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int subscribe_to_hostapd_interfaces()
|
||||
static int subscribe_to_hostapd_interfaces(char* hostapd_dir)
|
||||
{
|
||||
DIR * dirp;
|
||||
struct dirent * entry;
|
||||
|
@ -145,7 +145,7 @@ static int subscribe_to_hostapd_interfaces()
|
|||
return -1;
|
||||
}
|
||||
|
||||
dirp = opendir("/var/run/hostapd"); // error handling?
|
||||
dirp = opendir(hostapd_dir); // error handling?
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
if (entry->d_type == DT_SOCK) {
|
||||
char subscribe_name[256];
|
||||
|
@ -154,10 +154,11 @@ static int subscribe_to_hostapd_interfaces()
|
|||
add_subscriber(subscribe_name);
|
||||
}
|
||||
}
|
||||
free(hostapd_dir); // free string
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dawn_init_ubus(const char *ubus_socket)
|
||||
int dawn_init_ubus(const char *ubus_socket, char* hostapd_dir)
|
||||
{
|
||||
uloop_init();
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
@ -172,7 +173,7 @@ int dawn_init_ubus(const char *ubus_socket)
|
|||
|
||||
ubus_add_uloop(ctx);
|
||||
|
||||
subscribe_to_hostapd_interfaces();
|
||||
subscribe_to_hostapd_interfaces(hostapd_dir);
|
||||
|
||||
uloop_run();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "datastorage.h"
|
||||
|
||||
int dawn_init_ubus(const char *ubus_socket);
|
||||
int dawn_init_ubus(const char *ubus_socket, char* hostapd_dir);
|
||||
int parse_to_probe_req(struct blob_attr *msg, probe_entry* prob_req);
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue