def my_start_function(self): found = False for card in pyw.phylist(): if card[1] == self.device: found = True self.phyIndex = card[0] self.phyName = card[1] if not found: self.log.error("Device {} not found".format(self.device)) raise exceptions.UniFlexException(msg='Device not found') else: self.log.info("Device {} found, index: {}".format( self.phyName, self.phyIndex)) cmd = "rfkill unblock wifi" self.run_command(cmd)
def my_start_function(self): found = False # This is only a basic example that show how it is possible to look # for a PHY with the desired capabilities (in this case VHT support on # the 5GHz band). for phy in pyw.phylist(): phy_info = pyw.phyinfo(pyw.Card(phy[0], None, 0)) if bool(phy_info['bands']['5GHz']['VHT']): found = True self.phyIndex = phy[0] self.phyName = phy[1] print(phy_info) if not found: self.log.error("Device {} not found".format(self.device)) raise exceptions.UniFlexException(msg='Device not found') else: self.log.info("Device {} found, index: {}".format( self.phyName, self.phyIndex)) cmd = "rfkill unblock wifi" self.run_command(cmd)
def get_phy_list(self): return pyw.phylist()
def test_phylist(self): self.assertTrue((pri["phy"], "phy{0}".format(pri["phy"])) in pyw.phylist())
def start_adhoc(self, driver, iface, essid, freq, txpower, rate, ip_addr, rts='off', mac_address="aa:bb:cc:dd:ee:ff", skip_reload=False): # search for a wifi device that does not have VHT intcap = "VHT" wifi_int = pyw.winterfaces() for wifi_int_name in wifi_int: del_cmd = "sudo iw dev " + wifi_int_name + " del" [rcode, sout, serr] = run_command(del_cmd) self.log.debug("Deleting interface {}".format(wifi_int_name)) self.band = "2GHz" if int(freq) > 3000: self.band = "5GHz" # Look for a candidate PHY (currently based on frequency and # capabilities (HT or VHT) support phys = pyw.phylist() selected_phy = None for phy in phys: phy_info = pyw.phyinfo(pyw.Card(phy[0], None, 0)) if phy_info['bands'].get(self.band) and phy_info.get('modes'): if not bool(phy_info['bands'][self.band][intcap]): if 'ibss' in phy_info['modes']: selected_phy = phy break # Add and configure mesh and monitor interfaces if selected_phy is not None: # Create ibss point interface ibss_cmd = 'sudo iw phy ' + selected_phy[1] + \ ' interface add ' + iface + \ ' type ibss' [rcode, sout, serr] = run_command(ibss_cmd) self.log.debug("Creating interface {} on phy {}".format( iface, selected_phy[1])) self.interface = iface # Set ibss interface IP address ibss_ip_cmd = 'sudo ip addr add ' + ip_addr + \ ' dev ' + iface [rcode, sout, serr] = run_command(ibss_ip_cmd) # TODO: search for UPI self.log.debug("Setting IP addr {} to interface {}".format( ip_addr, iface)) # Add monitor interface ibss_mon_cmd = 'sudo iw dev ' + iface + ' interface add ' + \ 'mon0 type monitor' # TODO: search for UPI [rcode, sout, serr] = run_command(ibss_mon_cmd) self.log.debug( "Creating monitor interface mon0 for {}".format(iface)) # Bring interfaces up ibss_up_cmd = 'sudo ip link set dev ' + iface + ' up' [rcode, sout, serr] = run_command(ibss_up_cmd) self.log.debug("Bringing interface {} up".format(iface)) ibss_mon_up_cmd = 'sudo ip link set dev mon0 up' [rcode, sout, serr] = run_command(ibss_mon_up_cmd) self.log.debug("Bringing interface mon0 up") ibss_join_cmd = 'sudo iw dev ' + iface + ' ibss join ' + \ essid + ' ' + str(freq) + \ ' fixed-freq ' + mac_address + ' beacon-interval ' \ + "100" [rcode, sout, serr] = run_command(ibss_join_cmd) self.log.debug("Joining ad-hoc network {}, frequency {} GHz, " "cell {} with interface {}".format( essid, freq, mac_address, iface)) self.set_modulation_rate(rate) self.set_tx_power(txpower)
def test_phylist(self): self.assertTrue((pri['phy'],'phy{0}'.format(pri['phy'])) in pyw.phylist())
def test_phylist(self): self.assertTrue((pri['phy'], 'phy{0}'.format(pri['phy'])) in pyw.phylist())
parser.add_argument('--bint', dest='bint', type=int, default=100, help='Beacon interval in TUs', required=False) args = parser.parse_args() # Delete all Wi-Fi interfaces wifi_int = pyw.winterfaces() for wifi_int_name in wifi_int: pyw.devdel(pyw.getcard(wifi_int_name)) band = "2GHz" if args.chan > 14: band = "5GHz" # Look for a candidate PHY (currently based on frequency and capabilities # (HT or VHT) support phys = pyw.phylist() selected_phy = None for phy in phys: phy_info = pyw.phyinfo(pyw.Card(phy[0], None, 0)) if phy_info['bands'].get(band) and phy_info.get('modes'): if bool(phy_info['bands'][band][args.intcap]): if 'ibss' in phy_info['modes']: selected_phy = phy # print(selected_phy) break # Add and configure mesh and monitor interfaces if selected_phy is not None: phy_info = pyw.phyinfo(pyw.Card(selected_phy[0], None, 0)) # print(phy_info)