Beispiel #1
0
int runtime_config_qtn(int unit, int subunit)
{
	int ret;

	if (!rpc_qtn_ready()) {
		dbG("qcsapi error\n");
		return -1;
	}
	if ( unit == 1 && subunit == -1 ){
		dbG("Global QTN settings\n");
		if(nvram_get_int("wl1_itxbf") == 1 || nvram_get_int("wl1_txbf") == 1){
			dbG("[bf] set_bf_on\n");
			qcsapi_wifi_run_script("router_command.sh", "set_bf_on");
			ret = qcsapi_config_update_parameter(WIFINAME, "bf", "1");
			if (ret < 0) dbG("qcsapi error\n");
		}else{
			dbG("[bf] set_bf_off\n");
			qcsapi_wifi_run_script("router_command.sh", "set_bf_off");
			ret = qcsapi_config_update_parameter(WIFINAME, "bf", "0");
			if (ret < 0) dbG("qcsapi error\n");
		}
		gen_stateless_conf();
	}
	rpc_parse_nvram_from_httpd(unit, subunit);
	return 1;
}
Beispiel #2
0
int setRegrev_5G_qtn(const char *regrev)
{
	int ret;
	char value[20] = {0};

	if( regrev==NULL || !isValidRegrev((char *)regrev) )
		return 0;

	if (!rpc_qtn_ready()) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_bootcfg_update_parameter("regrev_5g", regrev);
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_bootcfg_get_parameter("regrev_5g", value, sizeof(value));
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}

	memset(cmd, 0, 32);
	sprintf(cmd, "asuscfe1:regrev=%s", regrev);
	eval("nvram", "set", cmd );
	puts(nvram_safe_get("1:regrev"));
	return 1;
}
Beispiel #3
0
int setAllLedOff_qtn(void)
{
	int ret;

	if (!rpc_qtn_ready()) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_wifi_run_script("router_command.sh", "wifi_led_off");
	if (ret < 0) {
		fprintf(stderr, "[led] router_command.sh: wifi_led_off error\n");
		return -1;
	}

	ret = qcsapi_led_set(1, 0);
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}

	ret = qcsapi_wifi_run_script("router_command.sh", "lan4_led_ctrl off");
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	return 0;
}
Beispiel #4
0
int GetPhyStatus_qtn(void)
{
	int ret;

	if (!rpc_qtn_ready()) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_wifi_run_script("router_command.sh", "get_eth_1000m");
	if (ret < 0) {
		ret = qcsapi_wifi_run_script("router_command.sh", "get_eth_100m");
		if (ret < 0) {
			ret = qcsapi_wifi_run_script("router_command.sh", "get_eth_10m");
			if (ret < 0) {
				// fprintf(stderr, "ATE command error\n");
				return 0;
			}else{
				return 10;
			}
		}else{
			return 100;
		}
		return -1;
	}else{
		return 1000;
	}
	return 0;
}
Beispiel #5
0
int
setCountryCode_5G_qtn(const char *cc)
{
	int ret;
	char value[20] = {0};

	if( cc==NULL || !isValidCountryCode(cc) )
		return 0;

	if (!rpc_qtn_ready()) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_bootcfg_update_parameter("ccode_5g", cc);
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_bootcfg_get_parameter("ccode_5g", value, sizeof(value));
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}

	sprintf(cmd, "asuscfe1:ccode=%s", cc);
	eval("nvram", "set", cmd );
	puts(nvram_safe_get("1:ccode"));

	return 1;
}
Beispiel #6
0
int del_qtn_cal_files(void)
{
	int ret;

	if (!rpc_qtn_ready()) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_wifi_run_script("router_command.sh", "del_cal_files");
	if (ret < 0) {
		fprintf(stderr, "[ate] delete calibration files error\n");
		return -1;
	}
	return 0;
}
Beispiel #7
0
int getMAC_5G_qtn(void)
{
	int ret;
	char value[20] = {0};

	if (!rpc_qtn_ready()) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_bootcfg_get_parameter("ethaddr", value, sizeof(value));
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	puts(value);
	return 1;
}
Beispiel #8
0
int setMAC_5G_qtn(const char *mac)
{
	int ret;
	char cmd_l[64];
	char value[20] = {0};

	if( mac==NULL || !isValidMacAddr(mac) )
		return 0;

	if (!rpc_qtn_ready())
	{
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_bootcfg_update_parameter("ethaddr", mac);
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
#if 0
	inc_mac(mac, 1);
#endif
	ret = qcsapi_bootcfg_update_parameter("wifiaddr", mac);
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_bootcfg_get_parameter("ethaddr", value, sizeof(value));
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}

	memset(cmd_l, 0, 64);
	sprintf(cmd_l, "asuscfe1:macaddr=%s", mac);
	eval("nvram", "set", cmd_l );
	// puts(nvram_safe_get("1:macaddr"));

	puts(value);
	return 1;
}
Beispiel #9
0
int enable_qtn_telnetsrv(int enable_flag)
{
	int ret;

	if (!rpc_qtn_ready()) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	if(enable_flag == 0){
		nvram_set("QTNTELNETSRV", "0");
		ret = qcsapi_wifi_run_script("router_command.sh", "enable_telnet_srv 0");
	}else{
		nvram_set("QTNTELNETSRV", "1");
		ret = qcsapi_wifi_run_script("router_command.sh", "enable_telnet_srv 1");
	}
	if (ret < 0) {
		fprintf(stderr, "[ate] set telnet server error\n");
		return -1;
	}
	nvram_commit();
	return 0;
}
Beispiel #10
0
int start_nodfs_scan_qtn(void)
{
	int		 qcsapi_retval;
	int pick_flags = 0;

	logmessage("dfs", "start dfs scan\n");

	pick_flags = IEEE80211_PICK_CLEAREST;
	pick_flags |= IEEE80211_PICK_NONDFS;

	if (!rpc_qtn_ready()) {
		dbG("5 GHz radio is not ready\n");
		return -1;
	}
	qcsapi_retval = qcsapi_wifi_start_scan_ext(WIFINAME, pick_flags);
	if (qcsapi_retval >= 0) {
		logmessage("nodfs_scan", "complete");
	}else{
		logmessage("nodfs_scan", "scan not complete");
	}

	return 1;
}
Beispiel #11
0
int Get_channel_list_qtn(int unit)
{
	int ret;
	string_1024 list_of_channels;
	char cur_ccode[20] = {0};

	if (!rpc_qtn_ready()) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_wifi_get_regulatory_region("wifi0", cur_ccode);
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	ret = qcsapi_regulatory_get_list_regulatory_channels(cur_ccode, 20 /* bw */, list_of_channels);
	if (ret < 0) {
		fprintf(stderr, "ATE command error\n");
		return -1;
	}
	puts(list_of_channels);

	return 1;
}
Beispiel #12
0
int start_psta_qtn(void)
{
	static qcsapi_SSID	 array_ssids[10 /* MAX_SSID_LIST_SIZE */];
	int			 qcsapi_retval;
	unsigned int		 iter;
	qcsapi_unsigned_int	 sizeof_list = 2 /* DEFAULT_SSID_LIST_SIZE */ ;
	char			*list_ssids[10 /* MAX_SSID_LIST_SIZE */ + 1];
	int ret;

	if (!rpc_qtn_ready()) {
		dbG("5 GHz radio is not ready\n");
		return -1;
	}

	logmessage("start_psta", "media bridge is running...");

	qcsapi_retval = qcsapi_wifi_reload_in_mode(WIFINAME, qcsapi_station);

	if (qcsapi_retval >= 0) {
		fprintf(stderr, "reload to STA mode successfuly\n" );
	} else {
		fprintf(stderr, "reload to STA mode failed\n" );
	}

	for (iter = 0; iter < sizeof_list; iter++) {
		list_ssids[iter] = array_ssids[iter];
		*(list_ssids[iter]) = '\0';
	}

	qcsapi_retval = qcsapi_SSID_get_SSID_list(WIFINAME, sizeof_list, &list_ssids[0]);
	if (qcsapi_retval >= 0) {
		for (iter = 0; iter < sizeof_list; iter++) {
			if ((list_ssids[iter] == NULL) || strlen(list_ssids[iter]) < 1) {
				break;
			}
			fprintf(stderr, "remove [%s]\n", list_ssids[iter]);
			qcsapi_SSID_remove_SSID(WIFINAME, array_ssids[iter]);
		}
	}

	// verify ssid, if not exists, create new one
	char ssid[33];
	strncpy(ssid, nvram_safe_get("wlc_ssid"), sizeof(ssid));
	logmessage("start_psta", "verify ssid [%s]", ssid);
	if(qcsapi_SSID_verify_SSID(WIFINAME, ssid) < 0){
		logmessage("start_psta", "Not such SSID in sta mode\n");
		if(qcsapi_SSID_create_SSID(WIFINAME, ssid) < 0)
			logmessage("start_psta", "fail to create SSID in sta mode\n");
	}

	// check security
	char auth[8];
	char crypto[16];
	char beacon[] = "WPAand11i";
	char encryption[] = "TKIPandAESEncryption";
	char key[65];
	uint32_t index = 0;

	strncpy(auth, nvram_safe_get("wlc_auth_mode"), sizeof(auth));
	strncpy(crypto, nvram_safe_get("wlc_crypto"), sizeof(crypto));
	strncpy(key, nvram_safe_get("wlc_wpa_psk"), sizeof(key));

	if(!strcmp(auth, "psk2") && !strcmp(crypto, "aes")){
		memcpy(beacon, "11i", strlen("11i") + 1);
		memcpy(encryption, "AESEncryption", strlen("AESEncryption") + 1);
	}
	else if(!strcmp(auth, "pskpsk2") && !strcmp(crypto, "aes") ){
		memcpy(beacon, "WPAand11i", strlen("WPAand11i") + 1);
		memcpy(encryption, "AESEncryption", strlen("AESEncryption") + 1);
	}
	else if(!strcmp(auth, "pskpsk2") && !strcmp(crypto, "tkip+aes") ){
		memcpy(beacon, "WPAand11i", strlen("WPAand11i") + 1);
		memcpy(encryption, "TKIPandAESEncryption", strlen("TKIPandAESEncryption") + 1);
	}
	else{
		logmessage("start_psta", "not support such authentication & encryption\n");
	}

	logmessage("start_psta", "ssid=%s, auth=%s, crypto=%s, encryption=%s, key=%s\n", ssid, auth, crypto, encryption, key);
	if(!strcmp(auth, "open")){
		if(qcsapi_SSID_set_authentication_mode(WIFINAME, ssid, "NONE") < 0)
			logmessage("start_psta", "fail to setup a open-none sta\n");
	}
	else{
		if(qcsapi_SSID_set_protocol(WIFINAME, ssid, beacon) < 0)
			logmessage("start_psta", "fail to setup protocol in sta\n");
		if(qcsapi_SSID_set_authentication_mode(WIFINAME, ssid, "PSKAuthentication") < 0)
			logmessage("start_psta", "fail to setup authentiocation type in sta\n");
		if(qcsapi_SSID_set_key_passphrase(WIFINAME, ssid, index, key) < 0)
			logmessage("start_psta", "fail to set key in sta\n");
	}

	// eval("wpa_cli", "reconfigure");
	ret = qcsapi_wifi_run_script("router_command.sh", "wpa_cli_reconfigure");
	if (ret < 0) {
		fprintf(stderr, "[psta] router_command.sh: wpa_cli_reconfigure error\n");
		return -1;
	}

	logmessage("start_psta", "start_psta done!\n");

	return 1;
}
Beispiel #13
0
int start_ap_qtn(void)
{
	int ret;
	int			 qcsapi_retval;
	unsigned int		 iter;
	char ssid[65];

	if (!rpc_qtn_ready()) {
		dbG("5 GHz radio is not ready\n");
		return -1;
	}

	logmessage("start_ap", "AP is running...");

#if 0
	qcsapi_retval = qcsapi_wifi_reload_in_mode(WIFINAME, qcsapi_access_point);

	if (qcsapi_retval >= 0) {
		fprintf(stderr, "reload to AP mode successfuly\n" );
	} else {
		fprintf(stderr, "reload to AP mode failed\n" );
	}
#endif
	sprintf(ssid, "%s", nvram_safe_get("wl1_ssid"));
	ret = qcsapi_wifi_set_SSID(WIFINAME, ssid);

	// check security
	char auth[8];
	char crypto[16];
	char beacon[] = "WPAand11i";
	char encryption[] = "TKIPandAESEncryption";
	char key[65];
	uint32_t index = 0;

	strncpy(auth, nvram_safe_get("wl1_auth_mode_x"), sizeof(auth));
	strncpy(crypto, nvram_safe_get("wl1_crypto"), sizeof(crypto));
	strncpy(key, nvram_safe_get("wl1_wpa_psk"), sizeof(key));

	if(!strcmp(auth, "psk2") && !strcmp(crypto, "aes")){
		memcpy(beacon, "11i", strlen("11i") + 1);
		memcpy(encryption, "AESEncryption", strlen("AESEncryption") + 1);
	}
	else if(!strcmp(auth, "pskpsk2") && !strcmp(crypto, "aes") ){
		memcpy(beacon, "WPAand11i", strlen("WPAand11i") + 1);
		memcpy(encryption, "AESEncryption", strlen("AESEncryption") + 1);
	}
	else if(!strcmp(auth, "pskpsk2") && !strcmp(crypto, "tkip+aes") ){
		memcpy(beacon, "WPAand11i", strlen("WPAand11i") + 1);
		memcpy(encryption, "TKIPandAESEncryption", strlen("TKIPandAESEncryption") + 1);
	}
	else{
		logmessage("start_ap", "No security in use\n");
		memcpy(beacon, "Basic", strlen("Basic") + 1);
	}

	logmessage("start_ap", "ssid=%s, auth=%s, crypto=%s, encryption=%s, key=%s\n", ssid, auth, crypto, encryption, key);
	if(!strcmp(auth, "open")){
		if(qcsapi_wifi_set_WPA_authentication_mode(WIFINAME, "NONE") < 0)
			logmessage("start_ap", "fail to setup a open-none ap\n");
		if(qcsapi_wifi_set_beacon_type(WIFINAME, beacon) < 0)
			logmessage("start_ap", "fail to setup beacon type in ap\n");
	}
	else{
		if(qcsapi_wifi_set_beacon_type(WIFINAME, beacon) < 0)
			logmessage("start_ap", "fail to setup beacon type in ap\n");
		if(qcsapi_wifi_set_WPA_authentication_mode(WIFINAME, "PSKAuthentication") < 0)
			logmessage("start_ap", "fail to setup authentiocation type in ap\n");
		if(qcsapi_wifi_set_key_passphrase(WIFINAME, index, key) < 0)
			logmessage("start_ap", "fail to set key in ap\n");
		if(qcsapi_wifi_set_WPA_encryption_modes(WIFINAME, encryption) < 0)
			logmessage("start_ap", "fail to set encryption mode in ap\n");
	}

	logmessage("start_ap", "start_ap done!\n");

	return 1;
}
Beispiel #14
0
int wlcscan_core_qtn(char *ofile, char *ifname)
{
	int i;
	int scanstatus = -1;
	uint32_t count;
	qcsapi_ap_properties	params;
	char buff[256];
	FILE *fp_apscan;

	if (!rpc_qtn_ready()) {
		dbG("5 GHz radio is not ready\n");
		return -1;
	}

	logmessage("wlcscan", "start wlcscan scan\n");

	/* clean APSCAN_INFO */
	lock_qtn_apscan = file_lock("sitesurvey");
	if((fp_apscan = fopen(ofile, "a")) != NULL){
		fclose(fp_apscan);
	}
	file_unlock(lock_qtn_apscan);
	
	// start scan AP
	// if(qcsapi_wifi_start_scan(ifname)){
	if(qcsapi_wifi_start_scan_ext(ifname, IEEE80211_PICK_ALL | IEEE80211_PICK_NOPICK_BG)){
		dbg("fail to start AP scan\n");
		return 0;
	}
	fprintf(stderr, "ok to start AP scan\n");

	// loop for check scan status
	while(1){
		if(qcsapi_wifi_get_scan_status(ifname, &scanstatus) < 0){
			dbg("scan error occurs\n");
			return 0;
		}
		
		// if scanstatus = 0 , no scan is running
		if(scanstatus == 0) break;
		else{
			dbg("scan is running...\n");
			sleep(1);
		}
	}

	// check AP scan
	if(qcsapi_wifi_get_results_AP_scan(ifname, &count) < 0){
		dbg("fail to get AP scan results, ifname=%s, count=%d\n", ifname, (int)count);
		return 0;
	}

	if((int)count > 0){
		if((fp_apscan = fopen(ofile, "a")) == NULL){
			dbg("fail to write to [%s]\n", ofile);
			return 0;
		}
		else{
			// for loop
			for(i = 0; i < (int)count; i++){
				// get properties of AP
				if(!qcsapi_wifi_get_properties_AP(ifname, (uint32_t)i, &params)){
					show_ap_properties((uint32_t)i, &params, buff);
					fprintf(fp_apscan, "%s", buff);
				}
				else{
					dbg("fail to get AP properties\n");
					fclose(fp_apscan);
				}

				if (i == (int)count - 1){
					fprintf(fp_apscan, "\n");
				}else{
					fprintf(fp_apscan, "\n");
				}
			}
			// for loop
		}
	}
	fclose(fp_apscan);
	return 1;
}
Beispiel #15
0
void rpc_parse_nvram_from_httpd(int unit, int subunit)
{
	if (!rpc_qtn_ready())
		return;

	if (unit == 1 && subunit == -1){
		rpc_qcsapi_set_SSID(WIFINAME, nvram_safe_get("wl1_ssid"));
		rpc_qcsapi_set_SSID_broadcast(WIFINAME, nvram_safe_get("wl1_closed"));
		rpc_qcsapi_set_vht(nvram_safe_get("wl1_nmode_x"));
		rpc_qcsapi_set_bw(nvram_safe_get("wl1_bw"));
		rpc_qcsapi_set_channel(nvram_safe_get("wl1_chanspec"));
		rpc_qcsapi_set_beacon_type(WIFINAME, nvram_safe_get("wl1_auth_mode_x"));
		rpc_qcsapi_set_WPA_encryption_modes(WIFINAME, nvram_safe_get("wl1_crypto"));
		rpc_qcsapi_set_key_passphrase(WIFINAME, nvram_safe_get("wl1_wpa_psk"));
		rpc_qcsapi_set_dtim(nvram_safe_get("wl1_dtim"));
		rpc_qcsapi_set_beacon_interval(nvram_safe_get("wl1_bcn"));
		rpc_set_radio(1, 0, nvram_get_int("wl1_radio"));
		rpc_update_macmode(nvram_safe_get("wl1_macmode"));
		rpc_update_wlmaclist();
		rpc_update_wdslist();
		rpc_update_wdslist();
		rpc_update_wds_psk(nvram_safe_get("wl1_wds_psk"));
		rpc_update_ap_isolate(WIFINAME, atoi(nvram_safe_get("wl1_ap_isolate")));

		if(nvram_get_int("wl1_80211h") == 1){
			dbG("[80211h] set_80211h_on\n");
			qcsapi_wifi_run_script("router_command.sh", "80211h_on");
		}else{
			dbG("[80211h] set_80211h_off\n");
			qcsapi_wifi_run_script("router_command.sh", "80211h_off");
		}
		if(nvram_get_int("sw_mode") == SW_MODE_ROUTER ||
			(nvram_get_int("sw_mode") == SW_MODE_AP &&
				nvram_get_int("wlc_psta") == 0)){
			if(nvram_get_int("wl1_chanspec") == 0){
				if (nvram_match("1:ccode", "EU")){
					if(nvram_get_int("acs_dfs") != 1){
						dbG("[dfs] start nodfs scanning and selection\n");
						start_nodfs_scan_qtn();
					}
				}else{
					/* all country except EU */
					dbG("[dfs] start nodfs scanning and selection\n");
					start_nodfs_scan_qtn();
				}
			}
		}
	}else if (unit == 1 && subunit == 1){
		if(nvram_get_int("wl1.1_bss_enabled") == 1){
			rpc_update_mbss("wl1.1_ssid", nvram_safe_get("wl1.1_ssid"));
			rpc_update_mbss("wl1.1_bss_enabled", nvram_safe_get("wl1.1_bss_enabled"));
			rpc_update_mbss("wl1.1_wpa_psk", nvram_safe_get("wl1.1_wpa_psk"));
			rpc_update_mbss("wl1.1_wpa_gtk_rekey", nvram_safe_get("wl1.1_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.1_auth_mode_x", nvram_safe_get("wl1.1_auth_mode_x"));
			rpc_update_mbss("wl1.1_mbss", nvram_safe_get("wl1.1_mbss"));
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}else if (unit == 1 && subunit == 2){
		if(nvram_get_int("wl1.2_bss_enabled") == 1){
			rpc_update_mbss("wl1.2_ssid", nvram_safe_get("wl1.2_ssid"));
			rpc_update_mbss("wl1.2_bss_enabled", nvram_safe_get("wl1.2_bss_enabled"));
			rpc_update_mbss("wl1.2_wpa_psk", nvram_safe_get("wl1.2_wpa_psk"));
			rpc_update_mbss("wl1.2_wpa_gtk_rekey", nvram_safe_get("wl1.2_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.2_auth_mode_x", nvram_safe_get("wl1.2_auth_mode_x"));
			rpc_update_mbss("wl1.2_mbss", nvram_safe_get("wl1.2_mbss"));
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}else if (unit == 1 && subunit == 3){
		if(nvram_get_int("wl1.3_bss_enabled") == 1){
			rpc_update_mbss("wl1.3_ssid", nvram_safe_get("wl1.3_ssid"));
			rpc_update_mbss("wl1.3_bss_enabled", nvram_safe_get("wl1.3_bss_enabled"));
			rpc_update_mbss("wl1.3_wpa_psk", nvram_safe_get("wl1.3_wpa_psk"));
			rpc_update_mbss("wl1.3_wpa_gtk_rekey", nvram_safe_get("wl1.3_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.3_auth_mode_x", nvram_safe_get("wl1.3_auth_mode_x"));
			rpc_update_mbss("wl1.3_mbss", nvram_safe_get("wl1.3_mbss"));
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}

//	rpc_show_config();
}
Beispiel #16
0
void rpc_parse_nvram_from_httpd(int unit, int subunit)
{
	int ret = 0;
	if (!rpc_qtn_ready())
		return;

	if (unit == 1 && subunit == -1){
		rpc_qcsapi_set_SSID(WIFINAME, nvram_safe_get("wl1_ssid"));
		rpc_qcsapi_set_SSID_broadcast(WIFINAME, nvram_safe_get("wl1_closed"));
		rpc_qcsapi_set_vht(nvram_safe_get("wl1_nmode_x"));
		rpc_qcsapi_set_bw(nvram_safe_get("wl1_bw"));
		rpc_qcsapi_set_channel(nvram_safe_get("wl1_chanspec"));
		rpc_qcsapi_set_beacon_type(WIFINAME, nvram_safe_get("wl1_auth_mode_x"));
		rpc_qcsapi_set_WPA_encryption_modes(WIFINAME, nvram_safe_get("wl1_crypto"));
		rpc_qcsapi_set_key_passphrase(WIFINAME, nvram_safe_get("wl1_wpa_psk"));
		rpc_qcsapi_set_dtim(nvram_safe_get("wl1_dtim"));
		rpc_qcsapi_set_beacon_interval(nvram_safe_get("wl1_bcn"));
		rpc_set_radio(1, 0, nvram_get_int("wl1_radio"));
		rpc_update_macmode(nvram_safe_get("wl1_macmode"));
		rpc_update_wlmaclist();
		rpc_update_wdslist();
		rpc_update_wdslist();
		rpc_update_wds_psk(nvram_safe_get("wl1_wds_psk"));
		rpc_update_ap_isolate(WIFINAME, atoi(nvram_safe_get("wl1_ap_isolate")));

		if(nvram_get_int("wps_enable") == 1){
			ret = rpc_qcsapi_wifi_disable_wps(WIFINAME, 0);
			if (ret < 0)
				dbG("rpc_qcsapi_wifi_disable_wps %s error, return: %d\n", WIFINAME, ret);

			ret = qcsapi_wps_set_ap_pin(WIFINAME, nvram_safe_get("wps_device_pin"));
			if (ret < 0)
				dbG("qcsapi_wps_set_ap_pin %s error, return: %d\n", WIFINAME, ret);

			ret = qcsapi_wps_registrar_set_pp_devname(WIFINAME, 0, (const char *) get_productid());
			if (ret < 0)
				dbG("qcsapi_wps_registrar_set_pp_devname %s error, return: %d\n", WIFINAME, ret);

		}else{
			ret = rpc_qcsapi_wifi_disable_wps(WIFINAME, 1);
			if (ret < 0)
				dbG("rpc_qcsapi_wifi_disable_wps %s error, return: %d\n", WIFINAME, ret);
		}

		ret = qcsapi_wps_upnp_enable(WIFINAME, 0);
		if (ret < 0)
			dbG("disable WPS UPnP %s error, return: %d\n", WIFINAME, ret);

		if(nvram_get_int("sw_mode") == SW_MODE_ROUTER ||
			(nvram_get_int("sw_mode") == SW_MODE_AP && nvram_get_int("wlc_psta") == 1)){
			if(nvram_get_int("wl1_mumimo") == 1){
				dbG("mu-mimo: enable MU-MIMO\n");
				ret = qcsapi_wifi_set_enable_mu(WIFINAME, 1);
			}else{
				dbG("mu-mimo: disable MU-MIMO\n");
				 qcsapi_wifi_set_enable_mu(WIFINAME, 0);
			}
			if (ret < 0)
				dbG("enable_mu %s error, return: %d\n", WIFINAME, ret);
		}
#ifdef RTCONFIG_IPV6
		if (get_ipv6_service() == IPV6_DISABLED)
			qcsapi_wifi_run_script("router_command.sh", "ipv6_off wifi0");
		else
			qcsapi_wifi_run_script("router_command.sh", "ipv6_on wifi0");
#endif
	}else if (unit == 1 && subunit == 1){
		if(nvram_get_int("wl1.1_bss_enabled") == 1){
			rpc_update_mbss("wl1.1_ssid", nvram_safe_get("wl1.1_ssid"));
			rpc_update_mbss("wl1.1_bss_enabled", nvram_safe_get("wl1.1_bss_enabled"));
			rpc_update_mbss("wl1.1_wpa_psk", nvram_safe_get("wl1.1_wpa_psk"));
			rpc_update_mbss("wl1.1_wpa_gtk_rekey", nvram_safe_get("wl1.1_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.1_auth_mode_x", nvram_safe_get("wl1.1_auth_mode_x"));
			rpc_update_mbss("wl1.1_mbss", nvram_safe_get("wl1.1_mbss"));
			if(nvram_get_int("sw_mode") == SW_MODE_ROUTER){
				if(nvram_match("wl1.1_lanaccess", "off") && !nvram_match("wl1.1_lanaccess", "")){
					dbG("[lanaccess] wifi1 lanaccess off\n");
					// libqcsapi_client/qtn/qtn_vlan.h
					// QVLAN_VID_ALL: 0xffff
					qcsapi_wifi_vlan_config("wifi0", e_qcsapi_vlan_enable, 0xffff /* QVLAN_VID_ALL */);
					qcsapi_wifi_vlan_config("wifi1", e_qcsapi_vlan_add, 4000 /* vid */);
				}else{
					qcsapi_wifi_vlan_config("wifi1", e_qcsapi_vlan_del, 4000 /* vid */);
				}
			}
#ifdef RTCONFIG_IPV6
			if (get_ipv6_service() == IPV6_DISABLED)
				qcsapi_wifi_run_script("router_command.sh", "ipv6_off wifi1");
			else
				qcsapi_wifi_run_script("router_command.sh", "ipv6_on wifi1");
#endif
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}else if (unit == 1 && subunit == 2){
		if(nvram_get_int("wl1.2_bss_enabled") == 1){
			rpc_update_mbss("wl1.2_ssid", nvram_safe_get("wl1.2_ssid"));
			rpc_update_mbss("wl1.2_bss_enabled", nvram_safe_get("wl1.2_bss_enabled"));
			rpc_update_mbss("wl1.2_wpa_psk", nvram_safe_get("wl1.2_wpa_psk"));
			rpc_update_mbss("wl1.2_wpa_gtk_rekey", nvram_safe_get("wl1.2_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.2_auth_mode_x", nvram_safe_get("wl1.2_auth_mode_x"));
			rpc_update_mbss("wl1.2_mbss", nvram_safe_get("wl1.2_mbss"));
			if(nvram_get_int("sw_mode") == SW_MODE_ROUTER){
				if(nvram_match("wl1.2_lanaccess", "off") && !nvram_match("wl1.2_lanaccess", "")){
					dbG("[lanaccess] wifi2 lanaccess off\n");
					// libqcsapi_client/qtn/qtn_vlan.h
					// QVLAN_VID_ALL: 0xffff
					qcsapi_wifi_vlan_config("wifi0", e_qcsapi_vlan_enable, 0xffff /* QVLAN_VID_ALL */);
					qcsapi_wifi_vlan_config("wifi2", e_qcsapi_vlan_add, 4001 /* vid */);
				}else{
					qcsapi_wifi_vlan_config("wifi1", e_qcsapi_vlan_del, 4001 /* vid */);
				}
			}
#ifdef RTCONFIG_IPV6
			if (get_ipv6_service() == IPV6_DISABLED)
				qcsapi_wifi_run_script("router_command.sh", "ipv6_off wifi2");
			else
				qcsapi_wifi_run_script("router_command.sh", "ipv6_on wifi2");
#endif
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}else if (unit == 1 && subunit == 3){
		if(nvram_get_int("wl1.3_bss_enabled") == 1){
			rpc_update_mbss("wl1.3_ssid", nvram_safe_get("wl1.3_ssid"));
			rpc_update_mbss("wl1.3_bss_enabled", nvram_safe_get("wl1.3_bss_enabled"));
			rpc_update_mbss("wl1.3_wpa_psk", nvram_safe_get("wl1.3_wpa_psk"));
			rpc_update_mbss("wl1.3_wpa_gtk_rekey", nvram_safe_get("wl1.3_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.3_auth_mode_x", nvram_safe_get("wl1.3_auth_mode_x"));
			rpc_update_mbss("wl1.3_mbss", nvram_safe_get("wl1.3_mbss"));
			if(nvram_get_int("sw_mode") == SW_MODE_ROUTER){
				if(nvram_match("wl1.3_lanaccess", "off") && !nvram_match("wl1.3_lanaccess", "")){
					dbG("[lanaccess] wifi3 lanaccess off\n");
					// libqcsapi_client/qtn/qtn_vlan.h
					// QVLAN_VID_ALL: 0xffff
					qcsapi_wifi_vlan_config("wifi0", e_qcsapi_vlan_enable, 0xffff /* QVLAN_VID_ALL */);
					qcsapi_wifi_vlan_config("wifi3", e_qcsapi_vlan_add, 4002 /* vid */);
				}else{
					qcsapi_wifi_vlan_config("wifi1", e_qcsapi_vlan_del, 4002 /* vid */);
				}
			}
#ifdef RTCONFIG_IPV6
			if (get_ipv6_service() == IPV6_DISABLED)
				qcsapi_wifi_run_script("router_command.sh", "ipv6_off wifi3");
			else
				qcsapi_wifi_run_script("router_command.sh", "ipv6_on wifi3");
#endif
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}
	if(nvram_get_int("sw_mode") == SW_MODE_ROUTER){
		create_mbssid_vlan();
	}

	/* disable UPNP */
	qcsapi_wps_upnp_enable(WIFINAME, 0);

//	rpc_show_config();
}
Beispiel #17
0
void rpc_parse_nvram_from_httpd(int unit, int subunit)
{
	if (!rpc_qtn_ready())
		return;

	if (unit == 1 && subunit == -1){
		rpc_qcsapi_set_SSID(WIFINAME, nvram_safe_get("wl1_ssid"));
		rpc_qcsapi_set_SSID_broadcast(WIFINAME, nvram_safe_get("wl1_closed"));
		rpc_qcsapi_set_vht(nvram_safe_get("wl1_nmode_x"));
		rpc_qcsapi_set_bw(nvram_safe_get("wl1_bw"));
		rpc_qcsapi_set_channel(nvram_safe_get("wl1_chanspec"));
		rpc_qcsapi_set_beacon_type(WIFINAME, nvram_safe_get("wl1_auth_mode_x"));
		rpc_qcsapi_set_WPA_encryption_modes(WIFINAME, nvram_safe_get("wl1_crypto"));
		rpc_qcsapi_set_key_passphrase(WIFINAME, nvram_safe_get("wl1_wpa_psk"));
		rpc_qcsapi_set_dtim(nvram_safe_get("wl1_dtim"));
		rpc_qcsapi_set_beacon_interval(nvram_safe_get("wl1_bcn"));
		rpc_set_radio(1, 0, nvram_get_int("wl1_radio"));
		rpc_update_macmode(nvram_safe_get("wl1_macmode"));
		rpc_update_wlmaclist();
		rpc_update_wdslist();
		rpc_update_wdslist();
		rpc_update_wds_psk(nvram_safe_get("wl1_wds_psk"));
		rpc_update_ap_isolate(WIFINAME, atoi(nvram_safe_get("wl1_ap_isolate")));
	}else if (unit == 1 && subunit == 1){
		if(nvram_get_int("wl1.1_bss_enabled") == 1){
			rpc_update_mbss("wl1.1_ssid", nvram_safe_get("wl1.1_ssid"));
			rpc_update_mbss("wl1.1_bss_enabled", nvram_safe_get("wl1.1_bss_enabled"));
			rpc_update_mbss("wl1.1_wpa_psk", nvram_safe_get("wl1.1_wpa_psk"));
			rpc_update_mbss("wl1.1_wpa_gtk_rekey", nvram_safe_get("wl1.1_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.1_auth_mode_x", nvram_safe_get("wl1.1_auth_mode_x"));
			rpc_update_mbss("wl1.1_mbss", nvram_safe_get("wl1.1_mbss"));
			if(nvram_get_int("sw_mode") == SW_MODE_ROUTER){
				if(nvram_match("wl1.1_lanaccess", "off") && !nvram_match("wl1.1_lanaccess", "")){
					dbG("[lanaccess] wifi1 lanaccess off\n");
					// libqcsapi_client/qtn/qtn_vlan.h
					// QVLAN_VID_ALL: 0xffff
					qcsapi_wifi_vlan_config("wifi0", e_qcsapi_vlan_enable, 0xffff /* QVLAN_VID_ALL */, 0);
					qcsapi_wifi_vlan_config("wifi1", e_qcsapi_vlan_bind, 4000 /* vid */, 0);
				}else{
					qcsapi_wifi_vlan_config("wifi1", e_qcsapi_vlan_unbind, 4000 /* vid */, 0);
				}
			}
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}else if (unit == 1 && subunit == 2){
		if(nvram_get_int("wl1.2_bss_enabled") == 1){
			rpc_update_mbss("wl1.2_ssid", nvram_safe_get("wl1.2_ssid"));
			rpc_update_mbss("wl1.2_bss_enabled", nvram_safe_get("wl1.2_bss_enabled"));
			rpc_update_mbss("wl1.2_wpa_psk", nvram_safe_get("wl1.2_wpa_psk"));
			rpc_update_mbss("wl1.2_wpa_gtk_rekey", nvram_safe_get("wl1.2_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.2_auth_mode_x", nvram_safe_get("wl1.2_auth_mode_x"));
			rpc_update_mbss("wl1.2_mbss", nvram_safe_get("wl1.2_mbss"));
			if(nvram_get_int("sw_mode") == SW_MODE_ROUTER){
				if(nvram_match("wl1.2_lanaccess", "off") && !nvram_match("wl1.2_lanaccess", "")){
					dbG("[lanaccess] wifi2 lanaccess off\n");
					// libqcsapi_client/qtn/qtn_vlan.h
					// QVLAN_VID_ALL: 0xffff
					qcsapi_wifi_vlan_config("wifi0", e_qcsapi_vlan_enable, 0xffff /* QVLAN_VID_ALL */, 0);
					qcsapi_wifi_vlan_config("wifi2", e_qcsapi_vlan_bind, 4001 /* vid */, 0);
				}else{
					qcsapi_wifi_vlan_config("wifi1", e_qcsapi_vlan_unbind, 4001 /* vid */, 0);
				}
			}
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}else if (unit == 1 && subunit == 3){
		if(nvram_get_int("wl1.3_bss_enabled") == 1){
			rpc_update_mbss("wl1.3_ssid", nvram_safe_get("wl1.3_ssid"));
			rpc_update_mbss("wl1.3_bss_enabled", nvram_safe_get("wl1.3_bss_enabled"));
			rpc_update_mbss("wl1.3_wpa_psk", nvram_safe_get("wl1.3_wpa_psk"));
			rpc_update_mbss("wl1.3_wpa_gtk_rekey", nvram_safe_get("wl1.3_wpa_gtk_rekey"));
			rpc_update_mbss("wl1.3_auth_mode_x", nvram_safe_get("wl1.3_auth_mode_x"));
			rpc_update_mbss("wl1.3_mbss", nvram_safe_get("wl1.3_mbss"));
			if(nvram_get_int("sw_mode") == SW_MODE_ROUTER){
				if(nvram_match("wl1.3_lanaccess", "off") && !nvram_match("wl1.3_lanaccess", "")){
					dbG("[lanaccess] wifi3 lanaccess off\n");
					// libqcsapi_client/qtn/qtn_vlan.h
					// QVLAN_VID_ALL: 0xffff
					qcsapi_wifi_vlan_config("wifi0", e_qcsapi_vlan_enable, 0xffff /* QVLAN_VID_ALL */, 0);
					qcsapi_wifi_vlan_config("wifi3", e_qcsapi_vlan_bind, 4002 /* vid */, 0);
				}else{
					qcsapi_wifi_vlan_config("wifi1", e_qcsapi_vlan_unbind, 4002 /* vid */, 0);
				}
			}
		}
		else{
			qcsapi_wifi_remove_bss(wl_vifname_qtn(unit, subunit));
		}
	}
	if(nvram_get_int("sw_mode") == SW_MODE_ROUTER){
		create_mbssid_vlan();
	}

//	rpc_show_config();
}