1 /*
2 * Copyright (c) 2020 Demant
3 * Copyright (c) 2020 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include <zephyr/types.h>
9 #include <zephyr/ztest.h>
10 #include <stdlib.h>
11
12 #include <zephyr/bluetooth/hci.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.h"
33 #include "lll_conn_iso.h"
34
35 #include "ull_tx_queue.h"
36
37 #include "isoal.h"
38 #include "ull_iso_types.h"
39 #include "ull_conn_iso_types.h"
40 #include "ull_conn_iso_internal.h"
41 #include "ull_conn_types.h"
42
43 #include "ull_internal.h"
44 #include "ull_conn_internal.h"
45 #include "ull_llcp_internal.h"
46 #include "ull_llcp.h"
47
48 #include "helper_pdu.h"
49 #include "helper_util.h"
50
51 static struct ll_conn *emul_conn_pool[CONFIG_BT_MAX_CONN];
52
53 static uint32_t event_active[CONFIG_BT_MAX_CONN];
54 sys_slist_t ut_rx_q;
55 static sys_slist_t lt_tx_q;
56 static uint32_t no_of_ctx_buffers_at_test_setup;
57
58 #define PDU_DC_LL_HEADER_SIZE (offsetof(struct pdu_data, lldata))
59 #define NODE_RX_HEADER_SIZE (offsetof(struct node_rx_pdu, pdu))
60 #define NODE_RX_STRUCT_OVERHEAD (NODE_RX_HEADER_SIZE)
61 #define PDU_DATA_SIZE sizeof(struct pdu_data)
62 #define PDU_RX_NODE_SIZE WB_UP(NODE_RX_STRUCT_OVERHEAD + PDU_DATA_SIZE)
63
64 helper_pdu_encode_func_t *const helper_pdu_encode[] = {
65 [LL_VERSION_IND] = helper_pdu_encode_version_ind,
66 [LL_LE_PING_REQ] = helper_pdu_encode_ping_req,
67 [LL_LE_PING_RSP] = helper_pdu_encode_ping_rsp,
68 [LL_FEATURE_REQ] = helper_pdu_encode_feature_req,
69 [LL_PERIPH_FEAT_XCHG] = helper_pdu_encode_peripheral_feature_req,
70 [LL_FEATURE_RSP] = helper_pdu_encode_feature_rsp,
71 [LL_MIN_USED_CHANS_IND] = helper_pdu_encode_min_used_chans_ind,
72 [LL_REJECT_IND] = helper_pdu_encode_reject_ind,
73 [LL_REJECT_EXT_IND] = helper_pdu_encode_reject_ext_ind,
74 [LL_ENC_REQ] = helper_pdu_encode_enc_req,
75 [LL_ENC_RSP] = helper_pdu_encode_enc_rsp,
76 [LL_START_ENC_REQ] = helper_pdu_encode_start_enc_req,
77 [LL_START_ENC_RSP] = helper_pdu_encode_start_enc_rsp,
78 [LL_PAUSE_ENC_REQ] = helper_pdu_encode_pause_enc_req,
79 [LL_PAUSE_ENC_RSP] = helper_pdu_encode_pause_enc_rsp,
80 [LL_PHY_REQ] = helper_pdu_encode_phy_req,
81 [LL_PHY_RSP] = helper_pdu_encode_phy_rsp,
82 [LL_PHY_UPDATE_IND] = helper_pdu_encode_phy_update_ind,
83 [LL_UNKNOWN_RSP] = helper_pdu_encode_unknown_rsp,
84 [LL_CONNECTION_UPDATE_IND] = helper_pdu_encode_conn_update_ind,
85 [LL_CONNECTION_PARAM_REQ] = helper_pdu_encode_conn_param_req,
86 [LL_CONNECTION_PARAM_RSP] = helper_pdu_encode_conn_param_rsp,
87 [LL_TERMINATE_IND] = helper_pdu_encode_terminate_ind,
88 [LL_CHAN_MAP_UPDATE_IND] = helper_pdu_encode_channel_map_update_ind,
89 [LL_LENGTH_REQ] = helper_pdu_encode_length_req,
90 [LL_LENGTH_RSP] = helper_pdu_encode_length_rsp,
91 [LL_CTE_REQ] = helper_pdu_encode_cte_req,
92 [LL_CTE_RSP] = helper_pdu_encode_cte_rsp,
93 [LL_CLOCK_ACCURACY_REQ] = helper_pdu_encode_sca_req,
94 [LL_CLOCK_ACCURACY_RSP] = helper_pdu_encode_sca_rsp,
95 [LL_CIS_REQ] = helper_pdu_encode_cis_req,
96 [LL_CIS_RSP] = helper_pdu_encode_cis_rsp,
97 [LL_CIS_IND] = helper_pdu_encode_cis_ind,
98 [LL_CIS_TERMINATE_IND] = helper_pdu_encode_cis_terminate_ind,
99 [LL_PERIODIC_SYNC_IND] = helper_pdu_encode_periodic_sync_ind,
100 [LL_ZERO] = helper_pdu_encode_zero,
101 };
102
103 helper_pdu_verify_func_t *const helper_pdu_verify[] = {
104 [LL_VERSION_IND] = helper_pdu_verify_version_ind,
105 [LL_LE_PING_REQ] = helper_pdu_verify_ping_req,
106 [LL_LE_PING_RSP] = helper_pdu_verify_ping_rsp,
107 [LL_FEATURE_REQ] = helper_pdu_verify_feature_req,
108 [LL_PERIPH_FEAT_XCHG] = helper_pdu_verify_peripheral_feature_req,
109 [LL_FEATURE_RSP] = helper_pdu_verify_feature_rsp,
110 [LL_MIN_USED_CHANS_IND] = helper_pdu_verify_min_used_chans_ind,
111 [LL_REJECT_IND] = helper_pdu_verify_reject_ind,
112 [LL_REJECT_EXT_IND] = helper_pdu_verify_reject_ext_ind,
113 [LL_ENC_REQ] = helper_pdu_verify_enc_req,
114 [LL_ENC_RSP] = helper_pdu_verify_enc_rsp,
115 [LL_START_ENC_REQ] = helper_pdu_verify_start_enc_req,
116 [LL_START_ENC_RSP] = helper_pdu_verify_start_enc_rsp,
117 [LL_PAUSE_ENC_REQ] = helper_pdu_verify_pause_enc_req,
118 [LL_PAUSE_ENC_RSP] = helper_pdu_verify_pause_enc_rsp,
119 [LL_PHY_REQ] = helper_pdu_verify_phy_req,
120 [LL_PHY_RSP] = helper_pdu_verify_phy_rsp,
121 [LL_PHY_UPDATE_IND] = helper_pdu_verify_phy_update_ind,
122 [LL_UNKNOWN_RSP] = helper_pdu_verify_unknown_rsp,
123 [LL_CONNECTION_UPDATE_IND] = helper_pdu_verify_conn_update_ind,
124 [LL_CONNECTION_PARAM_REQ] = helper_pdu_verify_conn_param_req,
125 [LL_CONNECTION_PARAM_RSP] = helper_pdu_verify_conn_param_rsp,
126 [LL_TERMINATE_IND] = helper_pdu_verify_terminate_ind,
127 [LL_CHAN_MAP_UPDATE_IND] = helper_pdu_verify_channel_map_update_ind,
128 [LL_LENGTH_REQ] = helper_pdu_verify_length_req,
129 [LL_LENGTH_RSP] = helper_pdu_verify_length_rsp,
130 [LL_CTE_REQ] = helper_pdu_verify_cte_req,
131 [LL_CTE_RSP] = helper_pdu_verify_cte_rsp,
132 [LL_CLOCK_ACCURACY_REQ] = helper_pdu_verify_sca_req,
133 [LL_CLOCK_ACCURACY_RSP] = helper_pdu_verify_sca_rsp,
134 [LL_CIS_REQ] = helper_pdu_verify_cis_req,
135 [LL_CIS_RSP] = helper_pdu_verify_cis_rsp,
136 [LL_CIS_IND] = helper_pdu_verify_cis_ind,
137 [LL_CIS_TERMINATE_IND] = helper_pdu_verify_cis_terminate_ind,
138 [LL_PERIODIC_SYNC_IND] = helper_pdu_verify_periodic_sync_ind,
139 };
140
141 helper_pdu_ntf_verify_func_t *const helper_pdu_ntf_verify[] = {
142 [LL_VERSION_IND] = NULL,
143 [LL_LE_PING_REQ] = NULL,
144 [LL_LE_PING_RSP] = NULL,
145 [LL_FEATURE_REQ] = NULL,
146 [LL_PERIPH_FEAT_XCHG] = NULL,
147 [LL_FEATURE_RSP] = NULL,
148 [LL_MIN_USED_CHANS_IND] = NULL,
149 [LL_REJECT_IND] = NULL,
150 [LL_REJECT_EXT_IND] = NULL,
151 [LL_ENC_REQ] = helper_pdu_ntf_verify_enc_req,
152 [LL_ENC_RSP] = NULL,
153 [LL_START_ENC_REQ] = NULL,
154 [LL_START_ENC_RSP] = NULL,
155 [LL_PHY_REQ] = NULL,
156 [LL_PHY_RSP] = NULL,
157 [LL_PHY_UPDATE_IND] = NULL,
158 [LL_UNKNOWN_RSP] = NULL,
159 [LL_CONNECTION_UPDATE_IND] = NULL,
160 [LL_CONNECTION_PARAM_REQ] = NULL,
161 [LL_CONNECTION_PARAM_RSP] = NULL,
162 [LL_TERMINATE_IND] = NULL,
163 [LL_CHAN_MAP_UPDATE_IND] = NULL,
164 [LL_LENGTH_REQ] = NULL,
165 [LL_LENGTH_RSP] = NULL,
166 [LL_CTE_REQ] = NULL,
167 [LL_CTE_RSP] = helper_pdu_ntf_verify_cte_rsp,
168 [LL_CTE_RSP] = NULL,
169 [LL_CLOCK_ACCURACY_REQ] = NULL,
170 [LL_CLOCK_ACCURACY_RSP] = NULL,
171 [LL_CIS_REQ] = NULL,
172 [LL_CIS_RSP] = NULL,
173 [LL_CIS_IND] = NULL,
174 [LL_CIS_TERMINATE_IND] = NULL,
175 [LL_PERIODIC_SYNC_IND] = NULL,
176 };
177
178 helper_node_encode_func_t *const helper_node_encode[] = {
179 [LL_VERSION_IND] = NULL,
180 [LL_LE_PING_REQ] = NULL,
181 [LL_LE_PING_RSP] = NULL,
182 [LL_FEATURE_REQ] = NULL,
183 [LL_PERIPH_FEAT_XCHG] = NULL,
184 [LL_FEATURE_RSP] = NULL,
185 [LL_MIN_USED_CHANS_IND] = NULL,
186 [LL_REJECT_IND] = NULL,
187 [LL_REJECT_EXT_IND] = NULL,
188 [LL_ENC_REQ] = NULL,
189 [LL_ENC_RSP] = NULL,
190 [LL_START_ENC_REQ] = NULL,
191 [LL_START_ENC_RSP] = NULL,
192 [LL_PHY_REQ] = NULL,
193 [LL_PHY_RSP] = NULL,
194 [LL_PHY_UPDATE_IND] = NULL,
195 [LL_UNKNOWN_RSP] = NULL,
196 [LL_CONNECTION_UPDATE_IND] = NULL,
197 [LL_CONNECTION_PARAM_REQ] = NULL,
198 [LL_CONNECTION_PARAM_RSP] = NULL,
199 [LL_TERMINATE_IND] = NULL,
200 [LL_CHAN_MAP_UPDATE_IND] = NULL,
201 [LL_CTE_REQ] = NULL,
202 [LL_CTE_RSP] = helper_node_encode_cte_rsp,
203 [LL_CLOCK_ACCURACY_REQ] = NULL,
204 [LL_CLOCK_ACCURACY_RSP] = NULL,
205 [LL_CIS_REQ] = NULL,
206 [LL_CIS_RSP] = NULL,
207 [LL_CIS_IND] = NULL,
208 [LL_CIS_TERMINATE_IND] = NULL,
209 [LL_PERIODIC_SYNC_IND] = NULL,
210 };
211
212 helper_node_verify_func_t *const helper_node_verify[] = {
213 [NODE_PHY_UPDATE] = helper_node_verify_phy_update,
214 [NODE_CONN_UPDATE] = helper_node_verify_conn_update,
215 [NODE_ENC_REFRESH] = helper_node_verify_enc_refresh,
216 [NODE_CTE_RSP] = helper_node_verify_cte_rsp,
217 [NODE_CIS_REQUEST] = helper_node_verify_cis_request,
218 [NODE_CIS_ESTABLISHED] = helper_node_verify_cis_established,
219 [NODE_PEER_SCA_UPDATE] = helper_node_verify_peer_sca_update,
220 };
221
222 /*
223 * for debugging purpose only
224 */
test_print_conn(struct ll_conn * conn)225 void test_print_conn(struct ll_conn *conn)
226 {
227 printf("------------------>\n");
228 printf("Mock structure\n");
229 printf(" Role: %d\n", conn->lll.role);
230 printf(" event-count: %d\n", conn->lll.event_counter);
231 printf("LLCP structure\n");
232 printf(" Local state: %d\n", conn->llcp.local.state);
233 printf(" Remote state: %d\n", conn->llcp.remote.state);
234 printf(" Collision: %d\n", conn->llcp.remote.collision);
235 printf(" Reject: %d\n", conn->llcp.remote.reject_opcode);
236 printf("--------------------->\n");
237 }
238
test_ctx_buffers_cnt(void)239 uint16_t test_ctx_buffers_cnt(void)
240 {
241 return no_of_ctx_buffers_at_test_setup;
242 }
243
find_idx(struct ll_conn * conn)244 static uint8_t find_idx(struct ll_conn *conn)
245 {
246 for (uint8_t i = 0; i < CONFIG_BT_MAX_CONN; i++) {
247 if (emul_conn_pool[i] == conn) {
248 return i;
249 }
250 }
251 zassert_true(0, "Invalid connection object");
252 return 0xFF;
253 }
254
test_setup(struct ll_conn * conn)255 void test_setup(struct ll_conn *conn)
256 {
257 ull_conn_init();
258
259 /**/
260 memset(conn, 0x00, sizeof(*conn));
261
262 /* Initialize the upper test rx queue */
263 sys_slist_init(&ut_rx_q);
264
265 /* Initialize the lower tester tx queue */
266 sys_slist_init(<_tx_q);
267
268 /* Initialize the control procedure code */
269 ull_cp_init();
270
271 /* Initialize the ULL TX Q */
272 ull_tx_q_init(&conn->tx_q);
273
274 /* Initialize the connection object */
275 ull_llcp_init(conn);
276
277 ll_reset();
278 conn->lll.event_counter = 0;
279 conn->lll.interval = 6;
280 conn->supervision_timeout = 600;
281 event_active[0] = 0;
282
283 memset(emul_conn_pool, 0x00, sizeof(emul_conn_pool));
284 emul_conn_pool[0] = conn;
285
286 no_of_ctx_buffers_at_test_setup = llcp_ctx_buffers_free();
287
288 }
289
test_setup_idx(struct ll_conn * conn,uint8_t idx)290 void test_setup_idx(struct ll_conn *conn, uint8_t idx)
291 {
292 if (idx == 0) {
293 test_setup(conn);
294 return;
295 }
296
297 memset(conn, 0x00, sizeof(*conn));
298
299 /* Initialize the ULL TX Q */
300 ull_tx_q_init(&conn->tx_q);
301
302 /* Initialize the connection object */
303 ull_llcp_init(conn);
304
305 conn->lll.event_counter = 0;
306 event_active[idx] = 0;
307 emul_conn_pool[idx] = conn;
308 }
309
test_set_role(struct ll_conn * conn,uint8_t role)310 void test_set_role(struct ll_conn *conn, uint8_t role)
311 {
312 conn->lll.role = role;
313 }
314
event_prepare(struct ll_conn * conn)315 void event_prepare(struct ll_conn *conn)
316 {
317 struct lll_conn *lll;
318 uint32_t *evt_active = &(event_active[find_idx(conn)]);
319
320 /* Can only be called with no active event */
321 zassert_equal(*evt_active, 0, "Called inside an active event");
322 *evt_active = 1;
323
324 /*** ULL Prepare ***/
325
326 /* Handle any LL Control Procedures */
327 ull_cp_run(conn);
328
329 /*** LLL Prepare ***/
330 lll = &conn->lll;
331
332 /* Save the latency for use in event */
333 lll->latency_prepare += lll->latency;
334
335 /* Calc current event counter value */
336 uint16_t event_counter = lll->event_counter + lll->latency_prepare;
337
338 /* Store the next event counter value */
339 lll->event_counter = event_counter + 1;
340
341 lll->latency_prepare = 0;
342 }
343
event_tx_ack(struct ll_conn * conn,struct node_tx * tx)344 void event_tx_ack(struct ll_conn *conn, struct node_tx *tx)
345 {
346 uint32_t *evt_active = &(event_active[find_idx(conn)]);
347 /* Can only be called with active event */
348 zassert_equal(*evt_active, 1, "Called outside an active event");
349
350 ull_cp_tx_ack(conn, tx);
351 }
352
event_done(struct ll_conn * conn)353 void event_done(struct ll_conn *conn)
354 {
355 struct node_rx_pdu *rx;
356 uint32_t *evt_active = &(event_active[find_idx(conn)]);
357
358 /* Can only be called with active event */
359 zassert_equal(*evt_active, 1, "Called outside an active event");
360 *evt_active = 0;
361
362 /* Notify all control procedures that wait with Host notifications for instant to be on
363 * air. This is done here because UT does not maintain actual connection events.
364 */
365 ull_cp_tx_ntf(conn);
366
367 while ((rx = (struct node_rx_pdu *)sys_slist_get(<_tx_q))) {
368
369 /* Mark buffer for release */
370 rx->hdr.type = NODE_RX_TYPE_RELEASE;
371
372 ull_cp_rx(conn, NULL, rx);
373
374 if (rx->hdr.type == NODE_RX_TYPE_RELEASE) {
375 /* Only release if node was not hi-jacked by LLCP */
376 ll_rx_release(rx);
377 } else if (rx->hdr.type != NODE_RX_TYPE_RETAIN) {
378 /* Otherwise put/sched to emulate ull_cp_rx return path */
379 ll_rx_put_sched(rx->hdr.link, rx);
380 }
381 }
382 }
383
event_counter(struct ll_conn * conn)384 uint16_t event_counter(struct ll_conn *conn)
385 {
386 uint16_t event_counter;
387 uint32_t *evt_active = &(event_active[find_idx(conn)]);
388
389 /* Calculate current event counter */
390 event_counter = ull_conn_event_counter(conn);
391
392 /* If event_counter is called inside an event_prepare()/event_done() pair
393 * return the current event counter value (i.e. -1);
394 * otherwise return the next event counter value
395 */
396 if (*evt_active) {
397 event_counter--;
398 }
399
400 return event_counter;
401 }
402
403 static struct node_rx_pdu *rx_malloc_store;
404
lt_tx_real(const char * file,uint32_t line,enum helper_pdu_opcode opcode,struct ll_conn * conn,void * param)405 void lt_tx_real(const char *file, uint32_t line, enum helper_pdu_opcode opcode,
406 struct ll_conn *conn, void *param)
407 {
408 struct pdu_data *pdu;
409 struct node_rx_pdu *rx;
410
411 rx = malloc(PDU_RX_NODE_SIZE);
412 zassert_not_null(rx, "Out of memory.\nCalled at %s:%d\n", file, line);
413
414 /* Remember RX node to allow for correct release */
415 rx_malloc_store = rx;
416
417 /* Encode node_rx_pdu if required by particular procedure */
418 if (helper_node_encode[opcode]) {
419 helper_node_encode[opcode](rx, param);
420 }
421
422 pdu = (struct pdu_data *)rx->pdu;
423 zassert_not_null(helper_pdu_encode[opcode], "PDU encode function cannot be NULL\n");
424 helper_pdu_encode[opcode](pdu, param);
425
426 sys_slist_append(<_tx_q, (sys_snode_t *)rx);
427 }
428
lt_tx_real_no_encode(const char * file,uint32_t line,struct pdu_data * pdu,struct ll_conn * conn,void * param)429 void lt_tx_real_no_encode(const char *file, uint32_t line, struct pdu_data *pdu,
430 struct ll_conn *conn, void *param)
431 {
432 struct node_rx_pdu *rx;
433
434 rx = malloc(PDU_RX_NODE_SIZE);
435 zassert_not_null(rx, "Out of memory.\nCalled at %s:%d\n", file, line);
436
437 /* Remember RX node to allow for correct release */
438 rx_malloc_store = rx;
439
440 memcpy((struct pdu_data *)rx->pdu, pdu, sizeof(struct pdu_data));
441 sys_slist_append(<_tx_q, (sys_snode_t *)rx);
442 }
443
release_ntf(struct node_rx_pdu * ntf)444 void release_ntf(struct node_rx_pdu *ntf)
445 {
446 if (ntf == rx_malloc_store) {
447 free(ntf);
448 return;
449 }
450
451 ntf->hdr.next = NULL;
452 ll_rx_mem_release((void **)&ntf);
453 }
454
lt_rx_real(const char * file,uint32_t line,enum helper_pdu_opcode opcode,struct ll_conn * conn,struct node_tx ** tx_ref,void * param)455 void lt_rx_real(const char *file, uint32_t line, enum helper_pdu_opcode opcode,
456 struct ll_conn *conn, struct node_tx **tx_ref, void *param)
457 {
458 struct node_tx *tx;
459 struct pdu_data *pdu;
460
461 tx = ull_tx_q_dequeue(&conn->tx_q);
462
463 zassert_not_null(tx, "Tx Q empty.\nCalled at %s:%d\n", file, line);
464
465 pdu = (struct pdu_data *)tx->pdu;
466 if (helper_pdu_verify[opcode]) {
467 helper_pdu_verify[opcode](file, line, pdu, param);
468 }
469
470 *tx_ref = tx;
471 }
472
lt_rx_q_is_empty_real(const char * file,uint32_t line,struct ll_conn * conn)473 void lt_rx_q_is_empty_real(const char *file, uint32_t line, struct ll_conn *conn)
474 {
475 struct node_tx *tx;
476
477 tx = ull_tx_q_dequeue(&conn->tx_q);
478 zassert_is_null(tx, "Tx Q not empty.\nCalled at %s:%d\n", file, line);
479 }
480
ut_rx_pdu_real(const char * file,uint32_t line,enum helper_pdu_opcode opcode,struct node_rx_pdu ** ntf_ref,void * param)481 void ut_rx_pdu_real(const char *file, uint32_t line, enum helper_pdu_opcode opcode,
482 struct node_rx_pdu **ntf_ref, void *param)
483 {
484 struct pdu_data *pdu;
485 struct node_rx_pdu *ntf;
486
487 ntf = (struct node_rx_pdu *)sys_slist_get(&ut_rx_q);
488 zassert_not_null(ntf, "Ntf Q empty.\nCalled at %s:%d\n", file, line);
489
490 zassert_equal(ntf->hdr.type, NODE_RX_TYPE_DC_PDU,
491 "Ntf node is of the wrong type.\nCalled at %s:%d\n", file, line);
492
493 pdu = (struct pdu_data *)ntf->pdu;
494 if (helper_pdu_ntf_verify[opcode]) {
495 helper_pdu_ntf_verify[opcode](file, line, pdu, param);
496 } else if (helper_pdu_verify[opcode]) {
497 helper_pdu_verify[opcode](file, line, pdu, param);
498 }
499
500 *ntf_ref = ntf;
501 }
502
ut_rx_node_real(const char * file,uint32_t line,enum helper_node_opcode opcode,struct node_rx_pdu ** ntf_ref,void * param)503 void ut_rx_node_real(const char *file, uint32_t line, enum helper_node_opcode opcode,
504 struct node_rx_pdu **ntf_ref, void *param)
505 {
506 struct node_rx_pdu *ntf;
507
508 ntf = (struct node_rx_pdu *)sys_slist_get(&ut_rx_q);
509 zassert_not_null(ntf, "Ntf Q empty.\nCalled at %s:%d\n", file, line);
510
511 zassert_not_equal(ntf->hdr.type, NODE_RX_TYPE_DC_PDU,
512 "Ntf node is of the wrong type.\nCalled at %s:%d\n", file, line);
513
514 if (helper_node_verify[opcode]) {
515 helper_node_verify[opcode](file, line, ntf, param);
516 }
517
518 *ntf_ref = ntf;
519 }
520
ut_rx_q_is_empty_real(const char * file,uint32_t line)521 void ut_rx_q_is_empty_real(const char *file, uint32_t line)
522 {
523 struct node_rx_pdu *ntf;
524
525 ntf = (struct node_rx_pdu *)sys_slist_get(&ut_rx_q);
526 zassert_is_null(ntf, "Ntf Q not empty.\nCalled at %s:%d\n", file, line);
527 }
528
encode_pdu(enum helper_pdu_opcode opcode,struct pdu_data * pdu,void * param)529 void encode_pdu(enum helper_pdu_opcode opcode, struct pdu_data *pdu, void *param)
530 {
531 zassert_not_null(helper_pdu_encode[opcode], "PDU encode function cannot be NULL\n");
532 helper_pdu_encode[opcode](pdu, param);
533 }
534