13 Commits

Author SHA1 Message Date
Pau Espin Pedrol
c45aa8f571 sccp: Handle N-NOTICE.ind (Routing Failure of SCCP CL messages)
ITU Q.714 2.8:
"""
When an end node is informed of a routing failure, this information
is forwarded towards the SCCP user by using the N-DISCONNECT primitive
(refer to reason for release in 2.1.1.2.4/Q.711) or the N-NOTICE primitive
(refer to reason for return in 2.2.2.2.4/Q.711)
"""

We are already handling N-DISCONNECT.ind for CO messages, but
N-NOTICE.ind for CL messages was not being handled.

If CL messages are not arriving to the Lb peer, then reset the link
and mark the peer as disconnected, until a new RESET can successfully fo
through.

Related: OS#5917
Change-Id: I4bfea43a99c768162faefde06558941f697bd718
2025-07-16 18:11:59 +02:00
Pau Espin Pedrol
1416f6497f Introduce stats msc.ran_peers.{total,active}
osmo_stats_init() was already being called despite no stats were being
used.

Change-Id: Ib01576036f34ac7f21c5bce0155b50932eb9b72a
2025-07-15 12:15:18 +02:00
Pau Espin Pedrol
576b13fb19 smlc: Initial implementation of N-PCSTATE.ind
Related: OS#5917
Change-Id: Id034a0c4d8bff0647a64658480dfa9b4cea563de
2025-07-15 12:15:18 +02:00
Pau Espin Pedrol
28748a57bb vty: Create smlc_vty.c
We already have a smlc_vty.h file, but no usual smlc_vty.c file where we
put commands or init functions existed yet.

Change-Id: I6899602c3a6e22ee6ff93540466f839b2bf5ccc1
2025-07-15 12:15:15 +02:00
Pau Espin Pedrol
9b3ab7372b cell_locations.h: Fix includes
No sigtran header is needed as a dependecy in that header.
struct gsm0808_cell_id is defined in gsm0808_utils.h.

Change-Id: Iceedd7a8c2e050e6631c5f471d2eb71ab8ee2432
2025-07-14 19:46:28 +02:00
Pau Espin Pedrol
b585ad15c9 lb_peer: Drop unused events CONNECTION_{SUCCESS,TIMEOUT}
Change-Id: If5d838e3c0cfdb08ea8a96330ea1de4fa73e091a
2025-07-14 19:12:49 +02:00
Pau Espin Pedrol
4f54a410f5 lb_peer: Mark multiple funcs as static
Change-Id: I7178608444f72bfb93b816a0bedee336a5b4cafe
2025-07-14 19:09:31 +02:00
Pau Espin Pedrol
310e21dbf1 lb_peer: Constify ptr arg in lb_peer_find()
Change-Id: Ia1da7ad3f6410a47c3e8d4e4f7f534073f2e0116
2025-07-14 19:05:52 +02:00
Oliver Smith
062390702c Bump version: 0.3.1.4-22f0 → 0.3.2
Change-Id: Iaca50b640d147f01c2c5adebd6e0853cf7502d86
2025-03-05 11:35:12 +01:00
Pau Espin Pedrol
22f0738935 Add missing required vty go_parent_cb for libosmo-sigtran
This callback is required when configuring SS7 network through VTY.

Change-Id: Ibab25aa1a9ed4d0680fb61999e79b56b9a7d08dc
2025-03-04 16:58:11 +01:00
Pau Espin Pedrol
39515ac59e jenkins.sh: No need to build libosmo-sigtran with doxygen
Change-Id: Ic63fbd92cc6e1a5f784ced2ccb5f998e6cabaf27
2024-12-10 16:56:59 +01:00
Pau Espin Pedrol
fea674ee2d jenkins.sh: Skip building unneeded libosmo-abis
Change-Id: I9e763963f22e7fb425faef3b70b821ebd7e7ce60
2024-12-10 16:25:35 +01:00
Oliver Smith
d5c7fd45b2 contrib/jenkins: libosmo-abis after libosmo-netif
Depends: libosmo-abis I079dc3999de508301dd37ed03e399356a58d3cab
Depends: libosmo-netif I13d6e88158f6d9ce017986283183ee9c2cc68cae
Change-Id: I00f1dc510823d947992c8a5b2ce97a22c322b43b
2024-11-22 13:19:26 +01:00
12 changed files with 334 additions and 47 deletions

View File

@@ -31,9 +31,8 @@ export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$inst/lib"
export PATH="$inst/bin:$PATH"
osmo-build-dep.sh libosmo-abis
osmo-build-dep.sh libosmo-netif
osmo-build-dep.sh libosmo-sigtran
osmo-build-dep.sh libosmo-netif "" --disable-doxygen
osmo-build-dep.sh libosmo-sigtran "" --disable-doxygen
# Additional configure options and depends
CONFIG=""

12
debian/changelog vendored
View File

@@ -1,3 +1,15 @@
osmo-smlc (0.3.2) unstable; urgency=medium
[ Oliver Smith ]
* contrib/jenkins: libosmo-abis after libosmo-netif
[ Pau Espin Pedrol ]
* jenkins.sh: Skip building unneeded libosmo-abis
* jenkins.sh: No need to build libosmo-sigtran with doxygen
* Add missing required vty go_parent_cb for libosmo-sigtran
-- Oliver Smith <osmith@sysmocom.de> Wed, 05 Mar 2025 11:35:11 +0100
osmo-smlc (0.3.1) unstable; urgency=medium
[ Harald Welte ]

View File

@@ -23,7 +23,7 @@
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/gsm/gsm0808_utils.h>
struct osmo_gad;

View File

@@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/gsm0808.h>
#include <osmocom/sigtran/sccp_sap.h>
@@ -49,8 +51,8 @@ enum lb_peer_event {
LB_PEER_EV_MSG_DOWN_CO,
LB_PEER_EV_RX_RESET,
LB_PEER_EV_RX_RESET_ACK,
LB_PEER_EV_CONNECTION_SUCCESS,
LB_PEER_EV_CONNECTION_TIMEOUT,
LB_PEER_EV_AVAILABLE,
LB_PEER_EV_UNAVAILABLE,
};
struct lb_peer_ev_ctx {
@@ -60,8 +62,8 @@ struct lb_peer_ev_ctx {
};
struct lb_peer *lb_peer_find_or_create(struct sccp_lb_inst *sli, const struct osmo_sccp_addr *peer_addr);
struct lb_peer *lb_peer_find(struct sccp_lb_inst *sli, const struct osmo_sccp_addr *peer_addr);
struct lb_peer *lb_peer_find(const struct sccp_lb_inst *sli, const struct osmo_sccp_addr *peer_addr);
struct lb_peer *lb_peer_find_by_pc(const struct sccp_lb_inst *sli, uint32_t pc);
int lb_peer_up_l2(struct sccp_lb_inst *sli, const struct osmo_sccp_addr *calling_addr, bool co, uint32_t conn_id,
struct msgb *l2);
void lb_peer_disconnect(struct sccp_lb_inst *sli, uint32_t conn_id);

View File

@@ -37,6 +37,7 @@ enum smlc_ctrl_node {
_LAST_CTRL_NODE_SMLC
};
/* rate_ctr */
enum {
SMLC_CTR_BSSMAP_LE_RX_UDT_RESET,
SMLC_CTR_BSSMAP_LE_RX_UDT_RESET_ACK,
@@ -58,3 +59,9 @@ enum {
SMLC_CTR_BSSMAP_LE_TX_DT1_PERFORM_LOCATION_RESPONSE,
SMLC_CTR_BSSMAP_LE_TX_DT1_BSSLAP_TA_REQUEST,
};
/* osmo_stat */
enum {
SMLC_STAT_LB_PEERS_TOTAL,
SMLC_STAT_LB_PEERS_ACTIVE,
};

View File

@@ -5,3 +5,5 @@
enum smlc_vty_node {
CELLS_NODE = _LAST_OSMOVTY_NODE + 1,
};
void smlc_vty_init(struct vty_app_info *vty_app_info);

View File

@@ -32,6 +32,7 @@ osmo_smlc_SOURCES = \
smlc_loc_req.c \
smlc_main.c \
smlc_subscr.c \
smlc_vty.c \
$(NULL)
osmo_smlc_LDADD = \

View File

@@ -1,5 +1,5 @@
/*
* (C) 2019 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* (C) 2019-2025 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* SPDX-License-Identifier: AGPL-3.0+
@@ -23,6 +23,7 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/stat_item.h>
#include <osmocom/gsm/bssmap_le.h>
#include <osmocom/sigtran/sccp_helpers.h>
@@ -57,6 +58,7 @@ static struct lb_peer *lb_peer_alloc(struct sccp_lb_inst *sli, const struct osmo
fi->priv = lbp;
llist_add(&lbp->entry, &sli->lb_peers);
osmo_stat_item_inc(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_TOTAL), 1);
return lbp;
}
@@ -69,7 +71,7 @@ struct lb_peer *lb_peer_find_or_create(struct sccp_lb_inst *sli, const struct os
return lb_peer_alloc(sli, peer_addr);
}
struct lb_peer *lb_peer_find(struct sccp_lb_inst *sli, const struct osmo_sccp_addr *peer_addr)
struct lb_peer *lb_peer_find(const struct sccp_lb_inst *sli, const struct osmo_sccp_addr *peer_addr)
{
struct lb_peer *lbp;
llist_for_each_entry(lbp, &sli->lb_peers, entry) {
@@ -80,6 +82,15 @@ struct lb_peer *lb_peer_find(struct sccp_lb_inst *sli, const struct osmo_sccp_ad
return NULL;
}
/* Find an lb_peer by its remote SCCP address */
struct lb_peer *lb_peer_find_by_pc(const struct sccp_lb_inst *sli, uint32_t pc)
{
struct osmo_sccp_addr rem_addr;
osmo_sccp_make_addr_pc_ssn(&rem_addr, pc, OSMO_SCCP_SSN_BSC_BSSAP_LE);
return lb_peer_find(sli, &rem_addr);
}
static const struct osmo_tdef_state_timeout lb_peer_fsm_timeouts[32] = {
[LB_PEER_ST_WAIT_RX_RESET_ACK] = { .T = -13 },
[LB_PEER_ST_DISCARDING] = { .T = -14 },
@@ -88,7 +99,7 @@ static const struct osmo_tdef_state_timeout lb_peer_fsm_timeouts[32] = {
#define lb_peer_state_chg(LB_PEER, NEXT_STATE) \
osmo_tdef_fsm_inst_state_chg((LB_PEER)->fi, NEXT_STATE, lb_peer_fsm_timeouts, g_smlc_tdefs, 5)
void lb_peer_discard_all_conns(struct lb_peer *lbp)
static void lb_peer_discard_all_conns(struct lb_peer *lbp)
{
struct lb_conn *lb_conn, *next;
@@ -137,7 +148,7 @@ static void lb_peer_rx_reset_ack(struct lb_peer *lbp, struct msgb* msg)
lb_peer_state_chg(lbp, LB_PEER_ST_READY);
}
void lb_peer_reset(struct lb_peer *lbp)
static void lb_peer_reset(struct lb_peer *lbp)
{
struct bssap_le_pdu reset = {
.discr = BSSAP_LE_MSG_DISCR_BSSMAP_LE,
@@ -167,7 +178,18 @@ void lb_peer_reset(struct lb_peer *lbp)
}
}
void lb_peer_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void lb_peer_disconnect(struct sccp_lb_inst *sli, uint32_t conn_id)
{
struct lb_conn *lb_conn;
llist_for_each_entry(lb_conn, &sli->lb_conns, entry) {
if (lb_conn->sccp_conn_id == conn_id) {
lb_conn_discard(lb_conn);
return;
}
}
}
static void lb_peer_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct lb_peer *lbp = fi->priv;
struct lb_peer_ev_ctx *ctx = data;
@@ -196,7 +218,7 @@ void lb_peer_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *dat
}
}
void lb_peer_st_wait_rx_reset(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void lb_peer_st_wait_rx_reset(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct lb_peer *lbp = fi->priv;
struct lb_peer_ev_ctx *ctx;
@@ -224,13 +246,22 @@ void lb_peer_st_wait_rx_reset(struct osmo_fsm_inst *fi, uint32_t event, void *da
lb_peer_rx_reset(lbp, msg);
return;
case LB_PEER_EV_AVAILABLE:
/* Send a RESET to the peer. */
lb_peer_reset(lbp);
return;
case LB_PEER_EV_UNAVAILABLE:
/* Do nothing, wait for peer to come up again. */
return;
default:
LOG_LB_PEER(lbp, LOGL_ERROR, "Unhandled event: %s\n", osmo_fsm_event_name(&lb_peer_fsm, event));
return;
}
}
void lb_peer_st_wait_rx_reset_ack(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void lb_peer_st_wait_rx_reset_ack(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct lb_peer *lbp = fi->priv;
struct lb_peer_ev_ctx *ctx;
@@ -259,13 +290,28 @@ void lb_peer_st_wait_rx_reset_ack(struct osmo_fsm_inst *fi, uint32_t event, void
lb_peer_rx_reset(lbp, msg);
return;
case LB_PEER_EV_AVAILABLE:
/* Send a RESET to the peer. */
lb_peer_reset(lbp);
return;
case LB_PEER_EV_UNAVAILABLE:
lb_peer_state_chg(lbp, LB_PEER_ST_WAIT_RX_RESET);
return;
default:
LOG_LB_PEER(lbp, LOGL_ERROR, "Unhandled event: %s\n", osmo_fsm_event_name(&lb_peer_fsm, event));
return;
}
}
void lb_peer_st_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void lb_peer_st_ready_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
if (prev_state != LB_PEER_ST_READY)
osmo_stat_item_inc(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_ACTIVE), 1);
}
static void lb_peer_st_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct lb_peer *lbp = fi->priv;
struct lb_peer_ev_ctx *ctx;
@@ -323,12 +369,28 @@ void lb_peer_st_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data)
lb_peer_rx_reset(lbp, msg);
return;
case LB_PEER_EV_AVAILABLE:
/* Send a RESET to the peer. */
lb_peer_reset(lbp);
return;
case LB_PEER_EV_UNAVAILABLE:
lb_peer_discard_all_conns(lbp);
lb_peer_state_chg(lbp, LB_PEER_ST_WAIT_RX_RESET);
return;
default:
LOG_LB_PEER(lbp, LOGL_ERROR, "Unhandled event: %s\n", osmo_fsm_event_name(&lb_peer_fsm, event));
return;
}
}
static void lb_peer_st_ready_onleave(struct osmo_fsm_inst *fi, uint32_t next_state)
{
if (next_state != LB_PEER_ST_READY)
osmo_stat_item_dec(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_ACTIVE), 1);
}
static int lb_peer_fsm_timer_cb(struct osmo_fsm_inst *fi)
{
struct lb_peer *lbp = fi->priv;
@@ -336,10 +398,17 @@ static int lb_peer_fsm_timer_cb(struct osmo_fsm_inst *fi)
return 0;
}
void lb_peer_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
/* struct lb_peer destructor: */
static void lb_peer_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
{
struct lb_peer *lbp = fi->priv;
lb_peer_discard_all_conns(lbp);
if (lbp->fi->state == LB_PEER_ST_READY)
osmo_stat_item_dec(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_ACTIVE), 1);
osmo_stat_item_dec(osmo_stat_item_group_get_item(g_smlc->statg, SMLC_STAT_LB_PEERS_TOTAL), 1);
llist_del(&lbp->entry);
}
@@ -352,8 +421,8 @@ static const struct value_string lb_peer_fsm_event_names[] = {
OSMO_VALUE_STRING(LB_PEER_EV_MSG_DOWN_CO),
OSMO_VALUE_STRING(LB_PEER_EV_RX_RESET),
OSMO_VALUE_STRING(LB_PEER_EV_RX_RESET_ACK),
OSMO_VALUE_STRING(LB_PEER_EV_CONNECTION_SUCCESS),
OSMO_VALUE_STRING(LB_PEER_EV_CONNECTION_TIMEOUT),
OSMO_VALUE_STRING(LB_PEER_EV_AVAILABLE),
OSMO_VALUE_STRING(LB_PEER_EV_UNAVAILABLE),
{}
};
@@ -367,7 +436,8 @@ static const struct osmo_fsm_state lb_peer_fsm_states[] = {
| S(LB_PEER_EV_RX_RESET)
| S(LB_PEER_EV_MSG_UP_CO_INITIAL)
| S(LB_PEER_EV_MSG_UP_CO)
| S(LB_PEER_EV_CONNECTION_TIMEOUT)
| S(LB_PEER_EV_AVAILABLE)
| S(LB_PEER_EV_UNAVAILABLE)
,
.out_state_mask = 0
| S(LB_PEER_ST_WAIT_RX_RESET)
@@ -384,7 +454,8 @@ static const struct osmo_fsm_state lb_peer_fsm_states[] = {
| S(LB_PEER_EV_RX_RESET_ACK)
| S(LB_PEER_EV_MSG_UP_CO_INITIAL)
| S(LB_PEER_EV_MSG_UP_CO)
| S(LB_PEER_EV_CONNECTION_TIMEOUT)
| S(LB_PEER_EV_AVAILABLE)
| S(LB_PEER_EV_UNAVAILABLE)
,
.out_state_mask = 0
| S(LB_PEER_ST_WAIT_RX_RESET)
@@ -396,6 +467,8 @@ static const struct osmo_fsm_state lb_peer_fsm_states[] = {
[LB_PEER_ST_READY] = {
.name = "READY",
.action = lb_peer_st_ready,
.onenter = lb_peer_st_ready_onenter,
.onleave = lb_peer_st_ready_onleave,
.in_event_mask = 0
| S(LB_PEER_EV_RX_RESET)
| S(LB_PEER_EV_MSG_UP_CO_INITIAL)
@@ -403,6 +476,8 @@ static const struct osmo_fsm_state lb_peer_fsm_states[] = {
| S(LB_PEER_EV_MSG_DOWN_CO_INITIAL)
| S(LB_PEER_EV_MSG_DOWN_CO)
| S(LB_PEER_EV_MSG_DOWN_CL)
| S(LB_PEER_EV_AVAILABLE)
| S(LB_PEER_EV_UNAVAILABLE)
,
.out_state_mask = 0
| S(LB_PEER_ST_WAIT_RX_RESET)
@@ -482,14 +557,3 @@ int lb_peer_up_l2(struct sccp_lb_inst *sli, const struct osmo_sccp_addr *calling
return osmo_fsm_inst_dispatch(lb_peer->fi, event, &ctx);
}
void lb_peer_disconnect(struct sccp_lb_inst *sli, uint32_t conn_id)
{
struct lb_conn *lb_conn;
llist_for_each_entry(lb_conn, &sli->lb_conns, entry) {
if (lb_conn->sccp_conn_id == conn_id) {
lb_conn_discard(lb_conn);
return;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* (C) 2020 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* (C) 2020-2025 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* SPDX-License-Identifier: AGPL-3.0+
@@ -85,6 +85,126 @@ struct sccp_lb_inst *sccp_lb_init(void *talloc_ctx, struct osmo_sccp_instance *s
return sli;
}
static void handle_notice_ind(struct sccp_lb_inst *sli, const struct osmo_scu_notice_param *ni)
{
struct lb_peer *lbp;
lbp = lb_peer_find(sli, &ni->calling_addr);
if (!lbp) {
LOG_SCCP_LB(sli, LOGL_DEBUG, "(calling_addr=%s) N-NOTICE.ind cause=%u='%s' importance=%u didn't match any lb_peer, ignoring\n",
osmo_sccp_addr_dump(&ni->calling_addr),
ni->cause, osmo_sccp_return_cause_name(ni->cause),
ni->importance);
return;
}
LOG_LB_PEER(lbp, LOGL_NOTICE, "N-NOTICE.ind cause=%u='%s' importance=%u\n",
ni->cause, osmo_sccp_return_cause_name(ni->cause),
ni->importance);
switch (ni->cause) {
case SCCP_RETURN_CAUSE_SUBSYSTEM_CONGESTION:
case SCCP_RETURN_CAUSE_NETWORK_CONGESTION:
/* Transient failures (hopefully), keep going. */
return;
default:
break;
}
/* Messages are not arriving to lb_peer. Signal it is unavailable to update local state. */
osmo_fsm_inst_dispatch(lbp->fi, LB_PEER_EV_UNAVAILABLE, NULL);
}
static void handle_pcstate_ind(struct sccp_lb_inst *sli, const struct osmo_scu_pcstate_param *pcst)
{
struct osmo_ss7_instance *cs7 = osmo_sccp_get_ss7(sli->sccp);
struct lb_peer *lbp;
bool connected;
bool disconnected;
LOG_SCCP_LB(sli, LOGL_DEBUG, "N-PCSTATE ind: affected_pc=%u=%s sp_status=%s remote_sccp_status=%s\n",
pcst->affected_pc, osmo_ss7_pointcode_print(cs7, pcst->affected_pc),
osmo_sccp_sp_status_name(pcst->sp_status),
osmo_sccp_rem_sccp_status_name(pcst->remote_sccp_status));
/* If we don't care about that point-code, ignore PCSTATE. */
lbp = lb_peer_find_by_pc(sli, pcst->affected_pc);
if (!lbp) {
LOG_SCCP_LB(sli, LOGL_DEBUG, "No lb_peer found under pc=%u=%s\n",
pcst->affected_pc, osmo_ss7_pointcode_print(cs7, pcst->affected_pc));
return;
}
/* See if this marks the point code to have become available, or to have been lost.
*
* I want to detect two events:
* - connection event (both indicators say PC is reachable).
* - disconnection event (at least one indicator says the PC is not reachable).
*
* There are two separate incoming indicators with various possible values -- the incoming events can be:
*
* - neither connection nor disconnection indicated -- just indicating congestion
* connected == false, disconnected == false --> do nothing.
* - both incoming values indicate that we are connected
* --> trigger connected
* - both indicate we are disconnected
* --> trigger disconnected
* - one value indicates 'connected', the other indicates 'disconnected'
* --> trigger disconnected
*
* Congestion could imply that we're connected, but it does not indicate that a PC's reachability changed, so no need to
* trigger on that.
*/
connected = false;
disconnected = false;
switch (pcst->sp_status) {
case OSMO_SCCP_SP_S_ACCESSIBLE:
connected = true;
break;
case OSMO_SCCP_SP_S_INACCESSIBLE:
disconnected = true;
break;
default:
case OSMO_SCCP_SP_S_CONGESTED:
/* Neither connecting nor disconnecting */
break;
}
switch (pcst->remote_sccp_status) {
case OSMO_SCCP_REM_SCCP_S_AVAILABLE:
if (!disconnected)
connected = true;
break;
case OSMO_SCCP_REM_SCCP_S_UNAVAILABLE_UNKNOWN:
case OSMO_SCCP_REM_SCCP_S_UNEQUIPPED:
case OSMO_SCCP_REM_SCCP_S_INACCESSIBLE:
disconnected = true;
connected = false;
break;
default:
case OSMO_SCCP_REM_SCCP_S_CONGESTED:
/* Neither connecting nor disconnecting */
break;
}
if (disconnected) {
LOG_SCCP_LB(sli, LOGL_NOTICE,
"now unreachable: N-PCSTATE ind: pc=%u=%s sp_status=%s remote_sccp_status=%s\n",
pcst->affected_pc, osmo_ss7_pointcode_print(cs7, pcst->affected_pc),
osmo_sccp_sp_status_name(pcst->sp_status),
osmo_sccp_rem_sccp_status_name(pcst->remote_sccp_status));
osmo_fsm_inst_dispatch(lbp->fi, LB_PEER_EV_UNAVAILABLE, NULL);
} else if (connected) {
LOG_SCCP_LB(sli, LOGL_NOTICE,
"now available: N-PCSTATE ind: pc=%u=%s sp_status=%s remote_sccp_status=%s\n",
pcst->affected_pc, osmo_ss7_pointcode_print(cs7, pcst->affected_pc),
osmo_sccp_sp_status_name(pcst->sp_status),
osmo_sccp_rem_sccp_status_name(pcst->remote_sccp_status));
osmo_fsm_inst_dispatch(lbp->fi, LB_PEER_EV_AVAILABLE, NULL);
}
}
static int sccp_lb_sap_up(struct osmo_prim_hdr *oph, void *_scu)
{
struct osmo_sccp_user *scu = _scu;
@@ -163,6 +283,24 @@ static int sccp_lb_sap_up(struct osmo_prim_hdr *oph, void *_scu)
rc = lb_peer_up_l2(sli, peer_addr, false, 0, oph->msg);
break;
case OSMO_PRIM(OSMO_SCU_PRIM_N_NOTICE, PRIM_OP_INDICATION):
handle_notice_ind(sli, &prim->u.notice);
rc = 0;
break;
case OSMO_PRIM(OSMO_SCU_PRIM_N_PCSTATE, PRIM_OP_INDICATION):
handle_pcstate_ind(sli, &prim->u.pcstate);
rc = 0;
break;
case OSMO_PRIM(OSMO_SCU_PRIM_N_STATE, PRIM_OP_INDICATION):
LOG_SCCP_LB(sli, LOGL_INFO,
"SCCP-User-SAP: Ignoring %s.%s\n",
osmo_scu_prim_type_name(oph->primitive),
get_value_string(osmo_prim_op_names, oph->operation));
rc = 0;
break;
default:
LOG_SCCP_LB_CL(sli, NULL, LOGL_ERROR, "%s(%s) unsupported\n", __func__, osmo_scu_prim_name(oph));
rc = -1;

View File

@@ -54,6 +54,19 @@ static const struct rate_ctr_group_desc smlc_ctrg_desc = {
smlc_ctr_description,
};
static const struct osmo_stat_item_desc smlc_stat_item_description[] = {
[SMLC_STAT_LB_PEERS_TOTAL] = { "lb_peers.total", "Total Lb peers seen since startup", OSMO_STAT_ITEM_NO_UNIT, 4, 0},
[SMLC_STAT_LB_PEERS_ACTIVE] = { "lb_peers.active", "Currently active Lb peers", OSMO_STAT_ITEM_NO_UNIT, 4, 0},
};
static const struct osmo_stat_item_group_desc smlc_statg_desc = {
"smlc",
"serving mobile location center",
OSMO_STATS_CLASS_GLOBAL,
ARRAY_SIZE(smlc_stat_item_description),
smlc_stat_item_description,
};
struct smlc_state *smlc_state_alloc(void *ctx)
{
struct smlc_state *smlc = talloc_zero(ctx, struct smlc_state);
@@ -61,5 +74,14 @@ struct smlc_state *smlc_state_alloc(void *ctx)
INIT_LLIST_HEAD(&smlc->subscribers);
INIT_LLIST_HEAD(&smlc->cell_locations);
smlc->ctrs = rate_ctr_group_alloc(smlc, &smlc_ctrg_desc, 0);
smlc->statg = osmo_stat_item_group_alloc(smlc, &smlc_statg_desc, 0);
if (!smlc->statg)
goto ret_free;
return smlc;
ret_free:
rate_ctr_group_free(smlc->ctrs);
talloc_free(smlc);
return NULL;
}

View File

@@ -19,7 +19,6 @@
#include <osmocom/ctrl/control_cmd.h>
#include <osmocom/ctrl/control_if.h>
#include <osmocom/ctrl/ports.h>
#include <osmocom/ctrl/control_vty.h>
#include <osmocom/core/application.h>
#include <osmocom/core/linuxlist.h>
@@ -29,17 +28,15 @@
#include <osmocom/core/rate_ctr.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/ports.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/misc.h>
#include <osmocom/sigtran/xua_msg.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/smlc/debug.h>
#include <osmocom/smlc/smlc_data.h>
#include <osmocom/smlc/sccp_lb_inst.h>
#include <osmocom/smlc/cell_locations.h>
#include <osmocom/smlc/smlc_vty.h>
#define _GNU_SOURCE
#include <getopt.h>
@@ -170,6 +167,7 @@ static struct vty_app_info vty_info = {
"This is free software: you are free to change and redistribute it.\r\n"
"There is NO WARRANTY, to the extent permitted by law.\r\n",
.version = PACKAGE_VERSION,
.go_parent_cb = osmo_ss7_vty_go_parent,
};
static void signal_handler(int signal)
@@ -239,17 +237,11 @@ int main(int argc, char **argv)
g_smlc = smlc_state_alloc(tall_smlc_ctx);
/* This needs to precede handle_options() */
vty_init(&vty_info);
logging_vty_add_cmds();
osmo_talloc_vty_add_cmds();
ctrl_vty_init(tall_smlc_ctx);
cell_locations_vty_init();
/* Initialize SS7 */
OSMO_ASSERT(osmo_ss7_init() == 0);
osmo_ss7_vty_init_asp(tall_smlc_ctx);
osmo_sccp_vty_init();
/* This needs to precede handle_options() */
smlc_vty_init(&vty_info);
/* parse options */
handle_options(argc, argv);

48
src/osmo-smlc/smlc_vty.c Normal file
View File

@@ -0,0 +1,48 @@
/*
* (C) 2025 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* SPDX-License-Identifier: AGPL-3.0+
*
* Author: Pau Espin Pedrol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <osmocom/ctrl/control_vty.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/misc.h>
#include <osmocom/vty/stats.h>
#include <osmocom/vty/vty.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/smlc/cell_locations.h>
void smlc_vty_init(struct vty_app_info *vty_app_info)
{
vty_init(vty_app_info);
logging_vty_add_cmds();
osmo_talloc_vty_add_cmds();
ctrl_vty_init(vty_app_info->tall_ctx);
osmo_fsm_vty_add_cmds();
osmo_stats_vty_add_cmds();
osmo_ss7_vty_init_asp(vty_app_info->tall_ctx);
osmo_sccp_vty_init();
cell_locations_vty_init();
}