aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2010-07-12 08:55:14 +0200
committerHarald Welte <laforge@gnumonks.org>2010-07-12 08:55:14 +0200
commitcd2a74bd43883e98c6a4f54bbf43a1915c83d483 (patch)
tree53b2e8978a57f9b95132ff214a75b82ec66e951b
parente10ae5b083fee8c91b7c8275aab72061280753e9 (diff)
Added single octet TV (type + value) to libosmocore.
In case of a single octet, the upper nibble is the type, the lower nibble carries the value. [import from accidentially committed changes to osmocom-bb.git] diff --git a/src/shared/libosmocore/include/osmocore/tlv.h b/src/shared/libosmocore/include/osmocore/tlv.h index c733dbc..4cfce87 100644 --- a/src/shared/libosmocore/include/osmocore/tlv.h +++ b/src/shared/libosmocore/include/osmocore/tlv.h @@ -212,6 +212,7 @@ enum tlv_type { TLV_TYPE_TLV, TLV_TYPE_TL16V, TLV_TYPE_TvLV, + TLV_TYPE_SINGLE_TV }; struct tlv_def { diff --git a/src/shared/libosmocore/src/tlv_parser.c b/src/shared/libosmocore/src/tlv_parser.c index 407e57a..bbef7a9 100644 --- a/src/shared/libosmocore/src/tlv_parser.c +++ b/src/shared/libosmocore/src/tlv_parser.c @@ -36,6 +36,14 @@ int tlv_parse_one(uint8_t *o_tag, uint16_t *o_len, const uint8_t **o_val, tag = *buf; *o_tag = tag; + /* single octet TV IE */ + if (def->def[tag & 0xf0].type == TLV_TYPE_SINGLE_TV) { + *o_tag = tag & 0xf0; + *o_val = buf; + *o_len = 1; + return 1; + } + /* FIXME: use tables for knwon IEI */ switch (def->def[tag].type) { case TLV_TYPE_T:
-rw-r--r--include/osmocore/tlv.h1
-rw-r--r--src/tlv_parser.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/include/osmocore/tlv.h b/include/osmocore/tlv.h
index c733dbc9..4cfce872 100644
--- a/include/osmocore/tlv.h
+++ b/include/osmocore/tlv.h
@@ -212,6 +212,7 @@ enum tlv_type {
TLV_TYPE_TLV,
TLV_TYPE_TL16V,
TLV_TYPE_TvLV,
+ TLV_TYPE_SINGLE_TV
};
struct tlv_def {
diff --git a/src/tlv_parser.c b/src/tlv_parser.c
index 407e57aa..bbef7a9a 100644
--- a/src/tlv_parser.c
+++ b/src/tlv_parser.c
@@ -36,6 +36,14 @@ int tlv_parse_one(uint8_t *o_tag, uint16_t *o_len, const uint8_t **o_val,
tag = *buf;
*o_tag = tag;
+ /* single octet TV IE */
+ if (def->def[tag & 0xf0].type == TLV_TYPE_SINGLE_TV) {
+ *o_tag = tag & 0xf0;
+ *o_val = buf;
+ *o_len = 1;
+ return 1;
+ }
+
/* FIXME: use tables for knwon IEI */
switch (def->def[tag].type) {
case TLV_TYPE_T: