Lines Matching full:buf

40  * @param[inout] buf A pointer to the buf_ctx structure containing current
46 static int pack_uint8(uint8_t val, struct buf_ctx *buf) in pack_uint8() argument
48 uint8_t *cur = buf->cur; in pack_uint8()
49 uint8_t *end = buf->end; in pack_uint8()
59 buf->cur = (cur + sizeof(uint8_t)); in pack_uint8()
68 * @param[inout] buf A pointer to the buf_ctx structure containing current
74 static int pack_uint16(uint16_t val, struct buf_ctx *buf) in pack_uint16() argument
76 uint8_t *cur = buf->cur; in pack_uint16()
77 uint8_t *end = buf->end; in pack_uint16()
87 buf->cur = (cur + sizeof(uint16_t)); in pack_uint16()
96 * @param[inout] buf A pointer to the buf_ctx structure containing current
102 static int pack_utf8_str(const struct mqtt_utf8 *str, struct buf_ctx *buf) in pack_utf8_str() argument
104 if ((buf->end - buf->cur) < GET_UT8STR_BUFFER_SIZE(str)) { in pack_utf8_str()
109 (uint32_t)GET_UT8STR_BUFFER_SIZE(str), (void *)buf->cur, (void *)buf->end); in pack_utf8_str()
112 (void)pack_uint16(str->size, buf); in pack_utf8_str()
114 memcpy(buf->cur, str->utf8, str->size); in pack_utf8_str()
115 buf->cur += str->size; in pack_utf8_str()
139 * @param[inout] buf A pointer to the buf_ctx structure containing current
145 static uint8_t packet_length_encode(uint32_t length, struct buf_ctx *buf) in packet_length_encode() argument
150 (buf == NULL) ? 0 : (void *)buf->cur, (buf == NULL) ? 0 : (void *)buf->end); in packet_length_encode()
155 if (buf != NULL) { in packet_length_encode()
156 *(buf->cur) = length & MQTT_LENGTH_VALUE_MASK; in packet_length_encode()
161 if (buf != NULL) { in packet_length_encode()
163 *(buf->cur) |= MQTT_LENGTH_CONTINUATION_BIT; in packet_length_encode()
165 buf->cur++; in packet_length_encode()
180 * @param[inout] buf Buffer context used to encode the frame.
194 struct buf_ctx *buf) in mqtt_encode_fixed_header() argument
196 uint32_t length = buf->cur - start; in mqtt_encode_fixed_header()
211 buf->cur = start - fixed_header_length; in mqtt_encode_fixed_header()
213 (void)pack_uint8(message_type, buf); in mqtt_encode_fixed_header()
214 (void)packet_length_encode(length, buf); in mqtt_encode_fixed_header()
219 buf->cur = buf->cur - fixed_header_length; in mqtt_encode_fixed_header()
220 buf->end = buf->cur + length + fixed_header_length; in mqtt_encode_fixed_header()
230 * @param[inout] buf A pointer to the buf_ctx structure containing current
237 static int zero_len_str_encode(struct buf_ctx *buf) in zero_len_str_encode() argument
239 return pack_uint16(0x0000, buf); in zero_len_str_encode()
254 struct buf_ctx *buf) in mqtt_message_id_only_enc() argument
265 buf->cur += MQTT_FIXED_HEADER_MAX_SIZE; in mqtt_message_id_only_enc()
266 start = buf->cur; in mqtt_message_id_only_enc()
268 err_code = pack_uint16(message_id, buf); in mqtt_message_id_only_enc()
273 return mqtt_encode_fixed_header(message_type, start, buf); in mqtt_message_id_only_enc()
277 struct buf_ctx *buf) in connect_request_encode() argument
294 buf->cur += MQTT_FIXED_HEADER_MAX_SIZE; in connect_request_encode()
295 start = buf->cur; in connect_request_encode()
300 err_code = pack_utf8_str(mqtt_proto_desc, buf); in connect_request_encode()
306 err_code = pack_uint8(client->protocol_version, buf); in connect_request_encode()
314 connect_flags_pos = buf->cur; in connect_request_encode()
316 err_code = pack_uint8(0, buf); in connect_request_encode()
322 err_code = pack_uint16(client->keepalive, buf); in connect_request_encode()
329 err_code = pack_utf8_str(&client->client_id, buf); in connect_request_encode()
344 err_code = pack_utf8_str(&client->will_topic->topic, buf); in connect_request_encode()
353 err_code = pack_utf8_str(client->will_message, buf); in connect_request_encode()
359 err_code = zero_len_str_encode(buf); in connect_request_encode()
373 err_code = pack_utf8_str(client->user_name, buf); in connect_request_encode()
386 err_code = pack_utf8_str(client->password, buf); in connect_request_encode()
395 return mqtt_encode_fixed_header(message_type, start, buf); in connect_request_encode()
398 int publish_encode(const struct mqtt_publish_param *param, struct buf_ctx *buf) in publish_encode() argument
412 buf->cur += MQTT_FIXED_HEADER_MAX_SIZE; in publish_encode()
413 start = buf->cur; in publish_encode()
415 err_code = pack_utf8_str(&param->message.topic.topic, buf); in publish_encode()
421 err_code = pack_uint16(param->message_id, buf); in publish_encode()
430 buf->cur += param->message.payload.len; in publish_encode()
432 err_code = mqtt_encode_fixed_header(message_type, start, buf); in publish_encode()
437 buf->end -= param->message.payload.len; in publish_encode()
443 struct buf_ctx *buf) in publish_ack_encode() argument
448 return mqtt_message_id_only_enc(message_type, param->message_id, buf); in publish_ack_encode()
452 struct buf_ctx *buf) in publish_receive_encode() argument
457 return mqtt_message_id_only_enc(message_type, param->message_id, buf); in publish_receive_encode()
461 struct buf_ctx *buf) in publish_release_encode() argument
466 return mqtt_message_id_only_enc(message_type, param->message_id, buf); in publish_release_encode()
470 struct buf_ctx *buf) in publish_complete_encode() argument
475 return mqtt_message_id_only_enc(message_type, param->message_id, buf); in publish_complete_encode()
478 int disconnect_encode(struct buf_ctx *buf) in disconnect_encode() argument
480 uint8_t *cur = buf->cur; in disconnect_encode()
481 uint8_t *end = buf->end; in disconnect_encode()
488 buf->end = (cur + sizeof(disc_packet)); in disconnect_encode()
494 struct buf_ctx *buf) in subscribe_encode() argument
507 buf->cur += MQTT_FIXED_HEADER_MAX_SIZE; in subscribe_encode()
508 start = buf->cur; in subscribe_encode()
510 err_code = pack_uint16(param->message_id, buf); in subscribe_encode()
516 err_code = pack_utf8_str(&param->list[i].topic, buf); in subscribe_encode()
521 err_code = pack_uint8(param->list[i].qos, buf); in subscribe_encode()
527 return mqtt_encode_fixed_header(message_type, start, buf); in subscribe_encode()
531 struct buf_ctx *buf) in unsubscribe_encode() argument
539 buf->cur += MQTT_FIXED_HEADER_MAX_SIZE; in unsubscribe_encode()
540 start = buf->cur; in unsubscribe_encode()
542 err_code = pack_uint16(param->message_id, buf); in unsubscribe_encode()
548 err_code = pack_utf8_str(&param->list[i].topic, buf); in unsubscribe_encode()
554 return mqtt_encode_fixed_header(message_type, start, buf); in unsubscribe_encode()
557 int ping_request_encode(struct buf_ctx *buf) in ping_request_encode() argument
559 uint8_t *cur = buf->cur; in ping_request_encode()
560 uint8_t *end = buf->end; in ping_request_encode()
567 buf->end = (cur + sizeof(ping_packet)); in ping_request_encode()