blob: cf939bf95b861a474fadc5651a992e5dbc4e564c [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 create_config(self, dtype):
55 """Create a base configuration based on input parameters.
Etan Cohenfc5f3732017-06-02 17:31:52 -070056
57 Args:
58 dtype: Publish or Subscribe discovery type
59
60 Returns:
61 Discovery configuration object.
62 """
Jaineel7e67a3f2019-08-28 15:58:49 -070063 config = {}
64 config[aconsts.DISCOVERY_KEY_DISCOVERY_TYPE] = dtype
65 config[
66 aconsts.DISCOVERY_KEY_SERVICE_NAME] = "GoogleTestServiceDataPath"
67 return config
Etan Cohenfc5f3732017-06-02 17:31:52 -070068
Jaineel7e67a3f2019-08-28 15:58:49 -070069 def request_network(self, dut, ns):
70 """Request a Wi-Fi Aware network.
Etan Cohenfc5f3732017-06-02 17:31:52 -070071
72 Args:
73 dut: Device
74 ns: Network specifier
75 Returns: the request key
76 """
Jaineel7e67a3f2019-08-28 15:58:49 -070077 network_req = {"TransportType": 5, "NetworkSpecifier": ns}
78 return dut.droid.connectivityRequestWifiAwareNetwork(network_req)
Etan Cohenfc5f3732017-06-02 17:31:52 -070079
Jaineel7e67a3f2019-08-28 15:58:49 -070080 def set_up_discovery(self,
81 ptype,
82 stype,
83 get_peer_id,
84 pub_on_both=False,
85 pub_on_both_same=True):
86 """Set up discovery sessions and wait for service discovery.
Etan Cohenfc5f3732017-06-02 17:31:52 -070087
88 Args:
89 ptype: Publish discovery type
90 stype: Subscribe discovery type
Etan Cohenbc80da12017-06-06 09:26:02 -070091 get_peer_id: Send a message across to get the peer's id
Etan Cohen204df172017-11-09 12:05:36 -080092 pub_on_both: If True then set up a publisher on both devices. The second
93 publisher isn't used (existing to test use-case).
94 pub_on_both_same: If True then the second publish uses an identical
95 service name, otherwise a different service name.
Etan Cohenfc5f3732017-06-02 17:31:52 -070096 """
Jaineel7e67a3f2019-08-28 15:58:49 -070097 p_dut = self.android_devices[0]
98 p_dut.pretty_name = "Publisher"
99 s_dut = self.android_devices[1]
100 s_dut.pretty_name = "Subscriber"
Etan Cohenfc5f3732017-06-02 17:31:52 -0700101
Jaineel7e67a3f2019-08-28 15:58:49 -0700102 # Publisher+Subscriber: attach and wait for confirmation
103 p_id = p_dut.droid.wifiAwareAttach()
104 autils.wait_for_event(p_dut, aconsts.EVENT_CB_ON_ATTACHED)
105 time.sleep(self.device_startup_offset)
106 s_id = s_dut.droid.wifiAwareAttach()
107 autils.wait_for_event(s_dut, aconsts.EVENT_CB_ON_ATTACHED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700108
Jaineel7e67a3f2019-08-28 15:58:49 -0700109 # Publisher: start publish and wait for confirmation
110 p_disc_id = p_dut.droid.wifiAwarePublish(p_id,
111 self.create_config(ptype))
112 autils.wait_for_event(p_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700113
Jaineel7e67a3f2019-08-28 15:58:49 -0700114 # Optionally set up a publish session on the Subscriber device
115 if pub_on_both:
116 p2_config = self.create_config(ptype)
117 if not pub_on_both_same:
118 p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] = (
119 p2_config[aconsts.DISCOVERY_KEY_SERVICE_NAME] + "-XYZXYZ")
120 s_dut.droid.wifiAwarePublish(s_id, p2_config)
121 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_PUBLISH_STARTED)
Etan Cohen204df172017-11-09 12:05:36 -0800122
Jaineel7e67a3f2019-08-28 15:58:49 -0700123 # Subscriber: start subscribe and wait for confirmation
124 s_disc_id = s_dut.droid.wifiAwareSubscribe(s_id,
125 self.create_config(stype))
126 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700127
Jaineel7e67a3f2019-08-28 15:58:49 -0700128 # Subscriber: wait for service discovery
129 discovery_event = autils.wait_for_event(
130 s_dut, aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
131 peer_id_on_sub = discovery_event["data"][
132 aconsts.SESSION_CB_KEY_PEER_ID]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700133
Jaineel7e67a3f2019-08-28 15:58:49 -0700134 peer_id_on_pub = None
135 if get_peer_id: # only need message to receive peer ID
136 # Subscriber: send message to peer (Publisher - so it knows our address)
137 s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub,
138 self.get_next_msg_id(),
139 self.PING_MSG,
140 self.MSG_RETX_COUNT)
141 autils.wait_for_event(s_dut, aconsts.SESSION_CB_ON_MESSAGE_SENT)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700142
Jaineel7e67a3f2019-08-28 15:58:49 -0700143 # Publisher: wait for received message
144 pub_rx_msg_event = autils.wait_for_event(
145 p_dut, aconsts.SESSION_CB_ON_MESSAGE_RECEIVED)
146 peer_id_on_pub = pub_rx_msg_event["data"][
147 aconsts.SESSION_CB_KEY_PEER_ID]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700148
Jaineel7e67a3f2019-08-28 15:58:49 -0700149 return (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
150 peer_id_on_pub)
Etan Cohenbc80da12017-06-06 09:26:02 -0700151
Jaineel7e67a3f2019-08-28 15:58:49 -0700152 def run_ib_data_path_test(self,
153 ptype,
154 stype,
155 encr_type,
156 use_peer_id,
157 passphrase_to_use=None,
158 pub_on_both=False,
159 pub_on_both_same=True,
160 expect_failure=False):
161 """Runs the in-band data-path tests.
Etan Cohenbc80da12017-06-06 09:26:02 -0700162
163 Args:
164 ptype: Publish discovery type
165 stype: Subscribe discovery type
166 encr_type: Encryption type, one of ENCR_TYPE_*
167 use_peer_id: On Responder (publisher): True to use peer ID, False to
168 accept any request
169 passphrase_to_use: The passphrase to use if encr_type=ENCR_TYPE_PASSPHRASE
170 If None then use self.PASSPHRASE
Etan Cohen204df172017-11-09 12:05:36 -0800171 pub_on_both: If True then set up a publisher on both devices. The second
172 publisher isn't used (existing to test use-case).
173 pub_on_both_same: If True then the second publish uses an identical
174 service name, otherwise a different service name.
Etan Cohen7922a312018-01-23 13:34:55 -0800175 expect_failure: If True then don't expect NDP formation, otherwise expect
176 NDP setup to succeed.
Etan Cohenbc80da12017-06-06 09:26:02 -0700177 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700178 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
179 peer_id_on_pub) = self.set_up_discovery(
180 ptype,
181 stype,
182 use_peer_id,
183 pub_on_both=pub_on_both,
184 pub_on_both_same=pub_on_both_same)
Etan Cohenbc80da12017-06-06 09:26:02 -0700185
Jaineel7e67a3f2019-08-28 15:58:49 -0700186 passphrase = None
187 pmk = None
188 if encr_type == self.ENCR_TYPE_PASSPHRASE:
189 passphrase = (self.PASSPHRASE
190 if passphrase_to_use == None else passphrase_to_use)
191 elif encr_type == self.ENCR_TYPE_PMK:
192 pmk = self.PMK
Etan Cohen058aaba2017-06-05 17:01:54 -0700193
Jaineel7e67a3f2019-08-28 15:58:49 -0700194 port = 1234
195 transport_protocol = 6 # TCP/IP
Etan Cohenfc5f3732017-06-02 17:31:52 -0700196
Jaineel7e67a3f2019-08-28 15:58:49 -0700197 # Publisher: request network
198 if encr_type == self.ENCR_TYPE_OPEN:
199 p_req_key = self.request_network(
200 p_dut,
201 p_dut.droid.wifiAwareCreateNetworkSpecifier(
202 p_disc_id, peer_id_on_pub
203 if use_peer_id else None, passphrase, pmk))
204 else:
205 p_req_key = self.request_network(
206 p_dut,
207 p_dut.droid.wifiAwareCreateNetworkSpecifier(
208 p_disc_id, peer_id_on_pub if use_peer_id else None,
209 passphrase, pmk, port, transport_protocol))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700210
Jaineel7e67a3f2019-08-28 15:58:49 -0700211 # Subscriber: request network
212 s_req_key = self.request_network(
213 s_dut,
214 s_dut.droid.wifiAwareCreateNetworkSpecifier(
215 s_disc_id, peer_id_on_sub, passphrase, pmk))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700216
Jaineel7e67a3f2019-08-28 15:58:49 -0700217 if expect_failure:
218 # Publisher & Subscriber: expect unavailable callbacks
219 autils.wait_for_event_with_keys(
220 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
221 autils.EVENT_NDP_TIMEOUT,
222 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
223 autils.wait_for_event_with_keys(
224 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
225 autils.EVENT_NDP_TIMEOUT,
226 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
227 else:
228 # Publisher & Subscriber: wait for network formation
229 p_net_event_nc = autils.wait_for_event_with_keys(
230 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
231 autils.EVENT_NDP_TIMEOUT,
232 (cconsts.NETWORK_CB_KEY_EVENT,
233 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
234 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
235 s_net_event_nc = autils.wait_for_event_with_keys(
236 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
237 autils.EVENT_NDP_TIMEOUT,
238 (cconsts.NETWORK_CB_KEY_EVENT,
239 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
240 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohenfc5f3732017-06-02 17:31:52 -0700241
Jaineel7e67a3f2019-08-28 15:58:49 -0700242 # validate no leak of information
243 asserts.assert_false(
244 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
245 "data"], "Network specifier leak!")
246 asserts.assert_false(
247 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
248 "data"], "Network specifier leak!")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700249
Jaineel7e67a3f2019-08-28 15:58:49 -0700250 # note that Pub <-> Sub since IPv6 are of peer's!
251 s_ipv6 = p_net_event_nc["data"][aconsts.NET_CAP_IPV6]
252 p_ipv6 = s_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700253
Jaineel7e67a3f2019-08-28 15:58:49 -0700254 self.verify_network_info(
255 p_net_event_nc["data"], s_net_event_nc["data"],
256 encr_type == self.ENCR_TYPE_OPEN, port, transport_protocol)
Etan Cohence202292017-06-05 13:55:54 -0700257
Jaineel7e67a3f2019-08-28 15:58:49 -0700258 p_net_event_lp = autils.wait_for_event_with_keys(
259 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
260 autils.EVENT_NDP_TIMEOUT,
261 (cconsts.NETWORK_CB_KEY_EVENT,
262 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
263 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
264 s_net_event_lp = autils.wait_for_event_with_keys(
265 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
266 autils.EVENT_NDP_TIMEOUT,
267 (cconsts.NETWORK_CB_KEY_EVENT,
268 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
269 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohence202292017-06-05 13:55:54 -0700270
Jaineel7e67a3f2019-08-28 15:58:49 -0700271 p_aware_if = p_net_event_lp["data"][
272 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
273 s_aware_if = s_net_event_lp["data"][
274 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohenfc5f3732017-06-02 17:31:52 -0700275
Jaineel7e67a3f2019-08-28 15:58:49 -0700276 self.log.info("Interface names: p=%s, s=%s", p_aware_if,
277 s_aware_if)
278 self.log.info("Interface addresses (IPv6): p=%s, s=%s", p_ipv6,
279 s_ipv6)
280
281 # open sockets to test connection
282 asserts.assert_true(
283 autils.verify_socket_connect(p_dut, s_dut, p_ipv6, s_ipv6, 0),
284 "Failed socket link with Pub as Server")
285 asserts.assert_true(
286 autils.verify_socket_connect(s_dut, p_dut, s_ipv6, p_ipv6, 0),
287 "Failed socket link with Sub as Server")
288
289 # terminate sessions and wait for ON_LOST callbacks
290 p_dut.droid.wifiAwareDestroy(p_id)
291 s_dut.droid.wifiAwareDestroy(s_id)
292
293 autils.wait_for_event_with_keys(
294 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
295 autils.EVENT_NDP_TIMEOUT,
296 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
297 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
298 autils.wait_for_event_with_keys(
299 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
300 autils.EVENT_NDP_TIMEOUT,
301 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
302 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
303
304 # clean-up
305 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
306 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
307
308 def run_oob_data_path_test(self,
309 encr_type,
310 use_peer_id,
311 setup_discovery_sessions=False,
312 expect_failure=False):
313 """Runs the out-of-band data-path tests.
Etan Cohenba8a53f2017-06-05 12:55:02 -0700314
315 Args:
316 encr_type: Encryption type, one of ENCR_TYPE_*
317 use_peer_id: On Responder: True to use peer ID, False to accept any
318 request
Etan Cohen35653522017-11-09 13:47:20 -0800319 setup_discovery_sessions: If True also set up a (spurious) discovery
320 session (pub on both sides, sub on Responder side). Validates a corner
321 case.
Etan Cohen7922a312018-01-23 13:34:55 -0800322 expect_failure: If True then don't expect NDP formation, otherwise expect
323 NDP setup to succeed.
Etan Cohenba8a53f2017-06-05 12:55:02 -0700324 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700325 init_dut = self.android_devices[0]
326 init_dut.pretty_name = "Initiator"
327 resp_dut = self.android_devices[1]
328 resp_dut.pretty_name = "Responder"
Etan Cohenba8a53f2017-06-05 12:55:02 -0700329
Jaineel7e67a3f2019-08-28 15:58:49 -0700330 # Initiator+Responder: attach and wait for confirmation & identity
331 init_id = init_dut.droid.wifiAwareAttach(True)
332 autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
333 init_ident_event = autils.wait_for_event(
334 init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
335 init_mac = init_ident_event["data"]["mac"]
336 time.sleep(self.device_startup_offset)
337 resp_id = resp_dut.droid.wifiAwareAttach(True)
338 autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
339 resp_ident_event = autils.wait_for_event(
340 resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
341 resp_mac = resp_ident_event["data"]["mac"]
Etan Cohenba8a53f2017-06-05 12:55:02 -0700342
Jaineel7e67a3f2019-08-28 15:58:49 -0700343 # wait for for devices to synchronize with each other - there are no other
344 # mechanisms to make sure this happens for OOB discovery (except retrying
345 # to execute the data-path request)
346 time.sleep(self.WAIT_FOR_CLUSTER)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700347
Jaineel7e67a3f2019-08-28 15:58:49 -0700348 if setup_discovery_sessions:
349 init_dut.droid.wifiAwarePublish(
350 init_id, self.create_config(aconsts.PUBLISH_TYPE_UNSOLICITED))
351 autils.wait_for_event(init_dut,
352 aconsts.SESSION_CB_ON_PUBLISH_STARTED)
353 resp_dut.droid.wifiAwarePublish(
354 resp_id, self.create_config(aconsts.PUBLISH_TYPE_UNSOLICITED))
355 autils.wait_for_event(resp_dut,
356 aconsts.SESSION_CB_ON_PUBLISH_STARTED)
357 resp_dut.droid.wifiAwareSubscribe(
358 resp_id, self.create_config(aconsts.SUBSCRIBE_TYPE_PASSIVE))
359 autils.wait_for_event(resp_dut,
360 aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED)
361 autils.wait_for_event(resp_dut,
362 aconsts.SESSION_CB_ON_SERVICE_DISCOVERED)
Etan Cohen35653522017-11-09 13:47:20 -0800363
Jaineel7e67a3f2019-08-28 15:58:49 -0700364 passphrase = None
365 pmk = None
366 if encr_type == self.ENCR_TYPE_PASSPHRASE:
367 passphrase = self.PASSPHRASE
368 elif encr_type == self.ENCR_TYPE_PMK:
369 pmk = self.PMK
Etan Cohen058aaba2017-06-05 17:01:54 -0700370
Jaineel7e67a3f2019-08-28 15:58:49 -0700371 # Responder: request network
372 resp_req_key = self.request_network(
373 resp_dut,
374 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
375 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac
376 if use_peer_id else None, passphrase, pmk))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700377
Jaineel7e67a3f2019-08-28 15:58:49 -0700378 # Initiator: request network
379 init_req_key = self.request_network(
380 init_dut,
381 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
382 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase,
383 pmk))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700384
Jaineel7e67a3f2019-08-28 15:58:49 -0700385 if expect_failure:
386 # Initiator & Responder: expect unavailable callbacks
387 autils.wait_for_event_with_keys(
388 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
389 autils.EVENT_NDP_TIMEOUT,
390 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
391 autils.wait_for_event_with_keys(
392 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
393 autils.EVENT_NDP_TIMEOUT,
394 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
395 else:
396 # Initiator & Responder: wait for network formation
397 init_net_event_nc = autils.wait_for_event_with_keys(
398 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
399 autils.EVENT_NDP_TIMEOUT,
400 (cconsts.NETWORK_CB_KEY_EVENT,
401 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
402 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
403 resp_net_event_nc = autils.wait_for_event_with_keys(
404 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
405 autils.EVENT_NDP_TIMEOUT,
406 (cconsts.NETWORK_CB_KEY_EVENT,
407 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
408 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700409
Jaineel7e67a3f2019-08-28 15:58:49 -0700410 # validate no leak of information
411 asserts.assert_false(
412 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in init_net_event_nc[
413 "data"], "Network specifier leak!")
414 asserts.assert_false(
415 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in resp_net_event_nc[
416 "data"], "Network specifier leak!")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700417
Jaineel7e67a3f2019-08-28 15:58:49 -0700418 # note that Init <-> Resp since IPv6 are of peer's!
419 init_ipv6 = resp_net_event_nc["data"][aconsts.NET_CAP_IPV6]
420 resp_ipv6 = init_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenba8a53f2017-06-05 12:55:02 -0700421
Jaineel7e67a3f2019-08-28 15:58:49 -0700422 init_net_event_lp = autils.wait_for_event_with_keys(
423 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
424 autils.EVENT_NDP_TIMEOUT,
425 (cconsts.NETWORK_CB_KEY_EVENT,
426 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
427 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
428 resp_net_event_lp = autils.wait_for_event_with_keys(
429 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
430 autils.EVENT_NDP_TIMEOUT,
431 (cconsts.NETWORK_CB_KEY_EVENT,
432 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
433 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
Etan Cohenba8a53f2017-06-05 12:55:02 -0700434
Jaineel7e67a3f2019-08-28 15:58:49 -0700435 init_aware_if = init_net_event_lp["data"][
436 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
437 resp_aware_if = resp_net_event_lp["data"][
438 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohence202292017-06-05 13:55:54 -0700439
Jaineel7e67a3f2019-08-28 15:58:49 -0700440 self.log.info("Interface names: I=%s, R=%s", init_aware_if,
441 resp_aware_if)
442 self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
443 resp_ipv6)
Etan Cohence202292017-06-05 13:55:54 -0700444
Jaineel7e67a3f2019-08-28 15:58:49 -0700445 # open sockets to test connection
446 asserts.assert_true(
447 autils.verify_socket_connect(init_dut, resp_dut, init_ipv6,
448 resp_ipv6, 0),
449 "Failed socket link with Initiator as Server")
450 asserts.assert_true(
451 autils.verify_socket_connect(resp_dut, init_dut, resp_ipv6,
452 init_ipv6, 0),
453 "Failed socket link with Responder as Server")
Etan Cohenba8a53f2017-06-05 12:55:02 -0700454
Jaineel7e67a3f2019-08-28 15:58:49 -0700455 # terminate sessions and wait for ON_LOST callbacks
456 init_dut.droid.wifiAwareDestroy(init_id)
457 resp_dut.droid.wifiAwareDestroy(resp_id)
458
459 autils.wait_for_event_with_keys(
460 init_dut, cconsts.EVENT_NETWORK_CALLBACK,
461 autils.EVENT_NDP_TIMEOUT,
462 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
463 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
464 autils.wait_for_event_with_keys(
465 resp_dut, cconsts.EVENT_NETWORK_CALLBACK,
466 autils.EVENT_NDP_TIMEOUT,
467 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_LOST),
468 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
469
470 # clean-up
471 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
472 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
473
474 def run_mismatched_ib_data_path_test(self, pub_mismatch, sub_mismatch):
475 """Runs the negative in-band data-path tests: mismatched peer ID.
Etan Cohenbc80da12017-06-06 09:26:02 -0700476
477 Args:
478 pub_mismatch: Mismatch the publisher's ID
479 sub_mismatch: Mismatch the subscriber's ID
480 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700481 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
482 peer_id_on_pub) = self.set_up_discovery(
483 aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE,
484 True)
Etan Cohenbc80da12017-06-06 09:26:02 -0700485
Jaineel7e67a3f2019-08-28 15:58:49 -0700486 if pub_mismatch:
487 peer_id_on_pub = peer_id_on_pub - 1
488 if sub_mismatch:
489 peer_id_on_sub = peer_id_on_sub - 1
Etan Cohenbc80da12017-06-06 09:26:02 -0700490
Jaineel7e67a3f2019-08-28 15:58:49 -0700491 # Publisher: request network
492 p_req_key = self.request_network(
493 p_dut,
494 p_dut.droid.wifiAwareCreateNetworkSpecifier(
495 p_disc_id, peer_id_on_pub, None))
Etan Cohenbc80da12017-06-06 09:26:02 -0700496
Jaineel7e67a3f2019-08-28 15:58:49 -0700497 # Subscriber: request network
498 s_req_key = self.request_network(
499 s_dut,
500 s_dut.droid.wifiAwareCreateNetworkSpecifier(
501 s_disc_id, peer_id_on_sub, None))
Etan Cohenbc80da12017-06-06 09:26:02 -0700502
Jaineel7e67a3f2019-08-28 15:58:49 -0700503 # Publisher & Subscriber:
504 # - expect unavailable callbacks on the party with the bad ID
505 # - also expect unavailable on the Initiator party (i.e. the
506 # Subscriber) if the Publisher has a bad ID
507 # - but a Publisher with a valid ID will keep waiting ...
508 autils.wait_for_event_with_keys(
509 s_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
510 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
511 if pub_mismatch:
512 autils.wait_for_event_with_keys(
513 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
514 autils.EVENT_NDP_TIMEOUT,
515 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
516 else:
517 time.sleep(autils.EVENT_NDP_TIMEOUT)
518 autils.fail_on_event_with_keys(
519 p_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
520 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
Etan Cohenbc80da12017-06-06 09:26:02 -0700521
Jaineel7e67a3f2019-08-28 15:58:49 -0700522 # clean-up
523 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
524 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
Etan Cohenbc80da12017-06-06 09:26:02 -0700525
Jaineel7e67a3f2019-08-28 15:58:49 -0700526 def run_mismatched_oob_data_path_test(self,
527 init_mismatch_mac=False,
528 resp_mismatch_mac=False,
529 init_encr_type=ENCR_TYPE_OPEN,
530 resp_encr_type=ENCR_TYPE_OPEN):
531 """Runs the negative out-of-band data-path tests: mismatched information
Etan Cohen85adc452017-06-06 08:32:08 -0700532 between Responder and Initiator.
533
534 Args:
535 init_mismatch_mac: True to mismatch the Initiator MAC address
536 resp_mismatch_mac: True to mismatch the Responder MAC address
537 init_encr_type: Encryption type of Initiator - ENCR_TYPE_*
538 resp_encr_type: Encryption type of Responder - ENCR_TYPE_*
539 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700540 init_dut = self.android_devices[0]
541 init_dut.pretty_name = "Initiator"
542 resp_dut = self.android_devices[1]
543 resp_dut.pretty_name = "Responder"
Etan Cohen85adc452017-06-06 08:32:08 -0700544
Jaineel7e67a3f2019-08-28 15:58:49 -0700545 # Initiator+Responder: attach and wait for confirmation & identity
546 init_id = init_dut.droid.wifiAwareAttach(True)
547 autils.wait_for_event(init_dut, aconsts.EVENT_CB_ON_ATTACHED)
548 init_ident_event = autils.wait_for_event(
549 init_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
550 init_mac = init_ident_event["data"]["mac"]
551 time.sleep(self.device_startup_offset)
552 resp_id = resp_dut.droid.wifiAwareAttach(True)
553 autils.wait_for_event(resp_dut, aconsts.EVENT_CB_ON_ATTACHED)
554 resp_ident_event = autils.wait_for_event(
555 resp_dut, aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
556 resp_mac = resp_ident_event["data"]["mac"]
Etan Cohen85adc452017-06-06 08:32:08 -0700557
Jaineel7e67a3f2019-08-28 15:58:49 -0700558 if init_mismatch_mac: # assumes legit ones don't start with "00"
559 init_mac = "00" + init_mac[2:]
560 if resp_mismatch_mac:
561 resp_mac = "00" + resp_mac[2:]
Etan Cohen85adc452017-06-06 08:32:08 -0700562
Jaineel7e67a3f2019-08-28 15:58:49 -0700563 # wait for for devices to synchronize with each other - there are no other
564 # mechanisms to make sure this happens for OOB discovery (except retrying
565 # to execute the data-path request)
566 time.sleep(self.WAIT_FOR_CLUSTER)
Etan Cohen85adc452017-06-06 08:32:08 -0700567
Jaineel7e67a3f2019-08-28 15:58:49 -0700568 # set up separate keys: even if types are the same we want a mismatch
569 init_passphrase = None
570 init_pmk = None
571 if init_encr_type == self.ENCR_TYPE_PASSPHRASE:
572 init_passphrase = self.PASSPHRASE
573 elif init_encr_type == self.ENCR_TYPE_PMK:
574 init_pmk = self.PMK
Etan Cohen85adc452017-06-06 08:32:08 -0700575
Jaineel7e67a3f2019-08-28 15:58:49 -0700576 resp_passphrase = None
577 resp_pmk = None
578 if resp_encr_type == self.ENCR_TYPE_PASSPHRASE:
579 resp_passphrase = self.PASSPHRASE2
580 elif resp_encr_type == self.ENCR_TYPE_PMK:
581 resp_pmk = self.PMK2
Etan Cohen85adc452017-06-06 08:32:08 -0700582
Jaineel7e67a3f2019-08-28 15:58:49 -0700583 # Responder: request network
584 resp_req_key = self.request_network(
585 resp_dut,
586 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
587 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac,
588 resp_passphrase, resp_pmk))
Etan Cohen85adc452017-06-06 08:32:08 -0700589
Jaineel7e67a3f2019-08-28 15:58:49 -0700590 # Initiator: request network
591 init_req_key = self.request_network(
592 init_dut,
593 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
594 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac,
595 init_passphrase, init_pmk))
Etan Cohen85adc452017-06-06 08:32:08 -0700596
Jaineel7e67a3f2019-08-28 15:58:49 -0700597 # Initiator & Responder:
598 # - expect unavailable on the Initiator party if the
599 # Initiator or Responder has a bad ID
600 # - but a Responder will keep waiting ...
601 autils.wait_for_event_with_keys(
602 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
603 (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE))
604 time.sleep(autils.EVENT_NDP_TIMEOUT)
605 autils.fail_on_event_with_keys(
606 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0,
607 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
Etan Cohen85adc452017-06-06 08:32:08 -0700608
Jaineel7e67a3f2019-08-28 15:58:49 -0700609 # clean-up
610 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
611 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohen85adc452017-06-06 08:32:08 -0700612
Jaineel7e67a3f2019-08-28 15:58:49 -0700613 def verify_network_info(self, p_data, s_data, open, port,
614 transport_protocol):
615 """Verify that the port and transport protocol information is correct.
616 - should only exist on subscriber (received from publisher)
617 and match transmitted values
618 - should only exist on an encrypted NDP
Etan Cohenba8a53f2017-06-05 12:55:02 -0700619
Jaineel7e67a3f2019-08-28 15:58:49 -0700620 Args:
621 p_data, s_data: Pub and Sub (respectively) net cap event data.
622 open: True if NDP unencrypted, False if encrypted.
623 port: Expected port value.
624 transport_protocol: Expected transport protocol value.
625 """
626 asserts.assert_true(aconsts.NET_CAP_PORT not in p_data,
627 "port info not expected on Pub")
628 asserts.assert_true(aconsts.NET_CAP_TRANSPORT_PROTOCOL not in p_data,
629 "transport protocol info not expected on Pub")
630 if open:
631 asserts.assert_true(aconsts.NET_CAP_PORT not in s_data,
632 "port info not expected on Sub (open NDP)")
633 asserts.assert_true(
634 aconsts.NET_CAP_TRANSPORT_PROTOCOL not in s_data,
635 "transport protocol info not expected on Sub (open NDP)")
636 else:
637 asserts.assert_equal(s_data[aconsts.NET_CAP_PORT], port,
638 "Port info does not match on Sub (from Pub)")
639 asserts.assert_equal(
640 s_data[aconsts.NET_CAP_TRANSPORT_PROTOCOL], transport_protocol,
641 "Transport protocol info does not match on Sub (from Pub)")
Etan Cohenfc5f3732017-06-02 17:31:52 -0700642
Jaineel7e67a3f2019-08-28 15:58:49 -0700643 #######################################
644 # Positive In-Band (IB) tests key:
645 #
646 # names is: test_ib_<pub_type>_<sub_type>_<encr_type>_<peer_spec>
647 # where:
648 #
649 # pub_type: Type of publish discovery session: unsolicited or solicited.
650 # sub_type: Type of subscribe discovery session: passive or active.
651 # encr_type: Encription type: open, passphrase
652 # peer_spec: Peer specification method: any or specific
653 #
654 # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
655 # peer using the Aware-provided peer handle (as opposed to a MAC address).
656 #######################################
657
658 @test_tracker_info(uuid="fa30bedc-d1de-4440-bf25-ec00d10555af")
659 def test_ib_unsolicited_passive_open_specific(self):
660 """Data-path: in-band, unsolicited/passive, open encryption, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700661
662 Verifies end-to-end discovery + data-path creation.
663 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700664 self.run_ib_data_path_test(
665 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
666 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
667 encr_type=self.ENCR_TYPE_OPEN,
668 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700669
Jaineel7e67a3f2019-08-28 15:58:49 -0700670 @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d")
671 def test_ib_unsolicited_passive_open_any(self):
672 """Data-path: in-band, unsolicited/passive, open encryption, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700673
674 Verifies end-to-end discovery + data-path creation.
675 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700676 self.run_ib_data_path_test(
677 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
678 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
679 encr_type=self.ENCR_TYPE_OPEN,
680 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700681
Jaineel7e67a3f2019-08-28 15:58:49 -0700682 @test_tracker_info(uuid="93b2a23d-8579-448a-936c-7812929464cf")
683 def test_ib_unsolicited_passive_passphrase_specific(self):
684 """Data-path: in-band, unsolicited/passive, passphrase, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700685
686 Verifies end-to-end discovery + data-path creation.
687 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700688 self.run_ib_data_path_test(
689 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
690 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
691 encr_type=self.ENCR_TYPE_PASSPHRASE,
692 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700693
Jaineel7e67a3f2019-08-28 15:58:49 -0700694 @test_tracker_info(uuid="1736126f-a0ff-4712-acc4-f89b4eef5716")
695 def test_ib_unsolicited_passive_passphrase_any(self):
696 """Data-path: in-band, unsolicited/passive, passphrase, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700697
698 Verifies end-to-end discovery + data-path creation.
699 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700700 self.run_ib_data_path_test(
701 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
702 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
703 encr_type=self.ENCR_TYPE_PASSPHRASE,
704 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700705
Jaineel7e67a3f2019-08-28 15:58:49 -0700706 @test_tracker_info(uuid="b9353d5b-3f77-46bf-bfd9-65d56a7c939a")
707 def test_ib_unsolicited_passive_pmk_specific(self):
708 """Data-path: in-band, unsolicited/passive, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700709
710 Verifies end-to-end discovery + data-path creation.
711 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700712 self.run_ib_data_path_test(
713 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
714 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
715 encr_type=self.ENCR_TYPE_PMK,
716 use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700717
Jaineel7e67a3f2019-08-28 15:58:49 -0700718 @test_tracker_info(uuid="06f3b2ab-4a10-4398-83a4-6a23851b1662")
719 def test_ib_unsolicited_passive_pmk_any(self):
720 """Data-path: in-band, unsolicited/passive, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700721
722 Verifies end-to-end discovery + data-path creation.
723 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700724 self.run_ib_data_path_test(
725 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
726 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
727 encr_type=self.ENCR_TYPE_PMK,
728 use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700729
Jaineel7e67a3f2019-08-28 15:58:49 -0700730 @test_tracker_info(uuid="0ed7d8b3-a69e-46ba-aeb7-13e507ecf290")
731 def test_ib_solicited_active_open_specific(self):
732 """Data-path: in-band, solicited/active, open encryption, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700733
Etan Cohenba8a53f2017-06-05 12:55:02 -0700734 Verifies end-to-end discovery + data-path creation.
735 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700736 self.run_ib_data_path_test(
737 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
738 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
739 encr_type=self.ENCR_TYPE_OPEN,
740 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700741
Jaineel7e67a3f2019-08-28 15:58:49 -0700742 @test_tracker_info(uuid="c7ba6d28-5ef6-45d9-95d5-583ad6d981f3")
743 def test_ib_solicited_active_open_any(self):
744 """Data-path: in-band, solicited/active, open encryption, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700745
Etan Cohenba8a53f2017-06-05 12:55:02 -0700746 Verifies end-to-end discovery + data-path creation.
747 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700748 self.run_ib_data_path_test(
749 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
750 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
751 encr_type=self.ENCR_TYPE_OPEN,
752 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700753
Jaineel7e67a3f2019-08-28 15:58:49 -0700754 @test_tracker_info(uuid="388cea99-0e2e-49ea-b00e-f3e56b6236e5")
755 def test_ib_solicited_active_passphrase_specific(self):
756 """Data-path: in-band, solicited/active, passphrase, specific peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700757
Etan Cohenba8a53f2017-06-05 12:55:02 -0700758 Verifies end-to-end discovery + data-path creation.
759 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700760 self.run_ib_data_path_test(
761 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
762 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
763 encr_type=self.ENCR_TYPE_PASSPHRASE,
764 use_peer_id=True)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700765
Jaineel7e67a3f2019-08-28 15:58:49 -0700766 @test_tracker_info(uuid="fcd3e28a-5eab-4169-8a0c-dc7204dcdc13")
767 def test_ib_solicited_active_passphrase_any(self):
768 """Data-path: in-band, solicited/active, passphrase, any peer
Etan Cohenfc5f3732017-06-02 17:31:52 -0700769
Etan Cohenba8a53f2017-06-05 12:55:02 -0700770 Verifies end-to-end discovery + data-path creation.
771 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700772 self.run_ib_data_path_test(
773 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
774 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
775 encr_type=self.ENCR_TYPE_PASSPHRASE,
776 use_peer_id=False)
Etan Cohenfc5f3732017-06-02 17:31:52 -0700777
Jaineel7e67a3f2019-08-28 15:58:49 -0700778 @test_tracker_info(uuid="9d4eaad7-ba53-4a06-8ce0-e308daea3309")
779 def test_ib_solicited_active_pmk_specific(self):
780 """Data-path: in-band, solicited/active, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700781
782 Verifies end-to-end discovery + data-path creation.
783 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700784 self.run_ib_data_path_test(
785 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
786 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
787 encr_type=self.ENCR_TYPE_PMK,
788 use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700789
Jaineel7e67a3f2019-08-28 15:58:49 -0700790 @test_tracker_info(uuid="129d850e-c312-4137-a67b-05ae95fe66cc")
791 def test_ib_solicited_active_pmk_any(self):
792 """Data-path: in-band, solicited/active, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700793
794 Verifies end-to-end discovery + data-path creation.
795 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700796 self.run_ib_data_path_test(
797 ptype=aconsts.PUBLISH_TYPE_SOLICITED,
798 stype=aconsts.SUBSCRIBE_TYPE_ACTIVE,
799 encr_type=self.ENCR_TYPE_PMK,
800 use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700801
Jaineel7e67a3f2019-08-28 15:58:49 -0700802 #######################################
803 # Positive In-Band (IB) with a publish session running on the subscriber
804 # tests key:
805 #
806 # names is: test_ib_extra_pub_<same|diff>_<pub_type>_<sub_type>
807 # _<encr_type>_<peer_spec>
808 # where:
809 #
810 # same|diff: Whether the extra publish session (on the subscriber) is the same
811 # or different from the primary session.
812 # pub_type: Type of publish discovery session: unsolicited or solicited.
813 # sub_type: Type of subscribe discovery session: passive or active.
814 # encr_type: Encryption type: open, passphrase
815 # peer_spec: Peer specification method: any or specific
816 #
817 # Note: In-Band means using Wi-Fi Aware for discovery and referring to the
818 # peer using the Aware-provided peer handle (as opposed to a MAC address).
819 #######################################
Etan Cohen204df172017-11-09 12:05:36 -0800820
Jaineel7e67a3f2019-08-28 15:58:49 -0700821 @test_tracker_info(uuid="e855dd81-45c8-4bb2-a204-7687c48ff843")
822 def test_ib_extra_pub_same_unsolicited_passive_open_specific(self):
823 """Data-path: in-band, unsolicited/passive, open encryption, specific peer.
Etan Cohen204df172017-11-09 12:05:36 -0800824
825 Configuration contains a publisher (for the same service) running on *both*
826 devices.
827
828 Verifies end-to-end discovery + data-path creation.
829 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700830 self.run_ib_data_path_test(
831 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
832 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
833 encr_type=self.ENCR_TYPE_OPEN,
834 use_peer_id=True,
835 pub_on_both=True,
836 pub_on_both_same=True)
Etan Cohen204df172017-11-09 12:05:36 -0800837
Jaineel7e67a3f2019-08-28 15:58:49 -0700838 @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d")
839 def test_ib_extra_pub_same_unsolicited_passive_open_any(self):
840 """Data-path: in-band, unsolicited/passive, open encryption, any peer.
Etan Cohen204df172017-11-09 12:05:36 -0800841
842 Configuration contains a publisher (for the same service) running on *both*
843 devices.
844
845 Verifies end-to-end discovery + data-path creation.
846 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700847 self.run_ib_data_path_test(
848 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
849 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
850 encr_type=self.ENCR_TYPE_OPEN,
851 use_peer_id=False,
852 pub_on_both=True,
853 pub_on_both_same=True)
Etan Cohen204df172017-11-09 12:05:36 -0800854
Jaineel7e67a3f2019-08-28 15:58:49 -0700855 @test_tracker_info(uuid="7a32f439-d745-4716-a75e-b54109aaaf82")
856 def test_ib_extra_pub_diff_unsolicited_passive_open_specific(self):
857 """Data-path: in-band, unsolicited/passive, open encryption, specific peer.
Etan Cohen204df172017-11-09 12:05:36 -0800858
859 Configuration contains a publisher (for a different service) running on
860 *both* devices.
861
862 Verifies end-to-end discovery + data-path creation.
863 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700864 self.run_ib_data_path_test(
865 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
866 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
867 encr_type=self.ENCR_TYPE_OPEN,
868 use_peer_id=True,
869 pub_on_both=True,
870 pub_on_both_same=False)
Etan Cohen204df172017-11-09 12:05:36 -0800871
Jaineel7e67a3f2019-08-28 15:58:49 -0700872 @test_tracker_info(uuid="a14ddc66-88fd-4b49-ab37-225533867c63")
873 def test_ib_extra_pub_diff_unsolicited_passive_open_any(self):
874 """Data-path: in-band, unsolicited/passive, open encryption, any peer.
Etan Cohen204df172017-11-09 12:05:36 -0800875
876 Configuration contains a publisher (for a different service) running on
877 *both* devices.
878
879 Verifies end-to-end discovery + data-path creation.
880 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700881 self.run_ib_data_path_test(
882 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
883 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
884 encr_type=self.ENCR_TYPE_OPEN,
885 use_peer_id=False,
886 pub_on_both=True,
887 pub_on_both_same=False)
Etan Cohen204df172017-11-09 12:05:36 -0800888
Jaineel7e67a3f2019-08-28 15:58:49 -0700889 #######################################
890 # Positive Out-of-Band (OOB) tests key:
891 #
892 # names is: test_oob_<encr_type>_<peer_spec>
893 # where:
894 #
895 # encr_type: Encryption type: open, passphrase
896 # peer_spec: Peer specification method: any or specific
897 #
898 # Optionally set up an extra discovery session to test coexistence. If so
899 # add "ib_coex" to test name.
900 #
901 # Note: Out-of-Band means using a non-Wi-Fi Aware mechanism for discovery and
902 # exchange of MAC addresses and then Wi-Fi Aware for data-path.
903 #######################################
Etan Cohenba8a53f2017-06-05 12:55:02 -0700904
Jaineel7e67a3f2019-08-28 15:58:49 -0700905 @test_tracker_info(uuid="7db17d8c-1dce-4084-b695-215bbcfe7d41")
906 def test_oob_open_specific(self):
907 """Data-path: out-of-band, open encryption, specific peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700908
909 Verifies end-to-end discovery + data-path creation.
910 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700911 self.run_oob_data_path_test(
912 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=True)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700913
Jaineel7e67a3f2019-08-28 15:58:49 -0700914 @test_tracker_info(uuid="ad416d89-cb95-4a07-8d29-ee213117450b")
915 def test_oob_open_any(self):
916 """Data-path: out-of-band, open encryption, any peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700917
918 Verifies end-to-end discovery + data-path creation.
919 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700920 self.run_oob_data_path_test(
921 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700922
Jaineel7e67a3f2019-08-28 15:58:49 -0700923 @test_tracker_info(uuid="74937a3a-d524-43e2-8979-4449271cab52")
924 def test_oob_passphrase_specific(self):
925 """Data-path: out-of-band, passphrase, specific peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700926
927 Verifies end-to-end discovery + data-path creation.
928 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700929 self.run_oob_data_path_test(
930 encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=True)
Etan Cohenba8a53f2017-06-05 12:55:02 -0700931
Jaineel7e67a3f2019-08-28 15:58:49 -0700932 @test_tracker_info(uuid="afcbdc7e-d3a9-465b-b1da-ce2e42e3941e")
933 def test_oob_passphrase_any(self):
934 """Data-path: out-of-band, passphrase, any peer
Etan Cohenba8a53f2017-06-05 12:55:02 -0700935
936 Verifies end-to-end discovery + data-path creation.
937 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700938 self.run_oob_data_path_test(
939 encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=False)
Etan Cohen058aaba2017-06-05 17:01:54 -0700940
Jaineel7e67a3f2019-08-28 15:58:49 -0700941 @test_tracker_info(uuid="0d095031-160a-4537-aab5-41b6ad5d55f8")
942 def test_oob_pmk_specific(self):
943 """Data-path: out-of-band, PMK, specific peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700944
945 Verifies end-to-end discovery + data-path creation.
946 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700947 self.run_oob_data_path_test(
948 encr_type=self.ENCR_TYPE_PMK, use_peer_id=True)
Etan Cohen058aaba2017-06-05 17:01:54 -0700949
Jaineel7e67a3f2019-08-28 15:58:49 -0700950 @test_tracker_info(uuid="e45477bd-66cc-4eb7-88dd-4518c8aa2a74")
951 def test_oob_pmk_any(self):
952 """Data-path: out-of-band, PMK, any peer
Etan Cohen058aaba2017-06-05 17:01:54 -0700953
954 Verifies end-to-end discovery + data-path creation.
955 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700956 self.run_oob_data_path_test(
957 encr_type=self.ENCR_TYPE_PMK, use_peer_id=False)
Etan Cohen6ace4582017-06-05 17:21:55 -0700958
Jaineel7e67a3f2019-08-28 15:58:49 -0700959 @test_tracker_info(uuid="dd464f24-b404-4eea-955c-d10c9e8adefc")
960 def test_oob_ib_coex_open_specific(self):
961 """Data-path: out-of-band, open encryption, specific peer - in-band coex:
Etan Cohen35653522017-11-09 13:47:20 -0800962 set up a concurrent discovery session to verify no impact. The session
963 consists of Publisher on both ends, and a Subscriber on the Responder.
964
965 Verifies end-to-end discovery + data-path creation.
966 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700967 self.run_oob_data_path_test(
968 encr_type=self.ENCR_TYPE_OPEN,
969 use_peer_id=True,
970 setup_discovery_sessions=True)
Etan Cohen35653522017-11-09 13:47:20 -0800971
Jaineel7e67a3f2019-08-28 15:58:49 -0700972 @test_tracker_info(uuid="088fcd3a-b015-4179-a9a5-91f782b03e3b")
973 def test_oob_ib_coex_open_any(self):
974 """Data-path: out-of-band, open encryption, any peer - in-band coex:
Etan Cohen35653522017-11-09 13:47:20 -0800975 set up a concurrent discovery session to verify no impact. The session
976 consists of Publisher on both ends, and a Subscriber on the Responder.
977
978 Verifies end-to-end discovery + data-path creation.
979 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700980 self.run_oob_data_path_test(
981 encr_type=self.ENCR_TYPE_OPEN,
982 use_peer_id=False,
983 setup_discovery_sessions=True)
Etan Cohen35653522017-11-09 13:47:20 -0800984
Jaineel7e67a3f2019-08-28 15:58:49 -0700985 ##############################################################
Etan Cohen6ace4582017-06-05 17:21:55 -0700986
Jaineel7e67a3f2019-08-28 15:58:49 -0700987 @test_tracker_info(uuid="1c2c9805-dc1e-43b5-a1b8-315e8c9a4337")
988 def test_passphrase_min(self):
989 """Data-path: minimum passphrase length
Etan Cohen6ace4582017-06-05 17:21:55 -0700990
991 Use in-band, unsolicited/passive, any peer combination
992 """
Jaineel7e67a3f2019-08-28 15:58:49 -0700993 self.run_ib_data_path_test(
994 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
995 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
996 encr_type=self.ENCR_TYPE_PASSPHRASE,
997 use_peer_id=False,
998 passphrase_to_use=self.PASSPHRASE_MIN)
Etan Cohen6ace4582017-06-05 17:21:55 -0700999
Jaineel7e67a3f2019-08-28 15:58:49 -07001000 @test_tracker_info(uuid="e696e2b9-87a9-4521-b337-61b9efaa2057")
1001 def test_passphrase_max(self):
1002 """Data-path: maximum passphrase length
Etan Cohen6ace4582017-06-05 17:21:55 -07001003
1004 Use in-band, unsolicited/passive, any peer combination
1005 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001006 self.run_ib_data_path_test(
1007 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1008 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1009 encr_type=self.ENCR_TYPE_PASSPHRASE,
1010 use_peer_id=False,
1011 passphrase_to_use=self.PASSPHRASE_MAX)
Etan Cohen85adc452017-06-06 08:32:08 -07001012
Jaineel7e67a3f2019-08-28 15:58:49 -07001013 @test_tracker_info(uuid="533cd44c-ff30-4283-ac28-f71fd7b4f02d")
1014 def test_negative_mismatch_publisher_peer_id(self):
1015 """Data-path: failure when publisher peer ID is mismatched"""
1016 self.run_mismatched_ib_data_path_test(
1017 pub_mismatch=True, sub_mismatch=False)
Etan Cohenbc80da12017-06-06 09:26:02 -07001018
Jaineel7e67a3f2019-08-28 15:58:49 -07001019 @test_tracker_info(uuid="682f275e-722a-4f8b-85e7-0dcea9d25532")
1020 def test_negative_mismatch_subscriber_peer_id(self):
1021 """Data-path: failure when subscriber peer ID is mismatched"""
1022 self.run_mismatched_ib_data_path_test(
1023 pub_mismatch=False, sub_mismatch=True)
Etan Cohenbc80da12017-06-06 09:26:02 -07001024
Jaineel7e67a3f2019-08-28 15:58:49 -07001025 @test_tracker_info(uuid="7fa82796-7fc9-4d9e-bbbb-84b751788943")
1026 def test_negative_mismatch_init_mac(self):
1027 """Data-path: failure when Initiator MAC address mismatch"""
1028 self.run_mismatched_oob_data_path_test(
1029 init_mismatch_mac=True, resp_mismatch_mac=False)
Etan Cohen85adc452017-06-06 08:32:08 -07001030
Jaineel7e67a3f2019-08-28 15:58:49 -07001031 @test_tracker_info(uuid="edeae959-4644-44f9-8d41-bdeb5216954e")
1032 def test_negative_mismatch_resp_mac(self):
1033 """Data-path: failure when Responder MAC address mismatch"""
1034 self.run_mismatched_oob_data_path_test(
1035 init_mismatch_mac=False, resp_mismatch_mac=True)
Etan Cohen85adc452017-06-06 08:32:08 -07001036
Jaineel7e67a3f2019-08-28 15:58:49 -07001037 @test_tracker_info(uuid="91f46949-c47f-49f9-a90f-6fae699613a7")
1038 def test_negative_mismatch_passphrase(self):
1039 """Data-path: failure when passphrases mismatch"""
1040 self.run_mismatched_oob_data_path_test(
1041 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1042 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001043
Jaineel7e67a3f2019-08-28 15:58:49 -07001044 @test_tracker_info(uuid="01c49c2e-dc92-4a27-bb47-c4fc67617c23")
1045 def test_negative_mismatch_pmk(self):
1046 """Data-path: failure when PMK mismatch"""
1047 self.run_mismatched_oob_data_path_test(
1048 init_encr_type=self.ENCR_TYPE_PMK,
1049 resp_encr_type=self.ENCR_TYPE_PMK)
Etan Cohen85adc452017-06-06 08:32:08 -07001050
Jaineel7e67a3f2019-08-28 15:58:49 -07001051 @test_tracker_info(uuid="4d651797-5fbb-408e-a4b6-a6e1944136da")
1052 def test_negative_mismatch_open_passphrase(self):
1053 """Data-path: failure when initiator is open, and responder passphrase"""
1054 self.run_mismatched_oob_data_path_test(
1055 init_encr_type=self.ENCR_TYPE_OPEN,
1056 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001057
Jaineel7e67a3f2019-08-28 15:58:49 -07001058 @test_tracker_info(uuid="1ae697f4-5987-4187-aeef-1e22d07d4a7c")
1059 def test_negative_mismatch_open_pmk(self):
1060 """Data-path: failure when initiator is open, and responder PMK"""
1061 self.run_mismatched_oob_data_path_test(
1062 init_encr_type=self.ENCR_TYPE_OPEN,
1063 resp_encr_type=self.ENCR_TYPE_PMK)
Etan Cohen85adc452017-06-06 08:32:08 -07001064
Jaineel7e67a3f2019-08-28 15:58:49 -07001065 @test_tracker_info(uuid="f027b1cc-0e7a-4075-b880-5e64b288afbd")
1066 def test_negative_mismatch_pmk_passphrase(self):
1067 """Data-path: failure when initiator is pmk, and responder passphrase"""
1068 self.run_mismatched_oob_data_path_test(
1069 init_encr_type=self.ENCR_TYPE_PMK,
1070 resp_encr_type=self.ENCR_TYPE_PASSPHRASE)
Etan Cohen85adc452017-06-06 08:32:08 -07001071
Jaineel7e67a3f2019-08-28 15:58:49 -07001072 @test_tracker_info(uuid="0819bbd4-72ae-49c4-bd46-5448db2b0a06")
1073 def test_negative_mismatch_passphrase_open(self):
1074 """Data-path: failure when initiator is passphrase, and responder open"""
1075 self.run_mismatched_oob_data_path_test(
1076 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1077 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen85adc452017-06-06 08:32:08 -07001078
Jaineel7e67a3f2019-08-28 15:58:49 -07001079 @test_tracker_info(uuid="7ef24f62-8e6b-4732-88a3-80a43584dda4")
1080 def test_negative_mismatch_pmk_open(self):
1081 """Data-path: failure when initiator is PMK, and responder open"""
1082 self.run_mismatched_oob_data_path_test(
1083 init_encr_type=self.ENCR_TYPE_PMK,
1084 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen85adc452017-06-06 08:32:08 -07001085
Jaineel7e67a3f2019-08-28 15:58:49 -07001086 @test_tracker_info(uuid="7b9c9efc-1c06-465e-8a5e-d6a22ac1da97")
1087 def test_negative_mismatch_passphrase_pmk(self):
1088 """Data-path: failure when initiator is passphrase, and responder pmk"""
1089 self.run_mismatched_oob_data_path_test(
1090 init_encr_type=self.ENCR_TYPE_PASSPHRASE,
1091 resp_encr_type=self.ENCR_TYPE_OPEN)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001092
Jaineel7e67a3f2019-08-28 15:58:49 -07001093 ##########################################################################
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001094
Jaineel7e67a3f2019-08-28 15:58:49 -07001095 def wait_for_request_responses(self, dut, req_keys, aware_ifs, aware_ipv6):
1096 """Wait for network request confirmation for all request keys.
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001097
1098 Args:
1099 dut: Device under test
1100 req_keys: (in) A list of the network requests
1101 aware_ifs: (out) A list into which to append the network interface
Jaineel7e67a3f2019-08-28 15:58:49 -07001102 aware_ipv6: (out) A list into which to append the network ipv6 address
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001103 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001104 num_events = 0 # looking for 2 events per NDP: link-prop + net-cap
1105 while num_events != 2 * len(req_keys):
1106 event = autils.wait_for_event(
1107 dut,
1108 cconsts.EVENT_NETWORK_CALLBACK,
1109 timeout=autils.EVENT_NDP_TIMEOUT)
1110 if (event["data"][cconsts.NETWORK_CB_KEY_EVENT] ==
1111 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED):
1112 if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys:
1113 num_events = num_events + 1
1114 aware_ifs.append(
1115 event["data"][cconsts.NETWORK_CB_KEY_INTERFACE_NAME])
1116 else:
1117 self.log.info(
1118 "Received an unexpected connectivity, the revoked "
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001119 "network request probably went through -- %s", event)
Jaineel7e67a3f2019-08-28 15:58:49 -07001120 elif (event["data"][cconsts.NETWORK_CB_KEY_EVENT] ==
1121 cconsts.NETWORK_CB_CAPABILITIES_CHANGED):
1122 if event["data"][cconsts.NETWORK_CB_KEY_ID] in req_keys:
1123 num_events = num_events + 1
1124 aware_ipv6.append(event["data"][aconsts.NET_CAP_IPV6])
1125 else:
1126 self.log.info(
1127 "Received an unexpected connectivity, the revoked "
1128 "network request probably went through -- %s", event)
1129 # validate no leak of information
1130 asserts.assert_false(
1131 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in event["data"],
1132 "Network specifier leak!")
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001133
Jaineel7e67a3f2019-08-28 15:58:49 -07001134 @test_tracker_info(uuid="2e325e2b-d552-4890-b470-20b40284395d")
1135 def test_multiple_identical_networks(self):
1136 """Validate that creating multiple networks between 2 devices, each network
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001137 with identical configuration is supported over a single NDP.
1138
1139 Verify that the interface and IPv6 address is the same for all networks.
1140 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001141 init_dut = self.android_devices[0]
1142 init_dut.pretty_name = "Initiator"
1143 resp_dut = self.android_devices[1]
1144 resp_dut.pretty_name = "Responder"
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001145
Jaineel7e67a3f2019-08-28 15:58:49 -07001146 N = 2 # first iteration (must be 2 to give us a chance to cancel the first)
1147 M = 5 # second iteration
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001148
Jaineel7e67a3f2019-08-28 15:58:49 -07001149 init_ids = []
1150 resp_ids = []
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001151
Jaineel7e67a3f2019-08-28 15:58:49 -07001152 # Initiator+Responder: attach and wait for confirmation & identity
1153 # create N+M sessions to be used in the different (but identical) NDPs
1154 for i in range(N + M):
1155 id, init_mac = autils.attach_with_identity(init_dut)
1156 init_ids.append(id)
1157 id, resp_mac = autils.attach_with_identity(resp_dut)
1158 resp_ids.append(id)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001159
Jaineel7e67a3f2019-08-28 15:58:49 -07001160 # wait for for devices to synchronize with each other - there are no other
1161 # mechanisms to make sure this happens for OOB discovery (except retrying
1162 # to execute the data-path request)
1163 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001164
Jaineel7e67a3f2019-08-28 15:58:49 -07001165 resp_req_keys = []
1166 init_req_keys = []
1167 resp_aware_ifs = []
1168 init_aware_ifs = []
1169 resp_aware_ipv6 = []
1170 init_aware_ipv6 = []
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001171
Jaineel7e67a3f2019-08-28 15:58:49 -07001172 # issue N quick requests for identical NDPs - without waiting for result
1173 # tests whether pre-setup multiple NDP procedure
1174 for i in range(N):
1175 # Responder: request network
1176 resp_req_keys.append(
1177 autils.request_network(
1178 resp_dut,
1179 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1180 resp_ids[i], aconsts.DATA_PATH_RESPONDER, init_mac,
1181 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001182
Jaineel7e67a3f2019-08-28 15:58:49 -07001183 # Initiator: request network
1184 init_req_keys.append(
1185 autils.request_network(
1186 init_dut,
1187 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1188 init_ids[i], aconsts.DATA_PATH_INITIATOR, resp_mac,
1189 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001190
Jaineel7e67a3f2019-08-28 15:58:49 -07001191 # remove the first request (hopefully before completed) testing that NDP
1192 # is still created
1193 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_keys[0])
1194 resp_req_keys.remove(resp_req_keys[0])
1195 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_keys[0])
1196 init_req_keys.remove(init_req_keys[0])
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001197
Jaineel7e67a3f2019-08-28 15:58:49 -07001198 # wait for network formation for all initial requests
1199 # note: for IPv6 Init <--> Resp since each reports the other's IPv6 address
1200 # in it's transport-specific network info
1201 self.wait_for_request_responses(resp_dut, resp_req_keys,
1202 resp_aware_ifs, init_aware_ipv6)
1203 self.wait_for_request_responses(init_dut, init_req_keys,
1204 init_aware_ifs, resp_aware_ipv6)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001205
Jaineel7e67a3f2019-08-28 15:58:49 -07001206 # issue M more requests for the same NDPs - tests post-setup multiple NDP
1207 for i in range(M):
1208 # Responder: request network
1209 resp_req_keys.append(
1210 autils.request_network(
1211 resp_dut,
1212 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1213 resp_ids[N + i], aconsts.DATA_PATH_RESPONDER, init_mac,
1214 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001215
Jaineel7e67a3f2019-08-28 15:58:49 -07001216 # Initiator: request network
1217 init_req_keys.append(
1218 autils.request_network(
1219 init_dut,
1220 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1221 init_ids[N + i], aconsts.DATA_PATH_INITIATOR, resp_mac,
1222 None)))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001223
Jaineel7e67a3f2019-08-28 15:58:49 -07001224 # wait for network formation for all subsequent requests
1225 self.wait_for_request_responses(resp_dut, resp_req_keys[N - 1:],
1226 resp_aware_ifs, init_aware_ipv6)
1227 self.wait_for_request_responses(init_dut, init_req_keys[N - 1:],
1228 init_aware_ifs, resp_aware_ipv6)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001229
Jaineel7e67a3f2019-08-28 15:58:49 -07001230 # determine whether all interfaces and ipv6 addresses are identical
1231 # (single NDP)
1232 init_aware_ifs = list(set(init_aware_ifs))
1233 resp_aware_ifs = list(set(resp_aware_ifs))
1234 init_aware_ipv6 = list(set(init_aware_ipv6))
1235 resp_aware_ipv6 = list(set(resp_aware_ipv6))
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001236
Jaineel7e67a3f2019-08-28 15:58:49 -07001237 self.log.info("Interface names: I=%s, R=%s", init_aware_ifs,
1238 resp_aware_ifs)
1239 self.log.info("Interface IPv6: I=%s, R=%s", init_aware_ipv6,
1240 resp_aware_ipv6)
1241 self.log.info("Initiator requests: %s", init_req_keys)
1242 self.log.info("Responder requests: %s", resp_req_keys)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001243
Jaineel7e67a3f2019-08-28 15:58:49 -07001244 asserts.assert_equal(
1245 len(init_aware_ifs), 1, "Multiple initiator interfaces")
1246 asserts.assert_equal(
1247 len(resp_aware_ifs), 1, "Multiple responder interfaces")
1248 asserts.assert_equal(
1249 len(init_aware_ipv6), 1, "Multiple initiator IPv6 addresses")
1250 asserts.assert_equal(
1251 len(resp_aware_ipv6), 1, "Multiple responder IPv6 addresses")
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001252
Jaineel7e67a3f2019-08-28 15:58:49 -07001253 for i in range(
1254 init_dut.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES]):
1255 # note: using get_ipv6_addr (ifconfig method) since want to verify
1256 # that interfaces which do not have any NDPs on them do not have
1257 # an IPv6 link-local address.
1258 if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
1259 init_ipv6 = autils.get_ipv6_addr(init_dut, if_name)
1260 resp_ipv6 = autils.get_ipv6_addr(resp_dut, if_name)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001261
Jaineel7e67a3f2019-08-28 15:58:49 -07001262 asserts.assert_equal(
1263 init_ipv6 is None, if_name not in init_aware_ifs,
1264 "Initiator interface %s in unexpected state" % if_name)
1265 asserts.assert_equal(
1266 resp_ipv6 is None, if_name not in resp_aware_ifs,
1267 "Responder interface %s in unexpected state" % if_name)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001268
Jaineel7e67a3f2019-08-28 15:58:49 -07001269 # release requests
1270 for resp_req_key in resp_req_keys:
1271 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
1272 for init_req_key in init_req_keys:
1273 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohen38c3d5a2017-07-28 10:02:48 -07001274
Jaineel7e67a3f2019-08-28 15:58:49 -07001275 def test_identical_network_from_both_sides(self):
1276 """Validate that requesting two identical NDPs (Open) each being initiated
Etan Cohenef38a7f2017-11-09 14:26:43 -08001277 from a different side, results in the same/single NDP.
1278
1279 Verify that the interface and IPv6 address is the same for all networks.
1280 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001281 dut1 = self.android_devices[0]
1282 dut2 = self.android_devices[1]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001283
Jaineel7e67a3f2019-08-28 15:58:49 -07001284 id1, mac1 = autils.attach_with_identity(dut1)
1285 id2, mac2 = autils.attach_with_identity(dut2)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001286
Jaineel7e67a3f2019-08-28 15:58:49 -07001287 # wait for for devices to synchronize with each other - there are no other
1288 # mechanisms to make sure this happens for OOB discovery (except retrying
1289 # to execute the data-path request)
1290 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001291
Jaineel7e67a3f2019-08-28 15:58:49 -07001292 # first NDP: DUT1 (Init) -> DUT2 (Resp)
1293 req_a_resp = autils.request_network(
1294 dut2,
1295 dut2.droid.wifiAwareCreateNetworkSpecifierOob(
1296 id2, aconsts.DATA_PATH_RESPONDER, mac1))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001297
Jaineel7e67a3f2019-08-28 15:58:49 -07001298 req_a_init = autils.request_network(
1299 dut1,
1300 dut1.droid.wifiAwareCreateNetworkSpecifierOob(
1301 id1, aconsts.DATA_PATH_INITIATOR, mac2))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001302
Jaineel7e67a3f2019-08-28 15:58:49 -07001303 req_a_resp_event_nc = autils.wait_for_event_with_keys(
1304 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1305 (cconsts.NETWORK_CB_KEY_EVENT,
1306 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1307 (cconsts.NETWORK_CB_KEY_ID, req_a_resp))
1308 req_a_init_event_nc = autils.wait_for_event_with_keys(
1309 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1310 (cconsts.NETWORK_CB_KEY_EVENT,
1311 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1312 (cconsts.NETWORK_CB_KEY_ID, req_a_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001313
Jaineel7e67a3f2019-08-28 15:58:49 -07001314 # validate no leak of information
1315 asserts.assert_false(
1316 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_a_resp_event_nc[
1317 "data"], "Network specifier leak!")
1318 asserts.assert_false(
1319 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_a_init_event_nc[
1320 "data"], "Network specifier leak!")
Etan Cohenef38a7f2017-11-09 14:26:43 -08001321
Jaineel7e67a3f2019-08-28 15:58:49 -07001322 # note that Init <-> Resp since IPv6 are of peer's!
1323 req_a_ipv6_init = req_a_resp_event_nc["data"][aconsts.NET_CAP_IPV6]
1324 req_a_ipv6_resp = req_a_init_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001325
Jaineel7e67a3f2019-08-28 15:58:49 -07001326 req_a_resp_event_lp = autils.wait_for_event_with_keys(
1327 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1328 (cconsts.NETWORK_CB_KEY_EVENT,
1329 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1330 (cconsts.NETWORK_CB_KEY_ID, req_a_resp))
1331 req_a_init_event_lp = autils.wait_for_event_with_keys(
1332 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1333 (cconsts.NETWORK_CB_KEY_EVENT,
1334 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1335 (cconsts.NETWORK_CB_KEY_ID, req_a_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001336
Jaineel7e67a3f2019-08-28 15:58:49 -07001337 req_a_if_resp = req_a_resp_event_lp["data"][
1338 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1339 req_a_if_init = req_a_init_event_lp["data"][
1340 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohenef38a7f2017-11-09 14:26:43 -08001341
Jaineel7e67a3f2019-08-28 15:58:49 -07001342 self.log.info("Interface names for A: I=%s, R=%s", req_a_if_init,
1343 req_a_if_resp)
1344 self.log.info("Interface addresses (IPv6) for A: I=%s, R=%s",
1345 req_a_ipv6_init, req_a_ipv6_resp)
Etan Cohenef38a7f2017-11-09 14:26:43 -08001346
Jaineel7e67a3f2019-08-28 15:58:49 -07001347 # second NDP: DUT2 (Init) -> DUT1 (Resp)
1348 req_b_resp = autils.request_network(
1349 dut1,
1350 dut1.droid.wifiAwareCreateNetworkSpecifierOob(
1351 id1, aconsts.DATA_PATH_RESPONDER, mac2))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001352
Jaineel7e67a3f2019-08-28 15:58:49 -07001353 req_b_init = autils.request_network(
1354 dut2,
1355 dut2.droid.wifiAwareCreateNetworkSpecifierOob(
1356 id2, aconsts.DATA_PATH_INITIATOR, mac1))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001357
Jaineel7e67a3f2019-08-28 15:58:49 -07001358 req_b_resp_event_nc = autils.wait_for_event_with_keys(
1359 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1360 (cconsts.NETWORK_CB_KEY_EVENT,
1361 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1362 (cconsts.NETWORK_CB_KEY_ID, req_b_resp))
1363 req_b_init_event_nc = autils.wait_for_event_with_keys(
1364 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1365 (cconsts.NETWORK_CB_KEY_EVENT,
1366 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1367 (cconsts.NETWORK_CB_KEY_ID, req_b_init))
Etan Cohenef38a7f2017-11-09 14:26:43 -08001368
Jaineel7e67a3f2019-08-28 15:58:49 -07001369 # validate no leak of information
1370 asserts.assert_false(
1371 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_b_resp_event_nc[
1372 "data"], "Network specifier leak!")
1373 asserts.assert_false(
1374 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in req_b_init_event_nc[
1375 "data"], "Network specifier leak!")
Etan Cohenef38a7f2017-11-09 14:26:43 -08001376
Jaineel7e67a3f2019-08-28 15:58:49 -07001377 # note that Init <-> Resp since IPv6 are of peer's!
1378 req_b_ipv6_init = req_b_resp_event_nc["data"][aconsts.NET_CAP_IPV6]
1379 req_b_ipv6_resp = req_b_init_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohena1e8d502017-08-16 09:28:18 -07001380
Jaineel7e67a3f2019-08-28 15:58:49 -07001381 req_b_resp_event_lp = autils.wait_for_event_with_keys(
1382 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1383 (cconsts.NETWORK_CB_KEY_EVENT,
1384 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1385 (cconsts.NETWORK_CB_KEY_ID, req_b_resp))
1386 req_b_init_event_lp = autils.wait_for_event_with_keys(
1387 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1388 (cconsts.NETWORK_CB_KEY_EVENT,
1389 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1390 (cconsts.NETWORK_CB_KEY_ID, req_b_init))
1391
1392 req_b_if_resp = req_b_resp_event_lp["data"][
1393 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1394 req_b_if_init = req_b_init_event_lp["data"][
1395 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1396
1397 self.log.info("Interface names for B: I=%s, R=%s", req_b_if_init,
1398 req_b_if_resp)
1399 self.log.info("Interface addresses (IPv6) for B: I=%s, R=%s",
1400 req_b_ipv6_init, req_b_ipv6_resp)
1401
1402 # validate equality of NDPs (using interface names & ipv6)
1403 asserts.assert_equal(req_a_if_init, req_b_if_resp,
1404 "DUT1 NDPs are on different interfaces")
1405 asserts.assert_equal(req_a_if_resp, req_b_if_init,
1406 "DUT2 NDPs are on different interfaces")
1407 asserts.assert_equal(req_a_ipv6_init, req_b_ipv6_resp,
1408 "DUT1 NDPs are using different IPv6 addresses")
1409 asserts.assert_equal(req_a_ipv6_resp, req_b_ipv6_init,
1410 "DUT2 NDPs are using different IPv6 addresses")
1411
1412 # release requests
1413 dut1.droid.connectivityUnregisterNetworkCallback(req_a_init)
1414 dut1.droid.connectivityUnregisterNetworkCallback(req_b_resp)
1415 dut2.droid.connectivityUnregisterNetworkCallback(req_a_resp)
1416 dut2.droid.connectivityUnregisterNetworkCallback(req_b_init)
1417
1418 ########################################################################
1419
1420 def run_multiple_ndi(self, sec_configs, flip_init_resp=False):
1421 """Validate that the device can create and use multiple NDIs.
Etan Cohena1e8d502017-08-16 09:28:18 -07001422
1423 The security configuration can be:
1424 - None: open
1425 - String: passphrase
1426 - otherwise: PMK (byte array)
1427
1428 Args:
1429 sec_configs: list of security configurations
Etan Cohend6923f22017-11-09 15:37:16 -08001430 flip_init_resp: if True the roles of Initiator and Responder are flipped
1431 between the 2 devices, otherwise same devices are always
1432 configured in the same role.
Etan Cohena1e8d502017-08-16 09:28:18 -07001433 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001434 dut1 = self.android_devices[0]
1435 dut2 = self.android_devices[1]
Etan Cohena1e8d502017-08-16 09:28:18 -07001436
Jaineel7e67a3f2019-08-28 15:58:49 -07001437 asserts.skip_if(
1438 dut1.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] <
1439 len(sec_configs)
1440 or dut2.aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] <
1441 len(sec_configs), "DUTs do not support enough NDIs")
Etan Cohena1e8d502017-08-16 09:28:18 -07001442
Jaineel7e67a3f2019-08-28 15:58:49 -07001443 id1, mac1 = autils.attach_with_identity(dut1)
1444 id2, mac2 = autils.attach_with_identity(dut2)
Etan Cohena1e8d502017-08-16 09:28:18 -07001445
Jaineel7e67a3f2019-08-28 15:58:49 -07001446 # wait for for devices to synchronize with each other - there are no other
1447 # mechanisms to make sure this happens for OOB discovery (except retrying
1448 # to execute the data-path request)
1449 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohena1e8d502017-08-16 09:28:18 -07001450
Jaineel7e67a3f2019-08-28 15:58:49 -07001451 dut2_req_keys = []
1452 dut1_req_keys = []
1453 dut2_aware_ifs = []
1454 dut1_aware_ifs = []
1455 dut2_aware_ipv6s = []
1456 dut1_aware_ipv6s = []
Etan Cohena1e8d502017-08-16 09:28:18 -07001457
Jaineel7e67a3f2019-08-28 15:58:49 -07001458 dut2_type = aconsts.DATA_PATH_RESPONDER
1459 dut1_type = aconsts.DATA_PATH_INITIATOR
1460 dut2_is_responder = True
1461 for sec in sec_configs:
1462 if dut2_is_responder:
1463 # DUT2 (Responder): request network
1464 dut2_req_key = autils.request_network(
1465 dut2,
1466 autils.get_network_specifier(dut2, id2, dut2_type, mac1,
1467 sec))
1468 dut2_req_keys.append(dut2_req_key)
Etan Cohena1e8d502017-08-16 09:28:18 -07001469
Jaineel7e67a3f2019-08-28 15:58:49 -07001470 # DUT1 (Initiator): request network
1471 dut1_req_key = autils.request_network(
1472 dut1,
1473 autils.get_network_specifier(dut1, id1, dut1_type, mac2,
1474 sec))
1475 dut1_req_keys.append(dut1_req_key)
1476 else:
1477 # DUT1 (Responder): request network
1478 dut1_req_key = autils.request_network(
1479 dut1,
1480 autils.get_network_specifier(dut1, id1, dut1_type, mac2,
1481 sec))
1482 dut1_req_keys.append(dut1_req_key)
Etan Cohend6923f22017-11-09 15:37:16 -08001483
Jaineel7e67a3f2019-08-28 15:58:49 -07001484 # DUT2 (Initiator): request network
1485 dut2_req_key = autils.request_network(
1486 dut2,
1487 autils.get_network_specifier(dut2, id2, dut2_type, mac1,
1488 sec))
1489 dut2_req_keys.append(dut2_req_key)
Etan Cohena1e8d502017-08-16 09:28:18 -07001490
Jaineel7e67a3f2019-08-28 15:58:49 -07001491 # Wait for network
1492 dut1_net_event_nc = autils.wait_for_event_with_keys(
1493 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1494 (cconsts.NETWORK_CB_KEY_EVENT,
1495 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1496 (cconsts.NETWORK_CB_KEY_ID, dut1_req_key))
1497 dut2_net_event_nc = autils.wait_for_event_with_keys(
1498 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1499 (cconsts.NETWORK_CB_KEY_EVENT,
1500 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1501 (cconsts.NETWORK_CB_KEY_ID, dut2_req_key))
Etan Cohena1e8d502017-08-16 09:28:18 -07001502
Jaineel7e67a3f2019-08-28 15:58:49 -07001503 # validate no leak of information
1504 asserts.assert_false(
1505 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in dut1_net_event_nc[
1506 "data"], "Network specifier leak!")
1507 asserts.assert_false(
1508 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in dut2_net_event_nc[
1509 "data"], "Network specifier leak!")
Etan Cohena1e8d502017-08-16 09:28:18 -07001510
Jaineel7e67a3f2019-08-28 15:58:49 -07001511 # Note: dut1 <--> dut2 IPv6's addresses since it is peer's info
1512 dut2_aware_ipv6 = dut1_net_event_nc["data"][aconsts.NET_CAP_IPV6]
1513 dut1_aware_ipv6 = dut2_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohend6923f22017-11-09 15:37:16 -08001514
Jaineel7e67a3f2019-08-28 15:58:49 -07001515 dut1_net_event_lp = autils.wait_for_event_with_keys(
1516 dut1, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1517 (cconsts.NETWORK_CB_KEY_EVENT,
1518 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1519 (cconsts.NETWORK_CB_KEY_ID, dut1_req_key))
1520 dut2_net_event_lp = autils.wait_for_event_with_keys(
1521 dut2, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1522 (cconsts.NETWORK_CB_KEY_EVENT,
1523 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1524 (cconsts.NETWORK_CB_KEY_ID, dut2_req_key))
Etan Cohena1e8d502017-08-16 09:28:18 -07001525
Jaineel7e67a3f2019-08-28 15:58:49 -07001526 dut2_aware_if = dut2_net_event_lp["data"][
1527 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
1528 dut1_aware_if = dut1_net_event_lp["data"][
1529 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohena1e8d502017-08-16 09:28:18 -07001530
Jaineel7e67a3f2019-08-28 15:58:49 -07001531 dut2_aware_ifs.append(dut2_aware_if)
1532 dut1_aware_ifs.append(dut1_aware_if)
1533 dut2_aware_ipv6s.append(dut2_aware_ipv6)
1534 dut1_aware_ipv6s.append(dut1_aware_ipv6)
Etan Cohena1e8d502017-08-16 09:28:18 -07001535
Jaineel7e67a3f2019-08-28 15:58:49 -07001536 if flip_init_resp:
1537 if dut2_is_responder:
1538 dut2_type = aconsts.DATA_PATH_INITIATOR
1539 dut1_type = aconsts.DATA_PATH_RESPONDER
1540 else:
1541 dut2_type = aconsts.DATA_PATH_RESPONDER
1542 dut1_type = aconsts.DATA_PATH_INITIATOR
1543 dut2_is_responder = not dut2_is_responder
Etan Cohena1e8d502017-08-16 09:28:18 -07001544
Jaineel7e67a3f2019-08-28 15:58:49 -07001545 # check that we are using 2 NDIs & that they have unique IPv6 addresses
1546 dut1_aware_ifs = list(set(dut1_aware_ifs))
1547 dut2_aware_ifs = list(set(dut2_aware_ifs))
1548 dut1_aware_ipv6s = list(set(dut1_aware_ipv6s))
1549 dut2_aware_ipv6s = list(set(dut2_aware_ipv6s))
Etan Cohena1e8d502017-08-16 09:28:18 -07001550
Jaineel7e67a3f2019-08-28 15:58:49 -07001551 self.log.info("Interface names: DUT1=%s, DUT2=%s", dut1_aware_ifs,
1552 dut2_aware_ifs)
1553 self.log.info("IPv6 addresses: DUT1=%s, DUT2=%s", dut1_aware_ipv6s,
1554 dut2_aware_ipv6s)
1555 self.log.info("DUT1 requests: %s", dut1_req_keys)
1556 self.log.info("DUT2 requests: %s", dut2_req_keys)
Etan Cohena1e8d502017-08-16 09:28:18 -07001557
Jaineel7e67a3f2019-08-28 15:58:49 -07001558 asserts.assert_equal(
1559 len(dut1_aware_ifs), len(sec_configs), "Multiple DUT1 interfaces")
1560 asserts.assert_equal(
1561 len(dut2_aware_ifs), len(sec_configs), "Multiple DUT2 interfaces")
1562 asserts.assert_equal(
1563 len(dut1_aware_ipv6s), len(sec_configs),
1564 "Multiple DUT1 IPv6 addresses")
1565 asserts.assert_equal(
1566 len(dut2_aware_ipv6s), len(sec_configs),
1567 "Multiple DUT2 IPv6 addresses")
1568
1569 for i in range(len(sec_configs)):
1570 # note: using get_ipv6_addr (ifconfig method) since want to verify
1571 # that the system information is the same as the reported information
1572 if_name = "%s%d" % (aconsts.AWARE_NDI_PREFIX, i)
1573 dut1_ipv6 = autils.get_ipv6_addr(dut1, if_name)
1574 dut2_ipv6 = autils.get_ipv6_addr(dut2, if_name)
1575
1576 asserts.assert_equal(
1577 dut1_ipv6 is None, if_name not in dut1_aware_ifs,
1578 "DUT1 interface %s in unexpected state" % if_name)
1579 asserts.assert_equal(
1580 dut2_ipv6 is None, if_name not in dut2_aware_ifs,
1581 "DUT2 interface %s in unexpected state" % if_name)
1582
1583 # release requests
1584 for dut2_req_key in dut2_req_keys:
1585 dut2.droid.connectivityUnregisterNetworkCallback(dut2_req_key)
1586 for dut1_req_key in dut1_req_keys:
1587 dut1.droid.connectivityUnregisterNetworkCallback(dut1_req_key)
1588
1589 @test_tracker_info(uuid="2d728163-11cc-46ba-a973-c8e1e71397fc")
1590 def test_multiple_ndi_open_passphrase(self):
1591 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001592 configuration (one open, one using passphrase). The result should use two
1593 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001594 self.run_multiple_ndi([None, self.PASSPHRASE])
Etan Cohena1e8d502017-08-16 09:28:18 -07001595
Jaineel7e67a3f2019-08-28 15:58:49 -07001596 @test_tracker_info(uuid="5f2c32aa-20b2-41f0-8b1e-d0b68df73ada")
1597 def test_multiple_ndi_open_pmk(self):
1598 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001599 configuration (one open, one using pmk). The result should use two
1600 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001601 self.run_multiple_ndi([None, self.PMK])
Etan Cohena1e8d502017-08-16 09:28:18 -07001602
Jaineel7e67a3f2019-08-28 15:58:49 -07001603 @test_tracker_info(uuid="34467659-bcfb-40cd-ba25-7e50560fca63")
1604 def test_multiple_ndi_passphrase_pmk(self):
1605 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001606 configuration (one using passphrase, one using pmk). The result should use
1607 two different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001608 self.run_multiple_ndi([self.PASSPHRASE, self.PMK])
Etan Cohena1e8d502017-08-16 09:28:18 -07001609
Jaineel7e67a3f2019-08-28 15:58:49 -07001610 @test_tracker_info(uuid="d9194ce6-45b6-41b1-9cc8-ada79968966d")
1611 def test_multiple_ndi_passphrases(self):
1612 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001613 configuration (using different passphrases). The result should use two
1614 different NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001615 self.run_multiple_ndi([self.PASSPHRASE, self.PASSPHRASE2])
Etan Cohena1e8d502017-08-16 09:28:18 -07001616
Jaineel7e67a3f2019-08-28 15:58:49 -07001617 @test_tracker_info(uuid="879df795-62d2-40d4-a862-bd46d8f7e67f")
1618 def test_multiple_ndi_pmks(self):
1619 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohena1e8d502017-08-16 09:28:18 -07001620 configuration (using different PMKS). The result should use two different
1621 NDIs"""
Jaineel7e67a3f2019-08-28 15:58:49 -07001622 self.run_multiple_ndi([self.PMK, self.PMK2])
Etan Cohend6923f22017-11-09 15:37:16 -08001623
Jaineel7e67a3f2019-08-28 15:58:49 -07001624 @test_tracker_info(uuid="397d380a-8e41-466e-9ccb-cf8f413d83ba")
1625 def test_multiple_ndi_open_passphrase_flip(self):
1626 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001627 configuration (one open, one using passphrase). The result should use two
1628 different NDIs.
1629
1630 Flip Initiator and Responder roles.
1631 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001632 self.run_multiple_ndi([None, self.PASSPHRASE], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001633
Jaineel7e67a3f2019-08-28 15:58:49 -07001634 @test_tracker_info(uuid="b3a4300b-1514-4cb8-a814-9c2baa449700")
1635 def test_multiple_ndi_open_pmk_flip(self):
1636 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001637 configuration (one open, one using pmk). The result should use two
1638 different NDIs
1639
1640 Flip Initiator and Responder roles.
1641 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001642 self.run_multiple_ndi([None, self.PMK], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001643
Jaineel7e67a3f2019-08-28 15:58:49 -07001644 @test_tracker_info(uuid="0bfea9e4-e57d-417f-8db4-245741e9bbd5")
1645 def test_multiple_ndi_passphrase_pmk_flip(self):
1646 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001647 configuration (one using passphrase, one using pmk). The result should use
1648 two different NDIs
1649
1650 Flip Initiator and Responder roles.
1651 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001652 self.run_multiple_ndi([self.PASSPHRASE, self.PMK], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001653
Jaineel7e67a3f2019-08-28 15:58:49 -07001654 @test_tracker_info(uuid="74023483-5417-431b-a362-991ad4a03ab8")
1655 def test_multiple_ndi_passphrases_flip(self):
1656 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001657 configuration (using different passphrases). The result should use two
1658 different NDIs
1659
1660 Flip Initiator and Responder roles.
1661 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001662 self.run_multiple_ndi(
1663 [self.PASSPHRASE, self.PASSPHRASE2], flip_init_resp=True)
Etan Cohend6923f22017-11-09 15:37:16 -08001664
Jaineel7e67a3f2019-08-28 15:58:49 -07001665 @test_tracker_info(uuid="873b2d91-28a1-403f-ae9c-d756bb2f59ee")
1666 def test_multiple_ndi_pmks_flip(self):
1667 """Verify that between 2 DUTs can create 2 NDPs with different security
Etan Cohend6923f22017-11-09 15:37:16 -08001668 configuration (using different PMKS). The result should use two different
1669 NDIs
1670
1671 Flip Initiator and Responder roles.
1672 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001673 self.run_multiple_ndi([self.PMK, self.PMK2], flip_init_resp=True)
Etan Cohen7922a312018-01-23 13:34:55 -08001674
Jaineel7e67a3f2019-08-28 15:58:49 -07001675 #######################################
Etan Cohen7922a312018-01-23 13:34:55 -08001676
Jaineel7e67a3f2019-08-28 15:58:49 -07001677 @test_tracker_info(uuid="2f10a9df-7fbd-490d-a238-3523f47ab54c")
1678 def test_ib_responder_any_usage(self):
1679 """Verify that configuring an in-band (Aware discovery) Responder to receive
Etan Cohen7922a312018-01-23 13:34:55 -08001680 an NDP request from any peer is not permitted by current API level. Override
1681 API check to validate that possible (i.e. that failure at current API level
1682 is due to an API check and not some underlying failure).
1683 """
1684
Jaineel7e67a3f2019-08-28 15:58:49 -07001685 # configure all devices to override API check and allow a Responder from ANY
1686 for ad in self.android_devices:
1687 autils.configure_ndp_allow_any_override(ad, True)
1688 self.run_ib_data_path_test(
1689 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1690 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1691 encr_type=self.ENCR_TYPE_OPEN,
1692 use_peer_id=False)
Etan Cohen7922a312018-01-23 13:34:55 -08001693
Jaineel7e67a3f2019-08-28 15:58:49 -07001694 # configure all devices to respect API check - i.e. disallow a Responder
1695 # from ANY
1696 for ad in self.android_devices:
1697 autils.configure_ndp_allow_any_override(ad, False)
1698 self.run_ib_data_path_test(
1699 ptype=aconsts.PUBLISH_TYPE_UNSOLICITED,
1700 stype=aconsts.SUBSCRIBE_TYPE_PASSIVE,
1701 encr_type=self.ENCR_TYPE_OPEN,
1702 use_peer_id=False,
1703 expect_failure=True)
Etan Cohen7922a312018-01-23 13:34:55 -08001704
Jaineel7e67a3f2019-08-28 15:58:49 -07001705 @test_tracker_info(uuid="5889cd41-0a72-4b7b-ab82-5b9168b9b5b8")
1706 def test_oob_responder_any_usage(self):
1707 """Verify that configuring an out-of-band (Aware discovery) Responder to
Etan Cohen7922a312018-01-23 13:34:55 -08001708 receive an NDP request from any peer is not permitted by current API level.
1709 Override API check to validate that possible (i.e. that failure at current
1710 API level is due to an API check and not some underlying failure).
1711 """
1712
Jaineel7e67a3f2019-08-28 15:58:49 -07001713 # configure all devices to override API check and allow a Responder from ANY
1714 for ad in self.android_devices:
1715 autils.configure_ndp_allow_any_override(ad, True)
1716 self.run_oob_data_path_test(
1717 encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False)
Etan Cohen7922a312018-01-23 13:34:55 -08001718
Jaineel7e67a3f2019-08-28 15:58:49 -07001719 # configure all devices to respect API check - i.e. disallow a Responder
1720 # from ANY
1721 for ad in self.android_devices:
1722 autils.configure_ndp_allow_any_override(ad, False)
1723 self.run_oob_data_path_test(
1724 encr_type=self.ENCR_TYPE_OPEN,
1725 use_peer_id=False,
1726 expect_failure=True)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001727
Jaineel7e67a3f2019-08-28 15:58:49 -07001728 #######################################
Etan Cohenc803dcc2018-02-02 15:14:04 -08001729
Jaineel7e67a3f2019-08-28 15:58:49 -07001730 def run_multiple_regulatory_domains(self, use_ib, init_domain,
1731 resp_domain):
1732 """Verify that a data-path setup with two conflicting regulatory domains
Etan Cohenc803dcc2018-02-02 15:14:04 -08001733 works (the result should be run in Channel 6 - but that is not tested).
1734
1735 Args:
1736 use_ib: True to use in-band discovery, False to use out-of-band discovery.
1737 init_domain: The regulatory domain of the Initiator/Subscriber.
1738 resp_domain: The regulator domain of the Responder/Publisher.
1739 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001740 init_dut = self.android_devices[0]
1741 resp_dut = self.android_devices[1]
Etan Cohenc803dcc2018-02-02 15:14:04 -08001742
Roshan Pius48df08c2019-09-13 08:07:30 -07001743 wutils.set_wifi_country_code(init_dut, init_domain)
1744 wutils.set_wifi_country_code(resp_dut, resp_domain)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001745
Jaineel7e67a3f2019-08-28 15:58:49 -07001746 if use_ib:
1747 (resp_req_key, init_req_key, resp_aware_if, init_aware_if,
1748 resp_ipv6, init_ipv6) = autils.create_ib_ndp(
1749 resp_dut, init_dut,
1750 autils.create_discovery_config(
1751 "GoogleTestXyz", aconsts.PUBLISH_TYPE_UNSOLICITED),
1752 autils.create_discovery_config(
1753 "GoogleTestXyz", aconsts.SUBSCRIBE_TYPE_PASSIVE),
1754 self.device_startup_offset)
1755 else:
1756 (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
1757 init_ipv6, resp_ipv6) = autils.create_oob_ndp(init_dut, resp_dut)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001758
Jaineel7e67a3f2019-08-28 15:58:49 -07001759 self.log.info("Interface names: I=%s, R=%s", init_aware_if,
1760 resp_aware_if)
1761 self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
1762 resp_ipv6)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001763
Jaineel7e67a3f2019-08-28 15:58:49 -07001764 # clean-up
1765 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
1766 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001767
Jaineel7e67a3f2019-08-28 15:58:49 -07001768 @test_tracker_info(uuid="eff53739-35c5-47a6-81f0-d70b51d89c3b")
1769 def test_multiple_regulator_domains_ib_us_jp(self):
1770 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001771
1772 - Uses in-band discovery
1773 - Subscriber=US, Publisher=JP
1774 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001775 self.run_multiple_regulatory_domains(
1776 use_ib=True,
1777 init_domain=wutils.WifiEnums.CountryCode.US,
1778 resp_domain=wutils.WifiEnums.CountryCode.JAPAN)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001779
Jaineel7e67a3f2019-08-28 15:58:49 -07001780 @test_tracker_info(uuid="19af47cc-3204-40ef-b50f-14cf7b89cf4a")
1781 def test_multiple_regulator_domains_ib_jp_us(self):
1782 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001783
1784 - Uses in-band discovery
1785 - Subscriber=JP, Publisher=US
1786 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001787 self.run_multiple_regulatory_domains(
1788 use_ib=True,
1789 init_domain=wutils.WifiEnums.CountryCode.JAPAN,
1790 resp_domain=wutils.WifiEnums.CountryCode.US)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001791
Jaineel7e67a3f2019-08-28 15:58:49 -07001792 @test_tracker_info(uuid="65285ab3-977f-4dbd-b663-d5a02f4fc663")
1793 def test_multiple_regulator_domains_oob_us_jp(self):
1794 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001795
1796 - Uses out-f-band discovery
1797 - Initiator=US, Responder=JP
1798 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001799 self.run_multiple_regulatory_domains(
1800 use_ib=False,
1801 init_domain=wutils.WifiEnums.CountryCode.US,
1802 resp_domain=wutils.WifiEnums.CountryCode.JAPAN)
Etan Cohenc803dcc2018-02-02 15:14:04 -08001803
Jaineel7e67a3f2019-08-28 15:58:49 -07001804 @test_tracker_info(uuid="8a417e24-aaf6-44b9-a089-a07c3ba8d954")
1805 def test_multiple_regulator_domains_oob_jp_us(self):
1806 """Verify data-path setup across multiple regulator domains.
Etan Cohenc803dcc2018-02-02 15:14:04 -08001807
1808 - Uses out-of-band discovery
1809 - Initiator=JP, Responder=US
1810 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001811 self.run_multiple_regulatory_domains(
1812 use_ib=False,
1813 init_domain=wutils.WifiEnums.CountryCode.JAPAN,
1814 resp_domain=wutils.WifiEnums.CountryCode.US)
Etan Cohen0ead4552017-12-27 16:17:50 -08001815
Jaineel7e67a3f2019-08-28 15:58:49 -07001816 ########################################################################
Etan Cohen0ead4552017-12-27 16:17:50 -08001817
Jaineel7e67a3f2019-08-28 15:58:49 -07001818 def run_mix_ib_oob(self, same_request, ib_first, inits_on_same_dut):
1819 """Validate that multiple network requests issued using both in-band and
Etan Cohen0ead4552017-12-27 16:17:50 -08001820 out-of-band discovery behave as expected.
1821
1822 The same_request parameter controls whether identical single NDP is
1823 expected, if True, or whether multiple NDPs on different NDIs are expected,
1824 if False.
1825
1826 Args:
1827 same_request: Issue canonically identical requests (same NMI peer, same
1828 passphrase) if True, if False use different passphrases.
1829 ib_first: If True then the in-band network is requested first, otherwise
1830 (if False) then the out-of-band network is requested first.
1831 inits_on_same_dut: If True then the Initiators are run on the same device,
1832 otherwise (if False) then the Initiators are run on
1833 different devices. Note that Subscribe == Initiator.
1834 """
Jaineel7e67a3f2019-08-28 15:58:49 -07001835 if not same_request:
1836 asserts.skip_if(
1837 self.android_devices[0]
1838 .aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < 2
1839 or self.android_devices[1]
1840 .aware_capabilities[aconsts.CAP_MAX_NDI_INTERFACES] < 2,
1841 "DUTs do not support enough NDIs")
Etan Cohen0ead4552017-12-27 16:17:50 -08001842
Jaineel7e67a3f2019-08-28 15:58:49 -07001843 (p_dut, s_dut, p_id, s_id, p_disc_id, s_disc_id, peer_id_on_sub,
1844 peer_id_on_pub_null) = self.set_up_discovery(
1845 aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE,
1846 False)
Etan Cohen0ead4552017-12-27 16:17:50 -08001847
Jaineel7e67a3f2019-08-28 15:58:49 -07001848 p_id2, p_mac = autils.attach_with_identity(p_dut)
1849 s_id2, s_mac = autils.attach_with_identity(s_dut)
Etan Cohen0ead4552017-12-27 16:17:50 -08001850
Jaineel7e67a3f2019-08-28 15:58:49 -07001851 if inits_on_same_dut:
1852 resp_dut = p_dut
1853 resp_id = p_id2
1854 resp_mac = p_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001855
Jaineel7e67a3f2019-08-28 15:58:49 -07001856 init_dut = s_dut
1857 init_id = s_id2
1858 init_mac = s_mac
1859 else:
1860 resp_dut = s_dut
1861 resp_id = s_id2
1862 resp_mac = s_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001863
Jaineel7e67a3f2019-08-28 15:58:49 -07001864 init_dut = p_dut
1865 init_id = p_id2
1866 init_mac = p_mac
Etan Cohen0ead4552017-12-27 16:17:50 -08001867
Jaineel7e67a3f2019-08-28 15:58:49 -07001868 passphrase = None if same_request else self.PASSPHRASE
Etan Cohen0ead4552017-12-27 16:17:50 -08001869
Jaineel7e67a3f2019-08-28 15:58:49 -07001870 if ib_first:
1871 # request in-band network (to completion)
1872 p_req_key = self.request_network(
1873 p_dut,
1874 p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, None))
1875 s_req_key = self.request_network(
1876 s_dut,
1877 s_dut.droid.wifiAwareCreateNetworkSpecifier(
1878 s_disc_id, peer_id_on_sub))
Etan Cohen0ead4552017-12-27 16:17:50 -08001879
Jaineel7e67a3f2019-08-28 15:58:49 -07001880 # Publisher & Subscriber: wait for network formation
1881 p_net_event_nc = autils.wait_for_event_with_keys(
1882 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1883 autils.EVENT_NDP_TIMEOUT,
1884 (cconsts.NETWORK_CB_KEY_EVENT,
1885 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1886 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1887 s_net_event_nc = autils.wait_for_event_with_keys(
1888 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1889 autils.EVENT_NDP_TIMEOUT,
1890 (cconsts.NETWORK_CB_KEY_EVENT,
1891 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1892 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
1893 p_net_event_lp = autils.wait_for_event_with_keys(
1894 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1895 autils.EVENT_NDP_TIMEOUT,
1896 (cconsts.NETWORK_CB_KEY_EVENT,
1897 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1898 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1899 s_net_event_lp = autils.wait_for_event_with_keys(
1900 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1901 autils.EVENT_NDP_TIMEOUT,
1902 (cconsts.NETWORK_CB_KEY_EVENT,
1903 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1904 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08001905
Jaineel7e67a3f2019-08-28 15:58:49 -07001906 # validate no leak of information
1907 asserts.assert_false(
1908 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
1909 "data"], "Network specifier leak!")
1910 asserts.assert_false(
1911 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
1912 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08001913
Jaineel7e67a3f2019-08-28 15:58:49 -07001914 # request out-of-band network
1915 resp_req_key = autils.request_network(
1916 resp_dut,
1917 resp_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1918 resp_id, aconsts.DATA_PATH_RESPONDER, init_mac, passphrase))
1919 init_req_key = autils.request_network(
1920 init_dut,
1921 init_dut.droid.wifiAwareCreateNetworkSpecifierOob(
1922 init_id, aconsts.DATA_PATH_INITIATOR, resp_mac, passphrase))
Etan Cohen0ead4552017-12-27 16:17:50 -08001923
Jaineel7e67a3f2019-08-28 15:58:49 -07001924 resp_net_event_nc = autils.wait_for_event_with_keys(
1925 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1926 (cconsts.NETWORK_CB_KEY_EVENT,
1927 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1928 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
1929 init_net_event_nc = autils.wait_for_event_with_keys(
1930 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1931 (cconsts.NETWORK_CB_KEY_EVENT,
1932 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1933 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
1934 resp_net_event_lp = autils.wait_for_event_with_keys(
1935 resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1936 (cconsts.NETWORK_CB_KEY_EVENT,
1937 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1938 (cconsts.NETWORK_CB_KEY_ID, resp_req_key))
1939 init_net_event_lp = autils.wait_for_event_with_keys(
1940 init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT,
1941 (cconsts.NETWORK_CB_KEY_EVENT,
1942 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1943 (cconsts.NETWORK_CB_KEY_ID, init_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08001944
Jaineel7e67a3f2019-08-28 15:58:49 -07001945 # validate no leak of information
1946 asserts.assert_false(
1947 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in resp_net_event_nc[
1948 "data"], "Network specifier leak!")
1949 asserts.assert_false(
1950 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in init_net_event_nc[
1951 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08001952
Jaineel7e67a3f2019-08-28 15:58:49 -07001953 if not ib_first:
1954 # request in-band network (to completion)
1955 p_req_key = self.request_network(
1956 p_dut,
1957 p_dut.droid.wifiAwareCreateNetworkSpecifier(p_disc_id, None))
1958 s_req_key = self.request_network(
1959 s_dut,
1960 s_dut.droid.wifiAwareCreateNetworkSpecifier(
1961 s_disc_id, peer_id_on_sub))
Etan Cohen0ead4552017-12-27 16:17:50 -08001962
Jaineel7e67a3f2019-08-28 15:58:49 -07001963 # Publisher & Subscriber: wait for network formation
1964 p_net_event_nc = autils.wait_for_event_with_keys(
1965 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1966 autils.EVENT_NDP_TIMEOUT,
1967 (cconsts.NETWORK_CB_KEY_EVENT,
1968 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1969 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1970 s_net_event_nc = autils.wait_for_event_with_keys(
1971 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1972 autils.EVENT_NDP_TIMEOUT,
1973 (cconsts.NETWORK_CB_KEY_EVENT,
1974 cconsts.NETWORK_CB_CAPABILITIES_CHANGED),
1975 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
1976 p_net_event_lp = autils.wait_for_event_with_keys(
1977 p_dut, cconsts.EVENT_NETWORK_CALLBACK,
1978 autils.EVENT_NDP_TIMEOUT,
1979 (cconsts.NETWORK_CB_KEY_EVENT,
1980 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1981 (cconsts.NETWORK_CB_KEY_ID, p_req_key))
1982 s_net_event_lp = autils.wait_for_event_with_keys(
1983 s_dut, cconsts.EVENT_NETWORK_CALLBACK,
1984 autils.EVENT_NDP_TIMEOUT,
1985 (cconsts.NETWORK_CB_KEY_EVENT,
1986 cconsts.NETWORK_CB_LINK_PROPERTIES_CHANGED),
1987 (cconsts.NETWORK_CB_KEY_ID, s_req_key))
Etan Cohen0ead4552017-12-27 16:17:50 -08001988
Jaineel7e67a3f2019-08-28 15:58:49 -07001989 # validate no leak of information
1990 asserts.assert_false(
1991 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in p_net_event_nc[
1992 "data"], "Network specifier leak!")
1993 asserts.assert_false(
1994 cconsts.NETWORK_CB_KEY_NETWORK_SPECIFIER in s_net_event_nc[
1995 "data"], "Network specifier leak!")
Etan Cohen0ead4552017-12-27 16:17:50 -08001996
Jaineel7e67a3f2019-08-28 15:58:49 -07001997 # note that Init <-> Resp & Pub <--> Sub since IPv6 are of peer's!
1998 init_ipv6 = resp_net_event_nc["data"][aconsts.NET_CAP_IPV6]
1999 resp_ipv6 = init_net_event_nc["data"][aconsts.NET_CAP_IPV6]
2000 pub_ipv6 = s_net_event_nc["data"][aconsts.NET_CAP_IPV6]
2001 sub_ipv6 = p_net_event_nc["data"][aconsts.NET_CAP_IPV6]
Etan Cohen0ead4552017-12-27 16:17:50 -08002002
Jaineel7e67a3f2019-08-28 15:58:49 -07002003 # extract net info
2004 pub_interface = p_net_event_lp["data"][
2005 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2006 sub_interface = s_net_event_lp["data"][
2007 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2008 resp_interface = resp_net_event_lp["data"][
2009 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
2010 init_interface = init_net_event_lp["data"][
2011 cconsts.NETWORK_CB_KEY_INTERFACE_NAME]
Etan Cohen0ead4552017-12-27 16:17:50 -08002012
Jaineel7e67a3f2019-08-28 15:58:49 -07002013 self.log.info("Interface names: Pub=%s, Sub=%s, Resp=%s, Init=%s",
2014 pub_interface, sub_interface, resp_interface,
2015 init_interface)
2016 self.log.info(
2017 "Interface addresses (IPv6): Pub=%s, Sub=%s, Resp=%s, Init=%s",
2018 pub_ipv6, sub_ipv6, resp_ipv6, init_ipv6)
Etan Cohen0ead4552017-12-27 16:17:50 -08002019
Jaineel7e67a3f2019-08-28 15:58:49 -07002020 # validate NDP/NDI conditions (using interface names & ipv6)
2021 if same_request:
2022 asserts.assert_equal(
2023 pub_interface, resp_interface if inits_on_same_dut else
2024 init_interface, "NDP interfaces don't match on Pub/other")
2025 asserts.assert_equal(
2026 sub_interface, init_interface if inits_on_same_dut else
2027 resp_interface, "NDP interfaces don't match on Sub/other")
Etan Cohen0ead4552017-12-27 16:17:50 -08002028
Jaineel7e67a3f2019-08-28 15:58:49 -07002029 asserts.assert_equal(pub_ipv6, resp_ipv6
2030 if inits_on_same_dut else init_ipv6,
2031 "NDP IPv6 don't match on Pub/other")
2032 asserts.assert_equal(sub_ipv6, init_ipv6
2033 if inits_on_same_dut else resp_ipv6,
2034 "NDP IPv6 don't match on Sub/other")
2035 else:
2036 asserts.assert_false(
2037 pub_interface == (resp_interface
2038 if inits_on_same_dut else init_interface),
2039 "NDP interfaces match on Pub/other")
2040 asserts.assert_false(
2041 sub_interface == (init_interface
2042 if inits_on_same_dut else resp_interface),
2043 "NDP interfaces match on Sub/other")
Etan Cohen0ead4552017-12-27 16:17:50 -08002044
Jaineel7e67a3f2019-08-28 15:58:49 -07002045 asserts.assert_false(
2046 pub_ipv6 == (resp_ipv6 if inits_on_same_dut else init_ipv6),
2047 "NDP IPv6 match on Pub/other")
2048 asserts.assert_false(
2049 sub_ipv6 == (init_ipv6 if inits_on_same_dut else resp_ipv6),
2050 "NDP IPv6 match on Sub/other")
2051
2052 # release requests
2053 p_dut.droid.connectivityUnregisterNetworkCallback(p_req_key)
2054 s_dut.droid.connectivityUnregisterNetworkCallback(s_req_key)
2055 resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
2056 init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
2057
2058 @test_tracker_info(uuid="d8a0839d-4ba0-43f2-af93-3cf1382f9f16")
2059 def test_identical_ndps_mix_ib_oob_ib_first_same_polarity(self):
2060 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002061 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2062
2063 The in-band request is issued first. Both Initiators (Sub == Initiator) are
2064 run on the same device.
2065 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002066 self.run_mix_ib_oob(
2067 same_request=True, ib_first=True, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002068
Jaineel7e67a3f2019-08-28 15:58:49 -07002069 @test_tracker_info(uuid="70bbb811-0bed-4a19-96b3-f2446e777c8a")
2070 def test_identical_ndps_mix_ib_oob_oob_first_same_polarity(self):
2071 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002072 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2073
2074 The out-of-band request is issued first. Both Initiators (Sub == Initiator)
2075 are run on the same device.
2076 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002077 self.run_mix_ib_oob(
2078 same_request=True, ib_first=False, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002079
Jaineel7e67a3f2019-08-28 15:58:49 -07002080 @test_tracker_info(uuid="d9796da5-f96a-4a51-be0f-89d6f5bfe3ad")
2081 def test_identical_ndps_mix_ib_oob_ib_first_diff_polarity(self):
2082 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002083 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2084
2085 The in-band request is issued first. Initiators (Sub == Initiator) are
2086 run on different devices.
2087 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002088 self.run_mix_ib_oob(
2089 same_request=True, ib_first=True, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002090
Jaineel7e67a3f2019-08-28 15:58:49 -07002091 @test_tracker_info(uuid="72b16cbf-53ad-4f98-8dcf-a8cc5fa812e3")
2092 def test_identical_ndps_mix_ib_oob_oob_first_diff_polarity(self):
2093 """Validate that a single NDP is created for multiple identical requests
Etan Cohen0ead4552017-12-27 16:17:50 -08002094 which are issued through either in-band (ib) or out-of-band (oob) APIs.
2095
2096 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2097 run on different devices.
2098 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002099 self.run_mix_ib_oob(
2100 same_request=True, ib_first=False, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002101
Jaineel7e67a3f2019-08-28 15:58:49 -07002102 @test_tracker_info(uuid="51f9581e-c5ee-48a7-84d2-adff4876c3d7")
2103 def test_multiple_ndis_mix_ib_oob_ib_first_same_polarity(self):
2104 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002105 different security configurations. Use a mix of in-band and out-of-band APIs
2106 to request the different NDPs.
2107
2108 The in-band request is issued first. Initiators (Sub == Initiator) are
2109 run on the same device.
2110 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002111 self.run_mix_ib_oob(
2112 same_request=False, ib_first=True, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002113
Jaineel7e67a3f2019-08-28 15:58:49 -07002114 @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853")
2115 def test_multiple_ndis_mix_ib_oob_oob_first_same_polarity(self):
2116 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002117 different security configurations. Use a mix of in-band and out-of-band APIs
2118 to request the different NDPs.
2119
2120 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2121 run on the same device.
2122 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002123 self.run_mix_ib_oob(
2124 same_request=False, ib_first=False, inits_on_same_dut=True)
Etan Cohen0ead4552017-12-27 16:17:50 -08002125
Jaineel7e67a3f2019-08-28 15:58:49 -07002126 @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853")
2127 def test_multiple_ndis_mix_ib_oob_ib_first_diff_polarity(self):
2128 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002129 different security configurations. Use a mix of in-band and out-of-band APIs
2130 to request the different NDPs.
2131
2132 The in-band request is issued first. Initiators (Sub == Initiator) are
2133 run on different devices.
2134 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002135 self.run_mix_ib_oob(
2136 same_request=False, ib_first=True, inits_on_same_dut=False)
Etan Cohen0ead4552017-12-27 16:17:50 -08002137
Jaineel7e67a3f2019-08-28 15:58:49 -07002138 @test_tracker_info(uuid="596caadf-028e-494b-bbce-8304ccec2cbb")
2139 def test_multiple_ndis_mix_ib_oob_oob_first_diff_polarity(self):
2140 """Validate that multiple NDIs are created for NDPs which are requested with
Etan Cohen0ead4552017-12-27 16:17:50 -08002141 different security configurations. Use a mix of in-band and out-of-band APIs
2142 to request the different NDPs.
2143
2144 The out-of-band request is issued first. Initiators (Sub == Initiator) are
2145 run on different devices.
2146 """
Jaineel7e67a3f2019-08-28 15:58:49 -07002147 self.run_mix_ib_oob(
2148 same_request=False, ib_first=False, inits_on_same_dut=False)
Etan Cohendbb49c92018-04-19 15:32:38 -07002149
Jaineel7e67a3f2019-08-28 15:58:49 -07002150 ########################################################################
Etan Cohendbb49c92018-04-19 15:32:38 -07002151
Jaineel7e67a3f2019-08-28 15:58:49 -07002152 def test_ndp_loop(self):
2153 """Validate that can create a loop (chain) of N NDPs between N devices,
Etan Cohendbb49c92018-04-19 15:32:38 -07002154 where N >= 3, e.g.
2155
2156 A - B
2157 B - C
2158 C - A
2159
2160 The NDPs are all OPEN (no encryption).
2161 """
Girish Moturuee454372019-10-14 11:23:02 -07002162 asserts.skip_if(
2163 len(self.android_devices) < 3,
Jaineel7e67a3f2019-08-28 15:58:49 -07002164 'A minimum of 3 devices is needed to run the test, have %d' % len(
2165 self.android_devices))
Etan Cohendbb49c92018-04-19 15:32:38 -07002166
Jaineel7e67a3f2019-08-28 15:58:49 -07002167 duts = self.android_devices
2168 loop_len = len(duts)
2169 ids = []
2170 macs = []
2171 reqs = []
2172 ifs = []
2173 ipv6s = []
Etan Cohendbb49c92018-04-19 15:32:38 -07002174
Jaineel7e67a3f2019-08-28 15:58:49 -07002175 for i in range(loop_len):
2176 duts[i].pretty_name = chr(ord("A") + i)
2177 reqs.append([])
2178 ifs.append([])
2179 ipv6s.append([])
Etan Cohendbb49c92018-04-19 15:32:38 -07002180
Jaineel7e67a3f2019-08-28 15:58:49 -07002181 # start-up 3 devices (attach w/ identity)
2182 for i in range(loop_len):
2183 ids.append(duts[i].droid.wifiAwareAttach(True))
2184 autils.wait_for_event(duts[i], aconsts.EVENT_CB_ON_ATTACHED)
2185 ident_event = autils.wait_for_event(
2186 duts[i], aconsts.EVENT_CB_ON_IDENTITY_CHANGED)
2187 macs.append(ident_event['data']['mac'])
Etan Cohendbb49c92018-04-19 15:32:38 -07002188
Jaineel7e67a3f2019-08-28 15:58:49 -07002189 # wait for for devices to synchronize with each other - there are no other
2190 # mechanisms to make sure this happens for OOB discovery (except retrying
2191 # to execute the data-path request)
2192 time.sleep(autils.WAIT_FOR_CLUSTER)
Etan Cohendbb49c92018-04-19 15:32:38 -07002193
Jaineel7e67a3f2019-08-28 15:58:49 -07002194 # create the N NDPs: i to (i+1) % N
2195 for i in range(loop_len):
2196 peer_device = (i + 1) % loop_len
Etan Cohendbb49c92018-04-19 15:32:38 -07002197
Jaineel7e67a3f2019-08-28 15:58:49 -07002198 (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
2199 init_ipv6, resp_ipv6) = autils.create_oob_ndp_on_sessions(
2200 duts[i], duts[peer_device], ids[i], macs[i], ids[peer_device],
2201 macs[peer_device])
Etan Cohendbb49c92018-04-19 15:32:38 -07002202
Jaineel7e67a3f2019-08-28 15:58:49 -07002203 reqs[i].append(init_req_key)
2204 reqs[peer_device].append(resp_req_key)
2205 ifs[i].append(init_aware_if)
2206 ifs[peer_device].append(resp_aware_if)
2207 ipv6s[i].append(init_ipv6)
2208 ipv6s[peer_device].append(resp_ipv6)
Etan Cohendbb49c92018-04-19 15:32:38 -07002209
Jaineel7e67a3f2019-08-28 15:58:49 -07002210 # clean-up
2211 for i in range(loop_len):
2212 for req in reqs[i]:
2213 duts[i].droid.connectivityUnregisterNetworkCallback(req)
Etan Cohendbb49c92018-04-19 15:32:38 -07002214
Jaineel7e67a3f2019-08-28 15:58:49 -07002215 # info
2216 self.log.info("MACs: %s", macs)
2217 self.log.info("Interface names: %s", ifs)
2218 self.log.info("IPv6 addresses: %s", ipv6s)
2219 asserts.explicit_pass(
2220 "NDP loop test", extras={
2221 "macs": macs,
2222 "ifs": ifs,
2223 "ipv6s": ipv6s
2224 })