Hi folks im trying to patch this file, in openwrt it was a old dev who made the patch and now i have no clue what is even going on here trying to make this build but keeps saying failed i already tried manual patching too but still its not working originally it was supposed to be working in TP-link 3420 v5 and now im on ax23
cat 900-wt.beacon.c.patch
--- a/src/ap/beacon.c 2016-09-15 16:06:16.414572869 +0530
+++ b/src/ap/beacon.c 2016-09-15 16:03:47.903738024 +0530
@@ -538,8 +538,77 @@ static enum ssid_match_result ssid_match
return wildcard ? WILDCARD_SSID_MATCH : NO_SSID_MATCH;
}
+#define WT 1
+#ifdef WT
+//#define _GNU_SOURCE
+#include <search.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#define WT_MAX_MAC_COUNT 200
+#define WT_FILE "/tmp/wt_wifi_probe_macid_lists"
+#define WT_MAX_FILE_COUNT 2
+#define WT_TMP_STR_LEN 100
+#define WT_SAMPLE_LINE "cc:10:99:56:12:aa,-000,2017-01-01 01:01:01"
+#define UCI_GET_PROBE_FLAG_CMD "/sbin/uci get wt.@wt[0].disable_probe"
+#define WT_PROBE_RES_FILE "/tmp/wt_wifi_probe_macid_lists.csv"
+#define PROG_TO_SIGNAL "proximity_mac_upload.sh"
+static void *TREE = NULL;
+static int wt_global_SIGUSR1_flag = 0;
+static int wt_global_proble_disable_flag = 1;
+static int fd = -1 ;
+static char * mapInit = NULL;
+static char *tmpPtr= NULL;
+static int wt_probe_init_task = 0;
+static int wt_i = 0;
+static int wt_file_count = 1;
+unsigned int *currMac = 0;
+void *pRes = NULL;
+void *tmp = NULL;
+static int wt_one_time_flag = 0;
+static int page_size = 4096;
+static int wt_file_size = 4096*2;
+static int wt_probe_line_size = (int)sizeof(WT_SAMPLE_LINE);
+static char wt_pre_allocated_array[WT_MAX_MAC_COUNT][ETH_ALEN] = {0};
+static int wt_pre_allocated_array_index = 0;
+static char tmpFileName[WT_TMP_STR_LEN] = {0};
+static int wt_global_max_mac_flag = 0;
+
+
+int wt_mac_compare(const void *mac1, const void *mac2) {
+ int i = 0;
+ char *tmp1 = (char *)mac1;
+ char *tmp2 = (char *)mac2;
+ for( i = 0; i < 6; i++ ) {
+ if(tmp1[i] == tmp2[i]) continue;
+ else if (tmp1[i] < tmp2[i]) return -1;
+ else if (tmp1[i] > tmp2[i]) return 1;
+ }
+ return 0;
+}
+void wt_dummy_fn(void *dummy){
-
+}
+void wt_signal_handler(int sig){
+ switch(sig){
+ case SIGUSR1:
+ wt_global_SIGUSR1_flag = 1;
+ syslog(4, "wt_probe : got signal from proximity_mac_upload");
+ break;
+ case SIGBUS:
+ wt_global_proble_disable_flag = 1;
+ syslog(4, "wt_probe : got SIGBUS");
+ signal(sig, SIG_DFL);
+ break;
+ case SIGSEGV:
+ wt_global_proble_disable_flag = 1;
+ signal(sig, SIG_DFL);
+ syslog(4, "wt_probe : got SIGSEGV");
+ break;
+ default:
+ break;
+ }
+}
+#endif
void handle_probe_req(struct hostapd_data *hapd,
const struct ieee80211_mgmt *mgmt, size_t len,
struct hostapd_frame_info *fi)
@@ -585,6 +654,101 @@ void handle_probe_req(struct hostapd_dat
MAC2STR(mgmt->sa));
return;
}
+#ifdef WT
+
+ if(wt_one_time_flag == 0){
+ signal(SIGUSR1, wt_signal_handler);
+ signal(SIGBUS, wt_signal_handler);
+ signal(SIGSEGV, wt_signal_handler);
+ char inputString[WT_TMP_STR_LEN] = {0};
+ int tmpRes = 1;
+ page_size = (int)sysconf(_SC_PAGESIZE);
+ FILE *uci_fp = popen(UCI_GET_PROBE_FLAG_CMD, "r");
+ if (uci_fp != NULL) {
+ fread(inputString, WT_TMP_STR_LEN, 1, uci_fp);
+ sscanf(inputString, "%d\n", &tmpRes);
+ pclose(uci_fp);
+ if(tmpRes == 0) {
+ syslog(4, "wt_probe : enabling wt_probe");
+ wt_global_proble_disable_flag = 0;
+ }else
+ syslog(4, "wt_probe : disabling wt_probe");
+ }
+ wt_one_time_flag = 1;
+ }
+
+ if(wt_global_proble_disable_flag == 1){
+ goto wt_end;
+ }
+
+ if(wt_probe_init_task == 0){
+ sprintf(tmpFileName, WT_FILE".%d.csv", wt_file_count);
+ if ((fd = open(tmpFileName, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600)) < 0) goto wt_end;
+ if ((tmpPtr = (char *)mmap(0, wt_file_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED)
+ goto wt_end;
+ mapInit = tmpPtr;
+ wt_pre_allocated_array_index = 0; // Reset array to start from the beginnning
+ if( wt_pre_allocated_array_index >= WT_MAX_MAC_COUNT){
+ wt_global_max_mac_flag = 1;
+ wt_global_SIGUSR1_flag = 1;
+ goto wt_end;
+ }
+ memcpy(wt_pre_allocated_array[wt_pre_allocated_array_index], hapd->own_addr, ETH_ALEN);
+ if((pRes = tsearch(wt_pre_allocated_array[wt_pre_allocated_array_index], &TREE, wt_mac_compare)) == NULL){
+ goto wt_end;
+ }
+ wt_pre_allocated_array_index++;
+ wt_i = 0;
+ wt_probe_init_task = 1; // wt_probe_init_task = 1 when initialization is complete.
+ }
+ if ((pRes = tfind(mgmt->sa, &TREE, wt_mac_compare)) != NULL) goto wt_end;
+
+ if( (wt_global_SIGUSR1_flag == 0) && (wt_i < (wt_file_size- wt_probe_line_size*2))){
+ if( wt_pre_allocated_array_index >= WT_MAX_MAC_COUNT){
+ wt_global_SIGUSR1_flag = 1;
+ wt_global_max_mac_flag = 1;
+ goto wt_end;
+ }
+ memcpy(wt_pre_allocated_array[wt_pre_allocated_array_index], mgmt->sa, ETH_ALEN);
+ if((pRes = tsearch(wt_pre_allocated_array[wt_pre_allocated_array_index], &TREE, wt_mac_compare)) == NULL){
+ goto wt_end;
+ }
+ wt_pre_allocated_array_index++;
+ if (lseek(fd, wt_probe_line_size-1, SEEK_END) == -1) goto wt_end;
+ if (write(fd, "\0", 1) == -1) goto wt_end;
+ time_t now = time(NULL);
+ struct tm tm1 = {0};
+ if(localtime_r(&now, &tm1) == NULL) goto wt_end;
+ sprintf(tmpPtr, MACSTR",%04d,%04d-%02d-%02d %02d:%02d:%02d\n",
+ MAC2STR(mgmt->sa), fi->ssi_signal, tm1.tm_year + 1900, tm1.tm_mon + 1, tm1.tm_mday,
+ tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
+ tmpPtr += wt_probe_line_size;
+ wt_i += wt_probe_line_size;
+ }else{
+ msync(mapInit, wt_file_size, MS_SYNC);
+ munmap(mapInit, wt_file_size);
+ mapInit = NULL;
+ close(fd);
+ fd = -1;
+ wt_probe_init_task = 0;
+ wt_file_count++;
+ if(wt_file_count > WT_MAX_FILE_COUNT) wt_file_count = 1;
+ tdestroy(TREE, wt_dummy_fn);
+ TREE = NULL;
+ unlink(WT_PROBE_RES_FILE);
+ symlink(tmpFileName, WT_PROBE_RES_FILE);
+ if(wt_global_max_mac_flag == 1){
+ wt_global_max_mac_flag = 0;
+ syslog(4, "wt_probe : sending sig2 to proximity_mac_upload");
+ system("killall -SIGUSR2 " PROG_TO_SIGNAL);
+ }else{
+ syslog(4, "wt_probe : sending sig1 to proximity_mac_upload");
+ system("killall -SIGUSR1 " PROG_TO_SIGNAL);
+ }
+ wt_global_SIGUSR1_flag = 0;
+ }
+ wt_end:
+#endif
/*
* No need to reply if the Probe Request frame was sent on an adjacent