7 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
9 changed files with 65 additions and 12 deletions

1
.gitignore vendored
View File

@@ -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

@@ -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;
}