This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/21227 )
Change subject: gprs_gb_parse: Add function to determine TLLI from encoded BSSGP
......................................................................
gprs_gb_parse: Add function to determine TLLI from encoded BSSGP
This will be needed to use the TLLI as link selector parameter
in osmo-gbproxy in an upcoming patch.
Depends: libosmocore.git I397b32a6e6ea3e9d218446138cceafa9b27685dd
Change-Id: Ia6d5300e63ad23987cbdca824db620305bd583d7
---
M include/osmocom/sgsn/gprs_gb_parse.h
M src/gprs/gprs_gb_parse.c
2 files changed, 51 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/27/21227/1
diff --git a/include/osmocom/sgsn/gprs_gb_parse.h b/include/osmocom/sgsn/gprs_gb_parse.h
index 9f43fae..58de17f 100644
--- a/include/osmocom/sgsn/gprs_gb_parse.h
+++ b/include/osmocom/sgsn/gprs_gb_parse.h
@@ -51,6 +51,8 @@
int gprs_gb_parse_bssgp(uint8_t *bssgp, size_t bssgp_len,
struct gprs_gb_parse_context *parse_ctx);
+int gprs_gb_parse_tlli(const uint8_t *bssgp, size_t bssgp_len, uint32_t *tlli);
+
const char *gprs_gb_message_name(const struct gprs_gb_parse_context *parse_ctx,
const char *default_msg_name);
diff --git a/src/gprs/gprs_gb_parse.c b/src/gprs/gprs_gb_parse.c
index e5de4d4..779cbfc 100644
--- a/src/gprs/gprs_gb_parse.c
+++ b/src/gprs/gprs_gb_parse.c
@@ -437,6 +437,55 @@
return gprs_gb_parse_dtap(ghp->data, ghp->data_len, parse_ctx);
}
+/*! Determine the TLLI from the given BSSGP message.
+ * \param[in] bssgp pointer to start of BSSGP header
+ * \param[in] bssgp_len length of BSSGP message in octets
+ * \param[out] tlli TLLI (if any) in host byte order
+ * \returns 1 if TLLI found; 0 if none found; negative on parse error */
+int gprs_gb_parse_tlli(const uint8_t *bssgp, size_t bssgp_len, uint32_t *tlli)
+{
+ const struct bssgp_normal_hdr *bgph;
+ const struct bssgp_ud_hdr *budh = NULL;
+ struct tlv_parsed tp;
+ uint8_t pdu_type;
+ const uint8_t *data;
+ size_t data_len;
+
+ if (bssgp_len < sizeof(struct bssgp_normal_hdr))
+ return -EINVAL;
+
+ bgph = (struct bssgp_normal_hdr *)bssgp;
+ pdu_type = bgph->pdu_type;
+
+ if (pdu_type == BSSGP_PDUT_UL_UNITDATA ||
+ pdu_type == BSSGP_PDUT_DL_UNITDATA) {
+ if (bssgp_len < sizeof(struct bssgp_ud_hdr))
+ return -EINVAL;
+ budh = (struct bssgp_ud_hdr *)bssgp;
+ bgph = NULL;
+ data = budh->data;
+ data_len = bssgp_len - sizeof(*budh);
+ } else {
+ data = bgph->data;
+ data_len = bssgp_len - sizeof(*bgph);
+ }
+ if (budh) {
+ *tlli = osmo_load32be((const uint8_t *)&budh->tlli);
+ return 1;
+ }
+
+ if (bssgp_tlv_parse(&tp, data, data_len) < 0)
+ return -EINVAL;
+
+ if (TLVP_PRESENT(&tp, BSSGP_IE_TLLI)) {
+ *tlli = osmo_load32be(TLVP_VAL(&tp, BSSGP_IE_TLLI));
+ return 1;
+ }
+
+ /* No TLLI present in message */
+ return 0;
+}
+
int gprs_gb_parse_bssgp(uint8_t *bssgp, size_t bssgp_len,
struct gprs_gb_parse_context *parse_ctx)
{
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/21227
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: Ia6d5300e63ad23987cbdca824db620305bd583d7
Gerrit-Change-Number: 21227
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201118/09c2a78f/attachment.htm>