summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-04-25 15:20:51 +0200
committerHarald Welte <laforge@gnumonks.org>2016-04-29 13:10:37 +0200
commit85234a32db7ab91f9361d4a54bea9523e2c7a5b9 (patch)
tree87bc9fcb3733b6edb916b485dc6b42d39eca8d5e
parent842674b8b3d245a2eecb352eb89609ed44cb0832 (diff)
move osmo_shift_* / osmo_match_shift_* to libosmogsm
-rw-r--r--openbsc/include/openbsc/gprs_utils.h11
-rw-r--r--openbsc/src/gprs/gprs_utils.c173
-rw-r--r--openbsc/src/gprs/osmo_gsup_messages.c1
3 files changed, 0 insertions, 185 deletions
diff --git a/openbsc/include/openbsc/gprs_utils.h b/openbsc/include/openbsc/gprs_utils.h
index b5bee2b6a..603605c7a 100644
--- a/openbsc/include/openbsc/gprs_utils.h
+++ b/openbsc/include/openbsc/gprs_utils.h
@@ -42,15 +42,4 @@ int gprs_is_mi_imsi(const uint8_t *value, size_t value_len);
int gprs_parse_mi_tmsi(const uint8_t *value, size_t value_len, uint32_t *tmsi);
void gprs_parse_tmsi(const uint8_t *value, uint32_t *tmsi);
-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);
-
int gprs_ra_id_equals(const struct gprs_ra_id *id1, const struct gprs_ra_id *id2);
diff --git a/openbsc/src/gprs/gprs_utils.c b/openbsc/src/gprs/gprs_utils.c
index 7ed8c3f19..64ed9788d 100644
--- a/openbsc/src/gprs/gprs_utils.c
+++ b/openbsc/src/gprs/gprs_utils.c
@@ -266,179 +266,6 @@ void gprs_parse_tmsi(const uint8_t *value, uint32_t *tmsi)
*tmsi = ntohl(tmsi_be);
}
-/* TODO: Move shift functions to libosmocore */
-
-/*! Advance the data pointer, subtract length and assign value pointer
- * \param data pointer to the pointer to data
- * \param data_len pointer to size_t containing \arg data length
- * \param[in] len the length that we expect the fixed IE to hav
- * \param[out] value pointer to pointer of value part of IE
- * \returns length of IE value; negative in case of error
- */
-int osmo_shift_v_fixed(uint8_t **data, size_t *data_len,
- size_t len, uint8_t **value)
-{
- if (len > *data_len)
- goto fail;
-
- if (value)
- *value = *data;
-
- *data += len;
- *data_len -= len;
-
- return len;
-
-fail:
- *data += *data_len;
- *data_len = 0;
- return -1;
-}
-
-/*! Match tag, check length and assign value pointer
- * \param data pointer to the pointer to data
- * \param data_len pointer to size_t containing \arg data length
- * \param[in] tag the tag (IEI) that we expect at \arg data
- * \param[in] len the length that we expect the fixed IE to have
- * \param[out] value pointer to pointer of value part of IE
- * \returns length of IE value; negative in case of error
- */
-int osmo_match_shift_tv_fixed(uint8_t **data, size_t *data_len,
- uint8_t tag, size_t len,
- uint8_t **value)
-{
- size_t ie_len;
-
- if (*data_len == 0)
- goto fail;
-
- if ((*data)[0] != tag)
- return 0;
-
- if (len > *data_len - 1)
- goto fail;
-
- if (value)
- *value = *data + 1;
-
- ie_len = len + 1;
- *data += ie_len;
- *data_len -= ie_len;
-
- return ie_len;
-
-fail:
- *data += *data_len;
- *data_len = 0;
- return -1;
-}
-
-/*! Verify TLV header and advance data / subtract length
- * \param data pointer to the pointer to data
- * \param data_len pointer to size_t containing \arg data length
- * \param[in] expected_tag the tag (IEI) that we expect at \arg data
- * \param[out] value pointer to pointer of value part of IE
- * \param[out] value_len pointer to length of \arg value
- * \returns length of IE value; negative in case of error
- */
-int osmo_match_shift_tlv(uint8_t **data, size_t *data_len,
- uint8_t expected_tag, uint8_t **value,
- size_t *value_len)
-{
- int rc;
- uint8_t tag;
- uint8_t *old_data = *data;
- size_t old_data_len = *data_len;
-
- rc = osmo_shift_tlv(data, data_len, &tag, value, value_len);
-
- if (rc > 0 && tag != expected_tag) {
- *data = old_data;
- *data_len = old_data_len;
- return 0;
- }
-
- return rc;
-}
-
-/*! Extract TLV and advance data pointer + subtract length
- * \param data pointer to the pointer to data
- * \param data_len pointer to size_t containing \arg data lengt
- * \param[out] tag extract the tag (IEI) at start of \arg data
- * \param[out] value extracted pointer to value part of TLV
- * \param[out] value_len extracted length of \arg value
- * \returns number of bytes subtracted
- */
-int osmo_shift_tlv(uint8_t **data, size_t *data_len,
- uint8_t *tag, uint8_t **value, size_t *value_len)
-{
- size_t len;
- size_t ie_len;
-
- if (*data_len < 2)
- goto fail;
-
- len = (*data)[1];
- if (len > *data_len - 2)
- goto fail;
-
- if (tag)
- *tag = (*data)[0];
- if (value)
- *value = *data + 2;
- if (value_len)
- *value_len = len;
-
- ie_len = len + 2;
-
- *data += ie_len;
- *data_len -= ie_len;
-
- return ie_len;
-
-fail:
- *data += *data_len;
- *data_len = 0;
- return -1;
-}
-
-/*! Extract LV and advance data pointer + subtract length
- * \param data pointer to the pointer to data
- * \param data_len pointer to size_t containing \arg data lengt
- * \param[out] value extracted pointer to value part of TLV
- * \param[out] value_len extracted length of \arg value
- * \returns number of bytes subtracted
- */
-int osmo_shift_lv(uint8_t **data, size_t *data_len,
- uint8_t **value, size_t *value_len)
-{
- size_t len;
- size_t ie_len;
-
- if (*data_len < 1)
- goto fail;
-
- len = (*data)[0];
- if (len > *data_len - 1)
- goto fail;
-
- if (value)
- *value = *data + 1;
- if (value_len)
- *value_len = len;
-
- ie_len = len + 1;
- *data += ie_len;
- *data_len -= ie_len;
-
- return ie_len;
-
-fail:
- *data += *data_len;
- *data_len = 0;
- return -1;
-}
-
int gprs_ra_id_equals(const struct gprs_ra_id *id1,
const struct gprs_ra_id *id2)
{
diff --git a/openbsc/src/gprs/osmo_gsup_messages.c b/openbsc/src/gprs/osmo_gsup_messages.c
index 94eae35b9..773588b63 100644
--- a/openbsc/src/gprs/osmo_gsup_messages.c
+++ b/openbsc/src/gprs/osmo_gsup_messages.c
@@ -26,7 +26,6 @@
#include <openbsc/osmo_gsup_messages.h>
#include <openbsc/debug.h>
-#include <openbsc/gprs_utils.h>
#include <openbsc/utils.h>
#include <osmocom/gsm/tlv.h>