Lines Matching refs:tlv
88 static uint8_t get_len_type(const struct oma_tlv *tlv) in get_len_type() argument
90 if (tlv->length < 8) { in get_len_type()
92 } else if (tlv->length < 0x100) { in get_len_type()
94 } else if (tlv->length < 0x10000) { in get_len_type()
113 static void tlv_setup(struct oma_tlv *tlv, uint8_t type, uint16_t id, in tlv_setup() argument
116 if (tlv) { in tlv_setup()
117 tlv->type = type; in tlv_setup()
118 tlv->id = id; in tlv_setup()
119 tlv->length = buflen; in tlv_setup()
152 static int oma_tlv_put(const struct oma_tlv *tlv, in oma_tlv_put() argument
161 len_type = get_len_type(tlv); in oma_tlv_put()
164 tmp = (tlv->type << 6) | in oma_tlv_put()
165 (tlv->id > 255 ? (1 << 5) : 0) | in oma_tlv_put()
167 (len_type == 0U ? tlv->length : 0); in oma_tlv_put()
177 if (tlv->id > 255) { in oma_tlv_put()
178 ret = oma_tlv_put_u8(out, (tlv->id >> 8) & 0xff, insert); in oma_tlv_put()
186 ret = oma_tlv_put_u8(out, tlv->id & 0xff, insert); in oma_tlv_put()
196 (tlv->length >> (i * 8)) & 0xff, in oma_tlv_put()
207 if (value != NULL && tlv->length > 0 && !insert) { in oma_tlv_put()
209 value, tlv->length); in oma_tlv_put()
215 return pos + tlv->length; in oma_tlv_put()
218 static int oma_tlv_get(struct oma_tlv *tlv, struct lwm2m_input_context *in, in oma_tlv_get() argument
234 tlv->type = (buf[0] >> 6) & 3; in oma_tlv_get()
243 tlv->id = buf[1]; in oma_tlv_get()
253 tlv->id = (tlv->id << 8) + buf[1]; in oma_tlv_get()
275 tlv->length = tlv_len; in oma_tlv_get()
310 struct oma_tlv tlv; in put_end_tlv() local
326 tlv_setup(&tlv, tlv_type, tlv_id, len); in put_end_tlv()
327 len = oma_tlv_put(&tlv, out, NULL, true) - tlv.length; in put_end_tlv()
408 struct oma_tlv tlv; in put_s8() local
415 tlv_setup(&tlv, tlv_calc_type(fd->writer_flags), in put_s8()
418 len = oma_tlv_put(&tlv, out, (uint8_t *)&value, false); in put_s8()
427 struct oma_tlv tlv; in put_s16() local
440 tlv_setup(&tlv, tlv_calc_type(fd->writer_flags), in put_s16()
443 len = oma_tlv_put(&tlv, out, (uint8_t *)&net_value, false); in put_s16()
452 struct oma_tlv tlv; in put_s32() local
465 tlv_setup(&tlv, tlv_calc_type(fd->writer_flags), in put_s32()
468 len = oma_tlv_put(&tlv, out, (uint8_t *)&net_value, false); in put_s32()
478 struct oma_tlv tlv; in put_s64() local
491 tlv_setup(&tlv, tlv_calc_type(fd->writer_flags), in put_s64()
494 len = oma_tlv_put(&tlv, out, (uint8_t *)&net_value, false); in put_s64()
509 struct oma_tlv tlv; in put_string() local
516 tlv_setup(&tlv, tlv_calc_type(fd->writer_flags), in put_string()
518 len = oma_tlv_put(&tlv, out, (uint8_t *)buf, false); in put_string()
527 struct oma_tlv tlv; in put_float() local
542 tlv_setup(&tlv, tlv_calc_type(fd->writer_flags), in put_float()
544 len = oma_tlv_put(&tlv, out, b64, false); in put_float()
566 struct oma_tlv tlv; in put_objlnk() local
575 tlv_setup(&tlv, tlv_calc_type(fd->writer_flags), in put_objlnk()
578 return oma_tlv_put(&tlv, out, (uint8_t *)&net_value, false); in put_objlnk()
584 struct oma_tlv tlv; in get_number() local
589 size = oma_tlv_get(&tlv, in, false); in get_number()
594 if (tlv.length > max_len) { in get_number()
595 LOG_ERR("invalid length: %u", tlv.length); in get_number()
599 ret = buf_read((uint8_t *)&temp, tlv.length, in get_number()
605 switch (tlv.length) { in get_number()
619 LOG_ERR("invalid length: %u", tlv.length); in get_number()
660 struct oma_tlv tlv; in get_string() local
664 size = oma_tlv_get(&tlv, in, false); in get_string()
669 if (buflen <= tlv.length) { in get_string()
673 ret = buf_read(buf, tlv.length, CPKT_BUF_READ(in->in_cpkt), in get_string()
679 buf[tlv.length] = '\0'; in get_string()
687 struct oma_tlv tlv; in get_float() local
692 size = oma_tlv_get(&tlv, in, false); in get_float()
697 if (tlv.length != 4U && tlv.length != 8U) { in get_float()
698 LOG_ERR("Invalid float length: %d", tlv.length); in get_float()
703 ret = buf_read(buf, tlv.length, CPKT_BUF_READ(in->in_cpkt), in get_float()
709 if (tlv.length == 4U) { in get_float()
717 tlv.length == 4U ? "32" : "64", ret); in get_float()
744 struct oma_tlv tlv; in get_opaque() local
749 size = oma_tlv_get(&tlv, in, false); in get_opaque()
754 opaque->len = tlv.length; in get_opaque()
755 opaque->remaining = tlv.length; in get_opaque()
821 struct oma_tlv tlv; in do_write_op_tlv_dummy_read() local
824 oma_tlv_get(&tlv, &msg->in, false); in do_write_op_tlv_dummy_read()
825 while (tlv.length--) { in do_write_op_tlv_dummy_read()
883 static int write_tlv_resource(struct lwm2m_message *msg, struct oma_tlv *tlv) in write_tlv_resource() argument
888 msg->in.block_ctx->path.res_id = tlv->id; in write_tlv_resource()
891 msg->path.res_id = tlv->id; in write_tlv_resource()
911 static int write_tlv_resource_instance(struct lwm2m_message *msg, struct oma_tlv *tlv) in write_tlv_resource_instance() argument
916 msg->in.block_ctx->path.res_inst_id = tlv->id; in write_tlv_resource_instance()
919 msg->path.res_inst_id = tlv->id; in write_tlv_resource_instance()
980 struct oma_tlv tlv; in do_write_op_tlv() local
1004 len = oma_tlv_get(&tlv, &msg->in, true); in do_write_op_tlv()
1009 if (tlv.type == OMA_TLV_TYPE_OBJECT_INSTANCE) { in do_write_op_tlv()
1014 oma_tlv_get(&tlv, &msg->in, false); in do_write_op_tlv()
1015 msg->path.obj_inst_id = tlv.id; in do_write_op_tlv()
1016 if (tlv.length == 0U) { in do_write_op_tlv()
1031 while (pos < tlv.length && in do_write_op_tlv()
1051 } else if (tlv.type == OMA_TLV_TYPE_RESOURCE) { in do_write_op_tlv()
1055 ret = write_tlv_resource(msg, &tlv); in do_write_op_tlv()
1059 } else if (tlv.type == OMA_TLV_TYPE_MULTI_RESOURCE) { in do_write_op_tlv()
1063 oma_tlv_get(&tlv, &msg->in, false); in do_write_op_tlv()
1064 ret = lwm2m_multi_resource_tlv_parse(msg, &tlv); in do_write_op_tlv()
1069 } else if (tlv.type == OMA_TLV_TYPE_RESOURCE_INSTANCE) { in do_write_op_tlv()
1073 ret = write_tlv_resource_instance(msg, &tlv); in do_write_op_tlv()