示例#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;
}
示例#2
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;
}
示例#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;
}
示例#4
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;
}
示例#5
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;
}
示例#6
0
int 
qtn_monitor_main(int argc, char *argv[])
{
	FILE *fp;
	sigset_t sigs_to_catch;
	int ret, retval = 0;
	time_t start_time = uptime();

	/* write pid */
	if ((fp = fopen("/var/run/qtn_monitor.pid", "w")) != NULL)
	{
		fprintf(fp, "%d", getpid());
		fclose(fp);
	}

	/* set the signal handler */
	sigemptyset(&sigs_to_catch);
	sigaddset(&sigs_to_catch, SIGTERM);
	sigprocmask(SIG_UNBLOCK, &sigs_to_catch, NULL);

	signal(SIGTERM, qtn_monitor_exit);

QTN_RESET:
	ret = rpc_qcsapi_init(1);
	if (ret < 0) {
		dbG("rpc_qcsapi_init error, return: %d\n", ret);
		retval = -1;
		goto ERROR;
	}
#if 0	/* replaced by STATELESS, send configuration from brcm to qtn */
	else if (nvram_get_int("qtn_restore_defaults"))
	{
		nvram_unset("qtn_restore_defaults");
		rpc_qcsapi_restore_default_config(0);
		dbG("Restaring Qcsapi init...\n");
		sleep(15);
		goto QTN_RESET;
	}
#endif

#if 0
	if(nvram_get_int("sw_mode") == SW_MODE_AP &&
		nvram_get_int("wlc_psta") == 1 &&
		nvram_get_int("wlc_band") == 1){
		dbG("[sw_mode] start QTN PSTA mode\n");
		start_psta_qtn();
	}
#endif

	ret = qcsapi_init();
	if (ret < 0)
	{
		dbG("Qcsapi qcsapi_init error, return: %d\n", ret);
		retval = -1;
		goto ERROR;
	}
	else
		dbG("Qcsapi qcsapi init takes %ld seconds\n", uptime() - start_time);

	dbG("defer lanport_ctrl(1)\n");
	lanport_ctrl(1);
	eval("ifconfig", "br0:1", "down");
#if defined(RTCONFIG_JFFS2ND_BACKUP)
	check_2nd_jffs();
#endif
	nvram_set("qtn_ready", "1");

	if(nvram_get_int("AllLED") == 0) setAllLedOff();

	// dbG("[QTN] update router_command.sh from brcm to qtn\n");
	// qcsapi_wifi_run_script("set_test_mode", "update_router_command");

#if 1	/* STATELESS */
	if(nvram_get_int("sw_mode") == SW_MODE_AP &&
		nvram_get_int("wlc_psta") == 1 &&
		nvram_get_int("wlc_band") == 1){
		dbG("[sw_mode] skip start_psta_qtn, QTN will run scripts automatically\n");
		// start_psta_qtn();
	}else{
		dbG("[***] rpc_parse_nvram_from_httpd\n");
		rpc_parse_nvram_from_httpd(1,-1);	/* wifi0 */
		rpc_parse_nvram_from_httpd(1,1);	/* wifi1 */
		rpc_parse_nvram_from_httpd(1,2);	/* wifi2 */
		rpc_parse_nvram_from_httpd(1,3);	/* wifi3 */
		dbG("[sw_mode] skip start_ap_qtn, QTN will run scripts automatically\n");
		// start_ap_qtn();
		qcsapi_mac_addr wl_mac_addr;
		ret = rpc_qcsapi_interface_get_mac_addr(WIFINAME, &wl_mac_addr);
		if (ret < 0)
			dbG("rpc_qcsapi_interface_get_mac_addr, return: %d\n", ret);
		else
		{
			nvram_set("1:macaddr", wl_ether_etoa((struct ether_addr *) &wl_mac_addr));
			nvram_set("wl1_hwaddr", wl_ether_etoa((struct ether_addr *) &wl_mac_addr));
		}

		rpc_update_wdslist();

		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);
		}

		rpc_set_radio(1, 0, nvram_get_int("wl1_radio"));

	}
#endif

	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();
			}
		}
	}
	if(nvram_get_int("sw_mode") == SW_MODE_AP &&
		nvram_get_int("wlc_psta") == 1 &&
		nvram_get_int("wlc_band") == 0){
		ret = qcsapi_wifi_reload_in_mode(WIFINAME, qcsapi_station);
		if (ret < 0)
			dbG("qtn reload_in_mode STA fail\n");
	}
	if(nvram_get_int("QTNTELNETSRV") == 1 && nvram_get_int("sw_mode") == SW_MODE_ROUTER){
		dbG("[QTNT] enable telnet server\n");
		qcsapi_wifi_run_script("router_command.sh", "enable_telnet_srv 1");
	}

	dbG("[dbg] qtn_monitor startup\n");
ERROR:
	remove("/var/run/qtn_monitor.pid");

	if (nvram_get_int("led_disable") == 1) {
		setAllLedOff_qtn();
//		qcsapi_wifi_run_script("router_command.sh", "wifi_led_off");
//		qcsapi_led_set(1, 0);
	}

	return retval;
}
示例#7
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();
}
示例#8
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();
}
示例#9
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;
}