daniel has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/41311?usp=email )
Change subject: Add VTY command to list TCAP ranges for an AS ......................................................................
Add VTY command to list TCAP ranges for an AS
Show the list of all tcap ranges and ASP for an AS:
OsmoSTP# show cs7 instance 0 as name as-ipa-loadshare-0 tcap-ranges Tid Min Tid Max SSN PC ASP Name ------- ------- --- ------------- ------------ 300 599 0 (no PC) asp-ipa-loadshare-0-1 0 299 0 (no PC) asp-ipa-loadshare-0-0
Show the tcap range and ASP for specific TCAP Id:
OsmoSTP# show cs7 instance 0 as name as-ipa-loadshare-0 tcap-ranges tid 15 Tid Min Tid Max SSN PC ASP Name ------- ------- --- ------------- ------------ 0 299 0 (no PC) asp-ipa-loadshare-0-0
Related: SYS#5423 Change-Id: I8026248d9897aadab5bf13a425269ec1e948dfdf --- M src/Makefile.am M src/ss7_vty.c A src/tcap_as_loadshare_vty.c A src/tcap_as_loadshare_vty.h M tests/vty/osmo_stp_test.vty M tests/vty/osmo_stp_test_tcap.vty 6 files changed, 165 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved
diff --git a/src/Makefile.am b/src/Makefile.am index c57b3d0..3721fed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,6 +26,7 @@ ss7_vty.h \ ss7_xua_srv.h \ tcap_as_loadshare.h \ + tcap_as_loadshare_vty.h \ tcap_trans_tracking.h \ xua_asp_fsm.h \ xua_as_fsm.h \ @@ -110,6 +111,7 @@ libosmo_sigtran_la_SOURCES += \ tcap_trans_tracking.c \ tcap_as_loadshare.c \ + tcap_as_loadshare_vty.c \ $(NULL)
AM_CFLAGS += \ diff --git a/src/ss7_vty.c b/src/ss7_vty.c index f3ba750..e880819 100644 --- a/src/ss7_vty.c +++ b/src/ss7_vty.c @@ -48,6 +48,9 @@ #include "ss7_user.h" #include "ss7_vty.h" #include "ss7_xua_srv.h" +#ifdef WITH_TCAP_LOADSHARING +#include "tcap_as_loadshare_vty.h" +#endif /* WITH_TCAP_LOADSHARING */
#define ROUTE_PRIO_RANGE_STR "<1-9>" #define ROUTE_PRIO_RANGE_HELP_STR "Priority\n" @@ -1556,6 +1559,9 @@ gen_cs7_timer_xua_cmd_strs(&cs7_timer_xua_cmd); install_lib_element(L_CS7_NODE, &cs7_timer_xua_cmd);
+#ifdef WITH_TCAP_LOADSHARING + tcap_as_vty_init(); +#endif /* WITH_TCAP_LOADSHARING */ install_node(&rtable_node, NULL); install_lib_element(L_CS7_NODE, &cs7_route_table_cmd); install_lib_element(L_CS7_RTABLE_NODE, &cfg_description_cmd); diff --git a/src/tcap_as_loadshare_vty.c b/src/tcap_as_loadshare_vty.c new file mode 100644 index 0000000..dcd8ccf --- /dev/null +++ b/src/tcap_as_loadshare_vty.c @@ -0,0 +1,136 @@ +/* SS7 TCAP Loadsharing VTY Interface */ + +/* (C) 2025 by sysmocom s.f.m.c. GmbH info@sysmocom.de + * Author: Alexander Couzens lynxis@fe80.eu + * Author: Daniel Willmann dwillmann@sysmocom.de + * 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, see http://www.gnu.org/licenses/. + * + */ + +#include <stdlib.h> +#include <unistd.h> + +#include <osmocom/core/hashtable.h> + +#include <osmocom/sigtran/osmo_ss7.h> + +#include <osmocom/vty/vty.h> +#include <osmocom/vty/command.h> +#include <osmocom/vty/logging.h> +#include <osmocom/vty/telnet_interface.h> +#include <osmocom/vty/misc.h> + +#include "ss7_as.h" +#include "ss7_asp.h" +#include "ss7_vty.h" +#include "tcap_as_loadshare.h" + +static int show_one_tcap_range(struct vty *vty, const struct osmo_ss7_as *as, const struct tcap_range *tcrng) +{ + vty_out(vty, "%-7u %-7u %3u %-13s %-12s%s", tcrng->tid_start, tcrng->tid_end, tcrng->ssn, osmo_ss7_pointcode_print(as->inst, tcrng->pc), tcrng->asp->cfg.name, VTY_NEWLINE); + return CMD_SUCCESS; +} + +DEFUN(show_cs7_as_tcapranges_name, show_cs7_as_name_tcapranges_cmd, + "show cs7 instance <0-15> as name AS_NAME tcap-ranges", + SHOW_STR CS7_STR INST_STR INST_STR "Application Server (AS)\n" + "Look up AS with a given name\n" + "Name of the Application Server (AS)\n" + "Display tcap ranges\n") +{ + int id = atoi(argv[0]); + const char *as_name = argv[1]; + struct osmo_ss7_instance *inst; + struct osmo_ss7_as *as = NULL; + int i; + struct tcap_range *tcrng; + + inst = osmo_ss7_instance_find(id); + if (!inst) { + vty_out(vty, "No SS7 instance %d found%s", id, VTY_NEWLINE); + return CMD_WARNING; + } + + if (as_name) { + as = osmo_ss7_as_find_by_name(inst, as_name); + if (!as) { + vty_out(vty, "No AS %s found%s", as_name, VTY_NEWLINE); + return CMD_WARNING; + } + } + + vty_out(vty, "Tid Min Tid Max SSN PC ASP Name %s", VTY_NEWLINE); + vty_out(vty, "------- ------- --- ------------- ------------%s", VTY_NEWLINE); + + hash_for_each(as->tcap.tid_ranges, i, tcrng, list) { + show_one_tcap_range(vty, as, tcrng); + } + + + return CMD_SUCCESS; +} + +DEFUN(show_cs7_as_tcaproute_name, show_cs7_as_name_tcapranges_tid_cmd, + "show cs7 instance <0-15> as name AS_NAME tcap-ranges tid TID", + SHOW_STR CS7_STR INST_STR INST_STR "Application Server (AS)\n" + "Display tcap range\n" + "Look up AS with a given name\n" + "Name of the Application Server (AS)\n" + "Show tcap range for a given TID\n" + "TID\n") +{ + int id = atoi(argv[0]); + const char *as_name = argv[1]; + int tid = atoi(argv[2]); + struct osmo_ss7_instance *inst; + struct osmo_ss7_as *as = NULL; + int i; + struct tcap_range *tcrng; + + inst = osmo_ss7_instance_find(id); + if (!inst) { + vty_out(vty, "No SS7 instance %d found%s", id, VTY_NEWLINE); + return CMD_WARNING; + } + + if (as_name) { + as = osmo_ss7_as_find_by_name(inst, as_name); + if (!as) { + vty_out(vty, "No AS %s found%s", as_name, VTY_NEWLINE); + return CMD_WARNING; + } + } + + vty_out(vty, "Tid Min Tid Max SSN PC ASP Name %s", VTY_NEWLINE); + vty_out(vty, "------- ------- --- ------------- ------------%s", VTY_NEWLINE); + + hash_for_each(as->tcap.tid_ranges, i, tcrng, list) { + if (tid < tcrng->tid_start || tid > tcrng->tid_end) + continue; + show_one_tcap_range(vty, as, tcrng); + } + + + return CMD_SUCCESS; +} + +void tcap_as_vty_init(void) +{ + install_lib_element_ve(&show_cs7_as_name_tcapranges_cmd); + install_lib_element_ve(&show_cs7_as_name_tcapranges_tid_cmd); +} diff --git a/src/tcap_as_loadshare_vty.h b/src/tcap_as_loadshare_vty.h new file mode 100644 index 0000000..cecd26f --- /dev/null +++ b/src/tcap_as_loadshare_vty.h @@ -0,0 +1,7 @@ +#pragma once + +struct vty; +struct osmo_ss7_instance; + +/* Register tcap vty commands */ +void tcap_as_vty_init(void); diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty index 47742f2..bf2db65 100644 --- a/tests/vty/osmo_stp_test.vty +++ b/tests/vty/osmo_stp_test.vty @@ -17,6 +17,7 @@ show cs7 instance <0-15> route binding-table [POINT_CODE] [all-matches] show cs7 instance <0-15> route-lookup POINT_CODE from POINT_CODE sls <0-15> [list-asps] show cs7 instance <0-15> sccp addressbook +... show cs7 instance <0-15> sccp users show cs7 instance <0-15> sccp ssn <0-65535> show cs7 instance <0-15> sccp connections @@ -45,6 +46,7 @@ show cs7 instance <0-15> route binding-table [POINT_CODE] [all-matches] show cs7 instance <0-15> route-lookup POINT_CODE from POINT_CODE sls <0-15> [list-asps] show cs7 instance <0-15> sccp addressbook +... show cs7 instance <0-15> sccp users show cs7 instance <0-15> sccp ssn <0-65535> show cs7 instance <0-15> sccp connections diff --git a/tests/vty/osmo_stp_test_tcap.vty b/tests/vty/osmo_stp_test_tcap.vty index 665945f..3085074 100644 --- a/tests/vty/osmo_stp_test_tcap.vty +++ b/tests/vty/osmo_stp_test_tcap.vty @@ -1,4 +1,16 @@ +OsmoSTP> list +... + show cs7 instance <0-15> as name AS_NAME tcap-ranges + show cs7 instance <0-15> as name AS_NAME tcap-ranges tid TID +... + OsmoSTP> enable +OsmoSTP# list +... + show cs7 instance <0-15> as name AS_NAME tcap-ranges + show cs7 instance <0-15> as name AS_NAME tcap-ranges tid TID +... + OsmoSTP# configure terminal OsmoSTP(config)# cs7 instance 0