xref: /freebsd/contrib/wpa/src/nan/nan_module_tests.h (revision 71e72c9e91c4b8007a4292e09669e8b549c29e97)
1 /*
2  * NAN NDP/NDL state machine testing definitions
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 #ifndef NAN_MODULE_TESTS_H
10 #define NAN_MODULE_TESTS_H
11 
12 #define NAN_TEST_NAME_MAX     32
13 
14 /**
15  * enum nan_test_ndp_notify_type - NDP notification
16  * NAN_TEST_NDP_NOTIFY_INVALID: Invalid
17  * NAN_TEST_NDP_NOTIFY_REQUEST: NDP request
18  * NAN_TEST_NDP_NOTIFY_RESPONSE: NDP response
19  * NAN_TEST_NDP_NOTIFY_CONNECTED: NDP connected
20  * NAN_TEST_NDP_NOTIFY_DISCONNECTED: NDP disconnected
21  */
22 enum nan_test_ndp_notify_type {
23 	NAN_TEST_NDP_NOTIFY_INVALID,
24 	NAN_TEST_NDP_NOTIFY_REQUEST,
25 	NAN_TEST_NDP_NOTIFY_RESPONSE,
26 	NAN_TEST_NDP_NOTIFY_CONNECTED,
27 	NAN_TEST_NDP_NOTIFY_DISCONNECTED,
28 };
29 
30 #define NAN_TEST_MAX_POT_AVAIL 256
31 #define NAN_MAX_NUM_NDPS       8
32 
33 /**
34  * nan_test_dev_conf - NAN test device configuration
35  * @schedule_cb: Callback to configure different schedule handling policies
36  *     for a device for initial request and response.
37  * @schedule_conf_cb: Callback to configure different schedule handling
38  *     policies for a device for confirmation.
39  * @get_chans_cb: Callback to configure different channels for potential
40  *     availability.
41  * @pot_avail: Device potential availability
42  * @pot_avail_len: Length of the device potential availability
43  * @n_ndps: Number of NDP configurations (to support scenarios that involve
44  *      establishing multiple NDPs in a single test case).
45  * @ndp_confs: Array of NDP configurations.
46  * @accept_request: For publisher device, indicates whether to accept an NDP
47  *     request or reject it. For subscriber device, indicates whether to accept
48  *     an NDP response or reject it.
49  * @term_once_connected: Terminate once connected.
50  * @expected_result: Expected NDP establishment result
51  * @reason: For publisher device, indicates the reject reason
52  * @csid: Cipher suite ID
53  * @expected_csid: Expected Cipher suite ID in case of a successful connection
54  * @pmk: Pairwise Master Key
55  */
56 struct nan_test_dev_conf {
57 	int (*schedule_cb)(struct nan_schedule *sched);
58 	int (*schedule_conf_cb)(struct nan_schedule *sched);
59 	int (*get_chans_cb)(struct nan_channels *chans);
60 
61 	u8 pot_avail[NAN_TEST_MAX_POT_AVAIL];
62 	size_t pot_avail_len;
63 
64 	size_t n_ndps;
65 	struct ndp_conf {
66 		bool accept_request;
67 		bool term_once_connected;
68 		enum nan_test_ndp_notify_type expected_result;
69 		u8 reason;
70 		enum nan_cipher_suite_id csid;
71 		enum nan_cipher_suite_id expected_csid;
72 	} ndp_confs[NAN_MAX_NUM_NDPS];
73 
74 	u8 pmk[PMK_LEN];
75 };
76 
77 /**
78  * nan_device - Represents a NAN test device
79  * @list: Used for global devices list
80  * @global: Pointer to NAN test global data structure
81  * @name: Test device name
82  * @nmi: Test device NMI
83  * @ndi: Test device NDI
84  * @counter: Device counter for NDP various purposes
85  * @pot_avail: Device potential availability
86  * @pot_avail_len: Length of the device potential availability
87  * @nan: Pointer to NAN data structure
88  * @conf: NAN test device configuration
89  * @n_ndps: Number of NDPs established so far minus one
90  * @connected_notify_received: Indicates whether a connected notification
91  *     was received
92  * @disconnected_notify_received: Indicates whether a disconnected notification
93  *     was received
94  * @tk: NAN TK
95  * @tk_len: Length of the NAN TK
96  * @csid: Cipher suite ID
97  */
98 struct nan_device {
99 	struct dl_list list;
100 	struct nan_test_global *global;
101 
102 	u8 name[NAN_TEST_NAME_MAX];
103 	u8 nmi[ETH_ALEN];
104 	u8 ndi[ETH_ALEN];
105 	u32 counter;
106 
107 	u8 *pot_avail;
108 	size_t pot_avail_len;
109 
110 	struct nan_data *nan;
111 	const struct nan_test_dev_conf *conf;
112 
113 	size_t n_ndps;
114 
115 	bool connected_notify_received;
116 	bool disconnected_notify_received;
117 
118 	u8 tk[NAN_TK_MAX_LEN];
119 	size_t tk_len;
120 	enum nan_cipher_suite_id csid;
121 };
122 
123 /**
124  * nan_test_case - Single NAN test configuration
125  * @name: Test name
126  * @pub_conf: Publisher test configuration
127  * @sub_conf: Subscriber test configuration
128  */
129 struct nan_test_case {
130 	const char *name;
131 	struct nan_test_dev_conf pub_conf;
132 	struct nan_test_dev_conf sub_conf;
133 };
134 
135 const struct nan_test_case * nan_test_case_get_next(void);
136 
137 #endif /* NAN_MODULE_TESTS_H */
138