Lines Matching refs:buf
30 static int unpack_uint8(struct buf_ctx *buf, uint8_t *val) in unpack_uint8() argument
32 uint8_t *cur = buf->cur; in unpack_uint8()
33 uint8_t *end = buf->end; in unpack_uint8()
42 buf->cur = (cur + sizeof(uint8_t)); in unpack_uint8()
60 static int unpack_uint16(struct buf_ctx *buf, uint16_t *val) in unpack_uint16() argument
62 uint8_t *cur = buf->cur; in unpack_uint16()
63 uint8_t *end = buf->end; in unpack_uint16()
72 buf->cur = (cur + sizeof(uint16_t)); in unpack_uint16()
90 static int unpack_utf8_str(struct buf_ctx *buf, struct mqtt_utf8 *str) in unpack_utf8_str() argument
95 NET_DBG(">> cur:%p, end:%p", (void *)buf->cur, (void *)buf->end); in unpack_utf8_str()
97 err_code = unpack_uint16(buf, &utf8_strlen); in unpack_utf8_str()
102 if ((buf->end - buf->cur) < utf8_strlen) { in unpack_utf8_str()
110 str->utf8 = buf->cur; in unpack_utf8_str()
111 buf->cur += utf8_strlen; in unpack_utf8_str()
134 static int unpack_raw_data(uint32_t length, struct buf_ctx *buf, in unpack_raw_data() argument
137 NET_DBG(">> cur:%p, end:%p", (void *)buf->cur, (void *)buf->end); in unpack_raw_data()
139 if ((buf->end - buf->cur) < length) { in unpack_raw_data()
147 str->data = buf->cur; in unpack_raw_data()
148 buf->cur += length; in unpack_raw_data()
158 int unpack_variable_int(struct buf_ctx *buf, uint32_t *val) in unpack_variable_int() argument
169 if (buf->cur >= buf->end) { in unpack_variable_int()
173 *val += ((uint32_t)*(buf->cur) & MQTT_LENGTH_VALUE_MASK) in unpack_variable_int()
177 } while ((*(buf->cur++) & MQTT_LENGTH_CONTINUATION_BIT) != 0U); in unpack_variable_int()
188 int fixed_header_decode(struct buf_ctx *buf, uint8_t *type_and_flags, in fixed_header_decode() argument
193 err_code = unpack_uint8(buf, type_and_flags); in fixed_header_decode()
198 err_code = unpack_variable_int(buf, length); in fixed_header_decode()
218 static int unpack_uint32(struct buf_ctx *buf, uint32_t *val) in unpack_uint32() argument
220 uint8_t *cur = buf->cur; in unpack_uint32()
221 uint8_t *end = buf->end; in unpack_uint32()
230 buf->cur = (cur + sizeof(uint32_t)); in unpack_uint32()
249 static int unpack_binary_data(struct buf_ctx *buf, struct mqtt_binstr *bin) in unpack_binary_data() argument
254 NET_DBG(">> cur:%p, end:%p", (void *)buf->cur, (void *)buf->end); in unpack_binary_data()
256 err = unpack_uint16(buf, &len); in unpack_binary_data()
261 if ((buf->end - buf->cur) < len) { in unpack_binary_data()
268 bin->data = buf->cur; in unpack_binary_data()
269 buf->cur += len; in unpack_binary_data()
287 struct buf_ctx *buf) in decode_uint32_property() argument
295 if (unpack_uint32(buf, value) < 0) { in decode_uint32_property()
307 struct buf_ctx *buf) in decode_uint16_property() argument
315 if (unpack_uint16(buf, value) < 0) { in decode_uint16_property()
327 struct buf_ctx *buf) in decode_uint8_property() argument
335 if (unpack_uint8(buf, value) < 0) { in decode_uint8_property()
347 struct buf_ctx *buf) in decode_string_property() argument
351 if (unpack_utf8_str(buf, str) < 0) { in decode_string_property()
367 struct buf_ctx *buf) in decode_binary_property() argument
371 if (unpack_binary_data(buf, bin) < 0) { in decode_binary_property()
387 struct buf_ctx *buf) in decode_user_property() argument
394 if (unpack_utf8_str(buf, &temp.name) < 0) { in decode_user_property()
398 if (unpack_utf8_str(buf, &temp.value) < 0) { in decode_user_property()
428 struct buf_ctx *buf) in decode_sub_id_property() argument
435 bytes = unpack_variable_int(buf, &value); in decode_sub_id_property()
464 struct buf_ctx *buf) in properties_decode() argument
470 bytes = unpack_variable_int(buf, &properties_len); in properties_decode()
482 err = unpack_uint8(buf, &type); in properties_decode()
509 &properties_len, buf); in properties_decode()
516 &properties_len, buf); in properties_decode()
525 &properties_len, buf); in properties_decode()
535 &properties_len, buf); in properties_decode()
539 &properties_len, buf); in properties_decode()
544 &properties_len, buf); in properties_decode()
548 &properties_len, buf); in properties_decode()
562 static int connack_properties_decode(struct buf_ctx *buf, in connack_properties_decode() argument
653 return properties_decode(prop, ARRAY_SIZE(prop), buf); in connack_properties_decode()
656 static int connack_properties_decode(struct buf_ctx *buf, in connack_properties_decode() argument
660 ARG_UNUSED(buf); in connack_properties_decode()
666 int connect_ack_decode(const struct mqtt_client *client, struct buf_ctx *buf, in connect_ack_decode() argument
672 err_code = unpack_uint8(buf, &flags); in connect_ack_decode()
677 err_code = unpack_uint8(buf, &ret_code); in connect_ack_decode()
693 err_code = connack_properties_decode(buf, param); in connect_ack_decode()
704 static int publish_properties_decode(struct buf_ctx *buf, in publish_properties_decode() argument
750 return properties_decode(prop, ARRAY_SIZE(prop), buf); in publish_properties_decode()
805 static int publish_properties_decode(struct buf_ctx *buf, in publish_properties_decode() argument
809 ARG_UNUSED(buf); in publish_properties_decode()
825 uint32_t var_length, struct buf_ctx *buf, in publish_decode() argument
835 err_code = unpack_utf8_str(buf, ¶m->message.topic.topic); in publish_decode()
843 err_code = unpack_uint16(buf, ¶m->message_id); in publish_decode()
852 err_code = publish_properties_decode(buf, param); in publish_decode()
880 static int common_ack_properties_decode(struct buf_ctx *buf, in common_ack_properties_decode() argument
896 return properties_decode(prop_dec, ARRAY_SIZE(prop_dec), buf); in common_ack_properties_decode()
899 static int common_ack_properties_decode(struct buf_ctx *buf, in common_ack_properties_decode() argument
903 ARG_UNUSED(buf); in common_ack_properties_decode()
909 static int common_pub_ack_decode(struct buf_ctx *buf, uint16_t *message_id, in common_pub_ack_decode() argument
916 err = unpack_uint16(buf, message_id); in common_pub_ack_decode()
921 remaining_len = buf->end - buf->cur; in common_pub_ack_decode()
926 err = unpack_uint8(buf, reason_code); in common_pub_ack_decode()
933 err = common_ack_properties_decode(buf, prop); in common_pub_ack_decode()
943 int publish_ack_decode(const struct mqtt_client *client, struct buf_ctx *buf, in publish_ack_decode() argument
956 return common_pub_ack_decode(buf, ¶m->message_id, reason_code, prop); in publish_ack_decode()
959 int publish_receive_decode(const struct mqtt_client *client, struct buf_ctx *buf, in publish_receive_decode() argument
972 return common_pub_ack_decode(buf, ¶m->message_id, reason_code, prop); in publish_receive_decode()
975 int publish_release_decode(const struct mqtt_client *client, struct buf_ctx *buf, in publish_release_decode() argument
988 return common_pub_ack_decode(buf, ¶m->message_id, reason_code, prop); in publish_release_decode()
991 int publish_complete_decode(const struct mqtt_client *client, struct buf_ctx *buf, in publish_complete_decode() argument
1004 return common_pub_ack_decode(buf, ¶m->message_id, reason_code, prop); in publish_complete_decode()
1008 static int suback_properties_decode(struct buf_ctx *buf, in suback_properties_decode() argument
1011 return common_ack_properties_decode(buf, ¶m->prop); in suback_properties_decode()
1014 static int suback_properties_decode(struct buf_ctx *buf, in suback_properties_decode() argument
1018 ARG_UNUSED(buf); in suback_properties_decode()
1024 int subscribe_ack_decode(const struct mqtt_client *client, struct buf_ctx *buf, in subscribe_ack_decode() argument
1029 err_code = unpack_uint16(buf, ¶m->message_id); in subscribe_ack_decode()
1035 err_code = suback_properties_decode(buf, param); in subscribe_ack_decode()
1041 return unpack_raw_data(buf->end - buf->cur, buf, ¶m->return_codes); in subscribe_ack_decode()
1045 static int unsuback_5_0_decode(struct buf_ctx *buf, in unsuback_5_0_decode() argument
1050 err = common_ack_properties_decode(buf, ¶m->prop); in unsuback_5_0_decode()
1055 return unpack_raw_data(buf->end - buf->cur, buf, ¶m->reason_codes); in unsuback_5_0_decode()
1058 static int unsuback_5_0_decode(struct buf_ctx *buf, in unsuback_5_0_decode() argument
1062 ARG_UNUSED(buf); in unsuback_5_0_decode()
1068 int unsubscribe_ack_decode(const struct mqtt_client *client, struct buf_ctx *buf, in unsubscribe_ack_decode() argument
1073 err = unpack_uint16(buf, ¶m->message_id); in unsubscribe_ack_decode()
1079 return unsuback_5_0_decode(buf, param); in unsubscribe_ack_decode()
1086 static int disconnect_properties_decode(struct buf_ctx *buf, in disconnect_properties_decode() argument
1112 return properties_decode(prop, ARRAY_SIZE(prop), buf); in disconnect_properties_decode()
1115 int disconnect_decode(const struct mqtt_client *client, struct buf_ctx *buf, in disconnect_decode() argument
1127 remaining_len = buf->end - buf->cur; in disconnect_decode()
1130 err = unpack_uint8(buf, &reason_code); in disconnect_decode()
1139 err = disconnect_properties_decode(buf, param); in disconnect_decode()
1148 static int auth_properties_decode(struct buf_ctx *buf, in auth_properties_decode() argument
1174 return properties_decode(prop, ARRAY_SIZE(prop), buf); in auth_properties_decode()
1177 int auth_decode(const struct mqtt_client *client, struct buf_ctx *buf, in auth_decode() argument
1188 remaining_len = buf->end - buf->cur; in auth_decode()
1191 err = unpack_uint8(buf, &reason_code); in auth_decode()
1200 err = auth_properties_decode(buf, param); in auth_decode()