13 Commits

Author SHA1 Message Date
Vadim Yanitskiy
91ea92868a vty: register talloc / stats introspection commands
Change-Id: I05ecc74426f68e19a18b7111ebc39ef504735d15
2025-07-23 13:55:17 +00:00
Vadim Yanitskiy
1b402db278 vty: clarify deprecation messages
When starting osmo-cbc with an old config file, it's unclear which
commands exactly are triggering deprecation warnings.  Let's print
the actual command instead of confusing 'This function'.

Change-Id: I7d45292065950846e5e28eb2b21abcdb0707a9b3
2025-07-23 13:55:17 +00:00
Pau Espin Pedrol
c5afbd3336 sbcap: Listen on (127.0.0.1|::1) by default
Follow what's described in the User Manual:
"The default is to bind to the 3GPP standard port number 29168 for
SBc-AP at the loopback IP address 127.0.0.1 and ::1."

Change-Id: I6cb1c7031c09469e7b7c29a0733e99faea9f6615
2025-07-22 20:50:12 +02:00
Pau Espin Pedrol
da85d1f75a Set default SBcAP local host when no VTY cfg sbcap node provided
During 7fbd6aa472 a "configured" flag was
introduced which could be used to make sure the SBcAP node was
configured before "peer" node, which made sure the local IP address was
set before triggering connect() in client mode.
However, the patch didn't account for the possibility that a user may
use a config file with no "sbcap" node at all, which hence ends up with
no local address being configured and opening the listen server SBcAP
socket will fail.

Related: OS#6814
Change-Id: I48eb465fecbeebd7cd8eafb17908ba0439bb9e50
2025-07-22 20:47:21 +02:00
Oliver Smith
2c34f95a04 Generate a version.h file
Related: OS#6626
Change-Id: Ia4ccdc833b95cd60fc27e7d73b55c99c1a0a8d7d
2025-06-23 16:37:46 +02:00
Oliver Smith
1a454c9174 Fix typo osmo-bsc -> osmo-cbc
Change-Id: I3da908d250771ca13e8b3f9069fe4f781defb461
2025-05-20 14:37:23 +02:00
Pau Espin Pedrol
f25277e872 Drop unnecessary static initialization to NULL
Moreover, this callback was drepecated and is not ever called since
libosmocore.git 70ce871532ab21955e0955d7e230eae65438f047 (release 1.3.0).

See also libosmocore.git d31de237582f6fe3315d61bb9a488d4cda92654e.

Change-Id: I68ed65537eb6f33ef666a79ddef70b46c995e0e7
2025-03-04 18:10:54 +01:00
Oliver Smith
28d66aa8ec Bump version: 0.5.0.5-8018 → 0.5.1
Change-Id: Ic28678b9325bdb702ca5985a5f18b6b761e8a1c5
2025-02-12 14:30:50 +01:00
Pau Espin Pedrol
80184a4e41 jenkins.sh: Skip building unneeded libosmo-abis
Change-Id: Ia8d93b276ace5798778354f25c4e8980e3412413
2024-12-10 16:16:49 +01:00
Pau Espin Pedrol
cc02c15505 abis: Fix reusing link->conn while it is being destroyed
Call to osmo_stream_cli_destroy() may end up triggering disconnect_cb(),
and we don't want to attempt doing more stuff with that conn when that
happens (we were even trying to reconnect() it...).
Avoid it by marking the pointer as NULL immediatelly before calling
e1inp_sign_link_destroy().

Change-Id: I56605766af974d86610d0958f4b82e6e4ff94502
2024-11-28 16:40:48 +01:00
Pau Espin Pedrol
f4fa15cb0e cbsp_link: Log unexpected return error codes
This easies spotting the cause of close/destroy code paths.

Change-Id: Ibfd9a33798ba88e2332c00ed90709e38bb2222d7
2024-11-28 16:39:15 +01:00
Pau Espin Pedrol
16daffdc52 .gitignore: Add *~
This allows getting rid of further files like install-sh~.

Change-Id: Iad7ce44a2ecd90116376a458cc40f355d3883c53
2024-11-28 16:37:24 +01:00
Oliver Smith
3bb05bafce contrib/jenkins: libosmo-abis after libosmo-netif
Depends: libosmo-abis I079dc3999de508301dd37ed03e399356a58d3cab
Depends: libosmo-netif I13d6e88158f6d9ce017986283183ee9c2cc68cae
Change-Id: I50c399223d97434848153d983db04bb2e9ce8dda
2024-11-22 11:09:41 +01:00
12 changed files with 86 additions and 16 deletions

3
.gitignore vendored
View File

@@ -2,6 +2,7 @@
*.a
*.lo
*.la
*~
.deps
Makefile
Makefile.in
@@ -20,7 +21,6 @@ depcomp
install-sh
missing
stamp-h1
configure~
# libtool
ltmain.sh
@@ -62,3 +62,4 @@ doc/manuals/vty/cbc_vty_reference.xml
contrib/osmo-cbc.spec
libosmo-sbcap.pc
include/osmocom/sbcap/version.h

View File

@@ -30,7 +30,6 @@ export LD_LIBRARY_PATH="$inst/lib"
export PATH="$inst/bin:$PATH"
osmo-build-dep.sh libosmocore "" --disable-doxygen
osmo-build-dep.sh libosmo-abis
osmo-build-dep.sh libosmo-netif "" --disable-doxygen
# Additional configure options and depends

13
debian/changelog vendored
View File

@@ -1,3 +1,16 @@
osmo-cbc (0.5.1) unstable; urgency=medium
[ Oliver Smith ]
* contrib/jenkins: libosmo-abis after libosmo-netif
[ Pau Espin Pedrol ]
* .gitignore: Add *~
* cbsp_link: Log unexpected return error codes
* abis: Fix reusing link->conn while it is being destroyed
* jenkins.sh: Skip building unneeded libosmo-abis
-- Oliver Smith <osmith@sysmocom.de> Wed, 12 Feb 2025 14:30:50 +0100
osmo-cbc (0.5.0) unstable; urgency=medium
[ Harald Welte ]

View File

@@ -1,4 +1,4 @@
/etc/osmocom/osmo-cbc.cfg
lib/systemd/system/osmo-cbc.service
usr/bin/osmo-cbc
usr/share/doc/osmo-cbc/examples/osmo-cbc/*.cfg usr/share/doc/osmo-bsc/examples
usr/share/doc/osmo-cbc/examples/osmo-cbc/*.cfg usr/share/doc/osmo-cbc/examples

View File

@@ -17,5 +17,5 @@ arguments:
Fork the process as a daemon into background.
*-c, --config-file 'CONFIGFILE'*::
Specify the file and path name of the configuration file to be
used. If none is specified, use `osmo-bsc.cfg` in the current
used. If none is specified, use `osmo-cbc.cfg` in the current
working directory.

View File

@@ -89,6 +89,7 @@ struct cbc {
extern struct cbc *g_cbc;
struct cbc *cbc_alloc(void *ctx);
int cbc_start(struct cbc *cbc);
void cbc_add_sbcap_default_local_host_if_needed(struct cbc *cbc);
/* rest_api.c */
int rest_api_init(void *ctx, const char *bind_addr, uint16_t port);

View File

@@ -1,3 +1,16 @@
version.h: version.h.tpl
$(AM_V_GEN)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)sed \
-e "s/{{VERSION}}/$$(echo '@VERSION@' | cut -d. -f1-3)/g" \
-e "s/{{VERSION_MAJOR}}/$$(echo '@VERSION@' | cut -d. -f1)/g" \
-e "s/{{VERSION_MINOR}}/$$(echo '@VERSION@' | cut -d. -f2)/g" \
-e "s/{{VERSION_PATCH}}/$$(echo '@VERSION@' | cut -d. -f3)/g" \
$< > $@
EXTRA_DIST = \
version.h.tpl \
$(NULL)
sbcap_HEADERS = \
sbcap_common.h \
sbcap_internal.h \
@@ -115,6 +128,7 @@ sbcap_HEADERS = \
SBcAP_Write-Replace-Warning-Indication.h \
SBcAP_Write-Replace-Warning-Request.h \
SBcAP_Write-Replace-Warning-Response.h \
version.h \
$(NULL)
sbcapdir = $(includedir)/osmocom/sbcap

View File

@@ -0,0 +1,16 @@
#pragma once
#define LIBOSMO_SBCAP_VERSION {{VERSION}}
#define LIBOSMO_SBCAP_VERSION_STR "{{VERSION}}"
#define LIBOSMO_SBCAP_VERSION_MAJOR {{VERSION_MAJOR}}
#define LIBOSMO_SBCAP_VERSION_MINOR {{VERSION_MINOR}}
#define LIBOSMO_SBCAP_VERSION_PATCH {{VERSION_PATCH}}
#define LIBOSMO_SBCAP_VERSION_GREATER_EQUAL(major, minor, patch) \
(LIBOSMO_SBCAP_VERSION_MAJOR > (major) || \
(LIBOSMO_SBCAP_VERSION_MAJOR == (major) && \
LIBOSMO_SBCAP_VERSION_MINOR > (minor)) || \
(LIBOSMO_SBCAP_VERSION_MAJOR == (major) && \
LIBOSMO_SBCAP_VERSION_MINOR == (minor) && \
LIBOSMO_SBCAP_VERSION_PATCH >= (patch)))

View File

@@ -85,7 +85,9 @@ struct cbc *cbc_alloc(void *ctx)
INIT_LLIST_HEAD(&cbc->expired_messages);
cbc->config.cbsp.local_host = talloc_strdup(cbc, "127.0.0.1");
cbc->config.cbsp.local_port = CBSP_TCP_PORT;
/* cbc->config.sbcap local_host set up during VTY (and vty_go_parent) */
/* Due to SCTP multi-home support, cbc->config.sbcap.local_host is not set here,
* but through VTY (user or vty_go_parent()), or if not set default is set after
* VTY cfg read, during cbc_start(). */
cbc->config.sbcap.local_port = SBcAP_SCTP_PORT;
cbc->config.ecbe.local_host = talloc_strdup(cbc, "127.0.0.1");
cbc->config.ecbe.local_port = 12345;
@@ -103,6 +105,17 @@ struct cbc *cbc_alloc(void *ctx)
return cbc;
}
/* If no local addr set, add a default one: */
void cbc_add_sbcap_default_local_host_if_needed(struct cbc *cbc)
{
if (g_cbc->config.sbcap.num_local_host > 0)
return;
g_cbc->config.sbcap.local_host[0] = talloc_strdup(g_cbc, "127.0.0.1");
g_cbc->config.sbcap.local_host[1] = talloc_strdup(g_cbc, "::1");
g_cbc->config.sbcap.num_local_host = 2;
}
int cbc_start(struct cbc *cbc)
{
void *tall_rest_ctx;
@@ -115,6 +128,12 @@ int cbc_start(struct cbc *cbc)
return rc;
}
/* User didn't configure an SBcAP node with a local address, use default: */
if (!cbc->config.sbcap.configured) {
cbc_add_sbcap_default_local_host_if_needed(cbc);
cbc->config.sbcap.configured = true;
}
if ((rc = cbc_sbcap_mgr_open_srv(cbc->sbcap.mgr)) < 0) {
LOGP(DMAIN, LOGL_ERROR, "Error binding SBc-AP port\n");
return rc;

View File

@@ -113,10 +113,7 @@ static int cbc_vty_go_parent(struct vty *vty)
break;
case SBcAP_NODE:
/* If no local addr set, add a default one: */
if (g_cbc->config.sbcap.num_local_host == 0) {
g_cbc->config.sbcap.local_host[0] = talloc_strdup(g_cbc, "127.0.0.1");
g_cbc->config.sbcap.num_local_host = 1;
}
cbc_add_sbcap_default_local_host_if_needed(g_cbc);
g_cbc->config.sbcap.configured = true;
vty->node = CONFIG_NODE;
vty->index = NULL;
@@ -147,7 +144,6 @@ static struct vty_app_info vty_info = {
.copyright = cbc_copyright,
.go_parent_cb = cbc_vty_go_parent,
.version = PACKAGE_VERSION,
.is_config_node = NULL,
};
static struct {
@@ -274,6 +270,8 @@ int main(int argc, char **argv)
sbcap_set_log_area(DSBcAP, DASN1C);
osmo_stats_init(tall_cbc_ctx);
osmo_fsm_log_timeouts(true);
vty_info.tall_ctx = tall_cbc_ctx;
vty_init(&vty_info);
g_cbc = cbc_alloc(tall_cbc_ctx);
@@ -284,6 +282,8 @@ int main(int argc, char **argv)
logging_vty_add_cmds();
osmo_fsm_vty_add_cmds();
osmo_stats_vty_add_cmds();
osmo_talloc_vty_add_cmds();
rc = vty_read_config_file(cmdline_config.config_file, NULL);
if (rc < 0) {

View File

@@ -551,9 +551,10 @@ DEFUN_DEPRECATED(cfg_cbc_peer_old, cfg_cbc_peer_old_cmd,
{
struct cbc_peer *peer;
vty_out(vty, "%% This function is deprecated, use "
vty_out(vty, "%% '%s' is deprecated, use "
"'peer " CBC_PEER_PROTO_NAME_VTY_CMD " NAME' instead. "
"Assuming 'cbsp' for peers being created%s", VTY_NEWLINE);
"Assuming 'cbsp' for peers being created%s",
self->string, VTY_NEWLINE);
peer = cbc_peer_by_name(argv[0]);
if (!peer)
@@ -629,8 +630,9 @@ DEFUN_DEPRECATED(cfg_peer_proto, cfg_peer_proto_cmd,
"Configure Protocol of Peer\n"
CBC_PEER_PROTO_NAME_VTY_STR)
{
vty_out(vty, "%% This function is deprecated and does nothing, use "
"'peer " CBC_PEER_PROTO_NAME_VTY_CMD " NAME' instead%s", VTY_NEWLINE);
vty_out(vty, "%% '%s' is deprecated and does nothing, use "
"'peer " CBC_PEER_PROTO_NAME_VTY_CMD " NAME' instead%s",
self->string, VTY_NEWLINE);
return CMD_SUCCESS;
}

View File

@@ -102,6 +102,8 @@ static int cbc_cbsp_link_cli_connect_cb(struct osmo_stream_cli *conn)
static int cbc_cbsp_link_cli_disconnect_cb(struct osmo_stream_cli *conn)
{
struct cbc_cbsp_link *link = osmo_stream_cli_get_data(conn);
if (!link->conn) /* conn is being destroyed by us, we called osmo_stream_cli_destroy() */
return 0;
LOGPCC(link, LOGL_NOTICE, "Disconnected.\n");
LOGPCC(link, LOGL_NOTICE, "Reconnecting...\n");
osmo_stream_cli_reconnect(conn);
@@ -121,6 +123,7 @@ static int cbc_cbsp_link_cli_read_cb(struct osmo_stream_cli *conn)
/* message de-segmentation */
rc = osmo_cbsp_recv_buffered(conn, ofd->fd, &msg, &link->rx_msg);
if (rc <= 0) {
LOGPCC(link, LOGL_NOTICE, "osmo_cbsp_recv_buffered() ret %d\n", rc);
if (rc == -EAGAIN || rc == -EINTR) {
/* more data needs to be read */
return 0;
@@ -205,6 +208,7 @@ static int cbsp_cbc_srv_read_cb(struct osmo_stream_srv *conn)
/* message de-segmentation */
rc = osmo_cbsp_recv_buffered(conn, ofd->fd, &msg, &link->rx_msg);
if (rc <= 0) {
LOGPCC(link, LOGL_NOTICE, "osmo_cbsp_recv_buffered() ret %d\n", rc);
if (rc == -EAGAIN || rc == -EINTR) {
/* more data needs to be read */
return 0;
@@ -362,10 +366,11 @@ void cbc_cbsp_link_close(struct cbc_cbsp_link *link)
return;
if (link->is_client) {
osmo_stream_cli_destroy(link->cli_conn);
struct osmo_stream_cli *cli_conn = link->cli_conn;
link->cli_conn = NULL;
osmo_stream_cli_destroy(cli_conn);
if (link->peer)
link->peer->link.cbsp = NULL;
link->cli_conn = NULL;
if (link->fi)
osmo_fsm_inst_dispatch(link->fi, CBSP_LINK_E_CMD_CLOSE, NULL);
} else {