diff --git a/src/ui/h_prop.c b/src/ui/h_prop.c index 5734b09..d704e7d 100644 --- a/src/ui/h_prop.c +++ b/src/ui/h_prop.c @@ -66,11 +66,39 @@ const char *build_wh_start_command(char *iface_src, char *iface_dest, char *ssid return cmd_start; } -const char *build_wh_mkconfig_command(char *iface_src, char *iface_dest, char *ssid, char *pass){ + +const char *build_wh_mkconfig_command(ConfigValues* cv){ const char* a=get_config_file(CONFIG_FILE_NAME); - snprintf(cmd_mkconfig, BUFSIZE, "%s %s %s %s %s %s %s", CREATE_AP, iface_src, iface_dest, ssid, pass,MKCONFIG,a); + char* new_str; + + snprintf(cmd_mkconfig, BUFSIZE, "%s %s %s %s %s %s %s", CREATE_AP, cv->iface_wifi, cv->iface_inet, cv->ssid, cv->pass,MKCONFIG,a); + + if(cv->freq!=NULL){ + strcat(cmd_mkconfig," --freq-band "); + strcat(cmd_mkconfig,cv->freq); + } + + if(cv->no_virt!=NULL && (strcmp(cv->no_virt,"1") == 0)) + strcat(cmd_mkconfig," --no-virt "); + + if(cv->use_psk!=NULL && (strcmp(cv->use_psk,"1") == 0)) + strcat(cmd_mkconfig," --psk "); + + if(cv->hidden!=NULL && (strcmp(cv->hidden,"1") == 0)) + strcat(cmd_mkconfig," --hidden "); + + if(cv->channel!=NULL && (strcmp(cv->channel,"default") != 0) && ((strcmp(cv->channel,"2.4") == 0)|| (strcmp(cv->channel,"5") == 0))){ + strcat(cmd_mkconfig," -c "); + strcat(cmd_mkconfig,cv->channel); + } + + if(cv->mac!=NULL) { + strcat(cmd_mkconfig, " --mac "); + strcat(cmd_mkconfig, cv->mac); + } + printf("%s \n",cmd_mkconfig); return cmd_mkconfig; diff --git a/src/ui/h_prop.h b/src/ui/h_prop.h index f02f66c..fafd181 100644 --- a/src/ui/h_prop.h +++ b/src/ui/h_prop.h @@ -6,10 +6,11 @@ #define WIHOTSPOT_H_PROP_H +#include "read_config.h" + static int parse_output(const char *); const char *build_wh_start_command(char *, char *, char *, char *); -const char *build_wh_mkconfig_command(char *, char *, char *, char *); const char *build_wh_from_config(void); int startShell(const char *); @@ -23,6 +24,8 @@ static int init_get_interface_list(); char** get_interface_list(int*); const char* build_kill_create_ap_command(char* pid); +const char *build_wh_mkconfig_command(ConfigValues* cv); + char** get_wifi_interface_list(int *length); #endif //WIHOTSPOT_H_PROP_H diff --git a/src/ui/read_config.cpp b/src/ui/read_config.cpp index 3feb146..2901e4f 100644 --- a/src/ui/read_config.cpp +++ b/src/ui/read_config.cpp @@ -71,6 +71,25 @@ static void setConfigValues(const char * key, char *value){ if( !strcmp ( INTERNET_IFACE, key )) configValues.iface_inet = value; + + if( !strcmp ( HIDDEN, key )) + configValues.hidden = value; + + if( !strcmp ( NO_VIRT, key )) + configValues.no_virt = value; + + if( !strcmp ( NEW_MACADDR, key )) + configValues.mac = value; + + if( !strcmp ( CHANNEL, key )) + configValues.channel = value; + + if( !strcmp ( FREQ_BAND, key )) + configValues.freq = value; + + if( !strcmp ( USE_PSK, key )) + configValues.use_psk = value; + } diff --git a/src/ui/read_config.h b/src/ui/read_config.h index c762e5b..809496d 100644 --- a/src/ui/read_config.h +++ b/src/ui/read_config.h @@ -5,7 +5,6 @@ #ifndef WIHOTSPOT_READ_CONFIG_H #define WIHOTSPOT_READ_CONFIG_H -#include "h_prop.h" #define READ_CONFIG_FILE_SUCCESS 0 #define READ_CONFIG_FILE_FAIL 1 @@ -54,8 +53,15 @@ typedef struct{ char *pass; char *iface_wifi; char *iface_inet; + char *no_virt; + char *use_psk; + char *channel; + char *freq; + char *hidden; + char *mac; } ConfigValues; + int read_config_file(); static void setConfigValues(const char * key, char *value); ConfigValues* getConfigValues(void);