Home | History | Annotate | Download | only in functional
      1 #!/usr/bin/python3.4
      2 #
      3 #   Copyright 2017 - The Android Open Source Project
      4 #
      5 #   Licensed under the Apache License, Version 2.0 (the "License");
      6 #   you may not use this file except in compliance with the License.
      7 #   You may obtain a copy of the License at
      8 #
      9 #       http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 #   Unless required by applicable law or agreed to in writing, software
     12 #   distributed under the License is distributed on an "AS IS" BASIS,
     13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 #   See the License for the specific language governing permissions and
     15 #   limitations under the License.
     16 
     17 import time
     18 
     19 from acts import asserts
     20 from acts.test_decorators import test_tracker_info
     21 from acts.test_utils.net import connectivity_const as cconsts
     22 from acts.test_utils.wifi.aware import aware_const as aconsts
     23 from acts.test_utils.wifi.aware import aware_test_utils as autils
     24 from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest
     25 
     26 
     27 class DataPathTest(AwareBaseTest):
     28   """Set of tests for Wi-Fi Aware data-path."""
     29 
     30   # configuration parameters used by tests
     31   ENCR_TYPE_OPEN = 0
     32   ENCR_TYPE_PASSPHRASE = 1
     33   ENCR_TYPE_PMK = 2
     34 
     35   PASSPHRASE = "This is some random passphrase - very very secure!!"
     36   PASSPHRASE_MIN = "01234567"
     37   PASSPHRASE_MAX = "012345678901234567890123456789012345678901234567890123456789012"
     38   PMK = "ODU0YjE3YzdmNDJiNWI4NTQ2NDJjNDI3M2VkZTQyZGU="
     39   PASSPHRASE2 = "This is some random passphrase - very very secure - but diff!!"
     40   PMK2 = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="
     41 
     42   PING_MSG = "ping"
     43 
     44   # message re-transmit counter (increases reliability in open-environment)
     45   # Note: reliability of message transmission is tested elsewhere
     46   MSG_RETX_COUNT = 5  # hard-coded max value, internal API
     47 
     48   # number of second to 'reasonably' wait to make sure that devices synchronize
     49   # with each other - useful for OOB test cases, where the OOB discovery would
     50   # take some time
     51   WAIT_FOR_CLUSTER = 5
     52 
     53   def __init__(self, controllers):
     54     AwareBaseTest.__init__(self, controllers)
     55 
     56   def create_config(self, dtype):
     57     """Create a base configuration based on input parameters.
     58 
     59     Args:
     60       dtype: Publish or Subscribe discovery type
     61 
     62     Returns:
     63       Discovery configuration object.
     64     """
     65     config = {}
     66     config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = dtype
     67     config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceDataPath"
     68     return config
     69 
     70   def request_network(self, dut, ns):
     71     """Request a Wi-Fi Aware network.
     72 
     73     Args:
     74       dut: Device
     75       ns: Network specifier
     76     Returns: the request key
     77     """
     78     network_req = {"TransportType": 5, "NetworkSpecifier": ns}
     79     return dut.droid.connectivityRequestWifiAwareNetwork(network_req)
     80 
     81   def set_up_discovery(self, ptype, stype, get_peer_id):
     82     """Set up discovery sessions and wait for service discovery.
     83 
     84     Args:
     85       ptype: Publish discovery type
     86       stype: Subscribe discovery type
     87       get_peer_id: Send a message across to get the peer's id
     88     """
     89     p_dut = self.android_devices[0]
     90     p_dut.pretty_name = "Publisher"
     91     s_dut = self.android_devices[1]
     92     s_dut.pretty_name = "Subscriber"
     93 
     94     # Publisher+Subscriber: attach and wait for confirmation
     95     p_id = p_dut.droid.wifiAwareAttach()
     96     autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED)
     97     time.sleep(self.device_startup_offset)
     98     s_id = s_dut.droid.wifiAwareAttach()
     99     autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED)
    100 
    101     # Publisher: start publish and wait for confirmation
    102     p_disc_id = p_dut.droid.wifiAwarePublish(p_id, self.create_config(ptype))
    103     autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
    104 
    105     # Subscriber: start subscribe and wait for confirmation
    106     s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id, self.create_config(stype))
    107     autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
    108 
    109     # Subscriber: wait for service discovery
    110     discovery_event = autils.wait_for_event(
    111         s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
    112     peer_id_on_sub = discovery_event["data"][aconsts.SESSION_CB_KEY_PEER_ID]
    113 
    114     peer_id_on_pub = None
    115     if get_peer_id: # only need message to receive peer ID
    116       # Subscriber: send message to peer (Publisher - so it knows our address)
    117       s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub,
    118                                        self.get_next_msg_id(), self.PING_MSG,
    119                                        self.MSG_RETX_COUNT)
    120       autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT)
    121 
    122       # Publisher: wait for received message
    123       pub_rx_msg_event = autils.wait_for_event(
    124           p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED)
    125       peer_id_on_pub = pub_rx_msg_event["data"][aconsts.SESSION_CB_KEY_PEER_ID]
    126 
    127     return (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
    128             peer_id_on_pub)
    129 
    130   def run_ib_data_path_test(self,
    131       ptype,
    132       stype,
    133       encr_type,
    134       use_peer_id,
    135       passphrase_to_use=None):
    136     """Runs the in-band data-path tests.
    137 
    138     Args:
    139       ptype: Publish discovery type
    140       stype: Subscribe discovery type
    141       encr_type: Encryption type, one of ENCR_TYPE_*
    142       use_peer_id: On Responder (publisher): True to use peer ID, False to
    143                    accept any request
    144       passphrase_to_use: The passphrase to use if encr_type=ENCR_TYPE_PASSPHRASE
    145                          If None then use self.PASSPHRASE
    146     """
    147     (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
    148      peer_id_on_pub) = self.set_up_discovery(ptype, stype, use_peer_id)
    149 
    150     passphrase = None
    151     pmk = None
    152     if encr_type == self.ENCR_TYPE_PASSPHRASE:
    153       passphrase = self.PASSPHRASE if passphrase_to_use == None else passphrase_to_use
    154     elif encr_type == self.ENCR_TYPE_PMK:
    155       pmk = self.PMK
    156 
    157     # Publisher: request network
    158     p_req_key = self.request_network(
    159         p_dut,
    160         p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, peer_id_on_pub if
    161         use_peer_id else None, passphrase, pmk))
    162 
    163     # Subscriber: request network
    164     s_req_key = self.request_network(
    165         s_dut,
    166         s_dut.droid.wifiAwareCreateNetworkSpecifier(s_disc_id, peer_id_on_sub,
    167                                                     passphrase, pmk))
    168 
    169     # Publisher & Subscriber: wait for network formation
    170     p_net_event = autils.wait_for_event_with_keys(
    171         p_dut, cconsts.EVENT_NETWORK_CALLBACK,
    172         autils.EVENT_NDP_TIMEOUT,
    173         (cconsts.NETWORK_CB_KEY_EVENT,
    174          cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
    175         (cconsts.NETWORK_CB_KEY_ID, p_req_key))
    176     s_net_event = autils.wait_for_event_with_keys(
    177         s_dut, cconsts.EVENT_NETWORK_CALLBACK,
    178         autils.EVENT_NDP_TIMEOUT,
    179         (cconsts.NETWORK_CB_KEY_EVENT,
    180          cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
    181         (cconsts.NETWORK_CB_KEY_ID, s_req_key))
    182 
    183     p_aware_if = p_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
    184     s_aware_if = s_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
    185     self.log.info("Interface names: p=%s, s=%s", p_aware_if, s_aware_if)
    186 
    187     p_ipv6 = p_dut.droid.connectivityGetLinkLocalIpv6Address(p_aware_if).split(
    188         "%")[0]
    189     s_ipv6 = s_dut.droid.connectivityGetLinkLocalIpv6Address(s_aware_if).split(
    190         "%")[0]
    191     self.log.info("Interface addresses (IPv6): p=%s, s=%s", p_ipv6, s_ipv6)
    192 
    193     # TODO: possibly send messages back and forth, prefer to use netcat/nc
    194 
    195     # terminate sessions and wait for ON_LOST callbacks
    196     p_dut.droid.wifiAwareDestroy(p_id)
    197     s_dut.droid.wifiAwareDestroy(s_id)
    198 
    199     autils.wait_for_event_with_keys(
    200         p_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
    201         (cconsts.NETWORK_CB_KEY_EVENT,
    202          cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, p_req_key))
    203     autils.wait_for_event_with_keys(
    204         s_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
    205         (cconsts.NETWORK_CB_KEY_EVENT,
    206          cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, s_req_key))
    207 
    208     # clean-up
    209     p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
    210     s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
    211 
    212   def run_oob_data_path_test(self, encr_type, use_peer_id):
    213     """Runs the out-of-band data-path tests.
    214 
    215     Args:
    216       encr_type: Encryption type, one of ENCR_TYPE_*
    217       use_peer_id: On Responder: True to use peer ID, False to accept any
    218                    request
    219     """
    220     init_dut = self.android_devices[0]
    221     init_dut.pretty_name = "Initiator"
    222     resp_dut = self.android_devices[1]
    223     resp_dut.pretty_name = "Responder"
    224 
    225     # Initiator+Responder: attach and wait for confirmation & identity
    226     init_id = init_dut.droid.wifiAwareAttach(True)
    227     autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
    228     init_ident_event = autils.wait_for_event(
    229         init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
    230     init_mac = init_ident_event["data"]["mac"]
    231     time.sleep(self.device_startup_offset)
    232     resp_id = resp_dut.droid.wifiAwareAttach(True)
    233     autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
    234     resp_ident_event = autils.wait_for_event(
    235         resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
    236     resp_mac = resp_ident_event["data"]["mac"]
    237 
    238     # wait for for devices to synchronize with each other - there are no other
    239     # mechanisms to make sure this happens for OOB discovery (except retrying
    240     # to execute the data-path request)
    241     time.sleep(self.WAIT_FOR_CLUSTER)
    242 
    243     passphrase = None
    244     pmk = None
    245     if encr_type == self.ENCR_TYPE_PASSPHRASE:
    246       passphrase = self.PASSPHRASE
    247     elif encr_type == self.ENCR_TYPE_PMK:
    248       pmk = self.PMK
    249 
    250     # Responder: request network
    251     resp_req_key = self.request_network(
    252         resp_dut,
    253         resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
    254             resp_id, aconsts.DATA_PATH_RESPONDER, init_mac
    255             if use_peer_id else None, passphrase, pmk))
    256 
    257     # Initiator: request network
    258     init_req_key = self.request_network(
    259         init_dut,
    260         init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
    261             init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase, pmk))
    262 
    263     # Initiator & Responder: wait for network formation
    264     init_net_event = autils.wait_for_event_with_keys(
    265         init_dut, cconsts.EVENT_NETWORK_CALLBACK,
    266         autils.EVENT_NDP_TIMEOUT,
    267         (cconsts.NETWORK_CB_KEY_EVENT,
    268          cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
    269         (cconsts.NETWORK_CB_KEY_ID, init_req_key))
    270     resp_net_event = autils.wait_for_event_with_keys(
    271         resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
    272         autils.EVENT_NDP_TIMEOUT,
    273         (cconsts.NETWORK_CB_KEY_EVENT,
    274          cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
    275         (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
    276 
    277     init_aware_if = init_net_event["data"][
    278       cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
    279     resp_aware_if = resp_net_event["data"][
    280       cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
    281     self.log.info("Interface names: I=%s, R=%s", init_aware_if, resp_aware_if)
    282 
    283     init_ipv6 = init_dut.droid.connectivityGetLinkLocalIpv6Address(
    284         init_aware_if).split("%")[0]
    285     resp_ipv6 = resp_dut.droid.connectivityGetLinkLocalIpv6Address(
    286         resp_aware_if).split("%")[0]
    287     self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
    288                   resp_ipv6)
    289 
    290     # TODO: possibly send messages back and forth, prefer to use netcat/nc
    291 
    292     # terminate sessions and wait for ON_LOST callbacks
    293     init_dut.droid.wifiAwareDestroy(init_id)
    294     resp_dut.droid.wifiAwareDestroy(resp_id)
    295 
    296     autils.wait_for_event_with_keys(
    297         init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
    298         (cconsts.NETWORK_CB_KEY_EVENT,
    299          cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, init_req_key))
    300     autils.wait_for_event_with_keys(
    301         resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
    302         (cconsts.NETWORK_CB_KEY_EVENT,
    303          cconsts.NETWORK_CB_LOST), (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
    304 
    305     # clean-up
    306     resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
    307     init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
    308 
    309   def run_mismatched_ib_data_path_test(self, pub_mismatch, sub_mismatch):
    310     """Runs the negative in-band data-path tests: mismatched peer ID.
    311 
    312     Args:
    313       pub_mismatch: Mismatch the publisher's ID
    314       sub_mismatch: Mismatch the subscriber's ID
    315     """
    316     (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id,
    317      peer_id_on_sub, peer_id_on_pub) = self.set_up_discovery(
    318          aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE, True)
    319 
    320     if pub_mismatch:
    321       peer_id_on_pub = peer_id_on_pub -1
    322     if sub_mismatch:
    323       peer_id_on_sub = peer_id_on_sub - 1
    324 
    325     # Publisher: request network
    326     p_req_key = self.request_network(
    327         p_dut,
    328         p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, peer_id_on_pub,
    329                                                     None))
    330 
    331     # Subscriber: request network
    332     s_req_key = self.request_network(
    333         s_dut,
    334         s_dut.droid.wifiAwareCreateNetworkSpecifier(s_disc_id, peer_id_on_sub,
    335                                                     None))
    336 
    337     # Publisher & Subscriber: fail on network formation
    338     time.sleep(autils.EVENT_NDP_TIMEOUT)
    339     autils.fail_on_event_with_keys(p_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
    340                                    (cconsts.NETWORK_CB_KEY_ID, p_req_key))
    341     autils.fail_on_event_with_keys(s_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
    342                                    (cconsts.NETWORK_CB_KEY_ID, s_req_key))
    343 
    344     # clean-up
    345     p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
    346     s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
    347 
    348   def run_mismatched_oob_data_path_test(self,
    349       init_mismatch_mac=False,
    350       resp_mismatch_mac=False,
    351       init_encr_type=ENCR_TYPE_OPEN,
    352       resp_encr_type=ENCR_TYPE_OPEN):
    353     """Runs the negative out-of-band data-path tests: mismatched information
    354     between Responder and Initiator.
    355 
    356     Args:
    357       init_mismatch_mac: True to mismatch the Initiator MAC address
    358       resp_mismatch_mac: True to mismatch the Responder MAC address
    359       init_encr_type: Encryption type of Initiator - ENCR_TYPE_*
    360       resp_encr_type: Encryption type of Responder - ENCR_TYPE_*
    361     """
    362     init_dut = self.android_devices[0]
    363     init_dut.pretty_name = "Initiator"
    364     resp_dut = self.android_devices[1]
    365     resp_dut.pretty_name = "Responder"
    366 
    367     # Initiator+Responder: attach and wait for confirmation & identity
    368     init_id = init_dut.droid.wifiAwareAttach(True)
    369     autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
    370     init_ident_event = autils.wait_for_event(
    371         init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
    372     init_mac = init_ident_event["data"]["mac"]
    373     time.sleep(self.device_startup_offset)
    374     resp_id = resp_dut.droid.wifiAwareAttach(True)
    375     autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
    376     resp_ident_event = autils.wait_for_event(
    377         resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
    378     resp_mac = resp_ident_event["data"]["mac"]
    379 
    380     if init_mismatch_mac: # assumes legit ones don't start with "00"
    381       init_mac = "00" + init_mac[2:]
    382     if resp_mismatch_mac:
    383       resp_mac = "00" + resp_mac[2:]
    384 
    385     # wait for for devices to synchronize with each other - there are no other
    386     # mechanisms to make sure this happens for OOB discovery (except retrying
    387     # to execute the data-path request)
    388     time.sleep(self.WAIT_FOR_CLUSTER)
    389 
    390     # set up separate keys: even if types are the same we want a mismatch
    391     init_passphrase = None
    392     init_pmk = None
    393     if init_encr_type == self.ENCR_TYPE_PASSPHRASE:
    394       init_passphrase = self.PASSPHRASE
    395     elif init_encr_type == self.ENCR_TYPE_PMK:
    396       init_pmk = self.PMK
    397 
    398     resp_passphrase = None
    399     resp_pmk = None
    400     if resp_encr_type == self.ENCR_TYPE_PASSPHRASE:
    401       resp_passphrase = self.PASSPHRASE2
    402     elif resp_encr_type == self.ENCR_TYPE_PMK:
    403       resp_pmk = self.PMK2
    404 
    405     # Responder: request network
    406     resp_req_key = self.request_network(
    407         resp_dut,
    408         resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
    409             resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, resp_passphrase,
    410             resp_pmk))
    411 
    412     # Initiator: request network
    413     init_req_key = self.request_network(
    414         init_dut,
    415         init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
    416             init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, init_passphrase,
    417             init_pmk))
    418 
    419     # Initiator & Responder: fail on network formation
    420     time.sleep(autils.EVENT_NDP_TIMEOUT)
    421     autils.fail_on_event_with_keys(init_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
    422                                    (cconsts.NETWORK_CB_KEY_ID, init_req_key))
    423     autils.fail_on_event_with_keys(resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
    424                                    (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
    425 
    426     # clean-up
    427     resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
    428     init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
    429 
    430 
    431   #######################################
    432   # Positive In-Band (IB) tests key:
    433   #
    434   # names is: test_ib_<pub_type>_<sub_type>_<encr_type>_<peer_spec>
    435   # where:
    436   #
    437   # pub_type: Type of publish discovery session: unsolicited or solicited.
    438   # sub_type: Type of subscribe discovery session: passive or active.
    439   # encr_type: Encription type: open, passphrase
    440   # peer_spec: Peer specification method: any or specific
    441   #
    442   # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
    443   # peer using the Aware-provided peer handle (as opposed to a MAC address).
    444   #######################################
    445 
    446   @test_tracker_info(uuid="fa30bedc-d1de-4440-bf25-ec00d10555af")
    447   def test_ib_unsolicited_passive_open_specific(self):
    448     """Data-path: in-band, unsolicited/passive, open encryption, specific peer
    449 
    450     Verifies end-to-end discovery + data-path creation.
    451     """
    452     self.run_ib_data_path_test(
    453         ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
    454         stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
    455         encr_type=self.ENCR_TYPE_OPEN,
    456         use_peer_id=True)
    457 
    458   @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d")
    459   def test_ib_unsolicited_passive_open_any(self):
    460     """Data-path: in-band, unsolicited/passive, open encryption, any peer
    461 
    462     Verifies end-to-end discovery + data-path creation.
    463     """
    464     self.run_ib_data_path_test(
    465         ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
    466         stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
    467         encr_type=self.ENCR_TYPE_OPEN,
    468         use_peer_id=False)
    469 
    470   @test_tracker_info(uuid="93b2a23d-8579-448a-936c-7812929464cf")
    471   def test_ib_unsolicited_passive_passphrase_specific(self):
    472     """Data-path: in-band, unsolicited/passive, passphrase, specific peer
    473 
    474     Verifies end-to-end discovery + data-path creation.
    475     """
    476     self.run_ib_data_path_test(
    477         ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
    478         stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
    479         encr_type=self.ENCR_TYPE_PASSPHRASE,
    480         use_peer_id=True)
    481 
    482   @test_tracker_info(uuid="1736126f-a0ff-4712-acc4-f89b4eef5716")
    483   def test_ib_unsolicited_passive_passphrase_any(self):
    484     """Data-path: in-band, unsolicited/passive, passphrase, any peer
    485 
    486     Verifies end-to-end discovery + data-path creation.
    487     """
    488     self.run_ib_data_path_test(
    489         ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
    490         stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
    491         encr_type=self.ENCR_TYPE_PASSPHRASE,
    492         use_peer_id=False)
    493 
    494   @test_tracker_info(uuid="b9353d5b-3f77-46bf-bfd9-65d56a7c939a")
    495   def test_ib_unsolicited_passive_pmk_specific(self):
    496     """Data-path: in-band, unsolicited/passive, PMK, specific peer
    497 
    498     Verifies end-to-end discovery + data-path creation.
    499     """
    500     self.run_ib_data_path_test(
    501         ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
    502         stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
    503         encr_type=self.ENCR_TYPE_PMK,
    504         use_peer_id=True)
    505 
    506   @test_tracker_info(uuid="06f3b2ab-4a10-4398-83a4-6a23851b1662")
    507   def test_ib_unsolicited_passive_pmk_any(self):
    508     """Data-path: in-band, unsolicited/passive, PMK, any peer
    509 
    510     Verifies end-to-end discovery + data-path creation.
    511     """
    512     self.run_ib_data_path_test(
    513         ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
    514         stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
    515         encr_type=self.ENCR_TYPE_PMK,
    516         use_peer_id=False)
    517 
    518   @test_tracker_info(uuid="0ed7d8b3-a69e-46ba-aeb7-13e507ecf290")
    519   def test_ib_solicited_active_open_specific(self):
    520     """Data-path: in-band, solicited/active, open encryption, specific peer
    521 
    522     Verifies end-to-end discovery + data-path creation.
    523     """
    524     self.run_ib_data_path_test(
    525         ptype=aconsts.PUBLISH_TYPE_SOLICITED,
    526         stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
    527         encr_type=self.ENCR_TYPE_OPEN,
    528         use_peer_id=True)
    529 
    530   @test_tracker_info(uuid="c7ba6d28-5ef6-45d9-95d5-583ad6d981f3")
    531   def test_ib_solicited_active_open_any(self):
    532     """Data-path: in-band, solicited/active, open encryption, any peer
    533 
    534     Verifies end-to-end discovery + data-path creation.
    535     """
    536     self.run_ib_data_path_test(
    537         ptype=aconsts.PUBLISH_TYPE_SOLICITED,
    538         stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
    539         encr_type=self.ENCR_TYPE_OPEN,
    540         use_peer_id=False)
    541 
    542   @test_tracker_info(uuid="388cea99-0e2e-49ea-b00e-f3e56b6236e5")
    543   def test_ib_solicited_active_passphrase_specific(self):
    544     """Data-path: in-band, solicited/active, passphrase, specific peer
    545 
    546     Verifies end-to-end discovery + data-path creation.
    547     """
    548     self.run_ib_data_path_test(
    549         ptype=aconsts.PUBLISH_TYPE_SOLICITED,
    550         stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
    551         encr_type=self.ENCR_TYPE_PASSPHRASE,
    552         use_peer_id=True)
    553 
    554   @test_tracker_info(uuid="fcd3e28a-5eab-4169-8a0c-dc7204dcdc13")
    555   def test_ib_solicited_active_passphrase_any(self):
    556     """Data-path: in-band, solicited/active, passphrase, any peer
    557 
    558     Verifies end-to-end discovery + data-path creation.
    559     """
    560     self.run_ib_data_path_test(
    561         ptype=aconsts.PUBLISH_TYPE_SOLICITED,
    562         stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
    563         encr_type=self.ENCR_TYPE_PASSPHRASE,
    564         use_peer_id=False)
    565 
    566   @test_tracker_info(uuid="9d4eaad7-ba53-4a06-8ce0-e308daea3309")
    567   def test_ib_solicited_active_pmk_specific(self):
    568     """Data-path: in-band, solicited/active, PMK, specific peer
    569 
    570     Verifies end-to-end discovery + data-path creation.
    571     """
    572     self.run_ib_data_path_test(
    573         ptype=aconsts.PUBLISH_TYPE_SOLICITED,
    574         stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
    575         encr_type=self.ENCR_TYPE_PMK,
    576         use_peer_id=True)
    577 
    578   @test_tracker_info(uuid="129d850e-c312-4137-a67b-05ae95fe66cc")
    579   def test_ib_solicited_active_pmk_any(self):
    580     """Data-path: in-band, solicited/active, PMK, any peer
    581 
    582     Verifies end-to-end discovery + data-path creation.
    583     """
    584     self.run_ib_data_path_test(
    585         ptype=aconsts.PUBLISH_TYPE_SOLICITED,
    586         stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
    587         encr_type=self.ENCR_TYPE_PMK,
    588         use_peer_id=False)
    589 
    590   #######################################
    591   # Positive Out-of-Band (OOB) tests key:
    592   #
    593   # names is: test_oob_<encr_type>_<peer_spec>
    594   # where:
    595   #
    596   # encr_type: Encription type: open, passphrase
    597   # peer_spec: Peer specification method: any or specific
    598   #
    599   # Note: Out-of-Band means using a non-Wi-Fi Aware mechanism for discovery and
    600   # exchange of MAC addresses and then Wi-Fi Aware for data-path.
    601   #######################################
    602 
    603   @test_tracker_info(uuid="7db17d8c-1dce-4084-b695-215bbcfe7d41")
    604   def test_oob_open_specific(self):
    605     """Data-path: out-of-band, open encryption, specific peer
    606 
    607     Verifies end-to-end discovery + data-path creation.
    608     """
    609     self.run_oob_data_path_test(
    610         encr_type=self.ENCR_TYPE_OPEN,
    611         use_peer_id=True)
    612 
    613   @test_tracker_info(uuid="ad416d89-cb95-4a07-8d29-ee213117450b")
    614   def test_oob_open_any(self):
    615     """Data-path: out-of-band, open encryption, any peer
    616 
    617     Verifies end-to-end discovery + data-path creation.
    618     """
    619     self.run_oob_data_path_test(
    620         encr_type=self.ENCR_TYPE_OPEN,
    621         use_peer_id=False)
    622 
    623   @test_tracker_info(uuid="74937a3a-d524-43e2-8979-4449271cab52")
    624   def test_oob_passphrase_specific(self):
    625     """Data-path: out-of-band, passphrase, specific peer
    626 
    627     Verifies end-to-end discovery + data-path creation.
    628     """
    629     self.run_oob_data_path_test(
    630         encr_type=self.ENCR_TYPE_PASSPHRASE,
    631         use_peer_id=True)
    632 
    633   @test_tracker_info(uuid="afcbdc7e-d3a9-465b-b1da-ce2e42e3941e")
    634   def test_oob_passphrase_any(self):
    635     """Data-path: out-of-band, passphrase, any peer
    636 
    637     Verifies end-to-end discovery + data-path creation.
    638     """
    639     self.run_oob_data_path_test(
    640         encr_type=self.ENCR_TYPE_PASSPHRASE,
    641         use_peer_id=False)
    642 
    643   @test_tracker_info(uuid="0d095031-160a-4537-aab5-41b6ad5d55f8")
    644   def test_oob_pmk_specific(self):
    645     """Data-path: out-of-band, PMK, specific peer
    646 
    647     Verifies end-to-end discovery + data-path creation.
    648     """
    649     self.run_oob_data_path_test(
    650         encr_type=self.ENCR_TYPE_PMK,
    651         use_peer_id=True)
    652 
    653   @test_tracker_info(uuid="e45477bd-66cc-4eb7-88dd-4518c8aa2a74")
    654   def test_oob_pmk_any(self):
    655     """Data-path: out-of-band, PMK, any peer
    656 
    657     Verifies end-to-end discovery + data-path creation.
    658     """
    659     self.run_oob_data_path_test(
    660         encr_type=self.ENCR_TYPE_PMK,
    661         use_peer_id=False)
    662 
    663   ##############################################################
    664 
    665   @test_tracker_info(uuid="1c2c9805-dc1e-43b5-a1b8-315e8c9a4337")
    666   def test_passphrase_min(self):
    667     """Data-path: minimum passphrase length
    668 
    669     Use in-band, unsolicited/passive, any peer combination
    670     """
    671     self.run_ib_data_path_test(ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
    672                                stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
    673                                encr_type=self.ENCR_TYPE_PASSPHRASE,
    674                                use_peer_id=False,
    675                                passphrase_to_use=self.PASSPHRASE_MIN)
    676 
    677   @test_tracker_info(uuid="e696e2b9-87a9-4521-b337-61b9efaa2057")
    678   def test_passphrase_max(self):
    679     """Data-path: maximum passphrase length
    680 
    681     Use in-band, unsolicited/passive, any peer combination
    682     """
    683     self.run_ib_data_path_test(ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
    684                                stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
    685                                encr_type=self.ENCR_TYPE_PASSPHRASE,
    686                                use_peer_id=False,
    687                                passphrase_to_use=self.PASSPHRASE_MAX)
    688 
    689   @test_tracker_info(uuid="533cd44c-ff30-4283-ac28-f71fd7b4f02d")
    690   def test_negative_mismatch_publisher_peer_id(self):
    691     """Data-path: failure when publisher peer ID is mismatched"""
    692     self.run_mismatched_ib_data_path_test(pub_mismatch=True, sub_mismatch=False)
    693 
    694   @test_tracker_info(uuid="682f275e-722a-4f8b-85e7-0dcea9d25532")
    695   def test_negative_mismatch_subscriber_peer_id(self):
    696     """Data-path: failure when subscriber peer ID is mismatched"""
    697     self.run_mismatched_ib_data_path_test(pub_mismatch=False, sub_mismatch=True)
    698 
    699   @test_tracker_info(uuid="7fa82796-7fc9-4d9e-bbbb-84b751788943")
    700   def test_negative_mismatch_init_mac(self):
    701     """Data-path: failure when Initiator MAC address mismatch"""
    702     self.run_mismatched_oob_data_path_test(
    703         init_mismatch_mac=True,
    704         resp_mismatch_mac=False)
    705 
    706   @test_tracker_info(uuid="edeae959-4644-44f9-8d41-bdeb5216954e")
    707   def test_negative_mismatch_resp_mac(self):
    708     """Data-path: failure when Responder MAC address mismatch"""
    709     self.run_mismatched_oob_data_path_test(
    710         init_mismatch_mac=False,
    711         resp_mismatch_mac=True)
    712 
    713   @test_tracker_info(uuid="91f46949-c47f-49f9-a90f-6fae699613a7")
    714   def test_negative_mismatch_passphrase(self):
    715     """Data-path: failure when passphrases mismatch"""
    716     self.run_mismatched_oob_data_path_test(
    717         init_encr_type=self.ENCR_TYPE_PASSPHRASE,
    718         resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
    719 
    720   @test_tracker_info(uuid="01c49c2e-dc92-4a27-bb47-c4fc67617c23")
    721   def test_negative_mismatch_pmk(self):
    722     """Data-path: failure when PMK mismatch"""
    723     self.run_mismatched_oob_data_path_test(
    724         init_encr_type=self.ENCR_TYPE_PMK,
    725         resp_encr_type=self.ENCR_TYPE_PMK)
    726 
    727   @test_tracker_info(uuid="4d651797-5fbb-408e-a4b6-a6e1944136da")
    728   def test_negative_mismatch_open_passphrase(self):
    729     """Data-path: failure when initiator is open, and responder passphrase"""
    730     self.run_mismatched_oob_data_path_test(
    731         init_encr_type=self.ENCR_TYPE_OPEN,
    732         resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
    733 
    734   @test_tracker_info(uuid="1ae697f4-5987-4187-aeef-1e22d07d4a7c")
    735   def test_negative_mismatch_open_pmk(self):
    736     """Data-path: failure when initiator is open, and responder PMK"""
    737     self.run_mismatched_oob_data_path_test(
    738         init_encr_type=self.ENCR_TYPE_OPEN,
    739         resp_encr_type=self.ENCR_TYPE_PMK)
    740 
    741   @test_tracker_info(uuid="f027b1cc-0e7a-4075-b880-5e64b288afbd")
    742   def test_negative_mismatch_pmk_passphrase(self):
    743     """Data-path: failure when initiator is pmk, and responder passphrase"""
    744     self.run_mismatched_oob_data_path_test(
    745         init_encr_type=self.ENCR_TYPE_PMK,
    746         resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
    747 
    748   @test_tracker_info(uuid="0819bbd4-72ae-49c4-bd46-5448db2b0a06")
    749   def test_negative_mismatch_passphrase_open(self):
    750     """Data-path: failure when initiator is passphrase, and responder open"""
    751     self.run_mismatched_oob_data_path_test(
    752         init_encr_type=self.ENCR_TYPE_PASSPHRASE,
    753         resp_encr_type=self.ENCR_TYPE_OPEN)
    754 
    755   @test_tracker_info(uuid="7ef24f62-8e6b-4732-88a3-80a43584dda4")
    756   def test_negative_mismatch_pmk_open(self):
    757     """Data-path: failure when initiator is PMK, and responder open"""
    758     self.run_mismatched_oob_data_path_test(
    759         init_encr_type=self.ENCR_TYPE_PMK,
    760         resp_encr_type=self.ENCR_TYPE_OPEN)
    761 
    762   @test_tracker_info(uuid="7b9c9efc-1c06-465e-8a5e-d6a22ac1da97")
    763   def test_negative_mismatch_passphrase_pmk(self):
    764     """Data-path: failure when initiator is passphrase, and responder pmk"""
    765     self.run_mismatched_oob_data_path_test(
    766         init_encr_type=self.ENCR_TYPE_PASSPHRASE,
    767         resp_encr_type=self.ENCR_TYPE_OPEN)
    768 
    769 
    770   ##########################################################################
    771 
    772   def wait_for_request_responses(self, dut, req_keys, aware_ifs):
    773     """Wait for network request confirmation for all request keys.
    774 
    775     Args:
    776       dut: Device under test
    777       req_keys: (in) A list of the network requests
    778       aware_ifs: (out) A list into which to append the network interface
    779     """
    780     num_events = 0
    781     while num_events != len(req_keys):
    782       event = autils.wait_for_event(dut, cconsts.EVENT_NETWORK_CALLBACK)
    783       if (event["data"][cconsts.NETWORK_CB_KEY_EVENT] ==
    784           cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED):
    785         if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys:
    786           num_events = num_events + 1
    787           aware_ifs.append(event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
    788         else:
    789           self.log.info("Received an unexpected connectivity, the revoked "
    790                         "network request probably went through -- %s", event)
    791 
    792   @test_tracker_info(uuid="2e325e2b-d552-4890-b470-20b40284395d")
    793   def test_multiple_identical_networks(self):
    794     """Validate that creating multiple networks between 2 devices, each network
    795     with identical configuration is supported over a single NDP.
    796 
    797     Verify that the interface and IPv6 address is the same for all networks.
    798     """
    799     init_dut = self.android_devices[0]
    800     init_dut.pretty_name = "Initiator"
    801     resp_dut = self.android_devices[1]
    802     resp_dut.pretty_name = "Responder"
    803 
    804     N = 2 # first iteration (must be 2 to give us a chance to cancel the first)
    805     M = 5 # second iteration
    806 
    807     init_ids = []
    808     resp_ids = []
    809 
    810     # Initiator+Responder: attach and wait for confirmation & identity
    811     # create 10 sessions to be used in the different (but identical) NDPs
    812     for i in range(N + M):
    813       id, init_mac = autils.attach_with_identity(init_dut)
    814       init_ids.append(id)
    815       id, resp_mac = autils.attach_with_identity(resp_dut)
    816       resp_ids.append(id)
    817 
    818     # wait for for devices to synchronize with each other - there are no other
    819     # mechanisms to make sure this happens for OOB discovery (except retrying
    820     # to execute the data-path request)
    821     time.sleep(autils.WAIT_FOR_CLUSTER)
    822 
    823     resp_req_keys = []
    824     init_req_keys = []
    825     resp_aware_ifs = []
    826     init_aware_ifs = []
    827 
    828     # issue N quick requests for identical NDPs - without waiting for result
    829     # tests whether pre-setup multiple NDP procedure
    830     for i in range(N):
    831       # Responder: request network
    832       resp_req_keys.append(autils.request_network(
    833           resp_dut,
    834           resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
    835               resp_ids[i], aconsts.DATA_PATH_RESPONDER, init_mac, None)))
    836 
    837       # Initiator: request network
    838       init_req_keys.append(autils.request_network(
    839           init_dut,
    840           init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
    841               init_ids[i], aconsts.DATA_PATH_INITIATOR, resp_mac, None)))
    842 
    843     # remove the first request (hopefully before completed) testing that NDP
    844     # is still created
    845     resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_keys[0])
    846     resp_req_keys.remove(resp_req_keys[0])
    847     init_dut.droid.connectivityUnregisterNetworkCallback(init_req_keys[0])
    848     init_req_keys.remove(init_req_keys[0])
    849 
    850     # wait for network formation for all initial requests
    851     self.wait_for_request_responses(resp_dut, resp_req_keys, resp_aware_ifs)
    852     self.wait_for_request_responses(init_dut, init_req_keys, init_aware_ifs)
    853 
    854     # issue N more requests for the same NDPs - tests post-setup multiple NDP
    855     for i in range(M):
    856       # Responder: request network
    857       resp_req_keys.append(autils.request_network(
    858           resp_dut,
    859           resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
    860               resp_ids[N + i], aconsts.DATA_PATH_RESPONDER, init_mac, None)))
    861 
    862       # Initiator: request network
    863       init_req_keys.append(autils.request_network(
    864           init_dut,
    865           init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
    866               init_ids[N + i], aconsts.DATA_PATH_INITIATOR, resp_mac, None)))
    867 
    868     # wait for network formation for all subsequent requests
    869     self.wait_for_request_responses(resp_dut, resp_req_keys[N - 1:],
    870                                     resp_aware_ifs)
    871     self.wait_for_request_responses(init_dut, init_req_keys[N - 1:],
    872                                     init_aware_ifs)
    873 
    874     # determine whether all interfaces are identical (single NDP) - can't really
    875     # test the IPv6 address since it is not part of the callback event - it is
    876     # simply obtained from the system (so we'll always get the same for the same
    877     # interface)
    878     init_aware_ifs = list(set(init_aware_ifs))
    879     resp_aware_ifs = list(set(resp_aware_ifs))
    880 
    881     self.log.info("Interface names: I=%s, R=%s", init_aware_ifs, resp_aware_ifs)
    882     self.log.info("Initiator requests: %s", init_req_keys)
    883     self.log.info("Responder requests: %s", resp_req_keys)
    884 
    885     asserts.assert_equal(
    886         len(init_aware_ifs), 1, "Multiple initiator interfaces")
    887     asserts.assert_equal(
    888         len(resp_aware_ifs), 1, "Multiple responder interfaces")
    889 
    890     self.log.info("Interface IPv6 (using ifconfig): I=%s, R=%s",
    891                   autils.get_ipv6_addr(init_dut, init_aware_ifs[0]),
    892                   autils.get_ipv6_addr(resp_dut, resp_aware_ifs[0]))
    893 
    894     for i in range(init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]):
    895       if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
    896       init_ipv6 = autils.get_ipv6_addr(init_dut, if_name)
    897       resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name)
    898 
    899       asserts.assert_equal(
    900           init_ipv6 is None, if_name not in init_aware_ifs,
    901           "Initiator interface %s in unexpected state" % if_name)
    902       asserts.assert_equal(
    903           resp_ipv6 is None, if_name not in resp_aware_ifs,
    904           "Responder interface %s in unexpected state" % if_name)
    905 
    906     # release requests
    907     for resp_req_key in resp_req_keys:
    908       resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
    909     for init_req_key in init_req_keys:
    910       init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
    911 
    912   ########################################################################
    913 
    914   def run_multiple_ndi(self, sec_configs):
    915     """Validate that the device can create and use multiple NDIs.
    916 
    917     The security configuration can be:
    918     - None: open
    919     - String: passphrase
    920     - otherwise: PMK (byte array)
    921 
    922     Args:
    923       sec_configs: list of security configurations
    924     """
    925     init_dut = self.android_devices[0]
    926     init_dut.pretty_name = "Initiator"
    927     resp_dut = self.android_devices[1]
    928     resp_dut.pretty_name = "Responder"
    929 
    930     asserts.skip_if(init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]
    931                     < len(sec_configs) or
    932                     resp_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]
    933                     < len(sec_configs),
    934                     "Initiator or Responder do not support multiple NDIs")
    935 
    936     init_id, init_mac = autils.attach_with_identity(init_dut)
    937     resp_id, resp_mac = autils.attach_with_identity(resp_dut)
    938 
    939     # wait for for devices to synchronize with each other - there are no other
    940     # mechanisms to make sure this happens for OOB discovery (except retrying
    941     # to execute the data-path request)
    942     time.sleep(autils.WAIT_FOR_CLUSTER)
    943 
    944     resp_req_keys = []
    945     init_req_keys = []
    946     resp_aware_ifs = []
    947     init_aware_ifs = []
    948 
    949     for sec in sec_configs:
    950       # Responder: request network
    951       resp_req_key = autils.request_network(resp_dut,
    952                                             autils.get_network_specifier(
    953                                                 resp_dut, resp_id,
    954                                                 aconsts.DATA_PATH_RESPONDER,
    955                                                 init_mac, sec))
    956       resp_req_keys.append(resp_req_key)
    957 
    958       # Initiator: request network
    959       init_req_key = autils.request_network(init_dut,
    960                                             autils.get_network_specifier(
    961                                                 init_dut, init_id,
    962                                                 aconsts.DATA_PATH_INITIATOR,
    963                                                 resp_mac, sec))
    964       init_req_keys.append(init_req_key)
    965 
    966       # Wait for network
    967       init_net_event = autils.wait_for_event_with_keys(
    968           init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT,
    969           (cconsts.NETWORK_CB_KEY_EVENT,
    970            cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
    971           (cconsts.NETWORK_CB_KEY_ID, init_req_key))
    972       resp_net_event = autils.wait_for_event_with_keys(
    973           resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_TIMEOUT,
    974           (cconsts.NETWORK_CB_KEY_EVENT,
    975            cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
    976           (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
    977 
    978       resp_aware_ifs.append(
    979           resp_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
    980       init_aware_ifs.append(
    981           init_net_event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
    982 
    983     # check that we are using 2 NDIs
    984     init_aware_ifs = list(set(init_aware_ifs))
    985     resp_aware_ifs = list(set(resp_aware_ifs))
    986 
    987     self.log.info("Interface names: I=%s, R=%s", init_aware_ifs, resp_aware_ifs)
    988     self.log.info("Initiator requests: %s", init_req_keys)
    989     self.log.info("Responder requests: %s", resp_req_keys)
    990 
    991     asserts.assert_equal(
    992         len(init_aware_ifs), len(sec_configs), "Multiple initiator interfaces")
    993     asserts.assert_equal(
    994         len(resp_aware_ifs), len(sec_configs), "Multiple responder interfaces")
    995 
    996     for i in range(len(sec_configs)):
    997       if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
    998       init_ipv6 = autils.get_ipv6_addr(init_dut, if_name)
    999       resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name)
   1000 
   1001       asserts.assert_equal(
   1002           init_ipv6 is None, if_name not in init_aware_ifs,
   1003           "Initiator interface %s in unexpected state" % if_name)
   1004       asserts.assert_equal(
   1005           resp_ipv6 is None, if_name not in resp_aware_ifs,
   1006           "Responder interface %s in unexpected state" % if_name)
   1007 
   1008     # release requests
   1009     for resp_req_key in resp_req_keys:
   1010       resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
   1011     for init_req_key in init_req_keys:
   1012       init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
   1013 
   1014   @test_tracker_info(uuid="2d728163-11cc-46ba-a973-c8e1e71397fc")
   1015   def test_multiple_ndi_open_passphrase(self):
   1016     """Verify that can between 2 DUTs can create 2 NDPs with different security
   1017     configuration (one open, one using passphrase). The result should use two
   1018     different NDIs"""
   1019     self.run_multiple_ndi([None, self.PASSPHRASE])
   1020 
   1021   @test_tracker_info(uuid="5f2c32aa-20b2-41f0-8b1e-d0b68df73ada")
   1022   def test_multiple_ndi_open_pmk(self):
   1023     """Verify that can between 2 DUTs can create 2 NDPs with different security
   1024     configuration (one open, one using pmk). The result should use two
   1025     different NDIs"""
   1026     self.run_multiple_ndi([None, self.PMK])
   1027 
   1028   @test_tracker_info(uuid="34467659-bcfb-40cd-ba25-7e50560fca63")
   1029   def test_multiple_ndi_passphrase_pmk(self):
   1030     """Verify that can between 2 DUTs can create 2 NDPs with different security
   1031     configuration (one using passphrase, one using pmk). The result should use
   1032     two different NDIs"""
   1033     self.run_multiple_ndi([self.PASSPHRASE, self.PMK])
   1034 
   1035   @test_tracker_info(uuid="d9194ce6-45b6-41b1-9cc8-ada79968966d")
   1036   def test_multiple_ndi_passphrases(self):
   1037     """Verify that can between 2 DUTs can create 2 NDPs with different security
   1038     configuration (using different passphrases). The result should use two
   1039     different NDIs"""
   1040     self.run_multiple_ndi([self.PASSPHRASE, self.PASSPHRASE2])
   1041 
   1042   @test_tracker_info(uuid="879df795-62d2-40d4-a862-bd46d8f7e67f")
   1043   def test_multiple_ndi_pmks(self):
   1044     """Verify that can between 2 DUTs can create 2 NDPs with different security
   1045     configuration (using different PMKS). The result should use two different
   1046     NDIs"""
   1047     self.run_multiple_ndi([self.PMK, self.PMK2])
   1048