developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <ctype.h> |
| 5 | #include <uci.h> |
| 6 | #include "wifi-test-tool.h" |
| 7 | |
| 8 | void set_channel(wifi_radio_param *radio_param, char *channel) |
| 9 | { |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 10 | if (strcmp(channel, "auto") == 0) { |
| 11 | radio_param->auto_channel = TRUE; |
| 12 | radio_param->channel = 0; |
| 13 | } else { |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 14 | radio_param->auto_channel = FALSE; |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 15 | radio_param->channel = strtol(channel, NULL, 10); |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 16 | } |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 17 | return; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 18 | } |
| 19 | |
developer | 52c6ca2 | 2022-10-06 17:16:43 +0800 | [diff] [blame] | 20 | void set_country(wifi_radio_param *radio_param, char *country) |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 21 | { |
| 22 | strcpy(radio_param->country, country); |
| 23 | } |
| 24 | |
developer | 52c6ca2 | 2022-10-06 17:16:43 +0800 | [diff] [blame] | 25 | void set_band(wifi_radio_param *radio_param, char *band) |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 26 | { |
| 27 | strcpy(radio_param->band, band); |
| 28 | } |
| 29 | |
| 30 | void set_hwmode(wifi_radio_param *radio_param, char *hwmode) |
| 31 | { |
| 32 | if (strncmp(hwmode, "11a", 3) == 0) |
| 33 | strcpy(radio_param->hwmode, "a"); |
| 34 | if (strncmp(hwmode, "11b", 3) == 0) |
| 35 | strcpy(radio_param->hwmode, "b"); |
| 36 | if (strncmp(hwmode, "11g", 3) == 0) |
| 37 | strcpy(radio_param->hwmode, "g"); |
| 38 | } |
| 39 | |
| 40 | void set_htmode(wifi_radio_param *radio_param, char *htmode) |
| 41 | { |
| 42 | char tmp[16] = {0}; |
| 43 | char *ptr = htmode; |
| 44 | ULONG bandwidth = 0; |
| 45 | radio_param->bandwidth = 20; |
| 46 | while (*ptr) { |
| 47 | if (isdigit(*ptr)) { |
| 48 | bandwidth = strtoul(ptr, NULL, 10); |
| 49 | radio_param->bandwidth = bandwidth; |
| 50 | break; |
| 51 | } |
| 52 | ptr++; |
| 53 | } |
| 54 | |
| 55 | // HT40 -> 11NGHT40PLUS |
| 56 | // VHT40+ -> 11ACVHT40PLUS |
| 57 | // HE80 -> 11AXHE80 |
| 58 | if (strstr(htmode, "+") != NULL) { |
| 59 | strncpy(tmp, htmode, strlen(htmode) - 1); |
| 60 | strcat(tmp, "PLUS"); |
| 61 | } else if (strstr(htmode, "-") != NULL) { |
| 62 | strncpy(tmp, htmode, strlen(htmode) - 1); |
| 63 | strcat(tmp, "MINUS"); |
| 64 | } else |
| 65 | strcpy(tmp, htmode); |
| 66 | |
| 67 | |
| 68 | if (strstr(htmode, "VHT") != NULL) { |
| 69 | snprintf(radio_param->htmode, sizeof(radio_param->htmode), "11AC%s", tmp); |
| 70 | } else if (strstr(htmode, "HT") != NULL && strstr(htmode, "NO") == NULL) { |
| 71 | snprintf(radio_param->htmode, sizeof(radio_param->htmode), "11NG%s", tmp); |
| 72 | } else if (strstr(htmode, "HE") != NULL) { |
| 73 | snprintf(radio_param->htmode, sizeof(radio_param->htmode), "11AX%s", tmp); |
| 74 | } else { // NOHT or NONE should be parsed with the band, so just fill the original string. |
| 75 | strcpy(radio_param->htmode, tmp); |
| 76 | } |
| 77 | |
| 78 | } |
| 79 | |
| 80 | void set_disable(wifi_radio_param *radio_param, char *disable) |
| 81 | { |
| 82 | if (strcmp(disable, "1") == 0) |
| 83 | radio_param->disabled = TRUE; |
| 84 | else |
| 85 | radio_param->disabled = FALSE; |
| 86 | } |
| 87 | |
| 88 | void set_radionum(wifi_ap_param *ap_param, char *radio_name) |
| 89 | { |
| 90 | int radio_num; |
| 91 | char *ptr = radio_name; |
| 92 | |
| 93 | while (*ptr) { |
| 94 | if (isdigit(*ptr)) { |
| 95 | radio_num = strtoul(ptr, NULL, 10); |
| 96 | ap_param->radio_index = radio_num; |
| 97 | break; |
| 98 | } |
| 99 | ptr++; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | void set_ssid(wifi_ap_param *ap_param, char *ssid) |
| 104 | { |
| 105 | strncpy(ap_param->ssid, ssid, 32); |
| 106 | } |
| 107 | |
| 108 | void set_encryption(wifi_ap_param *ap_param, char *encryption_mode) |
| 109 | { |
developer | ff378f2 | 2022-10-13 13:33:57 +0800 | [diff] [blame] | 110 | if (strcmp(encryption_mode, "none") == 0) { |
| 111 | ap_param->security.mode = wifi_security_mode_none; |
| 112 | ap_param->security.encr = wifi_encryption_none; |
| 113 | }else if(strncmp(encryption_mode, "psk2", 4) == 0){ |
| 114 | ap_param->security.mode = wifi_security_mode_wpa2_personal; |
| 115 | }else if(strncmp(encryption_mode, "psk-",4) == 0){ |
| 116 | ap_param->security.mode = wifi_security_mode_wpa_wpa2_personal; |
| 117 | }else if(strncmp(encryption_mode, "psk",3) == 0){ |
| 118 | ap_param->security.mode = wifi_security_mode_wpa_personal; |
| 119 | }else if(strncmp(encryption_mode, "wpa2",4) == 0){ |
| 120 | ap_param->security.mode = wifi_security_mode_wpa2_enterprise; |
| 121 | }else if(strncmp(encryption_mode, "wpa-",4) == 0){ |
| 122 | ap_param->security.mode = wifi_security_mode_wpa_wpa2_enterprise; |
| 123 | }else if(strcmp(encryption_mode, "sae") == 0){ |
| 124 | ap_param->security.mode = wifi_security_mode_wpa3_personal; |
| 125 | }else if(strcmp(encryption_mode, "wpa3") == 0){ |
| 126 | ap_param->security.mode = wifi_security_mode_wpa3_enterprise; |
| 127 | }else if(strcmp(encryption_mode, "sae-mixed") == 0){ |
| 128 | ap_param->security.mode = wifi_security_mode_wpa3_transition; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 129 | } |
| 130 | |
developer | ff378f2 | 2022-10-13 13:33:57 +0800 | [diff] [blame] | 131 | if(strstr(encryption_mode, "tkip") && (strstr(encryption_mode, "ccmp") || strstr(encryption_mode, "aes") )){ |
| 132 | ap_param->security.encr = wifi_encryption_aes_tkip; |
| 133 | }else if (strstr(encryption_mode, "tkip")){ |
| 134 | ap_param->security.encr = wifi_encryption_tkip; |
| 135 | }else{ |
| 136 | ap_param->security.encr = wifi_encryption_aes; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 137 | } |
developer | ff378f2 | 2022-10-13 13:33:57 +0800 | [diff] [blame] | 138 | |
| 139 | if(!strcmp(encryption_mode, "wpa3") || !strcmp(encryption_mode, "sae")){ |
| 140 | ap_param->security.mfp = wifi_mfp_cfg_required; |
| 141 | }else if (!strcmp(encryption_mode, "sae-mixed")){ |
| 142 | ap_param->security.mfp = wifi_mfp_cfg_optional; |
| 143 | }else{ |
| 144 | ap_param->security.mfp = wifi_mfp_cfg_disabled; |
| 145 | } |
| 146 | |
| 147 | if (!strcmp(encryption_mode, "sae")){ |
| 148 | ap_param->security.u.key.type = wifi_security_key_type_sae; |
| 149 | }else if (!strcmp(encryption_mode, "sae-mixed")){ |
| 150 | ap_param->security.u.key.type = wifi_security_key_type_psk_sae; |
| 151 | }else{ |
| 152 | ap_param->security.u.key.type = wifi_security_key_type_psk; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 153 | } |
developer | ff378f2 | 2022-10-13 13:33:57 +0800 | [diff] [blame] | 154 | |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | void set_key(wifi_ap_param *ap_param, char *key) |
| 158 | { |
developer | ff378f2 | 2022-10-13 13:33:57 +0800 | [diff] [blame] | 159 | strncpy(ap_param->security.u.key.key, key, 64); |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | void set_radio_param(wifi_radio_param radio_parameter) |
| 163 | { |
| 164 | BOOL enable; |
| 165 | BOOL current; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 166 | int ret = 0; |
| 167 | struct params param; |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 168 | wifi_radio_operationParam_t operationParam = {0}; |
| 169 | |
| 170 | if (radio_parameter.disabled == TRUE) { |
| 171 | wifi_setRadioEnable(radio_parameter.radio_index, FALSE); |
| 172 | return; |
| 173 | } |
| 174 | operationParam.enable = TRUE; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 175 | |
| 176 | fprintf(stderr, "Start setting radio\n"); |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 177 | ret = wifi_getRadioOperatingParameters(radio_parameter.radio_index, &operationParam); |
| 178 | if (ret != RETURN_OK) |
| 179 | fprintf(stderr, "[Get OperatingParameters failed!!!]\n"); |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 180 | |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 181 | // Channel |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 182 | operationParam.autoChannelEnabled = radio_parameter.auto_channel; |
| 183 | operationParam.channel = radio_parameter.channel; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 184 | |
developer | 25e0781 | 2022-10-13 15:27:02 +0800 | [diff] [blame^] | 185 | //bandwidth |
| 186 | if (radio_parameter.bandwidth == 20){ |
| 187 | operationParam.channelWidth = WIFI_CHANNELBANDWIDTH_20MHZ; |
| 188 | }else if (radio_parameter.bandwidth == 40){ |
| 189 | operationParam.channelWidth = WIFI_CHANNELBANDWIDTH_40MHZ; |
| 190 | }else if (radio_parameter.bandwidth == 80){ |
| 191 | operationParam.channelWidth = WIFI_CHANNELBANDWIDTH_80MHZ; |
| 192 | }else if (radio_parameter.bandwidth == 160){ |
| 193 | operationParam.channelWidth = WIFI_CHANNELBANDWIDTH_160MHZ; |
| 194 | } |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 195 | // Country |
| 196 | fprintf(stderr, "Set Country: %s\n", radio_parameter.country); |
| 197 | ret = wifi_setRadioCountryCode(radio_parameter.radio_index, radio_parameter.country); |
| 198 | if (ret != RETURN_OK) |
| 199 | fprintf(stderr, "[Set Country failed!!!]\n"); |
| 200 | ret = 0; |
| 201 | |
| 202 | // hwmode |
| 203 | fprintf(stderr, "Set hwmode: %s\n", radio_parameter.hwmode); |
| 204 | ret = wifi_setRadioHwMode(radio_parameter.radio_index, radio_parameter.hwmode); |
| 205 | if (ret != RETURN_OK) |
| 206 | fprintf(stderr, "[Set hwmode failed!!!]\n"); |
| 207 | ret = 0; |
| 208 | |
| 209 | // htmode |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 210 | unsigned int mode = 0; // enum wifi_ieee80211Variant_t |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 211 | if (strcmp(radio_parameter.band, "2g") == 0) { |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 212 | mode |= WIFI_80211_VARIANT_B | WIFI_80211_VARIANT_G; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 213 | if (strcmp(radio_parameter.htmode, "NOHT") == 0 || strcmp(radio_parameter.htmode, "NONE") == 0) |
| 214 | strcpy(radio_parameter.htmode, "11G"); |
| 215 | |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 216 | if (strstr(radio_parameter.htmode, "HE") != NULL) |
| 217 | mode |= WIFI_80211_VARIANT_N | WIFI_80211_VARIANT_AX; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 218 | |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 219 | } else if (strcmp(radio_parameter.band, "5g") == 0) { |
| 220 | mode |= WIFI_80211_VARIANT_A; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 221 | if (strcmp(radio_parameter.htmode, "NOHT") == 0 || strcmp(radio_parameter.htmode, "NONE") == 0) |
| 222 | strcpy(radio_parameter.htmode, "11A"); |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 223 | |
| 224 | if (strstr(radio_parameter.htmode, "HE") != NULL) |
| 225 | mode |= WIFI_80211_VARIANT_N | WIFI_80211_VARIANT_AC | WIFI_80211_VARIANT_AX; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | if (strstr(radio_parameter.htmode, "VHT") != NULL) |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 229 | mode |= WIFI_80211_VARIANT_N | WIFI_80211_VARIANT_AC; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 230 | else if (strstr(radio_parameter.htmode, "HT") != NULL && strstr(radio_parameter.htmode, "NO") == NULL) |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 231 | mode |= WIFI_80211_VARIANT_N; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 232 | |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 233 | operationParam.variant = mode; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 234 | |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 235 | // apply setting |
| 236 | ret = wifi_setRadioOperatingParameters(radio_parameter.radio_index, &operationParam); |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 237 | if (ret != RETURN_OK) |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 238 | fprintf(stderr, "[Apply setting failed!!!]\n"); |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 239 | |
| 240 | } |
| 241 | |
| 242 | void set_ap_param(wifi_ap_param ap_param) |
| 243 | { |
| 244 | int ret = 0; |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 245 | int vap_index_in_map = 0; |
| 246 | wifi_vap_info_t vap_info = {0}; |
| 247 | wifi_vap_info_map_t vap_map = {0}; |
| 248 | |
| 249 | ret = wifi_getRadioVapInfoMap(ap_param.radio_index, &vap_map); |
| 250 | if (ret != RETURN_OK) { // if failed, we set assume this vap as the first vap. |
| 251 | fprintf(stderr, "[Get vap map failed!!!]\n"); |
| 252 | vap_map.num_vaps = MAX_NUM_VAP_PER_RADIO; |
| 253 | } else { // get the index of the map |
| 254 | for (int i = 0; i < vap_map.num_vaps; i++) { |
| 255 | if (vap_map.vap_array[i].vap_index == ap_param.ap_index) { |
| 256 | vap_index_in_map = i; |
| 257 | break; |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | // get current setting |
| 263 | vap_info = vap_map.vap_array[vap_index_in_map]; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 264 | |
| 265 | fprintf(stderr, "Start setting ap\n"); |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 266 | // SSID |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 267 | strncpy(vap_info.u.bss_info.ssid, ap_param.ssid, 33); |
| 268 | vap_info.u.bss_info.ssid[32] = '\0'; |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 269 | |
developer | ff378f2 | 2022-10-13 13:33:57 +0800 | [diff] [blame] | 270 | vap_info.u.bss_info.security.mode = ap_param.security.mode; |
| 271 | vap_info.u.bss_info.security.encr = ap_param.security.encr; |
| 272 | vap_info.u.bss_info.security.mfp = ap_param.security.mfp; |
| 273 | vap_info.u.bss_info.security.u.key.type = ap_param.security.u.key.type; |
| 274 | strncpy(vap_info.u.bss_info.security.u.key.key, ap_param.security.u.key.key, 64); |
| 275 | |
| 276 | ret = wifi_setApSecurity(ap_param.ap_index, &vap_info.u.bss_info.security); |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 277 | if (ret != RETURN_OK) |
developer | ff378f2 | 2022-10-13 13:33:57 +0800 | [diff] [blame] | 278 | fprintf(stderr, "[set Security failed!!!]\n"); |
developer | 25e0781 | 2022-10-13 15:27:02 +0800 | [diff] [blame^] | 279 | |
developer | 63d7277 | 2022-10-07 09:42:31 +0800 | [diff] [blame] | 280 | // Replace the setting with uci config |
| 281 | vap_map.vap_array[vap_index_in_map] = vap_info; |
| 282 | ret = wifi_createVAP(ap_param.radio_index, &vap_map); |
| 283 | if (ret != RETURN_OK) |
| 284 | fprintf(stderr, "[Apply vap setting failed!!!]\n"); |
| 285 | |
developer | 91f8074 | 2022-10-04 15:20:18 +0800 | [diff] [blame] | 286 | // restart ap |
| 287 | wifi_setApEnable(ap_param.ap_index, FALSE); |
| 288 | wifi_setApEnable(ap_param.ap_index, TRUE); |
| 289 | } |
| 290 | |
| 291 | int apply_uci_config () |
| 292 | { |
| 293 | struct uci_context *uci_ctx = uci_alloc_context(); |
| 294 | struct uci_package *uci_pkg = NULL; |
| 295 | struct uci_element *e; |
| 296 | // struct uci_section *s; |
| 297 | const char cfg_name[] = "wireless"; |
| 298 | int max_radio_num = 0; |
| 299 | BOOL parsing_radio = FALSE; |
| 300 | |
| 301 | wifi_getMaxRadioNumber(&max_radio_num); |
| 302 | fprintf(stderr, "max radio number: %d\n", max_radio_num); |
| 303 | if (uci_load(uci_ctx, cfg_name, &uci_pkg) != UCI_OK) { |
| 304 | uci_free_context(uci_ctx); |
| 305 | fprintf(stderr, "%s: load uci failed.\n", __func__); |
| 306 | return RETURN_ERR; |
| 307 | } |
| 308 | |
| 309 | uci_foreach_element(&uci_pkg->sections, e) { |
| 310 | |
| 311 | struct uci_section *s = uci_to_section(e); |
| 312 | struct uci_element *option = NULL; |
| 313 | wifi_radio_param radio_param = {0}; |
| 314 | wifi_ap_param ap_param = {0}; |
| 315 | radio_param.radio_index = -1; |
| 316 | ap_param.ap_index = -1; |
| 317 | |
| 318 | if (strcmp(s->type, "wifi-device") == 0) { |
| 319 | sscanf(s->e.name, "radio%d", &radio_param.radio_index); |
| 320 | parsing_radio = TRUE; |
| 321 | fprintf(stderr, "\n----- Start parsing radio %d config. -----\n", radio_param.radio_index); |
| 322 | } else if (strcmp(s->type, "wifi-iface") == 0) { |
| 323 | sscanf(s->e.name, "default_radio%d", &ap_param.ap_index); |
| 324 | parsing_radio = FALSE; |
| 325 | fprintf(stderr, "\n----- Start parsing ap %d config. -----\n", ap_param.ap_index); |
| 326 | } |
| 327 | |
| 328 | uci_foreach_element(&s->options, option) { |
| 329 | |
| 330 | struct uci_option *op = uci_to_option(option); |
| 331 | if (parsing_radio == TRUE) { |
| 332 | // transform the type from input string and store the value in radio_param. |
| 333 | if (strcmp(op->e.name, "channel") == 0) |
| 334 | set_channel(&radio_param, op->v.string); |
| 335 | else if (strcmp(op->e.name, "hwmode") == 0) |
| 336 | set_hwmode(&radio_param, op->v.string); |
| 337 | else if (strcmp(op->e.name, "htmode") == 0) |
| 338 | set_htmode(&radio_param, op->v.string); |
| 339 | else if (strcmp(op->e.name, "disabled") == 0) |
| 340 | set_disable(&radio_param, op->v.string); |
| 341 | else if (strcmp(op->e.name, "band") == 0) |
| 342 | set_band(&radio_param, op->v.string); |
| 343 | else if (strcmp(op->e.name, "country") == 0) |
| 344 | set_country(&radio_param, op->v.string); |
| 345 | else if (strcmp(op->e.name, "noscan") == 0) |
| 346 | set_band(&radio_param, op->v.string); |
| 347 | else |
| 348 | fprintf(stderr, "[%s %s not set!]\n", op->e.name, op->v.string); |
| 349 | } else { |
| 350 | // parsing iface |
| 351 | if (strcmp(op->e.name, "device") == 0) |
| 352 | set_radionum(&ap_param, op->v.string); |
| 353 | else if (strcmp(op->e.name, "ssid") == 0) |
| 354 | set_ssid(&ap_param, op->v.string); |
| 355 | else if (strcmp(op->e.name, "encryption") == 0) |
| 356 | set_encryption(&ap_param, op->v.string); |
| 357 | else if (strcmp(op->e.name, "key") == 0) |
| 358 | set_key(&ap_param, op->v.string); |
| 359 | else |
| 360 | fprintf(stderr, "[%s %s not set!]\n", op->e.name, op->v.string); |
| 361 | } |
| 362 | } |
| 363 | if (parsing_radio == TRUE) |
| 364 | set_radio_param(radio_param); |
| 365 | else |
| 366 | set_ap_param(ap_param); |
| 367 | } |
| 368 | |
| 369 | uci_unload(uci_ctx, uci_pkg); |
| 370 | uci_free_context(uci_ctx); |
| 371 | return RETURN_OK; |
| 372 | } |
| 373 | |
| 374 | int main(int argc, char **argv) |
| 375 | { |
| 376 | if (argc != 2 || strcmp(argv[1], "reload") != 0) { |
| 377 | fprintf(stderr, "Usage: wifi reload.\nThis tool is only for RDKB MSP/SQC test.\n"); |
| 378 | return -1; |
| 379 | } |
| 380 | apply_uci_config(); |
| 381 | return 0; |
| 382 | } |