mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Change folderstructure
This commit is contained in:
parent
f69b1841b3
commit
1cefa5b4b8
10 changed files with 787 additions and 1 deletions
12
src/include/broadcastsocket.h
Normal file
12
src/include/broadcastsocket.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef __DAWN_BROADCASTSOCKET_H
|
||||
#define __DAWN_BROADCASTSOCKET_H
|
||||
|
||||
#include "ubus.h"
|
||||
|
||||
int init_socket_runopts(char *broadcast_ip, char *broadcast_port);
|
||||
int init_socket_conffile();
|
||||
int init_socket(const char *_broadcastIP, unsigned short _broadcastPort);
|
||||
int send_string(char *msg);
|
||||
void close_socket();
|
||||
|
||||
#endif
|
||||
48
src/include/datastorage.h
Normal file
48
src/include/datastorage.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#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>
|
||||
|
||||
#ifndef ETH_ALEN
|
||||
#define ETH_ALEN 6
|
||||
#endif
|
||||
|
||||
#define SORT_NUM 5
|
||||
#define TIME_THRESHOLD 60 // every minute
|
||||
|
||||
// Probe entrys
|
||||
typedef struct {
|
||||
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;
|
||||
} probe_entry;
|
||||
|
||||
// List
|
||||
typedef struct node {
|
||||
probe_entry data;
|
||||
struct node *ptr;
|
||||
} node;
|
||||
|
||||
node *insert(node *head, probe_entry entry);
|
||||
void free_list(node *head);
|
||||
void print_list();
|
||||
void insert_to_list(probe_entry entry, int inc_counter);
|
||||
int mac_first_in_probe_list(uint8_t bssid_addr[], uint8_t client_addr[]);
|
||||
|
||||
void *remove_thread(void *arg);
|
||||
|
||||
pthread_mutex_t list_mutex;
|
||||
node *probe_list_head;
|
||||
char sort_string[SORT_NUM];
|
||||
|
||||
#endif
|
||||
4
src/include/runopts.h
Normal file
4
src/include/runopts.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef __DAWN_RUNOPTS_H_
|
||||
#define __DAWN_RUNOPTS_H_
|
||||
|
||||
#endif
|
||||
11
src/include/ubus.h
Normal file
11
src/include/ubus.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef __DAWN_UBUS_H
|
||||
#define __DAWN_UBUS_H
|
||||
|
||||
#include "datastorage.h"
|
||||
|
||||
#define MIN_PROBE_REQ 2 // 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);
|
||||
|
||||
#endif
|
||||
30
src/include/utils.h
Normal file
30
src/include/utils.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef __DAWN_UTILS_H
|
||||
#define __DAWN_UTILS_H
|
||||
|
||||
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||
|
||||
static int hex_to_bin(char ch) {
|
||||
if ((ch >= '0') && (ch <= '9')) return ch - '0';
|
||||
ch = tolower(ch);
|
||||
if ((ch >= 'a') && (ch <= 'f')) return ch - 'a' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int hwaddr_aton(const char *txt, uint8_t *addr) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ETH_ALEN; i++) {
|
||||
int a, b;
|
||||
|
||||
a = hex_to_bin(*txt++);
|
||||
if (a < 0) return -1;
|
||||
b = hex_to_bin(*txt++);
|
||||
if (b < 0) return -1;
|
||||
*addr++ = (a << 4) | b;
|
||||
if (i < 5 && *txt++ != ':') return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue