mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-04 04:38:02 +00:00 
			
		
		
		
	Changed use_wpa2 to use_security function WIP, tested with WPA2, not yet tested with WEP, WPA, WPA3
This commit is contained in:
		@@ -894,19 +894,18 @@ class StationProfile:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    # TODO: create use_wpa3()
 | 
					    # TODO: create use_wpa3()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def use_wpa2(self, on=False, ssid=None, passwd=None):
 | 
					    def use_security(self, security_type, ssid=None, passwd=None):
 | 
				
			||||||
 | 
					        types = {"WEP": "wep_enable", "WPA": "wpa_enable", "WPA2": "wpa2_enable", "WPA3": "use-wpa3"}
 | 
				
			||||||
        self.add_sta_data["ssid"] = ssid
 | 
					        self.add_sta_data["ssid"] = ssid
 | 
				
			||||||
        if on:
 | 
					        if security_type in types.keys():
 | 
				
			||||||
            if (ssid is None) or ("" == ssid):
 | 
					            if (ssid is None) or ("" == ssid):
 | 
				
			||||||
                raise ValueError("use_wpa2: WPA2 requires ssid")
 | 
					                raise ValueError("use_security: %s requires ssid" % security_type)
 | 
				
			||||||
            if (passwd is None) or ("" == passwd):
 | 
					            if (passwd is None) or ("" == passwd):
 | 
				
			||||||
                raise ValueError("use_wpa2: WPA2 requires passphrase or [BLANK]")
 | 
					                raise ValueError("use_security: %s requires passphrase or [BLANK]" % security_type)
 | 
				
			||||||
            self.set_command_param("add_sta", "ssid", ssid)
 | 
					            self.set_command_param("add_sta", "ssid", ssid)
 | 
				
			||||||
            self.set_command_param("add_sta", "key", passwd)
 | 
					            self.set_command_param("add_sta", "key", passwd)
 | 
				
			||||||
            self.set_command_flag("add_sta", "wpa2_enable", 1)
 | 
					            self.set_command_flag("add_sta", types[security_type], 1)
 | 
				
			||||||
            self.add_sta_data["key"] = passwd
 | 
					            self.add_sta_data["key"] = passwd
 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            self.set_command_flag("add_sta", "wpa2_enable", 0)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def set_command_param(self, command_name, param_name, param_value):
 | 
					    def set_command_param(self, command_name, param_name, param_value):
 | 
				
			||||||
        # we have to check what the param name is
 | 
					        # we have to check what the param name is
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user