diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-01-04 16:34:16 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-01-04 19:56:39 +0100 |
commit | fc1a5538d0e155a4bebc6af6c400e7b6a39b4553 (patch) | |
tree | 8f2e81f50fbb7ab31175e77b0d03db9b92cb7ae5 | |
parent | eb967fccb2f9040459b20fc42ee4c52145a14cb5 (diff) |
Replace gprs_str_to_apn() with libosmocore API osmo_apn_from_str()
The exact same function exists in libosmocore with a different naming.
Change-Id: Ibef55a648f2d58f4fdd24fa553efde530982af2d
-rw-r--r-- | include/osmocom/sgsn/gprs_utils.h | 2 | ||||
-rw-r--r-- | src/gprs/gprs_utils.c | 34 | ||||
-rw-r--r-- | tests/sgsn/sgsn_test.c | 34 |
3 files changed, 17 insertions, 53 deletions
diff --git a/include/osmocom/sgsn/gprs_utils.h b/include/osmocom/sgsn/gprs_utils.h index 8a6731f12..1e6c8319c 100644 --- a/include/osmocom/sgsn/gprs_utils.h +++ b/include/osmocom/sgsn/gprs_utils.h @@ -29,8 +29,6 @@ struct msgb; struct gprs_ra_id; -int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str); - /* GSM 04.08, 10.5.7.3 GPRS Timer */ uint8_t gprs_secs_to_tmr_floor(int secs); diff --git a/src/gprs/gprs_utils.c b/src/gprs/gprs_utils.c index 9fddc73aa..46028c63c 100644 --- a/src/gprs/gprs_utils.c +++ b/src/gprs/gprs_utils.c @@ -30,40 +30,6 @@ #include <string.h> -int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str) -{ - uint8_t *last_len_field; - int len; - - /* Can we even write the length field to the output? */ - if (max_len == 0) - return -1; - - /* Remember where we need to put the length once we know it */ - last_len_field = apn_enc; - len = 1; - apn_enc += 1; - - while (str[0]) { - if (len >= max_len) - return -1; - - if (str[0] == '.') { - *last_len_field = (apn_enc - last_len_field) - 1; - last_len_field = apn_enc; - } else { - *apn_enc = str[0]; - } - apn_enc += 1; - str += 1; - len += 1; - } - - *last_len_field = (apn_enc - last_len_field) - 1; - - return len; -} - /* This functions returns a tmr value such that * - f is monotonic * - f(s) <= s diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c index a09f1a5b6..91a3dcf56 100644 --- a/tests/sgsn/sgsn_test.c +++ b/tests/sgsn/sgsn_test.c @@ -19,26 +19,26 @@ * */ +#include <osmocom/core/application.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/rate_ctr.h> +#include <osmocom/core/utils.h> +#include <osmocom/gsm/apn.h> +#include <osmocom/gsm/gsm_utils.h> +#include <osmocom/gsm/gsup.h> +#include <osmocom/gprs/gprs_bssgp.h> +#include <osmocom/vty/vty.h> + +#include <osmocom/gsupclient/gsup_client.h> + #include <osmocom/sgsn/gprs_llc.h> #include <osmocom/sgsn/sgsn.h> #include <osmocom/sgsn/gprs_gmm.h> #include <osmocom/sgsn/debug.h> #include <osmocom/sgsn/gprs_subscriber.h> -#include <osmocom/gsm/gsup.h> -#include <osmocom/gsupclient/gsup_client.h> #include <osmocom/sgsn/gprs_utils.h> #include <osmocom/sgsn/gprs_gmm_fsm.h> -#include <osmocom/gprs/gprs_bssgp.h> - -#include <osmocom/gsm/gsm_utils.h> - -#include <osmocom/core/application.h> -#include <osmocom/core/msgb.h> -#include <osmocom/core/rate_ctr.h> -#include <osmocom/core/utils.h> -#include <osmocom/vty/vty.h> - #include <stdio.h> #include "gprs_gb_parse.h" @@ -1492,7 +1492,7 @@ static void test_ggsn_selection(void) /* Resolve GGSNs */ tp.lv[GSM48_IE_GSM_APN].len = - gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Test.Apn"); + osmo_apn_from_str(apn_enc, sizeof(apn_enc), "Test.Apn"); ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str); OSMO_ASSERT(ggc != NULL); @@ -1500,7 +1500,7 @@ static void test_ggsn_selection(void) OSMO_ASSERT(strcmp(apn_str, "Test.Apn") == 0); tp.lv[GSM48_IE_GSM_APN].len = - gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Other.Apn"); + osmo_apn_from_str(apn_enc, sizeof(apn_enc), "Other.Apn"); ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str); OSMO_ASSERT(ggc != NULL); @@ -1526,7 +1526,7 @@ static void test_ggsn_selection(void) tp.lv[GSM48_IE_GSM_APN].val = apn_enc; tp.lv[GSM48_IE_GSM_APN].len = - gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Foo.Bar"); + osmo_apn_from_str(apn_enc, sizeof(apn_enc), "Foo.Bar"); ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str); OSMO_ASSERT(ggc == NULL); @@ -1543,7 +1543,7 @@ static void test_ggsn_selection(void) osmo_strlcpy(pdp_data->apn_str, "Test.Apn", sizeof(pdp_data->apn_str)); tp.lv[GSM48_IE_GSM_APN].len = - gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Test.Apn"); + osmo_apn_from_str(apn_enc, sizeof(apn_enc), "Test.Apn"); ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str); OSMO_ASSERT(ggc != NULL); @@ -1551,7 +1551,7 @@ static void test_ggsn_selection(void) OSMO_ASSERT(strcmp(apn_str, "Test.Apn") == 0); tp.lv[GSM48_IE_GSM_APN].len = - gprs_str_to_apn(apn_enc, sizeof(apn_enc), "Other.Apn"); + osmo_apn_from_str(apn_enc, sizeof(apn_enc), "Other.Apn"); ggc = sgsn_mm_ctx_find_ggsn_ctx(ctx, &tp, &gsm_cause, apn_str); OSMO_ASSERT(ggc == NULL); |