xref: /freebsd/contrib/wpa/src/nan/nan_module_test_cases.c (revision 71e72c9e91c4b8007a4292e09669e8b549c29e97)
1 /*
2  * nan_test - NAN NDP state machine test cases
3  * Copyright (C) 2025 Intel Corporation
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #include "utils/includes.h"
10 #include "utils/common.h"
11 #include "utils/list.h"
12 #include "nan_i.h"
13 #include "nan_module_tests.h"
14 
15 static u8 default_bitmap[] = { 0xfe, 0xff, 0xfe, 0xff };
16 
nan_test_schedule_cb(struct nan_schedule * sched,bool ndc,int freq,int center_freq1,int center_freq2,int bandwidth)17 static void nan_test_schedule_cb(struct nan_schedule *sched, bool ndc,
18 				 int freq, int center_freq1, int center_freq2,
19 				 int bandwidth)
20 {
21 	os_memset(sched, 0, sizeof(*sched));
22 
23 	/* Only map ID 0 is used */
24 	sched->map_ids_bitmap = 0x1;
25 
26 	sched->n_chans = 1;
27 	sched->chans[0].chan.freq = freq;
28 	sched->chans[0].chan.center_freq1 = center_freq1;
29 	sched->chans[0].chan.center_freq2 = center_freq2;
30 	sched->chans[0].chan.bandwidth = bandwidth;
31 
32 	sched->chans[0].committed.duration = 0;
33 	sched->chans[0].committed.period = 3;
34 	sched->chans[0].committed.offset = 0;
35 	sched->chans[0].committed.len = sizeof(default_bitmap);
36 	os_memcpy(sched->chans[0].committed.bitmap, default_bitmap,
37 		  sizeof(default_bitmap));
38 
39 	sched->chans[0].map_id = 0;
40 
41 	if (!ndc)
42 		return;
43 
44 	os_memset(&sched->ndc, 0, sizeof(sched->ndc));
45 	sched->ndc.duration = 0;
46 	sched->ndc.period = 3;
47 	sched->ndc.offset = 0;
48 	sched->ndc.len = 1;
49 	sched->ndc.bitmap[0] = 0xfe;
50 }
51 
52 
nan_test_schedule_cb_all_ndc(struct nan_schedule * sched)53 static int nan_test_schedule_cb_all_ndc(struct nan_schedule *sched)
54 {
55 	static u8 seq_id = 1;
56 
57 	nan_test_schedule_cb(sched, true, 5745, 5745, true, 20);
58 	sched->sequence_id = ++seq_id;
59 	return 0;
60 }
61 
62 
nan_test_schedule_cb_all_no_ndc(struct nan_schedule * sched)63 static int nan_test_schedule_cb_all_no_ndc(struct nan_schedule *sched)
64 {
65 	static u8 seq_id = 1;
66 
67 	nan_test_schedule_cb(sched, false, 5745, 5745, 0, 20);
68 	sched->sequence_id = ++seq_id;
69 	return 0;
70 }
71 
72 
nan_test_schedule_cb_all_no_ndc_period_4(struct nan_schedule * sched)73 static int nan_test_schedule_cb_all_no_ndc_period_4(struct nan_schedule *sched)
74 {
75 	static u8 seq_id = 1;
76 
77 	nan_test_schedule_cb(sched, false, 5745, 5745, 0, 20);
78 
79 	/*
80 	 * Modify the map to have a period or 1024 TUs (both halfs are
81 	 * identical).
82 	 */
83 	sched->chans[0].committed.period = 4;
84 	sched->chans[0].committed.len += sizeof(default_bitmap);
85 	os_memcpy(sched->chans[0].committed.bitmap + sizeof(default_bitmap),
86 		  default_bitmap,
87 		  sizeof(default_bitmap));
88 
89 	sched->sequence_id = ++seq_id;
90 	return 0;
91 }
92 
93 
nan_test_schedule_cb_2ghz_no_ndc(struct nan_schedule * sched)94 static int nan_test_schedule_cb_2ghz_no_ndc(struct nan_schedule *sched)
95 {
96 	static u8 seq_id = 1;
97 
98 	nan_test_schedule_cb(sched, false, 2437, 2437, 0, 20);
99 	sched->sequence_id = ++seq_id;
100 	return 0;
101 }
102 
103 
nan_test_get_chans_default(struct nan_channels * chans)104 static int nan_test_get_chans_default(struct nan_channels *chans)
105 {
106 	chans->n_chans = 2;
107 	chans->chans = os_zalloc(sizeof(struct nan_channel_info) *
108 				 chans->n_chans);
109 	if (!chans->chans)
110 		return -1;
111 
112 	chans->chans[0].channel = 6;
113 	chans->chans[0].op_class = 81;
114 	chans->chans[0].pref = 255;
115 
116 	chans->chans[1].channel = 149;
117 	chans->chans[1].op_class = 126;
118 	chans->chans[1].pref = 254;
119 
120 	return 0;
121 }
122 
123 
nan_test_get_chans_default_reverse(struct nan_channels * chans)124 static int nan_test_get_chans_default_reverse(struct nan_channels *chans)
125 {
126 	chans->n_chans = 2;
127 	chans->chans = os_zalloc(sizeof(struct nan_channel_info) *
128 				 chans->n_chans);
129 	if (!chans->chans)
130 		return -1;
131 
132 	chans->chans[0].channel = 149;
133 	chans->chans[0].op_class = 126;
134 	chans->chans[0].pref = 255;
135 
136 	chans->chans[1].channel = 6;
137 	chans->chans[1].op_class = 81;
138 	chans->chans[1].pref = 254;
139 
140 	return 0;
141 }
142 
143 
nan_test_get_chans_default_24g(struct nan_channels * chans)144 static int nan_test_get_chans_default_24g(struct nan_channels *chans)
145 {
146 	chans->n_chans = 1;
147 	chans->chans = os_zalloc(sizeof(struct nan_channel_info) *
148 				 chans->n_chans);
149 	if (!chans->chans)
150 		return -1;
151 
152 	chans->chans[0].channel = 6;
153 	chans->chans[0].op_class = 81;
154 	chans->chans[0].pref = 255;
155 
156 	return 0;
157 }
158 
159 
nan_test_get_chans_default_52g(struct nan_channels * chans)160 static int nan_test_get_chans_default_52g(struct nan_channels *chans)
161 {
162 	chans->n_chans = 1;
163 	chans->chans = os_zalloc(sizeof(struct nan_channel_info) *
164 				 chans->n_chans);
165 	if (!chans->chans)
166 		return -1;
167 
168 	chans->chans[0].channel = 149;
169 	chans->chans[0].op_class = 126;
170 	chans->chans[0].pref = 255;
171 
172 	return 0;
173 }
174 
175 
176 static struct nan_test_case three_way_ndp_two_way_ndl_chan_149 = {
177 	.name = "Three way NDP and two way NDL channel 149",
178 	.pub_conf = {
179 		.schedule_cb = nan_test_schedule_cb_all_ndc,
180 		.get_chans_cb = nan_test_get_chans_default,
181 		.n_ndps = 1,
182 		.ndp_confs = {
183 			{
184 				.accept_request = 1,
185 				.term_once_connected = 0,
186 				.expected_result =
187 					NAN_TEST_NDP_NOTIFY_CONNECTED,
188 			},
189 		},
190 		.pot_avail = {
191 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
192 			0xba, 0x02, 0x20, 0x02, 0x04
193 		},
194 		.pot_avail_len = 13,
195 	},
196 	.sub_conf = {
197 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
198 		.get_chans_cb = nan_test_get_chans_default,
199 		.n_ndps = 1,
200 		.ndp_confs = {
201 			{
202 				.accept_request = 1,
203 				.term_once_connected = 1,
204 				.expected_result =
205 					NAN_TEST_NDP_NOTIFY_CONNECTED,
206 			},
207 		},
208 	}
209 };
210 
211 
212 static struct nan_test_case three_way_ndp_two_way_ndl_diff_period = {
213 	.name = "Three way NDP and two way NDL channel 149. Subscriber period=4",
214 	.pub_conf = {
215 		.schedule_cb = nan_test_schedule_cb_all_ndc,
216 		.get_chans_cb = nan_test_get_chans_default,
217 		.n_ndps = 1,
218 		.ndp_confs = {
219 			{
220 				.accept_request = 1,
221 				.term_once_connected = 0,
222 				.expected_result =
223 					NAN_TEST_NDP_NOTIFY_CONNECTED,
224 			},
225 		},
226 		.pot_avail = {
227 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
228 			0xba, 0x02, 0x20, 0x02, 0x04
229 		},
230 		.pot_avail_len = 13,
231 	},
232 	.sub_conf = {
233 		.schedule_cb = nan_test_schedule_cb_all_no_ndc_period_4,
234 		.get_chans_cb = nan_test_get_chans_default,
235 		.n_ndps = 1,
236 		.ndp_confs = {
237 			{
238 				.accept_request = 1,
239 				.term_once_connected = 1,
240 				.expected_result =
241 					NAN_TEST_NDP_NOTIFY_CONNECTED,
242 			},
243 		},
244 	}
245 };
246 
247 static struct nan_test_case three_way_ndp_two_way_ndl_chan_6 = {
248 	.name = "Three way NDP and two way NDL channel 6",
249 	.pub_conf = {
250 		.schedule_cb = nan_test_schedule_cb_all_ndc,
251 		.get_chans_cb = nan_test_get_chans_default,
252 		.n_ndps = 1,
253 		.ndp_confs = {
254 			{
255 				.accept_request = 1,
256 				.term_once_connected = 1,
257 				.expected_result =
258 					NAN_TEST_NDP_NOTIFY_CONNECTED,
259 			},
260 		},
261 		.pot_avail = {
262 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
263 			0xba, 0x02, 0x20, 0x02, 0x04
264 		},
265 		.pot_avail_len = 13,
266 	},
267 	.sub_conf = {
268 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
269 		.get_chans_cb = nan_test_get_chans_default_24g,
270 		.n_ndps = 1,
271 		.ndp_confs = {
272 			{
273 				.accept_request = 1,
274 				.term_once_connected = 0,
275 				.expected_result =
276 					NAN_TEST_NDP_NOTIFY_CONNECTED,
277 			},
278 		},
279 	}
280 };
281 
282 static struct nan_test_case three_way_ndp_two_way_ndl_chan_mis = {
283 	.name = "Three way NDP and two way NDL channel mismatch",
284 	.pub_conf = {
285 		.schedule_cb = nan_test_schedule_cb_all_ndc,
286 		.get_chans_cb = nan_test_get_chans_default_52g,
287 		.n_ndps = 1,
288 		.ndp_confs = {
289 			{
290 				.accept_request = 1,
291 				.expected_result =
292 					NAN_TEST_NDP_NOTIFY_DISCONNECTED,
293 			},
294 		},
295 		.pot_avail = {
296 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
297 			0xba, 0x02, 0x20, 0x02, 0x04
298 		},
299 		.pot_avail_len = 13,
300 	},
301 	.sub_conf = {
302 		.schedule_cb = nan_test_schedule_cb_2ghz_no_ndc,
303 		.get_chans_cb = nan_test_get_chans_default_24g,
304 		.n_ndps = 1,
305 		.ndp_confs = {
306 			{
307 				.accept_request = 0,
308 				.expected_result =
309 					NAN_TEST_NDP_NOTIFY_DISCONNECTED,
310 			},
311 		},
312 	}
313 };
314 
315 static struct nan_test_case three_way_ndp_three_way_ndl = {
316 	.name = "Three way NDP and three way NDL",
317 	.pub_conf = {
318 		.schedule_cb = nan_test_schedule_cb_all_ndc,
319 		.get_chans_cb = nan_test_get_chans_default,
320 		.n_ndps = 1,
321 		.ndp_confs = {
322 			{
323 				.accept_request = 1,
324 				.expected_result =
325 					NAN_TEST_NDP_NOTIFY_CONNECTED,
326 			},
327 		},
328 		.pot_avail = {
329 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
330 			0xba, 0x02, 0x20, 0x02, 0x04
331 		},
332 		.pot_avail_len = 13,
333 	},
334 	.sub_conf = {
335 		.schedule_cb = nan_test_schedule_cb_2ghz_no_ndc,
336 		.schedule_conf_cb = nan_test_schedule_cb_all_ndc,
337 		.get_chans_cb = nan_test_get_chans_default_reverse,
338 		.n_ndps = 1,
339 		.ndp_confs = {
340 			{
341 				.accept_request = 1,
342 				.expected_result =
343 					NAN_TEST_NDP_NOTIFY_CONNECTED,
344 				.term_once_connected = 1,
345 			},
346 		},
347 	}
348 };
349 
350 static struct nan_test_case three_way_ndp_two_way_ndl_reject = {
351 	.name = "Three way NDP and two way NDL rejected",
352 	.pub_conf = {
353 		.schedule_cb = nan_test_schedule_cb_all_ndc,
354 		.get_chans_cb = nan_test_get_chans_default,
355 		.n_ndps = 1,
356 		.ndp_confs = {
357 			{
358 				.accept_request = 0,
359 				.expected_result =
360 					NAN_TEST_NDP_NOTIFY_DISCONNECTED,
361 				.reason = NAN_REASON_NDP_REJECTED,
362 			},
363 		},
364 		.pot_avail = {
365 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
366 			0xba, 0x02, 0x20, 0x02, 0x04
367 		},
368 		.pot_avail_len = 13,
369 	},
370 	.sub_conf = {
371 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
372 		.get_chans_cb = nan_test_get_chans_default,
373 		.n_ndps = 1,
374 		.ndp_confs = {
375 			{
376 				.accept_request = 0,
377 				.expected_result =
378 					NAN_TEST_NDP_NOTIFY_DISCONNECTED,
379 			},
380 		},
381 	}
382 };
383 
384 
385 static struct nan_test_case four_way_ndp_two_way_ndl_chan_149_ccm_128 = {
386 	.name = "Four way NDP and two way NDL channel 149 with CCMP 128",
387 	.pub_conf = {
388 		.schedule_cb = nan_test_schedule_cb_all_ndc,
389 		.get_chans_cb = nan_test_get_chans_default,
390 		.n_ndps = 1,
391 		.ndp_confs = {
392 			{
393 				.accept_request = 1,
394 				.expected_result =
395 					NAN_TEST_NDP_NOTIFY_CONNECTED,
396 				.csid = NAN_CS_SK_CCM_128,
397 				.expected_csid = NAN_CS_SK_CCM_128,
398 			},
399 		},
400 		.pot_avail = {
401 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
402 			0xba, 0x02, 0x20, 0x02, 0x04
403 		},
404 		.pot_avail_len = 13,
405 		.pmk = {
406 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
407 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
408 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
409 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
410 		},
411 	},
412 	.sub_conf = {
413 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
414 		.get_chans_cb = nan_test_get_chans_default,
415 		.n_ndps = 1,
416 		.ndp_confs = {
417 			{
418 				.accept_request = 1,
419 				.expected_result =
420 					NAN_TEST_NDP_NOTIFY_CONNECTED,
421 				.csid = NAN_CS_SK_CCM_128,
422 				.expected_csid = NAN_CS_SK_CCM_128,
423 				.term_once_connected = 1,
424 			},
425 		},
426 		.pmk = {
427 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
428 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
429 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
430 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
431 		},
432 	}
433 };
434 
435 static struct nan_test_case four_way_ndp_two_way_ndl_chan_149_gcm_256 = {
436 	.name = "Four way NDP and three way NDL with GCMP 256",
437 	.pub_conf = {
438 		.schedule_cb = nan_test_schedule_cb_all_ndc,
439 		.get_chans_cb = nan_test_get_chans_default,
440 		.n_ndps = 1,
441 		.ndp_confs = {
442 			{
443 				.accept_request = 1,
444 				.expected_result =
445 					NAN_TEST_NDP_NOTIFY_CONNECTED,
446 				.csid = NAN_CS_SK_GCM_256,
447 				.expected_csid = NAN_CS_SK_GCM_256,
448 			},
449 		},
450 		.pot_avail = {
451 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
452 			0xba, 0x02, 0x20, 0x02, 0x04
453 		},
454 		.pot_avail_len = 13,
455 		.pmk = {
456 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
457 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
458 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
459 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
460 		},
461 	},
462 	.sub_conf = {
463 		.schedule_cb = nan_test_schedule_cb_2ghz_no_ndc,
464 		.schedule_conf_cb = nan_test_schedule_cb_all_ndc,
465 		.get_chans_cb = nan_test_get_chans_default_reverse,
466 		.n_ndps = 1,
467 		.ndp_confs = {
468 			{
469 				.accept_request = 1,
470 				.expected_result =
471 					NAN_TEST_NDP_NOTIFY_CONNECTED,
472 				.csid = NAN_CS_SK_GCM_256,
473 				.expected_csid = NAN_CS_SK_GCM_256,
474 				.term_once_connected = 1,
475 			},
476 		},
477 		.pmk = {
478 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
479 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
480 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
481 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
482 		},
483 	}
484 };
485 
486 
487 static struct nan_test_case pmk_mismatch = {
488 	.name = "PMK mismatch test case",
489 	.pub_conf = {
490 		.schedule_cb = nan_test_schedule_cb_all_ndc,
491 		.get_chans_cb = nan_test_get_chans_default,
492 		.n_ndps = 1,
493 		.ndp_confs = {
494 			{
495 				.accept_request = 1,
496 				.expected_result =
497 					NAN_TEST_NDP_NOTIFY_DISCONNECTED,
498 				.csid = NAN_CS_SK_GCM_256,
499 			},
500 		},
501 		.pot_avail = {
502 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
503 			0xba, 0x02, 0x20, 0x02, 0x04
504 		},
505 		.pot_avail_len = 13,
506 		.pmk = {
507 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
508 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
509 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
510 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
511 		},
512 	},
513 	.sub_conf = {
514 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
515 		.get_chans_cb = nan_test_get_chans_default,
516 		.n_ndps = 1,
517 		.ndp_confs = {
518 			{
519 				.accept_request = 1,
520 				.expected_result =
521 					NAN_TEST_NDP_NOTIFY_DISCONNECTED,
522 				.csid = NAN_CS_SK_GCM_256,
523 			},
524 		},
525 		.pmk = {
526 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
527 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
528 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
529 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x0,
530 		},
531 	}
532 };
533 
534 
535 static struct nan_test_case two_ndps_no_security = {
536 	.name = "Two NDPs: no security. Both accepted",
537 	.pub_conf = {
538 		.schedule_cb = nan_test_schedule_cb_all_ndc,
539 		.get_chans_cb = nan_test_get_chans_default,
540 		.n_ndps = 2,
541 		.ndp_confs = {
542 			{
543 				.accept_request = 1,
544 				.term_once_connected = 0,
545 				.expected_result =
546 					NAN_TEST_NDP_NOTIFY_CONNECTED,
547 			},
548 			{
549 				.accept_request = 1,
550 				.term_once_connected = 0,
551 				.expected_result =
552 					NAN_TEST_NDP_NOTIFY_CONNECTED,
553 			},
554 		},
555 		.pot_avail = {
556 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
557 			0xba, 0x02, 0x20, 0x02, 0x04
558 		},
559 		.pot_avail_len = 13,
560 	},
561 	.sub_conf = {
562 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
563 		.get_chans_cb = nan_test_get_chans_default,
564 		.n_ndps = 2,
565 		.ndp_confs = {
566 			{
567 				.accept_request = 1,
568 				.term_once_connected = 0,
569 				.expected_result =
570 					NAN_TEST_NDP_NOTIFY_CONNECTED,
571 			},
572 			{
573 				.accept_request = 1,
574 				.term_once_connected = 1,
575 				.expected_result =
576 					NAN_TEST_NDP_NOTIFY_CONNECTED,
577 			},
578 		},
579 	}
580 };
581 
582 
583 static struct nan_test_case three_ndps_no_security_middle_one_rejected = {
584 	.name = "Three NDPs: no security. Middle one rejected",
585 	.pub_conf = {
586 		.schedule_cb = nan_test_schedule_cb_all_ndc,
587 		.get_chans_cb = nan_test_get_chans_default,
588 		.n_ndps = 3,
589 		.ndp_confs = {
590 			{
591 				.accept_request = 1,
592 				.expected_result =
593 					NAN_TEST_NDP_NOTIFY_CONNECTED,
594 			},
595 			{
596 				.accept_request = 0,
597 				.expected_result =
598 					NAN_TEST_NDP_NOTIFY_DISCONNECTED,
599 			},
600 			{
601 				.accept_request = 1,
602 				.expected_result =
603 					NAN_TEST_NDP_NOTIFY_CONNECTED,
604 			},
605 		},
606 		.pot_avail = {
607 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
608 			0xba, 0x02, 0x20, 0x02, 0x04
609 		},
610 		.pot_avail_len = 13,
611 	},
612 	.sub_conf = {
613 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
614 		.get_chans_cb = nan_test_get_chans_default,
615 		.n_ndps = 3,
616 		.ndp_confs = {
617 			{
618 				.accept_request = 1,
619 				.expected_result =
620 					NAN_TEST_NDP_NOTIFY_CONNECTED,
621 			},
622 			{
623 				.accept_request = 1,
624 				.expected_result =
625 					NAN_TEST_NDP_NOTIFY_DISCONNECTED,
626 			},
627 			{
628 				.accept_request = 1,
629 				.term_once_connected = 1,
630 				.expected_result =
631 					NAN_TEST_NDP_NOTIFY_CONNECTED,
632 			},
633 		},
634 	}
635 };
636 
637 
638 static struct nan_test_case three_ndps_increasing_security = {
639 	.name = "Three NDPs: increasing security levels",
640 	.pub_conf = {
641 		.schedule_cb = nan_test_schedule_cb_all_ndc,
642 		.get_chans_cb = nan_test_get_chans_default,
643 		.n_ndps = 3,
644 		.ndp_confs = {
645 			{
646 				.accept_request = 1,
647 				.expected_result =
648 					NAN_TEST_NDP_NOTIFY_CONNECTED,
649 			},
650 			{
651 				.accept_request = 1,
652 				.expected_result =
653 					NAN_TEST_NDP_NOTIFY_CONNECTED,
654 				.csid = NAN_CS_SK_CCM_128,
655 				.expected_csid = NAN_CS_SK_CCM_128,
656 			},
657 			{
658 				.accept_request = 1,
659 				.expected_result =
660 					NAN_TEST_NDP_NOTIFY_CONNECTED,
661 				.csid = NAN_CS_SK_GCM_256,
662 				.expected_csid = NAN_CS_SK_GCM_256,
663 			},
664 		},
665 		.pot_avail = {
666 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
667 			0xba, 0x02, 0x20, 0x02, 0x04
668 		},
669 		.pot_avail_len = 13,
670 		.pmk = {
671 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
672 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
673 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
674 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
675 		},
676 	},
677 	.sub_conf = {
678 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
679 		.get_chans_cb = nan_test_get_chans_default,
680 		.n_ndps = 3,
681 		.ndp_confs = {
682 			{
683 				.accept_request = 1,
684 				.expected_result =
685 					NAN_TEST_NDP_NOTIFY_CONNECTED,
686 			},
687 			{
688 				.accept_request = 1,
689 				.expected_result =
690 					NAN_TEST_NDP_NOTIFY_CONNECTED,
691 				.csid = NAN_CS_SK_CCM_128,
692 				.expected_csid = NAN_CS_SK_CCM_128,
693 			},
694 			{
695 				.accept_request = 1,
696 				.term_once_connected = 1,
697 				.expected_result =
698 					NAN_TEST_NDP_NOTIFY_CONNECTED,
699 				.csid = NAN_CS_SK_GCM_256,
700 				.expected_csid = NAN_CS_SK_GCM_256,
701 			},
702 		},
703 		.pmk = {
704 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
705 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
706 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
707 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
708 		},
709 	}
710 };
711 
712 
713 static struct nan_test_case three_ndps_deacreasing_security = {
714 	.name = "Three NDPs: decreasing security levels",
715 	.pub_conf = {
716 		.schedule_cb = nan_test_schedule_cb_all_ndc,
717 		.get_chans_cb = nan_test_get_chans_default,
718 		.n_ndps = 3,
719 		.ndp_confs = {
720 			{
721 				.accept_request = 1,
722 				.expected_result =
723 					NAN_TEST_NDP_NOTIFY_CONNECTED,
724 				.csid = NAN_CS_SK_GCM_256,
725 				.expected_csid = NAN_CS_SK_GCM_256,
726 			},
727 			{
728 				.accept_request = 1,
729 				.expected_result =
730 					NAN_TEST_NDP_NOTIFY_CONNECTED,
731 				.csid = NAN_CS_SK_CCM_128,
732 				.expected_csid = NAN_CS_SK_GCM_256,
733 			},
734 			{
735 				.accept_request = 1,
736 				.expected_result =
737 					NAN_TEST_NDP_NOTIFY_CONNECTED,
738 				.expected_csid = NAN_CS_SK_GCM_256,
739 			},
740 		},
741 		.pot_avail = {
742 			0x12, 0x0a, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00,
743 			0xba, 0x02, 0x20, 0x02, 0x04
744 		},
745 		.pot_avail_len = 13,
746 		.pmk = {
747 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
748 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
749 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
750 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
751 		},
752 	},
753 	.sub_conf = {
754 		.schedule_cb = nan_test_schedule_cb_all_no_ndc,
755 		.get_chans_cb = nan_test_get_chans_default,
756 		.n_ndps = 3,
757 		.ndp_confs = {
758 			{
759 				.accept_request = 1,
760 				.expected_result =
761 					NAN_TEST_NDP_NOTIFY_CONNECTED,
762 				.csid = NAN_CS_SK_GCM_256,
763 				.expected_csid = NAN_CS_SK_GCM_256,
764 			},
765 			{
766 				.accept_request = 1,
767 				.expected_result =
768 					NAN_TEST_NDP_NOTIFY_CONNECTED,
769 				.csid = NAN_CS_SK_CCM_128,
770 				.expected_csid = NAN_CS_SK_GCM_256,
771 			},
772 			{
773 				.accept_request = 1,
774 				.term_once_connected = 1,
775 				.expected_result =
776 					NAN_TEST_NDP_NOTIFY_CONNECTED,
777 				.expected_csid = NAN_CS_SK_GCM_256,
778 			},
779 		},
780 		.pmk = {
781 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
782 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
783 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
784 			0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
785 		},
786 	}
787 };
788 
789 
790 static const struct nan_test_case *g_nan_test_cases[] = {
791 	&three_way_ndp_two_way_ndl_chan_149,
792 	&three_way_ndp_two_way_ndl_diff_period,
793 	&three_way_ndp_two_way_ndl_chan_6,
794 	&three_way_ndp_two_way_ndl_chan_mis,
795 	&three_way_ndp_two_way_ndl_reject,
796 	&three_way_ndp_three_way_ndl,
797 	&four_way_ndp_two_way_ndl_chan_149_ccm_128,
798 	&four_way_ndp_two_way_ndl_chan_149_gcm_256,
799 	&pmk_mismatch,
800 	&two_ndps_no_security,
801 	&three_ndps_no_security_middle_one_rejected,
802 	&three_ndps_increasing_security,
803 	&three_ndps_deacreasing_security,
804 	NULL
805 };
806 
807 
nan_test_case_get_next(void)808 const struct nan_test_case * nan_test_case_get_next(void)
809 {
810 	static u32 nan_test_case_idx = 0;
811 	const struct nan_test_case *curr = g_nan_test_cases[nan_test_case_idx];
812 
813 	if (curr)
814 		nan_test_case_idx++;
815 
816 	return curr;
817 }
818