pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-asn1-tcap/+/41583?usp=email )
Change subject: Only export needed wrapper API ......................................................................
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 4 files changed, 54 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-asn1-tcap refs/changes/83/41583/1
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..0ef371e --- /dev/null +++ b/include/osmocom/tcap/tcap.h @@ -0,0 +1,9 @@ +/* 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); diff --git a/src/Makefile.am b/src/Makefile.am index fd5a167..d56c7ce 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_sigtran_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..f8dcf35 --- /dev/null +++ b/src/tcap.c @@ -0,0 +1,40 @@ +/* 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; +}