Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libosmo-sccp for openSUSE:Factory 
checked in at 2023-05-19 11:55:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libosmo-sccp (Old)
 and      /work/SRC/openSUSE:Factory/.libosmo-sccp.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libosmo-sccp"

Fri May 19 11:55:36 2023 rev:19 rq:1087823 version:1.7.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/libosmo-sccp/libosmo-sccp.changes        
2022-08-04 13:23:48.200556515 +0200
+++ /work/SRC/openSUSE:Factory/.libosmo-sccp.new.1533/libosmo-sccp.changes      
2023-05-19 11:56:06.395464010 +0200
@@ -1,0 +2,6 @@
+Thu May 18 11:31:13 UTC 2023 - Jan Engelhardt <[email protected]>
+
+- Update to release 1.7.0
+  * SIGTRAN: cache Optional Data for SCCP CR/CC/RLSD
+
+-------------------------------------------------------------------

Old:
----
  1.6.0.tar.gz

New:
----
  1.7.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libosmo-sccp.spec ++++++
--- /var/tmp/diff_new_pack.MkRa8I/_old  2023-05-19 11:56:07.079467921 +0200
+++ /var/tmp/diff_new_pack.MkRa8I/_new  2023-05-19 11:56:07.083467944 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package libosmo-sccp
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,14 +17,13 @@
 
 
 Name:           libosmo-sccp
-Version:        1.6.0
+Version:        1.7.0
 Release:        0
 %define libversion %(echo "%version" | sed 's/\\./_/g')
 Summary:        Osmocom library for the A-bis interface between BTS and BSC
 License:        AGPL-3.0-or-later AND GPL-2.0-or-later
 Group:          Hardware/Mobile
 URL:            https://projects.osmocom.org/projects/libosmo-sccp
-
 #Git-Clone:    https://git.osmocom.org/libosmo-sccp
 Source:         https://github.com/osmocom/libosmo-sccp/archive/%version.tar.gz
 Patch1:         0001-build-fixes.patch
@@ -34,10 +33,10 @@
 BuildRequires:  lksctp-tools-devel
 BuildRequires:  pkg-config >= 0.20
 BuildRequires:  systemd-rpm-macros
-BuildRequires:  pkgconfig(libosmo-netif) >= 1.2.0
-BuildRequires:  pkgconfig(libosmocore) >= 1.7.0
-BuildRequires:  pkgconfig(libosmogsm) >= 1.7.0
-BuildRequires:  pkgconfig(libosmovty) >= 1.7.0
+BuildRequires:  pkgconfig(libosmo-netif) >= 1.3.0
+BuildRequires:  pkgconfig(libosmocore) >= 1.8.0
+BuildRequires:  pkgconfig(libosmogsm) >= 1.8.0
+BuildRequires:  pkgconfig(libosmovty) >= 1.8.0
 
 %description
 SCCP is a network layer protocol that provides extended routing, flow

++++++ 0001-build-fixes.patch ++++++
--- /var/tmp/diff_new_pack.MkRa8I/_old  2023-05-19 11:56:07.111468103 +0200
+++ /var/tmp/diff_new_pack.MkRa8I/_new  2023-05-19 11:56:07.115468126 +0200
@@ -20,22 +20,22 @@
  tests/xua/Makefile.am  |    6 ++----
  8 files changed, 24 insertions(+), 17 deletions(-)
 
-Index: libosmo-sccp-1.6.0/configure.ac
+Index: libosmo-sccp-1.7.0/configure.ac
 ===================================================================
---- libosmo-sccp-1.6.0.orig/configure.ac
-+++ libosmo-sccp-1.6.0/configure.ac
+--- libosmo-sccp-1.7.0.orig/configure.ac
++++ libosmo-sccp-1.7.0/configure.ac
 @@ -36,6 +36,7 @@ if test "x$PKG_CONFIG_INSTALLED" = "xno"
  fi
  PKG_PROG_PKG_CONFIG([0.20])
  
 +PKG_CHECK_MODULES([TALLOC], [talloc])
- PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.7.0)
- PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.7.0)
- PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.7.0)
-Index: libosmo-sccp-1.6.0/libosmo-mtp.pc.in
+ PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.8.0)
+ PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.8.0)
+ PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.8.0)
+Index: libosmo-sccp-1.7.0/libosmo-mtp.pc.in
 ===================================================================
---- libosmo-sccp-1.6.0.orig/libosmo-mtp.pc.in
-+++ libosmo-sccp-1.6.0/libosmo-mtp.pc.in
+--- libosmo-sccp-1.7.0.orig/libosmo-mtp.pc.in
++++ libosmo-sccp-1.7.0/libosmo-mtp.pc.in
 @@ -6,5 +6,5 @@ includedir=@includedir@
  Name: Osmo MTP Lib
  Description: Osmo MTP Lib
@@ -43,10 +43,10 @@
 -Libs: -L${libdir} -lmtp
 +Libs: -L${libdir} -losmo-mtp
  Cflags: -I${includedir}/
-Index: libosmo-sccp-1.6.0/libosmo-sccp.pc.in
+Index: libosmo-sccp-1.7.0/libosmo-sccp.pc.in
 ===================================================================
---- libosmo-sccp-1.6.0.orig/libosmo-sccp.pc.in
-+++ libosmo-sccp-1.6.0/libosmo-sccp.pc.in
+--- libosmo-sccp-1.7.0.orig/libosmo-sccp.pc.in
++++ libosmo-sccp-1.7.0/libosmo-sccp.pc.in
 @@ -6,5 +6,5 @@ includedir=@includedir@
  Name: OpenBSC SCCP Lib
  Description: OpenBSC SCCP Lib
@@ -54,10 +54,10 @@
 -Libs: -L${libdir} -lsccp
 +Libs: -L${libdir} -losmo-sccp
  Cflags: -I${includedir}/
-Index: libosmo-sccp-1.6.0/src/Makefile.am
+Index: libosmo-sccp-1.7.0/src/Makefile.am
 ===================================================================
---- libosmo-sccp-1.6.0.orig/src/Makefile.am
-+++ libosmo-sccp-1.6.0/src/Makefile.am
+--- libosmo-sccp-1.7.0.orig/src/Makefile.am
++++ libosmo-sccp-1.7.0/src/Makefile.am
 @@ -7,15 +7,21 @@ noinst_HEADERS = sccp_internal.h ss7_int
  # Legacy static libs
  
@@ -93,20 +93,20 @@
 +noinst_LTLIBRARIES = libosmo-sigtran-internal.la
 +libosmo_sigtran_internal_la_SOURCES = $(libosmo_sigtran_la_SOURCES)
 +libosmo_sigtran_internal_la_LIBADD = $(libosmo_sigtran_la_LIBADD)
-Index: libosmo-sccp-1.6.0/tests/m2ua/Makefile.am
+Index: libosmo-sccp-1.7.0/tests/m2ua/Makefile.am
 ===================================================================
---- libosmo-sccp-1.6.0.orig/tests/m2ua/Makefile.am
-+++ libosmo-sccp-1.6.0/tests/m2ua/Makefile.am
+--- libosmo-sccp-1.7.0.orig/tests/m2ua/Makefile.am
++++ libosmo-sccp-1.7.0/tests/m2ua/Makefile.am
 @@ -5,4 +5,4 @@ EXTRA_DIST = m2ua_test.ok
  
  check_PROGRAMS = m2ua_test
  m2ua_test_SOURCES = m2ua_test.c
 -m2ua_test_LDADD = $(top_builddir)/src/libxua.a $(LIBOSMOCORE_LIBS)
 +m2ua_test_LDADD = $(top_builddir)/src/libosmo-xua.la $(LIBOSMOCORE_LIBS) 
${TALLOC_LIBS}
-Index: libosmo-sccp-1.6.0/tests/sccp/Makefile.am
+Index: libosmo-sccp-1.7.0/tests/sccp/Makefile.am
 ===================================================================
---- libosmo-sccp-1.6.0.orig/tests/sccp/Makefile.am
-+++ libosmo-sccp-1.6.0/tests/sccp/Makefile.am
+--- libosmo-sccp-1.7.0.orig/tests/sccp/Makefile.am
++++ libosmo-sccp-1.7.0/tests/sccp/Makefile.am
 @@ -1,13 +1,13 @@
 -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
 +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include ${TALLOC_CFLAGS}
@@ -124,10 +124,10 @@
 +      ${TALLOC_LIBS} \
        $(NULL)
  
-Index: libosmo-sccp-1.6.0/tests/ss7/Makefile.am
+Index: libosmo-sccp-1.7.0/tests/ss7/Makefile.am
 ===================================================================
---- libosmo-sccp-1.6.0.orig/tests/ss7/Makefile.am
-+++ libosmo-sccp-1.6.0/tests/ss7/Makefile.am
+--- libosmo-sccp-1.7.0.orig/tests/ss7/Makefile.am
++++ libosmo-sccp-1.7.0/tests/ss7/Makefile.am
 @@ -1,7 +1,5 @@
  AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -Wall
  AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS)
@@ -136,10 +136,10 @@
  LDADD = $(top_builddir)/src/libosmo-sigtran.la \
        $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMONETIF_LIBS) 
$(LIBSCTP_LIBS)
  
-Index: libosmo-sccp-1.6.0/tests/xua/Makefile.am
+Index: libosmo-sccp-1.7.0/tests/xua/Makefile.am
 ===================================================================
---- libosmo-sccp-1.6.0.orig/tests/xua/Makefile.am
-+++ libosmo-sccp-1.6.0/tests/xua/Makefile.am
+--- libosmo-sccp-1.7.0.orig/tests/xua/Makefile.am
++++ libosmo-sccp-1.7.0/tests/xua/Makefile.am
 @@ -1,8 +1,6 @@
 -AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -Wall
 +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -Wall 
$(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMONETIF_CFLAGS) 
$(LIBSCTP_CFLAGS)

++++++ 1.6.0.tar.gz -> 1.7.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/configure.ac 
new/libosmo-sccp-1.7.0/configure.ac
--- old/libosmo-sccp-1.6.0/configure.ac 2022-06-28 18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/configure.ac 2023-02-07 14:37:23.000000000 +0100
@@ -36,10 +36,10 @@
 fi
 PKG_PROG_PKG_CONFIG([0.20])
 
-PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.7.0)
-PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.7.0)
-PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.7.0)
-PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.2.0)
+PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.8.0)
+PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.8.0)
+PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.8.0)
+PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.3.0)
 
 old_LIBS=$LIBS
 AC_SEARCH_LIBS([sctp_recvmsg], [sctp], [
@@ -77,6 +77,7 @@
 then
        WERROR_FLAGS="-Werror"
        WERROR_FLAGS+=" -Wno-error=deprecated 
-Wno-error=deprecated-declarations"
+       WERROR_FLAGS+=" -Werror=implicit-int -Werror=int-conversion 
-Werror=old-style-definition"
        WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
        CFLAGS="$CFLAGS $WERROR_FLAGS"
        CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/contrib/jenkins.sh 
new/libosmo-sccp-1.7.0/contrib/jenkins.sh
--- old/libosmo-sccp-1.6.0/contrib/jenkins.sh   2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/contrib/jenkins.sh   2023-02-07 14:37:23.000000000 
+0100
@@ -50,6 +50,7 @@
 autoreconf --install --force
 ./configure --enable-sanitize --enable-werror --enable-external-tests $CONFIG
 $MAKE $PARALLEL_MAKE
+$MAKE $PARALLEL_MAKE check || cat-testlogs.sh
 DISTCHECK_CONFIGURE_FLAGS="--enable-external-tests $CONFIG" \
   $MAKE $PARALLEL_MAKE distcheck \
   || cat-testlogs.sh
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/contrib/libosmo-sccp.spec.in 
new/libosmo-sccp-1.7.0/contrib/libosmo-sccp.spec.in
--- old/libosmo-sccp-1.6.0/contrib/libosmo-sccp.spec.in 2022-06-28 
18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/contrib/libosmo-sccp.spec.in 2023-02-07 
14:37:23.000000000 +0100
@@ -34,10 +34,10 @@
 BuildRequires:  systemd-rpm-macros
 %endif
 BuildRequires:  xz
-BuildRequires:  pkgconfig(libosmo-netif) >= 1.2.0
-BuildRequires:  pkgconfig(libosmocore) >= 1.7.0
-BuildRequires:  pkgconfig(libosmogsm) >= 1.7.0
-BuildRequires:  pkgconfig(libosmovty) >= 1.7.0
+BuildRequires:  pkgconfig(libosmo-netif) >= 1.3.0
+BuildRequires:  pkgconfig(libosmocore) >= 1.8.0
+BuildRequires:  pkgconfig(libosmogsm) >= 1.8.0
+BuildRequires:  pkgconfig(libosmovty) >= 1.8.0
 %{?systemd_requires}
 
 %description
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/contrib/systemd/osmo-stp.service 
new/libosmo-sccp-1.7.0/contrib/systemd/osmo-stp.service
--- old/libosmo-sccp-1.6.0/contrib/systemd/osmo-stp.service     2022-06-28 
18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/contrib/systemd/osmo-stp.service     2023-02-07 
14:37:23.000000000 +0100
@@ -5,6 +5,8 @@
 [Service]
 Type=simple
 Restart=always
+StateDirectory=osmocom
+WorkingDirectory=%S/osmocom
 ExecStart=/usr/bin/osmo-stp -c /etc/osmocom/osmo-stp.cfg
 RestartSec=2
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/debian/changelog 
new/libosmo-sccp-1.7.0/debian/changelog
--- old/libosmo-sccp-1.6.0/debian/changelog     2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/debian/changelog     2023-02-07 14:37:23.000000000 
+0100
@@ -1,3 +1,35 @@
+libosmo-sccp (1.7.0) unstable; urgency=medium
+
+  [ Pau Espin Pedrol ]
+  * xua_snm: assert to guard against NULL ptr
+  * sccp: Validate local references > 0x00fffffe are not used
+
+  [ Max ]
+  * cosmetic: improve usage help of example code
+  * SCCP: enforce optional data length limits
+  * SCCP: Log more data on CR size error
+  * [cosmetic] sccp_scoc.c: constify function parameters
+  * Add basic readme for example code
+  * SIGTRAN: don't advance FSM on failed connection request
+  * SIGTRAN: add function to check connection existence
+  * SIGTRAN: error if attempting to send exceedingly big data
+  * SIGTRAN: add osmo_sccp_tx_disconn_data() helper
+  * examples: update vty code
+  * SIGTRAN: arrange the comments in the encoder to match the spec
+  * SIGTRAN: cache Optional Data for SCCP CR/CC/RLSD
+  * Set working directory in systemd service file
+
+  [ Harald Welte ]
+  * Add -Werror=implicit-int -Werror=int-conversion 
-Werror=old-style-definition
+  * SCOC: dump SUA header when logging "mismatching remote pc"
+  * cosmetic: fix typo in comment
+
+  [ Oliver Smith ]
+  * tests: fix old-style function definition
+  * contrib/jenkins.sh: add missing 'make check'
+
+ -- Pau Espin Pedrol <[email protected]>  Tue, 07 Feb 2023 14:37:23 +0100
+
 libosmo-sccp (1.6.0) unstable; urgency=medium
 
   [ Pau Espin Pedrol ]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/debian/control 
new/libosmo-sccp-1.7.0/debian/control
--- old/libosmo-sccp-1.6.0/debian/control       2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/debian/control       2023-02-07 14:37:23.000000000 
+0100
@@ -5,7 +5,7 @@
 Build-Depends: debhelper (>= 9),
                autotools-dev,
                pkg-config,
-               libosmocore-dev (>= 1.7.0),
+               libosmocore-dev (>= 1.8.0),
                autoconf,
                automake,
                libtool,
@@ -13,9 +13,9 @@
                git,
                doxygen,
                libdpkg-perl,
-               libosmo-netif-dev (>= 1.2.0),
+               libosmo-netif-dev (>= 1.3.0),
                libsctp-dev,
-               osmo-gsm-manuals-dev (>= 1.3.0)
+               osmo-gsm-manuals-dev (>= 1.4.0)
 Standards-Version: 3.9.7
 Vcs-Git: https://gitea.osmocom.org/osmocom/libosmo-sccp
 Vcs-Browser: https://gitea.osmocom.org/osmocom/libosmo-sccp
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/examples/README 
new/libosmo-sccp-1.7.0/examples/README
--- old/libosmo-sccp-1.6.0/examples/README      1970-01-01 01:00:00.000000000 
+0100
+++ new/libosmo-sccp-1.7.0/examples/README      2023-02-07 14:37:23.000000000 
+0100
@@ -0,0 +1,21 @@
+This example code is handy in illustrating libosmo-sigtran library use as well 
as experimenting with SCCP protocol.
+
+Run it as follows:
+Server:
+./sccp_demo_user -d DLINP,5:DLSS7,5:DLSCCP,1:DSCCP,1:DMAIN,1
+Client:
+./sccp_demo_user -d DLINP,5:DLSS7,5:DLSCCP,1:DSCCP,1:DMAIN,1 -c
+Server's vty:
+telnet 127.0.0.1 2324
+Client's vty:
+telnet 127.0.0.2 2325
+
+On the client side, after entering privileged mode by typing 'enable', you can 
switch to demo user mode with 'sccp-user' command.
+
+This gives several additional commands, for example:
+'called-addr-ssn 202' - selecting "echo" application (201 is "refuser", 203 is 
"callback")
+'connect-req 10 aaaaaaaaaaaaaaaaaaa' - sending N-CONNECT message with ID=12 
and optional data
+
+See vty's help for further details.
+
+Calling 'show cs7 instance 0 sccp connections' in privileged mode on the 
server will show currently active SCCP connections.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/examples/sccp_demo_user.c 
new/libosmo-sccp-1.7.0/examples/sccp_demo_user.c
--- old/libosmo-sccp-1.6.0/examples/sccp_demo_user.c    2022-06-28 
18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/examples/sccp_demo_user.c    2023-02-07 
14:37:23.000000000 +0100
@@ -105,7 +105,6 @@
 #define DEFAULT_LOCAL_PORT_CLIENT      M3UA_PORT
 #define DEFAULT_REMOTE_PORT_CLIENT     DEFAULT_LOCAL_PORT_SERVER
 #define DEFAULT_REMOTE_PORT_SERVER     DEFAULT_LOCAL_PORT_CLIENT
-#define DEFAULT_REMOTE_PORT_SERVER_STR DEFAULT_LOCAL_PORT_CLIENT_STR
 #define DEFAULT_PC_SERVER      1
 #define DEFAULT_PC_CLIENT      23
 
@@ -116,13 +115,14 @@
                        "Options:\n"
                        "  -p: protocol to use (m3ua, sua, ipa; default is 
ipa)\n"
                        "  -c: Run in client mode (default is server mode)\n"
+                       "  -C filename  The config file to use\n"
                        "  -l: local IP address and SCTP port (default is %s:%d 
in server mode,\n"
                        "                                       %s:%d in client 
mode)\n"
                        "  -r: remote IP address and SCTP port (default is 
%s:%d in server mode,\n"
                        "                                       %s:%d in client 
mode)\n"
                        "  -L: local point code (default is %d in server mode, 
%d in client mode)\n"
-                       "  -R: remote point code (default is %d in server mode, 
%d in client mode)\n",
-                       "  -d: LOGMASK (libosmocore log mask string, e.g. -d 
DLINP,1:DLSS7,2)\n"
+                       "  -R: remote point code (default is %d in server mode, 
%d in client mode)\n"
+                       "  -d: LOGMASK (libosmocore log mask string, e.g. -d 
DLINP,1:DLSS7,2)\n",
                        DEFAULT_LOCAL_ADDRESS_SERVER, DEFAULT_LOCAL_PORT_SERVER,
                        DEFAULT_LOCAL_ADDRESS_CLIENT, DEFAULT_LOCAL_PORT_CLIENT,
                        DEFAULT_REMOTE_ADDRESS_SERVER, 
DEFAULT_REMOTE_PORT_SERVER,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/examples/sccp_test_vty.c 
new/libosmo-sccp-1.7.0/examples/sccp_test_vty.c
--- old/libosmo-sccp-1.6.0/examples/sccp_test_vty.c     2022-06-28 
18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/examples/sccp_test_vty.c     2023-02-07 
14:37:23.000000000 +0100
@@ -38,35 +38,42 @@
 DEFUN(scu_conn_req, scu_conn_req_cmd,
        "connect-req <0-16777216> [DATA]",
        "N-CONNECT.req\n"
-       "Connection ID\n")
+       "Connection ID\n"
+       "Optional Data\n")
 {
        struct osmo_sccp_user *scu = vty->index;
-       int conn_id = atoi(argv[0]);
-       const char *data = argv[1];
+       int rc, conn_id = atoi(argv[0]);
+
+       rc = osmo_sccp_tx_conn_req(scu, conn_id, &g_calling_addr, 
&g_called_addr,
+                                                          (const uint8_t 
*)argv[1], (argc > 1) ? strlen(argv[1]) + 1 : 0);
+
+       if (rc < 0) {
+               vty_out(vty, "Error while sending N-CONNECT.req: %s%s", 
strerror(-rc), VTY_NEWLINE);
+               return CMD_WARNING;
+       }
 
-       osmo_sccp_tx_conn_req(scu, conn_id, &g_calling_addr, &g_called_addr,
-                               (const uint8_t *)data, data ? strlen(data)+1 : 
0);
        return CMD_SUCCESS;
 }
 
 DEFUN(scu_conn_resp, scu_conn_resp_cmd,
        "connect-resp <0-16777216> [DATA]",
        "N-CONNET.resp\n"
-       "Connection ID\n")
+       "Connection ID\n"
+       "Optional Data\n")
 {
        struct osmo_sccp_user *scu = vty->index;
        int conn_id = atoi(argv[0]);
-       const char *data = argv[1];
 
-       osmo_sccp_tx_conn_resp(scu, conn_id, NULL,
-                               (const uint8_t *)data, data ? strlen(data)+1 : 
0);
+       osmo_sccp_tx_conn_resp(scu, conn_id, NULL, (const uint8_t *)argv[1], 
(argc > 1) ? strlen(argv[1]) + 1 : 0);
+
        return CMD_SUCCESS;
 }
 
 DEFUN(scu_data_req, scu_data_req_cmd,
        "data-req <0-16777216> DATA",
-       "N-DATA.req\n"
-       "Connection ID\n")
+         "N-DATA.req\n"
+         "Connection ID\n"
+         "Data\n")
 {
        struct osmo_sccp_user *scu = vty->index;
        int conn_id = atoi(argv[0]);
@@ -89,14 +96,16 @@
 }
 
 DEFUN(scu_disc_req, scu_disc_req_cmd,
-       "disconnect-req <0-16777216>",
+       "disconnect-req <0-16777216> [DATA]",
        "N-DISCONNT.req\n"
-       "Connection ID\n")
+       "Connection ID\n"
+       "Optional Data\n")
 {
        struct osmo_sccp_user *scu = vty->index;
        int conn_id = atoi(argv[0]);
 
-       osmo_sccp_tx_disconn(scu, conn_id, NULL, 42);
+       osmo_sccp_tx_disconn_data(scu, conn_id, NULL, 42, (const uint8_t 
*)argv[1], (argc > 1) ? strlen(argv[1]) + 1 : 0);
+
        return CMD_SUCCESS;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/include/osmocom/sccp/sccp_types.h 
new/libosmo-sccp-1.7.0/include/osmocom/sccp/sccp_types.h
--- old/libosmo-sccp-1.6.0/include/osmocom/sccp/sccp_types.h    2022-06-28 
18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/include/osmocom/sccp/sccp_types.h    2023-02-07 
14:37:23.000000000 +0100
@@ -24,6 +24,9 @@
 #include <osmocom/core/endian.h>
 #include <osmocom/core/utils.h>
 
+#define SCCP_MAX_OPTIONAL_DATA 130
+#define SCCP_MAX_DATA 256
+
 /* Table 1/Q.713 - SCCP message types */
 enum sccp_message_types {
        SCCP_MSG_TYPE_CR        = 1,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libosmo-sccp-1.6.0/include/osmocom/sigtran/sccp_helpers.h 
new/libosmo-sccp-1.7.0/include/osmocom/sigtran/sccp_helpers.h
--- old/libosmo-sccp-1.6.0/include/osmocom/sigtran/sccp_helpers.h       
2022-06-28 18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/include/osmocom/sigtran/sccp_helpers.h       
2023-02-07 14:37:23.000000000 +0100
@@ -44,6 +44,10 @@
                         const struct osmo_sccp_addr *resp_addr,
                         uint32_t cause);
 
+int osmo_sccp_tx_disconn_data(struct osmo_sccp_user *scu, uint32_t conn_id,
+                               const struct osmo_sccp_addr *resp_addr,
+                               uint32_t cause, const uint8_t *data, size_t 
len);
+
 int osmo_sccp_tx_conn_resp_msg(struct osmo_sccp_user *scu, uint32_t conn_id,
                                const struct osmo_sccp_addr *resp_addr,
                                struct msgb *msg);
@@ -67,5 +71,7 @@
                              const struct osmo_sccp_addr *addr);
 char *osmo_sccp_addr_to_id_c(void *ctx, const struct osmo_ss7_instance *ss7, 
const struct osmo_sccp_addr *addr);
 
+bool osmo_sccp_conn_id_exists(const struct osmo_sccp_instance *inst, uint32_t 
id);
+
 char *osmo_sccp_addr_name(const struct osmo_ss7_instance *ss7, const struct 
osmo_sccp_addr *addr);
 char *osmo_sccp_inst_addr_name(const struct osmo_sccp_instance *sccp, const 
struct osmo_sccp_addr *addr);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libosmo-sccp-1.6.0/include/osmocom/sigtran/sccp_sap.h 
new/libosmo-sccp-1.7.0/include/osmocom/sigtran/sccp_sap.h
--- old/libosmo-sccp-1.6.0/include/osmocom/sigtran/sccp_sap.h   2022-06-28 
18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/include/osmocom/sigtran/sccp_sap.h   2023-02-07 
14:37:23.000000000 +0100
@@ -273,7 +273,7 @@
 
 #define msgb_scu_prim(msg) ((struct osmo_scu_prim *)(msg)->l1h)
 
-char *osmo_scu_prim_name(struct osmo_prim_hdr *oph);
+char *osmo_scu_prim_name(const struct osmo_prim_hdr *oph);
 
 struct osmo_ss7_instance;
 struct osmo_sccp_instance;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/src/Makefile.am 
new/libosmo-sccp-1.7.0/src/Makefile.am
--- old/libosmo-sccp-1.6.0/src/Makefile.am      2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/src/Makefile.am      2023-02-07 14:37:23.000000000 
+0100
@@ -25,7 +25,7 @@
 # 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=7:1:0
+LIBVERSION=8:0:1
 
 libosmo_sigtran_la_SOURCES = sccp_sap.c sua.c m3ua.c xua_msg.c sccp_helpers.c \
                             sccp2sua.c sccp_scrc.c sccp_sclc.c sccp_scoc.c \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/src/sccp.c 
new/libosmo-sccp-1.7.0/src/sccp.c
--- old/libosmo-sccp-1.6.0/src/sccp.c   2022-06-28 18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/src/sccp.c   2023-02-07 14:37:23.000000000 +0100
@@ -20,6 +20,7 @@
  *
  */
 
+#include <errno.h>
 #include <string.h>
 
 #include <osmocom/core/msgb.h>
@@ -27,7 +28,7 @@
 #include <osmocom/core/logging.h>
 #include <osmocom/core/endian.h>
 #include <osmocom/gsm/tlv.h>
-
+#include <osmocom/sccp/sccp_types.h>
 #include <osmocom/sccp/sccp.h>
 
 // Unassigned debug area
@@ -226,6 +227,12 @@
        }
 
        if (optional_data.data_len != 0) {
+               if (optional_data.data_len > SCCP_MAX_OPTIONAL_DATA) {
+                       LOGP(DSCCP, LOGL_ERROR,
+                                "optional data has length %u exceeding max of 
%u according to ITU-T Rec. Q.713 §4.2\n",
+                                optional_data.data_len, 
SCCP_MAX_OPTIONAL_DATA);
+                       return -EMSGSIZE;
+               }
                msgb->l3h = &msgb->l2h[optional_data.data_start];
                result->data_len = optional_data.data_len;
        } else {
@@ -260,6 +267,12 @@
        result->destination_local_reference = &rls->destination_local_reference;
 
        if (optional_data.data_len != 0) {
+               if (optional_data.data_len > SCCP_MAX_OPTIONAL_DATA) {
+                       LOGP(DSCCP, LOGL_ERROR,
+                                "optional data has length %u exceeding max of 
%u according to ITU-T Rec. Q.713 §4.5\n",
+                                optional_data.data_len, 
SCCP_MAX_OPTIONAL_DATA);
+                       return -EMSGSIZE;
+               }
                msgb->l3h = &msgb->l2h[optional_data.data_start];
                result->data_len = optional_data.data_len;
        } else {
@@ -297,6 +310,12 @@
 
        /* optional data */
        if (optional_data.data_len != 0) {
+               if (optional_data.data_len > SCCP_MAX_OPTIONAL_DATA) {
+                       LOGP(DSCCP, LOGL_ERROR,
+                                "optional data has length %u exceeding max of 
%u according to ITU-T Rec. Q.713 §4.4\n",
+                                optional_data.data_len, 
SCCP_MAX_OPTIONAL_DATA);
+                       return -EMSGSIZE;
+               }
                msgb->l3h = &msgb->l2h[optional_data.data_start];
                result->data_len = optional_data.data_len;
        } else {
@@ -334,6 +353,12 @@
        }
 
        if (optional_data.data_len != 0) {
+               if (optional_data.data_len > SCCP_MAX_OPTIONAL_DATA) {
+                       LOGP(DSCCP, LOGL_ERROR,
+                                "optional data has length %u exceeding max of 
%u according to ITU-T Rec. Q.713 §4.3\n",
+                                optional_data.data_len, 
SCCP_MAX_OPTIONAL_DATA);
+                       return -EMSGSIZE;
+               }
                msgb->l3h = &msgb->l2h[optional_data.data_start];
                result->data_len = optional_data.data_len;
        } else {
@@ -818,9 +843,11 @@
        uint8_t extra_size = 3 + 1;
        int called_len;
 
-       if (l3_data && (l3_length < 3 || l3_length > 130)) {
-               LOGP(DSCCP, LOGL_ERROR, "Invalid amount of data... %zu\n", 
l3_length);
-               return NULL;
+       if (l3_data) {
+               if (l3_length < 3 || l3_length > SCCP_MAX_OPTIONAL_DATA) {
+                       LOGP(DSCCP, LOGL_ERROR, "Invalid amount of data... 
%zu\n", l3_length);
+                       return NULL;
+               }
        }
 
        if (l3_data)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/src/sccp2sua.c 
new/libosmo-sccp-1.7.0/src/sccp2sua.c
--- old/libosmo-sccp-1.6.0/src/sccp2sua.c       2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/src/sccp2sua.c       2023-02-07 14:37:23.000000000 
+0100
@@ -26,6 +26,7 @@
 #include <stdbool.h>
 #include <string.h>
 #include <errno.h>
+#include <inttypes.h>
 
 #include <osmocom/sccp/sccp.h>
 #include <osmocom/core/linuxlist.h>
@@ -1002,13 +1003,18 @@
        return 0;
 }
 
-/* store a 'local reference' as big-eidian 24bit value at local_ref */
-static void store_local_ref(struct sccp_source_reference *local_ref, struct 
xua_msg *xua, uint16_t iei)
+/* store a 'local reference' as big-endian 24bit value at local_ref */
+static int store_local_ref(struct sccp_source_reference *local_ref, struct 
xua_msg *xua, uint16_t iei)
 {
        uint32_t tmp32 = xua_msg_get_u32(xua, iei);
+       if (tmp32 > 0x00fffffe) {
+               LOGP(DLSUA, LOGL_ERROR, "SUA->SCCP: Local Reference value 0x%" 
PRIx32 " > 0x00fffffe\n", tmp32);
+               return -1;
+       }
        local_ref->octet1 = (tmp32 >> 16) & 0xff;
        local_ref->octet2 = (tmp32 >> 8) & 0xff;
        local_ref->octet3 = tmp32 & 0xff;
+       return 0;
 }
 
 /*! \returns \ref xua in case of success, NULL on error (xua not freed!) */
@@ -1031,12 +1037,15 @@
 static int sua_to_sccp_cr(struct msgb *msg, struct xua_msg *xua)
 {
        struct sccp_connection_request *req;
+       int rc;
        req = (struct sccp_connection_request *) msgb_put(msg, sizeof(*req));
 
        /* Fixed Part */
        req->type = SCCP_MSG_TYPE_CR;
        req->proto_class = xua_msg_get_u32(xua, SUA_IEI_PROTO_CLASS);
-       store_local_ref(&req->source_local_reference, xua, SUA_IEI_SRC_REF);
+       rc = store_local_ref(&req->source_local_reference, xua, 
SUA_IEI_SRC_REF);
+       if (rc < 0)
+               return rc;
        /* Variable Part */
        sccp_add_var_addr(msg, &req->variable_called, xua, SUA_IEI_DEST_ADDR);
 
@@ -1061,13 +1070,18 @@
 static int sua_to_sccp_cc(struct msgb *msg, struct xua_msg *xua)
 {
        struct sccp_connection_confirm *cnf;
+       int rc;
        cnf = (struct sccp_connection_confirm *) msgb_put(msg, sizeof(*cnf));
 
        /* Fixed Part */
        cnf->type = SCCP_MSG_TYPE_CC;
        cnf->proto_class = xua_msg_get_u32(xua, SUA_IEI_PROTO_CLASS);
-       store_local_ref(&cnf->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
-       store_local_ref(&cnf->source_local_reference, xua, SUA_IEI_SRC_REF);
+       rc = store_local_ref(&cnf->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       if (rc < 0)
+               return rc;
+       rc = store_local_ref(&cnf->source_local_reference, xua, 
SUA_IEI_SRC_REF);
+       if (rc < 0)
+               return rc;
        /* Optional Part */
        return xua_ies_to_sccp_opts(msg, &cnf->optional_start, cnf->type, xua);
 }
@@ -1088,11 +1102,14 @@
 static int sua_to_sccp_cref(struct msgb *msg, struct xua_msg *xua)
 {
        struct sccp_connection_refused *ref;
+       int rc;
        ref = (struct sccp_connection_refused *) msgb_put(msg, sizeof(*ref));
 
        /* Fixed Part */
        ref->type = SCCP_MSG_TYPE_CREF;
-       store_local_ref(&ref->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       rc = store_local_ref(&ref->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       if (rc < 0)
+               return rc;
        ref->cause = xua_msg_get_u32(xua, SUA_IEI_CAUSE) & 0xff;
        /* Optional Part */
        return xua_ies_to_sccp_opts(msg, &ref->optional_start, ref->type, xua);
@@ -1114,12 +1131,17 @@
 static int sua_to_sccp_rlsd(struct msgb *msg, struct xua_msg *xua)
 {
        struct sccp_connection_released *rlsd;
+       int rc;
        rlsd =(struct sccp_connection_released *) msgb_put(msg, sizeof(*rlsd));
 
        /* Fixed Part */
        rlsd->type = SCCP_MSG_TYPE_RLSD;
-       store_local_ref(&rlsd->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
-       store_local_ref(&rlsd->source_local_reference, xua, SUA_IEI_SRC_REF);
+       rc = store_local_ref(&rlsd->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       if (rc < 0)
+               return rc;
+       rc = store_local_ref(&rlsd->source_local_reference, xua, 
SUA_IEI_SRC_REF);
+       if (rc < 0)
+               return rc;
        rlsd->release_cause = xua_msg_get_u32(xua, SUA_IEI_CAUSE) & 0xff;
 
        /* Optional Part */
@@ -1141,12 +1163,17 @@
 static int sua_to_sccp_rlc(struct msgb *msg, struct xua_msg *xua)
 {
        struct sccp_connection_release_complete *rlc;
+       int rc;
        rlc = (struct sccp_connection_release_complete *) msgb_put(msg, 
sizeof(*rlc));
 
        /* Fixed Part */
        rlc->type = SCCP_MSG_TYPE_RLC;
-       store_local_ref(&rlc->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
-       store_local_ref(&rlc->source_local_reference, xua, SUA_IEI_SRC_REF);
+       rc = store_local_ref(&rlc->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       if (rc < 0)
+               return rc;
+       rc = store_local_ref(&rlc->source_local_reference, xua, 
SUA_IEI_SRC_REF);
+       if (rc < 0)
+               return rc;
        return 0;
 }
 
@@ -1168,11 +1195,14 @@
 static int sua_to_sccp_dt1(struct msgb *msg, struct xua_msg *xua)
 {
        struct sccp_data_form1 *dt1;
+       int rc;
        dt1 = (struct sccp_data_form1 *) msgb_put(msg, sizeof(*dt1));
 
        /* Fixed Part */
        dt1->type = SCCP_MSG_TYPE_DT1;
-       store_local_ref(&dt1->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       rc = store_local_ref(&dt1->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       if (rc < 0)
+               return rc;
        dt1->segmenting = xua_msg_get_u32(xua, SUA_IEI_SEGMENTATION);
        /* Variable Part */
        sccp_add_variable_part(msg, &dt1->variable_start, xua, SUA_IEI_DATA);
@@ -1365,13 +1395,18 @@
 static int sua_to_sccp_it(struct msgb *msg, struct xua_msg *xua)
 {
        struct sccp_data_it *it;
+       int rc;
        it = (struct sccp_data_it *) msgb_put(msg, sizeof(*it));
 
        /* Fixed Part */
        it->type = SCCP_MSG_TYPE_IT;
        it->proto_class = xua_msg_get_u32(xua, SUA_IEI_PROTO_CLASS);
-       store_local_ref(&it->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
-       store_local_ref(&it->source_local_reference, xua, SUA_IEI_SRC_REF);
+       rc = store_local_ref(&it->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       if (rc < 0)
+               return rc;
+       rc = store_local_ref(&it->source_local_reference, xua, SUA_IEI_SRC_REF);
+       if (rc < 0)
+               return rc;
        if ((it->proto_class & 0xF) == 3) {
                //it->sequencing
                it->credit = xua_msg_get_u32(xua, SUA_IEI_CREDIT);
@@ -1394,11 +1429,14 @@
 static int sua_to_sccp_err(struct msgb *msg, struct xua_msg *xua)
 {
        struct sccp_proto_err *err;
+       int rc;
        err = (struct sccp_proto_err *) msgb_put(msg, sizeof(*err));
 
        /* Fixed Part */
        err->type = SCCP_MSG_TYPE_ERR;
-       store_local_ref(&err->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       rc = store_local_ref(&err->destination_local_reference, xua, 
SUA_IEI_DEST_REF);
+       if (rc < 0)
+               return rc;
        err->error_cause = xua_msg_get_u32(xua, SUA_IEI_CAUSE) & 0xff;
        return 0;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/src/sccp_helpers.c 
new/libosmo-sccp-1.7.0/src/sccp_helpers.c
--- old/libosmo-sccp-1.6.0/src/sccp_helpers.c   2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/src/sccp_helpers.c   2023-02-07 14:37:23.000000000 
+0100
@@ -21,6 +21,7 @@
  *
  */
 
+#include <errno.h>
 #include <string.h>
 #include <stdbool.h>
 
@@ -28,6 +29,7 @@
 #include <arpa/inet.h>
 #include <netinet/in.h>
 
+#include <osmocom/sccp/sccp_types.h>
 #include <osmocom/sigtran/sccp_sap.h>
 #include <osmocom/sigtran/sccp_helpers.h>
 
@@ -152,9 +154,21 @@
 int osmo_sccp_tx_data(struct osmo_sccp_user *scu, uint32_t conn_id,
                      const uint8_t *data, unsigned int len)
 {
-       struct msgb *msg = scu_msgb_alloc(__func__);
+       struct msgb *msg;
        struct osmo_scu_prim *prim;
 
+       if (!osmo_sccp_conn_id_exists(scu->inst, conn_id)) {
+               LOGP(DLSCCP, LOGL_ERROR, "N-DATA.req TX error: unable to find 
connection ID (local_ref) %u\n", conn_id);
+               return -ENOTCONN;
+       }
+
+       if (len > SCCP_MAX_DATA) {
+               LOGP(DLSCCP, LOGL_ERROR, "N-DATA.req TX error: amount of data 
%u > %u - ITU-T Rec. Q.713 §4.7 limit\n",
+                        len, SCCP_MAX_DATA);
+               return -EMSGSIZE;
+       }
+
+       msg = scu_msgb_alloc(__func__);
        prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
        osmo_prim_init(&prim->oph, SCCP_SAP_USER,
                        OSMO_SCU_PRIM_N_DATA,
@@ -179,14 +193,20 @@
 }
 
 /* N-DISCONNECT.req */
-int osmo_sccp_tx_disconn(struct osmo_sccp_user *scu, uint32_t conn_id,
-                        const struct osmo_sccp_addr *resp_addr,
-                        uint32_t cause)
+int osmo_sccp_tx_disconn_data(struct osmo_sccp_user *scu, uint32_t conn_id,
+                               const struct osmo_sccp_addr *resp_addr,
+                               uint32_t cause, const uint8_t *data, size_t len)
 {
-       struct msgb *msg = scu_msgb_alloc(__func__);
+       struct msgb *msg;
        struct osmo_scu_prim *prim;
        struct osmo_scu_disconn_param *param;
 
+       if (!osmo_sccp_conn_id_exists(scu->inst, conn_id)) {
+               LOGP(DLSCCP, LOGL_ERROR, "N-DISCONNECT.req TX error: unable to 
find connection ID (local_ref) %u\n", conn_id);
+               return -ENOTCONN;
+       }
+
+       msg = scu_msgb_alloc(__func__);
        prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
        osmo_prim_init(&prim->oph, SCCP_SAP_USER,
                        OSMO_SCU_PRIM_N_DISCONNECT,
@@ -199,9 +219,21 @@
        param->conn_id = conn_id;
        param->cause = cause;
 
+       if (data && len) {
+               msg->l2h = msgb_put(msg, len);
+               memcpy(msg->l2h, data, len);
+       }
+
        return osmo_sccp_user_sap_down(scu, &prim->oph);
 }
 
+int osmo_sccp_tx_disconn(struct osmo_sccp_user *scu, uint32_t conn_id,
+                        const struct osmo_sccp_addr *resp_addr,
+                        uint32_t cause)
+{
+       return osmo_sccp_tx_disconn_data(scu, conn_id, resp_addr, cause, NULL, 
0);
+}
+
 /* N-CONNECT.resp */
 int osmo_sccp_tx_conn_resp_msg(struct osmo_sccp_user *scu, uint32_t conn_id,
                                const struct osmo_sccp_addr *resp_addr,
@@ -210,6 +242,11 @@
        struct osmo_scu_prim *prim;
        struct osmo_scu_connect_param *param;
 
+       if (!osmo_sccp_conn_id_exists(scu->inst, conn_id)) {
+               LOGP(DLSCCP, LOGL_ERROR, "N-CONNECT.resp TX error: unable to 
find connection ID (local_ref) %u\n", conn_id);
+               return -ENOTCONN;
+       }
+
        msg->l2h = msg->data;
 
        prim = (struct osmo_scu_prim *) msgb_push(msg, sizeof(*prim));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/src/sccp_sap.c 
new/libosmo-sccp-1.7.0/src/sccp_sap.c
--- old/libosmo-sccp-1.6.0/src/sccp_sap.c       2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/src/sccp_sap.c       2023-02-07 14:37:23.000000000 
+0100
@@ -43,7 +43,7 @@
 
 static char prim_name_buf[128];
 
-char *osmo_scu_prim_name(struct osmo_prim_hdr *oph)
+char *osmo_scu_prim_name(const struct osmo_prim_hdr *oph)
 {
        const char *name = get_value_string(osmo_scu_prim_names, 
oph->primitive);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/src/sccp_scoc.c 
new/libosmo-sccp-1.7.0/src/sccp_scoc.c
--- old/libosmo-sccp-1.6.0/src/sccp_scoc.c      2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/src/sccp_scoc.c      2023-02-07 14:37:23.000000000 
+0100
@@ -46,14 +46,16 @@
  *  * use of multiple Routing Contexts in SUA case
  */
 
+#include <errno.h>
 #include <string.h>
 
+#include <osmocom/core/msgb.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/logging.h>
 #include <osmocom/core/timer.h>
 #include <osmocom/core/fsm.h>
-
+#include <osmocom/sigtran/sccp_helpers.h>
 #include <osmocom/sigtran/sccp_sap.h>
 #include <osmocom/sigtran/protocol/sua.h>
 #include <osmocom/sccp/sccp_types.h>
@@ -98,6 +100,8 @@
        uint32_t sccp_class;
        uint32_t release_cause; /* WAIT_CONN_CONF */
 
+       struct msgb *opt_data_cache;
+
        /* incoming (true) or outgoing (false) */
        bool incoming;
 
@@ -445,7 +449,7 @@
 
 static void conn_destroy(struct sccp_connection *conn);
 
-static struct sccp_connection *conn_find_by_id(struct osmo_sccp_instance 
*inst, uint32_t id)
+static struct sccp_connection *conn_find_by_id(const struct osmo_sccp_instance 
*inst, uint32_t id)
 {
        struct sccp_connection *conn;
 
@@ -456,6 +460,11 @@
        return NULL;
 }
 
+bool osmo_sccp_conn_id_exists(const struct osmo_sccp_instance *inst, uint32_t 
id)
+{
+       return conn_find_by_id(inst, id) ? true : false;
+}
+
 #define INIT_TIMER(x, fn, priv)                do { (x)->cb = fn; (x)->data = 
priv; } while (0)
 
 /* allocate + init a SCCP Connection with given ID */
@@ -508,10 +517,20 @@
        return conn_create_id(user, conn_id);
 }
 
+static void conn_opt_data_clear_cache(struct sccp_connection *conn)
+{
+       if (conn->opt_data_cache) {
+               msgb_free(conn->opt_data_cache);
+               conn->opt_data_cache = NULL;
+       }
+}
+
 /* destroy a SCCP connection state, releasing all timers, terminating
  * FSM and releasing associated memory */
 static void conn_destroy(struct sccp_connection *conn)
 {
+       conn_opt_data_clear_cache(conn);
+
        conn_stop_connect_timer(conn);
        conn_stop_inact_timers(conn);
        conn_stop_release_timers(conn);
@@ -569,11 +588,112 @@
        return 0;
 }
 
+/* Send cached optional data (if any) from expected message type and clear 
cache */
+static void xua_opt_data_send_cache(struct sccp_connection *conn, int 
exp_type, uint8_t msg_class)
+{
+       const struct xua_dialect *dialect = &xua_dialect_sua;
+       const struct xua_msg_class *xmc = dialect->class[msg_class];
+
+       if (!conn->opt_data_cache)
+               return;
+
+       if (conn->opt_data_cache->cb[0] != exp_type) {
+               /* Caller (from the FSM) knows what was the source of Optional 
Data we're sending.
+                * Compare this information with source of Optional Data 
recorded while caching
+                * to make sure we're on the same page.
+                */
+               LOGP(DLSCCP, LOGL_ERROR, "unexpected message type %s != cache 
source %s\n",
+                        xua_class_msg_name(xmc, exp_type), 
xua_class_msg_name(xmc, conn->opt_data_cache->cb[0]));
+       } else {
+               osmo_sccp_tx_data(conn->user, conn->conn_id, 
msgb_data(conn->opt_data_cache), msgb_length(conn->opt_data_cache));
+       }
+
+       conn_opt_data_clear_cache(conn);
+}
+
+/* Check if optional data should be dropped, log given error message if so */
+static bool xua_drop_data_check_drop(const struct osmo_scu_prim *prim, 
unsigned lim, const char *message)
+{
+       if (msgb_l2len(prim->oph.msg) > lim) {
+               LOGP(DLSCCP, LOGL_ERROR,
+                        "%s: dropping optional data with length %u > %u - 
%s\n",
+                        osmo_scu_prim_name(&prim->oph), 
msgb_l2len(prim->oph.msg), lim, message);
+               return true;
+       }
+       return false;
+}
+
+/* Cache the optional data (if necessary)
+ * returns true if Optional Data should be kept while encoding the message */
+static bool xua_opt_data_cache_keep(struct sccp_connection *conn, const struct 
osmo_scu_prim *prim, int msg_type)
+{
+       uint8_t *buf;
+
+       if (xua_drop_data_check_drop(prim, SCCP_MAX_DATA, "cache overrun"))
+               return false;
+
+       if (msgb_l2len(prim->oph.msg) > SCCP_MAX_OPTIONAL_DATA) {
+               if (conn->opt_data_cache) {
+                       /* Caching optional data, but there already is optional 
data occupying the cache: */
+                       LOGP(DLSCCP, LOGL_ERROR, "replacing unsent %u bytes of 
optional data cache with %s optional data\n",
+                                msgb_length(conn->opt_data_cache), 
osmo_scu_prim_name(&prim->oph));
+                       msgb_trim(conn->opt_data_cache, 0);
+               } else {
+                       conn->opt_data_cache = msgb_alloc_c(conn, 
SCCP_MAX_DATA, "SCCP optional data cache for CR/CC/RLSD");
+               }
+
+               buf = msgb_put(conn->opt_data_cache, msgb_l2len(prim->oph.msg));
+               memcpy(buf, msgb_l2(prim->oph.msg), msgb_l2len(prim->oph.msg));
+
+               conn->opt_data_cache->cb[0] = msg_type;
+
+               return false;
+       }
+       return true;
+}
+
+/* Check optional Data size limit, cache if necessary, return indication 
whether original opt data should be sent */
+static bool xua_opt_data_length_lim(struct sccp_connection *conn, const struct 
osmo_scu_prim *prim, int msg_type)
+{
+       if (!(prim && msgb_l2(prim->oph.msg) && msgb_l2len(prim->oph.msg)))
+               return false;
+
+       switch (msg_type) {
+       case SUA_CO_CORE: /* §4.2 Connection request (CR) */
+       case SUA_CO_COAK: /* §4.3 Connection confirm (CC) */
+               return xua_opt_data_cache_keep(conn, prim, msg_type);
+       case SUA_CO_COREF: /* §4.4 Connection refused (CREF) */
+               if (xua_drop_data_check_drop(prim, SCCP_MAX_OPTIONAL_DATA, 
"over ITU-T Rec. Q.713 §4.4 limit")) {
+                       /* From the state diagrams in ITU-T Rec Q.714, there's 
no way to send DT1 neither before nor after CREF
+                        * at this point, so the only option we have is to drop 
optional data:
+                        * see Figure C.3 / Q.714 (sheet 2 of 6) */
+                       return false;
+               }
+               break;
+       case SUA_CO_RELRE: /* §4.5 Released (RLSD) */
+               if (msgb_l2len(prim->oph.msg) > SCCP_MAX_OPTIONAL_DATA) {
+                       if (xua_drop_data_check_drop(prim, SCCP_MAX_DATA, 
"protocol error"))
+                               return false;
+                       /* There's no need to cache the optional data since the 
connection is still active at this point:
+                        * Send the Optional Data in a DT1 ahead of the RLSD, 
because it is too large to be sent in one message.
+                        */
+                       osmo_sccp_tx_data(conn->user, conn->conn_id, 
msgb_l2(prim->oph.msg), msgb_l2len(prim->oph.msg));
+                       return false;
+               }
+               break;
+       default:
+               return true;
+       }
+
+       return true;
+}
+
 /* generate a 'struct xua_msg' of requested type from connection +
  * primitive data */
 static struct xua_msg *xua_gen_msg_co(struct sccp_connection *conn, uint32_t 
event,
-                                     struct osmo_scu_prim *prim, int msg_type)
+                                     const struct osmo_scu_prim *prim, int 
msg_type)
 {
+       bool encode_opt_data = xua_opt_data_length_lim(conn, prim, msg_type);
        struct xua_msg *xua = xua_msg_alloc();
 
        if (!xua)
@@ -590,10 +710,11 @@
                /* optional: sequence number (class 3 only) */
                if (conn->calling_addr.presence)
                        xua_msg_add_sccp_addr(xua, SUA_IEI_SRC_ADDR, 
&conn->calling_addr);
-               /* optional: hop count; importance; priority; credit */
-               if (prim && msgb_l2(prim->oph.msg) && msgb_l2len(prim->oph.msg))
-                       xua_msg_add_data(xua, SUA_IEI_DATA, 
msgb_l2len(prim->oph.msg),
-                                        msgb_l2(prim->oph.msg));
+               /* optional: data */
+               if (encode_opt_data)
+                       xua_msg_add_data(xua, SUA_IEI_DATA, 
msgb_l2len(prim->oph.msg), msgb_l2(prim->oph.msg));
+               /* optional: hop count */
+               /* optional: importance */
                break;
        case SUA_CO_COAK: /* Connect Acknowledge == SCCP CC */
                xua->hdr = XUA_HDR(SUA_MSGC_CO, SUA_CO_COAK);
@@ -611,9 +732,10 @@
                 * parameter */
                if (conn->calling_addr.presence)
                        xua_msg_add_sccp_addr(xua, SUA_IEI_DEST_ADDR, 
&conn->calling_addr);
-               if (prim && msgb_l2(prim->oph.msg) && msgb_l2len(prim->oph.msg))
-                       xua_msg_add_data(xua, SUA_IEI_DATA, 
msgb_l2len(prim->oph.msg),
-                                        msgb_l2(prim->oph.msg));
+               /* optional: data */
+               if (encode_opt_data)
+                       xua_msg_add_data(xua, SUA_IEI_DATA, 
msgb_l2len(prim->oph.msg), msgb_l2(prim->oph.msg));
+               /* optional: importance */
                break;
        case SUA_CO_RELRE: /* Release Request == SCCP RLSD */
                if (!prim)
@@ -623,17 +745,16 @@
                xua_msg_add_u32(xua, SUA_IEI_DEST_REF, conn->remote_ref);
                xua_msg_add_u32(xua, SUA_IEI_SRC_REF, conn->conn_id);
                xua_msg_add_u32(xua, SUA_IEI_CAUSE, SUA_CAUSE_T_RELEASE | 
prim->u.disconnect.cause);
+               /* optional: data */
+               if (encode_opt_data)
+                       xua_msg_add_data(xua, SUA_IEI_DATA, 
msgb_l2len(prim->oph.msg), msgb_l2(prim->oph.msg));
                /* optional: importance */
-               if (prim && msgb_l2(prim->oph.msg) && msgb_l2len(prim->oph.msg))
-                       xua_msg_add_data(xua, SUA_IEI_DATA, 
msgb_l2len(prim->oph.msg),
-                                        msgb_l2(prim->oph.msg));
                break;
        case SUA_CO_RELCO: /* Release Confirm == SCCP RLC */
                xua->hdr = XUA_HDR(SUA_MSGC_CO, SUA_CO_RELCO);
                xua_msg_add_u32(xua, SUA_IEI_ROUTE_CTX, conn->inst->route_ctx);
                xua_msg_add_u32(xua, SUA_IEI_DEST_REF, conn->remote_ref);
                xua_msg_add_u32(xua, SUA_IEI_SRC_REF, conn->conn_id);
-               /* optional: importance */
                break;
        case SUA_CO_CODT: /* Connection Oriented Data Transfer == SCCP DT1 */
                if (!prim)
@@ -666,11 +787,10 @@
                /* conditional: dest addr */
                if (conn->calling_addr.presence)
                        xua_msg_add_sccp_addr(xua, SUA_IEI_DEST_ADDR, 
&conn->calling_addr);
-               /* optional: importance */
                /* optional: data */
-               if (prim && msgb_l2(prim->oph.msg) && msgb_l2len(prim->oph.msg))
-                       xua_msg_add_data(xua, SUA_IEI_DATA, 
msgb_l2len(prim->oph.msg),
-                                        msgb_l2(prim->oph.msg));
+               if (encode_opt_data)
+                       xua_msg_add_data(xua, SUA_IEI_DATA, 
msgb_l2len(prim->oph.msg), msgb_l2(prim->oph.msg));
+               /* optional: importance */
                break;
        /* FIXME */
        default:
@@ -687,15 +807,17 @@
        return NULL;
 }
 
-/* generate xua_msg, encode it and send it to SCRC */
+/* generate xua_msg, encode it and send it to SCRC
+ * returns 0 on success, negative on error
+ */
 static int xua_gen_encode_and_send(struct sccp_connection *conn, uint32_t 
event,
-                                  struct osmo_scu_prim *prim, int msg_type)
+                                  const struct osmo_scu_prim *prim, int 
msg_type)
 {
        struct xua_msg *xua;
 
        xua = xua_gen_msg_co(conn, event, prim, msg_type);
        if (!xua)
-               return -1;
+               return -ENOMEM;
 
        /* amend this with point code information; Many CO msgs
         * includes neither called nor calling party address! */
@@ -817,6 +939,7 @@
        struct osmo_scu_prim *prim = NULL;
        struct osmo_scu_connect_param *uconp;
        struct xua_msg *xua = NULL;
+       int rc;
 
        switch (event) {
        case SCOC_E_SCU_N_CONN_REQ:
@@ -827,10 +950,14 @@
                conn->calling_addr = uconp->calling_addr;
                conn->sccp_class = uconp->sccp_class;
                /* generate + send CR PDU to SCRC */
-               xua_gen_encode_and_send(conn, event, prim, SUA_CO_CORE);
-               /* start connection timer */
-               conn_start_connect_timer(conn);
-               osmo_fsm_inst_state_chg(fi, S_CONN_PEND_OUT, 0, 0);
+               rc = xua_gen_encode_and_send(conn, event, prim, SUA_CO_CORE);
+               if (rc < 0)
+                       LOGPFSML(fi, LOGL_ERROR, "Failed to initiate 
connection: %s\n", strerror(-rc));
+               else {
+                       /* start connection timer */
+                       conn_start_connect_timer(conn);
+                       osmo_fsm_inst_state_chg(fi, S_CONN_PEND_OUT, 0, 0);
+               }
                break;
 #if 0
        case SCOC_E_SCU_N_TYPE1_REQ:
@@ -901,11 +1028,13 @@
                /* start inactivity timers */
                conn_start_inact_timers(conn);
                osmo_fsm_inst_state_chg(fi, S_ACTIVE, 0, 0);
+               xua_opt_data_send_cache(conn, SUA_CO_COAK, SUA_MSGC_CO);
                break;
        case SCOC_E_SCU_N_DISC_REQ:
                prim = data;
                /* release resources: implicit */
                xua_gen_encode_and_send(conn, event, prim, SUA_CO_COREF);
+               /* N. B: we've ignored CREF sending errors as there's no 
recovery option anyway */
                osmo_fsm_inst_state_chg(fi, S_IDLE, 0, 0);
                break;
        }
@@ -982,6 +1111,11 @@
                conn->remote_pc = xua->mtp.opc;
 
                osmo_fsm_inst_state_chg(fi, S_ACTIVE, 0, 0);
+               /* If CR which was used to initiate this connection had 
excessive Optional Data which we had to cache,
+                * now is the time to send it: the connection is already active 
but we hadn't notified upper layers about it
+                * so we have the connection all to ourselves and can use it to 
transmit "leftover" data via DT1 */
+               xua_opt_data_send_cache(conn, SUA_CO_CORE, xua->hdr.msg_class);
+
                /* N-CONNECT.conf to user */
                scu_gen_encode_and_send(conn, event, xua, 
OSMO_SCU_PRIM_N_CONNECT,
                                        PRIM_OP_CONFIRM);
@@ -1592,11 +1726,12 @@
                                   struct xua_msg *xua)
 {
        LOGP(DLSCCP, LOGL_NOTICE,
-            "Received message for opc=%u=%s on conn with mismatching remote 
pc=%u=%s\n",
+            "Received message %s for opc=%u=%s on conn with mismatching remote 
pc=%u=%s\n",
+            xua_hdr_dump(xua, &xua_dialect_sua),
             xua->mtp.opc, osmo_ss7_pointcode_print(conn->inst->ss7, 
xua->mtp.opc),
             conn->remote_pc, osmo_ss7_pointcode_print2(conn->inst->ss7, 
conn->remote_pc));
        /* we have received a message with invalid origin PC and thus
-        * apply the action indiacted in Table B.2/Q.714 */
+        * apply the action indicated in Table B.2/Q.714 */
        switch (xua->hdr.msg_type) {
        case SUA_CO_RELRE: /* RLSD */
        case SUA_CO_RESRE: /* RSR */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/src/xua_snm.c 
new/libosmo-sccp-1.7.0/src/xua_snm.c
--- old/libosmo-sccp-1.6.0/src/xua_snm.c        2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/src/xua_snm.c        2023-02-07 14:37:23.000000000 
+0100
@@ -464,6 +464,8 @@
        const uint32_t *cong_level = xua_msg_get_u32p(xua, M3UA_IEI_CONG_IND, 
&_cong_level);
        int log_ss = osmo_ss7_asp_get_log_subsys(asp);
 
+       OSMO_ASSERT(ie_aff_pc);
+
        LOGPASP(asp, log_ss, LOGL_NOTICE, "RX SCON(%s) for %s level=%u\n", 
info_str ? info_str : "",
                format_affected_pcs_c(xua, asp->inst, ie_aff_pc), cong_level ? 
*cong_level : 0);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/tests/vty/ss7_asp_vty_test.c 
new/libosmo-sccp-1.7.0/tests/vty/ss7_asp_vty_test.c
--- old/libosmo-sccp-1.6.0/tests/vty/ss7_asp_vty_test.c 2022-06-28 
18:22:14.000000000 +0200
+++ new/libosmo-sccp-1.7.0/tests/vty/ss7_asp_vty_test.c 2023-02-07 
14:37:23.000000000 +0100
@@ -41,7 +41,7 @@
 const struct log_info log_info = {
 };
 
-static void print_help()
+static void print_help(void)
 {
        printf( "options:\n"
                "  -h   --help          this text\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libosmo-sccp-1.6.0/tests/xua/xua_test.c 
new/libosmo-sccp-1.7.0/tests/xua/xua_test.c
--- old/libosmo-sccp-1.6.0/tests/xua/xua_test.c 2022-06-28 18:22:14.000000000 
+0200
+++ new/libosmo-sccp-1.7.0/tests/xua/xua_test.c 2023-02-07 14:37:23.000000000 
+0100
@@ -572,7 +572,7 @@
        talloc_free(xua);
 }
 
-void test_sccp_addr_cmp()
+static void test_sccp_addr_cmp(void)
 {
        int ai;
        int bi;

++++++ harden_osmo-stp.service.patch ++++++
--- /var/tmp/diff_new_pack.MkRa8I/_old  2023-05-19 11:56:07.235468812 +0200
+++ /var/tmp/diff_new_pack.MkRa8I/_new  2023-05-19 11:56:07.239468835 +0200
@@ -1,7 +1,11 @@
-Index: libosmo-sccp-1.4.0/contrib/systemd/osmo-stp.service
+---
+ contrib/systemd/osmo-stp.service |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+Index: libosmo-sccp-1.7.0/contrib/systemd/osmo-stp.service
 ===================================================================
---- libosmo-sccp-1.4.0.orig/contrib/systemd/osmo-stp.service
-+++ libosmo-sccp-1.4.0/contrib/systemd/osmo-stp.service
+--- libosmo-sccp-1.7.0.orig/contrib/systemd/osmo-stp.service
++++ libosmo-sccp-1.7.0/contrib/systemd/osmo-stp.service
 @@ -3,6 +3,19 @@ Description=Osmocom STP (Signal Transfer
  Documentation=https://osmocom.org/projects/osmo-stp/wiki
  
@@ -21,5 +25,5 @@
 +# end of automatic additions 
  Type=simple
  Restart=always
- ExecStart=/usr/bin/osmo-stp -c /etc/osmocom/osmo-stp.cfg
+ StateDirectory=osmocom
 

Reply via email to