mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
test_storage: extend test harness; datastorage: two bug fixes
datastorage (bug fix): deleting expired array item would fail to test next item test_storage: extended to cover all required datastorage entry points test_storage: added ability to read script file test_storage: added new and revised test scripts TESTING.md: added to describe testing approach general: added various TODO notes on things to come back to general: revised #includes to make each "self-compiling" general: revised #includes to minimise usage across source files general: moved declarations and defintions to simplify and rationalise code datastorage: refactor to support scalability testing datastorage: made independent of time() calls to support testing datastorage: fixed redundant use of both SORT_NUM and SORT_LENGTH defines datastorage: fake kicking to test clients move between access points msghandler: new module to reduce compile time interdependencies mshhandler: (issue #100?) fixed SEGV memcpy() in dump_client() using strncpy() ubus: merged uface into ubus mac_utils: new module for MAC address utilites test_header: added target to help #include rationalisation Tested-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
parent
0f63e00c43
commit
67c3ed0d0a
46 changed files with 2947 additions and 1476 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef __DAWN_BROADCASTSOCKET_H
|
||||
#define __DAWN_BROADCASTSOCKET_H
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/**
|
||||
* Function that setups a broadcast socket.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef DAWN_CRYPTO_H
|
||||
#define DAWN_CRYPTO_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* Initialize gcrypt.
|
||||
|
|
|
|||
|
|
@ -3,16 +3,11 @@
|
|||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef ETH_ALEN
|
||||
#define ETH_ALEN 6
|
||||
#endif
|
||||
#include "mac_utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
/* Mac */
|
||||
|
||||
|
|
@ -20,7 +15,7 @@
|
|||
#define MAC_LIST_LENGTH 100
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
uint8_t mac_list[MAC_LIST_LENGTH][ETH_ALEN];
|
||||
extern uint8_t mac_list[][ETH_ALEN];
|
||||
|
||||
// ---------------- Functions ----------
|
||||
void insert_macs_from_file();
|
||||
|
|
@ -29,39 +24,37 @@ int insert_to_maclist(uint8_t mac[]);
|
|||
|
||||
int mac_in_maclist(uint8_t mac[]);
|
||||
|
||||
int mac_is_equal(uint8_t addr1[], uint8_t addr2[]);
|
||||
|
||||
int mac_is_greater(uint8_t addr1[], uint8_t addr2[]);
|
||||
|
||||
/* Metric */
|
||||
// ---------------- Global variables ----------------
|
||||
/*** Metrics and configuration data ***/
|
||||
|
||||
// ---------------- Structs ----------------
|
||||
struct probe_metric_s {
|
||||
int ap_weight;
|
||||
int ht_support;
|
||||
int vht_support;
|
||||
int no_ht_support;
|
||||
int no_vht_support;
|
||||
int rssi;
|
||||
int low_rssi;
|
||||
int freq;
|
||||
int chan_util;
|
||||
int max_chan_util;
|
||||
int rssi_val;
|
||||
int low_rssi_val;
|
||||
int chan_util_val;
|
||||
int max_chan_util_val;
|
||||
int ap_weight; // TODO: Never evaluated?
|
||||
int ht_support; // eval_probe_metric()()
|
||||
int vht_support; // eval_probe_metric()()
|
||||
int no_ht_support; // eval_probe_metric()()
|
||||
int no_vht_support; // eval_probe_metric()()
|
||||
int rssi; // eval_probe_metric()()
|
||||
int low_rssi; // eval_probe_metric()()
|
||||
int freq; // eval_probe_metric()()
|
||||
int chan_util; // eval_probe_metric()()
|
||||
int max_chan_util; // eval_probe_metric()()
|
||||
int rssi_val; // eval_probe_metric()()
|
||||
int low_rssi_val; // eval_probe_metric()()
|
||||
int chan_util_val; // eval_probe_metric()()
|
||||
int max_chan_util_val; // eval_probe_metric()()
|
||||
int min_probe_count;
|
||||
int bandwidth_threshold;
|
||||
int use_station_count;
|
||||
int max_station_diff;
|
||||
int bandwidth_threshold; // kick_clients()
|
||||
int use_station_count; // better_ap_available()
|
||||
int max_station_diff; // compare_station_count() <- better_ap_available()
|
||||
int eval_probe_req;
|
||||
int eval_auth_req;
|
||||
int eval_assoc_req;
|
||||
int deny_auth_reason;
|
||||
int deny_assoc_reason;
|
||||
int use_driver_recog;
|
||||
int min_kick_count;
|
||||
int min_kick_count; // kick_clients()
|
||||
int chan_util_avg_period;
|
||||
int set_hostapd_nr;
|
||||
int kicking;
|
||||
|
|
@ -98,12 +91,18 @@ struct network_config_s {
|
|||
int bandwidth;
|
||||
};
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
struct network_config_s network_config;
|
||||
struct time_config_s timeout_config;
|
||||
extern struct network_config_s network_config;
|
||||
extern struct time_config_s timeout_config;
|
||||
extern struct probe_metric_s dawn_metric;
|
||||
|
||||
struct probe_metric_s dawn_metric;
|
||||
extern int probe_entry_last;
|
||||
/*** Core DAWN data structures for tracking network devices and status ***/
|
||||
// Define this to remove printing / reporing of fields, and hence observe
|
||||
// which fields are evaluated in use.
|
||||
// #define DAWN_NO_OUTPUT
|
||||
|
||||
// TODO notes:
|
||||
// Never used? = No code reference
|
||||
// Never evaluated? = Set and passed in ubus, etc but never evaluated for outcomes
|
||||
|
||||
/* Probe, Auth, Assoc */
|
||||
|
||||
|
|
@ -111,16 +110,18 @@ extern int probe_entry_last;
|
|||
typedef struct probe_entry_s {
|
||||
uint8_t bssid_addr[ETH_ALEN];
|
||||
uint8_t client_addr[ETH_ALEN];
|
||||
uint8_t target_addr[ETH_ALEN];
|
||||
uint32_t signal;
|
||||
uint32_t freq;
|
||||
uint8_t ht_capabilities;
|
||||
uint8_t vht_capabilities;
|
||||
time_t time;
|
||||
uint8_t target_addr[ETH_ALEN]; // TODO: Never evaluated?
|
||||
uint32_t signal; // eval_probe_metric()
|
||||
uint32_t freq; // eval_probe_metric()
|
||||
uint8_t ht_capabilities; // eval_probe_metric()
|
||||
uint8_t vht_capabilities; // eval_probe_metric()
|
||||
time_t time; // remove_old...entries
|
||||
int counter;
|
||||
int deny_counter;
|
||||
uint8_t max_supp_datarate;
|
||||
uint8_t min_supp_datarate;
|
||||
#ifndef DAWN_NO_OUTPUT
|
||||
int deny_counter; // TODO: Never used?
|
||||
uint8_t max_supp_datarate; // TODO: Never used?
|
||||
uint8_t min_supp_datarate; // TODO: Never used?
|
||||
#endif
|
||||
uint32_t rcpi;
|
||||
uint32_t rsni;
|
||||
} probe_entry;
|
||||
|
|
@ -128,10 +129,10 @@ typedef struct probe_entry_s {
|
|||
typedef struct auth_entry_s {
|
||||
uint8_t bssid_addr[ETH_ALEN];
|
||||
uint8_t client_addr[ETH_ALEN];
|
||||
uint8_t target_addr[ETH_ALEN];
|
||||
uint32_t signal;
|
||||
uint32_t freq;
|
||||
time_t time;
|
||||
uint8_t target_addr[ETH_ALEN]; // TODO: Never evaluated?
|
||||
uint32_t signal; // TODO: Never evaluated?
|
||||
uint32_t freq; // TODO: Never evaluated?
|
||||
time_t time; // Never used for removal?
|
||||
int counter;
|
||||
} auth_entry;
|
||||
|
||||
|
|
@ -150,13 +151,13 @@ typedef struct auth_entry_s assoc_entry;
|
|||
#define NEIGHBOR_REPORT_LEN 200
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
struct auth_entry_s denied_req_array[DENY_REQ_ARRAY_LEN];
|
||||
extern struct auth_entry_s denied_req_array[];
|
||||
extern int denied_req_last;
|
||||
pthread_mutex_t denied_array_mutex;
|
||||
extern pthread_mutex_t denied_array_mutex;
|
||||
|
||||
struct probe_entry_s probe_array[PROBE_ARRAY_LEN];
|
||||
extern struct probe_entry_s probe_array[];
|
||||
extern int probe_entry_last;
|
||||
pthread_mutex_t probe_array_mutex;
|
||||
extern pthread_mutex_t probe_array_mutex;
|
||||
|
||||
// ---------------- Functions ----------------
|
||||
probe_entry insert_to_array(probe_entry entry, int inc_counter, int save_80211k, int is_beacon);
|
||||
|
|
@ -192,39 +193,39 @@ void print_auth_entry(auth_entry entry);
|
|||
typedef struct client_s {
|
||||
uint8_t bssid_addr[ETH_ALEN];
|
||||
uint8_t client_addr[ETH_ALEN];
|
||||
char signature[SIGNATURE_LEN];
|
||||
uint8_t ht_supported;
|
||||
uint8_t vht_supported;
|
||||
uint32_t freq;
|
||||
uint8_t auth;
|
||||
uint8_t assoc;
|
||||
uint8_t authorized;
|
||||
uint8_t preauth;
|
||||
uint8_t wds;
|
||||
uint8_t wmm;
|
||||
uint8_t ht;
|
||||
uint8_t vht;
|
||||
uint8_t wps;
|
||||
uint8_t mfp;
|
||||
time_t time;
|
||||
uint32_t aid;
|
||||
uint32_t kick_count;
|
||||
char signature[SIGNATURE_LEN]; // TODO: Never evaluated?
|
||||
uint8_t ht_supported; // TODO: Never evaluated?
|
||||
uint8_t vht_supported; // TODO: Never evaluated?
|
||||
uint32_t freq; // TODO: Never evaluated?
|
||||
uint8_t auth; // TODO: Never evaluated?
|
||||
uint8_t assoc; // TODO: Never evaluated?
|
||||
uint8_t authorized; // TODO: Never evaluated?
|
||||
uint8_t preauth; // TODO: Never evaluated?
|
||||
uint8_t wds; // TODO: Never evaluated?
|
||||
uint8_t wmm; // TODO: Never evaluated?
|
||||
uint8_t ht; // TODO: Never evaluated?
|
||||
uint8_t vht; // TODO: Never evaluated?
|
||||
uint8_t wps; // TODO: Never evaluated?
|
||||
uint8_t mfp; // TODO: Never evaluated?
|
||||
time_t time; // remove_old...entries
|
||||
uint32_t aid; // TODO: Never evaluated?
|
||||
uint32_t kick_count; // kick_clients()
|
||||
uint8_t rrm_enabled_capa; //the first byte is enough
|
||||
} client;
|
||||
|
||||
typedef struct ap_s {
|
||||
uint8_t bssid_addr[ETH_ALEN];
|
||||
uint32_t freq;
|
||||
uint8_t ht_support;
|
||||
uint8_t vht_support;
|
||||
uint32_t channel_utilization;
|
||||
time_t time;
|
||||
uint32_t station_count;
|
||||
uint8_t ssid[SSID_MAX_LEN];
|
||||
uint32_t freq; // TODO: Never evaluated?
|
||||
uint8_t ht_support; // eval_probe_metric()
|
||||
uint8_t vht_support; // eval_probe_metric()
|
||||
uint32_t channel_utilization; // eval_probe_metric()
|
||||
time_t time; // remove_old...entries
|
||||
uint32_t station_count; // compare_station_count() <- better_ap_available()
|
||||
uint8_t ssid[SSID_MAX_LEN]; // compare_sid() < -better_ap_available()
|
||||
char neighbor_report[NEIGHBOR_REPORT_LEN];
|
||||
uint32_t collision_domain;
|
||||
uint32_t bandwidth;
|
||||
uint32_t ap_weight;
|
||||
uint32_t collision_domain; // TODO: ap_get_collision_count() never evaluated?
|
||||
uint32_t bandwidth; // TODO: Never evaluated?
|
||||
uint32_t ap_weight; // eval_probe_metric()
|
||||
char iface[MAX_INTERFACE_NAME];
|
||||
char hostname[HOST_NAME_MAX];
|
||||
} ap;
|
||||
|
|
@ -232,19 +233,20 @@ typedef struct ap_s {
|
|||
// ---------------- Defines ----------------
|
||||
#define ARRAY_AP_LEN 50
|
||||
#define TIME_THRESHOLD_AP 30
|
||||
|
||||
#define ARRAY_CLIENT_LEN 1000
|
||||
#define TIME_THRESHOLD_CLIENT 30
|
||||
#define TIME_THRESHOLD_CLIENT_UPDATE 10
|
||||
#define TIME_THRESHOLD_CLIENT_KICK 60
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
struct ap_s ap_array[ARRAY_AP_LEN];
|
||||
extern struct ap_s ap_array[];
|
||||
extern int ap_entry_last;
|
||||
pthread_mutex_t ap_array_mutex;
|
||||
extern pthread_mutex_t ap_array_mutex;
|
||||
|
||||
struct client_s client_array[ARRAY_CLIENT_LEN];
|
||||
extern struct client_s client_array[];
|
||||
extern int client_entry_last;
|
||||
pthread_mutex_t client_array_mutex;
|
||||
extern pthread_mutex_t client_array_mutex;
|
||||
|
||||
// ---------------- Functions ----------------
|
||||
|
||||
|
|
@ -256,10 +258,14 @@ void remove_old_client_entries(time_t current_time, long long int threshold);
|
|||
|
||||
void insert_client_to_array(client entry);
|
||||
|
||||
void kick_clients(uint8_t bssid[], uint32_t id);
|
||||
int kick_clients(uint8_t bssid[], uint32_t id);
|
||||
|
||||
void update_iw_info(uint8_t bssid[]);
|
||||
|
||||
void client_array_insert(client entry);
|
||||
|
||||
client client_array_get_client(const uint8_t* client_addr);
|
||||
|
||||
client client_array_delete(client entry);
|
||||
|
||||
void print_client_array();
|
||||
|
|
@ -278,20 +284,20 @@ ap ap_array_get_ap(uint8_t bssid_addr[]);
|
|||
|
||||
int probe_array_set_all_probe_count(uint8_t client_addr[], uint32_t probe_count);
|
||||
|
||||
#ifndef DAWN_NO_OUTPUT
|
||||
int ap_get_collision_count(int col_domain);
|
||||
#endif
|
||||
|
||||
void send_beacon_reports(uint8_t bssid[], int id);
|
||||
|
||||
/* Utils */
|
||||
|
||||
// ---------------- Defines -------------------
|
||||
#define SORT_NUM 5
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
#define SORT_LENGTH 5
|
||||
char sort_string[SORT_LENGTH];
|
||||
extern char sort_string[];
|
||||
|
||||
// ---------------- Functions -------------------
|
||||
int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[], char* neighbor_report, int automatic_kick);
|
||||
|
||||
// All users of datastorage should call init_ / destroy_mutex at initialisation and termination respectively
|
||||
int init_mutex();
|
||||
void destroy_mutex();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#ifndef DAWN_RSSI_H
|
||||
#define DAWN_RSSI_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
#define HOSTAPD_DIR_LEN 200
|
||||
extern char hostapd_dir_glob[];
|
||||
|
||||
/**
|
||||
* Get RSSI using the mac adress of the client.
|
||||
* Function uses libiwinfo and searches through all interfaces that are existing.
|
||||
|
|
@ -58,7 +59,7 @@ int get_expected_throughput(const char *ifname, uint8_t *client_addr);
|
|||
|
||||
int get_bssid(const char *ifname, uint8_t *bssid_addr);
|
||||
|
||||
int get_ssid(const char *ifname, char *ssid);
|
||||
int get_ssid(const char *ifname, char *ssid, size_t ssidmax);
|
||||
|
||||
int get_channel_utilization(const char *ifname, uint64_t *last_channel_time, uint64_t *last_channel_time_busy);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef DAWN_UCI_H
|
||||
#define DAWN_UCI_H
|
||||
|
||||
#include <time.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* Init uci. Call this function before using the other functions!
|
||||
* @return if call was successful.
|
||||
|
|
|
|||
|
|
@ -17,4 +17,11 @@ double iee80211_calculate_bitrate(uint8_t supp_rate_val);
|
|||
*/
|
||||
double iee80211_calculate_expected_throughput_mbit(int exp_thr);
|
||||
|
||||
/**
|
||||
* Convert 802.11k RCPI value to RSSI dB
|
||||
* @param rcpi
|
||||
* @return
|
||||
*/
|
||||
int rcpi_to_rssi(int rcpi);
|
||||
|
||||
#endif //DAWN_IEEE80211_UTILS_H
|
||||
|
|
|
|||
43
src/include/mac_utils.h
Normal file
43
src/include/mac_utils.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef __DAWN_MAC_UTILS_H
|
||||
#define __DAWN_MAC_UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||
#define STR2MAC(a) &(a)[0], &(a)[1], &(a)[2], &(a)[3], &(a)[4], &(a)[5]
|
||||
|
||||
#define MACSTR "%02X:%02X:%02X:%02X:%02X:%02X"
|
||||
#define MACSTRLOWER "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
|
||||
#ifndef ETH_ALEN
|
||||
#define ETH_ALEN 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Convert mac adress string to mac adress.
|
||||
* @param txt
|
||||
* @param addr
|
||||
* @return
|
||||
*/
|
||||
int hwaddr_aton(const char* txt, uint8_t* addr);
|
||||
|
||||
/**
|
||||
* Convert mac to use big characters.
|
||||
* @param in
|
||||
* @param out
|
||||
* @return
|
||||
*/
|
||||
int convert_mac(char* in, char* out);
|
||||
|
||||
/**
|
||||
* Write mac to a file.
|
||||
* @param path
|
||||
* @param addr
|
||||
*/
|
||||
void write_mac_to_file(char* path, uint8_t addr[]);
|
||||
|
||||
int mac_is_equal(const uint8_t addr1[], const uint8_t addr2[]);
|
||||
|
||||
int mac_is_greater(const uint8_t addr1[], const uint8_t addr2[]);
|
||||
|
||||
#endif
|
||||
47
src/include/msghandler.h
Normal file
47
src/include/msghandler.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef __DAWN_MSGHANDLER_H
|
||||
#define __DAWN_MSGHANDLER_H
|
||||
|
||||
#include <libubox/blobmsg_json.h>
|
||||
|
||||
#include "datastorage.h"
|
||||
|
||||
/**
|
||||
* Parse to probe request.
|
||||
* @param msg
|
||||
* @param prob_req
|
||||
* @return
|
||||
*/
|
||||
int parse_to_probe_req(struct blob_attr* msg, probe_entry* prob_req);
|
||||
|
||||
/**
|
||||
* Dump a client array into the database.
|
||||
* @param msg - message to parse.
|
||||
* @param do_kick - use the automatic kick function when updating the clients.
|
||||
* @param id - ubus id.
|
||||
* @return
|
||||
*/
|
||||
int parse_to_clients(struct blob_attr* msg, int do_kick, uint32_t id);
|
||||
|
||||
/**
|
||||
* Parse to hostapd notify.
|
||||
* Notify are such notifications like:
|
||||
* + Disassociation
|
||||
* + Deauthentication
|
||||
* + ...
|
||||
* @param msg
|
||||
* @param notify_req
|
||||
* @return
|
||||
*/
|
||||
int parse_to_hostapd_notify(struct blob_attr* msg, hostapd_notify_entry* notify_req);
|
||||
|
||||
/**
|
||||
* Handle network messages.
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
int handle_network_msg(char* msg);
|
||||
|
||||
|
||||
int handle_deauth_req(struct blob_attr* msg);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef __DAWN_MULTICASTSTSOCKET_H
|
||||
#define __DAWN_MULTICASTSSOCKET_H
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/**
|
||||
* Setup a multicast socket.
|
||||
* Setup permissions. Join the multicast group, etc. ...
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include <pthread.h>
|
||||
|
||||
pthread_mutex_t send_mutex;
|
||||
|
||||
/**
|
||||
* Init a socket using the runopts.
|
||||
* @param _ip - ip to use.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <libubox/ustream.h>
|
||||
#include <netinet/in.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define ARRAY_NETWORK_LEN 50
|
||||
|
||||
|
|
|
|||
14
src/include/test_storage.h
Normal file
14
src/include/test_storage.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef __DAWN_TESTSTORAGE_H
|
||||
#define __DAWN_TESTSTORAGE_H
|
||||
|
||||
#include "datastorage.h"
|
||||
|
||||
/*
|
||||
** Contains declerations, etc needed across datastorage and its test harness,
|
||||
** but not more widely.
|
||||
*/
|
||||
void ap_array_insert(ap entry);
|
||||
|
||||
ap ap_array_delete(ap entry);
|
||||
|
||||
#endif
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
#include <libubox/blobmsg_json.h>
|
||||
#include <libubox/uloop.h>
|
||||
|
||||
|
||||
#include "datastorage.h"
|
||||
|
||||
// 802.11 Status codes
|
||||
|
|
@ -17,9 +16,6 @@
|
|||
#define UNSPECIFIED_REASON 0
|
||||
#define NO_MORE_STAS 5
|
||||
|
||||
#define HOSTAPD_DIR_LEN 200
|
||||
char hostapd_dir_glob[HOSTAPD_DIR_LEN];
|
||||
|
||||
/**
|
||||
* Init ubus.
|
||||
* Setup tcp socket.
|
||||
|
|
@ -41,14 +37,6 @@ void start_umdns_update();
|
|||
*/
|
||||
int ubus_call_umdns();
|
||||
|
||||
/**
|
||||
* Parse to probe request.
|
||||
* @param msg
|
||||
* @param prob_req
|
||||
* @return
|
||||
*/
|
||||
int parse_to_probe_req(struct blob_attr *msg, probe_entry *prob_req);
|
||||
|
||||
/**
|
||||
* Parse to authentication request.
|
||||
* @param msg
|
||||
|
|
@ -65,27 +53,6 @@ int parse_to_auth_req(struct blob_attr *msg, auth_entry *auth_req);
|
|||
*/
|
||||
int parse_to_assoc_req(struct blob_attr *msg, assoc_entry *assoc_req);
|
||||
|
||||
/**
|
||||
* Dump a client array into the database.
|
||||
* @param msg - message to parse.
|
||||
* @param do_kick - use the automatic kick function when updating the clients.
|
||||
* @param id - ubus id.
|
||||
* @return
|
||||
*/
|
||||
int parse_to_clients(struct blob_attr *msg, int do_kick, uint32_t id);
|
||||
|
||||
/**
|
||||
* Parse to hostapd notify.
|
||||
* Notify are such notifications like:
|
||||
* + Disassociation
|
||||
* + Deauthentication
|
||||
* + ...
|
||||
* @param msg
|
||||
* @param notify_req
|
||||
* @return
|
||||
*/
|
||||
int parse_to_hostapd_notify(struct blob_attr *msg, hostapd_notify_entry *notify_req);
|
||||
|
||||
/**
|
||||
* Kick client from all hostapd interfaces.
|
||||
* @param client_addr - the client adress of the client to kick.
|
||||
|
|
@ -102,19 +69,34 @@ void del_client_all_interfaces(const uint8_t *client_addr, uint32_t reason, uint
|
|||
void update_hostapd_sockets(struct uloop_timeout *t);
|
||||
|
||||
/**
|
||||
* Handle network messages.
|
||||
* @param msg
|
||||
* Send control message to all hosts to add the mac to a don't control list.
|
||||
* @param client_addr
|
||||
* @return
|
||||
*/
|
||||
int handle_network_msg(char *msg);
|
||||
int send_add_mac(uint8_t *client_addr);
|
||||
|
||||
void ubus_send_beacon_report(uint8_t client[], int id);
|
||||
|
||||
void uloop_add_data_cbs();
|
||||
|
||||
int uci_send_via_network();
|
||||
|
||||
int build_hearing_map_sort_client(struct blob_buf* b);
|
||||
|
||||
int build_network_overview(struct blob_buf* b);
|
||||
|
||||
int ap_get_nr(struct blob_buf* b, uint8_t own_bssid_addr[]);
|
||||
|
||||
int parse_add_mac_to_file(struct blob_attr* msg);
|
||||
|
||||
int handle_auth_req(struct blob_attr* msg);
|
||||
|
||||
/**
|
||||
* Send message via network.
|
||||
* @param msg
|
||||
* @param method
|
||||
* Send probe message via the network.
|
||||
* @param probe_entry
|
||||
* @return
|
||||
*/
|
||||
int send_blob_attr_via_network(struct blob_attr *msg, char *method);
|
||||
int ubus_send_probe_via_network(struct probe_entry_s probe_entry);
|
||||
|
||||
/**
|
||||
* Add mac to a list that contains addresses of clients that can not be controlled.
|
||||
|
|
@ -125,18 +107,45 @@ int send_blob_attr_via_network(struct blob_attr *msg, char *method);
|
|||
void blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const uint8_t *addr);
|
||||
|
||||
/**
|
||||
* Send control message to all hosts to add the mac to a don't control list.
|
||||
* Send message via network.
|
||||
* @param msg
|
||||
* @param method
|
||||
* @return
|
||||
*/
|
||||
int send_blob_attr_via_network(struct blob_attr* msg, char* method);
|
||||
|
||||
/**
|
||||
* Set client timer for updating the clients.
|
||||
* @param time
|
||||
*/
|
||||
void add_client_update_timer(time_t time);
|
||||
|
||||
/**
|
||||
* Kick client from hostapd interface.
|
||||
* @param id - the ubus id.
|
||||
* @param client_addr - the client adress of the client to kick.
|
||||
* @param reason - the reason to kick the client.
|
||||
* @param deauth - if the client should be deauthenticated.
|
||||
* @param ban_time - the ban time the client is not allowed to connect again.
|
||||
*/
|
||||
void del_client_interface(uint32_t id, const uint8_t* client_addr, uint32_t reason, uint8_t deauth, uint32_t ban_time);
|
||||
|
||||
/**
|
||||
* Function to set the probe counter to the min probe request.
|
||||
* This allows that the client is able to connect directly without sending multiple probe requests to the Access Point.
|
||||
* @param client_addr
|
||||
* @return
|
||||
*/
|
||||
int send_add_mac(uint8_t *client_addr);
|
||||
int send_set_probe(uint8_t client_addr[]);
|
||||
|
||||
int uci_send_via_network();
|
||||
|
||||
int build_hearing_map_sort_client(struct blob_buf *b);
|
||||
|
||||
int build_network_overview(struct blob_buf *b);
|
||||
|
||||
int ap_get_nr(struct blob_buf *b, uint8_t own_bssid_addr[]);
|
||||
/**
|
||||
* Function to tell a client that it is about to be disconnected.
|
||||
* @param id
|
||||
* @param client_addr
|
||||
* @param dest_ap
|
||||
* @param duration
|
||||
* @return - 0 = asynchronous (client has been told to remove itself, and caller should manage arrays); 1 = synchronous (caller should assume arrays are updated)
|
||||
*/
|
||||
int wnm_disassoc_imminent(uint32_t id, const uint8_t* client_addr, char* dest_ap, uint32_t duration);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
#ifndef __DAWN_UFACE_H
|
||||
#define __DAWN_UFACE_H
|
||||
|
||||
/**
|
||||
* Set client timer for updating the clients.
|
||||
* @param time
|
||||
*/
|
||||
void add_client_update_timer(time_t time);
|
||||
|
||||
/**
|
||||
* Kick client from hostapd interface.
|
||||
* @param id - the ubus id.
|
||||
* @param client_addr - the client adress of the client to kick.
|
||||
* @param reason - the reason to kick the client.
|
||||
* @param deauth - if the client should be deauthenticated.
|
||||
* @param ban_time - the ban time the client is not allowed to connect again.
|
||||
*/
|
||||
void del_client_interface(uint32_t id, const uint8_t *client_addr, uint32_t reason, uint8_t deauth, uint32_t ban_time);
|
||||
|
||||
/**
|
||||
* Function to set the probe counter to the min probe request.
|
||||
* This allows that the client is able to connect directly without sending multiple probe requests to the Access Point.
|
||||
* @param client_addr
|
||||
* @return
|
||||
*/
|
||||
int send_set_probe(uint8_t client_addr[]);
|
||||
|
||||
void ubus_send_beacon_report(uint8_t client[], int id);
|
||||
|
||||
/**
|
||||
* Send probe message via the network.
|
||||
* @param probe_entry
|
||||
* @return
|
||||
*/
|
||||
int ubus_send_probe_via_network(struct probe_entry_s probe_entry);
|
||||
|
||||
void uloop_add_data_cbs();
|
||||
|
||||
void wnm_disassoc_imminent(uint32_t id, const uint8_t *client_addr, char* dest_ap, uint32_t duration);
|
||||
|
||||
#endif // __DAWN_UFACE_H
|
||||
|
|
@ -2,43 +2,13 @@
|
|||
#define __DAWN_UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||
#define STR2MAC(a) &(a)[0], &(a)[1], &(a)[2], &(a)[3], &(a)[4], &(a)[5]
|
||||
|
||||
#define MACSTR "%02X:%02X:%02X:%02X:%02X:%02X"
|
||||
#define MACSTRLOWER "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
|
||||
/**
|
||||
* Convert char to binary.
|
||||
* @param ch
|
||||
* @return
|
||||
*/
|
||||
int hex_to_bin(char ch);
|
||||
|
||||
/**
|
||||
* Convert mac adress string to mac adress.
|
||||
* @param txt
|
||||
* @param addr
|
||||
* @return
|
||||
*/
|
||||
int hwaddr_aton(const char *txt, uint8_t *addr);
|
||||
|
||||
/**
|
||||
* Convert mac to use big characters.
|
||||
* @param in
|
||||
* @param out
|
||||
* @return
|
||||
*/
|
||||
int convert_mac(char *in, char *out);
|
||||
|
||||
/**
|
||||
* Write mac to a file.
|
||||
* @param path
|
||||
* @param addr
|
||||
*/
|
||||
void write_mac_to_file(char *path, uint8_t addr[]);
|
||||
int hex_to_dec(char ch);
|
||||
|
||||
/**
|
||||
* Check if a string is greater than another one.
|
||||
|
|
@ -48,6 +18,4 @@ void write_mac_to_file(char *path, uint8_t addr[]);
|
|||
*/
|
||||
int string_is_greater(uint8_t *str, uint8_t *str_2);
|
||||
|
||||
int rcpi_to_rssi(int rcpi);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue