mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Format code
This commit is contained in:
parent
88ca87c654
commit
7ba1f28f6b
9 changed files with 77 additions and 73 deletions
|
|
@ -9,10 +9,8 @@
|
|||
gcry_error_t gcry_error_handle;
|
||||
gcry_cipher_hd_t gcry_cipher_hd;
|
||||
|
||||
void gcrypt_init()
|
||||
{
|
||||
if (!gcry_check_version (GCRYPT_VERSION))
|
||||
{
|
||||
void gcrypt_init() {
|
||||
if (!gcry_check_version(GCRYPT_VERSION)) {
|
||||
fprintf(stderr, "gcrypt: library version mismatch");
|
||||
}
|
||||
gcry_error_t err = 0;
|
||||
|
|
@ -26,8 +24,7 @@ void gcrypt_init()
|
|||
}
|
||||
}
|
||||
|
||||
void gcrypt_set_key_and_iv(char *key, char *iv)
|
||||
{
|
||||
void gcrypt_set_key_and_iv(char *key, char *iv) {
|
||||
size_t keylen = gcry_cipher_get_algo_keylen(GCRY_CIPHER);
|
||||
size_t blklen = gcry_cipher_get_algo_blklen(GCRY_CIPHER);
|
||||
|
||||
|
|
@ -36,8 +33,7 @@ void gcrypt_set_key_and_iv(char *key, char *iv)
|
|||
GCRY_CIPHER, // int
|
||||
GCRY_C_MODE, // int
|
||||
0);
|
||||
if (gcry_error_handle)
|
||||
{
|
||||
if (gcry_error_handle) {
|
||||
fprintf(stderr, "gcry_cipher_open failed: %s/%s\n",
|
||||
gcry_strsource(gcry_error_handle),
|
||||
gcry_strerror(gcry_error_handle));
|
||||
|
|
@ -45,8 +41,7 @@ void gcrypt_set_key_and_iv(char *key, char *iv)
|
|||
}
|
||||
|
||||
gcry_error_handle = gcry_cipher_setkey(gcry_cipher_hd, key, keylen);
|
||||
if (gcry_error_handle)
|
||||
{
|
||||
if (gcry_error_handle) {
|
||||
fprintf(stderr, "gcry_cipher_setkey failed: %s/%s\n",
|
||||
gcry_strsource(gcry_error_handle),
|
||||
gcry_strerror(gcry_error_handle));
|
||||
|
|
@ -54,8 +49,7 @@ void gcrypt_set_key_and_iv(char *key, char *iv)
|
|||
}
|
||||
|
||||
gcry_error_handle = gcry_cipher_setiv(gcry_cipher_hd, iv, blklen);
|
||||
if (gcry_error_handle)
|
||||
{
|
||||
if (gcry_error_handle) {
|
||||
fprintf(stderr, "gcry_cipher_setiv failed: %s/%s\n",
|
||||
gcry_strsource(gcry_error_handle),
|
||||
gcry_strerror(gcry_error_handle));
|
||||
|
|
@ -64,8 +58,7 @@ void gcrypt_set_key_and_iv(char *key, char *iv)
|
|||
}
|
||||
|
||||
// free out buffer after using!
|
||||
char* gcrypt_encrypt_msg(char* msg, size_t msg_length)
|
||||
{
|
||||
char *gcrypt_encrypt_msg(char *msg, size_t msg_length) {
|
||||
if (0U != (msg_length & 0xfU))
|
||||
msg_length += 0x10U - (msg_length & 0xfU);
|
||||
|
||||
|
|
@ -77,8 +70,7 @@ char* gcrypt_encrypt_msg(char* msg, size_t msg_length)
|
|||
msg_length, // size_t
|
||||
msg, // const void *
|
||||
msg_length); // size_t
|
||||
if (gcry_error_handle)
|
||||
{
|
||||
if (gcry_error_handle) {
|
||||
printf("gcry_cipher_encrypt failed: %s/%s\n",
|
||||
gcry_strsource(gcry_error_handle),
|
||||
gcry_strerror(gcry_error_handle));
|
||||
|
|
@ -88,8 +80,7 @@ char* gcrypt_encrypt_msg(char* msg, size_t msg_length)
|
|||
}
|
||||
|
||||
// free out buffer after using!
|
||||
char* gcrypt_decrypt_msg(char* msg, size_t msg_length)
|
||||
{
|
||||
char *gcrypt_decrypt_msg(char *msg, size_t msg_length) {
|
||||
if (0U != (msg_length & 0xfU))
|
||||
msg_length += 0x10U - (msg_length & 0xfU);
|
||||
|
||||
|
|
@ -100,8 +91,7 @@ char* gcrypt_decrypt_msg(char* msg, size_t msg_length)
|
|||
msg_length, // size_t
|
||||
msg, // const void *
|
||||
msg_length); // size_t
|
||||
if (gcry_error_handle)
|
||||
{
|
||||
if (gcry_error_handle) {
|
||||
printf("gcry_cipher_encrypt failed: %s/%s\n",
|
||||
gcry_strsource(gcry_error_handle),
|
||||
gcry_strerror(gcry_error_handle));
|
||||
|
|
|
|||
|
|
@ -4,7 +4,11 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
void gcrypt_init();
|
||||
|
||||
void gcrypt_set_key_and_iv(char *key, char *iv);
|
||||
|
||||
char *gcrypt_encrypt_msg(char *msg, size_t msg_length);
|
||||
|
||||
char *gcrypt_decrypt_msg(char *msg, size_t msg_length);
|
||||
|
||||
#endif //DAWN_CRYPTO_H
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
struct probe_metric_s dawn_metric;
|
||||
|
||||
struct probe_metric_s
|
||||
{
|
||||
struct probe_metric_s {
|
||||
int ht_support;
|
||||
int vht_support;
|
||||
int n_ht_support;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,11 @@
|
|||
pthread_mutex_t send_mutex;
|
||||
|
||||
int init_socket_runopts(char *_ip, char *_port, int broadcast_socket);
|
||||
|
||||
int send_string(char *msg);
|
||||
|
||||
int send_string_enc(char *msg);
|
||||
|
||||
void close_socket();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,11 +7,17 @@
|
|||
#define MIN_PROBE_REQ 5 // TODO: Parse from config file...
|
||||
|
||||
int dawn_init_ubus(const char *ubus_socket, char *hostapd_dir);
|
||||
|
||||
int parse_to_probe_req(struct blob_attr *msg, probe_entry *prob_req);
|
||||
|
||||
int parse_to_clients(struct blob_attr *msg, int do_kick, uint32_t id);
|
||||
|
||||
void del_client_interface(uint32_t id, const uint8_t *client_addr, uint32_t reason, uint8_t deauth, uint32_t ban_time);
|
||||
|
||||
void del_client_all_interfaces(const uint8_t *client_addr, uint32_t reason, uint8_t deauth, uint32_t ban_time);
|
||||
|
||||
void *update_clients_thread(void *arg);
|
||||
|
||||
void *kick_clients_thread(void *arg);
|
||||
|
||||
char *hostapd_dir_glob;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ char recv_string[MAX_RECV_STRING + 1];
|
|||
int recv_string_len;
|
||||
|
||||
void *receive_msg(void *args);
|
||||
|
||||
void *receive_msg_enc(void *args);
|
||||
|
||||
int init_socket_runopts(char *_ip, char *_port, int broadcast_socket) {
|
||||
|
|
@ -136,7 +137,7 @@ void *receive_msg_enc(void *args) {
|
|||
if (strlen(recv_string) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
recv_string[recv_string_len] = '\0';
|
||||
//recv_string[recv_string_len] = '\0';
|
||||
|
||||
char *dec = gcrypt_decrypt_msg(recv_string, recv_string_len);
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,8 @@ int kick_client(struct client_s client_entry) {
|
|||
break;
|
||||
}
|
||||
if (!mac_is_equal(client_entry.bssid_addr, probe_array[k].bssid_addr) &&
|
||||
own_score < eval_probe_metric(client_entry, probe_array[k])) // that's wrong! find client_entry OR write things in probe array struct!
|
||||
own_score < eval_probe_metric(client_entry,
|
||||
probe_array[k])) // that's wrong! find client_entry OR write things in probe array struct!
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue