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