libosmogsm
0.12.0.47-7c74
Osmocom GSM library
|
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... | |
Macros | |
#define | LV_GROSS_LEN(x) (x+1) |
gross length of a LV type field More... | |
#define | TLV_GROSS_LEN(x) (x+2) |
gross length of a TLV type field More... | |
#define | TLV16_GROSS_LEN(x) ((2*x)+2) |
gross length of a TLV16 type field More... | |
#define | TL16V_GROSS_LEN(x) (x+3) |
gross length of a TL16V type field More... | |
#define | L16TV_GROSS_LEN(x) (x+3) |
gross length of a L16TV type field More... | |
#define | T16LV_GROSS_LEN(x) (x+3) |
gross length of a T16LV type field More... | |
#define | TVLV_MAX_ONEBYTE 0x7f |
maximum length of TLV of one byte length More... | |
#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) |
Return pointer to a TLV element if it is present. More... | |
#define | TLVP_GET_MINLEN(_tp, tag, min_len) (TLVP_PRES_LEN(_tp, tag, min_len)? &(_tp)->lv[tag] : NULL) |
Like TLVP_GET(), but enforcing a minimum val length. More... | |
#define | TLVP_VAL_MINLEN(_tp, tag, min_len) (TLVP_PRES_LEN(_tp, tag, min_len)? (_tp)->lv[tag].val : NULL) |
Like TLVP_VAL(), but enforcing a minimum val length. More... | |
Enumerations | |
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 More... | |
static uint16_t | VTVL_GAN_GROSS_LEN (uint16_t tag, uint16_t len) |
gross length of vTvL header (tag+len) More... | |
static uint16_t | VTVLV_GAN_GROSS_LEN (uint16_t tag, uint16_t len) |
gross length of vTvLV (tag+len+val) More... | |
static uint8_t * | lv_put (uint8_t *buf, uint8_t len, const uint8_t *val) |
put (append) a LV field More... | |
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. More... | |
static uint8_t * | tlv16_put (uint8_t *buf, uint8_t tag, uint8_t len, const uint16_t *val) |
put (append) a TLV16 field More... | |
static uint8_t * | tl16v_put (uint8_t *buf, uint8_t tag, uint16_t len, const uint8_t *val) |
put (append) a TL16V field More... | |
static uint8_t * | t16lv_put (uint8_t *buf, uint16_t tag, uint8_t len, const uint8_t *val) |
put (append) a TL16V field More... | |
static uint8_t * | tvlv_put (uint8_t *buf, uint8_t tag, uint16_t len, const uint8_t *val) |
put (append) a TvLV field More... | |
static uint8_t * | vt_gan_put (uint8_t *buf, uint16_t tag) |
put (append) a variable-length tag or variable-length length * More... | |
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 More... | |
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 More... | |
static uint8_t * | msgb_t16lv_put (struct msgb *msg, uint16_t tag, uint8_t len, const uint8_t *val) |
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 More... | |
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 More... | |
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 More... | |
static uint8_t * | v_put (uint8_t *buf, uint8_t val) |
put (append) a V field More... | |
static uint8_t * | tv_put (uint8_t *buf, uint8_t tag, uint8_t val) |
put (append) a TV field More... | |
static uint8_t * | tv_fixed_put (uint8_t *buf, uint8_t tag, unsigned int len, const uint8_t *val) |
put (append) a TVfixed field More... | |
static uint8_t * | tv16_put (uint8_t *buf, uint8_t tag, uint16_t val) |
put (append) a TV16 field More... | |
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 More... | |
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 More... | |
static uint8_t * | msgb_tv_put (struct msgb *msg, uint8_t tag, uint8_t val) |
put (append) a TV field to a Message buffers More... | |
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 More... | |
static uint8_t * | msgb_v_put (struct msgb *msg, uint8_t val) |
put (append) a V field to a Message buffers More... | |
static uint8_t * | msgb_tv16_put (struct msgb *msg, uint8_t tag, uint16_t val) |
put (append) a TV16 field to a Message buffers More... | |
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 More... | |
static uint8_t * | msgb_tv_push (struct msgb *msg, uint8_t tag, uint8_t val) |
push (prepend) a TV field to a Message buffers More... | |
static uint8_t * | msgb_tv16_push (struct msgb *msg, uint8_t tag, uint16_t val) |
push (prepend) a TV16 field to a Message buffers More... | |
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 More... | |
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. More... | |
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. More... | |
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. More... | |
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' More... | |
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. More... | |
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. More... | |
static uint16_t | tlvp_val16be (const struct tlv_parsed *tp, int pos) |
Retrieve (possibly unaligned) TLV element and convert to host byte order. More... | |
static uint32_t | tlvp_val32be (const struct tlv_parsed *tp, int pos) |
Retrieve (possibly unaligned) TLV element and convert to host byte order. More... | |
struct tlv_parsed * | osmo_tlvp_copy (const struct tlv_parsed *tp_orig, void *ctx) |
Copy tlv_parsed using given talloc context. More... | |
int | osmo_tlvp_merge (struct tlv_parsed *dst, const struct tlv_parsed *src) |
Merge all tlv_parsed attributes of 'src' into 'dst'. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | tlv_dump (struct tlv_parsed *dec) |
Dump parsed TLV structure to stdout. More... | |
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 |
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.
#define L16TV_GROSS_LEN | ( | x | ) | (x+3) |
gross length of a L16TV type field
Referenced by msgb_l16tv_put().
#define LV_GROSS_LEN | ( | x | ) | (x+1) |
gross length of a LV type field
Referenced by msgb_lv_put().
#define T16LV_GROSS_LEN | ( | x | ) | (x+3) |
gross length of a T16LV type field
Referenced by msgb_t16lv_put().
#define TL16V_GROSS_LEN | ( | x | ) | (x+3) |
gross length of a TL16V type field
Referenced by msgb_tl16v_put(), TVLV_GROSS_LEN(), and VTVLV_GAN_GROSS_LEN().
#define TLV16_GROSS_LEN | ( | x | ) | ((2*x)+2) |
gross length of a TLV16 type field
Referenced by msgb_tlv16_put().
#define TLV_GROSS_LEN | ( | x | ) | (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().
#define TLVP_GET | ( | _tp, | |
tag | |||
) | (TLVP_PRESENT(_tp, tag)? &(_tp)->lv[tag] : NULL) |
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);
[in] | _tp | pointer to tlv_parsed. |
[in] | tag | IE tag to return. |
#define TLVP_GET_MINLEN | ( | _tp, | |
tag, | |||
min_len | |||
) | (TLVP_PRES_LEN(_tp, tag, min_len)? &(_tp)->lv[tag] : NULL) |
Like TLVP_GET(), but enforcing a minimum val length.
[in] | _tp | pointer to tlv_parsed. |
[in] | tag | IE tag to return. |
[in] | min_len | Minimum value length in bytes. |
#define TLVP_LEN | ( | x, | |
y | |||
) | (x)->lv[y].len |
#define TLVP_PRES_LEN | ( | tp, | |
tag, | |||
min_len | |||
) | (TLVP_PRESENT(tp, tag) && TLVP_LEN(tp, tag) >= min_len) |
Referenced by ipa_ccm_tlv_to_unitdata().
#define TLVP_PRESENT | ( | x, | |
y | |||
) | ((x)->lv[y].val) |
#define TLVP_VAL | ( | x, | |
y | |||
) | (x)->lv[y].val |
#define TLVP_VAL_MINLEN | ( | _tp, | |
tag, | |||
min_len | |||
) | (TLVP_PRES_LEN(_tp, tag, min_len)? (_tp)->lv[tag].val : NULL) |
Like TLVP_VAL(), but enforcing a minimum val length.
[in] | _tp | pointer to tlv_parsed. |
[in] | tag | IE tag to return. |
[in] | min_len | Minimum value length in bytes. |
#define TVLV_MAX_ONEBYTE 0x7f |
maximum length of TLV of one byte length
Referenced by TVLV_GROSS_LEN(), tvlv_put(), vt_gan_put(), VTVL_GAN_GROSS_LEN(), and VTVLV_GAN_GROSS_LEN().
enum tlv_type |
TLV type.
|
static |
References ARRAY_SIZE, tlv_definition::def, TLV_TYPE_TvLV, TLV_TYPE_vTvLV_GAN, tvlv_att_def, tlv_def::type, and vtvlv_gan_att_def.
|
inlinestatic |
|
inlinestatic |
put (append) a L16TV field to Message buffers
References L16TV_GROSS_LEN, len, and msgb_put().
|
inlinestatic |
put (append) a LV field to a Message buffers
References LV_GROSS_LEN, lv_put(), and msgb_put().
Referenced by gsm48_encode_bearer_cap(), gsm48_encode_cause(), gsm48_encode_facility(), gsm48_encode_progress(), and gsm48_encode_useruser().
|
inlinestatic |
References msgb_put(), T16LV_GROSS_LEN, and t16lv_put().
|
inlinestatic |
put (append) a TL16V field to Message buffers
References msgb_put(), TL16V_GROSS_LEN, and tl16v_put().
Referenced by abis_nm_fail_evt_vrep(), and abis_nm_put_sw_desc().
|
inlinestatic |
put (append) a TLV16 field to Message buffers
References msgb_put(), TLV16_GROSS_LEN, and tlv16_put().
|
inlinestatic |
push (prepend) a TLV field to a Message buffers
References msgb_push(), TLV_GROSS_LEN, and tlv_put().
|
inlinestatic |
put (append) a TLV field to a Message buffers
References msgb_put(), TLV_GROSS_LEN, and tlv_put().
Referenced by encode_auth_info(), encode_pdp_info(), gsm0808_create_ass_fail(), gsm0808_create_cipher_complete(), gsm0808_create_cipher_reject(), gsm0808_create_classmark_update(), gsm0808_create_clear_command(), gsm0808_create_clear_complete(), gsm0808_create_clear_rqst(), gsm0808_create_handover_complete(), gsm0808_create_handover_failure(), gsm0808_create_handover_request_ack(), gsm0808_create_handover_required(), gsm0808_create_layer3_2(), gsm0808_create_paging2(), gsm0808_create_reset(), 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(), osmo_gsup_encode(), osmo_oap_encode(), put_old_bss_to_new_bss_information(), and rsl_rll_error().
|
inlinestatic |
push (prepend) a TV16 field to a Message buffers
References msgb_push(), and tv16_put().
Referenced by rsl_rll_push_l3(), and send_rslms_rll_l3_ui().
|
inlinestatic |
put (append) a TV16 field to a Message buffers
References msgb_put(), and tv16_put().
|
inlinestatic |
put (append) a TVfixed field to a Message buffers
References msgb_put(), and tv_fixed_put().
Referenced by abis_nm_fail_evt_vrep(), gsm0808_create_ass(), gsm0808_create_handover_required(), and l2_ph_rach_ind().
|
inlinestatic |
push (prepend) a TV field to a Message buffers
References msgb_push(), and tv_put().
Referenced by gsm0808_create_ass(), gsm0808_create_ass_compl(), gsm0808_create_ass_fail(), gsm0808_create_cipher(), gsm0808_create_cipher_complete(), gsm0808_create_cipher_reject(), gsm0808_create_classmark_update(), gsm0808_create_clear_rqst(), gsm0808_create_handover_complete(), gsm0808_create_handover_detect(), gsm0808_create_handover_failure(), gsm0808_create_handover_request_ack(), gsm0808_create_handover_required(), gsm0808_create_layer3_2(), gsm0808_create_lcls_conn_ctrl(), gsm0808_create_lcls_conn_ctrl_ack(), gsm0808_create_lcls_notification(), gsm0808_create_paging2(), gsm0808_create_reset(), gsm0808_create_reset_ack(), gsm0808_create_sapi_reject(), and send_rslms_rll_l3_ui().
|
inlinestatic |
put (append) a TV field to a Message buffers
References msgb_put(), and tv_put().
Referenced by abis_nm_fail_evt_vrep(), gsm0808_create_ass_compl(), gsm0808_create_ass_fail(), gsm0808_create_cipher(), gsm0808_create_cipher_complete(), gsm0808_create_clear_command(), gsm0808_create_handover_complete(), gsm0808_create_handover_request_ack(), gsm0808_create_lcls_conn_ctrl(), gsm0808_create_lcls_conn_ctrl_ack(), gsm0808_create_lcls_notification(), gsm0808_create_paging2(), gsm411_send_abort(), gsm411_send_rp_error(), gsm48_encode_keypad(), gsm48_encode_signal(), and l2_ph_rach_ind().
|
inlinestatic |
push (prepend) a TvLV field to a Message buffers
References msgb_push(), TVLV_GROSS_LEN(), and tvlv_put().
|
inlinestatic |
put (append) a TvLV field to Message buffers
References msgb_put(), TVLV_GROSS_LEN(), and tvlv_put().
|
inlinestatic |
put (append) a V field to a Message buffers
References msgb_put(), and v_put().
Referenced by abis_nm_put_sw_desc(), gsm0808_create_ass(), gsm0808_create_ass_compl(), gsm0808_create_ass_fail(), gsm0808_create_cipher(), gsm0808_create_cipher_complete(), gsm0808_create_cipher_reject(), gsm0808_create_classmark_update(), gsm0808_create_clear_command(), gsm0808_create_clear_rqst(), gsm0808_create_handover_complete(), gsm0808_create_handover_detect(), gsm0808_create_handover_failure(), gsm0808_create_handover_request_ack(), gsm0808_create_handover_required(), gsm0808_create_layer3_2(), gsm0808_create_lcls_conn_ctrl(), gsm0808_create_lcls_conn_ctrl_ack(), gsm0808_create_lcls_notification(), gsm0808_create_paging2(), gsm0808_create_reset(), gsm0808_create_reset_ack(), gsm0808_create_sapi_reject(), gsm48_encode_notify(), osmo_gsup_encode(), and osmo_oap_encode().
|
inlinestatic |
References msgb_push(), VTVL_GAN_GROSS_LEN(), and vtvl_gan_put().
|
inlinestatic |
References msgb_push(), VTVLV_GAN_GROSS_LEN(), and vtvlv_gan_put().
|
inlinestatic |
put (append) a vTvLV field to Message buffers
References msgb_put(), VTVLV_GAN_GROSS_LEN(), and vtvlv_gan_put().
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.
data | pointer to the pointer to data | |
data_len | pointer to size_t containing
| |
[in] | expected_tag | the tag (IEI) that we expect at
|
[out] | value | pointer to pointer of value part of IE |
[out] | value_len | pointer to length of
|
References data, and osmo_shift_tlv().
Referenced by osmo_gsup_decode(), and tlvp_val32be().
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.
data | pointer to the pointer to data | |
data_len | pointer to size_t containing
| |
[in] | tag | the tag (IEI) that we expect at
|
[in] | len | the length that we expect the fixed IE to have |
[out] | value | pointer to pointer of value part of IE |
Referenced by tlvp_val32be().
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.
data | pointer to the pointer to data | |
data_len | pointer to size_t containing
| |
[out] | value | extracted pointer to value part of TLV |
[out] | value_len | extracted length of
|
References len.
Referenced by tlvp_val32be().
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.
data | pointer to the pointer to data | |
data_len | pointer to size_t containing
| |
[out] | tag | extract the tag (IEI) at start of
|
[out] | value | extracted pointer to value part of TLV |
[out] | value_len | extracted length of
|
References len.
Referenced by decode_auth_info(), decode_pdp_info(), osmo_gsup_decode(), osmo_match_shift_tlv(), osmo_oap_decode(), and tlvp_val32be().
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.
data | pointer to the pointer to data | |
data_len | pointer to size_t containing
| |
[in] | len | the length that we expect the fixed IE to hav |
[out] | value | pointer to pointer of value part of IE |
Referenced by osmo_gsup_decode(), osmo_oap_decode(), and tlvp_val32be().
struct tlv_parsed * osmo_tlvp_copy | ( | const struct tlv_parsed * | tp_orig, |
void * | ctx | ||
) |
Copy tlv_parsed using given talloc context.
[in] | tp_orig | Parsed TLV structure |
[in] | ctx | Talloc context for allocations |
References ARRAY_SIZE, tlv_p_entry::len, len, tlv_parsed::lv, and tlv_p_entry::val.
Referenced by tlvp_val32be().
int osmo_tlvp_merge | ( | struct tlv_parsed * | dst, |
const struct tlv_parsed * | src | ||
) |
Merge all tlv_parsed attributes of 'src' into 'dst'.
[in] | dst | Parsed TLV structure to merge into |
[in] | src | Parsed TLV structure to merge from |
References ARRAY_SIZE, tlv_p_entry::len, len, tlv_parsed::lv, and tlv_p_entry::val.
Referenced by tlvp_val32be().
|
inlinestatic |
|
inlinestatic |
put (append) a TL16V field
Referenced by msgb_tl16v_put(), and tvlv_put().
|
inlinestatic |
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'
dst | TLV parser definition that is to be patched | |
[in] | src | TLV parser definition whose content is patched into dst |
References ARRAY_SIZE, tlv_definition::def, TLV_TYPE_NONE, and tlv_def::type.
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.
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().
[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 |
References tlv_parse2().
Referenced by abis_nm_get_sw_desc().
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.
[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 |
References tlv_p_entry::len, len, tlv_parsed::lv, tlv_parse_one(), and tlv_p_entry::val.
Referenced by tlv_parse().
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.
[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 |
References tlv_definition::def, tlv_def::fixed_len, len, 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().
|
inlinestatic |
Append a TLV field, a Tag-Length-Value field.
[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().
|
inlinestatic |
Align given TLV element with 16 bit value to an even address.
[in] | tp | pointer to tlv_parsed |
[in] | pos | element to return |
|
inlinestatic |
Retrieve (possibly unaligned) TLV element and convert to host byte order.
[in] | tp | pointer to tlv_parsed |
[in] | pos | element to return |
References TLVP_VAL.
|
inlinestatic |
Align given TLV element with 32 bit value to an address that is a multiple of 4.
[in] | tp | pointer to tlv_parsed |
[in] | pos | element to return |
|
inlinestatic |
Retrieve (possibly unaligned) TLV element and convert to host byte order.
[in] | tp | pointer to tlv_parsed |
[in] | pos | element to return |
References data, tlv_p_entry::len, osmo_match_shift_tlv(), osmo_match_shift_tv_fixed(), osmo_shift_lv(), osmo_shift_tlv(), osmo_shift_v_fixed(), osmo_tlvp_copy(), osmo_tlvp_merge(), and TLVP_VAL.
|
inlinestatic |
put (append) a TV16 field
[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().
|
inlinestatic |
|
inlinestatic |
put (append) a TV field
Referenced by msgb_tv_push(), and msgb_tv_put().
|
inlinestatic |
gross length of a TVLV type field
References TL16V_GROSS_LEN, TLV_GROSS_LEN, and TVLV_MAX_ONEBYTE.
Referenced by msgb_tvlv_push(), and msgb_tvlv_put().
|
inlinestatic |
put (append) a TvLV field
References tl16v_put(), tlv_put(), and TVLV_MAX_ONEBYTE.
Referenced by msgb_tvlv_push(), and msgb_tvlv_put().
|
inlinestatic |
put (append) a V field
Referenced by msgb_v_put().
|
inlinestatic |
put (append) a variable-length tag or variable-length length *
References TVLV_MAX_ONEBYTE.
Referenced by vtvl_gan_put().
|
inlinestatic |
gross length of vTvL header (tag+len)
References TVLV_MAX_ONEBYTE.
Referenced by msgb_vtvl_gan_push().
|
inlinestatic |
References vt_gan_put().
Referenced by msgb_vtvl_gan_push(), and vtvlv_gan_put().
|
inlinestatic |
gross length of vTvLV (tag+len+val)
References TL16V_GROSS_LEN, TLV_GROSS_LEN, and TVLV_MAX_ONEBYTE.
Referenced by msgb_vtvlv_gan_push(), and msgb_vtvlv_gan_put().
|
inlinestatic |
References len, and vtvl_gan_put().
Referenced by msgb_vtvlv_gan_push(), and msgb_vtvlv_gan_put().
struct tlv_definition tvlv_att_def |
Referenced by __attribute__().
struct tlv_definition tvlv_att_def |
Referenced by __attribute__().
struct tlv_definition vtvlv_gan_att_def |
Referenced by __attribute__().
struct tlv_definition vtvlv_gan_att_def |
Referenced by __attribute__().