reformat code

This commit is contained in:
PolynomialDivision 2017-10-23 15:45:37 +02:00
parent a2b7faee97
commit 377d0815e9
13 changed files with 116 additions and 124 deletions

View file

@ -31,8 +31,11 @@ void build_decoding_table();
void base64_cleanup();
int Base64decode_len(const char *bufcoded);
int Base64encode_len(int len);
int Base64encode(char *encoded, const char *string, int len);
int Base64decode(char *bufplain, const char *bufcoded);

View file

@ -101,8 +101,11 @@ struct ap_s ap_array[ARRAY_AP_LEN];
pthread_mutex_t ap_array_mutex;
ap insert_to_ap_array(ap entry);
void print_ap_array();
void *remove_ap_array_thread(void *arg);
ap ap_array_get_ap(uint8_t bssid_addr[]);
// Array

View file

@ -8,7 +8,9 @@
#define STR2MAC(a) &(a)[0], &(a)[1], &(a)[2], &(a)[3], &(a)[4], &(a)[5]
int hex_to_bin(char ch);
int hwaddr_aton(const char *txt, uint8_t *addr);
int convert_mac(char *in, char *out);
#endif

View file

@ -22,6 +22,7 @@
#include "crypto.h"
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
@ -42,8 +43,7 @@ pthread_t tid_get_client;
pthread_t tid_kick_clients;
pthread_t tid_ap;
void daemon_shutdown()
{
void daemon_shutdown() {
// kill threads
printf("Cancelling Threads!\n");
pthread_cancel(tid_probe);
@ -62,11 +62,9 @@ void daemon_shutdown()
//printf("Free Counter: %d\n", free_counter);
}
void signal_handler(int sig)
{
void signal_handler(int sig) {
printf("SOME SIGNAL RECEIVED!\n");
switch(sig)
{
switch (sig) {
case SIGHUP:
//syslog(LOG_WARNING, "Received SIGHUP signal.");
break;
@ -82,6 +80,7 @@ void signal_handler(int sig)
break;
}
}
/*
static void mtrace_init(void)
{

View file

@ -67,8 +67,7 @@ int eval_probe_metric(struct probe_entry_s probe_entry) {
return score;
}
int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[])
{
int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[]) {
int own_score = -1;
// find first client entry in probe array
@ -95,8 +94,7 @@ int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[])
}
// no entry for own ap
if(own_score == -1)
{
if (own_score == -1) {
return -1;
}
@ -106,7 +104,8 @@ int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[])
break;
}
if (!mac_is_equal(bssid_addr, probe_array[k].bssid_addr) &&
own_score < eval_probe_metric(probe_array[k])) // that's wrong! find client_entry OR write things in probe array struct!
own_score <
eval_probe_metric(probe_array[k])) // that's wrong! find client_entry OR write things in probe array struct!
{
return 1;
}
@ -139,11 +138,9 @@ void kick_clients(uint8_t bssid[], uint32_t id) {
// update rssi
int rssi = get_rssi_from_iwinfo(client_array[j].client_addr);
if(rssi != INT_MIN)
{
if (rssi != INT_MIN) {
pthread_mutex_unlock(&probe_array_mutex);
if(!probe_array_update_rssi(client_array[j].bssid_addr, client_array[j].client_addr, rssi))
{
if (!probe_array_update_rssi(client_array[j].bssid_addr, client_array[j].client_addr, rssi)) {
printf("Failed to update RSSI!\n");
}
pthread_mutex_lock(&probe_array_mutex);
@ -173,8 +170,7 @@ void kick_clients(uint8_t bssid[], uint32_t id) {
pthread_mutex_unlock(&client_array_mutex);
}
int is_connected(uint8_t bssid_addr[], uint8_t client_addr[])
{
int is_connected(uint8_t bssid_addr[], uint8_t client_addr[]) {
int i;
int found_in_array = 0;
@ -185,8 +181,7 @@ int is_connected(uint8_t bssid_addr[], uint8_t client_addr[])
for (i = 0; i <= client_entry_last; i++) {
if (mac_is_equal(bssid_addr, client_array[i].bssid_addr) &&
mac_is_equal(client_addr, client_array[i].client_addr))
{
mac_is_equal(client_addr, client_array[i].client_addr)) {
found_in_array = 1;
break;
}
@ -450,7 +445,6 @@ ap ap_array_get_ap(uint8_t bssid_addr[]) {
}
pthread_mutex_lock(&ap_array_mutex);
int i;

View file

@ -20,8 +20,7 @@ dawn.metric.freq
option remove_probe '120'
*/
struct time_config_s uci_get_time_config()
{
struct time_config_s uci_get_time_config() {
struct time_config_s ret;
struct uci_context *c;
@ -63,8 +62,7 @@ struct time_config_s uci_get_time_config()
return ret;
}
struct probe_metric_s uci_get_dawn_metric()
{
struct probe_metric_s uci_get_dawn_metric() {
struct probe_metric_s ret;
struct uci_context *c;

View file

@ -7,10 +7,10 @@
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
int call_iwinfo(char *client_addr);
int parse_rssi(char *iwinfo_string);
int get_rssi_from_iwinfo(__uint8_t* client_addr)
{
int get_rssi_from_iwinfo(__uint8_t *client_addr) {
char mac_buf[20];
sprintf(mac_buf, "%x:%x:%x:%x:%x:%x", MAC2STR(client_addr));
char mac_buf_conv[20];
@ -20,8 +20,7 @@ int get_rssi_from_iwinfo(__uint8_t* client_addr)
return call_iwinfo(mac_buf_conv);
}
int call_iwinfo(char* client_addr)
{
int call_iwinfo(char *client_addr) {
// TODO: REFACTOR THIS! USE NET LINK... LOOK AT IWINFO
FILE *fp;
@ -54,15 +53,13 @@ int call_iwinfo(char* client_addr)
return rssi;
}
int parse_rssi(char* iwinfo_string)
{
int parse_rssi(char *iwinfo_string) {
char cut_1[] = " ";
char cut_2[] = "dBm";
char *p_1 = strstr(iwinfo_string, cut_1);
char *p_2 = strstr(iwinfo_string, cut_2);
int rssi = INT_MIN;
if(p_1 != NULL && p_2 != NULL)
{
if (p_1 != NULL && p_2 != NULL) {
int length = (int) (p_2 - p_1);
char dest[length + 1];
memcpy(dest, p_1, (int) (p_2 - p_1));

View file

@ -290,11 +290,9 @@ static int hostapd_notify(struct ubus_context *ctx, struct ubus_object *obj,
if (strncmp(method, "probe", 5) == 0) {
return handle_probe_req(msg);
}
else if (strncmp(method, "auth", 4) == 0) {
} else if (strncmp(method, "auth", 4) == 0) {
return handle_auth_req(msg);
}
else if (strncmp(method, "assoc", 5) == 0) {
} else if (strncmp(method, "assoc", 5) == 0) {
return handle_assoc_req(msg);
}
return 0;
@ -611,8 +609,7 @@ static void ubus_umdns_cb(struct ubus_request *req, int type, struct blob_attr *
printf("UMDNS:\n%s", str);
}
int ubus_call_umdns()
{
int ubus_call_umdns() {
u_int32_t id;
if (ubus_lookup_id(ctx, "umdns", &id)) {
fprintf(stderr, "Failed to look up test object for %s\n", "umdns");
@ -624,8 +621,7 @@ int ubus_call_umdns()
return 0;
}
int ubus_send_probe_via_network(struct probe_entry_s probe_entry)
{
int ubus_send_probe_via_network(struct probe_entry_s probe_entry) {
printf("Try to send new probe!!!\n");
static struct blob_buf b;