mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
first version
This commit is contained in:
commit
f03f55ff92
28 changed files with 5682 additions and 0 deletions
14
src/include/broadcastsocket.h
Normal file
14
src/include/broadcastsocket.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef __DAWN_BROADCASTSOCKET_H
|
||||
#define __DAWN_BROADCASTSOCKET_H
|
||||
|
||||
|
||||
/**
|
||||
* Function that setups a broadcast socket.
|
||||
* @param _broadcast_ip - The broadcast ip to use.
|
||||
* @param _broadcast_port - The broadcast port to use.
|
||||
* @param addr The sockaddr_in struct.
|
||||
* @return the socket that was created.
|
||||
*/
|
||||
int setup_broadcast_socket(const char *_broadcast_ip, unsigned short _broadcast_port, struct sockaddr_in *addr);
|
||||
|
||||
#endif
|
||||
38
src/include/crypto.h
Normal file
38
src/include/crypto.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef DAWN_CRYPTO_H
|
||||
#define DAWN_CRYPTO_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Initialize gcrypt.
|
||||
* Has to be called before using the other functions!
|
||||
*/
|
||||
void gcrypt_init();
|
||||
|
||||
/**
|
||||
* Set the Key and the iv.
|
||||
* @param key
|
||||
* @param iv
|
||||
*/
|
||||
void gcrypt_set_key_and_iv(const char *key, const char *iv);
|
||||
|
||||
/**
|
||||
* Function that encrypts the message.
|
||||
* Free the string after using it!
|
||||
* @param msg
|
||||
* @param msg_length
|
||||
* @param out_length
|
||||
* @return the encrypted string.
|
||||
*/
|
||||
char *gcrypt_encrypt_msg(char *msg, size_t msg_length, int *out_length);
|
||||
|
||||
/**
|
||||
* FUnction that decrypts a message.
|
||||
* Free the string after using it!
|
||||
* @param msg
|
||||
* @param msg_length
|
||||
* @return the decrypted string.
|
||||
*/
|
||||
char *gcrypt_decrypt_msg(char *msg, size_t msg_length);
|
||||
|
||||
#endif //DAWN_CRYPTO_H
|
||||
267
src/include/datastorage.h
Normal file
267
src/include/datastorage.h
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
#ifndef __DAWN_DATASTORAGE_H
|
||||
#define __DAWN_DATASTORAGE_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <libubox/blobmsg_json.h>
|
||||
|
||||
#ifndef ETH_ALEN
|
||||
#define ETH_ALEN 6
|
||||
#endif
|
||||
|
||||
/* Mac */
|
||||
|
||||
// ---------------- Defines -------------------
|
||||
#define MAC_LIST_LENGTH 100
|
||||
|
||||
// ---------------- Structs ----------------
|
||||
uint8_t mac_list[MAC_LIST_LENGTH][ETH_ALEN];
|
||||
|
||||
// ---------------- Functions ----------
|
||||
void insert_macs_from_file();
|
||||
|
||||
int insert_to_maclist(uint8_t mac[]);
|
||||
|
||||
int mac_in_maclist(uint8_t mac[]);
|
||||
|
||||
|
||||
/* Metric */
|
||||
|
||||
struct probe_metric_s dawn_metric;
|
||||
|
||||
// ---------------- 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 min_probe_count;
|
||||
int bandwith_threshold;
|
||||
int use_station_count;
|
||||
int max_station_diff;
|
||||
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 chan_util_avg_period;
|
||||
int kicking;
|
||||
};
|
||||
|
||||
struct time_config_s {
|
||||
time_t update_client;
|
||||
time_t remove_client;
|
||||
time_t remove_probe;
|
||||
time_t remove_ap;
|
||||
time_t update_hostapd;
|
||||
time_t update_tcp_con;
|
||||
time_t denied_req_threshold;
|
||||
time_t update_chan_util;
|
||||
};
|
||||
|
||||
struct network_config_s {
|
||||
const char *broadcast_ip;
|
||||
int broadcast_port;
|
||||
int tcp_port;
|
||||
int network_option;
|
||||
const char *multicast;
|
||||
const char *shared_key;
|
||||
const char *iv;
|
||||
int bool_multicast;
|
||||
int use_symm_enc;
|
||||
int collision_domain;
|
||||
int bandwidth;
|
||||
};
|
||||
|
||||
struct network_config_s network_config;
|
||||
struct time_config_s timeout_config;
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
struct probe_metric_s dawn_metric;
|
||||
|
||||
|
||||
/* Probe, Auth, Assoc */
|
||||
|
||||
// ---------------- Structs ----------------
|
||||
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;
|
||||
int counter;
|
||||
int deny_counter;
|
||||
uint8_t max_supp_datarate;
|
||||
uint8_t min_supp_datarate;
|
||||
} probe_entry;
|
||||
|
||||
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;
|
||||
int counter;
|
||||
} auth_entry;
|
||||
|
||||
typedef struct hostapd_notify_entry_s {
|
||||
uint8_t bssid_addr[ETH_ALEN];
|
||||
uint8_t client_addr[ETH_ALEN];
|
||||
} hostapd_notify_entry;
|
||||
|
||||
typedef struct auth_entry_s assoc_entry;
|
||||
|
||||
#define DENY_REQ_ARRAY_LEN 100
|
||||
struct auth_entry_s denied_req_array[DENY_REQ_ARRAY_LEN];
|
||||
pthread_mutex_t denied_array_mutex;
|
||||
|
||||
auth_entry insert_to_denied_req_array(auth_entry entry, int inc_counter);
|
||||
|
||||
// ---------------- Defines ----------------
|
||||
#define PROBE_ARRAY_LEN 1000
|
||||
|
||||
#define SSID_MAX_LEN 32
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
struct probe_entry_s probe_array[PROBE_ARRAY_LEN];
|
||||
pthread_mutex_t probe_array_mutex;
|
||||
|
||||
// ---------------- Functions ----------------
|
||||
probe_entry insert_to_array(probe_entry entry, int inc_counter);
|
||||
|
||||
void probe_array_insert(probe_entry entry);
|
||||
|
||||
probe_entry probe_array_delete(probe_entry entry);
|
||||
|
||||
probe_entry probe_array_get_entry(uint8_t bssid_addr[], uint8_t client_addr[]);
|
||||
|
||||
void print_probe_array();
|
||||
|
||||
void print_probe_entry(probe_entry entry);
|
||||
|
||||
void print_auth_entry(auth_entry entry);
|
||||
|
||||
void uloop_add_data_cbs();
|
||||
|
||||
/* AP, Client */
|
||||
|
||||
// blobmsg_alloc_string_buffer(&b, "signature", 1024);
|
||||
#define SIGNATURE_LEN 1024
|
||||
|
||||
// ---------------- Structs ----------------
|
||||
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;
|
||||
} 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 collision_domain;
|
||||
uint32_t bandwidth;
|
||||
uint32_t ap_weight;
|
||||
} ap;
|
||||
|
||||
// ---------------- 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 client_s client_array[ARRAY_CLIENT_LEN];
|
||||
pthread_mutex_t client_array_mutex;
|
||||
struct ap_s ap_array[ARRAY_AP_LEN];
|
||||
pthread_mutex_t ap_array_mutex;
|
||||
|
||||
int mac_is_equal(uint8_t addr1[], uint8_t addr2[]);
|
||||
|
||||
int mac_is_greater(uint8_t addr1[], uint8_t addr2[]);
|
||||
|
||||
// ---------------- Functions ----------------
|
||||
|
||||
void insert_client_to_array(client entry);
|
||||
|
||||
void kick_clients(uint8_t bssid[], uint32_t id);
|
||||
|
||||
void client_array_insert(client entry);
|
||||
|
||||
client client_array_delete(client entry);
|
||||
|
||||
void print_client_array();
|
||||
|
||||
void print_client_entry(client entry);
|
||||
|
||||
ap insert_to_ap_array(ap entry);
|
||||
|
||||
void print_ap_array();
|
||||
|
||||
ap ap_array_get_ap(uint8_t bssid_addr[]);
|
||||
|
||||
int build_hearing_map_sort_client(struct blob_buf *b);
|
||||
|
||||
int build_network_overview(struct blob_buf *b);
|
||||
|
||||
int probe_array_set_all_probe_count(uint8_t client_addr[], uint32_t probe_count);
|
||||
|
||||
int ap_get_collision_count(int col_domain);
|
||||
|
||||
/* Utils */
|
||||
|
||||
// ---------------- Defines -------------------
|
||||
#define SORT_NUM 5
|
||||
|
||||
// ---------------- Global variables ----------------
|
||||
char *sort_string;
|
||||
|
||||
// ---------------- Functions -------------------
|
||||
int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[], int automatic_kick);
|
||||
|
||||
|
||||
#endif
|
||||
68
src/include/dawn_iwinfo.h
Normal file
68
src/include/dawn_iwinfo.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#ifndef DAWN_RSSI_H
|
||||
#define DAWN_RSSI_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* Get RSSI using the mac adress of the client.
|
||||
* Function uses libiwinfo and searches through all interfaces that are existing.
|
||||
* @param client_addr - mac adress of the client
|
||||
* @return The RSSI of the client if successful. INT_MIN if client was not found.
|
||||
*/
|
||||
int get_rssi_iwinfo(__uint8_t *client_addr);
|
||||
|
||||
/**
|
||||
* Get expected throughut using the mac adress of the client.
|
||||
* Function uses libiwinfo and searches through all interfaces that are existing.
|
||||
* @param client_addr - mac adress of the client
|
||||
* @return
|
||||
* + The expected throughput of the client if successful.
|
||||
* + INT_MIN if client was not found.
|
||||
* + 0 if the client is not supporting this feature.
|
||||
*/
|
||||
int get_expected_throughput_iwinfo(uint8_t *client_addr);
|
||||
|
||||
/**
|
||||
* Get rx and tx bandwidth using the mac of the client.
|
||||
* Function uses libiwinfo and searches through all interfaces that are existing.
|
||||
* @param client_addr - mac adress of the client
|
||||
* @param rx_rate - float pointer for returning the rx rate
|
||||
* @param tx_rate - float pointer for returning the tx rate
|
||||
* @return 0 if successful 1 otherwise.
|
||||
*/
|
||||
int get_bandwidth_iwinfo(__uint8_t *client_addr, float *rx_rate, float *tx_rate);
|
||||
|
||||
/**
|
||||
* Function checks if two bssid adresses have the same essid.
|
||||
* Function uses libiwinfo and searches through all interfaces that are existing.
|
||||
* @param bssid_addr
|
||||
* @param bssid_addr_to_compares
|
||||
* @return 1 if the bssid adresses have the same essid.
|
||||
*/
|
||||
int compare_essid_iwinfo(__uint8_t *bssid_addr, __uint8_t *bssid_addr_to_compare);
|
||||
|
||||
/**
|
||||
* Function returns the expected throughput using the interface and the client address.
|
||||
* @param ifname
|
||||
* @param client_addr
|
||||
* @return
|
||||
* + The expected throughput of the client if successful.
|
||||
* + INT_MIN if client was not found.
|
||||
* + 0 if the client is not supporting this feature.
|
||||
*/
|
||||
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_channel_utilization(const char *ifname, uint64_t *last_channel_time, uint64_t *last_channel_time_busy);
|
||||
|
||||
int support_ht(const char *ifname);
|
||||
|
||||
int support_vht(const char *ifname);
|
||||
|
||||
#endif //DAWN_RSSI_H
|
||||
50
src/include/dawn_uci.h
Normal file
50
src/include/dawn_uci.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#ifndef DAWN_UCI_H
|
||||
#define DAWN_UCI_H
|
||||
|
||||
/**
|
||||
* Init uci. Call this function before using the other functions!
|
||||
* @return if call was successful.
|
||||
*/
|
||||
int uci_init();
|
||||
|
||||
/**
|
||||
* Clear uci. Call this function after using uci!
|
||||
* @return if call was successful.
|
||||
*/
|
||||
int uci_clear();
|
||||
|
||||
/**
|
||||
* Function that returns the metric for the load balancing sheme using uci.
|
||||
* @return the load balancing metric.
|
||||
*/
|
||||
struct probe_metric_s uci_get_dawn_metric();
|
||||
|
||||
/**
|
||||
* Function that returns a struct with all the time config values.
|
||||
* @return the time config values.
|
||||
*/
|
||||
struct time_config_s uci_get_time_config();
|
||||
|
||||
/**
|
||||
* Function that returns all the network informations.
|
||||
* @return the network config values.
|
||||
*/
|
||||
struct network_config_s uci_get_dawn_network();
|
||||
|
||||
/**
|
||||
* Function that returns the hostapd directory reading from the config file.
|
||||
* @return the hostapd directory.
|
||||
*/
|
||||
const char *uci_get_dawn_hostapd_dir();
|
||||
|
||||
/**
|
||||
* Function that returns the sort order.
|
||||
* @return the sort order.
|
||||
*/
|
||||
const char *uci_get_dawn_sort_order();
|
||||
|
||||
int uci_set_network(char* uci_cmd);
|
||||
|
||||
int uci_reset();
|
||||
|
||||
#endif //DAWN_UCI_H_H
|
||||
20
src/include/ieee80211_utils.h
Normal file
20
src/include/ieee80211_utils.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef DAWN_IEEE80211_UTILS_H
|
||||
#define DAWN_IEEE80211_UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Calculate bitrate using the supported rates values.
|
||||
* @param supp_rate_val
|
||||
* @return the bitrate.
|
||||
*/
|
||||
double iee80211_calculate_bitrate(uint8_t supp_rate_val);
|
||||
|
||||
/**
|
||||
* Calculate expected throughput in Mbit/sec.
|
||||
* @param exp_thr
|
||||
* @return
|
||||
*/
|
||||
double iee80211_calculate_expected_throughput_mbit(int exp_thr);
|
||||
|
||||
#endif //DAWN_IEEE80211_UTILS_H
|
||||
21
src/include/multicastsocket.h
Normal file
21
src/include/multicastsocket.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef __DAWN_MULTICASTSTSOCKET_H
|
||||
#define __DAWN_MULTICASTSSOCKET_H
|
||||
|
||||
/**
|
||||
* Setup a multicast socket.
|
||||
* Setup permissions. Join the multicast group, etc. ...
|
||||
* @param _multicast_ip - multicast ip to use.
|
||||
* @param _multicast_port - multicast port to use.
|
||||
* @param addr
|
||||
* @return the multicast socket.
|
||||
*/
|
||||
int setup_multicast_socket(const char *_multicast_ip, unsigned short _multicast_port, struct sockaddr_in *addr);
|
||||
|
||||
/**
|
||||
* Removes the multicast socket.
|
||||
* @param socket
|
||||
* @return
|
||||
*/
|
||||
int remove_multicast_socket(int socket);
|
||||
|
||||
#endif
|
||||
39
src/include/networksocket.h
Normal file
39
src/include/networksocket.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef __DAWN_NETWORKSOCKET_H
|
||||
#define __DAWN_NETWORKSOCKET_H
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
pthread_mutex_t send_mutex;
|
||||
|
||||
/**
|
||||
* Init a socket using the runopts.
|
||||
* @param _ip - ip to use.
|
||||
* @param _port - port to use.
|
||||
* @param _multicast_socket - if socket should be multicast or broadcast.
|
||||
* @return the socket.
|
||||
*/
|
||||
int init_socket_runopts(const char *_ip, int _port, int _multicast_socket);
|
||||
|
||||
/**
|
||||
* Send message via network.
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
int send_string(char *msg);
|
||||
|
||||
/**
|
||||
* Send encrypted message via network.
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
int send_string_enc(char *msg);
|
||||
|
||||
/**
|
||||
* Close socket.
|
||||
*/
|
||||
void close_socket();
|
||||
|
||||
// save connections
|
||||
// struct sockaddr_in addr[100];
|
||||
|
||||
#endif
|
||||
46
src/include/tcpsocket.h
Normal file
46
src/include/tcpsocket.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef DAWN_TCPSOCKET_H
|
||||
#define DAWN_TCPSOCKET_H
|
||||
|
||||
#include <libubox/ustream.h>
|
||||
#include <netinet/in.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define ARRAY_NETWORK_LEN 50
|
||||
|
||||
struct network_con_s {
|
||||
struct list_head list;
|
||||
|
||||
struct uloop_fd fd;
|
||||
struct ustream_fd stream;
|
||||
struct sockaddr_in sock_addr;
|
||||
int connected;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add tcp connection.
|
||||
* @param ipv4
|
||||
* @param port
|
||||
* @return
|
||||
*/
|
||||
int add_tcp_conncection(char *ipv4, int port);
|
||||
|
||||
/**
|
||||
* Opens a tcp server and adds it to the uloop.
|
||||
* @param port
|
||||
* @return
|
||||
*/
|
||||
int run_server(int port);
|
||||
|
||||
/**
|
||||
* Send message via tcp to all other hosts.
|
||||
* @param msg
|
||||
*/
|
||||
void send_tcp(char *msg);
|
||||
|
||||
/**
|
||||
* Debug message.
|
||||
*/
|
||||
void print_tcp_array();
|
||||
|
||||
|
||||
#endif //DAWN_TCPSOCKET_H
|
||||
165
src/include/ubus.h
Normal file
165
src/include/ubus.h
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
#ifndef __DAWN_UBUS_H
|
||||
#define __DAWN_UBUS_H
|
||||
|
||||
#include <libubox/blobmsg_json.h>
|
||||
#include <libubox/uloop.h>
|
||||
|
||||
#include "datastorage.h"
|
||||
|
||||
// 802.11 Status codes
|
||||
#define WLAN_STATUS_SUCCESS 0
|
||||
#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
|
||||
#define WLAN_STATUS_DENIED_NOT_HT_SUPPORT 27
|
||||
#define WLAN_STATUS_DENIED_NOT_VHT_SUPPORT 104
|
||||
|
||||
// Disassociation Reason
|
||||
#define UNSPECIFIED_REASON 0
|
||||
#define NO_MORE_STAS 5
|
||||
|
||||
const char *hostapd_dir_glob;
|
||||
|
||||
/**
|
||||
* Init ubus.
|
||||
* Setup tcp socket.
|
||||
* Start ubus timer.
|
||||
* @param ubus_socket
|
||||
* @param hostapd_dir
|
||||
* @return
|
||||
*/
|
||||
int dawn_init_ubus(const char *ubus_socket, const char *hostapd_dir);
|
||||
|
||||
/**
|
||||
* Start the umdns timer for updating the zeroconfiguration properties.
|
||||
*/
|
||||
void start_umdns_update();
|
||||
|
||||
/**
|
||||
* Call umdns update to update the TCP connections.
|
||||
* @return
|
||||
*/
|
||||
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
|
||||
* @param auth_req
|
||||
* @return
|
||||
*/
|
||||
int parse_to_auth_req(struct blob_attr *msg, auth_entry *auth_req);
|
||||
|
||||
/**
|
||||
* Parse to association request.
|
||||
* @param msg
|
||||
* @param assoc_req
|
||||
* @return
|
||||
*/
|
||||
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 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);
|
||||
|
||||
/**
|
||||
* Kick client from all hostapd interfaces.
|
||||
* @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_all_interfaces(const uint8_t *client_addr, uint32_t reason, uint8_t deauth, uint32_t ban_time);
|
||||
|
||||
/**
|
||||
* Send probe message via the network.
|
||||
* @param probe_entry
|
||||
* @return
|
||||
*/
|
||||
int ubus_send_probe_via_network(struct probe_entry_s probe_entry);
|
||||
|
||||
/**
|
||||
* Update the hostapd sockets.
|
||||
* @param t
|
||||
*/
|
||||
void update_hostapd_sockets(struct uloop_timeout *t);
|
||||
|
||||
/**
|
||||
* Set client timer for updating the clients.
|
||||
* @param time
|
||||
*/
|
||||
void add_client_update_timer(time_t time);
|
||||
|
||||
/**
|
||||
* Handle network messages.
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
int handle_network_msg(char *msg);
|
||||
|
||||
/**
|
||||
* Send message via network.
|
||||
* @param msg
|
||||
* @param method
|
||||
* @return
|
||||
*/
|
||||
int send_blob_attr_via_network(struct blob_attr *msg, char *method);
|
||||
|
||||
/**
|
||||
* Add mac to a list that contains addresses of clients that can not be controlled.
|
||||
* @param buf
|
||||
* @param name
|
||||
* @param addr
|
||||
*/
|
||||
void blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const uint8_t *addr);
|
||||
|
||||
/**
|
||||
* 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[]);
|
||||
|
||||
/**
|
||||
* Send control message to all hosts to add the mac to a don't control list.
|
||||
* @param client_addr
|
||||
* @return
|
||||
*/
|
||||
int send_add_mac(uint8_t *client_addr);
|
||||
|
||||
int uci_send_via_network();
|
||||
|
||||
#endif
|
||||
50
src/include/utils.h
Normal file
50
src/include/utils.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#ifndef __DAWN_UTILS_H
|
||||
#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"
|
||||
|
||||
/**
|
||||
* 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[]);
|
||||
|
||||
/**
|
||||
* Check if a string is greater than another one.
|
||||
* @param str
|
||||
* @param str_2
|
||||
* @return
|
||||
*/
|
||||
int string_is_greater(uint8_t *str, uint8_t *str_2);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue