mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
update
This commit is contained in:
parent
3d1511974f
commit
400866db9d
4 changed files with 29 additions and 28 deletions
12
src/main.c
12
src/main.c
|
@ -26,7 +26,7 @@ void daemon_shutdown() {
|
|||
uloop_cancelled = true;
|
||||
|
||||
// free ressources
|
||||
printf("Freeing mutex ressources\n");
|
||||
fprintf(stdout, "Freeing mutex ressources\n");
|
||||
pthread_mutex_destroy(&list_mutex);
|
||||
pthread_mutex_destroy(&probe_array_mutex);
|
||||
pthread_mutex_destroy(&client_array_mutex);
|
||||
|
@ -53,17 +53,17 @@ void signal_handler(int sig) {
|
|||
|
||||
int init_mutex() {
|
||||
if (pthread_mutex_init(&list_mutex, NULL) != 0) {
|
||||
printf("\n mutex init failed\n");
|
||||
fprintf(stderr,"Mutex init failed!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&probe_array_mutex, NULL) != 0) {
|
||||
printf("\n mutex init failed\n");
|
||||
fprintf(stderr,"Mutex init failed!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&client_array_mutex, NULL) != 0) {
|
||||
printf("\n mutex init failed\n");
|
||||
fprintf(stderr,"Mutex init failed!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -73,12 +73,12 @@ int init_mutex() {
|
|||
}
|
||||
|
||||
if (pthread_mutex_init(&tcp_array_mutex, NULL) != 0) {
|
||||
printf("\n mutex init failed\n");
|
||||
fprintf(stderr,"Mutex init failed!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&denied_array_mutex, NULL) != 0) {
|
||||
printf("\n mutex init failed\n");
|
||||
fprintf(stderr,"Mutex init failed!\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -931,6 +931,9 @@ void denied_req_array_cb(struct uloop_timeout *t) {
|
|||
if(!is_connected_somehwere(denied_req_array[i].client_addr))
|
||||
{
|
||||
printf("Client has propaly a BAD DRIVER!\n");
|
||||
|
||||
// problem that somehow station will land into this list
|
||||
// maybe delete again?
|
||||
if (insert_to_maclist(denied_req_array[i].client_addr) == 0) {
|
||||
send_add_mac(denied_req_array[i].client_addr);
|
||||
write_mac_to_file("/etc/dawn/mac_list", denied_req_array[i].client_addr);
|
||||
|
|
|
@ -19,8 +19,6 @@ static int uci_lookup_option_int(struct uci_context *uci, struct uci_section *s,
|
|||
struct time_config_s uci_get_time_config() {
|
||||
struct time_config_s ret;
|
||||
|
||||
printf("Loading Times!");
|
||||
|
||||
struct uci_element *e;
|
||||
uci_foreach_element(&uci_pkg->sections, e)
|
||||
{
|
||||
|
@ -89,7 +87,6 @@ struct network_config_s uci_get_dawn_network() {
|
|||
struct uci_section *s = uci_to_section(e);
|
||||
|
||||
if (strcmp(s->type, "network") == 0) {
|
||||
printf("Fronund network entry!\n");
|
||||
ret.broadcast_ip = uci_lookup_option_string(uci_ctx, s, "broadcast_ip");
|
||||
ret.broadcast_port = uci_lookup_option_int(uci_ctx, s, "broadcast_port");
|
||||
ret.bool_multicast = uci_lookup_option_int(uci_ctx, s, "multicast");
|
||||
|
|
|
@ -611,8 +611,15 @@ int send_blob_attr_via_network(struct blob_attr *msg, char *method) {
|
|||
|
||||
//blobmsg_add_blob(&b, msg);
|
||||
str = blobmsg_format_json(b_send_network.head, true);
|
||||
//send_string_enc(str);
|
||||
send_tcp(str);
|
||||
|
||||
if (network_config.network_option == 2)
|
||||
{
|
||||
send_tcp(str);
|
||||
} else
|
||||
{
|
||||
send_string_enc(str);
|
||||
}
|
||||
//send_tcp(str);
|
||||
//free(str);
|
||||
//free(data_str);
|
||||
return 0;
|
||||
|
@ -1022,9 +1029,6 @@ int ubus_call_umdns() {
|
|||
}
|
||||
|
||||
int ubus_send_probe_via_network(struct probe_entry_s probe_entry) {
|
||||
|
||||
printf("SENDING PROBE VIA NETWORK!\n");
|
||||
|
||||
blob_buf_init(&b_probe, 0);
|
||||
blobmsg_add_macaddr(&b_probe, "bssid", probe_entry.bssid_addr);
|
||||
blobmsg_add_macaddr(&b_probe, "address", probe_entry.client_addr);
|
||||
|
@ -1040,9 +1044,6 @@ int ubus_send_probe_via_network(struct probe_entry_s probe_entry) {
|
|||
}
|
||||
|
||||
int send_set_probe(uint8_t client_addr[]) {
|
||||
|
||||
printf("SENDING SET PROBE VIA NETWORK!\n");
|
||||
|
||||
blob_buf_init(&b_probe, 0);
|
||||
blobmsg_add_macaddr(&b_probe, "bssid", client_addr);
|
||||
blobmsg_add_macaddr(&b_probe, "address", client_addr);
|
||||
|
@ -1114,16 +1115,18 @@ int send_add_mac(uint8_t* client_addr) {
|
|||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_macaddr(&b, "addr", client_addr);
|
||||
send_blob_attr_via_network(b.head, "addmac");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_hearing_map(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg) {
|
||||
int ret;
|
||||
|
||||
build_hearing_map_sort_client(&b);
|
||||
ubus_send_reply(ctx, req, b.head);
|
||||
ret = ubus_send_reply(ctx, req, b.head);
|
||||
if (ret)
|
||||
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1131,9 +1134,12 @@ static int get_hearing_map(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
static int get_network(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg) {
|
||||
int ret;
|
||||
|
||||
build_network_overview(&b);
|
||||
ubus_send_reply(ctx, req, b.head);
|
||||
ret = ubus_send_reply(ctx, req, b.head);
|
||||
if (ret)
|
||||
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1143,17 +1149,12 @@ static void ubus_add_oject() {
|
|||
ret = ubus_add_object(ctx, &dawn_object);
|
||||
if (ret)
|
||||
fprintf(stderr, "Failed to add object: %s\n", ubus_strerror(ret));
|
||||
printf("ADDED UBUS OBJECT!!!\n");
|
||||
|
||||
/*ret = ubus_register_subscriber(ctx, &test_event);
|
||||
if (ret)
|
||||
fprintf(stderr, "Failed to add watch handler: %s\n", ubus_strerror(ret));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
static void respond_to_notify(uint32_t id) {
|
||||
printf("SENDING NOTIFY!!!\n");
|
||||
// This is needed to respond to the ubus notify ...
|
||||
// TODO: Maybe we need to disable on shutdown...
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_u32(&b, "notify_response", 1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue