Hello community, here is the log from the commit of package libosmo-abis for openSUSE:Leap:15.2 checked in at 2020-01-17 12:01:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/libosmo-abis (Old) and /work/SRC/openSUSE:Leap:15.2/.libosmo-abis.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libosmo-abis" Fri Jan 17 12:01:13 2020 rev:13 rq:763625 version:0.8.0 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/libosmo-abis/libosmo-abis.changes 2020-01-15 15:22:33.358480526 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.libosmo-abis.new.26092/libosmo-abis.changes 2020-01-17 12:01:15.516499253 +0100 @@ -1,0 +2,16 @@ +Sun Jan 5 10:47:01 UTC 2020 - Martin Hauke <[email protected]> + +- Update to new upstream release 0.8.0 + * input/ipa_keepalive.c: make sure IPA keepalive FSM is registered + * input/ipaccess.c: propagate errors from ipa_parse_unitid() + * ipa: Allow setting local addr and port for struct ipa_client_conn + * ipa: ipa_server_link_close() add checks of link state + +------------------------------------------------------------------- +Thu Aug 15 04:29:02 UTC 2019 - Jan Engelhardt <[email protected]> + +- Update to new upstream release 0.7.0 + * ipaccess: allow TCP keepalive for IPA clients + * Add IPA keep-alive FSM implementation + +------------------------------------------------------------------- Old: ---- libosmo-abis-0.6.0.tar.xz New: ---- libosmo-abis-0.8.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libosmo-abis.spec ++++++ --- /var/tmp/diff_new_pack.8IYp3N/_old 2020-01-17 12:01:16.104499512 +0100 +++ /var/tmp/diff_new_pack.8IYp3N/_new 2020-01-17 12:01:16.108499513 +0100 @@ -1,7 +1,7 @@ # # spec file for package libosmo-abis # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,19 +12,19 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # -%define version_unconverted 0.6.0 +%define version_unconverted 0.8.0 Name: libosmo-abis -Version: 0.6.0 +Version: 0.8.0 Release: 0 Summary: Osmocom library for A-bis interface between BTS and BSC License: AGPL-3.0-or-later AND GPL-2.0-or-later Group: Productivity/Telephony/Utilities -Url: https://osmocom.org/projects/libosmo-abis/wiki/Libosmo-abis +URL: https://osmocom.org/projects/libosmo-abis/wiki/Libosmo-abis Source: %name-%version.tar.xz Patch1: osmo-talloc.diff @@ -108,7 +108,11 @@ %build echo "%version" >.tarball-version autoreconf -fiv -%configure --enable-shared --disable-static --includedir="%_includedir/%name" +%configure \ + --enable-shared \ + --disable-static \ + --disable-dahdi \ + --includedir="%_includedir/%name" make %{?_smp_mflags} %install ++++++ _service ++++++ --- /var/tmp/diff_new_pack.8IYp3N/_old 2020-01-17 12:01:16.128499522 +0100 +++ /var/tmp/diff_new_pack.8IYp3N/_new 2020-01-17 12:01:16.128499522 +0100 @@ -2,8 +2,8 @@ <service name="tar_scm" mode="disabled"> <param name="scm">git</param> <param name="url">git://git.osmocom.org/libosmo-abis</param> - <param name="parent-tag">0.6.0</param> - <param name="versionformat">0.6.0</param> + <param name="parent-tag">0.8.0</param> + <param name="versionformat">0.8.0</param> </service> <service name="recompress" mode="disabled"> <param name="file">*.tar</param> ++++++ libosmo-abis-0.6.0.tar.xz -> libosmo-abis-0.8.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/configure.ac new/libosmo-abis-0.8.0/configure.ac --- old/libosmo-abis-0.6.0/configure.ac 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/configure.ac 2020-01-02 20:53:32.000000000 +0100 @@ -64,7 +64,16 @@ PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.0.0) PKG_CHECK_MODULES(ORTP, ortp >= 0.22.0) -AC_CHECK_HEADERS(dahdi/user.h,,AC_MSG_WARN(DAHDI input driver will not be built)) +AC_ARG_ENABLE([dahdi], + AC_HELP_STRING([--disable-dahdi], + [disable support for DAHID ISDN (E1/T1) cards [default=yes]]), + [enable_dahdi="$enableval"], [enable_dahdi="yes"]) +AM_CONDITIONAL(ENABLE_DAHDI, test "x$enable_dahdi" = "xyes") +if test "x$enable_dahdi" = "xyes"; then + AC_CHECK_HEADERS([dahdi/user.h],[],[AC_MSG_ERROR([DAHDI input driver enabled but DAHDI not found])]) +else + AC_MSG_WARN([DAHDI input driver will not be built]) +fi AC_ARG_ENABLE(sanitize, [AS_HELP_STRING( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/contrib/jenkins.sh new/libosmo-abis-0.8.0/contrib/jenkins.sh --- old/libosmo-abis-0.6.0/contrib/jenkins.sh 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/contrib/jenkins.sh 2020-01-02 20:53:32.000000000 +0100 @@ -37,5 +37,6 @@ $MAKE $PARALLEL_MAKE $MAKE distcheck \ || cat-testlogs.sh +$MAKE maintainer-clean osmo-clean-workspace.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/debian/changelog new/libosmo-abis-0.8.0/debian/changelog --- old/libosmo-abis-0.6.0/debian/changelog 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/debian/changelog 2020-01-02 20:53:32.000000000 +0100 @@ -1,3 +1,53 @@ +libosmo-abis (0.8.0) unstable; urgency=medium + + [ Alexander Couzens ] + * ipa: ipa_server_link_close() add checks of link state + + [ Pau Espin Pedrol ] + * ipa: Allow setting local addr and port for struct ipa_client_conn + + [ Harald Welte ] + * dahdi: Use ioctl(DAHDI_SPECIFY) instead of legacy /dev/dahdi/%u + * Enable DAHDI support by default; require --disable-dahdi otherwise + + [ Vadim Yanitskiy ] + * input/ipaccess.c: propagate errors from ipa_parse_unitid() + * input/ipaccess.c: fix debug message on receipt of IPAC_MSGT_ID_GET + * e1_input.c: make reference counting get() / put() more verbose + * input/ipa_keepalive.c: make sure IPA keepalive FSM is registered + + -- Pau Espin Pedrol <[email protected]> Thu, 02 Jan 2020 20:53:32 +0100 + +libosmo-abis (0.7.0) unstable; urgency=medium + + [ Max ] + * Set local IP in ipa_server_link properly + * Log peer's port in accept callback + + [ Harald Welte ] + * ipa: Make ipa_server_conn_destroy() re-entrant + * Add IPA keep-alive FSM implementation + * ipa_keepalive_fsm: Fix OSMO_IPA_KA_E_STOP allstate event + * ipa_keepalive_fsm: Suppress error messages for INIT -> INIT transition + * ipaccess.c: Avoid calling close(-1) on error path + + [ Oliver Smith ] + * tests: use -no-install libtool flag to avoid ./lt-* scripts + * contrib/jenkins.sh: run "make maintainer-clean" + + [ Sylvain Munaut ] + * rtp: Add 'autoconnect' feature to the osmo_rtp_socket + + [ Eric Wild ] + * ipaccess: allow tcp keepalive for ipa clients + * add TCP_USER_TIMEOUT to keepalive + * extend the ipa keepalive fsm + + [ Debian Mobcom Maintainers ] + * spelling + + -- Harald Welte <[email protected]> Sun, 21 Jul 2019 21:32:08 +0200 + libosmo-abis (0.6.0) unstable; urgency=medium [ Neels Hofmeyr ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/debian/control new/libosmo-abis-0.8.0/debian/control --- old/libosmo-abis-0.6.0/debian/control 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/debian/control 2020-01-02 20:53:32.000000000 +0100 @@ -6,6 +6,7 @@ autotools-dev, autoconf, automake, + dahdi-source, libtool, dh-autoreconf, libdpkg-perl, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/include/osmocom/abis/ipa.h new/libosmo-abis-0.8.0/include/osmocom/abis/ipa.h --- old/libosmo-abis-0.6.0/include/osmocom/abis/ipa.h 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/include/osmocom/abis/ipa.h 2020-01-02 20:53:32.000000000 +0100 @@ -5,6 +5,7 @@ #include <osmocom/core/linuxlist.h> #include <osmocom/core/timer.h> #include <osmocom/core/select.h> +#include <osmocom/core/fsm.h> #include <osmocom/gsm/ipa.h> struct e1inp_line; @@ -77,6 +78,8 @@ int (*write_cb)(struct ipa_client_conn *link); void *data; struct msgb *pending_msg; + const char *local_addr; + uint16_t local_port; }; struct ipa_client_conn * @@ -85,7 +88,16 @@ void (*updown)(struct ipa_client_conn *link, int), int (*read_cb)(struct ipa_client_conn *link, struct msgb *msgb), int (*write_cb)(struct ipa_client_conn *link), - void *data); + void *data) OSMO_DEPRECATED("Use ipa_client_conn_create2() instead"); +struct ipa_client_conn * +ipa_client_conn_create2(void *ctx, struct e1inp_ts *ts, + int priv_nr, const char *loc_addr, uint16_t loc_port, + const char *rem_addr, uint16_t rem_port, + void (*updown_cb)(struct ipa_client_conn *link, int up), + int (*read_cb)(struct ipa_client_conn *link, + struct msgb *msgb), + int (*write_cb)(struct ipa_client_conn *link), + void *data); void ipa_client_conn_destroy(struct ipa_client_conn *link); int ipa_client_conn_open(struct ipa_client_conn *link); @@ -99,4 +111,43 @@ void ipa_msg_push_header(struct msgb *msg, uint8_t proto); + +/*********************************************************************** + * IPA Keep-Alive FSM + ***********************************************************************/ + +/*! parameters describing the keep-alive FSM (timeouts). */ +struct ipa_keepalive_params { + /*! interval in which to send IPA CCM PING requests to the peer. */ + unsigned int interval; + /*! time to wait for an IPA CCM PONG in response to a IPA CCM PING before giving up. */ + unsigned int wait_for_resp; +}; + +typedef int ipa_keepalive_timeout_cb_t(struct osmo_fsm_inst *fi, void *conn); + +typedef void ipa_keepalive_send_cb_t(struct osmo_fsm_inst *fi, void *conn, struct msgb *msg); + +struct osmo_fsm_inst *ipa_client_conn_alloc_keepalive_fsm(struct ipa_client_conn *client, + const struct ipa_keepalive_params *params, + const char *id); + +struct osmo_fsm_inst *ipa_server_conn_alloc_keepalive_fsm(struct ipa_server_conn *server, + const struct ipa_keepalive_params *params, + const char *id); + +struct osmo_fsm_inst *ipa_generic_conn_alloc_keepalive_fsm(void *ctx, void* data, + const struct ipa_keepalive_params *params, + const char *id); + +void ipa_keepalive_fsm_set_timeout_cb(struct osmo_fsm_inst *fi, ipa_keepalive_timeout_cb_t *cb); + +void ipa_keepalive_fsm_set_send_cb(struct osmo_fsm_inst *fi, ipa_keepalive_send_cb_t *fn); + +void ipa_keepalive_fsm_start(struct osmo_fsm_inst *fi); + +void ipa_keepalive_fsm_stop(struct osmo_fsm_inst *fi); + +void ipa_keepalive_fsm_pong_received(struct osmo_fsm_inst *fi); + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/include/osmocom/trau/osmo_ortp.h new/libosmo-abis-0.8.0/include/osmocom/trau/osmo_ortp.h --- old/libosmo-abis-0.6.0/include/osmocom/trau/osmo_ortp.h 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/include/osmocom/trau/osmo_ortp.h 2020-01-02 20:53:32.000000000 +0100 @@ -74,6 +74,7 @@ struct osmo_rtp_socket *osmo_rtp_socket_create(void *talloc_ctx, unsigned int flags); int osmo_rtp_socket_bind(struct osmo_rtp_socket *rs, const char *ip, int port); int osmo_rtp_socket_connect(struct osmo_rtp_socket *rs, const char *ip, uint16_t port); +int osmo_rtp_socket_autoconnect(struct osmo_rtp_socket *rs); int osmo_rtp_socket_set_pt(struct osmo_rtp_socket *rs, int payload_type); int osmo_rtp_socket_free(struct osmo_rtp_socket *rs); int osmo_rtp_skipped_frame(struct osmo_rtp_socket *rs, unsigned int duration); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/src/Makefile.am new/libosmo-abis-0.8.0/src/Makefile.am --- old/libosmo-abis-0.6.0/src/Makefile.am 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/src/Makefile.am 2020-01-02 20:53:32.000000000 +0100 @@ -1,8 +1,8 @@ # This is _NOT_ the library release version, it's an API version. # Please read chapter "Library interface versions" of the libtool documentation # before making any modifications: https://www.gnu.org/software/libtool/manual/html_node/Versioning.html -ABIS_LIBVERSION=6:2:0 -TRAU_LIBVERSION=3:2:1 +ABIS_LIBVERSION=8:0:2 +TRAU_LIBVERSION=4:0:2 AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS= -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) @@ -19,14 +19,17 @@ ipa_proxy.c \ subchan_demux.c \ trau_frame.c \ - input/dahdi.c \ input/ipa.c \ + input/ipa_keepalive.c \ input/ipaccess.c \ input/lapd.c \ input/lapd_pcap.c \ input/misdn.c \ input/rs232.c \ input/unixsocket.c +if ENABLE_DAHDI +libosmoabis_la_SOURCES += input/dahdi.c +endif libosmotrau_la_CFLAGS = $(AM_CFLAGS) $(ORTP_CFLAGS) libosmotrau_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(TRAU_LIBVERSION) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/src/e1_input.c new/libosmo-abis-0.8.0/src/e1_input.c --- old/libosmo-abis-0.6.0/src/e1_input.c 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/src/e1_input.c 2020-01-02 20:53:32.000000000 +0100 @@ -419,12 +419,19 @@ void e1inp_line_get(struct e1inp_line *line) { - line->refcnt++; + int old_refcnt = line->refcnt++; + + LOGP(DLINP, LOGL_DEBUG, "Line '%s' (%p) reference count get: %d -> %d\n", + line->name, line, old_refcnt, line->refcnt); } void e1inp_line_put(struct e1inp_line *line) { - line->refcnt--; + int old_refcnt = line->refcnt--; + + LOGP(DLINP, LOGL_DEBUG, "Line '%s' (%p) reference count put: %d -> %d\n", + line->name, line, old_refcnt, line->refcnt); + if (line->refcnt == 0) { /* Remove our counter group from libosmocore's global counter * list if we are freeing the last remaining talloc context. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/src/input/dahdi.c new/libosmo-abis-0.8.0/src/input/dahdi.c --- old/libosmo-abis-0.6.0/src/input/dahdi.c 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/src/input/dahdi.c 2020-01-02 20:53:32.000000000 +0100 @@ -1,6 +1,6 @@ /* OpenBSC Abis input driver for DAHDI */ -/* (C) 2008-2011 by Harald Welte <[email protected]> +/* (C) 2008-2019 by Harald Welte <[email protected]> * (C) 2009 by Holger Hans Peter Freyther <[email protected]> * (C) 2010 by Digium and Matthew Fredrickson <[email protected]> * @@ -26,8 +26,6 @@ #include "config.h" -#ifdef HAVE_DAHDI_USER_H - #include <stdio.h> #include <unistd.h> #include <stdlib.h> @@ -603,6 +601,33 @@ return 0; } +static int dahdi_open_slot(int dahdi_chan_nr) +{ + int rc, fd; +#ifndef DAHDI_SPECIFY + char openstr[128]; + snprintf(openstr, sizeof(openstr), "/dev/dahdi/%d", dev_nr); +#else + const char *openstr = "/dev/dahdi/channel"; +#endif + rc = open(openstr, O_RDWR | O_NONBLOCK); + if (rc < 0) { + LOGP(DLINP, LOGL_ERROR, "DAHDI: could not open %s %s\n", openstr, strerror(errno)); + return -EIO; + } + fd = rc; +#ifdef DAHDI_SPECIFY + rc = ioctl(fd, DAHDI_SPECIFY, &dahdi_chan_nr); + if (rc < 0) { + close(fd); + LOGP(DLINP, LOGL_ERROR, "DAHDI: could not DAHDI_SPECIFY %d: %s\n", + dahdi_chan_nr, strerror(errno)); + return -EIO; + } +#endif + return fd; +} + static int dahdi_e1_setup(struct e1inp_line *line) { struct span_cfg *scfg; @@ -623,7 +648,6 @@ /* TS0 is CRC4, don't need any fd for it */ for (ts = 1; ts <= scfg->chan_num; ts++) { unsigned int idx = ts-1; - char openstr[128]; struct e1inp_ts *e1i_ts = &line->ts[idx]; struct osmo_fd *bfd = &e1i_ts->driver.dahdi.fd; int dev_nr; @@ -640,7 +664,6 @@ bfd->data = line; bfd->priv_nr = ts; bfd->cb = dahdi_fd_cb; - snprintf(openstr, sizeof(openstr), "/dev/dahdi/%d", dev_nr); switch (e1i_ts->type) { case E1INP_TS_TYPE_NONE: @@ -657,13 +680,9 @@ break; case E1INP_TS_TYPE_SIGN: if (!bfd->fd) - bfd->fd = open(openstr, O_RDWR | O_NONBLOCK); - if (bfd->fd == -1) { - LOGP(DLINP, LOGL_ERROR, - "%s could not open %s %s\n", - __func__, openstr, strerror(errno)); + bfd->fd = dahdi_open_slot(dev_nr); + if (bfd->fd < 0) return -EIO; - } bfd->when = BSC_FD_READ | BSC_FD_EXCEPT; ret = dahdi_set_bufinfo(bfd->fd, 1); if (ret < 0) @@ -676,13 +695,9 @@ break; case E1INP_TS_TYPE_HDLC: if (!bfd->fd) - bfd->fd = open(openstr, O_RDWR | O_NONBLOCK); - if (bfd->fd == -1) { - LOGP(DLINP, LOGL_ERROR, - "%s could not open %s %s\n", - __func__, openstr, strerror(errno)); + bfd->fd = dahdi_open_slot(dev_nr); + if (bfd->fd < 0) return -EIO; - } bfd->when = BSC_FD_READ | BSC_FD_EXCEPT; ret = dahdi_set_bufinfo(bfd->fd, 1); if (ret < 0) @@ -696,13 +711,9 @@ e1i_ts->lapd = NULL; } if (!bfd->fd) - bfd->fd = open(openstr, O_RDWR | O_NONBLOCK); - if (bfd->fd == -1) { - LOGP(DLINP, LOGL_ERROR, - "%s could not open %s %s\n", - __func__, openstr, strerror(errno)); + bfd->fd = dahdi_open_slot(dev_nr); + if (bfd->fd < 0) return -EIO; - } ret = dahdi_set_bufinfo(bfd->fd, 0); if (ret < 0) return -EIO; @@ -713,12 +724,8 @@ break; } - if (bfd->fd < 0) { - LOGP(DLINP, LOGL_ERROR, - "%s could not open %s %s\n", - __func__, openstr, strerror(errno)); + if (bfd->fd < 0) return bfd->fd; - } ret = osmo_fd_register(bfd); if (ret < 0) { @@ -747,5 +754,3 @@ /* register the driver with the core */ return e1inp_driver_register(&dahdi_driver); } - -#endif /* HAVE_DAHDI_USER_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/src/input/ipa.c new/libosmo-abis-0.8.0/src/input/ipa.c --- old/libosmo-abis-0.6.0/src/input/ipa.c 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/src/input/ipa.c 2020-01-02 20:53:32.000000000 +0100 @@ -155,6 +155,20 @@ int (*write_cb)(struct ipa_client_conn *link), void *data) { + return ipa_client_conn_create2(ctx, ts, priv_nr, NULL, 0, addr, port, + updown_cb, read_cb, write_cb, data); +} + +struct ipa_client_conn * +ipa_client_conn_create2(void *ctx, struct e1inp_ts *ts, + int priv_nr, const char *loc_addr, uint16_t loc_port, + const char *rem_addr, uint16_t rem_port, + void (*updown_cb)(struct ipa_client_conn *link, int up), + int (*read_cb)(struct ipa_client_conn *link, + struct msgb *msgb), + int (*write_cb)(struct ipa_client_conn *link), + void *data) +{ struct ipa_client_conn *ipa_link; ipa_link = talloc_zero(ctx, struct ipa_client_conn); @@ -181,8 +195,10 @@ ipa_link->ofd->data = ipa_link; ipa_link->ofd->fd = -1; ipa_link->state = IPA_CLIENT_LINK_STATE_CONNECTING; - ipa_link->addr = talloc_strdup(ipa_link, addr); - ipa_link->port = port; + ipa_link->local_addr = talloc_strdup(ipa_link, loc_addr); + ipa_link->local_port = loc_port; + ipa_link->addr = talloc_strdup(ipa_link, rem_addr); + ipa_link->port = rem_port; ipa_link->updown_cb = updown_cb; ipa_link->read_cb = read_cb; /* default to generic write callback if not set. */ @@ -209,9 +225,10 @@ int ret; link->state = IPA_CLIENT_LINK_STATE_CONNECTING; - ret = osmo_sock_init(AF_INET, SOCK_STREAM, IPPROTO_TCP, + ret = osmo_sock_init2(AF_INET, SOCK_STREAM, IPPROTO_TCP, + link->local_addr, link->local_port, link->addr, link->port, - OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_NONBLOCK); + OSMO_SOCK_F_BIND|OSMO_SOCK_F_CONNECT|OSMO_SOCK_F_NONBLOCK); if (ret < 0) return ret; link->ofd->fd = ret; @@ -266,13 +283,13 @@ link->addr = talloc_strdup(link, ipbuf); } - LOGP(DLINP, LOGL_NOTICE, "accept()ed new link from %s to port %u\n", - inet_ntoa(sa.sin_addr), link->port); + LOGIPA(link, LOGL_NOTICE, "accept()ed new link from %s:%u\n", + inet_ntoa(sa.sin_addr), ntohs(sa.sin_port)); ret = link->accept_cb(link, fd); if (ret < 0) { LOGP(DLINP, LOGL_ERROR, - "failed to processs accept()ed new link, " + "failed to process accept()ed new link, " "reason=`%s'\n", strerror(-ret)); close(fd); return ret; @@ -297,6 +314,7 @@ ipa_link->ofd.when |= BSC_FD_READ | BSC_FD_WRITE; ipa_link->ofd.cb = ipa_server_fd_cb; + ipa_link->ofd.fd = -1; ipa_link->ofd.data = ipa_link; if (addr) ipa_link->addr = talloc_strdup(ipa_link, addr); @@ -326,6 +344,7 @@ link->ofd.fd = ret; if (osmo_fd_register(&link->ofd) < 0) { close(ret); + link->ofd.fd = -1; return -EIO; } return 0; @@ -333,8 +352,12 @@ void ipa_server_link_close(struct ipa_server_link *link) { + if (link->ofd.fd == -1) + return; + osmo_fd_unregister(&link->ofd); close(link->ofd.fd); + link->ofd.fd = -1; } static int ipa_server_conn_read(struct ipa_server_conn *conn) @@ -503,7 +526,12 @@ void ipa_server_conn_destroy(struct ipa_server_conn *conn) { + /* make the function re-entrant in case closed_cb() below somehow + * calls again into this destructor */ + if (conn->ofd.fd == -1) + return; close(conn->ofd.fd); + conn->ofd.fd = -1; msgb_free(conn->pending_msg); osmo_fd_unregister(&conn->ofd); if (conn->closed_cb) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/src/input/ipa_keepalive.c new/libosmo-abis-0.8.0/src/input/ipa_keepalive.c --- old/libosmo-abis-0.6.0/src/input/ipa_keepalive.c 1970-01-01 01:00:00.000000000 +0100 +++ new/libosmo-abis-0.8.0/src/input/ipa_keepalive.c 2020-01-02 20:53:32.000000000 +0100 @@ -0,0 +1,336 @@ +/* IPA keep-alive FSM; Periodically transmit IPA_PING and expect IPA_PONG in return. + * + * (C) 2019 by Harald Welte <[email protected]> + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include <osmocom/core/fsm.h> +#include <osmocom/core/timer.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/logging.h> + +#include <osmocom/gsm/protocol/ipaccess.h> + +#include <osmocom/abis/ipa.h> + +#define S(x) (1 << (x)) + + +/* generate a msgb containing an IPA CCM PING message */ +static struct msgb *gen_ipa_ping(void) +{ + struct msgb *msg = msgb_alloc_headroom(64, 32, "IPA PING"); + if (!msg) + return NULL; + + msgb_put_u8(msg, IPAC_MSGT_PING); + ipa_msg_push_header(msg, IPAC_PROTO_IPACCESS); + + return msg; +} + +enum osmo_ipa_keepalive_state { + OSMO_IPA_KA_S_INIT, + OSMO_IPA_KA_S_IDLE, /* waiting for next interval */ + OSMO_IPA_KA_S_WAIT_RESP, /* waiting for response to keepalive */ +}; + +enum osmo_ipa_keepalive_event { + OSMO_IPA_KA_E_START, + OSMO_IPA_KA_E_STOP, + OSMO_IPA_KA_E_PONG, +}; + +static const struct value_string ipa_keepalive_event_names[] = { + OSMO_VALUE_STRING(OSMO_IPA_KA_E_START), + OSMO_VALUE_STRING(OSMO_IPA_KA_E_STOP), + OSMO_VALUE_STRING(OSMO_IPA_KA_E_PONG), + { 0, NULL } +}; + +enum ipa_fsm_timer { + T_SEND_NEXT_PING = 1, + T_PONG_NOT_RECEIVED = 2, +}; + +struct ipa_fsm_priv { + struct ipa_keepalive_params params; + + struct ipa_server_conn *srv_conn; + struct ipa_client_conn *client_conn; + void *generic; + ipa_keepalive_timeout_cb_t *timeout_cb; + ipa_keepalive_send_cb_t *send_fn; +}; + +static void ipa_ka_init(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct ipa_fsm_priv *ifp = fi->priv; + + switch (event) { + case OSMO_IPA_KA_E_START: + osmo_fsm_inst_state_chg(fi, OSMO_IPA_KA_S_WAIT_RESP, + ifp->params.wait_for_resp, T_PONG_NOT_RECEIVED); + break; + default: + OSMO_ASSERT(0); + break; + } +} + +static void ipa_ka_wait_resp_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct ipa_fsm_priv *ifp = fi->priv; + struct msgb *msg; + + /* Send an IPA PING to the peer */ + msg = gen_ipa_ping(); + OSMO_ASSERT(msg); + + if (ifp->send_fn && ifp->generic) { + ifp->send_fn(fi, ifp->generic, msg); + return; + } + + if (ifp->srv_conn) { + if (ifp->send_fn) + ifp->send_fn(fi, ifp->srv_conn, msg); + else + ipa_server_conn_send(ifp->srv_conn, msg); + } + else { + OSMO_ASSERT(ifp->client_conn); + if (ifp->send_fn) + ifp->send_fn(fi, ifp->client_conn, msg); + else + ipa_client_conn_send(ifp->client_conn, msg); + } +} + +static void ipa_ka_wait_resp(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct ipa_fsm_priv *ifp = fi->priv; + + switch (event) { + case OSMO_IPA_KA_E_PONG: + osmo_fsm_inst_state_chg(fi, OSMO_IPA_KA_S_IDLE, + ifp->params.interval, T_SEND_NEXT_PING); + break; + default: + OSMO_ASSERT(0); + } +} + +static int ipa_ka_fsm_timer_cb(struct osmo_fsm_inst *fi) +{ + struct ipa_fsm_priv *ifp = fi->priv; + void *conn; + + switch (fi->T) { + case T_SEND_NEXT_PING: + /* send another PING */ + osmo_fsm_inst_state_chg(fi, OSMO_IPA_KA_S_WAIT_RESP, + ifp->params.wait_for_resp, T_PONG_NOT_RECEIVED); + return 0; + case T_PONG_NOT_RECEIVED: + /* PONG not received within time */ + if (ifp->srv_conn) + conn = ifp->srv_conn; + else if (ifp->client_conn) + conn = ifp->client_conn; + else + conn = ifp->generic; + if (ifp->timeout_cb) + return ifp->timeout_cb(fi, conn); + /* ask fsm core to terminate us */ + return 1; + default: + OSMO_ASSERT(0); + } +} + +static void ipa_ka_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case OSMO_IPA_KA_E_STOP: + osmo_fsm_inst_state_chg(fi, OSMO_IPA_KA_S_INIT, 0, 0); + break; + default: + OSMO_ASSERT(0); + break; + } +} + +static const struct osmo_fsm_state ipa_keepalive_states[] = { + [OSMO_IPA_KA_S_INIT] = { + .name = "INIT", + .in_event_mask = S(OSMO_IPA_KA_E_START), + .out_state_mask = S(OSMO_IPA_KA_S_WAIT_RESP) | S(OSMO_IPA_KA_S_INIT), + .action = ipa_ka_init, + }, + [OSMO_IPA_KA_S_IDLE] = { + .name = "IDLE", + .out_state_mask = S(OSMO_IPA_KA_S_WAIT_RESP) | S(OSMO_IPA_KA_S_INIT), + /* no permitted events aside from E_START, which is handled in allstate_events */ + }, + [OSMO_IPA_KA_S_WAIT_RESP] = { + .name = "WAIT_RESP", + .in_event_mask = S(OSMO_IPA_KA_E_PONG), + .out_state_mask = S(OSMO_IPA_KA_S_IDLE) | S(OSMO_IPA_KA_S_INIT), + .action = ipa_ka_wait_resp, + .onenter = ipa_ka_wait_resp_onenter, + }, +}; + +static struct osmo_fsm ipa_keepalive_fsm = { + .name = "IPA-KEEPALIVE", + .states = ipa_keepalive_states, + .num_states = ARRAY_SIZE(ipa_keepalive_states), + .log_subsys = DLINP, + .allstate_event_mask = S(OSMO_IPA_KA_E_STOP), + .allstate_action = ipa_ka_allstate_action, + .event_names = ipa_keepalive_event_names, + .timer_cb = ipa_ka_fsm_timer_cb, +}; + +static __attribute__((constructor)) void on_dso_load(void) +{ + OSMO_ASSERT(osmo_fsm_register(&ipa_keepalive_fsm) == 0); +} + + +static struct osmo_fsm_inst * +__ipa_conn_alloc_keepalive_fsm(void *ctx, const struct ipa_keepalive_params *params, const char *id) +{ + struct osmo_fsm_inst *fi; + struct ipa_fsm_priv *ifp; + + fi = osmo_fsm_inst_alloc(&ipa_keepalive_fsm, ctx, NULL, LOGL_DEBUG, id); + if (!fi) + return NULL; + ifp = talloc_zero(fi, struct ipa_fsm_priv); + if (!ifp) { + osmo_fsm_inst_term(fi, OSMO_FSM_TERM_ERROR, NULL); + return NULL; + } + memcpy(&ifp->params, params, sizeof(ifp->params)); + fi->priv = ifp; + + return fi; +} + +/*! Create a new instance of an IPA keepalive FSM: Periodically transmit PING and expect PONG. + * \param[in] client The client connection for which to crate the FSM. Used as talloc context. + * \param[in] params Parameters describing the keepalive FSM time-outs. + * \param[in] id String used as identifier for the FSM. + * \returns pointer to the newly-created FSM instance; NULL in case of error. */ +struct osmo_fsm_inst *ipa_client_conn_alloc_keepalive_fsm(struct ipa_client_conn *client, + const struct ipa_keepalive_params *params, + const char *id) +{ + struct osmo_fsm_inst *fi; + struct ipa_fsm_priv *ifp; + + fi = __ipa_conn_alloc_keepalive_fsm(client, params, id); + if (!fi) + return NULL; + ifp = fi->priv; + ifp->client_conn = client; + return fi; +} + +/*! Create a new instance of an IPA keepalive FSM: Periodically transmit PING and expect PONG. + * \param[in] server The server connection for which to crate the FSM. Used as talloc context. + * \param[in] params Parameters describing the keepalive FSM time-outs. + * \param[in] id String used as identifier for the FSM. + * \returns pointer to the newly-created FSM instance; NULL in case of error. */ +struct osmo_fsm_inst *ipa_server_conn_alloc_keepalive_fsm(struct ipa_server_conn *server, + const struct ipa_keepalive_params *params, + const char *id) +{ + struct osmo_fsm_inst *fi; + struct ipa_fsm_priv *ifp; + + fi = __ipa_conn_alloc_keepalive_fsm(server, params, id); + if (!fi) + return NULL; + ifp = fi->priv; + ifp->srv_conn = server; + return fi; +} + +/*! Create a new instance of an IPA keepalive FSM: Periodically transmit PING and expect PONG. + * \param[in] ctx Talloc context. + * \param[in] data Data to pass to write/timeout cb. + * \param[in] params Parameters describing the keepalive FSM time-outs. + * \param[in] id String used as identifier for the FSM. + * \returns pointer to the newly-created FSM instance; NULL in case of error. */ +struct osmo_fsm_inst *ipa_generic_conn_alloc_keepalive_fsm(void *ctx, void* data, + const struct ipa_keepalive_params *params, + const char *id) +{ + struct osmo_fsm_inst *fi; + struct ipa_fsm_priv *ifp; + + fi = __ipa_conn_alloc_keepalive_fsm(ctx, params, id); + if (!fi) + return NULL; + ifp = fi->priv; + ifp->generic = data; + return fi; +} + +/*! Set a timeout call-back which is to be called once the peer doesn't respond anymore */ +void ipa_keepalive_fsm_set_timeout_cb(struct osmo_fsm_inst *fi, ipa_keepalive_timeout_cb_t *cb) +{ + struct ipa_fsm_priv *ifp = fi->priv; + OSMO_ASSERT(fi->fsm == &ipa_keepalive_fsm); + ifp->timeout_cb = cb; +} + +/*! Set a custom send callback for sending pings */ +void ipa_keepalive_fsm_set_send_cb(struct osmo_fsm_inst *fi, ipa_keepalive_send_cb_t *fn) +{ + struct ipa_fsm_priv *ifp = fi->priv; + OSMO_ASSERT(fi->fsm == &ipa_keepalive_fsm); + ifp->send_fn = fn; +} + +/*! Inform IPA Keepalive FSM that a PONG has been received. */ +void ipa_keepalive_fsm_pong_received(struct osmo_fsm_inst *fi) +{ + OSMO_ASSERT(fi->fsm == &ipa_keepalive_fsm); + osmo_fsm_inst_dispatch(fi, OSMO_IPA_KA_E_PONG, NULL); +} + +/*! Start the ping/pong procedure of the IPA Keepalive FSM. */ +void ipa_keepalive_fsm_start(struct osmo_fsm_inst *fi) +{ + OSMO_ASSERT(fi->fsm == &ipa_keepalive_fsm); + osmo_fsm_inst_dispatch(fi, OSMO_IPA_KA_E_START, NULL); +} + +/*! Stop the ping/pong procedure of the IPA Keepalive FSM. */ +void ipa_keepalive_fsm_stop(struct osmo_fsm_inst *fi) +{ + OSMO_ASSERT(fi->fsm == &ipa_keepalive_fsm); + osmo_fsm_inst_dispatch(fi, OSMO_IPA_KA_E_STOP, NULL); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/src/input/ipaccess.c new/libosmo-abis-0.8.0/src/input/ipaccess.c --- old/libosmo-abis-0.6.0/src/input/ipaccess.c 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/src/input/ipaccess.c 2020-01-02 20:53:32.000000000 +0100 @@ -143,7 +143,11 @@ } unitid = (char *) TLVP_VAL(&tlvp, IPAC_IDTAG_UNIT); unitid[len - 1] = '\0'; - ipa_parse_unitid(unitid, &unit_data); + ret = ipa_parse_unitid(unitid, &unit_data); + if (ret) { + LOGP(DLINP, LOGL_ERROR, "Failed to parse unit ID '%s'\n", unitid); + goto err; + } if (!line->ops->sign_link_up) { LOGP(DLINP, LOGL_ERROR, @@ -215,8 +219,10 @@ return 0; err: osmo_fd_unregister(bfd); - close(bfd->fd); - bfd->fd = -1; + if (bfd->fd != -1) { + close(bfd->fd); + bfd->fd = -1; + } e1inp_line_put(line); return -1; } @@ -459,6 +465,17 @@ LOGP(DLINP, LOGL_NOTICE, "Failed to set keepalive count: %s\n", strerror(errno)); +#if defined(TCP_USER_TIMEOUT) + val = 1000 * line->keepalive_num_probes * + line->keepalive_probe_interval + + line->keepalive_idle_timeout; + ret = setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, + &val, sizeof(val)); + if (ret < 0) + LOGP(DLINP, LOGL_NOTICE, + "Failed to set user timoeut: %s\n", + strerror(errno)); +#endif #endif } } @@ -667,8 +684,10 @@ { struct e1inp_line *line = link->line; - if (up) - return; + if (up) { + update_fd_settings(line, link->ofd->fd); + return; + } if (line->ops->sign_link_down) line->ops->sign_link_down(line); @@ -701,7 +720,7 @@ if (link->ofd->priv_nr >= E1INP_SIGN_RSL) trx_nr = link->ofd->priv_nr - E1INP_SIGN_RSL; - LOGP(DLINP, LOGL_NOTICE, "received ID get from %u/%u/%u\n", + LOGP(DLINP, LOGL_NOTICE, "received ID_GET for unit ID %u/%u/%u\n", dev->site_id, dev->bts_id, trx_nr); rmsg = ipa_bts_id_resp(dev, data + 1, len - 1, trx_nr); ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); @@ -881,9 +900,10 @@ "OML connecting to %s:%u\n", line->ops->cfg.ipa.addr, IPA_TCP_PORT_OML); - link = ipa_client_conn_create(tall_ipa_ctx, + link = ipa_client_conn_create2(tall_ipa_ctx, e1inp_line_ipa_oml_ts(line), E1INP_SIGN_OML, + NULL, 0, line->ops->cfg.ipa.addr, IPA_TCP_PORT_OML, ipaccess_bts_updown_cb, @@ -931,9 +951,10 @@ return -EINVAL; } - rsl_link = ipa_client_conn_create(tall_ipa_ctx, + rsl_link = ipa_client_conn_create2(tall_ipa_ctx, e1inp_line_ipa_rsl_ts(line, trx_nr), E1INP_SIGN_RSL+trx_nr, + NULL, 0, rem_addr, rem_port, ipaccess_bts_updown_cb, ipaccess_bts_read_cb, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/src/ipa_proxy.c new/libosmo-abis-0.8.0/src/ipa_proxy.c --- old/libosmo-abis-0.6.0/src/ipa_proxy.c 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/src/ipa_proxy.c 2020-01-02 20:53:32.000000000 +0100 @@ -184,7 +184,8 @@ LOGP(DLINP, LOGL_NOTICE, "now trying to connect to destination\n"); - conn->dst = ipa_client_conn_create(NULL, NULL, 0, + conn->dst = ipa_client_conn_create2(NULL, NULL, 0, + NULL, 0, route->shared->dst.inst->net.addr, route->shared->dst.inst->net.port, NULL, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/src/trau/osmo_ortp.c new/libosmo-abis-0.8.0/src/trau/osmo_ortp.c --- old/libosmo-abis-0.6.0/src/trau/osmo_ortp.c 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/src/trau/osmo_ortp.c 2020-01-02 20:53:32.000000000 +0100 @@ -468,6 +468,28 @@ return osmo_rtp_socket_fdreg(rs); } +/*! \brief Automatically associates a RTP socket with the first incoming UDP packet + * \param[in] rs OsmoRTP socket + * + * The bound RTP socket will wait for incoming RTP packets and as soon as it + * sees one, will 'connect' to it, so all replies will go to that sources and + * incoming messages from other sources will be discarded. This obviously only + * works once. + * + * \returns 0 on success, <0 in case of error. + */ +int osmo_rtp_socket_autoconnect(struct osmo_rtp_socket *rs) +{ + rtp_session_set_symmetric_rtp(rs->sess, 1); + rtp_session_set_connected_mode(rs->sess, 1); + rs->flags &= ~OSMO_RTP_F_DISABLED; + + if (rs->flags & OSMO_RTP_F_POLL) + return 0; + else + return osmo_rtp_socket_fdreg(rs); +} + /*! \brief Increment timestamp on a RTP socket without sending any packet * \param[in] rs OsmoRTP socket * \param[in] duration duration in number of RTP clock ticks diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libosmo-abis-0.6.0/tests/Makefile.am new/libosmo-abis-0.8.0/tests/Makefile.am --- old/libosmo-abis-0.6.0/tests/Makefile.am 2019-01-24 18:22:52.000000000 +0100 +++ new/libosmo-abis-0.8.0/tests/Makefile.am 2020-01-02 20:53:32.000000000 +0100 @@ -1,6 +1,6 @@ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include AM_CFLAGS=-Wall -g $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(COVERAGE_CFLAGS) -AM_LDFLAGS = $(COVERAGE_LDFLAGS) +AM_LDFLAGS = $(COVERAGE_LDFLAGS) -no-install check_PROGRAMS = e1inp_ipa_bsc_test \ e1inp_ipa_bts_test \
