blob: 3f927c18adf87d5fbed6749e738916798fedcedd [file] [log] [blame]
Etan Cohenfc5f3732017-06-02 17:31:52 -07001#!/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
17import time
18
Etan Cohen38c3d5a2017-07-28 10:02:48 -070019from acts import asserts
Etan Cohenf02703c2017-08-24 11:11:44 -070020from acts.test_decorators import test_tracker_info
Etan Cohenfc5f3732017-06-02 17:31:52 -070021from acts.test_utils.net import connectivity_const as cconsts
Etan Cohen75f549b2018-04-25 08:07:58 -070022from acts.test_utils.wifi import wifi_test_utils as wutils
Etan Cohenfc5f3732017-06-02 17:31:52 -070023from acts.test_utils.wifi.aware import aware_const as aconsts
24from acts.test_utils.wifi.aware import aware_test_utils as autils
25from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest
26
27
28class DataPathTest(AwareBaseTest):
Jaineel7e67a3f2019-08-28 15:58:49 -070029 """Set of tests for Wi-Fi Aware data-path."""
Etan Cohenfc5f3732017-06-02 17:31:52 -070030
Jaineel7e67a3f2019-08-28 15:58:49 -070031 # configuration parameters used by tests
32 ENCR_TYPE_OPEN = 0
33 ENCR_TYPE_PASSPHRASE = 1
34 ENCR_TYPE_PMK = 2
Etan Cohenfc5f3732017-06-02 17:31:52 -070035
Jaineel7e67a3f2019-08-28 15:58:49 -070036 PASSPHRASE = "This is some random passphrase - very very secure!!"
37 PASSPHRASE_MIN = "01234567"
38 PASSPHRASE_MAX = "012345678901234567890123456789012345678901234567890123456789012"
39 PMK = "ODU0YjE3YzdmNDJiNWI4NTQ2NDJjNDI3M2VkZTQyZGU="
40 PASSPHRASE2 = "This is some random passphrase - very very secure - but diff!!"
41 PMK2 = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="
Etan Cohenfc5f3732017-06-02 17:31:52 -070042
Jaineel7e67a3f2019-08-28 15:58:49 -070043 PING_MSG = "ping"
Etan Cohenfc5f3732017-06-02 17:31:52 -070044
Jaineel7e67a3f2019-08-28 15:58:49 -070045 # message re-transmit counter (increases reliability in open-environment)
46 # Note: reliability of message transmission is tested elsewhere
47 MSG_RETX_COUNT = 5 # hard-coded max value, internal API
Etan Cohenfc5f3732017-06-02 17:31:52 -070048
Jaineel7e67a3f2019-08-28 15:58:49 -070049 # number of second to 'reasonably' wait to make sure that devices synchronize
50 # with each other - useful for OOB test cases, where the OOB discovery would
51 # take some time
52 WAIT_FOR_CLUSTER = 5
Etan Cohenba8a53f2017-06-05 12:55:02 -070053
Jaineel7e67a3f2019-08-28 15:58:49 -070054 def __init__(self, controllers):
55 AwareBaseTest.__init__(self, controllers)
Etan Cohenfc5f3732017-06-02 17:31:52 -070056
Jaineel7e67a3f2019-08-28 15:58:49 -070057 def create_config(self, dtype):
58 """Create a base configuration based on input parameters.
Etan Cohenfc5f3732017-06-02 17:31:52 -070059
60 Args:
61 dtype: Publish or Subscribe discovery type
62
63 Returns:
64 Discovery configuration object.
65 """
Jaineel7e67a3f2019-08-28 15:58:49 -070066 config = {}
67 config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = dtype
68 config[
69 aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceDataPath"
70 return config
Etan Cohenfc5f3732017-06-02 17:31:52 -070071
Jaineel7e67a3f2019-08-28 15:58:49 -070072 def request_network(self, dut, ns):
73 """Request a Wi-Fi Aware network.
Etan Cohenfc5f3732017-06-02 17:31:52 -070074
75 Args:
76 dut: Device
77 ns: Network specifier
78 Returns: the request key
79 """
Jaineel7e67a3f2019-08-28 15:58:49 -070080 network_req = {"TransportType": 5, "NetworkSpecifier": ns}
81 return dut.droid.connectivityRequestWifiAwareNetwork(network_req)
Etan Cohenfc5f3732017-06-02 17:31:52 -070082
Jaineel7e67a3f2019-08-28 15:58:49 -070083 def set_up_discovery(self,
84 ptype,
85 stype,
86 get_peer_id,
87 pub_on_both=False,
88 pub_on_both_same=True):
89 """Set up discovery sessions and wait for service discovery.
Etan Cohenfc5f3732017-06-02 17:31:52 -070090
91 Args:
92 ptype: Publish discovery type
93 stype: Subscribe discovery type
Etan Cohenbc80da12017-06-06 09:26:02 -070094 get_peer_id: Send a message across to get the peer's id
Etan Cohen204df172017-11-09 12:05:36 -080095 pub_on_both: If True then set up a publisher on both devices. The second
96 publisher isn't used (existing to test use-case).
97 pub_on_both_same: If True then the second publish uses an identical
98 service name, otherwise a different service name.
Etan Cohenfc5f3732017-06-02 17:31:52 -070099 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700100 p_dut = self.android_devices[0]
101 p_dut.pretty_name = "Publisher"
102 s_dut = self.android_devices[1]
103 s_dut.pretty_name = "Subscriber"
Etan Cohenfc5f3732017-06-02 17:31:52 -0700104
Jaineel7e67a3f2019-08-28 15:58:49 -0700105 # Publisher+Subscriber: attach and wait for confirmation
106 p_id = p_dut.droid.wifiAwareAttach()
107 autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED)
108 time.sleep(self.device_startup_offset)
109 s_id = s_dut.droid.wifiAwareAttach()
110 autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700111
Jaineel7e67a3f2019-08-28 15:58:49 -0700112 # Publisher: start publish and wait for confirmation
113 p_disc_id = p_dut.droid.wifiAwarePublish(p_id,
114 self.create_config(ptype))
115 autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700116
Jaineel7e67a3f2019-08-28 15:58:49 -0700117 # Optionally set up a publish session on the Subscriber device
118 if pub_on_both:
119 p2_config = self.create_config(ptype)
120 if not pub_on_both_same:
121 p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = (
122 p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] + "-XYZXYZ")
123 s_dut.droid.wifiAwarePublish(s_id, p2_config)
124 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
Etan Cohen204df172017-11-09 12:05:36 -0800125
Jaineel7e67a3f2019-08-28 15:58:49 -0700126 # Subscriber: start subscribe and wait for confirmation
127 s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id,
128 self.create_config(stype))
129 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700130
Jaineel7e67a3f2019-08-28 15:58:49 -0700131 # Subscriber: wait for service discovery
132 discovery_event = autils.wait_for_event(
133 s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
134 peer_id_on_sub = discovery_event["data"][
135 aconsts.SESSION_CB_KEY_PEER_ID]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700136
Jaineel7e67a3f2019-08-28 15:58:49 -0700137 peer_id_on_pub = None
138 if get_peer_id: # only need message to receive peer ID
139 # Subscriber: send message to peer (Publisher - so it knows our address)
140 s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub,
141 self.get_next_msg_id(),
142 self.PING_MSG,
143 self.MSG_RETX_COUNT)
144 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700145
Jaineel7e67a3f2019-08-28 15:58:49 -0700146 # Publisher: wait for received message
147 pub_rx_msg_event = autils.wait_for_event(
148 p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED)
149 peer_id_on_pub = pub_rx_msg_event["data"][
150 aconsts.SESSION_CB_KEY_PEER_ID]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700151
Jaineel7e67a3f2019-08-28 15:58:49 -0700152 return (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
153 peer_id_on_pub)
Etan Cohenbc80da12017-06-06 09:26:02 -0700154
Jaineel7e67a3f2019-08-28 15:58:49 -0700155 def run_ib_data_path_test(self,
156 ptype,
157 stype,
158 encr_type,
159 use_peer_id,
160 passphrase_to_use=None,
161 pub_on_both=False,
162 pub_on_both_same=True,
163 expect_failure=False):
164 """Runs the in-band data-path tests.
Etan Cohenbc80da12017-06-06 09:26:02 -0700165
166 Args:
167 ptype: Publish discovery type
168 stype: Subscribe discovery type
169 encr_type: Encryption type, one of ENCR_TYPE_*
170 use_peer_id: On Responder (publisher): True to use peer ID, False to
171 accept any request
172 passphrase_to_use: The passphrase to use if encr_type=ENCR_TYPE_PASSPHRASE
173 If None then use self.PASSPHRASE
Etan Cohen204df172017-11-09 12:05:36 -0800174 pub_on_both: If True then set up a publisher on both devices. The second
175 publisher isn't used (existing to test use-case).
176 pub_on_both_same: If True then the second publish uses an identical
177 service name, otherwise a different service name.
Etan Cohen7922a312018-01-23 13:34:55 -0800178 expect_failure: If True then don't expect NDP formation, otherwise expect
179 NDP setup to succeed.
Etan Cohenbc80da12017-06-06 09:26:02 -0700180 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700181 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
182 peer_id_on_pub) = self.set_up_discovery(
183 ptype,
184 stype,
185 use_peer_id,
186 pub_on_both=pub_on_both,
187 pub_on_both_same=pub_on_both_same)
Etan Cohenbc80da12017-06-06 09:26:02 -0700188
Jaineel7e67a3f2019-08-28 15:58:49 -0700189 passphrase = None
190 pmk = None
191 if encr_type == self.ENCR_TYPE_PASSPHRASE:
192 passphrase = (self.PASSPHRASE
193 if passphrase_to_use == None else passphrase_to_use)
194 elif encr_type == self.ENCR_TYPE_PMK:
195 pmk = self.PMK
Etan Cohen058aaba2017-06-05 17:01:54 -0700196
Jaineel7e67a3f2019-08-28 15:58:49 -0700197 port = 1234
198 transport_protocol = 6 # TCP/IP
Etan Cohenfc5f3732017-06-02 17:31:52 -0700199
Jaineel7e67a3f2019-08-28 15:58:49 -0700200 # Publisher: request network
201 if encr_type == self.ENCR_TYPE_OPEN:
202 p_req_key = self.request_network(
203 p_dut,
204 p_dut.droid.wifiAwareCreateNetworkSpecifier(
205 p_disc_id, peer_id_on_pub
206 if use_peer_id else None, passphrase, pmk))
207 else:
208 p_req_key = self.request_network(
209 p_dut,
210 p_dut.droid.wifiAwareCreateNetworkSpecifier(
211 p_disc_id, peer_id_on_pub if use_peer_id else None,
212 passphrase, pmk, port, transport_protocol))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700213
Jaineel7e67a3f2019-08-28 15:58:49 -0700214 # Subscriber: request network
215 s_req_key = self.request_network(
216 s_dut,
217 s_dut.droid.wifiAwareCreateNetworkSpecifier(
218 s_disc_id, peer_id_on_sub, passphrase, pmk))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700219
Jaineel7e67a3f2019-08-28 15:58:49 -0700220 if expect_failure:
221 # Publisher & Subscriber: expect unavailable callbacks
222 autils.wait_for_event_with_keys(
223 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
224 autils.EVENT_NDP_TIMEOUT,
225 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
226 autils.wait_for_event_with_keys(
227 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
228 autils.EVENT_NDP_TIMEOUT,
229 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
230 else:
231 # Publisher & Subscriber: wait for network formation
232 p_net_event_nc = autils.wait_for_event_with_keys(
233 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
234 autils.EVENT_NDP_TIMEOUT,
235 (cconsts.NETWORK_CB_KEY_EVENT,
236 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
237 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
238 s_net_event_nc = autils.wait_for_event_with_keys(
239 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
240 autils.EVENT_NDP_TIMEOUT,
241 (cconsts.NETWORK_CB_KEY_EVENT,
242 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
243 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700244
Jaineel7e67a3f2019-08-28 15:58:49 -0700245 # validate no leak of information
246 asserts.assert_false(
247 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
248 "data"], "Network specifier leak!")
249 asserts.assert_false(
250 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
251 "data"], "Network specifier leak!")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700252
Jaineel7e67a3f2019-08-28 15:58:49 -0700253 # note that Pub <-> Sub since IPv6 are of peer's!
254 s_ipv6 = p_net_event_nc["data"][aconsts.NET_CAP_IPV6]
255 p_ipv6 = s_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700256
Jaineel7e67a3f2019-08-28 15:58:49 -0700257 self.verify_network_info(
258 p_net_event_nc["data"], s_net_event_nc["data"],
259 encr_type == self.ENCR_TYPE_OPEN, port, transport_protocol)
Etan Cohence202292017-06-05 13:55:54 -0700260
Jaineel7e67a3f2019-08-28 15:58:49 -0700261 p_net_event_lp = autils.wait_for_event_with_keys(
262 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
263 autils.EVENT_NDP_TIMEOUT,
264 (cconsts.NETWORK_CB_KEY_EVENT,
265 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
266 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
267 s_net_event_lp = autils.wait_for_event_with_keys(
268 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
269 autils.EVENT_NDP_TIMEOUT,
270 (cconsts.NETWORK_CB_KEY_EVENT,
271 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
272 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohence202292017-06-05 13:55:54 -0700273
Jaineel7e67a3f2019-08-28 15:58:49 -0700274 p_aware_if = p_net_event_lp["data"][
275 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
276 s_aware_if = s_net_event_lp["data"][
277 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700278
Jaineel7e67a3f2019-08-28 15:58:49 -0700279 self.log.info("Interface names: p=%s, s=%s", p_aware_if,
280 s_aware_if)
281 self.log.info("Interface addresses (IPv6): p=%s, s=%s", p_ipv6,
282 s_ipv6)
283
284 # open sockets to test connection
285 asserts.assert_true(
286 autils.verify_socket_connect(p_dut, s_dut, p_ipv6, s_ipv6, 0),
287 "Failed socket link with Pub as Server")
288 asserts.assert_true(
289 autils.verify_socket_connect(s_dut, p_dut, s_ipv6, p_ipv6, 0),
290 "Failed socket link with Sub as Server")
291
292 # terminate sessions and wait for ON_LOST callbacks
293 p_dut.droid.wifiAwareDestroy(p_id)
294 s_dut.droid.wifiAwareDestroy(s_id)
295
296 autils.wait_for_event_with_keys(
297 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
298 autils.EVENT_NDP_TIMEOUT,
299 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
300 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
301 autils.wait_for_event_with_keys(
302 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
303 autils.EVENT_NDP_TIMEOUT,
304 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
305 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
306
307 # clean-up
308 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
309 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
310
311 def run_oob_data_path_test(self,
312 encr_type,
313 use_peer_id,
314 setup_discovery_sessions=False,
315 expect_failure=False):
316 """Runs the out-of-band data-path tests.
Etan Cohenba8a53f2017-06-05 12:55:02 -0700317
318 Args:
319 encr_type: Encryption type, one of ENCR_TYPE_*
320 use_peer_id: On Responder: True to use peer ID, False to accept any
321 request
Etan Cohen35653522017-11-09 13:47:20 -0800322 setup_discovery_sessions: If True also set up a (spurious) discovery
323 session (pub on both sides, sub on Responder side). Validates a corner
324 case.
Etan Cohen7922a312018-01-23 13:34:55 -0800325 expect_failure: If True then don't expect NDP formation, otherwise expect
326 NDP setup to succeed.
Etan Cohenba8a53f2017-06-05 12:55:02 -0700327 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700328 init_dut = self.android_devices[0]
329 init_dut.pretty_name = "Initiator"
330 resp_dut = self.android_devices[1]
331 resp_dut.pretty_name = "Responder"
Etan Cohenba8a53f2017-06-05 12:55:02 -0700332
Jaineel7e67a3f2019-08-28 15:58:49 -0700333 # Initiator+Responder: attach and wait for confirmation & identity
334 init_id = init_dut.droid.wifiAwareAttach(True)
335 autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
336 init_ident_event = autils.wait_for_event(
337 init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
338 init_mac = init_ident_event["data"]["mac"]
339 time.sleep(self.device_startup_offset)
340 resp_id = resp_dut.droid.wifiAwareAttach(True)
341 autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
342 resp_ident_event = autils.wait_for_event(
343 resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
344 resp_mac = resp_ident_event["data"]["mac"]
Etan Cohenba8a53f2017-06-05 12:55:02 -0700345
Jaineel7e67a3f2019-08-28 15:58:49 -0700346 # wait for for devices to synchronize with each other - there are no other
347 # mechanisms to make sure this happens for OOB discovery (except retrying
348 # to execute the data-path request)
349 time.sleep(self.WAIT_FOR_CLUSTER)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700350
Jaineel7e67a3f2019-08-28 15:58:49 -0700351 if setup_discovery_sessions:
352 init_dut.droid.wifiAwarePublish(
353 init_id, self.create_config(aconsts.PUBLISH_TYPE_UNSOLICITED))
354 autils.wait_for_event(init_dut,
355 aconsts.SESSION_CB_ON_PUBLISH_STARTED)
356 resp_dut.droid.wifiAwarePublish(
357 resp_id, self.create_config(aconsts.PUBLISH_TYPE_UNSOLICITED))
358 autils.wait_for_event(resp_dut,
359 aconsts.SESSION_CB_ON_PUBLISH_STARTED)
360 resp_dut.droid.wifiAwareSubscribe(
361 resp_id, self.create_config(aconsts.SUBSCRIBE_TYPE_PASSIVE))
362 autils.wait_for_event(resp_dut,
363 aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
364 autils.wait_for_event(resp_dut,
365 aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
Etan Cohen35653522017-11-09 13:47:20 -0800366
Jaineel7e67a3f2019-08-28 15:58:49 -0700367 passphrase = None
368 pmk = None
369 if encr_type == self.ENCR_TYPE_PASSPHRASE:
370 passphrase = self.PASSPHRASE
371 elif encr_type == self.ENCR_TYPE_PMK:
372 pmk = self.PMK
Etan Cohen058aaba2017-06-05 17:01:54 -0700373
Jaineel7e67a3f2019-08-28 15:58:49 -0700374 # Responder: request network
375 resp_req_key = self.request_network(
376 resp_dut,
377 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
378 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac
379 if use_peer_id else None, passphrase, pmk))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700380
Jaineel7e67a3f2019-08-28 15:58:49 -0700381 # Initiator: request network
382 init_req_key = self.request_network(
383 init_dut,
384 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
385 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase,
386 pmk))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700387
Jaineel7e67a3f2019-08-28 15:58:49 -0700388 if expect_failure:
389 # Initiator & Responder: expect unavailable callbacks
390 autils.wait_for_event_with_keys(
391 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
392 autils.EVENT_NDP_TIMEOUT,
393 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
394 autils.wait_for_event_with_keys(
395 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
396 autils.EVENT_NDP_TIMEOUT,
397 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
398 else:
399 # Initiator & Responder: wait for network formation
400 init_net_event_nc = autils.wait_for_event_with_keys(
401 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
402 autils.EVENT_NDP_TIMEOUT,
403 (cconsts.NETWORK_CB_KEY_EVENT,
404 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
405 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
406 resp_net_event_nc = autils.wait_for_event_with_keys(
407 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
408 autils.EVENT_NDP_TIMEOUT,
409 (cconsts.NETWORK_CB_KEY_EVENT,
410 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
411 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700412
Jaineel7e67a3f2019-08-28 15:58:49 -0700413 # validate no leak of information
414 asserts.assert_false(
415 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in init_net_event_nc[
416 "data"], "Network specifier leak!")
417 asserts.assert_false(
418 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in resp_net_event_nc[
419 "data"], "Network specifier leak!")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700420
Jaineel7e67a3f2019-08-28 15:58:49 -0700421 # note that Init <-> Resp since IPv6 are of peer's!
422 init_ipv6 = resp_net_event_nc["data"][aconsts.NET_CAP_IPV6]
423 resp_ipv6 = init_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenba8a53f2017-06-05 12:55:02 -0700424
Jaineel7e67a3f2019-08-28 15:58:49 -0700425 init_net_event_lp = autils.wait_for_event_with_keys(
426 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
427 autils.EVENT_NDP_TIMEOUT,
428 (cconsts.NETWORK_CB_KEY_EVENT,
429 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
430 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
431 resp_net_event_lp = autils.wait_for_event_with_keys(
432 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
433 autils.EVENT_NDP_TIMEOUT,
434 (cconsts.NETWORK_CB_KEY_EVENT,
435 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
436 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700437
Jaineel7e67a3f2019-08-28 15:58:49 -0700438 init_aware_if = init_net_event_lp["data"][
439 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
440 resp_aware_if = resp_net_event_lp["data"][
441 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohence202292017-06-05 13:55:54 -0700442
Jaineel7e67a3f2019-08-28 15:58:49 -0700443 self.log.info("Interface names: I=%s, R=%s", init_aware_if,
444 resp_aware_if)
445 self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
446 resp_ipv6)
Etan Cohence202292017-06-05 13:55:54 -0700447
Jaineel7e67a3f2019-08-28 15:58:49 -0700448 # open sockets to test connection
449 asserts.assert_true(
450 autils.verify_socket_connect(init_dut, resp_dut, init_ipv6,
451 resp_ipv6, 0),
452 "Failed socket link with Initiator as Server")
453 asserts.assert_true(
454 autils.verify_socket_connect(resp_dut, init_dut, resp_ipv6,
455 init_ipv6, 0),
456 "Failed socket link with Responder as Server")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700457
Jaineel7e67a3f2019-08-28 15:58:49 -0700458 # terminate sessions and wait for ON_LOST callbacks
459 init_dut.droid.wifiAwareDestroy(init_id)
460 resp_dut.droid.wifiAwareDestroy(resp_id)
461
462 autils.wait_for_event_with_keys(
463 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
464 autils.EVENT_NDP_TIMEOUT,
465 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
466 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
467 autils.wait_for_event_with_keys(
468 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
469 autils.EVENT_NDP_TIMEOUT,
470 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
471 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
472
473 # clean-up
474 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
475 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
476
477 def run_mismatched_ib_data_path_test(self, pub_mismatch, sub_mismatch):
478 """Runs the negative in-band data-path tests: mismatched peer ID.
Etan Cohenbc80da12017-06-06 09:26:02 -0700479
480 Args:
481 pub_mismatch: Mismatch the publisher's ID
482 sub_mismatch: Mismatch the subscriber's ID
483 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700484 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
485 peer_id_on_pub) = self.set_up_discovery(
486 aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE,
487 True)
Etan Cohenbc80da12017-06-06 09:26:02 -0700488
Jaineel7e67a3f2019-08-28 15:58:49 -0700489 if pub_mismatch:
490 peer_id_on_pub = peer_id_on_pub - 1
491 if sub_mismatch:
492 peer_id_on_sub = peer_id_on_sub - 1
Etan Cohenbc80da12017-06-06 09:26:02 -0700493
Jaineel7e67a3f2019-08-28 15:58:49 -0700494 # Publisher: request network
495 p_req_key = self.request_network(
496 p_dut,
497 p_dut.droid.wifiAwareCreateNetworkSpecifier(
498 p_disc_id, peer_id_on_pub, None))
Etan Cohenbc80da12017-06-06 09:26:02 -0700499
Jaineel7e67a3f2019-08-28 15:58:49 -0700500 # Subscriber: request network
501 s_req_key = self.request_network(
502 s_dut,
503 s_dut.droid.wifiAwareCreateNetworkSpecifier(
504 s_disc_id, peer_id_on_sub, None))
Etan Cohenbc80da12017-06-06 09:26:02 -0700505
Jaineel7e67a3f2019-08-28 15:58:49 -0700506 # Publisher & Subscriber:
507 # - expect unavailable callbacks on the party with the bad ID
508 # - also expect unavailable on the Initiator party (i.e. the
509 # Subscriber) if the Publisher has a bad ID
510 # - but a Publisher with a valid ID will keep waiting ...
511 autils.wait_for_event_with_keys(
512 s_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
513 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
514 if pub_mismatch:
515 autils.wait_for_event_with_keys(
516 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
517 autils.EVENT_NDP_TIMEOUT,
518 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
519 else:
520 time.sleep(autils.EVENT_NDP_TIMEOUT)
521 autils.fail_on_event_with_keys(
522 p_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
523 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
Etan Cohenbc80da12017-06-06 09:26:02 -0700524
Jaineel7e67a3f2019-08-28 15:58:49 -0700525 # clean-up
526 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
527 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
Etan Cohenbc80da12017-06-06 09:26:02 -0700528
Jaineel7e67a3f2019-08-28 15:58:49 -0700529 def run_mismatched_oob_data_path_test(self,
530 init_mismatch_mac=False,
531 resp_mismatch_mac=False,
532 init_encr_type=ENCR_TYPE_OPEN,
533 resp_encr_type=ENCR_TYPE_OPEN):
534 """Runs the negative out-of-band data-path tests: mismatched information
Etan Cohen85adc452017-06-06 08:32:08 -0700535 between Responder and Initiator.
536
537 Args:
538 init_mismatch_mac: True to mismatch the Initiator MAC address
539 resp_mismatch_mac: True to mismatch the Responder MAC address
540 init_encr_type: Encryption type of Initiator - ENCR_TYPE_*
541 resp_encr_type: Encryption type of Responder - ENCR_TYPE_*
542 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700543 init_dut = self.android_devices[0]
544 init_dut.pretty_name = "Initiator"
545 resp_dut = self.android_devices[1]
546 resp_dut.pretty_name = "Responder"
Etan Cohen85adc452017-06-06 08:32:08 -0700547
Jaineel7e67a3f2019-08-28 15:58:49 -0700548 # Initiator+Responder: attach and wait for confirmation & identity
549 init_id = init_dut.droid.wifiAwareAttach(True)
550 autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
551 init_ident_event = autils.wait_for_event(
552 init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
553 init_mac = init_ident_event["data"]["mac"]
554 time.sleep(self.device_startup_offset)
555 resp_id = resp_dut.droid.wifiAwareAttach(True)
556 autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
557 resp_ident_event = autils.wait_for_event(
558 resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
559 resp_mac = resp_ident_event["data"]["mac"]
Etan Cohen85adc452017-06-06 08:32:08 -0700560
Jaineel7e67a3f2019-08-28 15:58:49 -0700561 if init_mismatch_mac: # assumes legit ones don't start with "00"
562 init_mac = "00" + init_mac[2:]
563 if resp_mismatch_mac:
564 resp_mac = "00" + resp_mac[2:]
Etan Cohen85adc452017-06-06 08:32:08 -0700565
Jaineel7e67a3f2019-08-28 15:58:49 -0700566 # wait for for devices to synchronize with each other - there are no other
567 # mechanisms to make sure this happens for OOB discovery (except retrying
568 # to execute the data-path request)
569 time.sleep(self.WAIT_FOR_CLUSTER)
Etan Cohen85adc452017-06-06 08:32:08 -0700570
Jaineel7e67a3f2019-08-28 15:58:49 -0700571 # set up separate keys: even if types are the same we want a mismatch
572 init_passphrase = None
573 init_pmk = None
574 if init_encr_type == self.ENCR_TYPE_PASSPHRASE:
575 init_passphrase = self.PASSPHRASE
576 elif init_encr_type == self.ENCR_TYPE_PMK:
577 init_pmk = self.PMK
Etan Cohen85adc452017-06-06 08:32:08 -0700578
Jaineel7e67a3f2019-08-28 15:58:49 -0700579 resp_passphrase = None
580 resp_pmk = None
581 if resp_encr_type == self.ENCR_TYPE_PASSPHRASE:
582 resp_passphrase = self.PASSPHRASE2
583 elif resp_encr_type == self.ENCR_TYPE_PMK:
584 resp_pmk = self.PMK2
Etan Cohen85adc452017-06-06 08:32:08 -0700585
Jaineel7e67a3f2019-08-28 15:58:49 -0700586 # Responder: request network
587 resp_req_key = self.request_network(
588 resp_dut,
589 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
590 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac,
591 resp_passphrase, resp_pmk))
Etan Cohen85adc452017-06-06 08:32:08 -0700592
Jaineel7e67a3f2019-08-28 15:58:49 -0700593 # Initiator: request network
594 init_req_key = self.request_network(
595 init_dut,
596 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
597 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac,
598 init_passphrase, init_pmk))
Etan Cohen85adc452017-06-06 08:32:08 -0700599
Jaineel7e67a3f2019-08-28 15:58:49 -0700600 # Initiator & Responder:
601 # - expect unavailable on the Initiator party if the
602 # Initiator or Responder has a bad ID
603 # - but a Responder will keep waiting ...
604 autils.wait_for_event_with_keys(
605 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
606 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
607 time.sleep(autils.EVENT_NDP_TIMEOUT)
608 autils.fail_on_event_with_keys(
609 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
610 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
Etan Cohen85adc452017-06-06 08:32:08 -0700611
Jaineel7e67a3f2019-08-28 15:58:49 -0700612 # clean-up
613 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
614 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohen85adc452017-06-06 08:32:08 -0700615
Jaineel7e67a3f2019-08-28 15:58:49 -0700616 def verify_network_info(self, p_data, s_data, open, port,
617 transport_protocol):
618 """Verify that the port and transport protocol information is correct.
619 - should only exist on subscriber (received from publisher)
620 and match transmitted values
621 - should only exist on an encrypted NDP
Etan Cohenba8a53f2017-06-05 12:55:02 -0700622
Jaineel7e67a3f2019-08-28 15:58:49 -0700623 Args:
624 p_data, s_data: Pub and Sub (respectively) net cap event data.
625 open: True if NDP unencrypted, False if encrypted.
626 port: Expected port value.
627 transport_protocol: Expected transport protocol value.
628 """
629 asserts.assert_true(aconsts.NET_CAP_PORT not in p_data,
630 "port info not expected on Pub")
631 asserts.assert_true(aconsts.NET_CAP_TRANSPORT_PROTOCOL not in p_data,
632 "transport protocol info not expected on Pub")
633 if open:
634 asserts.assert_true(aconsts.NET_CAP_PORT not in s_data,
635 "port info not expected on Sub (open NDP)")
636 asserts.assert_true(
637 aconsts.NET_CAP_TRANSPORT_PROTOCOL not in s_data,
638 "transport protocol info not expected on Sub (open NDP)")
639 else:
640 asserts.assert_equal(s_data[aconsts.NET_CAP_PORT], port,
641 "Port info does not match on Sub (from Pub)")
642 asserts.assert_equal(
643 s_data[aconsts.NET_CAP_TRANSPORT_PROTOCOL], transport_protocol,
644 "Transport protocol info does not match on Sub (from Pub)")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700645
Jaineel7e67a3f2019-08-28 15:58:49 -0700646 #######################################
647 # Positive In-Band (IB) tests key:
648 #
649 # names is: test_ib_<pub_type>_<sub_type>_<encr_type>_<peer_spec>
650 # where:
651 #
652 # pub_type: Type of publish discovery session: unsolicited or solicited.
653 # sub_type: Type of subscribe discovery session: passive or active.
654 # encr_type: Encription type: open, passphrase
655 # peer_spec: Peer specification method: any or specific
656 #
657 # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
658 # peer using the Aware-provided peer handle (as opposed to a MAC address).
659 #######################################
660
661 @test_tracker_info(uuid="fa30bedc-d1de-4440-bf25-ec00d10555af")
662 def test_ib_unsolicited_passive_open_specific(self):
663 """Data-path: in-band, unsolicited/passive, open encryption, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700664
665 Verifies end-to-end discovery + data-path creation.
666 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700667 self.run_ib_data_path_test(
668 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
669 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
670 encr_type=self.ENCR_TYPE_OPEN,
671 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700672
Jaineel7e67a3f2019-08-28 15:58:49 -0700673 @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d")
674 def test_ib_unsolicited_passive_open_any(self):
675 """Data-path: in-band, unsolicited/passive, open encryption, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700676
677 Verifies end-to-end discovery + data-path creation.
678 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700679 self.run_ib_data_path_test(
680 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
681 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
682 encr_type=self.ENCR_TYPE_OPEN,
683 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700684
Jaineel7e67a3f2019-08-28 15:58:49 -0700685 @test_tracker_info(uuid="93b2a23d-8579-448a-936c-7812929464cf")
686 def test_ib_unsolicited_passive_passphrase_specific(self):
687 """Data-path: in-band, unsolicited/passive, passphrase, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700688
689 Verifies end-to-end discovery + data-path creation.
690 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700691 self.run_ib_data_path_test(
692 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
693 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
694 encr_type=self.ENCR_TYPE_PASSPHRASE,
695 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700696
Jaineel7e67a3f2019-08-28 15:58:49 -0700697 @test_tracker_info(uuid="1736126f-a0ff-4712-acc4-f89b4eef5716")
698 def test_ib_unsolicited_passive_passphrase_any(self):
699 """Data-path: in-band, unsolicited/passive, passphrase, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700700
701 Verifies end-to-end discovery + data-path creation.
702 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700703 self.run_ib_data_path_test(
704 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
705 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
706 encr_type=self.ENCR_TYPE_PASSPHRASE,
707 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700708
Jaineel7e67a3f2019-08-28 15:58:49 -0700709 @test_tracker_info(uuid="b9353d5b-3f77-46bf-bfd9-65d56a7c939a")
710 def test_ib_unsolicited_passive_pmk_specific(self):
711 """Data-path: in-band, unsolicited/passive, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700712
713 Verifies end-to-end discovery + data-path creation.
714 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700715 self.run_ib_data_path_test(
716 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
717 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
718 encr_type=self.ENCR_TYPE_PMK,
719 use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700720
Jaineel7e67a3f2019-08-28 15:58:49 -0700721 @test_tracker_info(uuid="06f3b2ab-4a10-4398-83a4-6a23851b1662")
722 def test_ib_unsolicited_passive_pmk_any(self):
723 """Data-path: in-band, unsolicited/passive, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700724
725 Verifies end-to-end discovery + data-path creation.
726 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700727 self.run_ib_data_path_test(
728 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
729 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
730 encr_type=self.ENCR_TYPE_PMK,
731 use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700732
Jaineel7e67a3f2019-08-28 15:58:49 -0700733 @test_tracker_info(uuid="0ed7d8b3-a69e-46ba-aeb7-13e507ecf290")
734 def test_ib_solicited_active_open_specific(self):
735 """Data-path: in-band, solicited/active, open encryption, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700736
Etan Cohenba8a53f2017-06-05 12:55:02 -0700737 Verifies end-to-end discovery + data-path creation.
738 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700739 self.run_ib_data_path_test(
740 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
741 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
742 encr_type=self.ENCR_TYPE_OPEN,
743 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700744
Jaineel7e67a3f2019-08-28 15:58:49 -0700745 @test_tracker_info(uuid="c7ba6d28-5ef6-45d9-95d5-583ad6d981f3")
746 def test_ib_solicited_active_open_any(self):
747 """Data-path: in-band, solicited/active, open encryption, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700748
Etan Cohenba8a53f2017-06-05 12:55:02 -0700749 Verifies end-to-end discovery + data-path creation.
750 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700751 self.run_ib_data_path_test(
752 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
753 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
754 encr_type=self.ENCR_TYPE_OPEN,
755 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700756
Jaineel7e67a3f2019-08-28 15:58:49 -0700757 @test_tracker_info(uuid="388cea99-0e2e-49ea-b00e-f3e56b6236e5")
758 def test_ib_solicited_active_passphrase_specific(self):
759 """Data-path: in-band, solicited/active, passphrase, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700760
Etan Cohenba8a53f2017-06-05 12:55:02 -0700761 Verifies end-to-end discovery + data-path creation.
762 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700763 self.run_ib_data_path_test(
764 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
765 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
766 encr_type=self.ENCR_TYPE_PASSPHRASE,
767 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700768
Jaineel7e67a3f2019-08-28 15:58:49 -0700769 @test_tracker_info(uuid="fcd3e28a-5eab-4169-8a0c-dc7204dcdc13")
770 def test_ib_solicited_active_passphrase_any(self):
771 """Data-path: in-band, solicited/active, passphrase, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700772
Etan Cohenba8a53f2017-06-05 12:55:02 -0700773 Verifies end-to-end discovery + data-path creation.
774 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700775 self.run_ib_data_path_test(
776 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
777 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
778 encr_type=self.ENCR_TYPE_PASSPHRASE,
779 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700780
Jaineel7e67a3f2019-08-28 15:58:49 -0700781 @test_tracker_info(uuid="9d4eaad7-ba53-4a06-8ce0-e308daea3309")
782 def test_ib_solicited_active_pmk_specific(self):
783 """Data-path: in-band, solicited/active, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700784
785 Verifies end-to-end discovery + data-path creation.
786 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700787 self.run_ib_data_path_test(
788 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
789 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
790 encr_type=self.ENCR_TYPE_PMK,
791 use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700792
Jaineel7e67a3f2019-08-28 15:58:49 -0700793 @test_tracker_info(uuid="129d850e-c312-4137-a67b-05ae95fe66cc")
794 def test_ib_solicited_active_pmk_any(self):
795 """Data-path: in-band, solicited/active, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700796
797 Verifies end-to-end discovery + data-path creation.
798 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700799 self.run_ib_data_path_test(
800 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
801 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
802 encr_type=self.ENCR_TYPE_PMK,
803 use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700804
Jaineel7e67a3f2019-08-28 15:58:49 -0700805 #######################################
806 # Positive In-Band (IB) with a publish session running on the subscriber
807 # tests key:
808 #
809 # names is: test_ib_extra_pub_<same|diff>_<pub_type>_<sub_type>
810 # _<encr_type>_<peer_spec>
811 # where:
812 #
813 # same|diff: Whether the extra publish session (on the subscriber) is the same
814 # or different from the primary session.
815 # pub_type: Type of publish discovery session: unsolicited or solicited.
816 # sub_type: Type of subscribe discovery session: passive or active.
817 # encr_type: Encryption type: open, passphrase
818 # peer_spec: Peer specification method: any or specific
819 #
820 # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
821 # peer using the Aware-provided peer handle (as opposed to a MAC address).
822 #######################################
Etan Cohen204df172017-11-09 12:05:36 -0800823
Jaineel7e67a3f2019-08-28 15:58:49 -0700824 @test_tracker_info(uuid="e855dd81-45c8-4bb2-a204-7687c48ff843")
825 def test_ib_extra_pub_same_unsolicited_passive_open_specific(self):
826 """Data-path: in-band, unsolicited/passive, open encryption, specific peer.
Etan Cohen204df172017-11-09 12:05:36 -0800827
828 Configuration contains a publisher (for the same service) running on *both*
829 devices.
830
831 Verifies end-to-end discovery + data-path creation.
832 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700833 self.run_ib_data_path_test(
834 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
835 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
836 encr_type=self.ENCR_TYPE_OPEN,
837 use_peer_id=True,
838 pub_on_both=True,
839 pub_on_both_same=True)
Etan Cohen204df172017-11-09 12:05:36 -0800840
Jaineel7e67a3f2019-08-28 15:58:49 -0700841 @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d")
842 def test_ib_extra_pub_same_unsolicited_passive_open_any(self):
843 """Data-path: in-band, unsolicited/passive, open encryption, any peer.
Etan Cohen204df172017-11-09 12:05:36 -0800844
845 Configuration contains a publisher (for the same service) running on *both*
846 devices.
847
848 Verifies end-to-end discovery + data-path creation.
849 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700850 self.run_ib_data_path_test(
851 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
852 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
853 encr_type=self.ENCR_TYPE_OPEN,
854 use_peer_id=False,
855 pub_on_both=True,
856 pub_on_both_same=True)
Etan Cohen204df172017-11-09 12:05:36 -0800857
Jaineel7e67a3f2019-08-28 15:58:49 -0700858 @test_tracker_info(uuid="7a32f439-d745-4716-a75e-b54109aaaf82")
859 def test_ib_extra_pub_diff_unsolicited_passive_open_specific(self):
860 """Data-path: in-band, unsolicited/passive, open encryption, specific peer.
Etan Cohen204df172017-11-09 12:05:36 -0800861
862 Configuration contains a publisher (for a different service) running on
863 *both* devices.
864
865 Verifies end-to-end discovery + data-path creation.
866 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700867 self.run_ib_data_path_test(
868 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
869 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
870 encr_type=self.ENCR_TYPE_OPEN,
871 use_peer_id=True,
872 pub_on_both=True,
873 pub_on_both_same=False)
Etan Cohen204df172017-11-09 12:05:36 -0800874
Jaineel7e67a3f2019-08-28 15:58:49 -0700875 @test_tracker_info(uuid="a14ddc66-88fd-4b49-ab37-225533867c63")
876 def test_ib_extra_pub_diff_unsolicited_passive_open_any(self):
877 """Data-path: in-band, unsolicited/passive, open encryption, any peer.
Etan Cohen204df172017-11-09 12:05:36 -0800878
879 Configuration contains a publisher (for a different service) running on
880 *both* devices.
881
882 Verifies end-to-end discovery + data-path creation.
883 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700884 self.run_ib_data_path_test(
885 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
886 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
887 encr_type=self.ENCR_TYPE_OPEN,
888 use_peer_id=False,
889 pub_on_both=True,
890 pub_on_both_same=False)
Etan Cohen204df172017-11-09 12:05:36 -0800891
Jaineel7e67a3f2019-08-28 15:58:49 -0700892 #######################################
893 # Positive Out-of-Band (OOB) tests key:
894 #
895 # names is: test_oob_<encr_type>_<peer_spec>
896 # where:
897 #
898 # encr_type: Encryption type: open, passphrase
899 # peer_spec: Peer specification method: any or specific
900 #
901 # Optionally set up an extra discovery session to test coexistence. If so
902 # add "ib_coex" to test name.
903 #
904 # Note: Out-of-Band means using a non-Wi-Fi Aware mechanism for discovery and
905 # exchange of MAC addresses and then Wi-Fi Aware for data-path.
906 #######################################
Etan Cohenba8a53f2017-06-05 12:55:02 -0700907
Jaineel7e67a3f2019-08-28 15:58:49 -0700908 @test_tracker_info(uuid="7db17d8c-1dce-4084-b695-215bbcfe7d41")
909 def test_oob_open_specific(self):
910 """Data-path: out-of-band, open encryption, specific peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700911
912 Verifies end-to-end discovery + data-path creation.
913 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700914 self.run_oob_data_path_test(
915 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=True)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700916
Jaineel7e67a3f2019-08-28 15:58:49 -0700917 @test_tracker_info(uuid="ad416d89-cb95-4a07-8d29-ee213117450b")
918 def test_oob_open_any(self):
919 """Data-path: out-of-band, open encryption, any peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700920
921 Verifies end-to-end discovery + data-path creation.
922 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700923 self.run_oob_data_path_test(
924 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700925
Jaineel7e67a3f2019-08-28 15:58:49 -0700926 @test_tracker_info(uuid="74937a3a-d524-43e2-8979-4449271cab52")
927 def test_oob_passphrase_specific(self):
928 """Data-path: out-of-band, passphrase, specific peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700929
930 Verifies end-to-end discovery + data-path creation.
931 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700932 self.run_oob_data_path_test(
933 encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=True)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700934
Jaineel7e67a3f2019-08-28 15:58:49 -0700935 @test_tracker_info(uuid="afcbdc7e-d3a9-465b-b1da-ce2e42e3941e")
936 def test_oob_passphrase_any(self):
937 """Data-path: out-of-band, passphrase, any peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700938
939 Verifies end-to-end discovery + data-path creation.
940 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700941 self.run_oob_data_path_test(
942 encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700943
Jaineel7e67a3f2019-08-28 15:58:49 -0700944 @test_tracker_info(uuid="0d095031-160a-4537-aab5-41b6ad5d55f8")
945 def test_oob_pmk_specific(self):
946 """Data-path: out-of-band, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700947
948 Verifies end-to-end discovery + data-path creation.
949 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700950 self.run_oob_data_path_test(
951 encr_type=self.ENCR_TYPE_PMK, use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700952
Jaineel7e67a3f2019-08-28 15:58:49 -0700953 @test_tracker_info(uuid="e45477bd-66cc-4eb7-88dd-4518c8aa2a74")
954 def test_oob_pmk_any(self):
955 """Data-path: out-of-band, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700956
957 Verifies end-to-end discovery + data-path creation.
958 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700959 self.run_oob_data_path_test(
960 encr_type=self.ENCR_TYPE_PMK, use_peer_id=False)
Etan Cohen6ace4582017-06-05 17:21:55 -0700961
Jaineel7e67a3f2019-08-28 15:58:49 -0700962 @test_tracker_info(uuid="dd464f24-b404-4eea-955c-d10c9e8adefc")
963 def test_oob_ib_coex_open_specific(self):
964 """Data-path: out-of-band, open encryption, specific peer - in-band coex:
Etan Cohen35653522017-11-09 13:47:20 -0800965 set up a concurrent discovery session to verify no impact. The session
966 consists of Publisher on both ends, and a Subscriber on the Responder.
967
968 Verifies end-to-end discovery + data-path creation.
969 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700970 self.run_oob_data_path_test(
971 encr_type=self.ENCR_TYPE_OPEN,
972 use_peer_id=True,
973 setup_discovery_sessions=True)
Etan Cohen35653522017-11-09 13:47:20 -0800974
Jaineel7e67a3f2019-08-28 15:58:49 -0700975 @test_tracker_info(uuid="088fcd3a-b015-4179-a9a5-91f782b03e3b")
976 def test_oob_ib_coex_open_any(self):
977 """Data-path: out-of-band, open encryption, any peer - in-band coex:
Etan Cohen35653522017-11-09 13:47:20 -0800978 set up a concurrent discovery session to verify no impact. The session
979 consists of Publisher on both ends, and a Subscriber on the Responder.
980
981 Verifies end-to-end discovery + data-path creation.
982 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700983 self.run_oob_data_path_test(
984 encr_type=self.ENCR_TYPE_OPEN,
985 use_peer_id=False,
986 setup_discovery_sessions=True)
Etan Cohen35653522017-11-09 13:47:20 -0800987
Jaineel7e67a3f2019-08-28 15:58:49 -0700988 ##############################################################
Etan Cohen6ace4582017-06-05 17:21:55 -0700989
Jaineel7e67a3f2019-08-28 15:58:49 -0700990 @test_tracker_info(uuid="1c2c9805-dc1e-43b5-a1b8-315e8c9a4337")
991 def test_passphrase_min(self):
992 """Data-path: minimum passphrase length
Etan Cohen6ace4582017-06-05 17:21:55 -0700993
994 Use in-band, unsolicited/passive, any peer combination
995 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700996 self.run_ib_data_path_test(
997 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
998 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
999 encr_type=self.ENCR_TYPE_PASSPHRASE,
1000 use_peer_id=False,
1001 passphrase_to_use=self.PASSPHRASE_MIN)
Etan Cohen6ace4582017-06-05 17:21:55 -07001002
Jaineel7e67a3f2019-08-28 15:58:49 -07001003 @test_tracker_info(uuid="e696e2b9-87a9-4521-b337-61b9efaa2057")
1004 def test_passphrase_max(self):
1005 """Data-path: maximum passphrase length
Etan Cohen6ace4582017-06-05 17:21:55 -07001006
1007 Use in-band, unsolicited/passive, any peer combination
1008 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001009 self.run_ib_data_path_test(
1010 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1011 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1012 encr_type=self.ENCR_TYPE_PASSPHRASE,
1013 use_peer_id=False,
1014 passphrase_to_use=self.PASSPHRASE_MAX)
Etan Cohen85adc452017-06-06 08:32:08 -07001015
Jaineel7e67a3f2019-08-28 15:58:49 -07001016 @test_tracker_info(uuid="533cd44c-ff30-4283-ac28-f71fd7b4f02d")
1017 def test_negative_mismatch_publisher_peer_id(self):
1018 """Data-path: failure when publisher peer ID is mismatched"""
1019 self.run_mismatched_ib_data_path_test(
1020 pub_mismatch=True, sub_mismatch=False)
Etan Cohenbc80da12017-06-06 09:26:02 -07001021
Jaineel7e67a3f2019-08-28 15:58:49 -07001022 @test_tracker_info(uuid="682f275e-722a-4f8b-85e7-0dcea9d25532")
1023 def test_negative_mismatch_subscriber_peer_id(self):
1024 """Data-path: failure when subscriber peer ID is mismatched"""
1025 self.run_mismatched_ib_data_path_test(
1026 pub_mismatch=False, sub_mismatch=True)
Etan Cohenbc80da12017-06-06 09:26:02 -07001027
Jaineel7e67a3f2019-08-28 15:58:49 -07001028 @test_tracker_info(uuid="7fa82796-7fc9-4d9e-bbbb-84b751788943")
1029 def test_negative_mismatch_init_mac(self):
1030 """Data-path: failure when Initiator MAC address mismatch"""
1031 self.run_mismatched_oob_data_path_test(
1032 init_mismatch_mac=True, resp_mismatch_mac=False)
Etan Cohen85adc452017-06-06 08:32:08 -07001033
Jaineel7e67a3f2019-08-28 15:58:49 -07001034 @test_tracker_info(uuid="edeae959-4644-44f9-8d41-bdeb5216954e")
1035 def test_negative_mismatch_resp_mac(self):
1036 """Data-path: failure when Responder MAC address mismatch"""
1037 self.run_mismatched_oob_data_path_test(
1038 init_mismatch_mac=False, resp_mismatch_mac=True)
Etan Cohen85adc452017-06-06 08:32:08 -07001039
Jaineel7e67a3f2019-08-28 15:58:49 -07001040 @test_tracker_info(uuid="91f46949-c47f-49f9-a90f-6fae699613a7")
1041 def test_negative_mismatch_passphrase(self):
1042 """Data-path: failure when passphrases mismatch"""
1043 self.run_mismatched_oob_data_path_test(
1044 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1045 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001046
Jaineel7e67a3f2019-08-28 15:58:49 -07001047 @test_tracker_info(uuid="01c49c2e-dc92-4a27-bb47-c4fc67617c23")
1048 def test_negative_mismatch_pmk(self):
1049 """Data-path: failure when PMK mismatch"""
1050 self.run_mismatched_oob_data_path_test(
1051 init_encr_type=self.ENCR_TYPE_PMK,
1052 resp_encr_type=self.ENCR_TYPE_PMK)
Etan Cohen85adc452017-06-06 08:32:08 -07001053
Jaineel7e67a3f2019-08-28 15:58:49 -07001054 @test_tracker_info(uuid="4d651797-5fbb-408e-a4b6-a6e1944136da")
1055 def test_negative_mismatch_open_passphrase(self):
1056 """Data-path: failure when initiator is open, and responder passphrase"""
1057 self.run_mismatched_oob_data_path_test(
1058 init_encr_type=self.ENCR_TYPE_OPEN,
1059 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001060
Jaineel7e67a3f2019-08-28 15:58:49 -07001061 @test_tracker_info(uuid="1ae697f4-5987-4187-aeef-1e22d07d4a7c")
1062 def test_negative_mismatch_open_pmk(self):
1063 """Data-path: failure when initiator is open, and responder PMK"""
1064 self.run_mismatched_oob_data_path_test(
1065 init_encr_type=self.ENCR_TYPE_OPEN,
1066 resp_encr_type=self.ENCR_TYPE_PMK)
Etan Cohen85adc452017-06-06 08:32:08 -07001067
Jaineel7e67a3f2019-08-28 15:58:49 -07001068 @test_tracker_info(uuid="f027b1cc-0e7a-4075-b880-5e64b288afbd")
1069 def test_negative_mismatch_pmk_passphrase(self):
1070 """Data-path: failure when initiator is pmk, and responder passphrase"""
1071 self.run_mismatched_oob_data_path_test(
1072 init_encr_type=self.ENCR_TYPE_PMK,
1073 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001074
Jaineel7e67a3f2019-08-28 15:58:49 -07001075 @test_tracker_info(uuid="0819bbd4-72ae-49c4-bd46-5448db2b0a06")
1076 def test_negative_mismatch_passphrase_open(self):
1077 """Data-path: failure when initiator is passphrase, and responder open"""
1078 self.run_mismatched_oob_data_path_test(
1079 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1080 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen85adc452017-06-06 08:32:08 -07001081
Jaineel7e67a3f2019-08-28 15:58:49 -07001082 @test_tracker_info(uuid="7ef24f62-8e6b-4732-88a3-80a43584dda4")
1083 def test_negative_mismatch_pmk_open(self):
1084 """Data-path: failure when initiator is PMK, and responder open"""
1085 self.run_mismatched_oob_data_path_test(
1086 init_encr_type=self.ENCR_TYPE_PMK,
1087 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen85adc452017-06-06 08:32:08 -07001088
Jaineel7e67a3f2019-08-28 15:58:49 -07001089 @test_tracker_info(uuid="7b9c9efc-1c06-465e-8a5e-d6a22ac1da97")
1090 def test_negative_mismatch_passphrase_pmk(self):
1091 """Data-path: failure when initiator is passphrase, and responder pmk"""
1092 self.run_mismatched_oob_data_path_test(
1093 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1094 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001095
Jaineel7e67a3f2019-08-28 15:58:49 -07001096 ##########################################################################
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001097
Jaineel7e67a3f2019-08-28 15:58:49 -07001098 def wait_for_request_responses(self, dut, req_keys, aware_ifs, aware_ipv6):
1099 """Wait for network request confirmation for all request keys.
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001100
1101 Args:
1102 dut: Device under test
1103 req_keys: (in) A list of the network requests
1104 aware_ifs: (out) A list into which to append the network interface
Jaineel7e67a3f2019-08-28 15:58:49 -07001105 aware_ipv6: (out) A list into which to append the network ipv6 address
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001106 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001107 num_events = 0 # looking for 2 events per NDP: link-prop + net-cap
1108 while num_events != 2 * len(req_keys):
1109 event = autils.wait_for_event(
1110 dut,
1111 cconsts.EVENT_NETWORK_CALLBACK,
1112 timeout=autils.EVENT_NDP_TIMEOUT)
1113 if (event["data"][cconsts.NETWORK_CB_KEY_EVENT] ==
1114 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED):
1115 if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys:
1116 num_events = num_events + 1
1117 aware_ifs.append(
1118 event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
1119 else:
1120 self.log.info(
1121 "Received an unexpected connectivity, the revoked "
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001122 "network request probably went through -- %s", event)
Jaineel7e67a3f2019-08-28 15:58:49 -07001123 elif (event["data"][cconsts.NETWORK_CB_KEY_EVENT] ==
1124 cconsts.NETWORK_CB_CAPABILITIES_CHANGED):
1125 if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys:
1126 num_events = num_events + 1
1127 aware_ipv6.append(event["data"][aconsts.NET_CAP_IPV6])
1128 else:
1129 self.log.info(
1130 "Received an unexpected connectivity, the revoked "
1131 "network request probably went through -- %s", event)
1132 # validate no leak of information
1133 asserts.assert_false(
1134 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in event["data"],
1135 "Network specifier leak!")
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001136
Jaineel7e67a3f2019-08-28 15:58:49 -07001137 @test_tracker_info(uuid="2e325e2b-d552-4890-b470-20b40284395d")
1138 def test_multiple_identical_networks(self):
1139 """Validate that creating multiple networks between 2 devices, each network
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001140 with identical configuration is supported over a single NDP.
1141
1142 Verify that the interface and IPv6 address is the same for all networks.
1143 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001144 init_dut = self.android_devices[0]
1145 init_dut.pretty_name = "Initiator"
1146 resp_dut = self.android_devices[1]
1147 resp_dut.pretty_name = "Responder"
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001148
Jaineel7e67a3f2019-08-28 15:58:49 -07001149 N = 2 # first iteration (must be 2 to give us a chance to cancel the first)
1150 M = 5 # second iteration
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001151
Jaineel7e67a3f2019-08-28 15:58:49 -07001152 init_ids = []
1153 resp_ids = []
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001154
Jaineel7e67a3f2019-08-28 15:58:49 -07001155 # Initiator+Responder: attach and wait for confirmation & identity
1156 # create N+M sessions to be used in the different (but identical) NDPs
1157 for i in range(N + M):
1158 id, init_mac = autils.attach_with_identity(init_dut)
1159 init_ids.append(id)
1160 id, resp_mac = autils.attach_with_identity(resp_dut)
1161 resp_ids.append(id)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001162
Jaineel7e67a3f2019-08-28 15:58:49 -07001163 # wait for for devices to synchronize with each other - there are no other
1164 # mechanisms to make sure this happens for OOB discovery (except retrying
1165 # to execute the data-path request)
1166 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001167
Jaineel7e67a3f2019-08-28 15:58:49 -07001168 resp_req_keys = []
1169 init_req_keys = []
1170 resp_aware_ifs = []
1171 init_aware_ifs = []
1172 resp_aware_ipv6 = []
1173 init_aware_ipv6 = []
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001174
Jaineel7e67a3f2019-08-28 15:58:49 -07001175 # issue N quick requests for identical NDPs - without waiting for result
1176 # tests whether pre-setup multiple NDP procedure
1177 for i in range(N):
1178 # Responder: request network
1179 resp_req_keys.append(
1180 autils.request_network(
1181 resp_dut,
1182 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1183 resp_ids[i], aconsts.DATA_PATH_RESPONDER, init_mac,
1184 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001185
Jaineel7e67a3f2019-08-28 15:58:49 -07001186 # Initiator: request network
1187 init_req_keys.append(
1188 autils.request_network(
1189 init_dut,
1190 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1191 init_ids[i], aconsts.DATA_PATH_INITIATOR, resp_mac,
1192 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001193
Jaineel7e67a3f2019-08-28 15:58:49 -07001194 # remove the first request (hopefully before completed) testing that NDP
1195 # is still created
1196 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_keys[0])
1197 resp_req_keys.remove(resp_req_keys[0])
1198 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_keys[0])
1199 init_req_keys.remove(init_req_keys[0])
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001200
Jaineel7e67a3f2019-08-28 15:58:49 -07001201 # wait for network formation for all initial requests
1202 # note: for IPv6 Init <--> Resp since each reports the other's IPv6 address
1203 # in it's transport-specific network info
1204 self.wait_for_request_responses(resp_dut, resp_req_keys,
1205 resp_aware_ifs, init_aware_ipv6)
1206 self.wait_for_request_responses(init_dut, init_req_keys,
1207 init_aware_ifs, resp_aware_ipv6)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001208
Jaineel7e67a3f2019-08-28 15:58:49 -07001209 # issue M more requests for the same NDPs - tests post-setup multiple NDP
1210 for i in range(M):
1211 # Responder: request network
1212 resp_req_keys.append(
1213 autils.request_network(
1214 resp_dut,
1215 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1216 resp_ids[N + i], aconsts.DATA_PATH_RESPONDER, init_mac,
1217 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001218
Jaineel7e67a3f2019-08-28 15:58:49 -07001219 # Initiator: request network
1220 init_req_keys.append(
1221 autils.request_network(
1222 init_dut,
1223 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1224 init_ids[N + i], aconsts.DATA_PATH_INITIATOR, resp_mac,
1225 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001226
Jaineel7e67a3f2019-08-28 15:58:49 -07001227 # wait for network formation for all subsequent requests
1228 self.wait_for_request_responses(resp_dut, resp_req_keys[N - 1:],
1229 resp_aware_ifs, init_aware_ipv6)
1230 self.wait_for_request_responses(init_dut, init_req_keys[N - 1:],
1231 init_aware_ifs, resp_aware_ipv6)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001232
Jaineel7e67a3f2019-08-28 15:58:49 -07001233 # determine whether all interfaces and ipv6 addresses are identical
1234 # (single NDP)
1235 init_aware_ifs = list(set(init_aware_ifs))
1236 resp_aware_ifs = list(set(resp_aware_ifs))
1237 init_aware_ipv6 = list(set(init_aware_ipv6))
1238 resp_aware_ipv6 = list(set(resp_aware_ipv6))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001239
Jaineel7e67a3f2019-08-28 15:58:49 -07001240 self.log.info("Interface names: I=%s, R=%s", init_aware_ifs,
1241 resp_aware_ifs)
1242 self.log.info("Interface IPv6: I=%s, R=%s", init_aware_ipv6,
1243 resp_aware_ipv6)
1244 self.log.info("Initiator requests: %s", init_req_keys)
1245 self.log.info("Responder requests: %s", resp_req_keys)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001246
Jaineel7e67a3f2019-08-28 15:58:49 -07001247 asserts.assert_equal(
1248 len(init_aware_ifs), 1, "Multiple initiator interfaces")
1249 asserts.assert_equal(
1250 len(resp_aware_ifs), 1, "Multiple responder interfaces")
1251 asserts.assert_equal(
1252 len(init_aware_ipv6), 1, "Multiple initiator IPv6 addresses")
1253 asserts.assert_equal(
1254 len(resp_aware_ipv6), 1, "Multiple responder IPv6 addresses")
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001255
Jaineel7e67a3f2019-08-28 15:58:49 -07001256 for i in range(
1257 init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]):
1258 # note: using get_ipv6_addr (ifconfig method) since want to verify
1259 # that interfaces which do not have any NDPs on them do not have
1260 # an IPv6 link-local address.
1261 if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
1262 init_ipv6 = autils.get_ipv6_addr(init_dut, if_name)
1263 resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001264
Jaineel7e67a3f2019-08-28 15:58:49 -07001265 asserts.assert_equal(
1266 init_ipv6 is None, if_name not in init_aware_ifs,
1267 "Initiator interface %s in unexpected state" % if_name)
1268 asserts.assert_equal(
1269 resp_ipv6 is None, if_name not in resp_aware_ifs,
1270 "Responder interface %s in unexpected state" % if_name)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001271
Jaineel7e67a3f2019-08-28 15:58:49 -07001272 # release requests
1273 for resp_req_key in resp_req_keys:
1274 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
1275 for init_req_key in init_req_keys:
1276 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001277
Jaineel7e67a3f2019-08-28 15:58:49 -07001278 def test_identical_network_from_both_sides(self):
1279 """Validate that requesting two identical NDPs (Open) each being initiated
Etan Cohenef38a7f2017-11-09 14:26:43 -08001280 from a different side, results in the same/single NDP.
1281
1282 Verify that the interface and IPv6 address is the same for all networks.
1283 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001284 dut1 = self.android_devices[0]
1285 dut2 = self.android_devices[1]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001286
Jaineel7e67a3f2019-08-28 15:58:49 -07001287 id1, mac1 = autils.attach_with_identity(dut1)
1288 id2, mac2 = autils.attach_with_identity(dut2)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001289
Jaineel7e67a3f2019-08-28 15:58:49 -07001290 # wait for for devices to synchronize with each other - there are no other
1291 # mechanisms to make sure this happens for OOB discovery (except retrying
1292 # to execute the data-path request)
1293 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001294
Jaineel7e67a3f2019-08-28 15:58:49 -07001295 # first NDP: DUT1 (Init) -> DUT2 (Resp)
1296 req_a_resp = autils.request_network(
1297 dut2,
1298 dut2.droid.wifiAwareCreateNetworkSpecifierOob(
1299 id2, aconsts.DATA_PATH_RESPONDER, mac1))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001300
Jaineel7e67a3f2019-08-28 15:58:49 -07001301 req_a_init = autils.request_network(
1302 dut1,
1303 dut1.droid.wifiAwareCreateNetworkSpecifierOob(
1304 id1, aconsts.DATA_PATH_INITIATOR, mac2))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001305
Jaineel7e67a3f2019-08-28 15:58:49 -07001306 req_a_resp_event_nc = autils.wait_for_event_with_keys(
1307 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1308 (cconsts.NETWORK_CB_KEY_EVENT,
1309 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1310 (cconsts.NETWORK_CB_KEY_ID, req_a_resp))
1311 req_a_init_event_nc = autils.wait_for_event_with_keys(
1312 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1313 (cconsts.NETWORK_CB_KEY_EVENT,
1314 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1315 (cconsts.NETWORK_CB_KEY_ID, req_a_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001316
Jaineel7e67a3f2019-08-28 15:58:49 -07001317 # validate no leak of information
1318 asserts.assert_false(
1319 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_a_resp_event_nc[
1320 "data"], "Network specifier leak!")
1321 asserts.assert_false(
1322 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_a_init_event_nc[
1323 "data"], "Network specifier leak!")
Etan Cohenef38a7f2017-11-09 14:26:43 -08001324
Jaineel7e67a3f2019-08-28 15:58:49 -07001325 # note that Init <-> Resp since IPv6 are of peer's!
1326 req_a_ipv6_init = req_a_resp_event_nc["data"][aconsts.NET_CAP_IPV6]
1327 req_a_ipv6_resp = req_a_init_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001328
Jaineel7e67a3f2019-08-28 15:58:49 -07001329 req_a_resp_event_lp = autils.wait_for_event_with_keys(
1330 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1331 (cconsts.NETWORK_CB_KEY_EVENT,
1332 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1333 (cconsts.NETWORK_CB_KEY_ID, req_a_resp))
1334 req_a_init_event_lp = autils.wait_for_event_with_keys(
1335 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1336 (cconsts.NETWORK_CB_KEY_EVENT,
1337 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1338 (cconsts.NETWORK_CB_KEY_ID, req_a_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001339
Jaineel7e67a3f2019-08-28 15:58:49 -07001340 req_a_if_resp = req_a_resp_event_lp["data"][
1341 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1342 req_a_if_init = req_a_init_event_lp["data"][
1343 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001344
Jaineel7e67a3f2019-08-28 15:58:49 -07001345 self.log.info("Interface names for A: I=%s, R=%s", req_a_if_init,
1346 req_a_if_resp)
1347 self.log.info("Interface addresses (IPv6) for A: I=%s, R=%s",
1348 req_a_ipv6_init, req_a_ipv6_resp)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001349
Jaineel7e67a3f2019-08-28 15:58:49 -07001350 # second NDP: DUT2 (Init) -> DUT1 (Resp)
1351 req_b_resp = autils.request_network(
1352 dut1,
1353 dut1.droid.wifiAwareCreateNetworkSpecifierOob(
1354 id1, aconsts.DATA_PATH_RESPONDER, mac2))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001355
Jaineel7e67a3f2019-08-28 15:58:49 -07001356 req_b_init = autils.request_network(
1357 dut2,
1358 dut2.droid.wifiAwareCreateNetworkSpecifierOob(
1359 id2, aconsts.DATA_PATH_INITIATOR, mac1))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001360
Jaineel7e67a3f2019-08-28 15:58:49 -07001361 req_b_resp_event_nc = autils.wait_for_event_with_keys(
1362 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1363 (cconsts.NETWORK_CB_KEY_EVENT,
1364 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1365 (cconsts.NETWORK_CB_KEY_ID, req_b_resp))
1366 req_b_init_event_nc = autils.wait_for_event_with_keys(
1367 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1368 (cconsts.NETWORK_CB_KEY_EVENT,
1369 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1370 (cconsts.NETWORK_CB_KEY_ID, req_b_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001371
Jaineel7e67a3f2019-08-28 15:58:49 -07001372 # validate no leak of information
1373 asserts.assert_false(
1374 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_b_resp_event_nc[
1375 "data"], "Network specifier leak!")
1376 asserts.assert_false(
1377 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_b_init_event_nc[
1378 "data"], "Network specifier leak!")
Etan Cohenef38a7f2017-11-09 14:26:43 -08001379
Jaineel7e67a3f2019-08-28 15:58:49 -07001380 # note that Init <-> Resp since IPv6 are of peer's!
1381 req_b_ipv6_init = req_b_resp_event_nc["data"][aconsts.NET_CAP_IPV6]
1382 req_b_ipv6_resp = req_b_init_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohena1e8d502017-08-16 09:28:18 -07001383
Jaineel7e67a3f2019-08-28 15:58:49 -07001384 req_b_resp_event_lp = autils.wait_for_event_with_keys(
1385 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1386 (cconsts.NETWORK_CB_KEY_EVENT,
1387 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1388 (cconsts.NETWORK_CB_KEY_ID, req_b_resp))
1389 req_b_init_event_lp = autils.wait_for_event_with_keys(
1390 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1391 (cconsts.NETWORK_CB_KEY_EVENT,
1392 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1393 (cconsts.NETWORK_CB_KEY_ID, req_b_init))
1394
1395 req_b_if_resp = req_b_resp_event_lp["data"][
1396 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1397 req_b_if_init = req_b_init_event_lp["data"][
1398 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1399
1400 self.log.info("Interface names for B: I=%s, R=%s", req_b_if_init,
1401 req_b_if_resp)
1402 self.log.info("Interface addresses (IPv6) for B: I=%s, R=%s",
1403 req_b_ipv6_init, req_b_ipv6_resp)
1404
1405 # validate equality of NDPs (using interface names & ipv6)
1406 asserts.assert_equal(req_a_if_init, req_b_if_resp,
1407 "DUT1 NDPs are on different interfaces")
1408 asserts.assert_equal(req_a_if_resp, req_b_if_init,
1409 "DUT2 NDPs are on different interfaces")
1410 asserts.assert_equal(req_a_ipv6_init, req_b_ipv6_resp,
1411 "DUT1 NDPs are using different IPv6 addresses")
1412 asserts.assert_equal(req_a_ipv6_resp, req_b_ipv6_init,
1413 "DUT2 NDPs are using different IPv6 addresses")
1414
1415 # release requests
1416 dut1.droid.connectivityUnregisterNetworkCallback(req_a_init)
1417 dut1.droid.connectivityUnregisterNetworkCallback(req_b_resp)
1418 dut2.droid.connectivityUnregisterNetworkCallback(req_a_resp)
1419 dut2.droid.connectivityUnregisterNetworkCallback(req_b_init)
1420
1421 ########################################################################
1422
1423 def run_multiple_ndi(self, sec_configs, flip_init_resp=False):
1424 """Validate that the device can create and use multiple NDIs.
Etan Cohena1e8d502017-08-16 09:28:18 -07001425
1426 The security configuration can be:
1427 - None: open
1428 - String: passphrase
1429 - otherwise: PMK (byte array)
1430
1431 Args:
1432 sec_configs: list of security configurations
Etan Cohend6923f22017-11-09 15:37:16 -08001433 flip_init_resp: if True the roles of Initiator and Responder are flipped
1434 between the 2 devices, otherwise same devices are always
1435 configured in the same role.
Etan Cohena1e8d502017-08-16 09:28:18 -07001436 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001437 dut1 = self.android_devices[0]
1438 dut2 = self.android_devices[1]
Etan Cohena1e8d502017-08-16 09:28:18 -07001439
Jaineel7e67a3f2019-08-28 15:58:49 -07001440 asserts.skip_if(
1441 dut1.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] <
1442 len(sec_configs)
1443 or dut2.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] <
1444 len(sec_configs), "DUTs do not support enough NDIs")
Etan Cohena1e8d502017-08-16 09:28:18 -07001445
Jaineel7e67a3f2019-08-28 15:58:49 -07001446 id1, mac1 = autils.attach_with_identity(dut1)
1447 id2, mac2 = autils.attach_with_identity(dut2)
Etan Cohena1e8d502017-08-16 09:28:18 -07001448
Jaineel7e67a3f2019-08-28 15:58:49 -07001449 # wait for for devices to synchronize with each other - there are no other
1450 # mechanisms to make sure this happens for OOB discovery (except retrying
1451 # to execute the data-path request)
1452 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohena1e8d502017-08-16 09:28:18 -07001453
Jaineel7e67a3f2019-08-28 15:58:49 -07001454 dut2_req_keys = []
1455 dut1_req_keys = []
1456 dut2_aware_ifs = []
1457 dut1_aware_ifs = []
1458 dut2_aware_ipv6s = []
1459 dut1_aware_ipv6s = []
Etan Cohena1e8d502017-08-16 09:28:18 -07001460
Jaineel7e67a3f2019-08-28 15:58:49 -07001461 dut2_type = aconsts.DATA_PATH_RESPONDER
1462 dut1_type = aconsts.DATA_PATH_INITIATOR
1463 dut2_is_responder = True
1464 for sec in sec_configs:
1465 if dut2_is_responder:
1466 # DUT2 (Responder): request network
1467 dut2_req_key = autils.request_network(
1468 dut2,
1469 autils.get_network_specifier(dut2, id2, dut2_type, mac1,
1470 sec))
1471 dut2_req_keys.append(dut2_req_key)
Etan Cohena1e8d502017-08-16 09:28:18 -07001472
Jaineel7e67a3f2019-08-28 15:58:49 -07001473 # DUT1 (Initiator): request network
1474 dut1_req_key = autils.request_network(
1475 dut1,
1476 autils.get_network_specifier(dut1, id1, dut1_type, mac2,
1477 sec))
1478 dut1_req_keys.append(dut1_req_key)
1479 else:
1480 # DUT1 (Responder): request network
1481 dut1_req_key = autils.request_network(
1482 dut1,
1483 autils.get_network_specifier(dut1, id1, dut1_type, mac2,
1484 sec))
1485 dut1_req_keys.append(dut1_req_key)
Etan Cohend6923f22017-11-09 15:37:16 -08001486
Jaineel7e67a3f2019-08-28 15:58:49 -07001487 # DUT2 (Initiator): request network
1488 dut2_req_key = autils.request_network(
1489 dut2,
1490 autils.get_network_specifier(dut2, id2, dut2_type, mac1,
1491 sec))
1492 dut2_req_keys.append(dut2_req_key)
Etan Cohena1e8d502017-08-16 09:28:18 -07001493
Jaineel7e67a3f2019-08-28 15:58:49 -07001494 # Wait for network
1495 dut1_net_event_nc = autils.wait_for_event_with_keys(
1496 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1497 (cconsts.NETWORK_CB_KEY_EVENT,
1498 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1499 (cconsts.NETWORK_CB_KEY_ID, dut1_req_key))
1500 dut2_net_event_nc = autils.wait_for_event_with_keys(
1501 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1502 (cconsts.NETWORK_CB_KEY_EVENT,
1503 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1504 (cconsts.NETWORK_CB_KEY_ID, dut2_req_key))
Etan Cohena1e8d502017-08-16 09:28:18 -07001505
Jaineel7e67a3f2019-08-28 15:58:49 -07001506 # validate no leak of information
1507 asserts.assert_false(
1508 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in dut1_net_event_nc[
1509 "data"], "Network specifier leak!")
1510 asserts.assert_false(
1511 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in dut2_net_event_nc[
1512 "data"], "Network specifier leak!")
Etan Cohena1e8d502017-08-16 09:28:18 -07001513
Jaineel7e67a3f2019-08-28 15:58:49 -07001514 # Note: dut1 <--> dut2 IPv6's addresses since it is peer's info
1515 dut2_aware_ipv6 = dut1_net_event_nc["data"][aconsts.NET_CAP_IPV6]
1516 dut1_aware_ipv6 = dut2_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohend6923f22017-11-09 15:37:16 -08001517
Jaineel7e67a3f2019-08-28 15:58:49 -07001518 dut1_net_event_lp = autils.wait_for_event_with_keys(
1519 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1520 (cconsts.NETWORK_CB_KEY_EVENT,
1521 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1522 (cconsts.NETWORK_CB_KEY_ID, dut1_req_key))
1523 dut2_net_event_lp = autils.wait_for_event_with_keys(
1524 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1525 (cconsts.NETWORK_CB_KEY_EVENT,
1526 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1527 (cconsts.NETWORK_CB_KEY_ID, dut2_req_key))
Etan Cohena1e8d502017-08-16 09:28:18 -07001528
Jaineel7e67a3f2019-08-28 15:58:49 -07001529 dut2_aware_if = dut2_net_event_lp["data"][
1530 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1531 dut1_aware_if = dut1_net_event_lp["data"][
1532 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohena1e8d502017-08-16 09:28:18 -07001533
Jaineel7e67a3f2019-08-28 15:58:49 -07001534 dut2_aware_ifs.append(dut2_aware_if)
1535 dut1_aware_ifs.append(dut1_aware_if)
1536 dut2_aware_ipv6s.append(dut2_aware_ipv6)
1537 dut1_aware_ipv6s.append(dut1_aware_ipv6)
Etan Cohena1e8d502017-08-16 09:28:18 -07001538
Jaineel7e67a3f2019-08-28 15:58:49 -07001539 if flip_init_resp:
1540 if dut2_is_responder:
1541 dut2_type = aconsts.DATA_PATH_INITIATOR
1542 dut1_type = aconsts.DATA_PATH_RESPONDER
1543 else:
1544 dut2_type = aconsts.DATA_PATH_RESPONDER
1545 dut1_type = aconsts.DATA_PATH_INITIATOR
1546 dut2_is_responder = not dut2_is_responder
Etan Cohena1e8d502017-08-16 09:28:18 -07001547
Jaineel7e67a3f2019-08-28 15:58:49 -07001548 # check that we are using 2 NDIs & that they have unique IPv6 addresses
1549 dut1_aware_ifs = list(set(dut1_aware_ifs))
1550 dut2_aware_ifs = list(set(dut2_aware_ifs))
1551 dut1_aware_ipv6s = list(set(dut1_aware_ipv6s))
1552 dut2_aware_ipv6s = list(set(dut2_aware_ipv6s))
Etan Cohena1e8d502017-08-16 09:28:18 -07001553
Jaineel7e67a3f2019-08-28 15:58:49 -07001554 self.log.info("Interface names: DUT1=%s, DUT2=%s", dut1_aware_ifs,
1555 dut2_aware_ifs)
1556 self.log.info("IPv6 addresses: DUT1=%s, DUT2=%s", dut1_aware_ipv6s,
1557 dut2_aware_ipv6s)
1558 self.log.info("DUT1 requests: %s", dut1_req_keys)
1559 self.log.info("DUT2 requests: %s", dut2_req_keys)
Etan Cohena1e8d502017-08-16 09:28:18 -07001560
Jaineel7e67a3f2019-08-28 15:58:49 -07001561 asserts.assert_equal(
1562 len(dut1_aware_ifs), len(sec_configs), "Multiple DUT1 interfaces")
1563 asserts.assert_equal(
1564 len(dut2_aware_ifs), len(sec_configs), "Multiple DUT2 interfaces")
1565 asserts.assert_equal(
1566 len(dut1_aware_ipv6s), len(sec_configs),
1567 "Multiple DUT1 IPv6 addresses")
1568 asserts.assert_equal(
1569 len(dut2_aware_ipv6s), len(sec_configs),
1570 "Multiple DUT2 IPv6 addresses")
1571
1572 for i in range(len(sec_configs)):
1573 # note: using get_ipv6_addr (ifconfig method) since want to verify
1574 # that the system information is the same as the reported information
1575 if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
1576 dut1_ipv6 = autils.get_ipv6_addr(dut1, if_name)
1577 dut2_ipv6 = autils.get_ipv6_addr(dut2, if_name)
1578
1579 asserts.assert_equal(
1580 dut1_ipv6 is None, if_name not in dut1_aware_ifs,
1581 "DUT1 interface %s in unexpected state" % if_name)
1582 asserts.assert_equal(
1583 dut2_ipv6 is None, if_name not in dut2_aware_ifs,
1584 "DUT2 interface %s in unexpected state" % if_name)
1585
1586 # release requests
1587 for dut2_req_key in dut2_req_keys:
1588 dut2.droid.connectivityUnregisterNetworkCallback(dut2_req_key)
1589 for dut1_req_key in dut1_req_keys:
1590 dut1.droid.connectivityUnregisterNetworkCallback(dut1_req_key)
1591
1592 @test_tracker_info(uuid="2d728163-11cc-46ba-a973-c8e1e71397fc")
1593 def test_multiple_ndi_open_passphrase(self):
1594 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001595 configuration (one open, one using passphrase). The result should use two
1596 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001597 self.run_multiple_ndi([None, self.PASSPHRASE])
Etan Cohena1e8d502017-08-16 09:28:18 -07001598
Jaineel7e67a3f2019-08-28 15:58:49 -07001599 @test_tracker_info(uuid="5f2c32aa-20b2-41f0-8b1e-d0b68df73ada")
1600 def test_multiple_ndi_open_pmk(self):
1601 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001602 configuration (one open, one using pmk). The result should use two
1603 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001604 self.run_multiple_ndi([None, self.PMK])
Etan Cohena1e8d502017-08-16 09:28:18 -07001605
Jaineel7e67a3f2019-08-28 15:58:49 -07001606 @test_tracker_info(uuid="34467659-bcfb-40cd-ba25-7e50560fca63")
1607 def test_multiple_ndi_passphrase_pmk(self):
1608 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001609 configuration (one using passphrase, one using pmk). The result should use
1610 two different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001611 self.run_multiple_ndi([self.PASSPHRASE, self.PMK])
Etan Cohena1e8d502017-08-16 09:28:18 -07001612
Jaineel7e67a3f2019-08-28 15:58:49 -07001613 @test_tracker_info(uuid="d9194ce6-45b6-41b1-9cc8-ada79968966d")
1614 def test_multiple_ndi_passphrases(self):
1615 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001616 configuration (using different passphrases). The result should use two
1617 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001618 self.run_multiple_ndi([self.PASSPHRASE, self.PASSPHRASE2])
Etan Cohena1e8d502017-08-16 09:28:18 -07001619
Jaineel7e67a3f2019-08-28 15:58:49 -07001620 @test_tracker_info(uuid="879df795-62d2-40d4-a862-bd46d8f7e67f")
1621 def test_multiple_ndi_pmks(self):
1622 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001623 configuration (using different PMKS). The result should use two different
1624 NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001625 self.run_multiple_ndi([self.PMK, self.PMK2])
Etan Cohend6923f22017-11-09 15:37:16 -08001626
Jaineel7e67a3f2019-08-28 15:58:49 -07001627 @test_tracker_info(uuid="397d380a-8e41-466e-9ccb-cf8f413d83ba")
1628 def test_multiple_ndi_open_passphrase_flip(self):
1629 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001630 configuration (one open, one using passphrase). The result should use two
1631 different NDIs.
1632
1633 Flip Initiator and Responder roles.
1634 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001635 self.run_multiple_ndi([None, self.PASSPHRASE], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001636
Jaineel7e67a3f2019-08-28 15:58:49 -07001637 @test_tracker_info(uuid="b3a4300b-1514-4cb8-a814-9c2baa449700")
1638 def test_multiple_ndi_open_pmk_flip(self):
1639 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001640 configuration (one open, one using pmk). The result should use two
1641 different NDIs
1642
1643 Flip Initiator and Responder roles.
1644 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001645 self.run_multiple_ndi([None, self.PMK], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001646
Jaineel7e67a3f2019-08-28 15:58:49 -07001647 @test_tracker_info(uuid="0bfea9e4-e57d-417f-8db4-245741e9bbd5")
1648 def test_multiple_ndi_passphrase_pmk_flip(self):
1649 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001650 configuration (one using passphrase, one using pmk). The result should use
1651 two different NDIs
1652
1653 Flip Initiator and Responder roles.
1654 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001655 self.run_multiple_ndi([self.PASSPHRASE, self.PMK], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001656
Jaineel7e67a3f2019-08-28 15:58:49 -07001657 @test_tracker_info(uuid="74023483-5417-431b-a362-991ad4a03ab8")
1658 def test_multiple_ndi_passphrases_flip(self):
1659 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001660 configuration (using different passphrases). The result should use two
1661 different NDIs
1662
1663 Flip Initiator and Responder roles.
1664 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001665 self.run_multiple_ndi(
1666 [self.PASSPHRASE, self.PASSPHRASE2], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001667
Jaineel7e67a3f2019-08-28 15:58:49 -07001668 @test_tracker_info(uuid="873b2d91-28a1-403f-ae9c-d756bb2f59ee")
1669 def test_multiple_ndi_pmks_flip(self):
1670 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001671 configuration (using different PMKS). The result should use two different
1672 NDIs
1673
1674 Flip Initiator and Responder roles.
1675 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001676 self.run_multiple_ndi([self.PMK, self.PMK2], flip_init_resp=True)
Etan Cohen7922a312018-01-23 13:34:55 -08001677
Jaineel7e67a3f2019-08-28 15:58:49 -07001678 #######################################
Etan Cohen7922a312018-01-23 13:34:55 -08001679
Jaineel7e67a3f2019-08-28 15:58:49 -07001680 @test_tracker_info(uuid="2f10a9df-7fbd-490d-a238-3523f47ab54c")
1681 def test_ib_responder_any_usage(self):
1682 """Verify that configuring an in-band (Aware discovery) Responder to receive
Etan Cohen7922a312018-01-23 13:34:55 -08001683 an NDP request from any peer is not permitted by current API level. Override
1684 API check to validate that possible (i.e. that failure at current API level
1685 is due to an API check and not some underlying failure).
1686 """
1687
Jaineel7e67a3f2019-08-28 15:58:49 -07001688 # configure all devices to override API check and allow a Responder from ANY
1689 for ad in self.android_devices:
1690 autils.configure_ndp_allow_any_override(ad, True)
1691 self.run_ib_data_path_test(
1692 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1693 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1694 encr_type=self.ENCR_TYPE_OPEN,
1695 use_peer_id=False)
Etan Cohen7922a312018-01-23 13:34:55 -08001696
Jaineel7e67a3f2019-08-28 15:58:49 -07001697 # configure all devices to respect API check - i.e. disallow a Responder
1698 # from ANY
1699 for ad in self.android_devices:
1700 autils.configure_ndp_allow_any_override(ad, False)
1701 self.run_ib_data_path_test(
1702 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1703 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1704 encr_type=self.ENCR_TYPE_OPEN,
1705 use_peer_id=False,
1706 expect_failure=True)
Etan Cohen7922a312018-01-23 13:34:55 -08001707
Jaineel7e67a3f2019-08-28 15:58:49 -07001708 @test_tracker_info(uuid="5889cd41-0a72-4b7b-ab82-5b9168b9b5b8")
1709 def test_oob_responder_any_usage(self):
1710 """Verify that configuring an out-of-band (Aware discovery) Responder to
Etan Cohen7922a312018-01-23 13:34:55 -08001711 receive an NDP request from any peer is not permitted by current API level.
1712 Override API check to validate that possible (i.e. that failure at current
1713 API level is due to an API check and not some underlying failure).
1714 """
1715
Jaineel7e67a3f2019-08-28 15:58:49 -07001716 # configure all devices to override API check and allow a Responder from ANY
1717 for ad in self.android_devices:
1718 autils.configure_ndp_allow_any_override(ad, True)
1719 self.run_oob_data_path_test(
1720 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False)
Etan Cohen7922a312018-01-23 13:34:55 -08001721
Jaineel7e67a3f2019-08-28 15:58:49 -07001722 # configure all devices to respect API check - i.e. disallow a Responder
1723 # from ANY
1724 for ad in self.android_devices:
1725 autils.configure_ndp_allow_any_override(ad, False)
1726 self.run_oob_data_path_test(
1727 encr_type=self.ENCR_TYPE_OPEN,
1728 use_peer_id=False,
1729 expect_failure=True)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001730
Jaineel7e67a3f2019-08-28 15:58:49 -07001731 #######################################
Etan Cohenc803dcc2018-02-02 15:14:04 -08001732
Jaineel7e67a3f2019-08-28 15:58:49 -07001733 def run_multiple_regulatory_domains(self, use_ib, init_domain,
1734 resp_domain):
1735 """Verify that a data-path setup with two conflicting regulatory domains
Etan Cohenc803dcc2018-02-02 15:14:04 -08001736 works (the result should be run in Channel 6 - but that is not tested).
1737
1738 Args:
1739 use_ib: True to use in-band discovery, False to use out-of-band discovery.
1740 init_domain: The regulatory domain of the Initiator/Subscriber.
1741 resp_domain: The regulator domain of the Responder/Publisher.
1742 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001743 init_dut = self.android_devices[0]
1744 resp_dut = self.android_devices[1]
Etan Cohenc803dcc2018-02-02 15:14:04 -08001745
Jaineel7e67a3f2019-08-28 15:58:49 -07001746 init_dut.droid.wifiSetCountryCode(init_domain)
1747 resp_dut.droid.wifiSetCountryCode(resp_domain)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001748
Jaineel7e67a3f2019-08-28 15:58:49 -07001749 if use_ib:
1750 (resp_req_key, init_req_key, resp_aware_if, init_aware_if,
1751 resp_ipv6, init_ipv6) = autils.create_ib_ndp(
1752 resp_dut, init_dut,
1753 autils.create_discovery_config(
1754 "GoogleTestXyz", aconsts.PUBLISH_TYPE_UNSOLICITED),
1755 autils.create_discovery_config(
1756 "GoogleTestXyz", aconsts.SUBSCRIBE_TYPE_PASSIVE),
1757 self.device_startup_offset)
1758 else:
1759 (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
1760 init_ipv6, resp_ipv6) = autils.create_oob_ndp(init_dut, resp_dut)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001761
Jaineel7e67a3f2019-08-28 15:58:49 -07001762 self.log.info("Interface names: I=%s, R=%s", init_aware_if,
1763 resp_aware_if)
1764 self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
1765 resp_ipv6)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001766
Jaineel7e67a3f2019-08-28 15:58:49 -07001767 # clean-up
1768 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
1769 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001770
Jaineel7e67a3f2019-08-28 15:58:49 -07001771 @test_tracker_info(uuid="eff53739-35c5-47a6-81f0-d70b51d89c3b")
1772 def test_multiple_regulator_domains_ib_us_jp(self):
1773 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001774
1775 - Uses in-band discovery
1776 - Subscriber=US, Publisher=JP
1777 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001778 self.run_multiple_regulatory_domains(
1779 use_ib=True,
1780 init_domain=wutils.WifiEnums.CountryCode.US,
1781 resp_domain=wutils.WifiEnums.CountryCode.JAPAN)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001782
Jaineel7e67a3f2019-08-28 15:58:49 -07001783 @test_tracker_info(uuid="19af47cc-3204-40ef-b50f-14cf7b89cf4a")
1784 def test_multiple_regulator_domains_ib_jp_us(self):
1785 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001786
1787 - Uses in-band discovery
1788 - Subscriber=JP, Publisher=US
1789 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001790 self.run_multiple_regulatory_domains(
1791 use_ib=True,
1792 init_domain=wutils.WifiEnums.CountryCode.JAPAN,
1793 resp_domain=wutils.WifiEnums.CountryCode.US)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001794
Jaineel7e67a3f2019-08-28 15:58:49 -07001795 @test_tracker_info(uuid="65285ab3-977f-4dbd-b663-d5a02f4fc663")
1796 def test_multiple_regulator_domains_oob_us_jp(self):
1797 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001798
1799 - Uses out-f-band discovery
1800 - Initiator=US, Responder=JP
1801 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001802 self.run_multiple_regulatory_domains(
1803 use_ib=False,
1804 init_domain=wutils.WifiEnums.CountryCode.US,
1805 resp_domain=wutils.WifiEnums.CountryCode.JAPAN)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001806
Jaineel7e67a3f2019-08-28 15:58:49 -07001807 @test_tracker_info(uuid="8a417e24-aaf6-44b9-a089-a07c3ba8d954")
1808 def test_multiple_regulator_domains_oob_jp_us(self):
1809 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001810
1811 - Uses out-of-band discovery
1812 - Initiator=JP, Responder=US
1813 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001814 self.run_multiple_regulatory_domains(
1815 use_ib=False,
1816 init_domain=wutils.WifiEnums.CountryCode.JAPAN,
1817 resp_domain=wutils.WifiEnums.CountryCode.US)
Etan Cohen0ead4552017-12-27 16:17:50 -08001818
Jaineel7e67a3f2019-08-28 15:58:49 -07001819 ########################################################################
Etan Cohen0ead4552017-12-27 16:17:50 -08001820
Jaineel7e67a3f2019-08-28 15:58:49 -07001821 def run_mix_ib_oob(self, same_request, ib_first, inits_on_same_dut):
1822 """Validate that multiple network requests issued using both in-band and
Etan Cohen0ead4552017-12-27 16:17:50 -08001823 out-of-band discovery behave as expected.
1824
1825 The same_request parameter controls whether identical single NDP is
1826 expected, if True, or whether multiple NDPs on different NDIs are expected,
1827 if False.
1828
1829 Args:
1830 same_request: Issue canonically identical requests (same NMI peer, same
1831 passphrase) if True, if False use different passphrases.
1832 ib_first: If True then the in-band network is requested first, otherwise
1833 (if False) then the out-of-band network is requested first.
1834 inits_on_same_dut: If True then the Initiators are run on the same device,
1835 otherwise (if False) then the Initiators are run on
1836 different devices. Note that Subscribe == Initiator.
1837 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001838 if not same_request:
1839 asserts.skip_if(
1840 self.android_devices[0]
1841 .aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < 2
1842 or self.android_devices[1]
1843 .aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < 2,
1844 "DUTs do not support enough NDIs")
Etan Cohen0ead4552017-12-27 16:17:50 -08001845
Jaineel7e67a3f2019-08-28 15:58:49 -07001846 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
1847 peer_id_on_pub_null) = self.set_up_discovery(
1848 aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE,
1849 False)
Etan Cohen0ead4552017-12-27 16:17:50 -08001850
Jaineel7e67a3f2019-08-28 15:58:49 -07001851 p_id2, p_mac = autils.attach_with_identity(p_dut)
1852 s_id2, s_mac = autils.attach_with_identity(s_dut)
Etan Cohen0ead4552017-12-27 16:17:50 -08001853
Jaineel7e67a3f2019-08-28 15:58:49 -07001854 if inits_on_same_dut:
1855 resp_dut = p_dut
1856 resp_id = p_id2
1857 resp_mac = p_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001858
Jaineel7e67a3f2019-08-28 15:58:49 -07001859 init_dut = s_dut
1860 init_id = s_id2
1861 init_mac = s_mac
1862 else:
1863 resp_dut = s_dut
1864 resp_id = s_id2
1865 resp_mac = s_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001866
Jaineel7e67a3f2019-08-28 15:58:49 -07001867 init_dut = p_dut
1868 init_id = p_id2
1869 init_mac = p_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001870
Jaineel7e67a3f2019-08-28 15:58:49 -07001871 passphrase = None if same_request else self.PASSPHRASE
Etan Cohen0ead4552017-12-27 16:17:50 -08001872
Jaineel7e67a3f2019-08-28 15:58:49 -07001873 if ib_first:
1874 # request in-band network (to completion)
1875 p_req_key = self.request_network(
1876 p_dut,
1877 p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, None))
1878 s_req_key = self.request_network(
1879 s_dut,
1880 s_dut.droid.wifiAwareCreateNetworkSpecifier(
1881 s_disc_id, peer_id_on_sub))
Etan Cohen0ead4552017-12-27 16:17:50 -08001882
Jaineel7e67a3f2019-08-28 15:58:49 -07001883 # Publisher & Subscriber: wait for network formation
1884 p_net_event_nc = autils.wait_for_event_with_keys(
1885 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1886 autils.EVENT_NDP_TIMEOUT,
1887 (cconsts.NETWORK_CB_KEY_EVENT,
1888 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1889 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1890 s_net_event_nc = autils.wait_for_event_with_keys(
1891 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1892 autils.EVENT_NDP_TIMEOUT,
1893 (cconsts.NETWORK_CB_KEY_EVENT,
1894 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1895 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
1896 p_net_event_lp = autils.wait_for_event_with_keys(
1897 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1898 autils.EVENT_NDP_TIMEOUT,
1899 (cconsts.NETWORK_CB_KEY_EVENT,
1900 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1901 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1902 s_net_event_lp = autils.wait_for_event_with_keys(
1903 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1904 autils.EVENT_NDP_TIMEOUT,
1905 (cconsts.NETWORK_CB_KEY_EVENT,
1906 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1907 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08001908
Jaineel7e67a3f2019-08-28 15:58:49 -07001909 # validate no leak of information
1910 asserts.assert_false(
1911 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
1912 "data"], "Network specifier leak!")
1913 asserts.assert_false(
1914 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
1915 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08001916
Jaineel7e67a3f2019-08-28 15:58:49 -07001917 # request out-of-band network
1918 resp_req_key = autils.request_network(
1919 resp_dut,
1920 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1921 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, passphrase))
1922 init_req_key = autils.request_network(
1923 init_dut,
1924 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1925 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase))
Etan Cohen0ead4552017-12-27 16:17:50 -08001926
Jaineel7e67a3f2019-08-28 15:58:49 -07001927 resp_net_event_nc = autils.wait_for_event_with_keys(
1928 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1929 (cconsts.NETWORK_CB_KEY_EVENT,
1930 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1931 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
1932 init_net_event_nc = autils.wait_for_event_with_keys(
1933 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1934 (cconsts.NETWORK_CB_KEY_EVENT,
1935 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1936 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
1937 resp_net_event_lp = autils.wait_for_event_with_keys(
1938 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1939 (cconsts.NETWORK_CB_KEY_EVENT,
1940 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1941 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
1942 init_net_event_lp = autils.wait_for_event_with_keys(
1943 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1944 (cconsts.NETWORK_CB_KEY_EVENT,
1945 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1946 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08001947
Jaineel7e67a3f2019-08-28 15:58:49 -07001948 # validate no leak of information
1949 asserts.assert_false(
1950 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in resp_net_event_nc[
1951 "data"], "Network specifier leak!")
1952 asserts.assert_false(
1953 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in init_net_event_nc[
1954 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08001955
Jaineel7e67a3f2019-08-28 15:58:49 -07001956 if not ib_first:
1957 # request in-band network (to completion)
1958 p_req_key = self.request_network(
1959 p_dut,
1960 p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, None))
1961 s_req_key = self.request_network(
1962 s_dut,
1963 s_dut.droid.wifiAwareCreateNetworkSpecifier(
1964 s_disc_id, peer_id_on_sub))
Etan Cohen0ead4552017-12-27 16:17:50 -08001965
Jaineel7e67a3f2019-08-28 15:58:49 -07001966 # Publisher & Subscriber: wait for network formation
1967 p_net_event_nc = autils.wait_for_event_with_keys(
1968 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1969 autils.EVENT_NDP_TIMEOUT,
1970 (cconsts.NETWORK_CB_KEY_EVENT,
1971 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1972 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1973 s_net_event_nc = autils.wait_for_event_with_keys(
1974 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1975 autils.EVENT_NDP_TIMEOUT,
1976 (cconsts.NETWORK_CB_KEY_EVENT,
1977 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1978 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
1979 p_net_event_lp = autils.wait_for_event_with_keys(
1980 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1981 autils.EVENT_NDP_TIMEOUT,
1982 (cconsts.NETWORK_CB_KEY_EVENT,
1983 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1984 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1985 s_net_event_lp = autils.wait_for_event_with_keys(
1986 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1987 autils.EVENT_NDP_TIMEOUT,
1988 (cconsts.NETWORK_CB_KEY_EVENT,
1989 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1990 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08001991
Jaineel7e67a3f2019-08-28 15:58:49 -07001992 # validate no leak of information
1993 asserts.assert_false(
1994 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
1995 "data"], "Network specifier leak!")
1996 asserts.assert_false(
1997 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
1998 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08001999
Jaineel7e67a3f2019-08-28 15:58:49 -07002000 # note that Init <-> Resp & Pub <--> Sub since IPv6 are of peer's!
2001 init_ipv6 = resp_net_event_nc["data"][aconsts.NET_CAP_IPV6]
2002 resp_ipv6 = init_net_event_nc["data"][aconsts.NET_CAP_IPV6]
2003 pub_ipv6 = s_net_event_nc["data"][aconsts.NET_CAP_IPV6]
2004 sub_ipv6 = p_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohen0ead4552017-12-27 16:17:50 -08002005
Jaineel7e67a3f2019-08-28 15:58:49 -07002006 # extract net info
2007 pub_interface = p_net_event_lp["data"][
2008 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2009 sub_interface = s_net_event_lp["data"][
2010 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2011 resp_interface = resp_net_event_lp["data"][
2012 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2013 init_interface = init_net_event_lp["data"][
2014 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohen0ead4552017-12-27 16:17:50 -08002015
Jaineel7e67a3f2019-08-28 15:58:49 -07002016 self.log.info("Interface names: Pub=%s, Sub=%s, Resp=%s, Init=%s",
2017 pub_interface, sub_interface, resp_interface,
2018 init_interface)
2019 self.log.info(
2020 "Interface addresses (IPv6): Pub=%s, Sub=%s, Resp=%s, Init=%s",
2021 pub_ipv6, sub_ipv6, resp_ipv6, init_ipv6)
Etan Cohen0ead4552017-12-27 16:17:50 -08002022
Jaineel7e67a3f2019-08-28 15:58:49 -07002023 # validate NDP/NDI conditions (using interface names & ipv6)
2024 if same_request:
2025 asserts.assert_equal(
2026 pub_interface, resp_interface if inits_on_same_dut else
2027 init_interface, "NDP interfaces don't match on Pub/other")
2028 asserts.assert_equal(
2029 sub_interface, init_interface if inits_on_same_dut else
2030 resp_interface, "NDP interfaces don't match on Sub/other")
Etan Cohen0ead4552017-12-27 16:17:50 -08002031
Jaineel7e67a3f2019-08-28 15:58:49 -07002032 asserts.assert_equal(pub_ipv6, resp_ipv6
2033 if inits_on_same_dut else init_ipv6,
2034 "NDP IPv6 don't match on Pub/other")
2035 asserts.assert_equal(sub_ipv6, init_ipv6
2036 if inits_on_same_dut else resp_ipv6,
2037 "NDP IPv6 don't match on Sub/other")
2038 else:
2039 asserts.assert_false(
2040 pub_interface == (resp_interface
2041 if inits_on_same_dut else init_interface),
2042 "NDP interfaces match on Pub/other")
2043 asserts.assert_false(
2044 sub_interface == (init_interface
2045 if inits_on_same_dut else resp_interface),
2046 "NDP interfaces match on Sub/other")
Etan Cohen0ead4552017-12-27 16:17:50 -08002047
Jaineel7e67a3f2019-08-28 15:58:49 -07002048 asserts.assert_false(
2049 pub_ipv6 == (resp_ipv6 if inits_on_same_dut else init_ipv6),
2050 "NDP IPv6 match on Pub/other")
2051 asserts.assert_false(
2052 sub_ipv6 == (init_ipv6 if inits_on_same_dut else resp_ipv6),
2053 "NDP IPv6 match on Sub/other")
2054
2055 # release requests
2056 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
2057 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
2058 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
2059 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
2060
2061 @test_tracker_info(uuid="d8a0839d-4ba0-43f2-af93-3cf1382f9f16")
2062 def test_identical_ndps_mix_ib_oob_ib_first_same_polarity(self):
2063 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002064 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2065
2066 The in-band request is issued first. Both Initiators (Sub == Initiator) are
2067 run on the same device.
2068 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002069 self.run_mix_ib_oob(
2070 same_request=True, ib_first=True, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002071
Jaineel7e67a3f2019-08-28 15:58:49 -07002072 @test_tracker_info(uuid="70bbb811-0bed-4a19-96b3-f2446e777c8a")
2073 def test_identical_ndps_mix_ib_oob_oob_first_same_polarity(self):
2074 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002075 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2076
2077 The out-of-band request is issued first. Both Initiators (Sub == Initiator)
2078 are run on the same device.
2079 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002080 self.run_mix_ib_oob(
2081 same_request=True, ib_first=False, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002082
Jaineel7e67a3f2019-08-28 15:58:49 -07002083 @test_tracker_info(uuid="d9796da5-f96a-4a51-be0f-89d6f5bfe3ad")
2084 def test_identical_ndps_mix_ib_oob_ib_first_diff_polarity(self):
2085 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002086 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2087
2088 The in-band request is issued first. Initiators (Sub == Initiator) are
2089 run on different devices.
2090 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002091 self.run_mix_ib_oob(
2092 same_request=True, ib_first=True, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002093
Jaineel7e67a3f2019-08-28 15:58:49 -07002094 @test_tracker_info(uuid="72b16cbf-53ad-4f98-8dcf-a8cc5fa812e3")
2095 def test_identical_ndps_mix_ib_oob_oob_first_diff_polarity(self):
2096 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002097 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2098
2099 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2100 run on different devices.
2101 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002102 self.run_mix_ib_oob(
2103 same_request=True, ib_first=False, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002104
Jaineel7e67a3f2019-08-28 15:58:49 -07002105 @test_tracker_info(uuid="51f9581e-c5ee-48a7-84d2-adff4876c3d7")
2106 def test_multiple_ndis_mix_ib_oob_ib_first_same_polarity(self):
2107 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002108 different security configurations. Use a mix of in-band and out-of-band APIs
2109 to request the different NDPs.
2110
2111 The in-band request is issued first. Initiators (Sub == Initiator) are
2112 run on the same device.
2113 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002114 self.run_mix_ib_oob(
2115 same_request=False, ib_first=True, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002116
Jaineel7e67a3f2019-08-28 15:58:49 -07002117 @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853")
2118 def test_multiple_ndis_mix_ib_oob_oob_first_same_polarity(self):
2119 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002120 different security configurations. Use a mix of in-band and out-of-band APIs
2121 to request the different NDPs.
2122
2123 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2124 run on the same device.
2125 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002126 self.run_mix_ib_oob(
2127 same_request=False, ib_first=False, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002128
Jaineel7e67a3f2019-08-28 15:58:49 -07002129 @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853")
2130 def test_multiple_ndis_mix_ib_oob_ib_first_diff_polarity(self):
2131 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002132 different security configurations. Use a mix of in-band and out-of-band APIs
2133 to request the different NDPs.
2134
2135 The in-band request is issued first. Initiators (Sub == Initiator) are
2136 run on different devices.
2137 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002138 self.run_mix_ib_oob(
2139 same_request=False, ib_first=True, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002140
Jaineel7e67a3f2019-08-28 15:58:49 -07002141 @test_tracker_info(uuid="596caadf-028e-494b-bbce-8304ccec2cbb")
2142 def test_multiple_ndis_mix_ib_oob_oob_first_diff_polarity(self):
2143 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002144 different security configurations. Use a mix of in-band and out-of-band APIs
2145 to request the different NDPs.
2146
2147 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2148 run on different devices.
2149 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002150 self.run_mix_ib_oob(
2151 same_request=False, ib_first=False, inits_on_same_dut=False)
Etan Cohendbb49c92018-04-19 15:32:38 -07002152
Jaineel7e67a3f2019-08-28 15:58:49 -07002153 ########################################################################
Etan Cohendbb49c92018-04-19 15:32:38 -07002154
Jaineel7e67a3f2019-08-28 15:58:49 -07002155 def test_ndp_loop(self):
2156 """Validate that can create a loop (chain) of N NDPs between N devices,
Etan Cohendbb49c92018-04-19 15:32:38 -07002157 where N >= 3, e.g.
2158
2159 A - B
2160 B - C
2161 C - A
2162
2163 The NDPs are all OPEN (no encryption).
2164 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002165 asserts.assert_true(
2166 len(self.android_devices) >= 3,
2167 'A minimum of 3 devices is needed to run the test, have %d' % len(
2168 self.android_devices))
Etan Cohendbb49c92018-04-19 15:32:38 -07002169
Jaineel7e67a3f2019-08-28 15:58:49 -07002170 duts = self.android_devices
2171 loop_len = len(duts)
2172 ids = []
2173 macs = []
2174 reqs = []
2175 ifs = []
2176 ipv6s = []
Etan Cohendbb49c92018-04-19 15:32:38 -07002177
Jaineel7e67a3f2019-08-28 15:58:49 -07002178 for i in range(loop_len):
2179 duts[i].pretty_name = chr(ord("A") + i)
2180 reqs.append([])
2181 ifs.append([])
2182 ipv6s.append([])
Etan Cohendbb49c92018-04-19 15:32:38 -07002183
Jaineel7e67a3f2019-08-28 15:58:49 -07002184 # start-up 3 devices (attach w/ identity)
2185 for i in range(loop_len):
2186 ids.append(duts[i].droid.wifiAwareAttach(True))
2187 autils.wait_for_event(duts[i], aconsts.EVENT_CB_ON_ATTACHED)
2188 ident_event = autils.wait_for_event(
2189 duts[i], aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
2190 macs.append(ident_event['data']['mac'])
Etan Cohendbb49c92018-04-19 15:32:38 -07002191
Jaineel7e67a3f2019-08-28 15:58:49 -07002192 # wait for for devices to synchronize with each other - there are no other
2193 # mechanisms to make sure this happens for OOB discovery (except retrying
2194 # to execute the data-path request)
2195 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohendbb49c92018-04-19 15:32:38 -07002196
Jaineel7e67a3f2019-08-28 15:58:49 -07002197 # create the N NDPs: i to (i+1) % N
2198 for i in range(loop_len):
2199 peer_device = (i + 1) % loop_len
Etan Cohendbb49c92018-04-19 15:32:38 -07002200
Jaineel7e67a3f2019-08-28 15:58:49 -07002201 (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
2202 init_ipv6, resp_ipv6) = autils.create_oob_ndp_on_sessions(
2203 duts[i], duts[peer_device], ids[i], macs[i], ids[peer_device],
2204 macs[peer_device])
Etan Cohendbb49c92018-04-19 15:32:38 -07002205
Jaineel7e67a3f2019-08-28 15:58:49 -07002206 reqs[i].append(init_req_key)
2207 reqs[peer_device].append(resp_req_key)
2208 ifs[i].append(init_aware_if)
2209 ifs[peer_device].append(resp_aware_if)
2210 ipv6s[i].append(init_ipv6)
2211 ipv6s[peer_device].append(resp_ipv6)
Etan Cohendbb49c92018-04-19 15:32:38 -07002212
Jaineel7e67a3f2019-08-28 15:58:49 -07002213 # clean-up
2214 for i in range(loop_len):
2215 for req in reqs[i]:
2216 duts[i].droid.connectivityUnregisterNetworkCallback(req)
Etan Cohendbb49c92018-04-19 15:32:38 -07002217
Jaineel7e67a3f2019-08-28 15:58:49 -07002218 # info
2219 self.log.info("MACs: %s", macs)
2220 self.log.info("Interface names: %s", ifs)
2221 self.log.info("IPv6 addresses: %s", ipv6s)
2222 asserts.explicit_pass(
2223 "NDP loop test", extras={
2224 "macs": macs,
2225 "ifs": ifs,
2226 "ipv6s": ipv6s
2227 })