本文整理汇总了Python中wpasupplicant.WpaSupplicant类的典型用法代码示例。如果您正苦于以下问题:Python WpaSupplicant类的具体用法?Python WpaSupplicant怎么用?Python WpaSupplicant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WpaSupplicant类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_cfg80211_tx_frame
def test_cfg80211_tx_frame(dev, apdev, params):
"""cfg80211 offchannel TX frame command"""
dev[0].p2p_start_go(freq='2412')
go = WpaSupplicant(dev[0].group_ifname)
frame = binascii.unhexlify("d0000000020000000100" + go.own_addr().replace(':', '') + "02000000010000000409506f9a090001dd5e506f9a0902020025080401001f0502006414060500585804510b0906000200000000000b1000585804510b0102030405060708090a0b0d1d000200000000000108000000000000000000101100084465766963652041110500585804510bdd190050f204104a0001101012000200011049000600372a000120")
ifindex = int(go.get_driver_status_field("ifindex"))
res = nl80211_frame(go, ifindex, frame, freq=2422, duration=500,
offchannel_tx_ok=True)
time.sleep(0.1)
# note: Uncommenting this seems to remove the incorrect channel issue
#nl80211_frame_wait_cancel(dev[0], ifindex, res[nl80211_attr['COOKIE']])
# note: this Action frame ends up getting sent incorrectly on 2422 MHz
nl80211_frame(go, ifindex, frame, freq=2412)
time.sleep(1.5)
# note: also the Deauthenticate frame sent by the GO going down ends up
# being transmitted incorrectly on 2422 MHz.
del go
out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
"wlan.fc.type_subtype == 13", ["radiotap.channel.freq"])
if out is not None:
freq = out.splitlines()
if len(freq) != 2:
raise Exception("Unexpected number of Action frames (%d)" % len(freq))
if freq[0] != "2422":
raise Exception("First Action frame on unexpected channel: %s MHz" % freq[0])
if freq[1] != "2412":
raise Exception("Second Action frame on unexpected channel: %s MHz" % freq[1])
开发者ID:greearb,项目名称:hostap-ct,代码行数:32,代码来源:test_cfg80211.py
示例2: test_ap_roam_with_reassoc_auth_timeout
def test_ap_roam_with_reassoc_auth_timeout(dev, apdev, params):
"""Roam using reassoc between two APs and authentication times out"""
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5",
drv_params="force_connect_cmd=1,force_bss_selection=1")
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
hapd0 = hostapd.add_ap(apdev[0], params)
bssid0 = hapd0.own_addr()
id = wpas.connect("test-wpa2-psk", psk="12345678", scan_freq="2412")
hwsim_utils.test_connectivity(wpas, hapd0)
hapd1 = hostapd.add_ap(apdev[1], params)
bssid1 = hapd1.own_addr()
wpas.scan_for_bss(bssid1, freq=2412)
if "OK" not in wpas.request("SET_NETWORK " + str(id) + " bssid " + bssid1):
raise Exception("SET_NETWORK failed")
if "OK" not in wpas.request("SET ignore_auth_resp 1"):
raise Exception("SET ignore_auth_resp failed")
if "OK" not in wpas.request("REASSOCIATE"):
raise Exception("REASSOCIATE failed")
logger.info("Wait ~10s for auth timeout...")
time.sleep(10)
ev = wpas.wait_event(["CTRL-EVENT-SCAN-STARTED"], 12)
if not ev:
raise Exception("CTRL-EVENT-SCAN-STARTED not seen")
b = get_blacklist(wpas)
if bssid0 in b:
raise Exception("Unexpected blacklist contents: " + str(b))
开发者ID:michael-dev,项目名称:hostapd,代码行数:33,代码来源:test_ap_roam.py
示例3: test_gas_fragment_with_comeback_delay_mcc
def test_gas_fragment_with_comeback_delay_mcc(dev, apdev):
"""GAS fragmentation and comeback delay with mac80211_hwsim MCC enabled"""
with HWSimRadio(n_channels=2) as (radio, iface):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add(iface)
gas_fragment_and_comeback(wpas, apdev[0], frag_limit=50,
comeback_delay=500)
开发者ID:AstroProfundis,项目名称:hostap,代码行数:7,代码来源:test_gas.py
示例4: cleanup_macsec
def cleanup_macsec():
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False)
wpas.interface_remove("veth0")
wpas.interface_remove("veth1")
del wpas
subprocess.call(["ip", "link", "del", "veth0"],
stderr=open('/dev/null', 'w'))
开发者ID:greearb,项目名称:hostap-ct,代码行数:7,代码来源:test_macsec.py
示例5: test_p2p_config_methods
def test_p2p_config_methods(dev):
"""P2P and WPS config method update"""
addr0 = dev[0].p2p_dev_addr()
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5")
addr1 = wpas.p2p_dev_addr()
if "OK" not in wpas.request("SET config_methods keypad virtual_push_button"):
raise Exception("Failed to set config_methods")
wpas.p2p_listen()
if not dev[0].discover_peer(addr1):
raise Exception("Device discovery timed out")
dev[0].p2p_stop_find()
peer = dev[0].get_peer(addr1)
if peer['config_methods'] != '0x180':
raise Exception("Unexpected peer config methods(1): " + peer['config_methods'])
dev[0].global_request("P2P_FLUSH")
if "OK" not in wpas.request("SET config_methods virtual_display"):
raise Exception("Failed to set config_methods")
if not dev[0].discover_peer(addr1):
raise Exception("Device discovery timed out")
dev[0].p2p_stop_find()
peer = dev[0].get_peer(addr1)
if peer['config_methods'] != '0x8':
raise Exception("Unexpected peer config methods(2): " + peer['config_methods'])
wpas.p2p_stop_find()
开发者ID:asriadi,项目名称:hostap,代码行数:30,代码来源:test_p2p_discovery.py
示例6: test_rfkill_p2p_discovery_p2p_dev
def test_rfkill_p2p_discovery_p2p_dev(dev, apdev):
"""rfkill block/unblock P2P Discovery with P2P Device"""
with HWSimRadio(use_p2p_device=True) as (radio, iface):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add(iface)
_test_rfkill_p2p_discovery(dev[0], wpas)
_test_rfkill_p2p_discovery(wpas, dev[1])
开发者ID:dimkr,项目名称:wpa_supplicant,代码行数:7,代码来源:test_rfkill.py
示例7: test_p2p_device_grpform2
def test_p2p_device_grpform2(dev, apdev):
"""P2P group formation with driver using cfg80211 P2P Device (reverse)"""
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5")
[i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_intent=15,
r_dev=dev[0], r_intent=0)
check_grpform_results(i_res, r_res)
remove_group(wpas, dev[0])
开发者ID:AlejandroAbad,项目名称:hostap,代码行数:8,代码来源:test_p2p_device.py
示例8: test_offchannel_tx_roc_grpform2
def test_offchannel_tx_roc_grpform2(dev, apdev):
"""P2P group formation(2) using cfg80211 remain-on-channel for offchannel TX"""
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5", drv_params="no_offchannel_tx=1")
[i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_freq=2412,
r_dev=dev[0], r_freq=2412)
check_grpform_results(i_res, r_res)
remove_group(dev[0], wpas)
开发者ID:Hansenq,项目名称:wifi-goes-to-town,代码行数:9,代码来源:test_offchannel_tx.py
示例9: test_p2p_device_grpform
def test_p2p_device_grpform(dev, apdev):
"""P2P group formation with driver using cfg80211 P2P Device"""
with HWSimRadio(use_p2p_device=True) as (radio, iface):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add(iface)
[i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
r_dev=wpas, r_intent=0)
check_grpform_results(i_res, r_res)
remove_group(dev[0], wpas)
开发者ID:aelarabawy,项目名称:hostap,代码行数:9,代码来源:test_p2p_device.py
示例10: cleanup_macsec_br
def cleanup_macsec_br(count):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5', monitor=False)
for i in range(count):
wpas.interface_remove("veth%d" % i)
subprocess.call(["ip", "link", "del", "veth%d" % i],
stderr=open('/dev/null', 'w'))
del wpas
subprocess.call(["ip", "link", "set", "brveth", "down"])
subprocess.call(["brctl", "delbr", "brveth"])
开发者ID:greearb,项目名称:hostap-ct,代码行数:9,代码来源:test_macsec.py
示例11: test_owe_unsupported_group_connect_cmd
def test_owe_unsupported_group_connect_cmd(dev, apdev):
"""Opportunistic Wireless Encryption and unsupported group using cfg80211 connect command"""
try:
wpas = None
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5", drv_params="force_connect_cmd=1")
run_owe_unsupported_group([wpas], apdev)
finally:
if wpas:
wpas.request("VENDOR_ELEM_REMOVE 13 *")
开发者ID:michael-dev,项目名称:hostapd,代码行数:10,代码来源:test_owe.py
示例12: test_p2p_device_persistent_group2_no_group_iface
def test_p2p_device_persistent_group2_no_group_iface(dev):
"""P2P persistent group formation and re-invocation (reverse) with cfg80211 P2P Device (no separate group interface)"""
with HWSimRadio(use_p2p_device=True) as (radio, iface):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add(iface)
wpas.global_request("SET p2p_no_group_iface 1")
form(wpas, dev[0])
invite_from_cli(wpas, dev[0])
invite_from_go(wpas, dev[0])
开发者ID:zarelaky,项目名称:WN752N-v2-hostapd,代码行数:10,代码来源:test_p2p_device.py
示例13: test_ap_open_sta_enable_disable
def test_ap_open_sta_enable_disable(dev, apdev):
"""AP with open mode and wpa_supplicant ENABLE/DISABLE_NETWORK"""
hapd = hostapd.add_ap(apdev[0], { "ssid": "open" })
bssid = apdev[0]['bssid']
sta_enable_disable(dev[0], bssid)
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5", drv_params="force_connect_cmd=1")
sta_enable_disable(wpas, bssid)
开发者ID:cococorp,项目名称:hostap-upstream,代码行数:10,代码来源:test_ap_open.py
示例14: test_p2p_device_persistent_group
def test_p2p_device_persistent_group(dev):
"""P2P persistent group formation and re-invocation with cfg80211 P2P Device"""
with HWSimRadio(use_p2p_device=True) as (radio, iface):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add(iface)
wpas.global_request("SET p2p_no_group_iface 0")
form(dev[0], wpas)
invite_from_cli(dev[0], wpas)
invite_from_go(dev[0], wpas)
开发者ID:zarelaky,项目名称:WN752N-v2-hostapd,代码行数:10,代码来源:test_p2p_device.py
示例15: test_sta_dynamic
def test_sta_dynamic(dev, apdev):
"""Dynamically added wpa_supplicant interface"""
params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")
hostapd.add_ap(apdev[0]['ifname'], params)
logger.info("Create a dynamic wpa_supplicant interface and connect")
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add("wlan5")
wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412")
开发者ID:jku,项目名称:hostap,代码行数:10,代码来源:test_sta_dynamic.py
示例16: get_wext_interface
def get_wext_interface():
if not os.path.exists("/proc/net/wireless"):
raise HwsimSkip("WEXT support not included in the kernel")
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
try:
wpas.interface_add("wlan5", driver="wext")
except Exception, e:
wpas.close_ctrl()
raise HwsimSkip("WEXT driver support not included in wpa_supplicant")
开发者ID:cococorp,项目名称:hostap-upstream,代码行数:10,代码来源:test_wext.py
示例17: test_p2p_device_nfc_invite
def test_p2p_device_nfc_invite(dev, apdev):
"""P2P NFC invitiation with driver using cfg80211 P2P Device"""
with HWSimRadio(use_p2p_device=True) as (radio, iface):
wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
wpas.interface_add(iface)
set_ip_addr_info(dev[0])
logger.info("Start autonomous GO")
dev[0].p2p_start_go()
logger.info("Write NFC Tag on the P2P Client")
res = wpas.global_request("P2P_LISTEN")
if "FAIL" in res:
raise Exception("Failed to start Listen mode")
pw = wpas.global_request("WPS_NFC_TOKEN NDEF").rstrip()
if "FAIL" in pw:
raise Exception("Failed to generate password token")
res = wpas.global_request("P2P_SET nfc_tag 1").rstrip()
if "FAIL" in res:
raise Exception("Failed to enable NFC Tag for P2P static handover")
sel = wpas.global_request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip()
if "FAIL" in sel:
raise Exception("Failed to generate NFC connection handover select")
logger.info("Read NFC Tag on the GO to trigger invitation")
res = dev[0].request("WPS_NFC_TAG_READ " + sel)
if "FAIL" in res:
raise Exception("Failed to provide NFC tag contents to wpa_supplicant")
ev = wpas.wait_global_event(grpform_events, timeout=20)
if ev is None:
raise Exception("Joining the group timed out")
res = wpas.group_form_result(ev)
hwsim_utils.test_connectivity_p2p(dev[0], wpas)
check_ip_addr(res)
开发者ID:Hansenq,项目名称:wifi-goes-to-town,代码行数:35,代码来源:test_p2p_device.py
示例18: test_p2p_go_move_scm_multi
def test_p2p_go_move_scm_multi(dev, apdev):
"""P2P GO move due to SCM operation preference multiple times"""
with HWSimRadio(n_channels=2) as (radio, iface):
wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
wpas.interface_add(iface)
if wpas.get_mcc() < 2:
raise Exception("New radio does not support MCC")
ndev = [wpas, dev[1]]
_test_p2p_go_move_scm_multi(ndev, apdev)
开发者ID:msolters,项目名称:rpi-softap,代码行数:11,代码来源:test_p2p_channel.py
示例19: test_p2p_go_move_scm_peer_does_not_support
def test_p2p_go_move_scm_peer_does_not_support(dev, apdev):
"""No P2P GO move due to SCM operation (peer does not supports)"""
with HWSimRadio(n_channels=2) as (radio, iface):
wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
wpas.interface_add(iface)
if wpas.get_mcc() < 2:
raise Exception("New radio does not support MCC")
ndev = [wpas, dev[1]]
_test_p2p_go_move_scm_peer_does_not_support(ndev, apdev)
开发者ID:msolters,项目名称:rpi-softap,代码行数:11,代码来源:test_p2p_channel.py
示例20: test_p2p_go_move_active
def test_p2p_go_move_active(dev, apdev):
"""P2P GO stays in freq although SCM is possible"""
with HWSimRadio(n_channels=2) as (radio, iface):
wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
wpas.interface_add(iface)
if wpas.get_mcc() < 2:
raise Exception("New radio does not support MCC")
ndev = [wpas, dev[1]]
_test_p2p_go_move_active(ndev, apdev)
开发者ID:msolters,项目名称:rpi-softap,代码行数:11,代码来源:test_p2p_channel.py
注:本文中的wpasupplicant.WpaSupplicant类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论