def test_ap_vendor_elements(dev, apdev):
    'WPA2-PSK AP with vendor elements added'
    bssid = apdev[0]['bssid']
    ssid = 'test-wpa2-psk'
    passphrase = 'qwertyuiop'
    params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
    params['vendor_elements'] = 'dd0411223301'
    params['assocresp_elements'] = 'dd0411223302'
    hapd = hostapd.add_ap(apdev[0], params)
    dev[0].connect(ssid, psk=passphrase, scan_freq='2412')
    bss = dev[0].get_bss(bssid)
    if ('dd0411223301' not in bss['ie']):
        raise Exception('Vendor element not shown in scan results')
    hapd.set('vendor_elements', 'dd051122330203dd0400137400dd04001374ff')
    if ('OK' not in hapd.request('UPDATE_BEACON')):
        raise Exception('UPDATE_BEACON failed')
    dev[1].scan_for_bss(apdev[0]['bssid'], freq='2412')
    bss = dev[1].get_bss(bssid)
    if ('dd0411223301' in bss['ie']):
        raise Exception('Old vendor element still in scan results')
    if ('dd051122330203' not in bss['ie']):
        raise Exception('New vendor element not shown in scan results')
WPA2-PSK AP with vendor elements added
def test_ap_vendor_elements(dev, apdev):
    
    bssid = apdev[0]['bssid']
    ssid = 'test-wpa2-psk'
    passphrase = 'qwertyuiop'
    params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
    params['vendor_elements'] = 'dd0411223301'
    params['assocresp_elements'] = 'dd0411223302'
    hapd = hostapd.add_ap(apdev[0], params)
    dev[0].connect(ssid, psk=passphrase, scan_freq='2412')
    bss = dev[0].get_bss(bssid)
    if ('dd0411223301' not in bss['ie']):
        raise Exception('Vendor element not shown in scan results')
    hapd.set('vendor_elements', 'dd051122330203dd0400137400dd04001374ff')
    if ('OK' not in hapd.request('UPDATE_BEACON')):
        raise Exception('UPDATE_BEACON failed')
    dev[1].scan_for_bss(apdev[0]['bssid'], freq='2412')
    bss = dev[1].get_bss(bssid)
    if ('dd0411223301' in bss['ie']):
        raise Exception('Old vendor element still in scan results')
    if ('dd051122330203' not in bss['ie']):
        raise Exception('New vendor element not shown in scan results')