From patchwork Tue Jan 5 10:42:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Erlbeck X-Patchwork-Id: 563024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (unknown [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 8D58C1402C0 for ; Tue, 5 Jan 2016 21:43:28 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 0DF70A3DC; Tue, 5 Jan 2016 10:43:19 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from mail.sysmocom.de (mail.sysmocom.de [IPv6:2a01:4f8:191:444c::2:4]) by lists.osmocom.org (Postfix) with ESMTP id 710F5A3A8 for ; Tue, 5 Jan 2016 10:43:17 +0000 (UTC) Received: from sysmocom-tmp.am93.sysmocom.de (ip5b418565.dynamic.kabel-deutschland.de [91.65.133.101]) by mail.sysmocom.de (Postfix) with ESMTPSA id 4E57F1BDB0; Tue, 5 Jan 2016 10:42:47 +0000 (UTC) From: Jacob Erlbeck To: openbsc@lists.osmocom.org Subject: [PATCH 3/3] sgsn: Consolidate gprs_apn2str with osmo_apn_to_str Date: Tue, 5 Jan 2016 11:42:43 +0100 Message-Id: <1451990563-4184-4-git-send-email-jerlbeck@sysmocom.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451990563-4184-1-git-send-email-jerlbeck@sysmocom.de> References: <1447753069-17466-6-git-send-email-jerlbeck@sysmocom.de> <1451990563-4184-1-git-send-email-jerlbeck@sysmocom.de> X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" 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(-) 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 #include +#include + #include #include @@ -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)