pespin has uploaded this change for review.

View Change

vty: show cs7 instance asp: Allow printing only a specific asp by name

Change-Id: I08426272069ce5f3c8403b08dcaf686547bee336
---
M src/osmo_ss7_vty.c
M tests/vty/ss7_asp_test.vty
2 files changed, 60 insertions(+), 30 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/75/35275/1
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 91a1eb7..94f3498 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -1160,14 +1160,45 @@
return buf;
}

+static void show_one_asp(struct vty *vty, struct osmo_ss7_asp *asp)
+{
+ char as_buf[64];
+ char buf_loc[OSMO_SOCK_MAX_ADDRS * INET6_ADDRSTRLEN + OSMO_SOCK_MAX_ADDRS + 2 + 6 + 1];
+ char buf_rem[sizeof(buf_loc)];
+
+ int fd = ss7_asp_get_fd(asp);
+ if (fd > 0) {
+ int proto = ss7_asp_proto_to_ip_proto(asp->cfg.proto);
+ if (!get_sockname_buf(buf_loc, sizeof(buf_loc), fd, proto, true))
+ OSMO_STRLCPY_ARRAY(buf_loc, "<sockname-error>");
+ if (!get_sockname_buf(buf_rem, sizeof(buf_rem), fd, proto, false))
+ OSMO_STRLCPY_ARRAY(buf_rem, "<sockname-error>");
+ } else {
+ osmo_ss7_asp_peer_snprintf(buf_loc, sizeof(buf_loc), &asp->cfg.local);
+ osmo_ss7_asp_peer_snprintf(buf_rem, sizeof(buf_rem), &asp->cfg.remote);
+ }
+
+ vty_out(vty, "%-12s %-12s %-13s %-4s %-4s %-9s %-23s %-23s%s",
+ asp->cfg.name,
+ as_list_for_asp(asp, as_buf, sizeof(as_buf)),
+ asp->fi ? osmo_fsm_inst_state_name(asp->fi) : "uninitialized",
+ get_value_string(osmo_ss7_asp_protocol_vals, asp->cfg.proto),
+ osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)),
+ asp->cfg.is_server ? "server" : "client",
+ buf_loc, buf_rem,
+ VTY_NEWLINE);
+}
+
DEFUN(show_cs7_asp, show_cs7_asp_cmd,
- "show cs7 instance <0-15> asp",
- SHOW_STR CS7_STR INST_STR INST_STR "Application Server Process (ASP)\n")
+ "show cs7 instance <0-15> asp [ASP_NAME]",
+ SHOW_STR CS7_STR INST_STR INST_STR
+ "Application Server Process (ASP)\n"
+ "Name of the Application Server Process (ASP)")
{
struct osmo_ss7_instance *inst;
- struct osmo_ss7_asp *asp;
- char as_buf[64];
+ struct osmo_ss7_asp *asp = NULL;
int id = atoi(argv[0]);
+ const char *asp_name = argc >= 2 ? argv[1] : NULL;

inst = osmo_ss7_instance_find(id);
if (!inst) {
@@ -1175,34 +1206,24 @@
return CMD_WARNING;
}

+ if (asp_name) {
+ asp = osmo_ss7_asp_find_by_name(inst, asp_name);
+ if (!asp) {
+ vty_out(vty, "No ASP %s found%s", asp_name, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+
vty_out(vty, "ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses%s", VTY_NEWLINE);
vty_out(vty, "------------ ------------ ------------- ---- ---- --------- ----------------------- -----------------------%s", VTY_NEWLINE);

- llist_for_each_entry(asp, &inst->asp_list, list) {
- char buf_loc[OSMO_SOCK_MAX_ADDRS * INET6_ADDRSTRLEN + OSMO_SOCK_MAX_ADDRS + 2 + 6 + 1];
- char buf_rem[sizeof(buf_loc)];
- int fd = ss7_asp_get_fd(asp);
- if (fd > 0) {
- int proto = ss7_asp_proto_to_ip_proto(asp->cfg.proto);
- if (!get_sockname_buf(buf_loc, sizeof(buf_loc), fd, proto, true))
- OSMO_STRLCPY_ARRAY(buf_loc, "<sockname-error>");
- if (!get_sockname_buf(buf_rem, sizeof(buf_rem), fd, proto, false))
- OSMO_STRLCPY_ARRAY(buf_rem, "<sockname-error>");
- } else {
- osmo_ss7_asp_peer_snprintf(buf_loc, sizeof(buf_loc), &asp->cfg.local);
- osmo_ss7_asp_peer_snprintf(buf_rem, sizeof(buf_rem), &asp->cfg.remote);
- }
-
- vty_out(vty, "%-12s %-12s %-13s %-4s %-4s %-9s %-23s %-23s%s",
- asp->cfg.name,
- as_list_for_asp(asp, as_buf, sizeof(as_buf)),
- asp->fi? osmo_fsm_inst_state_name(asp->fi) : "uninitialized",
- get_value_string(osmo_ss7_asp_protocol_vals, asp->cfg.proto),
- osmo_str_tolower(get_value_string(osmo_ss7_asp_role_names, asp->cfg.role)),
- asp->cfg.is_server ? "server" : "client",
- buf_loc, buf_rem,
- VTY_NEWLINE);
+ if (asp) {
+ show_one_asp(vty, asp);
+ return CMD_SUCCESS;
}
+
+ llist_for_each_entry(asp, &inst->asp_list, list)
+ show_one_asp(vty, asp);
return CMD_SUCCESS;
}

diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index a767552..2022eb7 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -3,7 +3,7 @@
show cs7 instance <0-15> users
show cs7 (sua|m3ua|ipa) [<0-65534>]
show cs7 config
- show cs7 instance <0-15> asp
+ show cs7 instance <0-15> asp [ASP_NAME]
show cs7 instance <0-15> as (active|all|m3ua|sua)
show cs7 instance <0-15> route
show cs7 instance <0-15> sccp addressbook
@@ -19,7 +19,7 @@
show cs7 instance <0-15> users
show cs7 (sua|m3ua|ipa) [<0-65534>]
show cs7 config
- show cs7 instance <0-15> asp
+ show cs7 instance <0-15> asp [ASP_NAME]
show cs7 instance <0-15> as (active|all|m3ua|sua)
show cs7 instance <0-15> route
show cs7 instance <0-15> sccp addressbook

To view, visit change 35275. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I08426272069ce5f3c8403b08dcaf686547bee336
Gerrit-Change-Number: 35275
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange