Home
last modified time | relevance | path

Searched refs:cpkt (Results 1 – 17 of 17) sorted by relevance

/Zephyr-latest/subsys/net/lib/coap/
Dcoap.c68 static int insert_option(struct coap_packet *cpkt, uint16_t code, const uint8_t *value,
71 static inline void encode_u8(struct coap_packet *cpkt, uint16_t offset, uint8_t data) in encode_u8() argument
73 cpkt->data[offset] = data; in encode_u8()
74 ++cpkt->offset; in encode_u8()
77 static inline void encode_be16(struct coap_packet *cpkt, uint16_t offset, uint16_t data) in encode_be16() argument
79 cpkt->data[offset] = data >> 8; in encode_be16()
80 cpkt->data[offset + 1] = (uint8_t)data; in encode_be16()
81 cpkt->offset += 2; in encode_be16()
84 static inline void encode_buffer(struct coap_packet *cpkt, uint16_t offset, const uint8_t *data, in encode_buffer() argument
87 memcpy(cpkt->data + offset, data, len); in encode_buffer()
[all …]
Dcoap_link_format.c24 static inline bool append_u8(struct coap_packet *cpkt, uint8_t data) in append_u8() argument
26 if (!cpkt) { in append_u8()
30 if (cpkt->max_len - cpkt->offset < 1) { in append_u8()
34 cpkt->data[cpkt->offset++] = data; in append_u8()
39 static inline bool append_be16(struct coap_packet *cpkt, uint16_t data) in append_be16() argument
41 if (!cpkt) { in append_be16()
45 if (cpkt->max_len - cpkt->offset < 2) { in append_be16()
49 cpkt->data[cpkt->offset++] = data >> 8; in append_be16()
50 cpkt->data[cpkt->offset++] = (uint8_t) data; in append_be16()
55 static inline bool append(struct coap_packet *cpkt, const uint8_t *data, uint16_t len) in append() argument
[all …]
Dcoap_server.c522 int coap_service_send(const struct coap_service *service, const struct coap_packet *cpkt, in coap_service_send() argument
544 if (coap_header_get_type(cpkt) == COAP_TYPE_CON) { in coap_service_send()
553 ret = coap_pending_init(pending, cpkt, addr, params); in coap_service_send()
566 memcpy(pending->data, cpkt->data, pending->len); in coap_service_send()
577 ret = zsock_sendto(service->data->sock_fd, cpkt->data, cpkt->offset, 0, addr, addr_len); in coap_service_send()
582 __ASSERT_NO_MSG(ret == cpkt->offset); in coap_service_send()
587 int coap_resource_send(const struct coap_resource *resource, const struct coap_packet *cpkt, in coap_resource_send() argument
594 return coap_service_send(svc, cpkt, addr, addr_len, params); in coap_resource_send()
/Zephyr-latest/tests/net/lib/coap/src/
Dmain.c82 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()
[all …]
/Zephyr-latest/tests/net/lib/lwm2m/block_transfer/src/
Dmain.c74 zassert_not_equal(msg->msg_data, msg->cpkt.data, in ZTEST_F()
76 zassert_equal(msg->cpkt.data, msg->body_encode_buffer.data, in ZTEST_F()
79 zassert_equal(EXPECTED_LWM2M_COAP_FULL_BUFFER_SIZE, msg->cpkt.max_len, in ZTEST_F()
82 zassert_equal(EXPECTED_DEFAULT_HEADER_OFFSET, msg->cpkt.offset); in ZTEST_F()
85 msg->out.out_cpkt = &msg->cpkt; in ZTEST_F()
89 zassert_equal(msg->cpkt.max_len, msg->cpkt.offset, "Buffer should be full"); in ZTEST_F()
107 zassert_not_equal(msg->msg_data, msg->cpkt.data, in ZTEST_F()
109 zassert_equal(msg->cpkt.data, msg->body_encode_buffer.data, in ZTEST_F()
112 ret = coap_append_option_int(&msg->cpkt, COAP_OPTION_CONTENT_FORMAT, in ZTEST_F()
116 ret = coap_packet_append_payload_marker(&msg->cpkt); in ZTEST_F()
[all …]
/Zephyr-latest/include/zephyr/net/
Dcoap.h413 uint8_t coap_header_get_version(const struct coap_packet *cpkt);
422 uint8_t coap_header_get_type(const struct coap_packet *cpkt);
433 uint8_t coap_header_get_token(const struct coap_packet *cpkt, uint8_t *token);
442 uint8_t coap_header_get_code(const struct coap_packet *cpkt);
451 int coap_header_set_code(const struct coap_packet *cpkt, uint8_t code);
460 uint16_t coap_header_get_id(const struct coap_packet *cpkt);
471 const uint8_t *coap_packet_get_payload(const struct coap_packet *cpkt,
504 int coap_packet_parse(struct coap_packet *cpkt, uint8_t *data, uint16_t len,
516 int coap_packet_set_path(struct coap_packet *cpkt, const char *path);
533 int coap_packet_init(struct coap_packet *cpkt, uint8_t *data, uint16_t max_len,
[all …]
Dcoap_service.h243 int coap_service_send(const struct coap_service *service, const struct coap_packet *cpkt,
259 int coap_resource_send(const struct coap_resource *resource, const struct coap_packet *cpkt,
/Zephyr-latest/tests/net/lib/lwm2m/lwm2m_rd_client/src/
Dstubs.h26 uint8_t coap_header_get_code_fake_created(const struct coap_packet *cpkt);
27 uint8_t coap_header_get_code_fake_deleted(const struct coap_packet *cpkt);
28 uint8_t coap_header_get_code_fake_changed(const struct coap_packet *cpkt);
29 uint8_t coap_header_get_code_fake_bad_request(const struct coap_packet *cpkt);
33 int coap_packet_append_option_fake_err(struct coap_packet *cpkt, uint16_t code,
38 int coap_find_options_do_registration_reply_cb_ok(const struct coap_packet *cpkt, uint16_t code,
Dstubs.c15 uint8_t coap_header_get_code_fake_created(const struct coap_packet *cpkt) in coap_header_get_code_fake_created() argument
19 uint8_t coap_header_get_code_fake_deleted(const struct coap_packet *cpkt) in coap_header_get_code_fake_deleted() argument
23 uint8_t coap_header_get_code_fake_changed(const struct coap_packet *cpkt) in coap_header_get_code_fake_changed() argument
27 uint8_t coap_header_get_code_fake_bad_request(const struct coap_packet *cpkt) in coap_header_get_code_fake_bad_request() argument
35 int coap_packet_append_option_fake_err(struct coap_packet *cpkt, uint16_t code, in coap_packet_append_option_fake_err() argument
44 int coap_find_options_do_registration_reply_cb_ok(const struct coap_packet *cpkt, uint16_t code, in coap_find_options_do_registration_reply_cb_ok() argument
/Zephyr-latest/tests/net/lib/lwm2m/content_json/src/
Dmain.c116 test_msg.out.out_cpkt = &test_msg.cpkt; in context_reset()
119 test_msg.in.in_cpkt = &test_msg.cpkt; in context_reset()
125 test_msg.cpkt.data = test_msg.msg_data; in context_reset()
126 test_msg.cpkt.max_len = sizeof(test_msg.msg_data); in context_reset()
132 test_msg.cpkt.offset = strlen(payload) + 1; in test_payload_set()
148 test_msg.cpkt.offset = sizeof(test_msg.msg_data) - TEST_PAYLOAD_OFFSET; in test_prepare_nomem()
185 zassert_equal(test_msg.cpkt.offset, offset, in ZTEST()
227 zassert_equal(test_msg.cpkt.offset, offset, in ZTEST()
269 zassert_equal(test_msg.cpkt.offset, offset, in ZTEST()
311 zassert_equal(test_msg.cpkt.offset, offset, in ZTEST()
[all …]
/Zephyr-latest/tests/net/lib/lwm2m/content_senml_cbor/src/
Dmain.c132 test_msg.out.out_cpkt = &test_msg.cpkt; in context_reset()
135 test_msg.in.in_cpkt = &test_msg.cpkt; in context_reset()
141 test_msg.cpkt.data = test_msg.msg_data; in context_reset()
142 test_msg.cpkt.max_len = sizeof(test_msg.msg_data); in context_reset()
148 test_msg.cpkt.offset = payload.len + 1; in test_payload_set()
165 test_msg.cpkt.offset = sizeof(test_msg.msg_data) - TEST_PAYLOAD_OFFSET; in test_prepare_nomem()
247 zassert_equal(test_msg.cpkt.offset, offset, in ZTEST()
335 zassert_equal(test_msg.cpkt.offset, offset, in ZTEST()
423 zassert_equal(test_msg.cpkt.offset, offset, in ZTEST()
511 zassert_equal(test_msg.cpkt.offset, offset, in ZTEST()
[all …]
/Zephyr-latest/subsys/net/lib/lwm2m/
Dlwm2m_object.h145 #define CPKT_BUF_WRITE(cpkt) (cpkt)->data, &(cpkt)->offset, (cpkt)->max_len argument
146 #define CPKT_BUF_READ(cpkt) (cpkt)->data, (cpkt)->max_len argument
147 #define CPKT_BUF_W_PTR(cpkt) ((cpkt)->data + (cpkt)->offset) argument
148 #define CPKT_BUF_W_SIZE(cpkt) ((cpkt)->max_len - (cpkt)->offset) argument
150 #define CPKT_BUF_W_REGION(cpkt) CPKT_BUF_W_PTR(cpkt), CPKT_BUF_W_SIZE(cpkt) argument
494 struct coap_packet cpkt; member
Dlwm2m_pull_context.c138 ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_PATH, cursor, strlen(cursor)); in transfer_request()
160 ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_PATH, cursor, in transfer_request()
175 ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_PATH, cursor, len); in transfer_request()
183 ret = coap_append_block2_option(&msg->cpkt, ctx); in transfer_request()
190 ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_PROXY_URI, context.uri, in transfer_request()
198 ret = coap_append_option_int(&msg->cpkt, COAP_OPTION_SIZE2, 0); in transfer_request()
Dlwm2m_message_handling.c295 NET_ASSERT(msg->msg_data == msg->cpkt.data, in build_msg_block_for_send()
306 ret = buf_append(CPKT_BUF_WRITE(&msg->cpkt), msg->body_encode_buffer.data, in build_msg_block_for_send()
311 msg->cpkt.hdr_len = msg->body_encode_buffer.hdr_len; in build_msg_block_for_send()
341 ret = buf_append(CPKT_BUF_WRITE(&msg->cpkt), in build_msg_block_for_send()
347 msg->cpkt.opt_len = msg->body_encode_buffer.opt_len; in build_msg_block_for_send()
349 msg->cpkt.delta = msg->body_encode_buffer.delta; in build_msg_block_for_send()
372 ret = coap_append_descriptive_block_option(&msg->cpkt, msg->out.block_ctx); in build_msg_block_for_send()
377 ret = coap_packet_append_payload_marker(&msg->cpkt); in build_msg_block_for_send()
383 ret = buf_append(CPKT_BUF_WRITE(&msg->cpkt), in build_msg_block_for_send()
399 msg->body_encode_buffer = msg->cpkt; in prepare_msg_for_send()
[all …]
Dlwm2m_rd_client.c754 ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_PATH, in sm_send_bootstrap_registration()
763 ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_QUERY, in sm_send_bootstrap_registration()
780 coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_QUERY, in sm_send_bootstrap_registration()
888 ret = coap_packet_append_option(&msg->cpkt, COAP_OPTION_URI_PATH, in sm_send_registration()
897 &msg->cpkt, COAP_OPTION_URI_PATH, in sm_send_registration()
906 &msg->cpkt, COAP_OPTION_CONTENT_FORMAT, in sm_send_registration()
917 &msg->cpkt, COAP_OPTION_URI_QUERY, in sm_send_registration()
926 &msg->cpkt, COAP_OPTION_URI_QUERY, in sm_send_registration()
939 &msg->cpkt, COAP_OPTION_URI_QUERY, in sm_send_registration()
954 &msg->cpkt, COAP_OPTION_URI_QUERY, in sm_send_registration()
[all …]
Dlwm2m_rw_cbor.c33 #define CPKT_CBOR_W_SZ(pos, cpkt) ((size_t)(pos) - (size_t)(cpkt)->data - (size_t)(cpkt)->offset) argument
Dlwm2m_engine.c675 bool ongoing_block_tx = coap_block_has_more(&ongoing_tx->cpkt); in hint_socket_state()
749 rc = zsock_send(msg->ctx->sock_fd, msg->cpkt.data, msg->cpkt.offset, 0); in socket_send_message()