--- src/shared/util.c | 11 ++++++++++- src/shared/util.h | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/shared/util.c b/src/shared/util.c index c0c2c4a17f12..74d43671c108 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -4,7 +4,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * * */ @@ -218,6 +218,15 @@ bool util_ltv_foreach(const uint8_t *data, uint8_t len, uint8_t *type, return true; } +/* Helper to add l,t,v data in an iovec struct */ +void util_ltv_push(struct iovec *output, uint8_t l, uint8_t t, void *v) +{ + output->iov_base = realloc(output->iov_base, output->iov_len + l + 2); + util_iov_push_u8(output, l + 1); + util_iov_push_u8(output, t); + util_iov_push_mem(output, l, v); +} + /* Helper to print debug information of LTV entries */ bool util_debug_ltv(const uint8_t *data, uint8_t len, const struct util_ltv_debugger *debugger, size_t num, diff --git a/src/shared/util.h b/src/shared/util.h index 6322b13d612a..accacc79ee8b 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -4,7 +4,7 @@ * BlueZ - Bluetooth protocol stack for Linux * * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. - * Copyright 2023 NXP + * Copyright 2023-2024 NXP * * */ @@ -134,6 +134,8 @@ struct util_ltv_debugger { util_debug_func_t func, void *user_data); }; +void util_ltv_push(struct iovec *output, uint8_t l, uint8_t t, void *v); + bool util_debug_ltv(const uint8_t *data, uint8_t len, const struct util_ltv_debugger *debugger, size_t num, util_debug_func_t function, void *user_data); -- 2.40.1