Lines Matching refs:cpkt

82 	struct coap_packet cpkt;  in ZTEST()  local
86 r = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, in ZTEST()
91 zassert_equal(cpkt.offset, sizeof(result_pdu), in ZTEST()
93 zassert_equal(cpkt.hdr_len, COAP_FIXED_HEADER_SIZE, in ZTEST()
95 zassert_equal(cpkt.opt_len, 0, "Invalid options length"); in ZTEST()
96 zassert_mem_equal(result_pdu, cpkt.data, cpkt.offset, in ZTEST()
105 struct coap_packet cpkt; in ZTEST() local
113 r = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, in ZTEST()
120 r = coap_append_option_int(&cpkt, COAP_OPTION_CONTENT_FORMAT, in ZTEST()
124 r = coap_packet_append_payload_marker(&cpkt); in ZTEST()
127 r = coap_packet_append_payload(&cpkt, payload, sizeof(payload)); in ZTEST()
130 zassert_equal(cpkt.offset, sizeof(result_pdu), in ZTEST()
132 zassert_equal(cpkt.hdr_len, COAP_FIXED_HEADER_SIZE + strlen(token), in ZTEST()
134 zassert_equal(cpkt.opt_len, 1, "Invalid options length"); in ZTEST()
135 zassert_mem_equal(result_pdu, cpkt.data, cpkt.offset, in ZTEST()
138 payload_start = coap_packet_get_payload(&cpkt, &payload_len); in ZTEST()
141 zassert_equal_ptr(payload_start, cpkt.data + cpkt.offset - payload_len, in ZTEST()
149 struct coap_packet cpkt; in ZTEST() local
159 r = coap_packet_parse(&cpkt, data, sizeof(pdu), NULL, 0); in ZTEST()
162 zassert_equal(cpkt.offset, sizeof(pdu), in ZTEST()
164 zassert_equal(cpkt.hdr_len, COAP_FIXED_HEADER_SIZE, in ZTEST()
166 zassert_equal(cpkt.opt_len, 0, "Invalid options length"); in ZTEST()
168 ver = coap_header_get_version(&cpkt); in ZTEST()
169 type = coap_header_get_type(&cpkt); in ZTEST()
170 code = coap_header_get_code(&cpkt); in ZTEST()
171 id = coap_header_get_id(&cpkt); in ZTEST()
185 struct coap_packet cpkt; in ZTEST() local
195 r = coap_packet_parse(&cpkt, data, sizeof(pdu), NULL, 0); in ZTEST()
198 zassert_equal(cpkt.offset, sizeof(pdu), in ZTEST()
200 zassert_equal(cpkt.hdr_len, COAP_FIXED_HEADER_SIZE, in ZTEST()
202 zassert_equal(cpkt.opt_len, 1, "Invalid options length"); in ZTEST()
204 ver = coap_header_get_version(&cpkt); in ZTEST()
205 type = coap_header_get_type(&cpkt); in ZTEST()
206 code = coap_header_get_code(&cpkt); in ZTEST()
207 id = coap_header_get_id(&cpkt); in ZTEST()
222 struct coap_packet cpkt; in ZTEST() local
238 r = coap_packet_parse(&cpkt, data, sizeof(pdu), NULL, 0); in ZTEST()
241 zassert_equal(cpkt.offset, sizeof(pdu), in ZTEST()
243 zassert_equal(cpkt.hdr_len, COAP_FIXED_HEADER_SIZE + strlen("token"), in ZTEST()
245 zassert_equal(cpkt.opt_len, 3, "Invalid options length"); in ZTEST()
247 payload_start = coap_packet_get_payload(&cpkt, &payload_len); in ZTEST()
250 zassert_equal_ptr(payload_start, cpkt.data + cpkt.offset - payload_len, in ZTEST()
253 ver = coap_header_get_version(&cpkt); in ZTEST()
254 type = coap_header_get_type(&cpkt); in ZTEST()
255 code = coap_header_get_code(&cpkt); in ZTEST()
256 id = coap_header_get_id(&cpkt); in ZTEST()
265 tkl = coap_header_get_token(&cpkt, (uint8_t *)token); in ZTEST()
271 count = coap_find_options(&cpkt, COAP_OPTION_CONTENT_FORMAT, in ZTEST()
282 count = coap_find_options(&cpkt, COAP_OPTION_ETAG, options, count); in ZTEST()
292 struct coap_packet cpkt; in ZTEST() local
296 r = coap_packet_parse(&cpkt, NULL, sizeof(opt), NULL, 0); in ZTEST()
299 r = coap_packet_parse(&cpkt, data, 0, NULL, 0); in ZTEST()
303 r = coap_packet_parse(&cpkt, data, sizeof(opt), NULL, 0); in ZTEST()
311 struct coap_packet cpkt; in ZTEST() local
316 r = coap_packet_parse(&cpkt, data, sizeof(opt), NULL, 0); in ZTEST()
324 struct coap_packet cpkt; in ZTEST() local
330 r = coap_packet_parse(&cpkt, data, sizeof(opt), NULL, 0); in ZTEST()
338 struct coap_packet cpkt; in ZTEST() local
344 r = coap_packet_parse(&cpkt, data, sizeof(opt), NULL, 0); in ZTEST()
352 struct coap_packet cpkt; in ZTEST() local
358 r = coap_packet_parse(&cpkt, data, sizeof(opt), NULL, 0); in ZTEST()
366 struct coap_packet cpkt; in ZTEST() local
372 r = coap_packet_parse(&cpkt, data, sizeof(opt), NULL, 0); in ZTEST()
380 struct coap_packet cpkt; in ZTEST() local
386 r = coap_packet_parse(&cpkt, data, sizeof(pdu), NULL, 0); in ZTEST()
396 struct coap_packet cpkt; in ZTEST() local
404 r = coap_packet_parse(&cpkt, data, sizeof(pdu), NULL, 0); in ZTEST()
407 r = coap_ack_init(&ack_cpkt, &cpkt, ack_data, COAP_BUF_SIZE, in ZTEST()
423 struct coap_packet cpkt; in ZTEST() local
431 r = coap_packet_parse(&cpkt, data, sizeof(pdu), NULL, 0); in ZTEST()
434 r = coap_ack_init(&ack_cpkt, &cpkt, ack_data, COAP_BUF_SIZE, in ZTEST()
775 struct coap_packet cpkt; in ZTEST() local
786 r = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, COAP_VERSION_1, in ZTEST()
794 r = coap_pending_init(pending, &cpkt, (struct sockaddr *) &dummy_addr, in ZTEST()
1051 struct coap_packet cpkt; in ZTEST() local
1056 r = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, COAP_VERSION_1, COAP_TYPE_CON, in ZTEST()
1060 r = coap_append_option_int(&cpkt, COAP_OPTION_CONTENT_FORMAT, in ZTEST()
1066 zassert_mem_equal(&expected_options_0, &cpkt.data[cpkt.hdr_len], cpkt.opt_len); in ZTEST()
1070 r = coap_packet_append_option(&cpkt, COAP_OPTION_PROXY_URI, proxy_uri, strlen(proxy_uri)); in ZTEST()
1076 zassert_mem_equal(expected_options_1, &cpkt.data[cpkt.hdr_len], cpkt.opt_len); in ZTEST()
1080 r = coap_packet_append_option(&cpkt, COAP_OPTION_PROXY_SCHEME, proxy_scheme, in ZTEST()
1088 zassert_mem_equal(expected_options_2, &cpkt.data[cpkt.hdr_len], cpkt.opt_len); in ZTEST()
1093 r = coap_append_option_int(&cpkt, COAP_OPTION_BLOCK2, block_option); in ZTEST()
1101 zassert_mem_equal(expected_options_3, &cpkt.data[cpkt.hdr_len], cpkt.opt_len); in ZTEST()
1106 r = coap_find_options(&cpkt, COAP_OPTION_CONTENT_FORMAT, &opt, 1); in ZTEST()
1109 r = coap_find_options(&cpkt, COAP_OPTION_PROXY_URI, &opt, 1); in ZTEST()
1114 r = coap_find_options(&cpkt, COAP_OPTION_PROXY_SCHEME, &opt, 1); in ZTEST()
1119 r = coap_find_options(&cpkt, COAP_OPTION_BLOCK2, &opt, 1); in ZTEST()
1124 zassert_equal(cpkt.hdr_len, 9, "Wrong header len"); in ZTEST()
1125 zassert_equal(cpkt.opt_len, 14, "Wrong options size"); in ZTEST()
1126 zassert_equal(cpkt.delta, 39, "Wrong delta"); in ZTEST()
1128 zassert_equal(cpkt.offset, 23, "Wrong data size"); in ZTEST()
1130 zassert_mem_equal(result, cpkt.data, cpkt.offset, in ZTEST()
1134 #define ASSERT_OPTIONS(cpkt, expected_opt_len, expected_data, expected_data_len) \ argument
1137 zassert_equal(expected_hdr_len, cpkt.hdr_len, "Wrong header length"); \
1138 zassert_equal(expected_opt_len, cpkt.opt_len, "Wrong option length"); \
1139 zassert_equal(expected_hdr_len + expected_opt_len, cpkt.offset, "Wrong offset"); \
1140 zassert_equal(expected_data_len, cpkt.offset, "Wrong offset"); \
1141 zassert_mem_equal(expected_data, cpkt.data, expected_data_len, "Wrong data"); \
1146 struct coap_packet cpkt; in ZTEST() local
1156 r = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, COAP_VERSION_1, COAP_TYPE_CON, in ZTEST()
1160 r = coap_append_option_int(&cpkt, COAP_OPTION_SIZE2, in ZTEST()
1165 ASSERT_OPTIONS(cpkt, 3, expected_0, 12); in ZTEST()
1169 r = coap_packet_append_option(&cpkt, COAP_OPTION_URI_PATH, uri_path, strlen(uri_path)); in ZTEST()
1177 ASSERT_OPTIONS(cpkt, 8, expected_1, 17); in ZTEST()
1179 r = coap_append_option_int(&cpkt, COAP_OPTION_CONTENT_FORMAT, COAP_CONTENT_FORMAT_APP_JSON); in ZTEST()
1187 ASSERT_OPTIONS(cpkt, 10, expected_2, 19); in ZTEST()
1191 r = coap_packet_append_option(&cpkt, COAP_OPTION_URI_HOST, uri_host, strlen(uri_host)); in ZTEST()
1199 ASSERT_OPTIONS(cpkt, 19, expected_3, 28); in ZTEST()
1201 r = coap_append_option_int(&cpkt, COAP_OPTION_URI_PORT, 5638); in ZTEST()
1210 ASSERT_OPTIONS(cpkt, 22, expected_4, 31); in ZTEST()
1214 r = coap_packet_append_option(&cpkt, COAP_OPTION_URI_QUERY, uri_query0, strlen(uri_query0)); in ZTEST()
1219 r = coap_packet_append_option(&cpkt, COAP_OPTION_URI_QUERY, uri_query1, strlen(uri_query1)); in ZTEST()
1229 ASSERT_OPTIONS(cpkt, 36, expected_5, 45); in ZTEST()
1231 r = coap_append_option_int(&cpkt, COAP_OPTION_ACCEPT, COAP_CONTENT_FORMAT_APP_CBOR); in ZTEST()
1241 ASSERT_OPTIONS(cpkt, 37, expected_6, 46); in ZTEST()
1243 r = coap_append_option_int(&cpkt, COAP_OPTION_OBSERVE, 0); in ZTEST()
1253 ASSERT_OPTIONS(cpkt, 38, expected_7, 47); in ZTEST()
1255 r = coap_append_option_int(&cpkt, COAP_OPTION_MAX_AGE, 3); in ZTEST()
1265 ASSERT_OPTIONS(cpkt, 40, expected_8, 49); in ZTEST()
1267 r = coap_append_option_int(&cpkt, COAP_OPTION_SIZE1, 64); in ZTEST()
1277 ASSERT_OPTIONS(cpkt, 43, expected_9, 52); in ZTEST()
1279 zassert_equal(cpkt.hdr_len, 9, "Wrong header len"); in ZTEST()
1280 zassert_equal(cpkt.opt_len, 43, "Wrong options size"); in ZTEST()
1281 zassert_equal(cpkt.delta, 60, "Wrong delta"); in ZTEST()
1282 zassert_equal(cpkt.offset, 52, "Wrong data size"); in ZTEST()
1285 #define ASSERT_OPTIONS_AND_PAYLOAD(cpkt, expected_opt_len, expected_data, expected_offset, \ argument
1291 zassert_equal(expected_hdr_len, cpkt.hdr_len, "Wrong header length"); \
1292 zassert_equal(expected_opt_len, cpkt.opt_len, "Wrong option length"); \
1293 zassert_equal(expected_offset, cpkt.offset, "Wrong offset"); \
1294 zassert_mem_equal(expected_data, cpkt.data, expected_offset, "Wrong data"); \
1295 zassert_equal(expected_delta, cpkt.delta, "Wrong delta"); \
1298 static void init_basic_test_msg(struct coap_packet *cpkt, uint8_t *data) in init_basic_test_msg() argument
1310 r = coap_packet_init(cpkt, data, COAP_BUF_SIZE, COAP_VERSION_1, COAP_TYPE_CON, in init_basic_test_msg()
1314 r = coap_append_option_int(cpkt, COAP_OPTION_SIZE2, in init_basic_test_msg()
1318 r = coap_packet_append_option(cpkt, COAP_OPTION_URI_PATH, uri_path, strlen(uri_path)); in init_basic_test_msg()
1321 r = coap_append_option_int(cpkt, COAP_OPTION_CONTENT_FORMAT, COAP_CONTENT_FORMAT_APP_JSON); in init_basic_test_msg()
1324 r = coap_packet_append_option(cpkt, COAP_OPTION_URI_HOST, uri_host, strlen(uri_host)); in init_basic_test_msg()
1327 r = coap_append_option_int(cpkt, COAP_OPTION_URI_PORT, 5638); in init_basic_test_msg()
1330 r = coap_packet_append_option(cpkt, COAP_OPTION_URI_QUERY, uri_query0, strlen(uri_query0)); in init_basic_test_msg()
1333 r = coap_packet_append_option(cpkt, COAP_OPTION_URI_QUERY, uri_query1, strlen(uri_query1)); in init_basic_test_msg()
1336 r = coap_append_option_int(cpkt, COAP_OPTION_ACCEPT, COAP_CONTENT_FORMAT_APP_CBOR); in init_basic_test_msg()
1339 r = coap_append_option_int(cpkt, COAP_OPTION_OBSERVE, 0); in init_basic_test_msg()
1342 r = coap_append_option_int(cpkt, COAP_OPTION_MAX_AGE, 3); in init_basic_test_msg()
1345 r = coap_append_option_int(cpkt, COAP_OPTION_SIZE1, 64); in init_basic_test_msg()
1355 ASSERT_OPTIONS((*cpkt), 43, expected_9, 52); in init_basic_test_msg()
1357 r = coap_packet_append_payload_marker(cpkt); in init_basic_test_msg()
1362 r = coap_packet_append_payload(cpkt, test_payload, ARRAY_SIZE(test_payload)); in init_basic_test_msg()
1365 zassert_equal((*cpkt).hdr_len, 9, "Wrong header len"); in init_basic_test_msg()
1366 zassert_equal((*cpkt).opt_len, 43, "Wrong options size"); in init_basic_test_msg()
1367 zassert_equal((*cpkt).delta, 60, "Wrong delta"); in init_basic_test_msg()
1368 zassert_equal((*cpkt).offset, 57, "Wrong data size"); in init_basic_test_msg()
1374 struct coap_packet cpkt; in ZTEST() local
1377 init_basic_test_msg(&cpkt, data); in ZTEST()
1379 r = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_HOST); in ZTEST()
1388 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 34, expected_0, 48, 60); in ZTEST()
1394 struct coap_packet cpkt; in ZTEST() local
1397 init_basic_test_msg(&cpkt, data); in ZTEST()
1399 r = coap_packet_remove_option(&cpkt, COAP_OPTION_OBSERVE); in ZTEST()
1408 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 42, expected_0, 56, 60); in ZTEST()
1414 struct coap_packet cpkt; in ZTEST() local
1417 init_basic_test_msg(&cpkt, data); in ZTEST()
1419 r = coap_packet_remove_option(&cpkt, COAP_OPTION_SIZE1); in ZTEST()
1428 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 40, expected_0, 54, 28); in ZTEST()
1430 r = coap_append_option_int(&cpkt, COAP_OPTION_SIZE1, 65); in ZTEST()
1440 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 43, expected_1, 57, 60); in ZTEST()
1445 struct coap_packet cpkt; in ZTEST() local
1455 r1 = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, COAP_VERSION_1, COAP_TYPE_CON, in ZTEST()
1459 r1 = coap_packet_append_option(&cpkt, COAP_OPTION_URI_PATH, uri_path, strlen(uri_path)); in ZTEST()
1462 r1 = coap_packet_append_payload_marker(&cpkt); in ZTEST()
1467 r1 = coap_packet_append_payload(&cpkt, test_payload, ARRAY_SIZE(test_payload)); in ZTEST()
1474 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 5, expected_0, 19, 11); in ZTEST()
1477 r1 = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_PATH); in ZTEST()
1483 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 0, expected_1, 14, 0); in ZTEST()
1489 struct coap_packet cpkt; in ZTEST() local
1492 init_basic_test_msg(&cpkt, data); in ZTEST()
1494 r = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_QUERY); in ZTEST()
1503 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 36, expected_0, 50, 60); in ZTEST()
1509 struct coap_packet cpkt; in ZTEST() local
1512 init_basic_test_msg(&cpkt, data); in ZTEST()
1514 r = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_PORT); in ZTEST()
1517 r = coap_packet_remove_option(&cpkt, COAP_OPTION_OBSERVE); in ZTEST()
1520 r = coap_packet_remove_option(&cpkt, COAP_OPTION_SIZE1); in ZTEST()
1529 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 36, expected_0, 50, 28); in ZTEST()
1531 r = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_HOST); in ZTEST()
1534 r = coap_packet_remove_option(&cpkt, COAP_OPTION_SIZE2); in ZTEST()
1537 r = coap_packet_remove_option(&cpkt, COAP_OPTION_CONTENT_FORMAT); in ZTEST()
1545 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 23, expected_1, 37, 17); in ZTEST()
1547 r = coap_packet_remove_option(&cpkt, COAP_OPTION_ACCEPT); in ZTEST()
1550 r = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_PATH); in ZTEST()
1553 r = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_QUERY); in ZTEST()
1560 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 10, expected_2, 24, 15); in ZTEST()
1562 r = coap_packet_remove_option(&cpkt, COAP_OPTION_MAX_AGE); in ZTEST()
1565 r = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_QUERY); in ZTEST()
1571 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 0, expected_3, 14, 0); in ZTEST()
1574 r = coap_packet_remove_option(&cpkt, COAP_OPTION_MAX_AGE); in ZTEST()
1577 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 0, expected_3, 14, 0); in ZTEST()
1583 struct coap_packet cpkt; in ZTEST() local
1589 r = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, COAP_VERSION_1, COAP_TYPE_CON, in ZTEST()
1593 r = coap_append_option_int(&cpkt, COAP_OPTION_CONTENT_FORMAT, COAP_CONTENT_FORMAT_APP_CBOR); in ZTEST()
1596 r = coap_append_option_int(&cpkt, COAP_OPTION_ACCEPT, COAP_CONTENT_FORMAT_APP_OCTET_STREAM); in ZTEST()
1599 r = coap_packet_append_payload_marker(&cpkt); in ZTEST()
1604 r = coap_packet_append_payload(&cpkt, test_payload, ARRAY_SIZE(test_payload)); in ZTEST()
1610 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 4, expected_original_msg, 18, 17); in ZTEST()
1613 r = coap_packet_remove_option(&cpkt, COAP_OPTION_URI_PATH); in ZTEST()
1616 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 4, expected_original_msg, 18, 17); in ZTEST()
1619 r = coap_packet_remove_option(&cpkt, COAP_OPTION_MAX_AGE); in ZTEST()
1622 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 4, expected_original_msg, 18, 17); in ZTEST()
1625 r = coap_packet_remove_option(&cpkt, COAP_OPTION_LOCATION_QUERY); in ZTEST()
1628 ASSERT_OPTIONS_AND_PAYLOAD(cpkt, 4, expected_original_msg, 18, 17); in ZTEST()
1635 struct coap_packet cpkt; in assert_coap_packet_set_path_query_options() local
1643 res = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, COAP_VERSION_1, COAP_TYPE_CON, in assert_coap_packet_set_path_query_options()
1648 res = coap_packet_set_path(&cpkt, path); in assert_coap_packet_set_path_query_options()
1651 res = coap_find_options(&cpkt, code, options, ARRAY_SIZE(options)); in assert_coap_packet_set_path_query_options()
1744 struct coap_packet cpkt; in ZTEST() local
1769 r = coap_packet_init(&cpkt, data, COAP_BUF_SIZE, COAP_VERSION_1, in ZTEST()
1782 r = coap_pending_init(pending, &cpkt, (struct sockaddr *) &dummy_addr, in ZTEST()
1791 r = coap_pending_init(pending, &cpkt, (struct sockaddr *) &dummy_addr, in ZTEST()