[PATCH 1/2] src: move GSM-specific functions to libosmogsm library

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

pablo at gnumonks.org pablo at gnumonks.org
Tue Mar 22 15:36:12 UTC 2011


From: Pablo Neira Ayuso <pablo at gnumonks.org>

This patch moves the GSM-specific functions to the new library
libosmogsm which is provided by libosmocore.

I have also moved generate_backtrace() to backtrace.c instead
of gsm_utils.c, otherwise the timer and msgfile tests depend on
libosmogsm.

Signed-off-by: Pablo Neira Ayuso <pablo at gnumonks.org>
---
 Makefile.am                      |    2 +-
 configure.in                     |    2 +
 include/osmocore/Makefile.am     |    3 +-
 include/osmocore/backtrace.h     |    6 ++++
 include/osmocore/gsm_utils.h     |    1 -
 libosmogsm.pc.in                 |   11 ++++++++
 src/Makefile.am                  |   14 +++++-----
 src/backtrace.c                  |   50 ++++++++++++++++++++++++++++++++++++++
 src/gsm/Makefile.am              |   13 ++++++++++
 src/{ => gsm}/comp128.c          |    0
 src/{ => gsm}/gprs_cipher_core.c |    0
 src/{ => gsm}/gsm0480.c          |    0
 src/{ => gsm}/gsm0808.c          |    0
 src/{ => gsm}/gsm48.c            |    0
 src/{ => gsm}/gsm48_ie.c         |    0
 src/{ => gsm}/gsm_utils.c        |   23 -----------------
 src/{ => gsm}/rsl.c              |    0
 src/{ => gsm}/rxlev_stat.c       |    0
 src/{ => gsm}/tlv_parser.c       |    0
 src/panic.c                      |    1 +
 tests/sms/Makefile.am            |    2 +-
 tests/smscb/Makefile.am          |    2 +-
 tests/ussd/Makefile.am           |    2 +-
 23 files changed, 96 insertions(+), 36 deletions(-)
 create mode 100644 include/osmocore/backtrace.h
 create mode 100644 libosmogsm.pc.in
 create mode 100644 src/backtrace.c
 create mode 100644 src/gsm/Makefile.am
 rename src/{ => gsm}/comp128.c (100%)
 rename src/{ => gsm}/gprs_cipher_core.c (100%)
 rename src/{ => gsm}/gsm0480.c (100%)
 rename src/{ => gsm}/gsm0808.c (100%)
 rename src/{ => gsm}/gsm48.c (100%)
 rename src/{ => gsm}/gsm48_ie.c (100%)
 rename src/{ => gsm}/gsm_utils.c (96%)
 rename src/{ => gsm}/rsl.c (100%)
 rename src/{ => gsm}/rxlev_stat.c (100%)
 rename src/{ => gsm}/tlv_parser.c (100%)

diff --git a/Makefile.am b/Makefile.am
index 93254e8..e391de8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
 SUBDIRS = include src tests
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc
+pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc libosmogsm.pc
 
 BUILT_SOURCES = $(top_srcdir)/.version
 $(top_srcdir)/.version:
diff --git a/configure.in b/configure.in
index 165cecb..b572bf4 100644
--- a/configure.in
+++ b/configure.in
@@ -101,6 +101,7 @@ AC_OUTPUT(
 	libosmocore.pc
 	libosmocodec.pc
 	libosmovty.pc
+	libosmogsm.pc
 	include/osmocom/Makefile
 	include/osmocom/vty/Makefile
 	include/osmocom/codec/Makefile
@@ -111,6 +112,7 @@ AC_OUTPUT(
 	src/Makefile
 	src/vty/Makefile
 	src/codec/Makefile
+	src/gsm/Makefile
 	tests/Makefile
 	tests/timer/Makefile
 	tests/sms/Makefile
diff --git a/include/osmocore/Makefile.am b/include/osmocore/Makefile.am
index a3b12ef..b65589a 100644
--- a/include/osmocore/Makefile.am
+++ b/include/osmocore/Makefile.am
@@ -2,7 +2,8 @@ osmocore_HEADERS = signal.h linuxlist.h timer.h select.h msgb.h bits.h \
 		   tlv.h bitvec.h comp128.h statistics.h gsm_utils.h utils.h \
 		   gsmtap.h write_queue.h rsl.h gsm48.h rxlev_stat.h mncc.h \
 		   gsm48_ie.h logging.h gsm0808.h rate_ctr.h gsmtap_util.h \
-		   plugin.h crc16.h panic.h process.h gsm0480.h msgfile.h
+		   plugin.h crc16.h panic.h process.h gsm0480.h msgfile.h \
+		   backtrace.h
 
 if ENABLE_TALLOC
 osmocore_HEADERS += talloc.h
diff --git a/include/osmocore/backtrace.h b/include/osmocore/backtrace.h
new file mode 100644
index 0000000..bbbb2c2
--- /dev/null
+++ b/include/osmocore/backtrace.h
@@ -0,0 +1,6 @@
+#ifndef _OSMO_BACKTRACE_H_
+#define _OSMO_BACKTRACE_H_
+
+void generate_backtrace();
+
+#endif
diff --git a/include/osmocore/gsm_utils.h b/include/osmocore/gsm_utils.h
index 0aadd2e..19adb70 100644
--- a/include/osmocore/gsm_utils.h
+++ b/include/osmocore/gsm_utils.h
@@ -114,5 +114,4 @@ int gprs_tlli_type(uint32_t tlli);
 
 uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type);
 
-void generate_backtrace();
 #endif
diff --git a/libosmogsm.pc.in b/libosmogsm.pc.in
new file mode 100644
index 0000000..753bb3a
--- /dev/null
+++ b/libosmogsm.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Osmocom GSM Core Library
+Description: GSM Core Library
+Version: @VERSION@
+Libs: -L${libdir} -losmogsm
+Cflags: -I${includedir}/
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 94492c5..c5c8a21 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS=. vty codec
+SUBDIRS=. vty codec gsm
 
 # This is _NOT_ the library release version, it's an API version.
 # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification
@@ -9,12 +9,12 @@ AM_CFLAGS = -fPIC -Wall
 
 lib_LTLIBRARIES = libosmocore.la
 
-libosmocore_la_SOURCES = timer.c select.c signal.c msgb.c rxlev_stat.c bits.c \
-			 tlv_parser.c bitvec.c comp128.c gsm_utils.c statistics.c \
-			 write_queue.c utils.c rsl.c gsm48.c gsm48_ie.c \
-			 logging.c logging_syslog.c gsm0808.c rate_ctr.c \
-			 gsmtap_util.c gprs_cipher_core.c crc16.c panic.c \
-			 process.c gsm0480.c
+libosmocore_la_SOURCES = timer.c select.c signal.c msgb.c bits.c \
+			 bitvec.c statistics.c \
+			 write_queue.c utils.c \
+			 logging.c logging_syslog.c rate_ctr.c \
+			 gsmtap_util.c crc16.c panic.c backtrace.c \
+			 process.c
 
 if ENABLE_PLUGIN
 libosmocore_la_SOURCES += plugin.c
diff --git a/src/backtrace.c b/src/backtrace.c
new file mode 100644
index 0000000..4239445
--- /dev/null
+++ b/src/backtrace.c
@@ -0,0 +1,50 @@
+/*
+ * (C) 2008 by Daniel Willmann <daniel at totalueberwachung.de>
+ * (C) 2009 by Holger Hans Peter Freyther <zecke at selfish.org>
+ * (C) 2009-2010 by Harald Welte <laforge at gnumonks.org>
+ * (C) 2010 by Nico Golde <nico at ngolde.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <osmocore/utils.h>
+#include "config.h"
+
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+void generate_backtrace()
+{
+	int i, nptrs;
+	void *buffer[100];
+	char **strings;
+
+	nptrs = backtrace(buffer, ARRAY_SIZE(buffer));
+	printf("backtrace() returned %d addresses\n", nptrs);
+
+	strings = backtrace_symbols(buffer, nptrs);
+	if (!strings)
+		return;
+
+	for (i = 1; i < nptrs; i++)
+		printf("%s\n", strings[i]);
+
+	free(strings);
+}
+#endif
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
new file mode 100644
index 0000000..a8c2e56
--- /dev/null
+++ b/src/gsm/Makefile.am
@@ -0,0 +1,13 @@
+# This is _NOT_ the library release version, it's an API version.
+# Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification
+LIBVERSION=0:0:0
+
+INCLUDES = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS = -fPIC -Wall
+
+lib_LTLIBRARIES = libosmogsm.la
+
+libosmogsm_la_SOURCES = rxlev_stat.c tlv_parser.c comp128.c gsm_utils.c \
+                        rsl.c gsm48.c gsm48_ie.c gsm0808.c \
+			gprs_cipher_core.c gsm0480.c
+libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la
diff --git a/src/comp128.c b/src/gsm/comp128.c
similarity index 100%
rename from src/comp128.c
rename to src/gsm/comp128.c
diff --git a/src/gprs_cipher_core.c b/src/gsm/gprs_cipher_core.c
similarity index 100%
rename from src/gprs_cipher_core.c
rename to src/gsm/gprs_cipher_core.c
diff --git a/src/gsm0480.c b/src/gsm/gsm0480.c
similarity index 100%
rename from src/gsm0480.c
rename to src/gsm/gsm0480.c
diff --git a/src/gsm0808.c b/src/gsm/gsm0808.c
similarity index 100%
rename from src/gsm0808.c
rename to src/gsm/gsm0808.c
diff --git a/src/gsm48.c b/src/gsm/gsm48.c
similarity index 100%
rename from src/gsm48.c
rename to src/gsm/gsm48.c
diff --git a/src/gsm48_ie.c b/src/gsm/gsm48_ie.c
similarity index 100%
rename from src/gsm48_ie.c
rename to src/gsm/gsm48_ie.c
diff --git a/src/gsm_utils.c b/src/gsm/gsm_utils.c
similarity index 96%
rename from src/gsm_utils.c
rename to src/gsm/gsm_utils.c
index 31e3cd6..54a13ad 100644
--- a/src/gsm_utils.c
+++ b/src/gsm/gsm_utils.c
@@ -334,29 +334,6 @@ enum gsm_band gsm_band_parse(const char* mhz)
 	}
 }
 
-
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>
-void generate_backtrace()
-{
-	int i, nptrs;
-	void *buffer[100];
-	char **strings;
-
-	nptrs = backtrace(buffer, ARRAY_SIZE(buffer));
-	printf("backtrace() returned %d addresses\n", nptrs);
-
-	strings = backtrace_symbols(buffer, nptrs);
-	if (!strings)
-		return;
-
-	for (i = 1; i < nptrs; i++)
-		printf("%s\n", strings[i]);
-
-	free(strings);
-}
-#endif
-
 enum gsm_band gsm_arfcn2band(uint16_t arfcn)
 {
 	int is_pcs = arfcn & ARFCN_PCS;
diff --git a/src/rsl.c b/src/gsm/rsl.c
similarity index 100%
rename from src/rsl.c
rename to src/gsm/rsl.c
diff --git a/src/rxlev_stat.c b/src/gsm/rxlev_stat.c
similarity index 100%
rename from src/rxlev_stat.c
rename to src/gsm/rxlev_stat.c
diff --git a/src/tlv_parser.c b/src/gsm/tlv_parser.c
similarity index 100%
rename from src/tlv_parser.c
rename to src/gsm/tlv_parser.c
diff --git a/src/panic.c b/src/panic.c
index 5fb7b56..21e8fd5 100644
--- a/src/panic.c
+++ b/src/panic.c
@@ -22,6 +22,7 @@
 
 #include <osmocore/gsm_utils.h>
 #include <osmocore/panic.h>
+#include <osmocore/backtrace.h>
 
 #include "../config.h"
 
diff --git a/tests/sms/Makefile.am b/tests/sms/Makefile.am
index a8f1ff6..fa4e387 100644
--- a/tests/sms/Makefile.am
+++ b/tests/sms/Makefile.am
@@ -2,4 +2,4 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
 noinst_PROGRAMS = sms_test
 
 sms_test_SOURCES = sms_test.c
-sms_test_LDADD = $(top_builddir)/src/libosmocore.la
+sms_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/tests/smscb/Makefile.am b/tests/smscb/Makefile.am
index 1d0e538..9a6fb4f 100644
--- a/tests/smscb/Makefile.am
+++ b/tests/smscb/Makefile.am
@@ -2,4 +2,4 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
 noinst_PROGRAMS = smscb_test
 
 smscb_test_SOURCES = smscb_test.c
-smscb_test_LDADD = $(top_builddir)/src/libosmocore.la
+smscb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/tests/ussd/Makefile.am b/tests/ussd/Makefile.am
index d29506c..ef9aa49 100644
--- a/tests/ussd/Makefile.am
+++ b/tests/ussd/Makefile.am
@@ -2,4 +2,4 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include
 noinst_PROGRAMS = ussd_test
 
 ussd_test_SOURCES = ussd_test.c
-ussd_test_LDADD = $(top_builddir)/src/libosmocore.la
+ussd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
-- 
1.7.2.3





More information about the OpenBSC mailing list