tlv.h
Go to the documentation of this file.
#pragma once
#include <stdint.h>
#include <string.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/bit16gen.h>
#include <osmocom/core/bit32gen.h>
/* Terminology / wording
tag length value (in bits)
V - - 8
LV - 8 N * 8
TLV 8 8 N * 8
TL16V 8 16 N * 8
TLV16 8 8 N * 16
TvLV 8 8/16 N * 8
vTvLV 8/16 8/16 N * 8
T16LV 16 8 N * 8
*/
#define LV_GROSS_LEN(x) (x+1)
#define TLV_GROSS_LEN(x) (x+2)
#define TLV16_GROSS_LEN(x) ((2*x)+2)
#define TL16V_GROSS_LEN(x) (x+3)
#define L16TV_GROSS_LEN(x) (x+3)
#define T16LV_GROSS_LEN(x) (x+3)
#define TVLV_MAX_ONEBYTE 0x7f
static inline uint16_t TVLV_GROSS_LEN(uint16_t len)
{
if (len <= TVLV_MAX_ONEBYTE)
return TLV_GROSS_LEN(len);
else
return TL16V_GROSS_LEN(len);
}
static inline uint16_t VTVL_GAN_GROSS_LEN(uint16_t tag, uint16_t len)
{
uint16_t ret = 2;
if (tag > TVLV_MAX_ONEBYTE)
ret++;
if (len > TVLV_MAX_ONEBYTE)
ret++;
return ret;
}
static inline uint16_t VTVLV_GAN_GROSS_LEN(uint16_t tag, uint16_t len)
{
uint16_t ret;
if (len <= TVLV_MAX_ONEBYTE)
ret = TLV_GROSS_LEN(len);
else
ret = TL16V_GROSS_LEN(len);
if (tag > TVLV_MAX_ONEBYTE)
ret += 1;
return ret;
}
/* TLV generation */
static inline uint8_t *lv_put(uint8_t *buf, uint8_t len,
const uint8_t *val)
{
*buf++ = len;
memcpy(buf, val, len);
return buf + len;
}
static inline uint8_t *tlv_put(uint8_t *buf, uint8_t tag, uint8_t len,
const uint8_t *val)
{
*buf++ = tag;
*buf++ = len;
if (len) {
if (val)
memcpy(buf, val, len);
else
memset(buf, 0, len);
}
return buf + len;
}
static inline uint8_t *tlv16_put(uint8_t *buf, uint8_t tag, uint8_t len,
const uint16_t *val)
{
*buf++ = tag;
*buf++ = len;
memcpy(buf, val, len*2);
return buf + len*2;
}
static inline uint8_t *tl16v_put(uint8_t *buf, uint8_t tag, uint16_t len,
const uint8_t *val)
{
*buf++ = tag;
*buf++ = len >> 8;
*buf++ = len & 0xff;
memcpy(buf, val, len);
return buf + len*2;
}
static inline uint8_t *t16lv_put(uint8_t *buf, uint16_t tag, uint8_t len,
const uint8_t *val)
{
*buf++ = tag >> 8;
*buf++ = tag & 0xff;
*buf++ = len;
memcpy(buf, val, len);
return buf + len + 2;
}
static inline uint8_t *tvlv_put(uint8_t *buf, uint8_t tag, uint16_t len,
const uint8_t *val)
{
uint8_t *ret;
if (len <= TVLV_MAX_ONEBYTE) {
ret = tlv_put(buf, tag, len, val);
buf[1] |= 0x80;
} else
ret = tl16v_put(buf, tag, len, val);
return ret;
}
static inline uint8_t *vt_gan_put(uint8_t *buf, uint16_t tag)
{
if (tag > TVLV_MAX_ONEBYTE) {
/* two-byte TAG */
*buf++ = 0x80 | (tag >> 8);
*buf++ = (tag & 0xff);
} else
*buf++ = tag;
return buf;
}
/* put (append) vTvL (GAN) field (tag + length)*/
static inline uint8_t *vtvl_gan_put(uint8_t *buf, uint16_t tag, uint16_t len)
{
uint8_t *ret;
ret = vt_gan_put(buf, tag);
return vt_gan_put(ret, len);
}
/* put (append) vTvLV (GAN) field (tag + length + val) */
static inline uint8_t *vtvlv_gan_put(uint8_t *buf, uint16_t tag, uint16_t len,
const uint8_t *val)
{
uint8_t *ret;
ret = vtvl_gan_put(buf, tag, len );
memcpy(ret, val, len);
ret = buf + len;
return ret;
}
static inline uint8_t *msgb_tlv16_put(struct msgb *msg, uint8_t tag, uint8_t len, const uint16_t *val)
{
uint8_t *buf = msgb_put(msg, TLV16_GROSS_LEN(len));
return tlv16_put(buf, tag, len, val);
}
static inline uint8_t *msgb_tl16v_put(struct msgb *msg, uint8_t tag, uint16_t len,
const uint8_t *val)
{
uint8_t *buf = msgb_put(msg, TL16V_GROSS_LEN(len));
return tl16v_put(buf, tag, len, val);
}
static inline uint8_t *msgb_t16lv_put(struct msgb *msg, uint16_t tag, uint8_t len, const uint8_t *val)
{
uint8_t *buf = msgb_put(msg, T16LV_GROSS_LEN(len));
return t16lv_put(buf, tag, len, val);
}
static inline uint8_t *msgb_tvlv_put(struct msgb *msg, uint8_t tag, uint16_t len,
const uint8_t *val)
{
uint8_t *buf = msgb_put(msg, TVLV_GROSS_LEN(len));
return tvlv_put(buf, tag, len, val);
}
static inline uint8_t *msgb_vtvlv_gan_put(struct msgb *msg, uint16_t tag,
uint16_t len, const uint8_t *val)
{
uint8_t *buf = msgb_put(msg, VTVLV_GAN_GROSS_LEN(tag, len));
return vtvlv_gan_put(buf, tag, len, val);
}
static inline uint8_t *msgb_l16tv_put(struct msgb *msg, uint16_t len, uint8_t tag,
const uint8_t *val)
{
uint8_t *buf = msgb_put(msg, L16TV_GROSS_LEN(len));
*buf++ = len >> 8;
*buf++ = len & 0xff;
*buf++ = tag;
memcpy(buf, val, len);
return buf + len;
}
static inline uint8_t *v_put(uint8_t *buf, uint8_t val)
{
*buf++ = val;
return buf;
}
static inline uint8_t *tv_put(uint8_t *buf, uint8_t tag,
uint8_t val)
{
*buf++ = tag;
*buf++ = val;
return buf;
}
static inline uint8_t *tv_fixed_put(uint8_t *buf, uint8_t tag,
unsigned int len, const uint8_t *val)
{
*buf++ = tag;
memcpy(buf, val, len);
return buf + len;
}
static inline uint8_t *tv16_put(uint8_t *buf, uint8_t tag,
uint16_t val)
{
*buf++ = tag;
*buf++ = val >> 8;
*buf++ = val & 0xff;
return buf;
}
static inline uint8_t *msgb_lv_put(struct msgb *msg, uint8_t len, const uint8_t *val)
{
uint8_t *buf = msgb_put(msg, LV_GROSS_LEN(len));
return lv_put(buf, len, val);
}
static inline uint8_t *msgb_tlv_put(struct msgb *msg, uint8_t tag, uint8_t len, const uint8_t *val)
{
uint8_t *buf = msgb_put(msg, TLV_GROSS_LEN(len));
return tlv_put(buf, tag, len, val);
}
static inline uint8_t *msgb_tv_put(struct msgb *msg, uint8_t tag, uint8_t val)
{
uint8_t *buf = msgb_put(msg, 2);
return tv_put(buf, tag, val);
}
static inline uint8_t *msgb_tv_fixed_put(struct msgb *msg, uint8_t tag,
unsigned int len, const uint8_t *val)
{
uint8_t *buf = msgb_put(msg, 1+len);
return tv_fixed_put(buf, tag, len, val);
}
static inline uint8_t *msgb_v_put(struct msgb *msg, uint8_t val)
{
uint8_t *buf = msgb_put(msg, 1);
return v_put(buf, val);
}
static inline uint8_t *msgb_tv16_put(struct msgb *msg, uint8_t tag, uint16_t val)
{
uint8_t *buf = msgb_put(msg, 3);
return tv16_put(buf, tag, val);
}
static inline uint8_t *msgb_tlv_push(struct msgb *msg, uint8_t tag, uint8_t len, const uint8_t *val)
{
uint8_t *buf = msgb_push(msg, TLV_GROSS_LEN(len));
tlv_put(buf, tag, len, val);
return buf;
}
static inline uint8_t *msgb_tv_push(struct msgb *msg, uint8_t tag, uint8_t val)
{
uint8_t *buf = msgb_push(msg, 2);
tv_put(buf, tag, val);
return buf;
}
static inline uint8_t *msgb_tv16_push(struct msgb *msg, uint8_t tag, uint16_t val)
{
uint8_t *buf = msgb_push(msg, 3);
tv16_put(buf, tag, val);
return buf;
}
static inline uint8_t *msgb_tvlv_push(struct msgb *msg, uint8_t tag, uint16_t len,
const uint8_t *val)
{
uint8_t *buf = msgb_push(msg, TVLV_GROSS_LEN(len));
tvlv_put(buf, tag, len, val);
return buf;
}
/* push (prepend) a vTvL header to a \ref msgb
*/
static inline uint8_t *msgb_vtvl_gan_push(struct msgb *msg, uint16_t tag,
uint16_t len)
{
uint8_t *buf = msgb_push(msg, VTVL_GAN_GROSS_LEN(tag, len));
vtvl_gan_put(buf, tag, len);
return buf;
}
static inline uint8_t *msgb_vtvlv_gan_push(struct msgb *msg, uint16_t tag,
uint16_t len, const uint8_t *val)
{
uint8_t *buf = msgb_push(msg, VTVLV_GAN_GROSS_LEN(tag, len));
vtvlv_gan_put(buf, tag, len, val);
return buf;
}
/* TLV parsing */
struct tlv_p_entry {
uint16_t len;
const uint8_t *val;
};
enum tlv_type {
TLV_TYPE_NONE,
TLV_TYPE_FIXED,
TLV_TYPE_T,
TLV_TYPE_TV,
TLV_TYPE_TLV,
TLV_TYPE_TL16V,
TLV_TYPE_TvLV,
TLV_TYPE_SINGLE_TV,
TLV_TYPE_vTvLV_GAN,
};
struct tlv_def {
enum tlv_type type;
uint8_t fixed_len;
};
struct tlv_definition {
struct tlv_def def[256];
};
struct tlv_parsed {
struct tlv_p_entry lv[256];
};
extern struct tlv_definition tvlv_att_def;
extern struct tlv_definition vtvlv_gan_att_def;
int tlv_parse_one(uint8_t *o_tag, uint16_t *o_len, const uint8_t **o_val,
const struct tlv_definition *def,
const uint8_t *buf, int buf_len);
int tlv_parse(struct tlv_parsed *dec, const struct tlv_definition *def,
const uint8_t *buf, int buf_len, uint8_t lv_tag, uint8_t lv_tag2);
int tlv_parse2(struct tlv_parsed *dec, int dec_multiples,
const struct tlv_definition *def, const uint8_t *buf, int buf_len,
uint8_t lv_tag, uint8_t lv_tag2);
/* take a master (src) tlv def and fill up all empty slots in 'dst' */
void tlv_def_patch(struct tlv_definition *dst, const struct tlv_definition *src);
#define TLVP_PRESENT(x, y) ((x)->lv[y].val)
#define TLVP_LEN(x, y) (x)->lv[y].len
#define TLVP_VAL(x, y) (x)->lv[y].val
#define TLVP_PRES_LEN(tp, tag, min_len) \
(TLVP_PRESENT(tp, tag) && TLVP_LEN(tp, tag) >= min_len)
#define TLVP_GET(_tp, tag) (TLVP_PRESENT(_tp, tag)? &(_tp)->lv[tag] : NULL)
#define TLVP_GET_MINLEN(_tp, tag, min_len) \
(TLVP_PRES_LEN(_tp, tag, min_len)? &(_tp)->lv[tag] : NULL)
#define TLVP_VAL_MINLEN(_tp, tag, min_len) \
(TLVP_PRES_LEN(_tp, tag, min_len)? (_tp)->lv[tag].val : NULL)
static inline uint16_t tlvp_val16_unal(const struct tlv_parsed *tp, int pos)
{
uint16_t res;
memcpy(&res, TLVP_VAL(tp, pos), sizeof(res));
return res;
}
static inline uint32_t tlvp_val32_unal(const struct tlv_parsed *tp, int pos)
{
uint32_t res;
memcpy(&res, TLVP_VAL(tp, pos), sizeof(res));
return res;
}
static inline uint16_t tlvp_val16be(const struct tlv_parsed *tp, int pos)
{
return osmo_load16be(TLVP_VAL(tp, pos));
}
static inline uint32_t tlvp_val32be(const struct tlv_parsed *tp, int pos)
{
return osmo_load32be(TLVP_VAL(tp, pos));
}
struct tlv_parsed *osmo_tlvp_copy(const struct tlv_parsed *tp_orig, void *ctx);
int osmo_tlvp_merge(struct tlv_parsed *dst, const struct tlv_parsed *src);
int osmo_shift_v_fixed(uint8_t **data, size_t *data_len,
size_t len, uint8_t **value);
int osmo_match_shift_tv_fixed(uint8_t **data, size_t *data_len,
uint8_t tag, size_t len, uint8_t **value);
int osmo_shift_tlv(uint8_t **data, size_t *data_len,
uint8_t *tag, uint8_t **value, size_t *value_len);
int osmo_match_shift_tlv(uint8_t **data, size_t *data_len,
uint8_t tag, uint8_t **value, size_t *value_len);
int osmo_shift_lv(uint8_t **data, size_t *data_len,
uint8_t **value, size_t *value_len);
tlv_parse_one
int tlv_parse_one(uint8_t *o_tag, uint16_t *o_len, const uint8_t **o_val, const struct tlv_definition *def, const uint8_t *buf, int buf_len)
Parse a single TLV encoded IE.
Definition: tlv_parser.c:132
msgb_l16tv_put
static uint8_t * msgb_l16tv_put(struct msgb *msg, uint16_t len, uint8_t tag, const uint8_t *val)
put (append) a L16TV field to msgb
Definition: tlv.h:235
len
uint8_t len
Definition: gsm_04_11.h:2
data
uint8_t data[0]
message payload data
Definition: gsm_03_41.h:34
tlvp_val16be
static uint16_t tlvp_val16be(const struct tlv_parsed *tp, int pos)
Retrieve (possibly unaligned) TLV element and convert to host byte order.
Definition: tlv.h:509
osmo_tlvp_copy
struct tlv_parsed * osmo_tlvp_copy(const struct tlv_parsed *tp_orig, void *ctx)
Copy tlv_parsed using given talloc context.
Definition: tlv_parser.c:69
tlv_p_entry::val
const uint8_t * val
pointer to value
Definition: tlv.h:396
osmo_tlvp_merge
int osmo_tlvp_merge(struct tlv_parsed *dst, const struct tlv_parsed *src)
Merge all tlv_parsed attributes of 'src' into 'dst'.
Definition: tlv_parser.c:104
tlv_def_patch
void tlv_def_patch(struct tlv_definition *dst, const struct tlv_definition *src)
take a master (src) tlvdev and fill up all empty slots in 'dst'
Definition: tlv_parser.c:340
TLV16_GROSS_LEN
#define TLV16_GROSS_LEN(x)
gross length of a TLV16 type field
Definition: tlv.h:32
tlv_parse
int tlv_parse(struct tlv_parsed *dec, const struct tlv_definition *def, const uint8_t *buf, int buf_len, uint8_t lv_tag, uint8_t lv_tag2)
Parse an entire buffer of TLV encoded Information Elements.
Definition: tlv_parser.c:237
tvlv_att_def
struct tlv_definition tvlv_att_def
Definition: tlv_parser.c:48
osmo_shift_tlv
int osmo_shift_tlv(uint8_t **data, size_t *data_len, uint8_t *tag, uint8_t **value, size_t *value_len)
Extract TLV and advance data pointer + subtract length.
Definition: tlv_parser.c:463
TLV_TYPE_FIXED
@ TLV_TYPE_FIXED
fixed-length value-only
Definition: tlv.h:402
tlv_p_entry::len
uint16_t len
length
Definition: tlv.h:395
msgb_v_put
static uint8_t * msgb_v_put(struct msgb *msg, uint8_t val)
put (append) a V field to a msgb
Definition: tlv.h:321
msgb_tv16_put
static uint8_t * msgb_tv16_put(struct msgb *msg, uint8_t tag, uint16_t val)
put (append) a TV16 field to a msgb
Definition: tlv.h:329
LV_GROSS_LEN
#define LV_GROSS_LEN(x)
gross length of a LV type field
Definition: tlv.h:28
TLV_TYPE_T
@ TLV_TYPE_T
tag-only
Definition: tlv.h:403
tlv_parse2
int tlv_parse2(struct tlv_parsed *dec, int dec_multiples, const struct tlv_definition *def, const uint8_t *buf, int buf_len, uint8_t lv_tag, uint8_t lv_tag2)
Like tlv_parse(), but capable of decoding multiple occurences of the same IE.
Definition: tlv_parser.c:260
msgb_vtvl_gan_push
static uint8_t * msgb_vtvl_gan_push(struct msgb *msg, uint16_t tag, uint16_t len)
Definition: tlv.h:374
vt_gan_put
static uint8_t * vt_gan_put(uint8_t *buf, uint16_t tag)
put (append) a variable-length tag or variable-length length *
Definition: tlv.h:162
VTVLV_GAN_GROSS_LEN
static uint16_t VTVLV_GAN_GROSS_LEN(uint16_t tag, uint16_t len)
gross length of vTvLV (tag+len+val)
Definition: tlv.h:67
msgb_tv16_push
static uint8_t * msgb_tv16_push(struct msgb *msg, uint8_t tag, uint16_t val)
push (prepend) a TV16 field to a msgb
Definition: tlv.h:355
TL16V_GROSS_LEN
#define TL16V_GROSS_LEN(x)
gross length of a TL16V type field
Definition: tlv.h:34
msgb_lv_put
static uint8_t * msgb_lv_put(struct msgb *msg, uint8_t len, const uint8_t *val)
put (append) a LV field to a msgb
Definition: tlv.h:288
tlv_p_entry
Entry in a TLV parser array.
Definition: tlv.h:394
tlv_parsed::lv
struct tlv_p_entry lv[256]
Definition: tlv.h:425
tlvp_val32be
static uint32_t tlvp_val32be(const struct tlv_parsed *tp, int pos)
Retrieve (possibly unaligned) TLV element and convert to host byte order.
Definition: tlv.h:519
TLV_TYPE_TLV
@ TLV_TYPE_TLV
tag-length-value
Definition: tlv.h:405
tv_fixed_put
static uint8_t * tv_fixed_put(uint8_t *buf, uint8_t tag, unsigned int len, const uint8_t *val)
put (append) a TVfixed field
Definition: tlv.h:264
TVLV_GROSS_LEN
static uint16_t TVLV_GROSS_LEN(uint16_t len)
gross length of a TVLV type field
Definition: tlv.h:44
TLV_TYPE_TvLV
@ TLV_TYPE_TvLV
tag, variable length, value
Definition: tlv.h:407
tlvp_val16_unal
static uint16_t tlvp_val16_unal(const struct tlv_parsed *tp, int pos)
Align given TLV element with 16 bit value to an even address.
Definition: tlv.h:485
tlv_definition
Definition of All 256 IE / TLV.
Definition: tlv.h:419
t16lv_put
static uint8_t * t16lv_put(uint8_t *buf, uint16_t tag, uint8_t len, const uint8_t *val)
put (append) a TL16V field
Definition: tlv.h:136
tlv_put
static uint8_t * tlv_put(uint8_t *buf, uint8_t tag, uint8_t len, const uint8_t *val)
Append a TLV field, a Tag-Length-Value field.
Definition: tlv.h:100
tlv_def::type
enum tlv_type type
TLV type.
Definition: tlv.h:414
msgb_vtvlv_gan_put
static uint8_t * msgb_vtvlv_gan_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *val)
put (append) a vTvLV field to msgb
Definition: tlv.h:227
v_put
static uint8_t * v_put(uint8_t *buf, uint8_t val)
put (append) a V field
Definition: tlv.h:248
tlv_def
Definition of a single IE (Information Element)
Definition: tlv.h:413
VTVL_GAN_GROSS_LEN
static uint16_t VTVL_GAN_GROSS_LEN(uint16_t tag, uint16_t len)
gross length of vTvL header (tag+len)
Definition: tlv.h:53
tlv_type
tlv_type
TLV type.
Definition: tlv.h:400
TLV_TYPE_TL16V
@ TLV_TYPE_TL16V
tag, 16 bit length, value
Definition: tlv.h:406
msgb_tlv16_put
static uint8_t * msgb_tlv16_put(struct msgb *msg, uint8_t tag, uint8_t len, const uint16_t *val)
put (append) a TLV16 field to msgb
Definition: tlv.h:198
L16TV_GROSS_LEN
#define L16TV_GROSS_LEN(x)
gross length of a L16TV type field
Definition: tlv.h:36
tlv_definition::def
struct tlv_def def[256]
Definition: tlv.h:420
TVLV_MAX_ONEBYTE
#define TVLV_MAX_ONEBYTE
maximum length of TLV of one byte length
Definition: tlv.h:41
tlvp_val32_unal
static uint32_t tlvp_val32_unal(const struct tlv_parsed *tp, int pos)
Align given TLV element with 32 bit value to an address that is a multiple of 4.
Definition: tlv.h:497
osmo_match_shift_tv_fixed
int osmo_match_shift_tv_fixed(uint8_t **data, size_t *data_len, uint8_t tag, size_t len, uint8_t **value)
Match tag, check length and assign value pointer.
Definition: tlv_parser.c:397
msgb_tlv_put
static uint8_t * msgb_tlv_put(struct msgb *msg, uint8_t tag, uint8_t len, const uint8_t *val)
put (append) a TLV field to a msgb
Definition: tlv.h:296
TLV_TYPE_SINGLE_TV
@ TLV_TYPE_SINGLE_TV
tag and value (both 4 bit) in 1 byte
Definition: tlv.h:408
vtvl_gan_put
static uint8_t * vtvl_gan_put(uint8_t *buf, uint16_t tag, uint16_t len)
Definition: tlv.h:175
msgb_vtvlv_gan_push
static uint8_t * msgb_vtvlv_gan_push(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *val)
Definition: tlv.h:383
msgb_tl16v_put
static uint8_t * msgb_tl16v_put(struct msgb *msg, uint8_t tag, uint16_t len, const uint8_t *val)
put (append) a TL16V field to msgb
Definition: tlv.h:205
tlv_def::fixed_len
uint8_t fixed_len
length in case of TLV_TYPE_FIXED
Definition: tlv.h:415
msgb_tlv_push
static uint8_t * msgb_tlv_push(struct msgb *msg, uint8_t tag, uint8_t len, const uint8_t *val)
push (prepend) a TLV field to a msgb
Definition: tlv.h:337
tl16v_put
static uint8_t * tl16v_put(uint8_t *buf, uint8_t tag, uint16_t len, const uint8_t *val)
put (append) a TL16V field
Definition: tlv.h:125
tlv16_put
static uint8_t * tlv16_put(uint8_t *buf, uint8_t tag, uint8_t len, const uint16_t *val)
put (append) a TLV16 field
Definition: tlv.h:115
tv16_put
static uint8_t * tv16_put(uint8_t *buf, uint8_t tag, uint16_t val)
put (append) a TV16 field
Definition: tlv.h:277
TLV_TYPE_NONE
@ TLV_TYPE_NONE
no type
Definition: tlv.h:401
osmo_shift_v_fixed
int osmo_shift_v_fixed(uint8_t **data, size_t *data_len, size_t len, uint8_t **value)
Advance the data pointer, subtract length and assign value pointer.
Definition: tlv_parser.c:369
vtvlv_gan_att_def
struct tlv_definition vtvlv_gan_att_def
Definition: tlv_parser.c:49
msgb_tvlv_put
static uint8_t * msgb_tvlv_put(struct msgb *msg, uint8_t tag, uint16_t len, const uint8_t *val)
put (append) a TvLV field to msgb
Definition: tlv.h:219
msgb_tv_push
static uint8_t * msgb_tv_push(struct msgb *msg, uint8_t tag, uint8_t val)
push (prepend) a TV field to a msgb
Definition: tlv.h:346
T16LV_GROSS_LEN
#define T16LV_GROSS_LEN(x)
gross length of a T16LV type field
Definition: tlv.h:38
osmo_match_shift_tlv
int osmo_match_shift_tlv(uint8_t **data, size_t *data_len, uint8_t tag, uint8_t **value, size_t *value_len)
Verify TLV header and advance data / subtract length.
Definition: tlv_parser.c:435
lv_put
static uint8_t * lv_put(uint8_t *buf, uint8_t len, const uint8_t *val)
put (append) a LV field
Definition: tlv.h:85
osmo_shift_lv
int osmo_shift_lv(uint8_t **data, size_t *data_len, uint8_t **value, size_t *value_len)
Extract LV and advance data pointer + subtract length.
Definition: tlv_parser.c:503
tv_put
static uint8_t * tv_put(uint8_t *buf, uint8_t tag, uint8_t val)
put (append) a TV field
Definition: tlv.h:255
msgb_tv_fixed_put
static uint8_t * msgb_tv_fixed_put(struct msgb *msg, uint8_t tag, unsigned int len, const uint8_t *val)
put (append) a TVfixed field to a msgb
Definition: tlv.h:312
tvlv_put
static uint8_t * tvlv_put(uint8_t *buf, uint8_t tag, uint16_t len, const uint8_t *val)
put (append) a TvLV field
Definition: tlv.h:147
vtvlv_gan_put
static uint8_t * vtvlv_gan_put(uint8_t *buf, uint16_t tag, uint16_t len, const uint8_t *val)
Definition: tlv.h:184
msgb_t16lv_put
static uint8_t * msgb_t16lv_put(struct msgb *msg, uint16_t tag, uint8_t len, const uint8_t *val)
Definition: tlv.h:212
tlv_parsed
result of the TLV parser
Definition: tlv.h:424
TLV_GROSS_LEN
#define TLV_GROSS_LEN(x)
gross length of a TLV type field
Definition: tlv.h:30
msgb_tv_put
static uint8_t * msgb_tv_put(struct msgb *msg, uint8_t tag, uint8_t val)
put (append) a TV field to a msgb
Definition: tlv.h:304
msgb_tvlv_push
static uint8_t * msgb_tvlv_push(struct msgb *msg, uint8_t tag, uint16_t len, const uint8_t *val)
push (prepend) a TvLV field to a msgb
Definition: tlv.h:364
TLV_TYPE_vTvLV_GAN
@ TLV_TYPE_vTvLV_GAN
variable-length tag, variable-length length
Definition: tlv.h:409
TLV_TYPE_TV
@ TLV_TYPE_TV
tag-value (8bit)
Definition: tlv.h:404
TLVP_VAL
#define TLVP_VAL(x, y)
Definition: tlv.h:444