1 /*
2  * Copyright (c) 2020 Nordic Semiconductor ASA
3  * Copyright (c) 2020 Demant
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <zephyr/types.h>
9 #include <zephyr/ztest.h>
10 
11 #include <zephyr/bluetooth/hci.h>
12 #include <zephyr/sys/byteorder.h>
13 #include <zephyr/sys/slist.h>
14 #include <zephyr/sys/util.h>
15 
16 #include "hal/ccm.h"
17 
18 #include "util/util.h"
19 #include "util/mem.h"
20 #include "util/memq.h"
21 #include "util/dbuf.h"
22 
23 #include "pdu_df.h"
24 #include "lll/pdu_vendor.h"
25 #include "pdu.h"
26 #include "ll.h"
27 #include "ll_settings.h"
28 #include "ll_feat.h"
29 
30 #include "lll.h"
31 #include "lll/lll_df_types.h"
32 #include "lll_conn_iso.h"
33 
34 #include "lll_conn.h"
35 #include "ull_tx_queue.h"
36 #include "isoal.h"
37 #include "ull_iso_types.h"
38 #include "ull_conn_types.h"
39 #include "ull_conn_iso_types.h"
40 
41 #include "ull_llcp.h"
42 
43 #include "helper_pdu.h"
44 #include "helper_features.h"
45 
46 #define PDU_MEM_EQUAL(_f, _s, _p, _t)                                                              \
47 	zassert_mem_equal(_s._f, _p->_f, sizeof(_p->_f), _t "\nCalled at %s:%d\n", file, line);
48 
helper_pdu_encode_ping_req(struct pdu_data * pdu,void * param)49 void helper_pdu_encode_ping_req(struct pdu_data *pdu, void *param)
50 {
51 	pdu->ll_id = PDU_DATA_LLID_CTRL;
52 	pdu->len = offsetof(struct pdu_data_llctrl, ping_req) +
53 		   sizeof(struct pdu_data_llctrl_ping_req);
54 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PING_REQ;
55 }
56 
helper_pdu_encode_ping_rsp(struct pdu_data * pdu,void * param)57 void helper_pdu_encode_ping_rsp(struct pdu_data *pdu, void *param)
58 {
59 	pdu->ll_id = PDU_DATA_LLID_CTRL;
60 	pdu->len = offsetof(struct pdu_data_llctrl, ping_rsp) +
61 		   sizeof(struct pdu_data_llctrl_ping_rsp);
62 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PING_RSP;
63 }
64 
helper_pdu_encode_feature_req(struct pdu_data * pdu,void * param)65 void helper_pdu_encode_feature_req(struct pdu_data *pdu, void *param)
66 {
67 	struct pdu_data_llctrl_feature_req *feature_req = param;
68 
69 	pdu->ll_id = PDU_DATA_LLID_CTRL;
70 	pdu->len = offsetof(struct pdu_data_llctrl, feature_req) +
71 		   sizeof(struct pdu_data_llctrl_feature_req);
72 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_FEATURE_REQ;
73 	for (int counter = 0; counter < 8; counter++) {
74 		uint8_t expected_value = feature_req->features[counter];
75 
76 		pdu->llctrl.feature_req.features[counter] = expected_value;
77 	}
78 }
helper_pdu_encode_peripheral_feature_req(struct pdu_data * pdu,void * param)79 void helper_pdu_encode_peripheral_feature_req(struct pdu_data *pdu, void *param)
80 {
81 	struct pdu_data_llctrl_feature_req *feature_req = param;
82 
83 	pdu->ll_id = PDU_DATA_LLID_CTRL;
84 	pdu->len = offsetof(struct pdu_data_llctrl, feature_req) +
85 		   sizeof(struct pdu_data_llctrl_feature_req);
86 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PER_INIT_FEAT_XCHG;
87 
88 	for (int counter = 0; counter < 8; counter++) {
89 		uint8_t expected_value = feature_req->features[counter];
90 
91 		pdu->llctrl.feature_req.features[counter] = expected_value;
92 	}
93 }
94 
helper_pdu_encode_feature_rsp(struct pdu_data * pdu,void * param)95 void helper_pdu_encode_feature_rsp(struct pdu_data *pdu, void *param)
96 {
97 	struct pdu_data_llctrl_feature_rsp *feature_rsp = param;
98 
99 	pdu->ll_id = PDU_DATA_LLID_CTRL;
100 	pdu->len = offsetof(struct pdu_data_llctrl, feature_rsp) +
101 		   sizeof(struct pdu_data_llctrl_feature_rsp);
102 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_FEATURE_RSP;
103 	for (int counter = 0; counter < 8; counter++) {
104 		uint8_t expected_value = feature_rsp->features[counter];
105 
106 		pdu->llctrl.feature_req.features[counter] = expected_value;
107 	}
108 }
109 
helper_pdu_encode_min_used_chans_ind(struct pdu_data * pdu,void * param)110 void helper_pdu_encode_min_used_chans_ind(struct pdu_data *pdu, void *param)
111 {
112 	struct pdu_data_llctrl_min_used_chans_ind *p = param;
113 
114 	pdu->ll_id = PDU_DATA_LLID_CTRL;
115 	pdu->len = offsetof(struct pdu_data_llctrl, min_used_chans_ind) +
116 		   sizeof(struct pdu_data_llctrl_min_used_chans_ind);
117 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_MIN_USED_CHAN_IND;
118 	pdu->llctrl.min_used_chans_ind.phys = p->phys;
119 	pdu->llctrl.min_used_chans_ind.min_used_chans = p->min_used_chans;
120 }
121 
helper_pdu_encode_version_ind(struct pdu_data * pdu,void * param)122 void helper_pdu_encode_version_ind(struct pdu_data *pdu, void *param)
123 {
124 	struct pdu_data_llctrl_version_ind *p = param;
125 
126 	pdu->ll_id = PDU_DATA_LLID_CTRL;
127 	pdu->len = offsetof(struct pdu_data_llctrl, version_ind) +
128 		   sizeof(struct pdu_data_llctrl_version_ind);
129 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_VERSION_IND;
130 	pdu->llctrl.version_ind.version_number = p->version_number;
131 	pdu->llctrl.version_ind.company_id = p->company_id;
132 	pdu->llctrl.version_ind.sub_version_number = p->sub_version_number;
133 }
134 
helper_pdu_encode_enc_req(struct pdu_data * pdu,void * param)135 void helper_pdu_encode_enc_req(struct pdu_data *pdu, void *param)
136 {
137 	struct pdu_data_llctrl_enc_req *p = param;
138 
139 	pdu->ll_id = PDU_DATA_LLID_CTRL;
140 	pdu->len =
141 		offsetof(struct pdu_data_llctrl, enc_req) + sizeof(struct pdu_data_llctrl_enc_req);
142 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_ENC_REQ;
143 	memcpy(pdu->llctrl.enc_req.rand, p->rand, sizeof(pdu->llctrl.enc_req.rand));
144 	memcpy(pdu->llctrl.enc_req.ediv, p->ediv, sizeof(pdu->llctrl.enc_req.ediv));
145 	memcpy(pdu->llctrl.enc_req.skdm, p->skdm, sizeof(pdu->llctrl.enc_req.skdm));
146 	memcpy(pdu->llctrl.enc_req.ivm, p->ivm, sizeof(pdu->llctrl.enc_req.ivm));
147 }
148 
helper_pdu_encode_enc_rsp(struct pdu_data * pdu,void * param)149 void helper_pdu_encode_enc_rsp(struct pdu_data *pdu, void *param)
150 {
151 	struct pdu_data_llctrl_enc_rsp *p = param;
152 
153 	pdu->ll_id = PDU_DATA_LLID_CTRL;
154 	pdu->len =
155 		offsetof(struct pdu_data_llctrl, enc_rsp) + sizeof(struct pdu_data_llctrl_enc_rsp);
156 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_ENC_RSP;
157 	memcpy(pdu->llctrl.enc_rsp.skds, p->skds, sizeof(pdu->llctrl.enc_rsp.skds));
158 	memcpy(pdu->llctrl.enc_rsp.ivs, p->ivs, sizeof(pdu->llctrl.enc_rsp.ivs));
159 }
160 
helper_pdu_encode_start_enc_req(struct pdu_data * pdu,void * param)161 void helper_pdu_encode_start_enc_req(struct pdu_data *pdu, void *param)
162 {
163 	pdu->ll_id = PDU_DATA_LLID_CTRL;
164 	pdu->len = offsetof(struct pdu_data_llctrl, start_enc_req) +
165 		   sizeof(struct pdu_data_llctrl_start_enc_req);
166 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_START_ENC_REQ;
167 }
168 
helper_pdu_encode_start_enc_rsp(struct pdu_data * pdu,void * param)169 void helper_pdu_encode_start_enc_rsp(struct pdu_data *pdu, void *param)
170 {
171 	pdu->ll_id = PDU_DATA_LLID_CTRL;
172 	pdu->len = offsetof(struct pdu_data_llctrl, start_enc_rsp) +
173 		   sizeof(struct pdu_data_llctrl_start_enc_rsp);
174 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_START_ENC_RSP;
175 }
176 
helper_pdu_encode_pause_enc_req(struct pdu_data * pdu,void * param)177 void helper_pdu_encode_pause_enc_req(struct pdu_data *pdu, void *param)
178 {
179 	pdu->ll_id = PDU_DATA_LLID_CTRL;
180 	pdu->len = offsetof(struct pdu_data_llctrl, pause_enc_req) +
181 		   sizeof(struct pdu_data_llctrl_pause_enc_req);
182 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_REQ;
183 }
184 
helper_pdu_encode_pause_enc_rsp(struct pdu_data * pdu,void * param)185 void helper_pdu_encode_pause_enc_rsp(struct pdu_data *pdu, void *param)
186 {
187 	pdu->ll_id = PDU_DATA_LLID_CTRL;
188 	pdu->len = offsetof(struct pdu_data_llctrl, pause_enc_rsp) +
189 		   sizeof(struct pdu_data_llctrl_pause_enc_rsp);
190 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_RSP;
191 }
192 
helper_pdu_encode_reject_ext_ind(struct pdu_data * pdu,void * param)193 void helper_pdu_encode_reject_ext_ind(struct pdu_data *pdu, void *param)
194 {
195 	struct pdu_data_llctrl_reject_ext_ind *p = param;
196 
197 	pdu->ll_id = PDU_DATA_LLID_CTRL;
198 	pdu->len = offsetof(struct pdu_data_llctrl, reject_ext_ind) +
199 		   sizeof(struct pdu_data_llctrl_reject_ext_ind);
200 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND;
201 	pdu->llctrl.reject_ext_ind.reject_opcode = p->reject_opcode;
202 	pdu->llctrl.reject_ext_ind.error_code = p->error_code;
203 }
204 
helper_pdu_encode_reject_ind(struct pdu_data * pdu,void * param)205 void helper_pdu_encode_reject_ind(struct pdu_data *pdu, void *param)
206 {
207 	struct pdu_data_llctrl_reject_ind *p = param;
208 
209 	pdu->ll_id = PDU_DATA_LLID_CTRL;
210 	pdu->len = offsetof(struct pdu_data_llctrl, reject_ind) +
211 		   sizeof(struct pdu_data_llctrl_reject_ind);
212 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_REJECT_IND;
213 	pdu->llctrl.reject_ind.error_code = p->error_code;
214 }
215 
helper_pdu_encode_phy_req(struct pdu_data * pdu,void * param)216 void helper_pdu_encode_phy_req(struct pdu_data *pdu, void *param)
217 {
218 	struct pdu_data_llctrl_phy_req *p = param;
219 
220 	pdu->ll_id = PDU_DATA_LLID_CTRL;
221 	pdu->len =
222 		offsetof(struct pdu_data_llctrl, phy_req) + sizeof(struct pdu_data_llctrl_phy_req);
223 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PHY_REQ;
224 	pdu->llctrl.phy_req.rx_phys = p->rx_phys;
225 	pdu->llctrl.phy_req.tx_phys = p->tx_phys;
226 }
227 
helper_pdu_encode_phy_rsp(struct pdu_data * pdu,void * param)228 void helper_pdu_encode_phy_rsp(struct pdu_data *pdu, void *param)
229 {
230 	struct pdu_data_llctrl_phy_rsp *p = param;
231 
232 	pdu->ll_id = PDU_DATA_LLID_CTRL;
233 	pdu->len =
234 		offsetof(struct pdu_data_llctrl, phy_rsp) + sizeof(struct pdu_data_llctrl_phy_rsp);
235 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PHY_RSP;
236 	pdu->llctrl.phy_rsp.rx_phys = p->rx_phys;
237 	pdu->llctrl.phy_rsp.tx_phys = p->tx_phys;
238 }
239 
helper_pdu_encode_phy_update_ind(struct pdu_data * pdu,void * param)240 void helper_pdu_encode_phy_update_ind(struct pdu_data *pdu, void *param)
241 {
242 	struct pdu_data_llctrl_phy_upd_ind *p = param;
243 
244 	pdu->ll_id = PDU_DATA_LLID_CTRL;
245 	pdu->len = offsetof(struct pdu_data_llctrl, phy_upd_ind) +
246 		   sizeof(struct pdu_data_llctrl_phy_upd_ind);
247 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND;
248 	pdu->llctrl.phy_upd_ind.instant = p->instant;
249 	pdu->llctrl.phy_upd_ind.c_to_p_phy = p->c_to_p_phy;
250 	pdu->llctrl.phy_upd_ind.p_to_c_phy = p->p_to_c_phy;
251 }
252 
helper_pdu_encode_unknown_rsp(struct pdu_data * pdu,void * param)253 void helper_pdu_encode_unknown_rsp(struct pdu_data *pdu, void *param)
254 {
255 	struct pdu_data_llctrl_unknown_rsp *p = param;
256 
257 	pdu->ll_id = PDU_DATA_LLID_CTRL;
258 	pdu->len = offsetof(struct pdu_data_llctrl, unknown_rsp) +
259 		   sizeof(struct pdu_data_llctrl_unknown_rsp);
260 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_UNKNOWN_RSP;
261 	pdu->llctrl.unknown_rsp.type = p->type;
262 }
263 
helper_pdu_encode_conn_param_req(struct pdu_data * pdu,void * param)264 void helper_pdu_encode_conn_param_req(struct pdu_data *pdu, void *param)
265 {
266 	struct pdu_data_llctrl_conn_param_req *p = param;
267 
268 	pdu->ll_id = PDU_DATA_LLID_CTRL;
269 	pdu->len = offsetof(struct pdu_data_llctrl, conn_param_req) +
270 		   sizeof(struct pdu_data_llctrl_conn_param_req);
271 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ;
272 
273 	pdu->llctrl.conn_param_req.interval_min = sys_cpu_to_le16(p->interval_min);
274 	pdu->llctrl.conn_param_req.interval_max = sys_cpu_to_le16(p->interval_max);
275 	pdu->llctrl.conn_param_req.latency = sys_cpu_to_le16(p->latency);
276 	pdu->llctrl.conn_param_req.timeout = sys_cpu_to_le16(p->timeout);
277 	pdu->llctrl.conn_param_req.preferred_periodicity = p->preferred_periodicity;
278 	pdu->llctrl.conn_param_req.reference_conn_event_count =
279 		sys_cpu_to_le16(p->reference_conn_event_count);
280 	pdu->llctrl.conn_param_req.offset0 = sys_cpu_to_le16(p->offset0);
281 	pdu->llctrl.conn_param_req.offset1 = sys_cpu_to_le16(p->offset1);
282 	pdu->llctrl.conn_param_req.offset2 = sys_cpu_to_le16(p->offset2);
283 	pdu->llctrl.conn_param_req.offset3 = sys_cpu_to_le16(p->offset3);
284 	pdu->llctrl.conn_param_req.offset4 = sys_cpu_to_le16(p->offset4);
285 	pdu->llctrl.conn_param_req.offset5 = sys_cpu_to_le16(p->offset5);
286 }
287 
helper_pdu_encode_conn_param_rsp(struct pdu_data * pdu,void * param)288 void helper_pdu_encode_conn_param_rsp(struct pdu_data *pdu, void *param)
289 {
290 	struct pdu_data_llctrl_conn_param_rsp *p = param;
291 
292 	pdu->ll_id = PDU_DATA_LLID_CTRL;
293 	pdu->len = offsetof(struct pdu_data_llctrl, conn_param_rsp) +
294 		   sizeof(struct pdu_data_llctrl_conn_param_rsp);
295 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_RSP;
296 
297 	pdu->llctrl.conn_param_rsp.interval_min = sys_cpu_to_le16(p->interval_min);
298 	pdu->llctrl.conn_param_rsp.interval_max = sys_cpu_to_le16(p->interval_max);
299 	pdu->llctrl.conn_param_rsp.latency = sys_cpu_to_le16(p->latency);
300 	pdu->llctrl.conn_param_rsp.timeout = sys_cpu_to_le16(p->timeout);
301 	pdu->llctrl.conn_param_rsp.preferred_periodicity = p->preferred_periodicity;
302 	pdu->llctrl.conn_param_rsp.reference_conn_event_count =
303 		sys_cpu_to_le16(p->reference_conn_event_count);
304 	pdu->llctrl.conn_param_rsp.offset0 = sys_cpu_to_le16(p->offset0);
305 	pdu->llctrl.conn_param_rsp.offset1 = sys_cpu_to_le16(p->offset1);
306 	pdu->llctrl.conn_param_rsp.offset2 = sys_cpu_to_le16(p->offset2);
307 	pdu->llctrl.conn_param_rsp.offset3 = sys_cpu_to_le16(p->offset3);
308 	pdu->llctrl.conn_param_rsp.offset4 = sys_cpu_to_le16(p->offset4);
309 	pdu->llctrl.conn_param_rsp.offset5 = sys_cpu_to_le16(p->offset5);
310 }
311 
helper_pdu_encode_conn_update_ind(struct pdu_data * pdu,void * param)312 void helper_pdu_encode_conn_update_ind(struct pdu_data *pdu, void *param)
313 {
314 	struct pdu_data_llctrl_conn_update_ind *p = param;
315 
316 	pdu->ll_id = PDU_DATA_LLID_CTRL;
317 	pdu->len = offsetof(struct pdu_data_llctrl, conn_update_ind) +
318 		   sizeof(struct pdu_data_llctrl_conn_update_ind);
319 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CONN_UPDATE_IND;
320 
321 	pdu->llctrl.conn_update_ind.win_size = p->win_size;
322 	pdu->llctrl.conn_update_ind.win_offset = sys_cpu_to_le16(p->win_offset);
323 	pdu->llctrl.conn_update_ind.interval = sys_cpu_to_le16(p->interval);
324 	pdu->llctrl.conn_update_ind.latency = sys_cpu_to_le16(p->latency);
325 	pdu->llctrl.conn_update_ind.timeout = sys_cpu_to_le16(p->timeout);
326 	pdu->llctrl.conn_update_ind.instant = sys_cpu_to_le16(p->instant);
327 }
328 
helper_pdu_encode_terminate_ind(struct pdu_data * pdu,void * param)329 void helper_pdu_encode_terminate_ind(struct pdu_data *pdu, void *param)
330 {
331 	struct pdu_data_llctrl_terminate_ind *p = param;
332 
333 	pdu->ll_id = PDU_DATA_LLID_CTRL;
334 	pdu->len = offsetof(struct pdu_data_llctrl, terminate_ind) +
335 		   sizeof(struct pdu_data_llctrl_terminate_ind);
336 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_TERMINATE_IND;
337 	pdu->llctrl.terminate_ind.error_code = p->error_code;
338 }
339 
helper_pdu_encode_channel_map_update_ind(struct pdu_data * pdu,void * param)340 void helper_pdu_encode_channel_map_update_ind(struct pdu_data *pdu, void *param)
341 {
342 	struct pdu_data_llctrl_chan_map_ind *p = param;
343 
344 	pdu->ll_id = PDU_DATA_LLID_CTRL;
345 	pdu->len = offsetof(struct pdu_data_llctrl, chan_map_ind) +
346 		   sizeof(struct pdu_data_llctrl_chan_map_ind);
347 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CHAN_MAP_IND;
348 	pdu->llctrl.chan_map_ind.instant = p->instant;
349 	memcpy(pdu->llctrl.chan_map_ind.chm, p->chm, sizeof(pdu->llctrl.chan_map_ind.chm));
350 }
351 
helper_pdu_encode_length_req(struct pdu_data * pdu,void * param)352 void helper_pdu_encode_length_req(struct pdu_data *pdu, void *param)
353 {
354 	struct pdu_data_llctrl_length_req *p = param;
355 
356 	pdu->ll_id = PDU_DATA_LLID_CTRL;
357 	pdu->len = offsetof(struct pdu_data_llctrl, length_req) +
358 		   sizeof(struct pdu_data_llctrl_length_req);
359 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_LENGTH_REQ;
360 
361 	pdu->llctrl.length_req.max_rx_octets = p->max_rx_octets;
362 	pdu->llctrl.length_req.max_tx_octets = p->max_tx_octets;
363 	pdu->llctrl.length_req.max_rx_time = p->max_rx_time;
364 	pdu->llctrl.length_req.max_tx_time = p->max_tx_time;
365 }
366 
helper_pdu_encode_length_rsp(struct pdu_data * pdu,void * param)367 void helper_pdu_encode_length_rsp(struct pdu_data *pdu, void *param)
368 {
369 	struct pdu_data_llctrl_length_rsp *p = param;
370 
371 	pdu->ll_id = PDU_DATA_LLID_CTRL;
372 	pdu->len = offsetof(struct pdu_data_llctrl, length_rsp) +
373 		   sizeof(struct pdu_data_llctrl_length_rsp);
374 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_LENGTH_RSP;
375 
376 	pdu->llctrl.length_req.max_rx_octets = p->max_rx_octets;
377 	pdu->llctrl.length_req.max_tx_octets = p->max_tx_octets;
378 	pdu->llctrl.length_req.max_rx_time = p->max_rx_time;
379 	pdu->llctrl.length_req.max_tx_time = p->max_tx_time;
380 }
helper_pdu_encode_cte_req(struct pdu_data * pdu,void * param)381 void helper_pdu_encode_cte_req(struct pdu_data *pdu, void *param)
382 {
383 	struct pdu_data_llctrl_cte_req *p = param;
384 
385 	pdu->ll_id = PDU_DATA_LLID_CTRL;
386 	pdu->len =
387 		offsetof(struct pdu_data_llctrl, cte_req) + sizeof(struct pdu_data_llctrl_cte_req);
388 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CTE_REQ;
389 	pdu->llctrl.cte_req.min_cte_len_req = p->min_cte_len_req;
390 	pdu->llctrl.cte_req.cte_type_req = p->cte_type_req;
391 }
392 
helper_pdu_encode_cte_rsp(struct pdu_data * pdu,void * param)393 void helper_pdu_encode_cte_rsp(struct pdu_data *pdu, void *param)
394 {
395 	pdu->ll_id = PDU_DATA_LLID_CTRL;
396 	pdu->len =
397 		offsetof(struct pdu_data_llctrl, cte_rsp) + sizeof(struct pdu_data_llctrl_cte_rsp);
398 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CTE_RSP;
399 }
400 
helper_pdu_encode_zero(struct pdu_data * pdu,void * param)401 void helper_pdu_encode_zero(struct pdu_data *pdu, void *param)
402 {
403 	pdu->ll_id = PDU_DATA_LLID_CTRL;
404 	pdu->len = 0;
405 }
406 
helper_node_encode_cte_rsp(struct node_rx_pdu * rx,void * param)407 void helper_node_encode_cte_rsp(struct node_rx_pdu *rx, void *param)
408 {
409 	rx->rx_ftr.iq_report = (struct cte_conn_iq_report *)param;
410 }
411 
helper_pdu_encode_cis_req(struct pdu_data * pdu,void * param)412 void helper_pdu_encode_cis_req(struct pdu_data *pdu, void *param)
413 {
414 	struct pdu_data_llctrl_cis_req *p = param;
415 
416 	pdu->ll_id = PDU_DATA_LLID_CTRL;
417 	pdu->len = offsetof(struct pdu_data_llctrl, cis_req) +
418 		   sizeof(struct pdu_data_llctrl_cis_req);
419 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CIS_REQ;
420 
421 	pdu->llctrl.cis_req.cig_id           =  p->cig_id;
422 	pdu->llctrl.cis_req.cis_id           =  p->cis_id;
423 	pdu->llctrl.cis_req.c_phy            =  p->c_phy;
424 	pdu->llctrl.cis_req.p_phy            =  p->p_phy;
425 	pdu->llctrl.cis_req.c_max_pdu        =  p->c_max_pdu;
426 	pdu->llctrl.cis_req.p_max_pdu        =  p->p_max_pdu;
427 	pdu->llctrl.cis_req.nse              =  p->nse;
428 	pdu->llctrl.cis_req.p_bn             =  p->p_bn;
429 	pdu->llctrl.cis_req.c_bn             =  p->c_bn;
430 	pdu->llctrl.cis_req.c_ft             =  p->c_ft;
431 	pdu->llctrl.cis_req.p_ft             =  p->p_ft;
432 	pdu->llctrl.cis_req.iso_interval     =  p->iso_interval;
433 	pdu->llctrl.cis_req.conn_event_count = p->conn_event_count;
434 	memcpy(pdu->llctrl.cis_req.c_max_sdu_packed, p->c_max_sdu_packed,
435 	       sizeof(p->c_max_sdu_packed));
436 	memcpy(pdu->llctrl.cis_req.p_max_sdu, p->p_max_sdu, sizeof(p->p_max_sdu));
437 	memcpy(pdu->llctrl.cis_req.c_sdu_interval, p->c_sdu_interval, sizeof(p->c_sdu_interval));
438 	memcpy(pdu->llctrl.cis_req.p_sdu_interval, p->p_sdu_interval, sizeof(p->p_sdu_interval));
439 	memcpy(pdu->llctrl.cis_req.sub_interval, p->sub_interval, sizeof(p->sub_interval));
440 	memcpy(pdu->llctrl.cis_req.cis_offset_min, p->cis_offset_min, sizeof(p->cis_offset_min));
441 	memcpy(pdu->llctrl.cis_req.cis_offset_max, p->cis_offset_max, sizeof(p->cis_offset_max));
442 }
443 
helper_pdu_encode_cis_rsp(struct pdu_data * pdu,void * param)444 void helper_pdu_encode_cis_rsp(struct pdu_data *pdu, void *param)
445 {
446 	struct pdu_data_llctrl_cis_rsp *p = param;
447 
448 	pdu->ll_id = PDU_DATA_LLID_CTRL;
449 	pdu->len = offsetof(struct pdu_data_llctrl, cis_rsp) +
450 		   sizeof(struct pdu_data_llctrl_cis_rsp);
451 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CIS_RSP;
452 	memcpy(pdu->llctrl.cis_rsp.cis_offset_min, p->cis_offset_min, sizeof(p->cis_offset_min));
453 	memcpy(pdu->llctrl.cis_rsp.cis_offset_max, p->cis_offset_max, sizeof(p->cis_offset_max));
454 	pdu->llctrl.cis_rsp.conn_event_count = p->conn_event_count;
455 }
456 
helper_pdu_encode_cis_ind(struct pdu_data * pdu,void * param)457 void helper_pdu_encode_cis_ind(struct pdu_data *pdu, void *param)
458 {
459 	struct pdu_data_llctrl_cis_ind *p = param;
460 
461 	pdu->ll_id = PDU_DATA_LLID_CTRL;
462 	pdu->len = offsetof(struct pdu_data_llctrl, cis_ind) +
463 		   sizeof(struct pdu_data_llctrl_cis_ind);
464 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CIS_IND;
465 	memcpy(pdu->llctrl.cis_ind.aa, p->aa, sizeof(p->aa));
466 	memcpy(pdu->llctrl.cis_ind.cis_offset, p->cis_offset, sizeof(p->cis_offset));
467 	memcpy(pdu->llctrl.cis_ind.cig_sync_delay, p->cig_sync_delay, sizeof(p->cig_sync_delay));
468 	memcpy(pdu->llctrl.cis_ind.cis_sync_delay, p->cis_sync_delay, sizeof(p->cis_sync_delay));
469 	pdu->llctrl.cis_ind.conn_event_count = p->conn_event_count;
470 }
471 
helper_pdu_encode_cis_terminate_ind(struct pdu_data * pdu,void * param)472 void helper_pdu_encode_cis_terminate_ind(struct pdu_data *pdu, void *param)
473 {
474 	struct pdu_data_llctrl_cis_terminate_ind *p = param;
475 
476 	pdu->ll_id = PDU_DATA_LLID_CTRL;
477 	pdu->len = offsetof(struct pdu_data_llctrl, cis_terminate_ind) +
478 		   sizeof(struct pdu_data_llctrl_cis_terminate_ind);
479 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CIS_TERMINATE_IND;
480 	pdu->llctrl.cis_terminate_ind.cig_id = p->cig_id;
481 	pdu->llctrl.cis_terminate_ind.cis_id = p->cis_id;
482 	pdu->llctrl.cis_terminate_ind.error_code = p->error_code;
483 }
484 
helper_pdu_encode_sca_req(struct pdu_data * pdu,void * param)485 void helper_pdu_encode_sca_req(struct pdu_data *pdu, void *param)
486 {
487 	struct pdu_data_llctrl_clock_accuracy_req *p = param;
488 
489 	pdu->ll_id = PDU_DATA_LLID_CTRL;
490 	pdu->len = offsetof(struct pdu_data_llctrl, clock_accuracy_req) +
491 		sizeof(struct pdu_data_llctrl_clock_accuracy_req);
492 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CLOCK_ACCURACY_REQ;
493 	pdu->llctrl.clock_accuracy_req.sca = p->sca;
494 }
495 
helper_pdu_encode_sca_rsp(struct pdu_data * pdu,void * param)496 void helper_pdu_encode_sca_rsp(struct pdu_data *pdu, void *param)
497 {
498 	struct pdu_data_llctrl_clock_accuracy_rsp *p = param;
499 
500 	pdu->ll_id = PDU_DATA_LLID_CTRL;
501 	pdu->len = offsetof(struct pdu_data_llctrl, clock_accuracy_rsp) +
502 		sizeof(struct pdu_data_llctrl_clock_accuracy_rsp);
503 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CLOCK_ACCURACY_RSP;
504 	pdu->llctrl.clock_accuracy_rsp.sca = p->sca;
505 }
506 
helper_pdu_encode_periodic_sync_ind(struct pdu_data * pdu,void * param)507 void helper_pdu_encode_periodic_sync_ind(struct pdu_data *pdu, void *param)
508 {
509 	struct pdu_data_llctrl_periodic_sync_ind *p = param;
510 
511 	pdu->ll_id = PDU_DATA_LLID_CTRL;
512 	pdu->len = offsetof(struct pdu_data_llctrl, periodic_sync_ind) +
513 		sizeof(struct pdu_data_llctrl_periodic_sync_ind);
514 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_PERIODIC_SYNC_IND;
515 
516 	pdu->llctrl.periodic_sync_ind.id = sys_cpu_to_le16(p->id);
517 
518 	memcpy(&pdu->llctrl.periodic_sync_ind.sync_info, &p->sync_info,
519 			sizeof(struct pdu_adv_sync_info));
520 
521 	pdu->llctrl.periodic_sync_ind.conn_event_count = sys_cpu_to_le16(p->conn_event_count);
522 	pdu->llctrl.periodic_sync_ind.last_pa_event_counter =
523 							sys_cpu_to_le16(p->last_pa_event_counter);
524 	pdu->llctrl.periodic_sync_ind.sid = p->sid;
525 	pdu->llctrl.periodic_sync_ind.addr_type = p->addr_type;
526 	pdu->llctrl.periodic_sync_ind.sca = p->sca;
527 	pdu->llctrl.periodic_sync_ind.phy = p->phy;
528 
529 	memcpy(pdu->llctrl.periodic_sync_ind.adv_addr, p->adv_addr, sizeof(p->adv_addr));
530 
531 	pdu->llctrl.periodic_sync_ind.sync_conn_event_count = p->sync_conn_event_count;
532 }
533 
helper_pdu_verify_version_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)534 void helper_pdu_verify_version_ind(const char *file, uint32_t line, struct pdu_data *pdu,
535 				   void *param)
536 {
537 	struct pdu_data_llctrl_version_ind *p = param;
538 
539 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
540 		      line);
541 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_VERSION_IND,
542 		      "Not a LL_VERSION_IND.\nCalled at %s:%d\n", file, line);
543 	zassert_equal(pdu->llctrl.version_ind.version_number, p->version_number,
544 		      "Wrong version number.\nCalled at %s:%d\n", file, line);
545 	zassert_equal(pdu->llctrl.version_ind.company_id, p->company_id,
546 		      "Wrong company id.\nCalled at %s:%d\n", file, line);
547 	zassert_equal(pdu->llctrl.version_ind.sub_version_number, p->sub_version_number,
548 		      "Wrong sub version number.\nCalled at %s:%d\n", file, line);
549 }
550 
helper_pdu_verify_ping_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)551 void helper_pdu_verify_ping_req(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
552 {
553 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
554 		      line);
555 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PING_REQ,
556 		      "Not a LL_PING_REQ. Called at %s:%d\n", file, line);
557 }
558 
helper_pdu_verify_ping_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)559 void helper_pdu_verify_ping_rsp(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
560 {
561 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
562 		      line);
563 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PING_RSP,
564 		      "Not a LL_PING_RSP.\nCalled at %s:%d\n", file, line);
565 }
566 
helper_pdu_verify_feature_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)567 void helper_pdu_verify_feature_req(const char *file, uint32_t line, struct pdu_data *pdu,
568 				   void *param)
569 {
570 	struct pdu_data_llctrl_feature_req *feature_req = param;
571 
572 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL);
573 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_FEATURE_REQ,
574 		      "Wrong opcode.\nCalled at %s:%d\n", file, line);
575 
576 	for (int counter = 0; counter < 8; counter++) {
577 		uint8_t expected_value = feature_req->features[counter];
578 
579 		zassert_equal(pdu->llctrl.feature_req.features[counter], expected_value,
580 			      "Wrong feature exchange data.\nAt %s:%d\n", file, line);
581 	}
582 }
583 
helper_pdu_verify_peripheral_feature_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)584 void helper_pdu_verify_peripheral_feature_req(const char *file, uint32_t line, struct pdu_data *pdu,
585 					      void *param)
586 {
587 	struct pdu_data_llctrl_feature_req *feature_req = param;
588 
589 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL);
590 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PER_INIT_FEAT_XCHG);
591 
592 	for (int counter = 0; counter < 8; counter++) {
593 		uint8_t expected_value = feature_req->features[counter];
594 
595 		zassert_equal(pdu->llctrl.feature_req.features[counter], expected_value,
596 			      "Wrong feature data\nCalled at %s:%d\n", file, line);
597 	}
598 }
599 
helper_pdu_verify_feature_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)600 void helper_pdu_verify_feature_rsp(const char *file, uint32_t line, struct pdu_data *pdu,
601 				   void *param)
602 {
603 	struct pdu_data_llctrl_feature_rsp *feature_rsp = param;
604 
605 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL);
606 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_FEATURE_RSP,
607 		      "Response: %d Expected: %d\n", pdu->llctrl.opcode,
608 		      PDU_DATA_LLCTRL_TYPE_FEATURE_RSP);
609 
610 	for (int counter = 0; counter < 8; counter++) {
611 		uint8_t expected_value = feature_rsp->features[counter];
612 
613 		zassert_equal(pdu->llctrl.feature_rsp.features[counter], expected_value,
614 			      "Wrong feature data\nCalled at %s:%d\n", file, line);
615 	}
616 }
617 
helper_pdu_verify_min_used_chans_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)618 void helper_pdu_verify_min_used_chans_ind(const char *file, uint32_t line, struct pdu_data *pdu,
619 					  void *param)
620 {
621 	struct pdu_data_llctrl_min_used_chans_ind *p = param;
622 
623 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
624 		      line);
625 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_MIN_USED_CHAN_IND,
626 		      "Not a MIN_USED_CHAN_IND.\nCalled at %s:%d\n", file, line);
627 	zassert_equal(pdu->llctrl.min_used_chans_ind.phys, p->phys, "Wrong PHY.\nCalled at %s:%d\n",
628 		      file, line);
629 	zassert_equal(pdu->llctrl.min_used_chans_ind.min_used_chans, p->min_used_chans,
630 		      "Channel count\nCalled at %s:%d\n", file, line);
631 }
632 
helper_pdu_verify_enc_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)633 void helper_pdu_verify_enc_req(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
634 {
635 	struct pdu_data_llctrl_enc_req *p = param;
636 
637 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
638 		      line);
639 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_ENC_REQ,
640 		      "Not a LL_ENC_REQ. Called at %s:%d\n", file, line);
641 
642 	PDU_MEM_EQUAL(rand, pdu->llctrl.enc_req, p, "Rand mismatch.");
643 	PDU_MEM_EQUAL(ediv, pdu->llctrl.enc_req, p, "EDIV mismatch.");
644 	PDU_MEM_EQUAL(skdm, pdu->llctrl.enc_req, p, "SKDm mismatch.");
645 	PDU_MEM_EQUAL(ivm, pdu->llctrl.enc_req, p, "IVm mismatch.");
646 }
647 
helper_pdu_ntf_verify_enc_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)648 void helper_pdu_ntf_verify_enc_req(const char *file, uint32_t line, struct pdu_data *pdu,
649 				   void *param)
650 {
651 	struct pdu_data_llctrl_enc_req *p = param;
652 
653 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
654 		      line);
655 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_ENC_REQ,
656 		      "Not a LL_ENC_REQ. Called at %s:%d\n", file, line);
657 
658 	PDU_MEM_EQUAL(rand, pdu->llctrl.enc_req, p, "Rand mismatch.");
659 	PDU_MEM_EQUAL(ediv, pdu->llctrl.enc_req, p, "EDIV mismatch.");
660 }
661 
helper_pdu_verify_enc_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)662 void helper_pdu_verify_enc_rsp(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
663 {
664 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
665 		      line);
666 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_ENC_RSP,
667 		      "Not a LL_ENC_RSP.\nCalled at %s:%d\n", file, line);
668 }
669 
helper_pdu_verify_start_enc_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)670 void helper_pdu_verify_start_enc_req(const char *file, uint32_t line, struct pdu_data *pdu,
671 				     void *param)
672 {
673 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
674 		      line);
675 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_START_ENC_REQ,
676 		      "Not a LL_START_ENC_REQ.\nCalled at %s:%d\n", file, line);
677 }
678 
helper_pdu_verify_start_enc_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)679 void helper_pdu_verify_start_enc_rsp(const char *file, uint32_t line, struct pdu_data *pdu,
680 				     void *param)
681 {
682 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
683 		      line);
684 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_START_ENC_RSP,
685 		      "Not a LL_START_ENC_RSP.\nCalled at %s:%d\n", file, line);
686 }
687 
helper_pdu_verify_pause_enc_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)688 void helper_pdu_verify_pause_enc_req(const char *file, uint32_t line, struct pdu_data *pdu,
689 				     void *param)
690 {
691 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
692 		      line);
693 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_REQ,
694 		      "Not a LL_PAUSE_ENC_REQ.\nCalled at %s:%d\n", file, line);
695 }
696 
helper_pdu_verify_pause_enc_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)697 void helper_pdu_verify_pause_enc_rsp(const char *file, uint32_t line, struct pdu_data *pdu,
698 				     void *param)
699 {
700 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
701 		      line);
702 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_RSP,
703 		      "Not a LL_PAUSE_ENC_RSP.\nCalled at %s:%d\n", file, line);
704 }
705 
helper_node_verify_enc_refresh(const char * file,uint32_t line,struct node_rx_pdu * rx,void * param)706 void helper_node_verify_enc_refresh(const char *file, uint32_t line, struct node_rx_pdu *rx,
707 				    void *param)
708 {
709 	zassert_equal(rx->hdr.type, NODE_RX_TYPE_ENC_REFRESH,
710 		      "Not an ENC_REFRESH node.\nCalled at %s:%d\n", file, line);
711 }
712 
helper_pdu_verify_reject_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)713 void helper_pdu_verify_reject_ind(const char *file, uint32_t line, struct pdu_data *pdu,
714 				  void *param)
715 {
716 	struct pdu_data_llctrl_reject_ind *p = param;
717 
718 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
719 		      line);
720 	zassert_equal(pdu->len,
721 		      offsetof(struct pdu_data_llctrl, reject_ind) +
722 			      sizeof(struct pdu_data_llctrl_reject_ind),
723 		      "Wrong length.\nCalled at %s:%d\n", file, line);
724 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_REJECT_IND,
725 		      "Not a LL_REJECT_IND.\nCalled at %s:%d\n", file, line);
726 	zassert_equal(pdu->llctrl.reject_ind.error_code, p->error_code,
727 		      "Error code mismatch.\nCalled at %s:%d\n", file, line);
728 }
729 
helper_pdu_verify_reject_ext_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)730 void helper_pdu_verify_reject_ext_ind(const char *file, uint32_t line, struct pdu_data *pdu,
731 				      void *param)
732 {
733 	struct pdu_data_llctrl_reject_ext_ind *p = param;
734 
735 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
736 		      line);
737 	zassert_equal(pdu->len,
738 		      offsetof(struct pdu_data_llctrl, reject_ext_ind) +
739 			      sizeof(struct pdu_data_llctrl_reject_ext_ind),
740 		      "Wrong length.\nCalled at %s:%d\n", file, line);
741 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND,
742 		      "Not a LL_REJECT_EXT_IND.\nCalled at %s:%d\n", file, line);
743 	zassert_equal(pdu->llctrl.reject_ext_ind.reject_opcode, p->reject_opcode,
744 		      "Reject opcode mismatch.\nCalled at %s:%d\n", file, line);
745 	zassert_equal(pdu->llctrl.reject_ext_ind.error_code, p->error_code,
746 		      "Error code mismatch.\nCalled at %s:%d\n", file, line);
747 }
748 
helper_pdu_verify_phy_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)749 void helper_pdu_verify_phy_req(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
750 {
751 	struct pdu_data_llctrl_phy_req *p = param;
752 
753 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
754 		      line);
755 	zassert_equal(pdu->len,
756 		      offsetof(struct pdu_data_llctrl, phy_req) +
757 			      sizeof(struct pdu_data_llctrl_phy_req),
758 		      "Wrong length.\nCalled at %s:%d\n", file, line);
759 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PHY_REQ,
760 		      "Not a LL_PHY_REQ.\nCalled at %s:%d\n", file, line);
761 	zassert_equal(pdu->llctrl.phy_req.rx_phys, p->rx_phys,
762 		      "rx phys mismatch.\nCalled at %s:%d\n", file, line);
763 	zassert_equal(pdu->llctrl.phy_req.tx_phys, p->tx_phys,
764 		      "tx phys mismatch.\nCalled at %s:%d\n", file, line);
765 }
766 
helper_pdu_verify_phy_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)767 void helper_pdu_verify_phy_rsp(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
768 {
769 	struct pdu_data_llctrl_phy_rsp *p = param;
770 
771 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
772 		      line);
773 	zassert_equal(pdu->len,
774 		      offsetof(struct pdu_data_llctrl, phy_rsp) +
775 			      sizeof(struct pdu_data_llctrl_phy_rsp),
776 		      "Wrong length.\nCalled at %s:%d\n", file, line);
777 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PHY_RSP,
778 		      "Not a LL_PHY_RSP.\nCalled at %s:%d\n", file, line);
779 	zassert_equal(pdu->llctrl.phy_rsp.rx_phys, p->rx_phys,
780 		      "rx phys mismatch.\nCalled at %s:%d\n", file, line);
781 	zassert_equal(pdu->llctrl.phy_rsp.tx_phys, p->tx_phys,
782 		      "tx phys mismatch.\nCalled at %s:%d\n", file, line);
783 }
784 
helper_pdu_verify_phy_update_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)785 void helper_pdu_verify_phy_update_ind(const char *file, uint32_t line, struct pdu_data *pdu,
786 				      void *param)
787 {
788 	struct pdu_data_llctrl_phy_upd_ind *p = param;
789 
790 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
791 		      line);
792 	zassert_equal(pdu->len,
793 		      offsetof(struct pdu_data_llctrl, phy_upd_ind) +
794 			      sizeof(struct pdu_data_llctrl_phy_upd_ind),
795 		      "Wrong length.\nCalled at %s:%d\n", file, line);
796 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND,
797 		      "Not a LL_PHY_UPDATE_IND.\nCalled at %s:%d\n", file, line);
798 	zassert_equal(pdu->llctrl.phy_upd_ind.instant, p->instant,
799 		      "instant mismatch.\nCalled at %s:%d\n", file, line);
800 	zassert_equal(pdu->llctrl.phy_upd_ind.c_to_p_phy, p->c_to_p_phy,
801 		      "c_to_p_phy mismatch.\nCalled at %s:%d\n", file, line);
802 	zassert_equal(pdu->llctrl.phy_upd_ind.p_to_c_phy, p->p_to_c_phy,
803 		      "p_to_c_phy mismatch.\nCalled at %s:%d\n", file, line);
804 }
805 
helper_node_verify_phy_update(const char * file,uint32_t line,struct node_rx_pdu * rx,void * param)806 void helper_node_verify_phy_update(const char *file, uint32_t line, struct node_rx_pdu *rx,
807 				   void *param)
808 {
809 	struct node_rx_pu *pdu = (struct node_rx_pu *)rx->pdu;
810 	struct node_rx_pu *p = param;
811 
812 	zassert_equal(rx->hdr.type, NODE_RX_TYPE_PHY_UPDATE,
813 		      "Not a PHY_UPDATE node.\nCalled at %s:%d\n", file, line);
814 	zassert_equal(pdu->status, p->status, "Status mismatch.\nCalled at %s:%d\n", file, line);
815 }
816 
helper_node_verify_peer_sca_update(const char * file,uint32_t line,struct node_rx_pdu * rx,void * param)817 void helper_node_verify_peer_sca_update(const char *file, uint32_t line, struct node_rx_pdu *rx,
818 				   void *param)
819 {
820 	struct node_rx_sca *pdu = (struct node_rx_sca *)rx->pdu;
821 	struct node_rx_sca *p = param;
822 
823 	zassert_equal(rx->hdr.type, NODE_RX_TYPE_REQ_PEER_SCA_COMPLETE,
824 		      "Not an SCA node.\nCalled at %s:%d\n", file, line);
825 	zassert_equal(pdu->status, p->status, "Status mismatch.\nCalled at %s:%d\n", file, line);
826 	zassert_equal(pdu->sca, p->sca, "SCA mismatch.\nCalled at %s:%d\n", file, line);
827 }
828 
helper_pdu_verify_unknown_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)829 void helper_pdu_verify_unknown_rsp(const char *file, uint32_t line, struct pdu_data *pdu,
830 				   void *param)
831 {
832 	struct pdu_data_llctrl_unknown_rsp *p = param;
833 
834 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
835 		      line);
836 	zassert_equal(pdu->len,
837 		      offsetof(struct pdu_data_llctrl, unknown_rsp) +
838 			      sizeof(struct pdu_data_llctrl_unknown_rsp),
839 		      "Wrong length.\nCalled at %s:%d\n", file, line);
840 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_UNKNOWN_RSP,
841 		      "Not a LL_UNKNOWN_RSP.\nCalled at %s:%d\n", file, line);
842 	zassert_equal(pdu->llctrl.unknown_rsp.type, p->type, "Type mismatch.\nCalled at %s:%d\n",
843 		      file, line);
844 }
845 
helper_pdu_verify_conn_param_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)846 void helper_pdu_verify_conn_param_req(const char *file, uint32_t line, struct pdu_data *pdu,
847 				      void *param)
848 {
849 	struct pdu_data_llctrl_conn_param_req *p = param;
850 
851 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
852 		      line);
853 	zassert_equal(pdu->len,
854 		      offsetof(struct pdu_data_llctrl, conn_param_req) +
855 			      sizeof(struct pdu_data_llctrl_conn_param_req),
856 		      "Wrong length.\nCalled at %s:%d\n", file, line);
857 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ,
858 		      "Not a LL_CONNECTION_PARAM_REQ.\nCalled at %s:%d\n", file, line);
859 
860 	zassert_equal(pdu->llctrl.conn_param_req.interval_min, p->interval_min,
861 		      "Interval_min mismatch.\nCalled at %s:%d\n", file, line);
862 	zassert_equal(pdu->llctrl.conn_param_req.interval_max, p->interval_max,
863 		      "Interval_max mismatch.\nCalled at %s:%d\n", file, line);
864 	zassert_equal(pdu->llctrl.conn_param_req.latency, p->latency,
865 		      "Latency mismatch.\nCalled at %s:%d\n", file, line);
866 	zassert_equal(pdu->llctrl.conn_param_req.timeout, p->timeout,
867 		      "Timeout mismatch.\nCalled at %s:%d\n", file, line);
868 	zassert_equal(pdu->llctrl.conn_param_req.preferred_periodicity, p->preferred_periodicity,
869 		      "Preferred_periodicity mismatch.\nCalled at %s:%d\n", file, line);
870 	zassert_equal(pdu->llctrl.conn_param_req.reference_conn_event_count,
871 		      p->reference_conn_event_count,
872 		      "Reference_conn_event_count mismatch.\nCalled at %s:%d\n", file, line);
873 	zassert_equal(pdu->llctrl.conn_param_req.offset0, p->offset0,
874 		      "Offset0 mismatch.\nCalled at %s:%d\n", file, line);
875 	zassert_equal(pdu->llctrl.conn_param_req.offset1, p->offset1,
876 		      "Offset1 mismatch.\nCalled at %s:%d\n", file, line);
877 	zassert_equal(pdu->llctrl.conn_param_req.offset2, p->offset2,
878 		      "Offset2 mismatch.\nCalled at %s:%d\n", file, line);
879 	zassert_equal(pdu->llctrl.conn_param_req.offset3, p->offset3,
880 		      "Offset3 mismatch.\nCalled at %s:%d\n", file, line);
881 	zassert_equal(pdu->llctrl.conn_param_req.offset4, p->offset4,
882 		      "Offset4 mismatch.\nCalled at %s:%d\n", file, line);
883 	zassert_equal(pdu->llctrl.conn_param_req.offset5, p->offset5,
884 		      "Offset5 mismatch.\nCalled at %s:%d\n", file, line);
885 }
886 
helper_pdu_verify_conn_param_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)887 void helper_pdu_verify_conn_param_rsp(const char *file, uint32_t line, struct pdu_data *pdu,
888 				      void *param)
889 {
890 	struct pdu_data_llctrl_conn_param_rsp *p = param;
891 
892 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
893 		      line);
894 	zassert_equal(pdu->len,
895 		      offsetof(struct pdu_data_llctrl, conn_param_rsp) +
896 			      sizeof(struct pdu_data_llctrl_conn_param_rsp),
897 		      "Wrong length.\nCalled at %s:%d\n", file, line);
898 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CONN_PARAM_RSP,
899 		      "Not a LL_CONNECTION_PARAM_RSP.\nCalled at %s:%d\n", file, line);
900 
901 	zassert_equal(pdu->llctrl.conn_param_rsp.interval_min, p->interval_min,
902 		      "Interval_min mismatch.\nCalled at %s:%d\n", file, line);
903 	zassert_equal(pdu->llctrl.conn_param_rsp.interval_max, p->interval_max,
904 		      "Interval_max mismatch.\nCalled at %s:%d\n", file, line);
905 	zassert_equal(pdu->llctrl.conn_param_rsp.latency, p->latency,
906 		      "Latency mismatch.\nCalled at %s:%d\n", file, line);
907 	zassert_equal(pdu->llctrl.conn_param_rsp.timeout, p->timeout,
908 		      "Timeout mismatch.\nCalled at %s:%d\n", file, line);
909 	zassert_equal(pdu->llctrl.conn_param_rsp.preferred_periodicity, p->preferred_periodicity,
910 		      "Preferred_periodicity mismatch.\nCalled at %s:%d\n", file, line);
911 	zassert_equal(pdu->llctrl.conn_param_rsp.reference_conn_event_count,
912 		      p->reference_conn_event_count,
913 		      "Reference_conn_event_count mismatch.\nCalled at %s:%d\n", file, line);
914 	zassert_equal(pdu->llctrl.conn_param_rsp.offset0, p->offset0,
915 		      "Offset0 mismatch.\nCalled at %s:%d\n", file, line);
916 	zassert_equal(pdu->llctrl.conn_param_rsp.offset1, p->offset1,
917 		      "Offset1 mismatch.\nCalled at %s:%d\n", file, line);
918 	zassert_equal(pdu->llctrl.conn_param_rsp.offset2, p->offset2,
919 		      "Offset2 mismatch.\nCalled at %s:%d\n", file, line);
920 	zassert_equal(pdu->llctrl.conn_param_rsp.offset3, p->offset3,
921 		      "Offset3 mismatch.\nCalled at %s:%d\n", file, line);
922 	zassert_equal(pdu->llctrl.conn_param_rsp.offset4, p->offset4,
923 		      "Offset4 mismatch.\nCalled at %s:%d\n", file, line);
924 	zassert_equal(pdu->llctrl.conn_param_rsp.offset5, p->offset5,
925 		      "Offset5 mismatch.\nCalled at %s:%d\n", file, line);
926 }
927 
helper_pdu_verify_conn_update_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)928 void helper_pdu_verify_conn_update_ind(const char *file, uint32_t line, struct pdu_data *pdu,
929 				       void *param)
930 {
931 	struct pdu_data_llctrl_conn_update_ind *p = param;
932 
933 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
934 		      line);
935 	zassert_equal(pdu->len,
936 		      offsetof(struct pdu_data_llctrl, conn_update_ind) +
937 			      sizeof(struct pdu_data_llctrl_conn_update_ind),
938 		      "Wrong length.\nCalled at %s:%d\n", file, line);
939 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CONN_UPDATE_IND,
940 		      "Not a LL_CONNECTION_UPDATE_IND.\nCalled at %s:%d\n", file, line);
941 	zassert_equal(pdu->llctrl.conn_update_ind.win_size, p->win_size,
942 		      "Win_size mismatch.\nCalled at %s:%d\n", file, line);
943 	zassert_equal(pdu->llctrl.conn_update_ind.win_offset, p->win_offset,
944 		      "Win_offset mismatch.\nCalled at %s:%d\n", file, line);
945 	zassert_equal(pdu->llctrl.conn_update_ind.latency, p->latency,
946 		      "Latency.\nCalled at %s:%d\n", file, line);
947 	zassert_equal(pdu->llctrl.conn_update_ind.interval, p->interval,
948 		      "Interval mismatch.\nCalled at %s:%d\n", file, line);
949 	zassert_equal(pdu->llctrl.conn_update_ind.timeout, p->timeout,
950 		      "Timeout mismatch.\nCalled at %s:%d\n", file, line);
951 	zassert_equal(pdu->llctrl.conn_update_ind.instant, p->instant,
952 		      "Instant mismatch.\nCalled at %s:%d\n", file, line);
953 }
954 
helper_node_verify_conn_update(const char * file,uint32_t line,struct node_rx_pdu * rx,void * param)955 void helper_node_verify_conn_update(const char *file, uint32_t line, struct node_rx_pdu *rx,
956 				    void *param)
957 {
958 	struct node_rx_pu *pdu = (struct node_rx_pu *)rx->pdu;
959 	struct node_rx_pu *p = param;
960 
961 	zassert_equal(rx->hdr.type, NODE_RX_TYPE_CONN_UPDATE,
962 		      "Not a CONN_UPDATE node.\nCalled at %s:%d\n", file, line);
963 	zassert_equal(pdu->status, p->status, "Status mismatch.\nCalled at %s:%d\n", file, line);
964 }
965 
helper_pdu_verify_terminate_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)966 void helper_pdu_verify_terminate_ind(const char *file, uint32_t line, struct pdu_data *pdu,
967 				     void *param)
968 {
969 	struct pdu_data_llctrl_terminate_ind *p = param;
970 
971 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
972 		      line);
973 	zassert_equal(pdu->len,
974 		      offsetof(struct pdu_data_llctrl, terminate_ind) +
975 			      sizeof(struct pdu_data_llctrl_terminate_ind),
976 		      "Wrong length.\nCalled at %s:%d\n", file, line);
977 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_TERMINATE_IND,
978 		      "Not a LL_TERMINATE_IND.\nCalled at %s:%d\n", file, line);
979 	zassert_equal(pdu->llctrl.terminate_ind.error_code, p->error_code,
980 		      "Error code mismatch.\nCalled at %s:%d\n", file, line);
981 }
982 
helper_pdu_verify_channel_map_update_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)983 void helper_pdu_verify_channel_map_update_ind(const char *file, uint32_t line, struct pdu_data *pdu,
984 					      void *param)
985 {
986 	struct pdu_data_llctrl_chan_map_ind *p = param;
987 
988 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
989 		      line);
990 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CHAN_MAP_IND,
991 		      "Not a LL_CHANNEL_MAP_UPDATE_IND.\nCalled at %s:%d ( %d %d)\n", file, line,
992 		      pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CHAN_MAP_IND);
993 	zassert_equal(pdu->len,
994 		      offsetof(struct pdu_data_llctrl, chan_map_ind) +
995 			      sizeof(struct pdu_data_llctrl_chan_map_ind),
996 		      "Wrong length.\nCalled at %s:%d\n", file, line);
997 	zassert_equal(pdu->llctrl.chan_map_ind.instant, p->instant,
998 		      "Instant mismatch.\nCalled at %s:%d\n", file, line);
999 	zassert_mem_equal(pdu->llctrl.chan_map_ind.chm, p->chm, sizeof(p->chm),
1000 			  "Channel Map mismatch.\nCalled at %s:%d\n", file, line);
1001 }
1002 
helper_pdu_verify_length_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1003 void helper_pdu_verify_length_req(const char *file, uint32_t line, struct pdu_data *pdu,
1004 				  void *param)
1005 {
1006 	struct pdu_data_llctrl_length_req *p = param;
1007 
1008 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1009 		      line);
1010 	zassert_equal(pdu->len,
1011 		      offsetof(struct pdu_data_llctrl, length_req) +
1012 			      sizeof(struct pdu_data_llctrl_length_req),
1013 		      "Wrong length.\nCalled at %s:%d\n", file, line);
1014 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_LENGTH_REQ,
1015 		      "Not a LL_LENGTH_REQ.\nCalled at %s:%d\n", file, line);
1016 	zassert_equal(pdu->llctrl.length_req.max_rx_octets, p->max_rx_octets,
1017 		      "max_rx_octets mismatch.\nCalled at %s:%d\n", file, line);
1018 	zassert_equal(pdu->llctrl.length_req.max_tx_octets, p->max_tx_octets,
1019 		      "max_tx_octets mismatch.\nCalled at %s:%d\n", file, line);
1020 	zassert_equal(pdu->llctrl.length_req.max_rx_time, p->max_rx_time,
1021 		      "max_rx_time mismatch.\nCalled at %s:%d\n", file, line);
1022 	zassert_equal(pdu->llctrl.length_req.max_tx_time, p->max_tx_time,
1023 		      "max_tx_time mismatch.\nCalled at %s:%d\n", file, line);
1024 }
1025 
helper_pdu_verify_length_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1026 void helper_pdu_verify_length_rsp(const char *file, uint32_t line, struct pdu_data *pdu,
1027 				  void *param)
1028 {
1029 	struct pdu_data_llctrl_length_rsp *p = param;
1030 
1031 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1032 		      line);
1033 	zassert_equal(pdu->len,
1034 		      offsetof(struct pdu_data_llctrl, length_rsp) +
1035 			      sizeof(struct pdu_data_llctrl_length_rsp),
1036 		      "Wrong length.\nCalled at %s:%d\n", file, line);
1037 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_LENGTH_RSP,
1038 		      "Not a LL_LENGTH_RSP.\nCalled at %s:%d\n", file, line);
1039 	zassert_equal(pdu->llctrl.length_rsp.max_rx_octets, p->max_rx_octets,
1040 		      "max_rx_octets mismatch.\nCalled at %s:%d\n", file, line);
1041 	zassert_equal(pdu->llctrl.length_rsp.max_tx_octets, p->max_tx_octets,
1042 		      "max_tx_octets mismatch.\nCalled at %s:%d\n", file, line);
1043 	zassert_equal(pdu->llctrl.length_rsp.max_rx_time, p->max_rx_time,
1044 		      "max_rx_time mismatch.\nCalled at %s:%d\n", file, line);
1045 	zassert_equal(pdu->llctrl.length_rsp.max_tx_time, p->max_tx_time,
1046 		      "max_tx_time mismatch.\nCalled at %s:%d\n", file, line);
1047 }
1048 
helper_pdu_verify_cte_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1049 void helper_pdu_verify_cte_req(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
1050 {
1051 	struct pdu_data_llctrl_cte_req *p = param;
1052 
1053 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1054 		      line);
1055 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CTE_REQ,
1056 		      "Not a LL_CTE_REQ.\nCalled at %s:%d ( %d %d)\n", file, line,
1057 		      pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CTE_REQ);
1058 	zassert_equal(pdu->len,
1059 		      offsetof(struct pdu_data_llctrl, cte_req) +
1060 			      sizeof(struct pdu_data_llctrl_cte_req),
1061 		      "Wrong length.\nCalled at %s:%d\n", file, line);
1062 	zassert_equal(pdu->llctrl.cte_req.min_cte_len_req, p->min_cte_len_req,
1063 		      "Minimal CTE length request mismatch.\nCalled at %s:%d\n", file, line);
1064 	zassert_equal(pdu->llctrl.cte_req.cte_type_req, p->cte_type_req,
1065 		      "CTE type request mismatch.\nCalled at %s:%d\n", file, line);
1066 }
1067 
helper_pdu_verify_cte_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1068 void helper_pdu_verify_cte_rsp(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
1069 {
1070 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1071 		      line);
1072 	zassert_equal(pdu->len,
1073 		      offsetof(struct pdu_data_llctrl, cte_rsp) +
1074 			      sizeof(struct pdu_data_llctrl_cte_rsp),
1075 		      "Wrong length.\nCalled at %s:%d\n", file, line);
1076 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CTE_RSP,
1077 		      "Not a LL_CTE_RSP.\nCalled at %s:%d\n", file, line);
1078 }
1079 
helper_node_verify_cte_rsp(const char * file,uint32_t line,struct node_rx_pdu * rx,void * param)1080 void helper_node_verify_cte_rsp(const char *file, uint32_t line, struct node_rx_pdu *rx,
1081 				void *param)
1082 {
1083 	struct cte_conn_iq_report *p_iq_report = param;
1084 	struct cte_conn_iq_report *rx_iq_report = rx->rx_ftr.iq_report;
1085 
1086 	zassert_equal(rx_iq_report->cte_info.time, p_iq_report->cte_info.time,
1087 		      "CTE Time mismatch.\nCalled at %s:%d\n", file, line);
1088 	zassert_equal(rx_iq_report->local_slot_durations, p_iq_report->local_slot_durations,
1089 		      "Slot duration mismatch.\nCalled at %s:%d\n", file, line);
1090 	zassert_equal(rx_iq_report->packet_status, p_iq_report->packet_status,
1091 		      "Packet status mismatch.\nCalled at %s:%d\n", file, line);
1092 	zassert_equal(rx_iq_report->rssi_ant_id, p_iq_report->rssi_ant_id,
1093 		      "RSSI antenna id mismatch.\nCalled at %s:%d\n", file, line);
1094 	zassert_equal(rx_iq_report->sample_count, p_iq_report->sample_count,
1095 		      "Sample count mismatch.\nCalled at %s:%d\n", file, line);
1096 	zassert_equal(memcmp(rx_iq_report->sample, p_iq_report->sample, p_iq_report->sample_count),
1097 		      0, "IQ samples mismatch.\nCalled at %s:%d\n", file, line);
1098 }
1099 
helper_pdu_ntf_verify_cte_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1100 void helper_pdu_ntf_verify_cte_rsp(const char *file, uint32_t line, struct pdu_data *pdu,
1101 				   void *param)
1102 {
1103 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1104 		      line);
1105 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CTE_RSP,
1106 		      "Not a LL_CTE_RSP. Called at %s:%d\n", file, line);
1107 }
1108 
helper_node_verify_cis_request(const char * file,uint32_t line,struct node_rx_pdu * rx,void * param)1109 void helper_node_verify_cis_request(const char *file, uint32_t line, struct node_rx_pdu *rx,
1110 				    void *param)
1111 {
1112 	struct node_rx_conn_iso_req *p = (struct node_rx_conn_iso_req *)param;
1113 	struct node_rx_conn_iso_req *pdu = (struct node_rx_conn_iso_req *)rx->pdu;
1114 
1115 	zassert_equal(rx->hdr.type, NODE_RX_TYPE_CIS_REQUEST,
1116 		      "Not a CIS_REQUEST node.\nCalled at %s:%d\n", file, line);
1117 	zassert_equal(p->cig_id, pdu->cig_id,
1118 		      "cig_id mismatch.\nCalled at %s:%d\n", file, line);
1119 	zassert_equal(p->cis_handle, pdu->cis_handle,
1120 		      "cis_handle mismatch.\nCalled at %s:%d\n", file, line);
1121 	zassert_equal(p->cis_id, pdu->cis_id,
1122 		      "cis_id mismatch.\nCalled at %s:%d\n", file, line);
1123 }
1124 
helper_node_verify_cis_established(const char * file,uint32_t line,struct node_rx_pdu * rx,void * param)1125 void helper_node_verify_cis_established(const char *file, uint32_t line, struct node_rx_pdu *rx,
1126 					void *param)
1127 {
1128 	struct node_rx_conn_iso_estab *p = (struct node_rx_conn_iso_estab *)param;
1129 	struct node_rx_conn_iso_estab *pdu = (struct node_rx_conn_iso_estab *)rx->pdu;
1130 
1131 	zassert_equal(rx->hdr.type, NODE_RX_TYPE_CIS_ESTABLISHED,
1132 		      "Not a CIS_ESTABLISHED node.\nCalled at %s:%d\n", file, line);
1133 	zassert_equal(p->status, pdu->status,
1134 		      "status mismatch.\nCalled at %s:%d\n", file, line);
1135 	zassert_equal(p->cis_handle, pdu->cis_handle,
1136 		      "cis_handle mismatch.\nCalled at %s:%d\n", file, line);
1137 }
1138 
helper_pdu_verify_cis_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1139 void helper_pdu_verify_cis_req(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
1140 {
1141 	struct pdu_data_llctrl_cis_req *p = param;
1142 
1143 	pdu->ll_id = PDU_DATA_LLID_CTRL;
1144 	pdu->len = offsetof(struct pdu_data_llctrl, cis_req) +
1145 		   sizeof(struct pdu_data_llctrl_cis_req);
1146 	pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_CIS_REQ;
1147 
1148 	zassert_equal(pdu->llctrl.cis_req.cig_id, p->cig_id,
1149 		      "cig_id mismatch.\nCalled at %s:%d\n", file, line);
1150 	zassert_equal(pdu->llctrl.cis_req.cis_id, p->cis_id,
1151 		      "cis_id mismatch.\nCalled at %s:%d\n", file, line);
1152 	zassert_equal(pdu->llctrl.cis_req.c_phy, p->c_phy,
1153 		      "c_phy mismatch.\nCalled at %s:%d\n", file, line);
1154 	zassert_equal(pdu->llctrl.cis_req.p_phy, p->p_phy,
1155 		      "p_phy mismatch.\nCalled at %s:%d\n", file, line);
1156 	zassert_equal(pdu->llctrl.cis_req.c_max_pdu, p->c_max_pdu,
1157 		      "c_max_pdu mismatch.\nCalled at %s:%d\n", file, line);
1158 	zassert_equal(pdu->llctrl.cis_req.p_max_pdu, p->p_max_pdu,
1159 		      "p_max_pdu mismatch.\nCalled at %s:%d\n", file, line);
1160 	zassert_equal(pdu->llctrl.cis_req.nse, p->nse,
1161 		      "nse mismatch.\nCalled at %s:%d\n", file, line);
1162 	zassert_equal(pdu->llctrl.cis_req.p_bn, p->p_bn,
1163 		      "p_bn mismatch.\nCalled at %s:%d\n", file, line);
1164 	zassert_equal(pdu->llctrl.cis_req.c_bn, p->c_bn,
1165 		      "c_bn mismatch.\nCalled at %s:%d\n", file, line);
1166 	zassert_equal(pdu->llctrl.cis_req.c_ft, p->c_ft,
1167 		      "c_ft mismatch.\nCalled at %s:%d\n", file, line);
1168 	zassert_equal(pdu->llctrl.cis_req.p_ft, p->p_ft,
1169 		      "p_ft mismatch.\nCalled at %s:%d\n", file, line);
1170 	zassert_equal(pdu->llctrl.cis_req.iso_interval, p->iso_interval,
1171 		      "iso_interval mismatch.\nCalled at %s:%d\n", file, line);
1172 	zassert_equal(pdu->llctrl.cis_req.conn_event_count, p->conn_event_count,
1173 		      "conn_event_count mismatch.\nCalled at %s:%d\n", file, line);
1174 	zassert_mem_equal(pdu->llctrl.cis_req.c_max_sdu_packed, p->c_max_sdu_packed,
1175 			  sizeof(p->c_max_sdu_packed),
1176 			  "c_max_sdu_packed mismatch.\nCalled at %s:%d\n", file, line);
1177 	zassert_mem_equal(pdu->llctrl.cis_req.p_max_sdu, p->p_max_sdu,
1178 			  sizeof(p->p_max_sdu),
1179 			  "p_max_sdu mismatch.\nCalled at %s:%d\n", file, line);
1180 	zassert_mem_equal(pdu->llctrl.cis_req.c_sdu_interval, p->c_sdu_interval,
1181 			  sizeof(p->c_sdu_interval),
1182 			  "c_sdu_interval mismatch.\nCalled at %s:%d\n", file, line);
1183 	zassert_mem_equal(pdu->llctrl.cis_req.p_sdu_interval, p->p_sdu_interval,
1184 			  sizeof(p->p_sdu_interval),
1185 			  "p_sdu_interval mismatch.\nCalled at %s:%d\n", file, line);
1186 	zassert_mem_equal(pdu->llctrl.cis_req.sub_interval, p->sub_interval,
1187 			  sizeof(p->sub_interval),
1188 			  "sub_interval mismatch.\nCalled at %s:%d\n", file, line);
1189 	zassert_mem_equal(pdu->llctrl.cis_req.cis_offset_min, p->cis_offset_min,
1190 			  sizeof(p->cis_offset_min),
1191 			  "cis_offset_min mismatch.\nCalled at %s:%d\n", file, line);
1192 	zassert_mem_equal(pdu->llctrl.cis_req.cis_offset_max, p->cis_offset_max,
1193 			  sizeof(p->cis_offset_max),
1194 			  "cis_offset_max mismatch.\nCalled at %s:%d\n", file, line);
1195 }
1196 
helper_pdu_verify_cis_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1197 void helper_pdu_verify_cis_rsp(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
1198 {
1199 	struct pdu_data_llctrl_cis_rsp *p = param;
1200 
1201 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1202 		      line);
1203 	zassert_equal(pdu->len,
1204 		      offsetof(struct pdu_data_llctrl, cis_rsp) +
1205 			      sizeof(struct pdu_data_llctrl_cis_rsp),
1206 		      "Wrong length.\nCalled at %s:%d\n", file, line);
1207 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CIS_RSP,
1208 		      "Not a LL_CIS_RSP.\nCalled at %s:%d\n", file, line);
1209 
1210 	zassert_mem_equal(pdu->llctrl.cis_rsp.cis_offset_min, p->cis_offset_min,
1211 			  sizeof(p->cis_offset_min),
1212 			  "cis_offset_min mismatch.\nCalled at %s:%d\n", file, line);
1213 	zassert_mem_equal(pdu->llctrl.cis_rsp.cis_offset_max, p->cis_offset_max,
1214 			  sizeof(p->cis_offset_max),
1215 			  "cis_offset_max mismatch.\nCalled at %s:%d\n", file, line);
1216 	zassert_equal(pdu->llctrl.cis_rsp.conn_event_count, p->conn_event_count,
1217 		      "conn_event_count mismatch.\nCalled at %s:%d\n", file, line);
1218 }
1219 
helper_pdu_verify_cis_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1220 void helper_pdu_verify_cis_ind(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
1221 {
1222 	struct pdu_data_llctrl_cis_ind *p = param;
1223 
1224 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1225 		      line);
1226 	zassert_equal(pdu->len,
1227 		      offsetof(struct pdu_data_llctrl, cis_ind) +
1228 			      sizeof(struct pdu_data_llctrl_cis_ind),
1229 		      "Wrong length.\nCalled at %s:%d\n", file, line);
1230 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CIS_IND,
1231 		      "Not a LL_CIS_IND.\nCalled at %s:%d\n", file, line);
1232 
1233 	zassert_mem_equal(pdu->llctrl.cis_ind.aa, p->aa, sizeof(p->aa),
1234 			  "aa mismatch.\nCalled at %s:%d\n", file, line);
1235 	zassert_mem_equal(pdu->llctrl.cis_ind.cis_offset, p->cis_offset, sizeof(p->cis_offset),
1236 			  "cis_offset mismatch.\nCalled at %s:%d\n", file, line);
1237 	zassert_mem_equal(pdu->llctrl.cis_ind.cig_sync_delay, p->cig_sync_delay,
1238 			  sizeof(p->cig_sync_delay),
1239 			  "cig_sync_delay mismatch.\nCalled at %s:%d\n", file, line);
1240 	zassert_mem_equal(pdu->llctrl.cis_ind.cis_sync_delay, p->cis_sync_delay,
1241 			  sizeof(p->cis_sync_delay),
1242 			  "cis_sync_delay mismatch.\nCalled at %s:%d\n", file, line);
1243 	zassert_equal(pdu->llctrl.cis_ind.conn_event_count, p->conn_event_count,
1244 		      "conn_event_count mismatch.\nCalled at %s:%d\n", file, line);
1245 }
1246 
helper_pdu_verify_cis_terminate_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1247 void helper_pdu_verify_cis_terminate_ind(const char *file, uint32_t line, struct pdu_data *pdu,
1248 					 void *param)
1249 {
1250 	struct pdu_data_llctrl_cis_terminate_ind *p = param;
1251 
1252 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1253 		      line);
1254 	zassert_equal(pdu->len,
1255 		      offsetof(struct pdu_data_llctrl, cis_terminate_ind) +
1256 			      sizeof(struct pdu_data_llctrl_cis_terminate_ind),
1257 		      "Wrong length.\nCalled at %s:%d\n", file, line);
1258 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CIS_TERMINATE_IND,
1259 		      "Not a LL_CIS_TERMINATE_IND.\nCalled at %s:%d\n", file, line);
1260 	zassert_equal(pdu->llctrl.cis_terminate_ind.cig_id, p->cig_id,
1261 		      "CIG ID mismatch.\nCalled at %s:%d\n", file, line);
1262 	zassert_equal(pdu->llctrl.cis_terminate_ind.cis_id, p->cis_id,
1263 		      "CIS ID mismatch.\nCalled at %s:%d\n", file, line);
1264 	zassert_equal(pdu->llctrl.cis_terminate_ind.error_code, p->error_code,
1265 		      "Error code mismatch.\nCalled at %s:%d\n", file, line);
1266 }
1267 
helper_pdu_verify_sca_req(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1268 void helper_pdu_verify_sca_req(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
1269 {
1270 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1271 		      line);
1272 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CLOCK_ACCURACY_REQ,
1273 		      "Not a LL_CLOCK_ACCURACY_REQ. Called at %s:%d\n", file, line);
1274 }
1275 
helper_pdu_verify_sca_rsp(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1276 void helper_pdu_verify_sca_rsp(const char *file, uint32_t line, struct pdu_data *pdu, void *param)
1277 {
1278 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1279 		      line);
1280 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_CLOCK_ACCURACY_RSP,
1281 		      "Not a LL_CLOCK_ACCURACY_RSP.\nCalled at %s:%d\n", file, line);
1282 }
1283 
helper_pdu_verify_periodic_sync_ind(const char * file,uint32_t line,struct pdu_data * pdu,void * param)1284 void helper_pdu_verify_periodic_sync_ind(const char *file, uint32_t line, struct pdu_data *pdu,
1285 					 void *param)
1286 {
1287 	struct pdu_data_llctrl_periodic_sync_ind *p = param;
1288 
1289 	zassert_equal(pdu->ll_id, PDU_DATA_LLID_CTRL, "Not a Control PDU.\nCalled at %s:%d\n", file,
1290 		      line);
1291 	zassert_equal(pdu->llctrl.opcode, PDU_DATA_LLCTRL_TYPE_PERIODIC_SYNC_IND,
1292 		      "Not a LL_PERIODIC_SYNC_IND.\nCalled at %s:%d\n", file, line);
1293 
1294 	zassert_equal(pdu->llctrl.periodic_sync_ind.id, p->id,
1295 		      "id mismatch.\nCalled at %s:%d\n", file, line);
1296 
1297 	zassert_equal(pdu->llctrl.periodic_sync_ind.conn_event_count, p->conn_event_count,
1298 		      "conn_event_count mismatch.\nCalled at %s:%d\n", file, line);
1299 
1300 	zassert_equal(pdu->llctrl.periodic_sync_ind.last_pa_event_counter, p->last_pa_event_counter,
1301 		      "last_pa_event_counter mismatch.\nCalled at %s:%d\n", file, line);
1302 
1303 	zassert_equal(pdu->llctrl.periodic_sync_ind.sid, p->sid,
1304 		      "sid mismatch.\nCalled at %s:%d\n", file, line);
1305 
1306 	zassert_equal(pdu->llctrl.periodic_sync_ind.addr_type, p->addr_type,
1307 		      "addr_type mismatch.\nCalled at %s:%d\n", file, line);
1308 
1309 	zassert_equal(pdu->llctrl.periodic_sync_ind.sca, p->sca,
1310 		      "sca mismatch.\nCalled at %s:%d\n", file, line);
1311 
1312 	zassert_equal(pdu->llctrl.periodic_sync_ind.phy, p->phy,
1313 		      "phy mismatch.\nCalled at %s:%d\n", file, line);
1314 
1315 	zassert_equal(pdu->llctrl.periodic_sync_ind.sync_conn_event_count, p->sync_conn_event_count,
1316 		      "sync_conn_event_count mismatch.\nCalled at %s:%d\n", file, line);
1317 
1318 	zassert_mem_equal(&pdu->llctrl.periodic_sync_ind.sync_info, &p->sync_info,
1319 			   sizeof(struct pdu_adv_sync_info),
1320 			  "sync_info mismatch.\nCalled at %s:%d\n", file, line);
1321 
1322 	zassert_mem_equal(pdu->llctrl.periodic_sync_ind.adv_addr, p->adv_addr,
1323 			  sizeof(p->adv_addr),
1324 			  "adv_addr mismatch.\nCalled at %s:%d\n", file, line);
1325 }
1326