Merge pull request #6 from berlin-open-wireless-lab/feature/format_mac

Feature/format mac
This commit is contained in:
Polynomdivision 2017-10-26 19:01:15 +02:00 committed by GitHub
commit bd1dbf39d6
4 changed files with 17 additions and 16 deletions

View file

@ -7,6 +7,8 @@
#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"
int hex_to_bin(char ch);
int hwaddr_aton(const char *txt, uint8_t *addr);

View file

@ -4,6 +4,7 @@
#include "ubus.h"
#include "rssi.h"
#include "utils.h"
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
@ -435,7 +436,7 @@ ap ap_array_get_ap(uint8_t bssid_addr[]) {
ap ret;
char bssid_mac_string[20];
sprintf(bssid_mac_string, "%x:%x:%x:%x:%x:%x", MAC2STR(bssid_addr));
sprintf(bssid_mac_string, MACSTR, MAC2STR(bssid_addr));
printf("Try to find: %s\n", bssid_mac_string);
printf("in\n");
print_ap_array();
@ -898,9 +899,9 @@ void print_probe_entry(probe_entry entry) {
char mac_buf_client[20];
char mac_buf_target[20];
sprintf(mac_buf_ap, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.bssid_addr));
sprintf(mac_buf_client, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.client_addr));
sprintf(mac_buf_target, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.target_addr));
sprintf(mac_buf_ap, MACSTR, MAC2STR(entry.bssid_addr));
sprintf(mac_buf_client, MACSTR, MAC2STR(entry.client_addr));
sprintf(mac_buf_target, MACSTR, MAC2STR(entry.target_addr));
printf(
"bssid_addr: %s, client_addr: %s, signal: %d, freq: "
@ -913,9 +914,9 @@ void print_auth_entry(auth_entry entry) {
char mac_buf_client[20];
char mac_buf_target[20];
sprintf(mac_buf_ap, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.bssid_addr));
sprintf(mac_buf_client, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.client_addr));
sprintf(mac_buf_target, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.target_addr));
sprintf(mac_buf_ap, MACSTR, MAC2STR(entry.bssid_addr));
sprintf(mac_buf_client, MACSTR, MAC2STR(entry.client_addr));
sprintf(mac_buf_target, MACSTR, MAC2STR(entry.target_addr));
printf(
"bssid_addr: %s, client_addr: %s, signal: %d, freq: "
@ -927,8 +928,8 @@ void print_client_entry(client entry) {
char mac_buf_ap[20];
char mac_buf_client[20];
sprintf(mac_buf_ap, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.bssid_addr));
sprintf(mac_buf_client, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.client_addr));
sprintf(mac_buf_ap, MACSTR, MAC2STR(entry.bssid_addr));
sprintf(mac_buf_client, MACSTR, MAC2STR(entry.client_addr));
printf("bssid_addr: %s, client_addr: %s, freq: %d, ht_supported: %d, vht_supported: %d, ht: %d, vht: %d\n",
mac_buf_ap, mac_buf_client, entry.freq, entry.ht_supported, entry.vht_supported, entry.ht, entry.vht);
@ -946,7 +947,7 @@ void print_client_array() {
void print_ap_entry(ap entry) {
char mac_buf_ap[20];
sprintf(mac_buf_ap, "%x:%x:%x:%x:%x:%x", MAC2STR(entry.bssid_addr));
sprintf(mac_buf_ap, MACSTR, MAC2STR(entry.bssid_addr));
printf("bssid_addr: %s, freq: %d, ht: %d, vht: %d, chan_utilz: %d\n",
mac_buf_ap, entry.freq, entry.ht, entry.vht, entry.channel_utilization);
}

View file

@ -12,7 +12,7 @@ int parse_rssi(char *iwinfo_string);
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));
sprintf(mac_buf, MACSTR, MAC2STR(client_addr));
char mac_buf_conv[20];
convert_mac(mac_buf, mac_buf_conv);

View file

@ -119,8 +119,6 @@ static int subscribe_to_hostapd_interfaces(char *hostapd_dir);
static int ubus_get_clients();
/* hostapd function */
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
static void
blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const uint8_t *addr) {
@ -438,7 +436,7 @@ dump_client_table(struct blob_attr *head, int len, const char *bssid_addr, uint3
int tmp_int_mac[ETH_ALEN];
uint8_t tmp_mac[ETH_ALEN];
sscanf((char *) hdr->name, "%x:%x:%x:%x:%x:%x", STR2MAC(tmp_int_mac));
sscanf((char *) hdr->name, MACSTR, STR2MAC(tmp_int_mac));
for (int i = 0; i < ETH_ALEN; ++i)
tmp_mac[i] = (uint8_t) tmp_int_mac[i];
@ -535,12 +533,12 @@ void *kick_clients_thread(void *arg) {
/*
int tmp_int_mac[ETH_ALEN];
uint8_t tmp_mac[ETH_ALEN];
sscanf("a4:2b:b0:de:f1:fd", "%x:%x:%x:%x:%x:%x", STR2MAC(tmp_int_mac));
sscanf("a4:2b:b0:de:f1:fd", MACSTR, STR2MAC(tmp_int_mac));
for(int i = 0; i < ETH_ALEN; ++i )
tmp_mac[i] = (uint8_t) tmp_int_mac[i];
//kick_clients(tmp_mac);
sscanf("a4:2b:b0:de:f1:fe", "%x:%x:%x:%x:%x:%x", STR2MAC(tmp_int_mac));
sscanf("a4:2b:b0:de:f1:fe", MACSTR, STR2MAC(tmp_int_mac));
for(int i = 0; i < ETH_ALEN; ++i )
tmp_mac[i] = (uint8_t) tmp_int_mac[i];*/
//kick_clients(tmp_mac);