From 22f34710d9e4d237ae72fb1dd835c261c0652d87 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Fri, 2 Oct 2020 02:34:39 +0200 Subject: ns2: vty: on `show ns` add information of NS binds Change-Id: I6cef42749555e577d5573f2ed8b8bce4cf842a98 --- src/gb/gprs_ns2_udp.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/gb/gprs_ns2_udp.c') diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c index 251f869a..3ce05084 100644 --- a/src/gb/gprs_ns2_udp.c +++ b/src/gb/gprs_ns2_udp.c @@ -78,6 +78,34 @@ static void free_vc(struct gprs_ns2_vc *nsvc) nsvc->priv = NULL; } +static void dump_vty(const struct gprs_ns2_vc_bind *bind, + struct vty *vty, bool _stats) +{ + struct priv_bind *priv; + struct gprs_ns2_vc *nsvc; + struct osmo_sockaddr_str sockstr = {}; + unsigned long nsvcs = 0; + + if (!bind) + return; + + priv = bind->priv; + if (osmo_sockaddr_str_from_sockaddr(&sockstr, &priv->addr.u.sas)) + strcpy(sockstr.ip, "invalid"); + + llist_for_each_entry(nsvc, &bind->nsvc, blist) { + nsvcs++; + } + + vty_out(vty, "UDP bind: %s:%d dcsp: %d%s", sockstr.ip, sockstr.port, priv->dscp, VTY_NEWLINE); + vty_out(vty, " %lu NS-VC: %s", nsvcs, VTY_NEWLINE); + + llist_for_each_entry(nsvc, &bind->nsvc, blist) { + vty_out(vty, " %s%s", gprs_ns2_ll_str(nsvc), VTY_NEWLINE); + } +} + + /*! Find a NS-VC by its remote socket address. * \param[in] bind in which to search * \param[in] saddr remote peer socket adddress to search @@ -262,6 +290,7 @@ int gprs_ns2_ip_bind(struct gprs_ns2_inst *nsi, bind->driver = &vc_driver_ip; bind->send_vc = nsip_vc_sendmsg; bind->free_vc = free_vc; + bind->dump_vty = dump_vty; bind->nsi = nsi; priv = bind->priv = talloc_zero(bind, struct priv_bind); -- cgit v1.2.3