mirror of
https://github.com/lakinduakash/linux-wifi-hotspot.git
synced 2024-11-21 19:40:11 +00:00
Read new configs and bulid mkconfig command
This commit is contained in:
parent
d61e3e2de8
commit
ba555e6931
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user