diff options
Diffstat (limited to 'src/gprs')
-rw-r--r-- | src/gprs/gb_proxy_patch.c | 7 | ||||
-rw-r--r-- | src/gprs/gb_proxy_vty.c | 3 | ||||
-rw-r--r-- | src/gprs/gprs_sgsn.c | 3 | ||||
-rw-r--r-- | src/gprs/gprs_subscriber.c | 3 | ||||
-rw-r--r-- | src/gprs/gprs_utils.c | 28 | ||||
-rw-r--r-- | src/gprs/gtphub.c | 4 | ||||
-rw-r--r-- | src/gprs/sgsn_cdr.c | 3 | ||||
-rw-r--r-- | src/gprs/sgsn_vty.c | 17 |
8 files changed, 17 insertions, 51 deletions
diff --git a/src/gprs/gb_proxy_patch.c b/src/gprs/gb_proxy_patch.c index 7bddc4494..210fb2b96 100644 --- a/src/gprs/gb_proxy_patch.c +++ b/src/gprs/gb_proxy_patch.c @@ -28,6 +28,7 @@ #include <osmocom/gprs/protocol/gsm_08_18.h> #include <osmocom/core/rate_ctr.h> +#include <osmocom/gsm/apn.h> /* patch RA identifier in place */ static void gbproxy_patch_raid(uint8_t *raid_enc, struct gbproxy_peer *peer, @@ -101,7 +102,7 @@ static void gbproxy_patch_apn_ie(struct msgb *msg, LOGP(DGPRS, LOGL_DEBUG, "Patching %s to SGSN: Removing APN '%s'\n", log_text, - gprs_apn_to_str(str1, apn, apn_len)); + osmo_apn_to_str(str1, apn, apn_len)); *new_apn_ie_len = 0; gprs_msgb_resize_area(msg, apn_ie, apn_ie_len, 0); @@ -116,8 +117,8 @@ static void gbproxy_patch_apn_ie(struct msgb *msg, "Patching %s to SGSN: " "Replacing APN '%s' -> '%s'\n", log_text, - gprs_apn_to_str(str1, apn, apn_len), - gprs_apn_to_str(str2, peer->cfg->core_apn, + osmo_apn_to_str(str1, apn, apn_len), + osmo_apn_to_str(str2, peer->cfg->core_apn, peer->cfg->core_apn_size)); *new_apn_ie_len = peer->cfg->core_apn_size + 2; diff --git a/src/gprs/gb_proxy_vty.c b/src/gprs/gb_proxy_vty.c index 933b6b010..86d65a8e3 100644 --- a/src/gprs/gb_proxy_vty.c +++ b/src/gprs/gb_proxy_vty.c @@ -29,6 +29,7 @@ #include <openbsc/gsm_04_08.h> #include <osmocom/gprs/gprs_ns.h> +#include <osmocom/gsm/apn.h> #include <openbsc/debug.h> #include <openbsc/gb_proxy.h> @@ -107,7 +108,7 @@ static int config_write_gbproxy(struct vty *vty) if (g_cfg->core_apn_size > 0) { char str[500] = {0}; vty_out(vty, " core-access-point-name %s%s", - gprs_apn_to_str(str, g_cfg->core_apn, + osmo_apn_to_str(str, g_cfg->core_apn, g_cfg->core_apn_size), VTY_NEWLINE); } else { diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c index 93b133f3b..43eeaaa9b 100644 --- a/src/gprs/gprs_sgsn.c +++ b/src/gprs/gprs_sgsn.c @@ -30,6 +30,7 @@ #include <osmocom/gprs/gprs_ns.h> #include <osmocom/gprs/gprs_bssgp.h> #include <osmocom/gsm/protocol/gsm_04_08_gprs.h> +#include <osmocom/gsm/apn.h> #include <openbsc/gprs_subscriber.h> #include <openbsc/debug.h> @@ -758,7 +759,7 @@ struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx, return NULL; } - gprs_apn_to_str(req_apn_str, + osmo_apn_to_str(req_apn_str, TLVP_VAL(tp, GSM48_IE_GSM_APN), TLVP_LEN(tp, GSM48_IE_GSM_APN)); diff --git a/src/gprs/gprs_subscriber.c b/src/gprs/gprs_subscriber.c index aa03509a5..94297d0d6 100644 --- a/src/gprs/gprs_subscriber.c +++ b/src/gprs/gprs_subscriber.c @@ -22,6 +22,7 @@ #include <osmocom/gsm/protocol/gsm_04_08_gprs.h> #include <osmocom/gsm/gsup.h> +#include <osmocom/gsm/apn.h> #include <osmocom/core/utils.h> #include <osmocom/core/logging.h> #include <openbsc/gprs_subscriber.h> @@ -371,7 +372,7 @@ static void gprs_subscr_gsup_insert_data(struct gprs_subscr *subscr, OSMO_ASSERT(pdp_data != NULL); pdp_data->pdp_type = pdp_info->pdp_type; - gprs_apn_to_str(pdp_data->apn_str, + osmo_apn_to_str(pdp_data->apn_str, pdp_info->apn_enc, pdp_info->apn_enc_len); memcpy(pdp_data->qos_subscribed, pdp_info->qos_enc, pdp_info->qos_enc_len); pdp_data->qos_subscribed_len = pdp_info->qos_enc_len; diff --git a/src/gprs/gprs_utils.c b/src/gprs/gprs_utils.c index 64ed9788d..91a09d2db 100644 --- a/src/gprs/gprs_utils.c +++ b/src/gprs/gprs_utils.c @@ -114,34 +114,6 @@ int gprs_msgb_resize_area(struct msgb *msg, uint8_t *area, return 0; } -/* TODO: Move these conversion functions to a utils file. */ -/* TODO: consolidate with gprs_apn2str(). */ -/** memmove apn_enc to out_str, replacing the length octets in apn_enc with '.' - * (omitting the first one) and terminating with a '\0'. - * out_str needs to have rest_chars amount of bytes or 1 whatever is bigger. - */ -char * gprs_apn_to_str(char *out_str, const uint8_t *apn_enc, size_t rest_chars) -{ - char *str = out_str; - - while (rest_chars > 0 && apn_enc[0]) { - size_t label_size = apn_enc[0]; - if (label_size + 1 > rest_chars) - return NULL; - - memmove(str, apn_enc + 1, label_size); - str += label_size; - rest_chars -= label_size + 1; - apn_enc += label_size + 1; - - if (rest_chars) - *(str++) = '.'; - } - str[0] = '\0'; - - return out_str; -} - int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str) { uint8_t *last_len_field; diff --git a/src/gprs/gtphub.c b/src/gprs/gtphub.c index 5e7520e39..0a8e375ab 100644 --- a/src/gprs/gtphub.c +++ b/src/gprs/gtphub.c @@ -42,6 +42,8 @@ #include <osmocom/core/rate_ctr.h> #include <osmocom/core/stats.h> +#include <osmocom/gsm/apn.h> + static const int GTPH_GC_TICK_SECONDS = 1; @@ -498,7 +500,7 @@ static int get_ie_apn_str(union gtpie_member *ie[], const char **apn_str) len = sizeof(apn_buf) - 1; apn_buf[len] = '\0'; - *apn_str = gprs_apn_to_str(apn_buf, (uint8_t*)apn_buf, len); + *apn_str = osmo_apn_to_str(apn_buf, (uint8_t*)apn_buf, len); if (!(*apn_str)) { LOG(LOGL_ERROR, "APN IE: present but cannot be decoded: %s\n", osmo_hexdump((uint8_t*)apn_buf, len)); diff --git a/src/gprs/sgsn_cdr.c b/src/gprs/sgsn_cdr.c index 091089610..16ea9d47a 100644 --- a/src/gprs/sgsn_cdr.c +++ b/src/gprs/sgsn_cdr.c @@ -22,6 +22,7 @@ #include <openbsc/signal.h> #include <openbsc/gprs_utils.h> #include <openbsc/debug.h> +#include <osmocom/gsm/apn.h> #include <openbsc/vty.h> @@ -145,7 +146,7 @@ static void cdr_log_pdp(struct sgsn_instance *inst, const char *ev, if (pdp->lib) { - gprs_apn_to_str(apni, pdp->lib->apn_use.v, pdp->lib->apn_use.l); + osmo_apn_to_str(apni, pdp->lib->apn_use.v, pdp->lib->apn_use.l); inet_ntop(AF_INET, &pdp->lib->hisaddr0.s_addr, ggsn_addr, sizeof(ggsn_addr)); extract_eua(&pdp->lib->eua, eua_addr); } diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c index cc8d6c399..cf44cc420 100644 --- a/src/gprs/sgsn_vty.c +++ b/src/gprs/sgsn_vty.c @@ -28,6 +28,7 @@ #include <osmocom/core/utils.h> #include <osmocom/core/rate_ctr.h> #include <osmocom/gsm/protocol/gsm_04_08_gprs.h> +#include <osmocom/gsm/apn.h> #include <openbsc/debug.h> #include <openbsc/sgsn.h> @@ -116,7 +117,6 @@ DECLARE_TIMER(3397, "Wait for DEACT AA PDP CTX ACK timer (s)") #define GSM48_MAX_APN_LEN 102 /* 10.5.6.1 */ -/* TODO: consolidate with gprs_apn_to_str(). */ /** Copy apn to a static buffer, replacing the length octets in apn_enc with '.' * and terminating with a '\0'. Return the static buffer. * len: the length of the encoded APN (which has no terminating zero). @@ -124,23 +124,10 @@ DECLARE_TIMER(3397, "Wait for DEACT AA PDP CTX ACK timer (s)") static char *gprs_apn2str(uint8_t *apn, unsigned int len) { static char apnbuf[GSM48_MAX_APN_LEN+1]; - unsigned int i = 0; if (!apn) return ""; - - if (len > sizeof(apnbuf)-1) - len = sizeof(apnbuf)-1; - - memcpy(apnbuf, apn, len); - apnbuf[len] = '\0'; - - /* replace the domain name step sizes with dots */ - while (i < len) { - unsigned int step = apnbuf[i]; - apnbuf[i] = '.'; - i += step+1; - } + osmo_apn_to_str(apnbuf, apn, len); return apnbuf+1; } |