Add mac filter command

Write mac addreses to file
This commit is contained in:
Lakindu Akash 2020-10-30 23:07:59 +05:30
parent f0be75cb54
commit 3b6668051d
No known key found for this signature in database
GPG Key ID: 87D9889F7A634A38
2 changed files with 20 additions and 1 deletions

View File

@ -37,7 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "read_config.h"
#define BUFSIZE 512
#define BUFSIZE 1024
#define SUDO "pkexec --user root"
@ -52,6 +52,7 @@ char cmd_start[BUFSIZE];
char cmd_mkconfig[BUFSIZE];
char cmd_config[BUFSIZE];
char cmd_kill[BUFSIZE];
char cmd_write_mac[BUFSIZE];
char h_running_info[BUFSIZE];
char interface_list[BUFSIZE];
@ -125,6 +126,12 @@ const char *build_wh_mkconfig_command(ConfigValues* cv){
strcat(cmd_mkconfig, cv->mac);
}
if(cv->mac_filter!=NULL && (strcmp(cv->mac_filter,"1") == 0)){
strcat(cmd_mkconfig, " --mac-filter ");
strcat(cmd_mkconfig, cv->mac_filter);
write_accepted_macs(cv->accepted_mac_file,cv->accepted_macs);
}
printf("%s \n",cmd_mkconfig);
return cmd_mkconfig;
@ -147,6 +154,16 @@ const char* build_kill_create_ap_command(char* pid){
return cmd_kill;
}
void write_accepted_macs(char* filename, char* accepted_macs){
printf("%s \n",filename);
printf("%s \n",accepted_macs);
snprintf(cmd_write_mac,BUFSIZE,"%s '%s' %s %s","echo", accepted_macs, "| sudo tee", filename);
int r=system(cmd_write_mac);
}
//int write_config(char* file){
//
// config_t cfg;

View File

@ -55,4 +55,6 @@ const char *build_wh_mkconfig_command(ConfigValues* cv);
char** get_wifi_interface_list(int *length);
void write_accepted_macs(char* filename, char* accepted_macs);
#endif //WIHOTSPOT_H_PROP_H