[3/3] sgsn: Consolidate gprs_apn2str with osmo_apn_to_str
diff mbox

Message ID 1451990563-4184-4-git-send-email-jerlbeck@sysmocom.de
State New
Headers show

Commit Message

Jacob Erlbeck Jan. 5, 2016, 10:42 a.m. UTC
This commit replaces the implementation of gprs_apn2str by a call
to osmo_apn_to_str.

Sponsored-by: On-Waves ehf
---
 openbsc/src/gprs/sgsn_vty.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

Patch
diff mbox

diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index 706c9ea..384f1f8 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -40,6 +40,8 @@ 
 #include <osmocom/vty/vty.h>
 #include <osmocom/vty/misc.h>
 
+#include <osmocom/gsm/apn.h>
+
 #include <osmocom/abis/ipa.h>
 
 #include <pdp.h>
@@ -110,7 +112,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 osmo_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).
@@ -118,25 +119,8 @@  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;
-	}
 
-	return apnbuf+1;
+	return osmo_apn_to_str(apnbuf, apn, len);
 }
 
 char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len)