pespin submitted this change.

View Change

Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved daniel: Looks good to me, but someone else must approve
Only export needed wrapper API

Otherwise the asn_* symbols collide with other generated skeletons on
apps/library clients (eg. libasn1c.git).

Related: OS#6895
Related: OS#6896
Change-Id: I6d97ac94be91064be7203b11cffa4de9056afce1
---
M include/osmocom/tcap/Makefile.am
A include/osmocom/tcap/tcap.h
M src/Makefile.am
A src/tcap.c
M tests/parse/Makefile.am
5 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/include/osmocom/tcap/Makefile.am b/include/osmocom/tcap/Makefile.am
index d0a425a..304958b 100644
--- a/include/osmocom/tcap/Makefile.am
+++ b/include/osmocom/tcap/Makefile.am
@@ -98,6 +98,7 @@
osmo_asn1_tcap_HEADERS = \
$(SKEL_HEADER_FILES) \
$(GEN_HEADER_FILES) \
+ tcap.h \
version.h \
$(NULL)

diff --git a/include/osmocom/tcap/tcap.h b/include/osmocom/tcap/tcap.h
new file mode 100644
index 0000000..309f283
--- /dev/null
+++ b/include/osmocom/tcap/tcap.h
@@ -0,0 +1,11 @@
+/* libosmo-asn1-tcap public API */
+#pragma once
+
+#include <stdint.h>
+#include <unistd.h>
+
+#include <osmocom/tcap/TCAP_TCMessage.h>
+
+int osmo_asn1_tcap_decode(struct TCAP_TCMessage *tcapmsg, const uint8_t *data, size_t data_len);
+
+void osmo_asn1_tcap_TCMessage_free_contents(struct TCAP_TCMessage *tcapmsg);
diff --git a/src/Makefile.am b/src/Makefile.am
index fd5a167..de48e4a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,3 +1,5 @@
+AM_CFLAGS = -I$(top_srcdir)/include/ -I$(top_srcdir)/src/skel $(ASN_MODULE_CFLAGS)
+
SKEL_SRC = \
skel/ANY.c \
skel/ANY_ber.c \
@@ -197,10 +199,10 @@
# documentation before making any modification
LIBVERSION=0:0:0

-#INCLUDES = $(all_includes) -I/usr/local/include/asn1c -I$(top_srcdir)/include
-AM_CFLAGS = -I$(top_srcdir)/include/ -I$(top_srcdir)/src/skel $(ASN_MODULE_CFLAGS)
+libosmo_asn1_tcap_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined -export-symbols-regex '^osmo_'

libosmo_asn1_tcap_la_SOURCES = \
+ tcap.c \
$(ASN_MODULE_SRC)

lib_LTLIBRARIES=libosmo-asn1-tcap.la
diff --git a/src/tcap.c b/src/tcap.c
new file mode 100644
index 0000000..68c7d9c
--- /dev/null
+++ b/src/tcap.c
@@ -0,0 +1,45 @@
+/* libosmo-asn1-tcap public API */
+/* (C) 2025 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <stdint.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <osmocom/tcap/asn_codecs.h>
+#include <osmocom/tcap/TCAP_TCMessage.h>
+
+int osmo_asn1_tcap_decode(struct TCAP_TCMessage *tcapmsg, const uint8_t *data, size_t data_len)
+{
+
+ asn_dec_rval_t asn_rc;
+
+ memset(tcapmsg, 0, sizeof(struct TCAP_TCMessage));
+
+ asn_rc = ber_decode(0, &asn_DEF_TCAP_TCMessage, (void **)&tcapmsg, data, data_len);
+ if (asn_rc.code != RC_OK)
+ return -EINVAL;
+ return 0;
+}
+
+void osmo_asn1_tcap_TCMessage_free_contents(struct TCAP_TCMessage *tcapmsg)
+{
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_TCAP_TCMessage, tcapmsg);
+}
diff --git a/tests/parse/Makefile.am b/tests/parse/Makefile.am
index 4a502b8..821865d 100644
--- a/tests/parse/Makefile.am
+++ b/tests/parse/Makefile.am
@@ -2,7 +2,7 @@
AM_CFLAGS = -Wall
AM_LDFLAGS = -no-install

-LDADD = $(top_builddir)/src/libosmo-asn1-tcap.la
+LDADD = $(top_builddir)/src/.libs/libosmo-asn1-tcap.a

check_PROGRAMS = \
tcap_parse_test \

To view, visit change 41583. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: libosmo-asn1-tcap
Gerrit-Branch: master
Gerrit-Change-Id: I6d97ac94be91064be7203b11cffa4de9056afce1
Gerrit-Change-Number: 41583
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>