Loading...
Searching...
No Matches
TLV parser

Osmocom TLV Parser More...

## Files

file | tlv.h
file | tlv_parser.c

## Data Structures

struct | tlv_p_entry
| Entry in a TLV parser array. More...
struct | tlv_def
| Definition of a single IE (Information Element). More...
struct | tlv_definition
| Definition of All 256 IE / TLV. More...
struct | tlv_parsed
| result of the TLV parser More...
struct | osmo_tlv_prot_msg_def
struct | osmo_tlv_prot_ie_def
struct | osmo_tlv_prot_def
| Osmocom TLV protocol definition. More...

## Macros

#define | LV_GROSS_LEN(x)
| gross length of a LV type field
#define | TLV_GROSS_LEN(x)
| gross length of a TLV type field
#define | TLV16_GROSS_LEN(x)
| gross length of a TLV16 type field
#define | TL16V_GROSS_LEN(x)
| gross length of a TL16V type field
#define | L16TV_GROSS_LEN(x)
| gross length of a L16TV type field
#define | T16LV_GROSS_LEN(x)
| gross length of a T16LV type field
#define | TVLV_MAX_ONEBYTE 0x7f
| maximum length of TLV of one byte length
#define | TLVP_PRESENT(x, y)
#define | TLVP_LEN(x, y)
#define | TLVP_VAL(x, y)
#define | TLVP_PRES_LEN(tp, tag, min_len)
#define | TLVP_GET(_tp, tag)
| Return pointer to a TLV element if it is present.
#define | TLVP_GET_MINLEN(_tp, tag, min_len)
| Like TLVP_GET(), but enforcing a minimum val length.
#define | TLVP_VAL_MINLEN(_tp, tag, min_len)
| Like TLVP_VAL(), but enforcing a minimum val length.
#define | MSG_DEF(name, mand_ies, flags)

## Enumerations

enum | osmo_tlv_parser_error { OSMO_TLVP_ERR_OFS_BEYOND_BUFFER = -1 , OSMO_TLVP_ERR_OFS_LEN_BEYOND_BUFFER = -2 , OSMO_TLVP_ERR_UNKNOWN_TLV_TYPE = -3 , OSMO_TLVP_ERR_MAND_IE_MISSING = -50 , OSMO_TLVP_ERR_IE_TOO_SHORT = -51 }
| error return codes of various TLV parser functions More...
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 }
| TLV type. More...

## Functions

static uint16_t | TVLV_GROSS_LEN (uint16_t len)
| gross length of a TVLV type field
static uint16_t | VTVL_GAN_GROSS_LEN (uint16_t tag, uint16_t len)
| gross length of vTvL header (tag+len)
static uint16_t | VTVLV_GAN_GROSS_LEN (uint16_t tag, uint16_t len)
| gross length of vTvLV (tag+len+val)
static uint8_t * | lv_put (uint8_t *buf, uint8_t len, const uint8_t *val)
| put (append) a LV field
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.
static uint8_t * | tl_put (uint8_t *buf, uint8_t tag, uint8_t len)
| put (append) a TL field (a TLV field but omitting the value part).
static uint8_t * | tlv16_put (uint8_t *buf, uint8_t tag, uint8_t len, const uint16_t *val)
| put (append) a TLV16 field
static uint8_t * | tl16v_put (uint8_t *buf, uint8_t tag, uint16_t len, const uint8_t *val)
| put (append) a TL16V field
static uint8_t * | tl16_put (uint8_t *buf, uint8_t tag, uint16_t len)
| put (append) a TL16 field.
static uint8_t * | t16lv_put (uint8_t *buf, uint16_t tag, uint8_t len, const uint8_t *val)
| put (append) a TL16V field
static uint8_t * | tvlv_put (uint8_t *buf, uint8_t tag, uint16_t len, const uint8_t *val)
| put (append) a TvLV field
static uint8_t * | tvl_put (uint8_t *buf, uint8_t tag, uint16_t len)
| put (append) a TvL field (a TvLV with variable-size length, where the value part's length is already known, but will be put() later).
static uint8_t * | vt_gan_put (uint8_t *buf, uint16_t tag)
| put (append) a variable-length tag or variable-length length *
static uint8_t * | vtvl_gan_put (uint8_t *buf, uint16_t tag, uint16_t len)
static uint8_t * | vtvlv_gan_put (uint8_t *buf, uint16_t tag, uint16_t len, const uint8_t *val)
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 Message buffers
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 Message buffers
static uint8_t * | msgb_t16lv_put (struct msgb *msg, uint16_t tag, uint8_t len, const uint8_t *val)
static uint8_t * | msgb_tvl_put (struct msgb *msg, uint8_t tag, uint16_t len)
| put (append) a TvL field to Message buffers, i.e.
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 Message buffers
static uint8_t * | msgb_tvlv_put_16be (struct msgb *msg, uint8_t tag, uint16_t val)
| put (append) a TvLV field containing a big-endian 16bit value to msgb.
static uint8_t * | msgb_tvlv_put_32be (struct msgb *msg, uint8_t tag, uint32_t val)
| put (append) a TvLV field containing a big-endian 16bit value to msgb.
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 Message buffers
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 Message buffers
static uint8_t * | v_put (uint8_t *buf, uint8_t val)
| put (append) a V field
static uint8_t * | tv_put (uint8_t *buf, uint8_t tag, uint8_t val)
| put (append) a TV field
static uint8_t * | tv_fixed_put (uint8_t *buf, uint8_t tag, unsigned int len, const uint8_t *val)
| put (append) a TVfixed field
static uint8_t * | tv16_put (uint8_t *buf, uint8_t tag, uint16_t val)
| put (append) a TV16 field
static uint8_t * | msgb_lv_put (struct msgb *msg, uint8_t len, const uint8_t *val)
| put (append) a LV field to a Message buffers
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 Message buffers
static uint8_t * | msgb_tv_put (struct msgb *msg, uint8_t tag, uint8_t val)
| put (append) a TV field to a Message buffers
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 Message buffers
static uint8_t * | msgb_v_put (struct msgb *msg, uint8_t val)
| put (append) a V field to a Message buffers
static uint8_t * | msgb_tl_put (struct msgb *msg, uint8_t tag)
| put (append) a TL fields to a Message buffers
static uint8_t * | msgb_tv16_put (struct msgb *msg, uint8_t tag, uint16_t val)
| put (append) a TV16 field (network order) to the given msgb
static uint8_t * | msgb_tv32_put (struct msgb *msg, uint8_t tag, uint32_t val)
| put (append) a TV32 field (network order) to the given msgb
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 Message buffers
static uint8_t * | msgb_tlv1_push (struct msgb *msg, uint8_t tag, uint8_t val)
| push 1-byte tagged value
static uint8_t * | msgb_tv_push (struct msgb *msg, uint8_t tag, uint8_t val)
| push (prepend) a TV field to a Message buffers
static uint8_t * | msgb_tv16_push (struct msgb *msg, uint8_t tag, uint16_t val)
| push (prepend) a TV16 field to a Message buffers
static uint8_t * | msgb_tv32_push (struct msgb *msg, uint8_t tag, uint32_t val)
| push (prepend) a TV32 field to a Message buffers
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 Message buffers
static uint8_t * | msgb_vtvl_gan_push (struct msgb *msg, uint16_t tag, uint16_t len)
static uint8_t * | msgb_vtvlv_gan_push (struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *val)
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.
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.
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.
void | tlv_def_patch (struct tlv_definition *dst, const struct tlv_definition *src)
| take a master (src) tlv_definition and fill up all empty slots in 'dst'
int | tlv_encode_one (struct msgb *msg, enum tlv_type type, uint8_t tag, unsigned int len, const uint8_t *val)
| Encode a single TLV into given message buffer.
int | tlv_encode (struct msgb *msg, const struct tlv_definition *def, const struct tlv_parsed *tp)
| Encode a set of decoded TLVs according to a given definition into a message buffer.
int | tlv_encode_ordered (struct msgb *msg, const struct tlv_definition *def, const struct tlv_parsed *tp, const uint8_t *tag_order, unsigned int tag_order_len)
| Encode a set of decoded TLVs according to a given definition and IE order into a message buffer.
static uint8_t | tlvp_val8 (const struct tlv_parsed *tp, uint8_t tag, uint8_t default_val)
| Obtain 1-byte TLV element.
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.
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.
static uint16_t | tlvp_val16be (const struct tlv_parsed *tp, int pos)
| Retrieve (possibly unaligned) TLV element and convert to host byte order.
static uint32_t | tlvp_val32be (const struct tlv_parsed *tp, int pos)
| Retrieve (possibly unaligned) TLV element and convert to host byte order.
struct tlv_parsed * | osmo_tlvp_copy (const struct tlv_parsed *tp_orig, void *ctx)
| Copy tlv_parsed using given talloc context.
int | osmo_tlvp_merge (struct tlv_parsed *dst, const struct tlv_parsed *src)
| Merge all tlv_parsed attributes of 'src' into 'dst'.
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.
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.
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.
int | osmo_match_shift_tlv (uint8_t **data, size_t *data_len, uint8_t expected_tag, uint8_t **value, size_t *value_len)
| Verify TLV header and advance data / subtract length.
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.
const char * | osmo_tlv_prot_msg_name (const struct osmo_tlv_prot_def *pdef, uint8_t msg_type)
| get the message name for given msg_type in protocol pdef
const char * | osmo_tlv_prot_ie_name (const struct osmo_tlv_prot_def *pdef, uint8_t iei)
| get the IE name for given IEI in protocol pdef
int | osmo_tlv_prot_validate_tp (const struct osmo_tlv_prot_def *pdef, uint8_t msg_type, const struct tlv_parsed *tp, int log_subsys, const char *log_pfx)
| Validate an already TLV-decoded message against the protocol definition.
int | osmo_tlv_prot_parse (const struct osmo_tlv_prot_def *pdef, struct tlv_parsed *dec, unsigned int dec_multiples, uint8_t msg_type, const uint8_t *buf, unsigned int buf_len, uint8_t lv_tag, uint8_t lv_tag2, int log_subsys, const char *log_pfx)
| Parse + Validate a TLV-encoded message against the protocol definition.
static uint32_t | osmo_tlv_prot_msgt_flags (const struct osmo_tlv_prot_def *pdef, uint8_t msg_type)
int | tlv_dump (struct tlv_parsed *dec)
| Dump parsed TLV structure to stdout.
static | __attribute__ ((constructor))

## Variables

struct tlv_definition | tvlv_att_def
struct tlv_definition | vtvlv_gan_att_def
struct tlv_definition | tvlv_att_def
struct tlv_definition | vtvlv_gan_att_def
static __thread char | ienamebuf [32]
static __thread char | msgnamebuf [32]

## Detailed Description

Osmocom TLV Parser

The Osmocom TLV parser is intended to operate as a low-level C implementation without dynamic memory allocations. Basically, it iterates over the IE (Information Elements) of the message and fills an array of pointers, indexed by the IEI (IE Identifier). The parser output is thus an array of pointers to the start of the respective IE inside the message.

The TLV parser is configured by a TLV parser definition, which determines which if the IEIs for a given protocol are of which particular type. Types are e.g. TV (Tag + single byte value), Tag + fixed-length value, TLV with 8bit length, TLV with 16bit length, TLV with variable-length length field, etc.

## Macro Definition Documentation

## L16TV_GROSS_LEN

#define L16TV_GROSS_LEN | ( |  | x | ) |

Value:
(x+3)
x
uint32_t x

gross length of a L16TV type field

Referenced by msgb_l16tv_put().

## LV_GROSS_LEN

#define LV_GROSS_LEN | ( |  | x | ) |

Value:
(x+1)

gross length of a LV type field

Referenced by msgb_lv_put().

## MSG_DEF

#define MSG_DEF | ( |  | name,
|  |  | mand_ies,
|  |  | flags )

Value:
{ name, mand_ies, ARRAY_SIZE(mand_ies), flags }
flags
uint16_t flags
ARRAY_SIZE
#define ARRAY_SIZE(x)
name
char name[32]

## T16LV_GROSS_LEN

#define T16LV_GROSS_LEN | ( |  | x | ) |

Value:
(x+3)

gross length of a T16LV type field

Referenced by msgb_t16lv_put().

## TL16V_GROSS_LEN

#define TL16V_GROSS_LEN | ( |  | x | ) |

Value:
(x+3)

gross length of a TL16V type field

Referenced by msgb_tl16v_put(), TVLV_GROSS_LEN(), and VTVLV_GAN_GROSS_LEN().

## TLV16_GROSS_LEN

#define TLV16_GROSS_LEN | ( |  | x | ) |

Value:
((2*x)+2)

gross length of a TLV16 type field

Referenced by msgb_tlv16_put().

## TLV_GROSS_LEN

#define TLV_GROSS_LEN | ( |  | x | ) |

Value:
(x+2)

gross length of a TLV type field

Referenced by msgb_tlv_push(), msgb_tlv_put(), TVLV_GROSS_LEN(), and VTVLV_GAN_GROSS_LEN().

## TLVP_GET

#define TLVP_GET | ( |  | _tp,
|  |  | tag )

Value:
(TLVP_PRESENT(_tp, tag)? &(_tp)->lv[tag] : NULL)
TLVP_PRESENT
#define TLVP_PRESENT(x, y)
Definition tlv.h:556

Return pointer to a TLV element if it is present.

Usage: struct tlv_p_entry *e = TVLP_GET(&tp, TAG); if (!e) return -ENOENT; hexdump(e->val, e->len);

Parameters

  [in] | _tp | pointer to tlv_parsed.
  [in] | tag | IE tag to return.

Returns
  struct tlv_p_entry pointer, or NULL if not present.

Referenced by osmo_bssmap_le_dec_reset().

## TLVP_GET_MINLEN

#define TLVP_GET_MINLEN | ( |  | _tp,
|  |  | tag,
|  |  | min_len )

Value:
(TLVP_PRES_LEN(_tp, tag, min_len)? &(_tp)->lv[tag] : NULL)
TLVP_PRES_LEN
#define TLVP_PRES_LEN(tp, tag, min_len)
Definition tlv.h:560

Like TLVP_GET(), but enforcing a minimum val length.

Parameters

  [in] | _tp | pointer to tlv_parsed.
  [in] | tag | IE tag to return.
  [in] | min_len | Minimum value length in bytes.

Returns
  struct tlv_p_entry pointer, or NULL if not present or too short.

## TLVP_LEN

#define TLVP_LEN | ( |  | x,
|  |  | y )

Value:
(x)->lv[y].len
len
uint8_t len
Definition gsm_04_11.h:0

Referenced by abis_nm_get_sw_desc(), cbsp_dec_failure(), cbsp_dec_kill(), cbsp_dec_kill_compl(), cbsp_dec_kill_fail(), cbsp_dec_load_query(), cbsp_dec_load_query_compl(), cbsp_dec_load_query_fail(), cbsp_dec_msg_status_query(), cbsp_dec_msg_status_query_compl(), cbsp_dec_msg_status_query_fail(), cbsp_dec_reset(), cbsp_dec_reset_compl(), cbsp_dec_reset_fail(), cbsp_dec_restart(), cbsp_dec_write_repl(), cbsp_dec_write_repl_compl(), cbsp_dec_write_repl_fail(), gsm0808_dec_gcr(), gsm0808_get_cause(), osmo_tlv_prot_validate_tp(), rslms_rx_rll_data_req(), rslms_rx_rll_est_req(), rslms_rx_rll_res_req(), rslms_rx_rll_udata_req(), tlv_encode(), and tlv_encode_ordered().

## TLVP_PRES_LEN

#define TLVP_PRES_LEN | ( |  | tp,
|  |  | tag,
|  |  | min_len )

Value:
(TLVP_PRESENT(tp, tag) && TLVP_LEN(tp, tag) >= min_len)
TLVP_LEN
#define TLVP_LEN(x, y)
Definition tlv.h:557

Referenced by cbsp_dec_error_ind(), cbsp_dec_failure(), cbsp_dec_keep_alive(), cbsp_dec_kill(), cbsp_dec_kill_compl(), cbsp_dec_kill_fail(), cbsp_dec_load_query(), cbsp_dec_load_query_compl(), cbsp_dec_load_query_fail(), cbsp_dec_msg_status_query(), cbsp_dec_msg_status_query_compl(), cbsp_dec_msg_status_query_fail(), cbsp_dec_reset(), cbsp_dec_reset_compl(), cbsp_dec_reset_fail(), cbsp_dec_restart(), cbsp_dec_write_repl(), cbsp_dec_write_repl_compl(), cbsp_dec_write_repl_fail(), and ipa_ccm_tlv_to_unitdata().

## TLVP_PRESENT

#define TLVP_PRESENT | ( |  | x,
|  |  | y )

Value:
(!!((x)->lv[y].val))

Referenced by abis_nm_get_sw_desc(), cbsp_dec_write_repl(), gsm0808_dec_lcls(), osmo_tlv_prot_validate_tp(), rslms_rx_rll_data_req(), rslms_rx_rll_est_req(), rslms_rx_rll_res_req(), rslms_rx_rll_udata_req(), tlv_encode(), and tlv_encode_ordered().

## TLVP_VAL

#define TLVP_VAL | ( |  | x,
|  |  | y )

Value:
(x)->lv[y].val

Referenced by abis_nm_get_sw_desc(), cbsp_dec_error_ind(), cbsp_dec_failure(), cbsp_dec_keep_alive(), cbsp_dec_kill(), cbsp_dec_kill_compl(), cbsp_dec_kill_fail(), cbsp_dec_load_query(), cbsp_dec_load_query_compl(), cbsp_dec_load_query_fail(), cbsp_dec_msg_status_query(), cbsp_dec_msg_status_query_compl(), cbsp_dec_msg_status_query_fail(), cbsp_dec_reset(), cbsp_dec_reset_compl(), cbsp_dec_reset_fail(), cbsp_dec_restart(), cbsp_dec_write_repl(), cbsp_dec_write_repl_compl(), cbsp_dec_write_repl_fail(), ipa_ccm_tlv_to_unitdata(), rslms_rx_rll_data_req(), rslms_rx_rll_est_req(), rslms_rx_rll_res_req(), rslms_rx_rll_udata_req(), tlv_encode(), tlv_encode_ordered(), tlvp_val16_unal(), tlvp_val16be(), tlvp_val32_unal(), and tlvp_val32be().

## TLVP_VAL_MINLEN

#define TLVP_VAL_MINLEN | ( |  | _tp,
|  |  | tag,
|  |  | min_len )

Value:
(TLVP_PRES_LEN(_tp, tag, min_len)? (_tp)->lv[tag].val : NULL)

Like TLVP_VAL(), but enforcing a minimum val length.

Parameters

  [in] | _tp | pointer to tlv_parsed.
  [in] | tag | IE tag to return.
  [in] | min_len | Minimum value length in bytes.

Returns
  const uint8_t pointer to value, or NULL if not present or too short.

Referenced by gsm0808_dec_gcr(), gsm0808_get_cause(), and tlvp_val8().

## TVLV_MAX_ONEBYTE

#define TVLV_MAX_ONEBYTE 0x7f

maximum length of TLV of one byte length

Referenced by tvl_put(), TVLV_GROSS_LEN(), tvlv_put(), vt_gan_put(), VTVL_GAN_GROSS_LEN(), and VTVLV_GAN_GROSS_LEN().

## Enumeration Type Documentation

## osmo_tlv_parser_error

enum osmo_tlv_parser_error

error return codes of various TLV parser functions

Enumerator
OSMO_TLVP_ERR_OFS_BEYOND_BUFFER |
OSMO_TLVP_ERR_OFS_LEN_BEYOND_BUFFER |
OSMO_TLVP_ERR_UNKNOWN_TLV_TYPE |
OSMO_TLVP_ERR_MAND_IE_MISSING |
OSMO_TLVP_ERR_IE_TOO_SHORT |

## tlv_type

enum tlv_type

TLV type.

Enumerator
TLV_TYPE_NONE | no type
TLV_TYPE_FIXED | fixed-length value-only
TLV_TYPE_T | tag-only
TLV_TYPE_TV | tag-value (8bit)
TLV_TYPE_TLV | tag-length-value
TLV_TYPE_TL16V | tag, 16 bit length, value
TLV_TYPE_TvLV | tag, variable length, value
TLV_TYPE_SINGLE_TV | tag and value (both 4 bit) in 1 byte
TLV_TYPE_vTvLV_GAN | variable-length tag, variable-length length

## Function Documentation

## __attribute__()

__attribute__ | ( | (constructor) |  | ) |

static

References TLV_TYPE_TvLV, TLV_TYPE_vTvLV_GAN, tvlv_att_def, and vtvlv_gan_att_def.

## lv_put()

uint8_t * lv_put | ( | uint8_t * | buf,
|  | uint8_t | len,
|  | const uint8_t * | val )

inline static

put (append) a LV field

References len.

Referenced by msgb_lv_put().

## msgb_l16tv_put()

uint8_t * msgb_l16tv_put | ( | struct msgb * | msg,
|  | uint16_t | len,
|  | uint8_t | tag,
|  | const uint8_t * | val )

inline static

put (append) a L16TV field to Message buffers

References L16TV_GROSS_LEN, len, and msg.

## msgb_lv_put()

uint8_t * msgb_lv_put | ( | struct msgb * | msg,
|  | uint8_t | len,
|  | const uint8_t * | val )

inline static

put (append) a LV field to a Message buffers

Returns
  pointer to first byte after newly-put information

References len, LV_GROSS_LEN, lv_put(), and msg.

Referenced by gsm48_encode_bearer_cap(), gsm48_encode_cause(), gsm48_encode_facility(), gsm48_encode_progress(), gsm48_encode_useruser(), and osmo_enc_gcr().

## msgb_t16lv_put()

uint8_t * msgb_t16lv_put | ( | struct msgb * | msg,
|  | uint16_t | tag,
|  | uint8_t | len,
|  | const uint8_t * | val )

inline static

References len, msg, T16LV_GROSS_LEN, and t16lv_put().

## msgb_tl16v_put()

uint8_t * msgb_tl16v_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint16_t | len,
|  | const uint8_t * | val )

inline static

put (append) a TL16V field to Message buffers

References len, msg, TL16V_GROSS_LEN, and tl16v_put().

Referenced by abis_nm_fail_evt_vrep(), abis_nm_put_sw_desc(), and tlv_encode_one().

## msgb_tl_put()

uint8_t * msgb_tl_put | ( | struct msgb * | msg,
|  | uint8_t | tag )

inline static

put (append) a TL fields to a Message buffers

Returns
  pointer to the length field so it can be updated after adding new information under specified tag

References len, msg, and msgb_v_put().

Referenced by gsm0808_create_common_id(), gsm0808_create_perform_location_request(), gsm0808_create_perform_location_response(), gsm0808_enc_gcr(), gsm0808_enc_lcs_cause(), osmo_bssmap_le_enc_perform_loc_abort(), osmo_bssmap_le_enc_perform_loc_req(), osmo_bssmap_le_enc_perform_loc_resp(), and osmo_gsup_encode().

## msgb_tlv16_put()

uint8_t * msgb_tlv16_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint8_t | len,
|  | const uint16_t * | val )

inline static

put (append) a TLV16 field to Message buffers

References len, msg, TLV16_GROSS_LEN, and tlv16_put().

## msgb_tlv1_push()

uint8_t * msgb_tlv1_push | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint8_t | val )

inline static

push 1-byte tagged value

References msg, and msgb_tlv_push().

Referenced by gsm0480_gen_reject(), gsm0480_gen_return_error(), gsm0480_gen_ussd_resp_7bit(), and gsm0480_wrap_invoke().

## msgb_tlv_push()

uint8_t * msgb_tlv_push | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint8_t | len,
|  | const uint8_t * | val )

inline static

push (prepend) a TLV field to a Message buffers

Returns
  pointer to first byte of newly-pushed information

References len, msg, TLV_GROSS_LEN, and tlv_put().

Referenced by msgb_tlv1_push().

## msgb_tlv_put()

uint8_t * msgb_tlv_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint8_t | len,
|  | const uint8_t * | val )

inline static

put (append) a TLV field to a Message buffers

Returns
  pointer to first byte after newly-put information

References len, msg, TLV_GROSS_LEN, and tlv_put().

Referenced by encode_auth_info(), encode_pdp_info(), gsm0808_create_cipher_complete(), gsm0808_create_classmark_update(), gsm0808_create_clear_complete(), gsm0808_create_handover_command(), gsm0808_create_handover_complete(), gsm0808_create_handover_failure(), gsm0808_create_handover_request(), gsm0808_create_handover_request_ack2(), gsm0808_create_layer3_2(), gsm0808_create_notification_data(), gsm0808_create_paging2(), gsm0808_create_uplink_app_data(), gsm0808_create_uplink_request(), gsm0808_create_uplink_request_cnf(), gsm0808_create_vgcs_queuing_ind(), gsm0808_create_vgcs_sms(), gsm0808_create_vgcs_vbs_assign_fail(), gsm0808_create_vgcs_vbs_assign_req(), gsm0808_create_vgcs_vbs_assign_stat(), gsm29118_create_dl_ud(), gsm29118_create_lu_ack(), gsm29118_create_lu_rej(), gsm29118_create_mm_info_req(), gsm29118_create_paging_req(), gsm29118_create_release_req(), gsm29118_create_status(), gsm48_encode_bearer_cap(), gsm48_encode_called(), gsm48_encode_callerid(), gsm48_encode_cause(), gsm48_encode_cccap(), gsm48_encode_facility(), gsm48_encode_progress(), gsm48_encode_ssversion(), gsm48_encode_useruser(), msgb_sgsap_imsi_put(), msgb_sgsap_lai_put(), msgb_sgsap_name_put(), osmo_bssmap_le_ie_enc_lcs_qos(), osmo_gsup_encode(), osmo_oap_encode(), put_old_bss_to_new_bss_information(), rsl_rll_error(), and tlv_encode_one().

## msgb_tv16_push()

uint8_t * msgb_tv16_push | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint16_t | val )

inline static

push (prepend) a TV16 field to a Message buffers

Returns
  pointer to first byte of newly-pushed information

References msg, and tv16_put().

Referenced by rsl_rll_push_l3(), and send_rslms_rll_l3_ui().

## msgb_tv16_put()

uint8_t * msgb_tv16_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint16_t | val )

inline static

put (append) a TV16 field (network order) to the given msgb

Returns
  pointer to first byte after newly-put information

References msg, and tv16_put().

Referenced by cbsp_enc_error_ind(), cbsp_enc_kill(), cbsp_enc_kill_compl(), cbsp_enc_kill_fail(), cbsp_enc_msg_status_query(), cbsp_enc_msg_status_query_compl(), cbsp_enc_msg_status_query_fail(), cbsp_enc_write_repl(), cbsp_enc_write_repl_compl(), cbsp_enc_write_repl_fail(), gsm0808_create_ass2(), gsm0808_create_vgcs_vbs_assign_req(), and gsm0808_create_vgcs_vbs_assign_res().

## msgb_tv32_push()

uint8_t * msgb_tv32_push | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint32_t | val )

inline static

push (prepend) a TV32 field to a Message buffers

Returns
  pointer to first byte of newly-pushed information

References msg.

## msgb_tv32_put()

uint8_t * msgb_tv32_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint32_t | val )

inline static

put (append) a TV32 field (network order) to the given msgb

Returns
  pointer to first byte after newly-put information

References msg.

## msgb_tv_fixed_put()

uint8_t * msgb_tv_fixed_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | unsigned int | len,
|  | const uint8_t * | val )

inline static

put (append) a TVfixed field to a Message buffers

Returns
  pointer to first byte after newly-put information

References len, msg, and tv_fixed_put().

Referenced by abis_nm_fail_evt_vrep(), gsm0808_create_ass2(), gsm0808_create_handover_request(), gsm0808_create_handover_required(), gsm0808_enc_kc128(), l2_ph_rach_ind(), and tlv_encode_one().

## msgb_tv_push()

uint8_t * msgb_tv_push | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint8_t | val )

inline static

push (prepend) a TV field to a Message buffers

Returns
  pointer to first byte of newly-pushed information

References msg, and tv_put().

Referenced by gsm0480_gen_reject(), gsm0808_create_ass2(), gsm0808_create_ass_compl2(), gsm0808_create_ass_fail(), gsm0808_create_cipher2(), gsm0808_create_cipher_complete(), gsm0808_create_cipher_reject(), gsm0808_create_cipher_reject_ext(), gsm0808_create_classmark_request(), gsm0808_create_classmark_update(), gsm0808_create_clear_command2(), gsm0808_create_clear_rqst(), gsm0808_create_common_id(), gsm0808_create_handover_command(), gsm0808_create_handover_complete(), gsm0808_create_handover_detect(), gsm0808_create_handover_failure(), gsm0808_create_handover_performed(), gsm0808_create_handover_request(), gsm0808_create_handover_request_ack2(), gsm0808_create_handover_required(), gsm0808_create_handover_required_reject(), gsm0808_create_handover_succeeded(), gsm0808_create_layer3_2(), gsm0808_create_lcls_conn_ctrl(), gsm0808_create_lcls_conn_ctrl_ack(), gsm0808_create_lcls_notification(), gsm0808_create_notification_data(), gsm0808_create_paging2(), gsm0808_create_perform_location_abort(), gsm0808_create_perform_location_request(), gsm0808_create_perform_location_response(), gsm0808_create_reset(), gsm0808_create_reset_ack(), gsm0808_create_sapi_reject_cause(), gsm0808_create_uplink_app_data(), gsm0808_create_uplink_reject_cmd(), gsm0808_create_uplink_release_cmd(), gsm0808_create_uplink_release_ind(), gsm0808_create_uplink_request(), gsm0808_create_uplink_request_ack(), gsm0808_create_uplink_request_cnf(), gsm0808_create_uplink_seized_cmd(), gsm0808_create_vgcs_additional_info(), gsm0808_create_vgcs_sms(), gsm0808_create_vgcs_vbs_area_cell_info(), gsm0808_create_vgcs_vbs_assign_fail(), gsm0808_create_vgcs_vbs_assign_req(), gsm0808_create_vgcs_vbs_assign_res(), gsm0808_create_vgcs_vbs_assign_stat(), gsm0808_create_vgcs_vbs_setup(), gsm0808_create_vgcs_vbs_setup_ack(), gsm0808_create_vgcs_vbs_setup_refuse(), osmo_bssap_le_enc(), and send_rslms_rll_l3_ui().

## msgb_tv_put()

uint8_t * msgb_tv_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint8_t | val )

inline static

put (append) a TV field to a Message buffers

Returns
  pointer to first byte after newly-put information

References msg, and tv_put().

Referenced by abis_nm_fail_evt_vrep(), cbsp_enc_error_ind(), cbsp_enc_failure(), cbsp_enc_keep_alive(), cbsp_enc_kill(), cbsp_enc_kill_compl(), cbsp_enc_kill_fail(), cbsp_enc_load_query(), cbsp_enc_load_query_compl(), cbsp_enc_load_query_fail(), cbsp_enc_msg_status_query(), cbsp_enc_msg_status_query_compl(), cbsp_enc_msg_status_query_fail(), cbsp_enc_restart(), cbsp_enc_write_repl(), cbsp_enc_write_repl_compl(), cbsp_enc_write_repl_fail(), gsm0808_create_ass_compl2(), gsm0808_create_ass_fail(), gsm0808_create_cipher2(), gsm0808_create_cipher_complete(), gsm0808_create_clear_command(), gsm0808_create_handover_complete(), gsm0808_create_handover_performed(), gsm0808_create_handover_request(), gsm0808_create_handover_request_ack2(), gsm0808_create_handover_required(), gsm0808_create_lcls_conn_ctrl(), gsm0808_create_lcls_conn_ctrl_ack(), gsm0808_create_lcls_notification(), gsm0808_create_paging2(), gsm0808_create_sapi_reject_cause(), gsm0808_create_uplink_reject_cmd(), gsm0808_create_uplink_release_ind(), gsm0808_create_uplink_request(), gsm0808_create_uplink_request_ack(), gsm0808_create_uplink_seized_cmd(), gsm0808_create_vgcs_vbs_assign_fail(), gsm0808_create_vgcs_vbs_assign_req(), gsm0808_create_vgcs_vbs_assign_res(), gsm0808_enc_lcls(), gsm411_send_abort(), gsm411_send_rp_error(), gsm48_encode_keypad(), gsm48_encode_signal(), l2_ph_rach_ind(), osmo_gsup_encode_an_apdu(), osmo_gsup_sms_encode_sm_rp_da(), osmo_gsup_sms_encode_sm_rp_oa(), and tlv_encode_one().

## msgb_tvl_put()

uint8_t * msgb_tvl_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint16_t | len )

inline static

put (append) a TvL field to Message buffers, i.e.

a TvLV with variable-size length, where the value's length is already known, but will be put() later. The value section is not yet reserved, only tag and variable-length are put in the msgb.

Returns
  pointer to the value's start position and end of the msgb.

References len, msg, tvl_put(), and TVLV_GROSS_LEN().

## msgb_tvlv_push()

uint8_t * msgb_tvlv_push | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint16_t | len,
|  | const uint8_t * | val )

inline static

push (prepend) a TvLV field to a Message buffers

Returns
  pointer to first byte of newly-pushed information

References len, msg, TVLV_GROSS_LEN(), and tvlv_put().

## msgb_tvlv_put()

uint8_t * msgb_tvlv_put | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint16_t | len,
|  | const uint8_t * | val )

inline static

put (append) a TvLV field to Message buffers

References len, msg, TVLV_GROSS_LEN(), and tvlv_put().

Referenced by msgb_tvlv_put_16be(), msgb_tvlv_put_32be(), and tlv_encode_one().

## msgb_tvlv_put_16be()

uint8_t * msgb_tvlv_put_16be | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint16_t | val )

inline static

put (append) a TvLV field containing a big-endian 16bit value to msgb.

References msg, and msgb_tvlv_put().

## msgb_tvlv_put_32be()

uint8_t * msgb_tvlv_put_32be | ( | struct msgb * | msg,
|  | uint8_t | tag,
|  | uint32_t | val )

inline static

put (append) a TvLV field containing a big-endian 16bit value to msgb.

References msg, and msgb_tvlv_put().

## msgb_v_put()

uint8_t * msgb_v_put | ( | struct msgb * | msg,
|  | uint8_t | val )

inline static

put (append) a V field to a Message buffers

Returns
  pointer to first byte after newly-put information

References msg, and v_put().

Referenced by abis_nm_put_sw_desc(), gsm0808_create_ass2(), gsm0808_create_ass_compl2(), gsm0808_create_ass_fail(), gsm0808_create_cipher2(), gsm0808_create_cipher_complete(), gsm0808_create_cipher_reject(), gsm0808_create_cipher_reject_ext(), gsm0808_create_classmark_request(), gsm0808_create_classmark_update(), gsm0808_create_clear_command(), gsm0808_create_clear_command2(), gsm0808_create_clear_rqst(), gsm0808_create_common_id(), gsm0808_create_handover_command(), gsm0808_create_handover_complete(), gsm0808_create_handover_detect(), gsm0808_create_handover_failure(), gsm0808_create_handover_performed(), gsm0808_create_handover_request(), gsm0808_create_handover_request_ack2(), gsm0808_create_handover_required(), gsm0808_create_handover_required_reject(), gsm0808_create_handover_succeeded(), gsm0808_create_layer3_2(), gsm0808_create_lcls_conn_ctrl(), gsm0808_create_lcls_conn_ctrl_ack(), gsm0808_create_lcls_notification(), gsm0808_create_notification_data(), gsm0808_create_paging2(), gsm0808_create_perform_location_abort(), gsm0808_create_perform_location_request(), gsm0808_create_perform_location_response(), gsm0808_create_reset(), gsm0808_create_reset_ack(), gsm0808_create_sapi_reject_cause(), gsm0808_create_uplink_app_data(), gsm0808_create_uplink_reject_cmd(), gsm0808_create_uplink_release_cmd(), gsm0808_create_uplink_release_ind(), gsm0808_create_uplink_request(), gsm0808_create_uplink_request_ack(), gsm0808_create_uplink_request_cnf(), gsm0808_create_uplink_seized_cmd(), gsm0808_create_vgcs_additional_info(), gsm0808_create_vgcs_vbs_area_cell_info(), gsm0808_create_vgcs_vbs_assign_fail(), gsm0808_create_vgcs_vbs_assign_req(), gsm0808_create_vgcs_vbs_assign_res(), gsm0808_create_vgcs_vbs_assign_stat(), gsm0808_create_vgcs_vbs_setup(), gsm0808_create_vgcs_vbs_setup_ack(), gsm0808_create_vgcs_vbs_setup_refuse(), gsm0808_enc_lcls(), gsm48_encode_notify(), msgb_tl_put(), osmo_bssmap_le_enc(), osmo_gsup_encode(), osmo_gsup_encode_an_apdu(), osmo_gsup_sms_encode_sm_rp_da(), osmo_gsup_sms_encode_sm_rp_oa(), osmo_oap_encode(), and tlv_encode_one().

## msgb_vtvl_gan_push()

uint8_t * msgb_vtvl_gan_push | ( | struct msgb * | msg,
|  | uint16_t | tag,
|  | uint16_t | len )

inline static

References len, msg, VTVL_GAN_GROSS_LEN(), and vtvl_gan_put().

## msgb_vtvlv_gan_push()

uint8_t * msgb_vtvlv_gan_push | ( | struct msgb * | msg,
|  | uint16_t | tag,
|  | uint16_t | len,
|  | const uint8_t * | val )

inline static

References len, msg, VTVLV_GAN_GROSS_LEN(), and vtvlv_gan_put().

## msgb_vtvlv_gan_put()

uint8_t * msgb_vtvlv_gan_put | ( | struct msgb * | msg,
|  | uint16_t | tag,
|  | uint16_t | len,
|  | const uint8_t * | val )

inline static

put (append) a vTvLV field to Message buffers

References len, msg, VTVLV_GAN_GROSS_LEN(), and vtvlv_gan_put().

Referenced by tlv_encode_one().

## osmo_match_shift_tlv()

int osmo_match_shift_tlv | ( | uint8_t ** | data,
|  | size_t * | data_len,
|  | uint8_t | expected_tag,
|  | uint8_t ** | value,
|  | size_t * | value_len )

Verify TLV header and advance data / subtract length.

Parameters

  | data | pointer to the pointer to data

  data_len

  pointer to size_t containing
  - data length

  [in]

  expected_tag

  the tag (IEI) that we expect at
  - data

  [out] | value | pointer to pointer of value part of IE

  [out]

  value_len

  pointer to length of
  - value

Returns
  length of IE value; negative in case of error

References osmo_shift_tlv().

Referenced by osmo_gsup_decode().

## 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.

Parameters

  | data | pointer to the pointer to data

  data_len

  pointer to size_t containing
  - data length

  [in]

  tag

  the tag (IEI) that we expect at
  - data

  [in] | len | the length that we expect the fixed IE to have
  [out] | value | pointer to pointer of value part of IE

Returns
  length of IE value; negative in case of error

References len.

## 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.

Parameters

  | data | pointer to the pointer to data

  data_len

  pointer to size_t containing
  - data lengt

  [out] | value | extracted pointer to value part of TLV

  [out]

  value_len

  extracted length of
  - value

Returns
  number of bytes subtracted

References len.

## 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.

Parameters

  | data | pointer to the pointer to data

  data_len

  pointer to size_t containing
  - data lengt

  [out]

  tag

  extract the tag (IEI) at start of
  - data

  [out] | value | extracted pointer to value part of TLV

  [out]

  value_len

  extracted length of
  - value

Returns
  number of bytes subtracted

References len.

Referenced by decode_auth_info(), decode_pdp_info(), osmo_gsup_decode(), osmo_match_shift_tlv(), and osmo_oap_decode().

## 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.

Parameters

  | data | pointer to the pointer to data

  data_len

  pointer to size_t containing
  - data length

  [in] | len | the length that we expect the fixed IE to hav
  [out] | value | pointer to pointer of value part of IE

Returns
  length of IE value; negative in case of error

References len.

Referenced by osmo_gsup_decode(), and osmo_oap_decode().

## osmo_tlv_prot_ie_name()

const char * osmo_tlv_prot_ie_name | ( | const struct osmo_tlv_prot_def * | pdef,
|  | uint8_t | iei )

get the IE name for given IEI in protocol pdef

References osmo_tlv_prot_def::ie_def, iei, ienamebuf, and osmo_tlv_prot_ie_def::name.

Referenced by osmo_tlv_prot_validate_tp().

## osmo_tlv_prot_msg_name()

const char * osmo_tlv_prot_msg_name | ( | const struct osmo_tlv_prot_def * | pdef,
|  | uint8_t | msg_type )

get the message name for given msg_type in protocol pdef

References osmo_tlv_prot_def::msg_def, msgnamebuf, osmo_tlv_prot_def::msgt_names, and osmo_tlv_prot_msg_def::name.

Referenced by osmo_tlv_prot_parse(), and osmo_tlv_prot_validate_tp().

## osmo_tlv_prot_msgt_flags()

uint32_t osmo_tlv_prot_msgt_flags | ( | const struct osmo_tlv_prot_def * | pdef,
|  | uint8_t | msg_type )

inline static

References osmo_tlv_prot_msg_def::flags, and osmo_tlv_prot_def::msg_def.

## osmo_tlv_prot_parse()

int osmo_tlv_prot_parse | ( | const struct osmo_tlv_prot_def * | pdef,
|  | struct tlv_parsed * | dec,
|  | unsigned int | dec_multiples,
|  | uint8_t | msg_type,
|  | const uint8_t * | buf,
|  | unsigned int | buf_len,
|  | uint8_t | lv_tag,
|  | uint8_t | lv_tag2,
|  | int | log_subsys,
|  | const char * | log_pfx )

Parse + Validate a TLV-encoded message against the protocol definition.

Parameters

  [in] | pdef | protocol definition of given protocol
  [out] | dec | caller-allocated pointer to tlv_parsed
  [in] | dec_multiples | length of the tlv_parsed[] in dec.
  [in] | msg_type | message type of the parsed message
  [in] | buf | the input data buffer to be parsed
  [in] | buf_len | length of the input data buffer
  [in] | lv_tag | an initial LV tag at the start of the buffer
  [in] | lv_tag2 | a second initial LV tag following the lv_tag
  [in] | log_subsys | logging sub-system for log messages
  [in] | log_pfx | prefix for log messages

Returns
  0 in case of success; negative osmo_tlv_parser_error in case of error

References osmo_tlv_prot_def::name, osmo_tlv_prot_msg_name(), osmo_tlv_prot_validate_tp(), osmo_tlv_prot_def::tlv_def, and tlv_parse2().

## osmo_tlv_prot_validate_tp()

int osmo_tlv_prot_validate_tp | ( | const struct osmo_tlv_prot_def * | pdef,
|  | uint8_t | msg_type,
|  | const struct tlv_parsed * | tp,
|  | int | log_subsys,
|  | const char * | log_pfx )

Validate an already TLV-decoded message against the protocol definition.

Parameters

  [in] | pdef | protocol definition of given protocol
  [in] | msg_type | message type of the parsed message
  [in] | tp | TLV parser result
  [in] | log_subsys | logging sub-system for log messages
  [in] | log_pfx | prefix for log messages

Returns
  0 in case of success; negative osmo_tlv_parser_error in case of error

References osmo_tlv_prot_def::ie_def, iei, tlv_parsed::lv, osmo_tlv_prot_msg_def::mand_count, osmo_tlv_prot_msg_def::mand_ies, osmo_tlv_prot_ie_def::min_len, osmo_tlv_prot_def::msg_def, osmo_tlv_prot_def::name, osmo_tlv_prot_ie_name(), osmo_tlv_prot_msg_name(), OSMO_TLVP_ERR_IE_TOO_SHORT, OSMO_TLVP_ERR_MAND_IE_MISSING, TLVP_LEN, and TLVP_PRESENT.

Referenced by osmo_tlv_prot_parse().

## osmo_tlvp_copy()

struct tlv_parsed * osmo_tlvp_copy | ( | const struct tlv_parsed * | tp_orig,
|  | void * | ctx )

Copy tlv_parsed using given talloc context.

Parameters

  [in] | tp_orig | Parsed TLV structure
  [in] | ctx | Talloc context for allocations

Returns
  NULL on errors, tlv_parsed pointer otherwise

References len, tlv_p_entry::len, tlv_parsed::lv, and tlv_p_entry::val.

## 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'.

Parameters

  [in] | dst | Parsed TLV structure to merge into
  [in] | src | Parsed TLV structure to merge from

Returns
  0 on success, negative on error

References len, tlv_p_entry::len, tlv_parsed::lv, and tlv_p_entry::val.

## t16lv_put()

uint8_t * t16lv_put | ( | uint8_t * | buf,
|  | uint16_t | tag,
|  | uint8_t | len,
|  | const uint8_t * | val )

inline static

put (append) a TL16V field

References len.

Referenced by msgb_t16lv_put().

## tl16_put()

uint8_t * tl16_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint16_t | len )

inline static

put (append) a TL16 field.

References len.

Referenced by tvl_put().

## tl16v_put()

uint8_t * tl16v_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint16_t | len,
|  | const uint8_t * | val )

inline static

put (append) a TL16V field

References len.

Referenced by msgb_tl16v_put(), and tvlv_put().

## tl_put()

uint8_t * tl_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint8_t | len )

inline static

put (append) a TL field (a TLV field but omitting the value part).

References len.

Referenced by tvl_put().

## tlv16_put()

uint8_t * tlv16_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint8_t | len,
|  | const uint16_t * | val )

inline static

put (append) a TLV16 field

References len.

Referenced by msgb_tlv16_put().

## tlv_def_patch()

void tlv_def_patch | ( | struct tlv_definition * | dst,
|  | const struct tlv_definition * | src )

take a master (src) tlv_definition and fill up all empty slots in 'dst'

Parameters

  | dst | TLV parser definition that is to be patched
  [in] | src | TLV parser definition whose content is patched into dst

References tlv_definition::def, TLV_TYPE_NONE, and tlv_def::type.

## tlv_dump()

int tlv_dump | ( | struct tlv_parsed * | dec | ) |

Dump parsed TLV structure to stdout.

References tlv_p_entry::len, tlv_parsed::lv, and tlv_p_entry::val.

## tlv_encode()

int tlv_encode | ( | struct msgb * | msg,
|  | const struct tlv_definition * | def,
|  | const struct tlv_parsed * | tp )

Encode a set of decoded TLVs according to a given definition into a message buffer.

Parameters

  [in,out] | msg | Caller-allocated message buffer with sufficient tailroom
  [in] | def | structure defining the valid TLV tags / configurations
  [in] | tp | decoded values to be encoded

Returns
  number of bytes consumed in msg; negative in case of error

References tlv_definition::def, tlv_parsed::lv, msg, tlv_encode_one(), TLVP_LEN, TLVP_PRESENT, TLVP_VAL, and tlv_def::type.

## tlv_encode_one()

int tlv_encode_one | ( | struct msgb * | msg,
|  | enum tlv_type | type,
|  | uint8_t | tag,
|  | unsigned int | len,
|  | const uint8_t * | val )

Encode a single TLV into given message buffer.

Parameters

  [in,out] | msg | Caller-allocated message buffer with sufficient tailroom
  [in] | type | TLV type/format to use during encode
  [in] | tag | Tag of TLV to be encoded
  [in] | len | Length of TLV to be encoded
  [in] | val | Value part of TLV to be encoded

Returns
  0 on success; negative in case of error

References len, msg, msgb_tl16v_put(), msgb_tlv_put(), msgb_tv_fixed_put(), msgb_tv_put(), msgb_tvlv_put(), msgb_v_put(), msgb_vtvlv_gan_put(), TLV_TYPE_FIXED, TLV_TYPE_NONE, TLV_TYPE_SINGLE_TV, TLV_TYPE_T, TLV_TYPE_TL16V, TLV_TYPE_TLV, TLV_TYPE_TV, TLV_TYPE_TvLV, and TLV_TYPE_vTvLV_GAN.

Referenced by tlv_encode(), and tlv_encode_ordered().

## tlv_encode_ordered()

int tlv_encode_ordered | ( | struct msgb * | msg,
|  | const struct tlv_definition * | def,
|  | const struct tlv_parsed * | tp,
|  | const uint8_t * | tag_order,
|  | unsigned int | tag_order_len )

Encode a set of decoded TLVs according to a given definition and IE order into a message buffer.

Parameters

  [in,out] | msg | Caller-allocated message buffer with sufficient tailroom
  [in] | def | structure defining the valid TLV tags / configurations
  [in] | tp | decoded values to be encoded
  [in] | tag_order | array of tags determining the IE encoding order
  [in] | tag_order_len | length of tag_order

Returns
  number of bytes consumed in msg; negative in case of error

References tlv_definition::def, msg, tlv_encode_one(), TLVP_LEN, TLVP_PRESENT, TLVP_VAL, and tlv_def::type.

## 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.

In case of multiple occurences of an IE, keep only the first occurence. Most GSM related protocols clearly indicate that in case of duplicate IEs, only the first occurrence shall be used, while any further occurrences shall be ignored. See e.g. 3GPP TS 24.008 Section 8.6.3. For multiple occurences, use tlv_parse2().

Parameters

  [out] | dec | caller-allocated pointer to tlv_parsed
  [in] | def | structure defining the valid TLV tags / configurations
  [in] | buf | the input data buffer to be parsed
  [in] | buf_len | length of the input data buffer
  [in] | lv_tag | an initial LV tag at the start of the buffer
  [in] | lv_tag2 | a second initial LV tag following the lv_tag

Returns
  number of TLV entries parsed; negative in case of error

References tlv_parse2().

Referenced by abis_nm_get_sw_desc(), and osmo_bssmap_le_dec().

## 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.

Parse an entire buffer of TLV encoded Information Elements. To decode multiple occurences of IEs, provide in dec an array of tlv_parsed, and pass the size of that array in dec_multiples. The first occurence of each IE is stored in dec[0], the second in dec[1] and so forth. If there are more occurences than the array length given in dec_multiples, the remaining occurences are dropped.

Parameters

  [out] | dec | caller-allocated pointer to tlv_parsed
  [in] | dec_multiples | length of the tlv_parsed[] in dec.
  [in] | def | structure defining the valid TLV tags / configurations
  [in] | buf | the input data buffer to be parsed
  [in] | buf_len | length of the input data buffer
  [in] | lv_tag | an initial LV tag at the start of the buffer
  [in] | lv_tag2 | a second initial LV tag following the lv_tag

Returns
  number of TLV entries parsed; negative in case of error

References len, tlv_p_entry::len, tlv_parsed::lv, OSMO_TLVP_ERR_OFS_BEYOND_BUFFER, OSMO_TLVP_ERR_OFS_LEN_BEYOND_BUFFER, tlv_parse_one(), and tlv_p_entry::val.

Referenced by osmo_bsslap_dec(), osmo_cbsp_decode(), osmo_tlv_prot_parse(), and tlv_parse().

## 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.

Parameters

  [out] | o_tag | the tag of the IE that was found
  [out] | o_len | length of the IE that was found
  [out] | o_val | pointer to the data of the IE that was found
  [in] | def | structure defining the valid TLV tags / configurations
  [in] | buf | the input data buffer to be parsed
  [in] | buf_len | length of the input data buffer

Returns
  number of bytes consumed by the TLV entry / IE parsed; negative in case of error.

In IEs of type TLV_TYPE_SINGLE_TV, the data pointer o_val will point to the byte shared by both the Tag and te Value, hence the tag is to be trimmed by the caller.

References tlv_definition::def, tlv_def::fixed_len, len, OSMO_TLVP_ERR_OFS_BEYOND_BUFFER, OSMO_TLVP_ERR_OFS_LEN_BEYOND_BUFFER, OSMO_TLVP_ERR_UNKNOWN_TLV_TYPE, TLV_TYPE_FIXED, TLV_TYPE_SINGLE_TV, TLV_TYPE_T, TLV_TYPE_TL16V, TLV_TYPE_TLV, TLV_TYPE_TV, TLV_TYPE_TvLV, TLV_TYPE_vTvLV_GAN, and tlv_def::type.

Referenced by tlv_parse2().

## tlv_put()

uint8_t * tlv_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint8_t | len,
|  | const uint8_t * | val )

inline static

Append a TLV field, a Tag-Length-Value field.

Parameters

  [out] | buf | Location in a buffer to append TLV at.
  [in] | tag | Tag id to write.
  [in] | len | Length field to write and amount of bytes to append.
  [in] | val | Pointer to data to append, or NULL to append zero data. Always append tag and length. Append len bytes read from val. If val is NULL, append len zero bytes instead. If len is zero, do not append any data apart from tag and length.

References len.

Referenced by msgb_tlv_push(), msgb_tlv_put(), and tvlv_put().

## tlvp_val16_unal()

uint16_t tlvp_val16_unal | ( | const struct tlv_parsed * | tp,
|  | int | pos )

inline static

Align given TLV element with 16 bit value to an even address.

Parameters

  [in] | tp | pointer to tlv_parsed
  [in] | pos | element to return

Returns
  aligned 16 bit value

References TLVP_VAL.

## tlvp_val16be()

uint16_t tlvp_val16be | ( | const struct tlv_parsed * | tp,
|  | int | pos )

inline static

Retrieve (possibly unaligned) TLV element and convert to host byte order.

Parameters

  [in] | tp | pointer to tlv_parsed
  [in] | pos | element to return

Returns
  aligned 16 bit value in host byte order

References TLVP_VAL.

Referenced by cbsp_dec_error_ind(), cbsp_dec_kill(), cbsp_dec_kill_compl(), cbsp_dec_kill_fail(), cbsp_dec_msg_status_query(), cbsp_dec_msg_status_query_compl(), cbsp_dec_msg_status_query_fail(), cbsp_dec_write_repl(), cbsp_dec_write_repl_compl(), and cbsp_dec_write_repl_fail().

## tlvp_val32_unal()

uint32_t tlvp_val32_unal | ( | const struct tlv_parsed * | tp,
|  | int | pos )

inline static

Align given TLV element with 32 bit value to an address that is a multiple of 4.

Parameters

  [in] | tp | pointer to tlv_parsed
  [in] | pos | element to return

Returns
  aligned 32 bit value

References TLVP_VAL.

## tlvp_val32be()

uint32_t tlvp_val32be | ( | const struct tlv_parsed * | tp,
|  | int | pos )

inline static

Retrieve (possibly unaligned) TLV element and convert to host byte order.

Parameters

  [in] | tp | pointer to tlv_parsed
  [in] | pos | element to return

Returns
  aligned 32 bit value in host byte order

References TLVP_VAL.

## tlvp_val8()

uint8_t tlvp_val8 | ( | const struct tlv_parsed * | tp,
|  | uint8_t | tag,
|  | uint8_t | default_val )

inline static

Obtain 1-byte TLV element.

Parameters

  [in] | tp | pointer to tlv_parsed
  [in] | tag | the Tag to look for
  [in] | default_val | default value to use if tag not available

Returns
  the 1st byte of value with a given tag or default_val if tag was not found

References TLVP_VAL_MINLEN.

Referenced by gsm0808_dec_lcls().

## tv16_put()

uint8_t * tv16_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint16_t | val )

inline static

put (append) a TV16 field

Parameters

  [in,out] | buf | data buffer
  [in] | tag | Tag value
  [in] | val | Value (in host byte order!)

Referenced by msgb_tv16_push(), and msgb_tv16_put().

## tv_fixed_put()

uint8_t * tv_fixed_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | unsigned int | len,
|  | const uint8_t * | val )

inline static

put (append) a TVfixed field

References len.

Referenced by msgb_tv_fixed_put().

## tv_put()

uint8_t * tv_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint8_t | val )

inline static

put (append) a TV field

Referenced by msgb_tv_push(), and msgb_tv_put().

## tvl_put()

uint8_t * tvl_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint16_t | len )

inline static

put (append) a TvL field (a TvLV with variable-size length, where the value part's length is already known, but will be put() later).

Returns
  pointer to the value's start position.

References len, tl16_put(), tl_put(), and TVLV_MAX_ONEBYTE.

Referenced by msgb_tvl_put().

## TVLV_GROSS_LEN()

uint16_t TVLV_GROSS_LEN | ( | uint16_t | len | ) |

inline static

gross length of a TVLV type field

References len, TL16V_GROSS_LEN, TLV_GROSS_LEN, and TVLV_MAX_ONEBYTE.

Referenced by msgb_tvl_put(), msgb_tvlv_push(), and msgb_tvlv_put().

## tvlv_put()

uint8_t * tvlv_put | ( | uint8_t * | buf,
|  | uint8_t | tag,
|  | uint16_t | len,
|  | const uint8_t * | val )

inline static

put (append) a TvLV field

References len, tl16v_put(), tlv_put(), and TVLV_MAX_ONEBYTE.

Referenced by msgb_tvlv_push(), and msgb_tvlv_put().

## v_put()

uint8_t * v_put | ( | uint8_t * | buf,
|  | uint8_t | val )

inline static

put (append) a V field

Referenced by msgb_v_put().

## vt_gan_put()

uint8_t * vt_gan_put | ( | uint8_t * | buf,
|  | uint16_t | tag )

inline static

put (append) a variable-length tag or variable-length length *

References TVLV_MAX_ONEBYTE.

Referenced by vtvl_gan_put().

## VTVL_GAN_GROSS_LEN()

uint16_t VTVL_GAN_GROSS_LEN | ( | uint16_t | tag,
|  | uint16_t | len )

inline static

gross length of vTvL header (tag+len)

References len, and TVLV_MAX_ONEBYTE.

Referenced by msgb_vtvl_gan_push().

## vtvl_gan_put()

uint8_t * vtvl_gan_put | ( | uint8_t * | buf,
|  | uint16_t | tag,
|  | uint16_t | len )

inline static

References len, and vt_gan_put().

Referenced by msgb_vtvl_gan_push(), and vtvlv_gan_put().

## VTVLV_GAN_GROSS_LEN()

uint16_t VTVLV_GAN_GROSS_LEN | ( | uint16_t | tag,
|  | uint16_t | len )

inline static

gross length of vTvLV (tag+len+val)

References len, TL16V_GROSS_LEN, TLV_GROSS_LEN, and TVLV_MAX_ONEBYTE.

Referenced by msgb_vtvlv_gan_push(), and msgb_vtvlv_gan_put().

## vtvlv_gan_put()

uint8_t * vtvlv_gan_put | ( | uint8_t * | buf,
|  | uint16_t | tag,
|  | uint16_t | len,
|  | const uint8_t * | val )

inline static

References len, and vtvl_gan_put().

Referenced by msgb_vtvlv_gan_push(), and msgb_vtvlv_gan_put().

## Variable Documentation

## ienamebuf

__thread char ienamebuf[32]

static

Referenced by osmo_tlv_prot_ie_name().

## msgnamebuf

__thread char msgnamebuf[32]

static

Referenced by osmo_tlv_prot_msg_name().

## tvlv_att_def [1/2]

struct tlv_definition tvlv_att_def

extern

Referenced by __attribute__().

## tvlv_att_def [2/2]

struct tlv_definition tvlv_att_def

Referenced by __attribute__().

## vtvlv_gan_att_def [1/2]

struct tlv_definition vtvlv_gan_att_def

extern

Referenced by __attribute__().

## vtvlv_gan_att_def [2/2]

struct tlv_definition vtvlv_gan_att_def

Referenced by __attribute__().