aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sctp_m2ua.h2
-rw-r--r--src/main.c4
-rw-r--r--src/sctp_m2ua.c18
-rw-r--r--src/vty_interface_cmds.c11
4 files changed, 34 insertions, 1 deletions
diff --git a/include/sctp_m2ua.h b/include/sctp_m2ua.h
index 96ee200..ee46a66 100644
--- a/include/sctp_m2ua.h
+++ b/include/sctp_m2ua.h
@@ -80,4 +80,6 @@ struct mtp_m2ua_link *mtp_m2ua_link_create(struct sctp_m2ua_transport *transport
struct mtp_m2ua_link *mtp_m2ua_link_init(struct mtp_link *link);
+int sctp_m2ua_conn_count(struct sctp_m2ua_transport *tran);
+
#endif
diff --git a/src/main.c b/src/main.c
index 70a2f85..a9ec681 100644
--- a/src/main.c
+++ b/src/main.c
@@ -130,3 +130,7 @@ int main(int argc, char **argv)
return 0;
}
+int sctp_m2ua_conn_count(struct sctp_m2ua_transport *trans)
+{
+ return 0;
+}
diff --git a/src/sctp_m2ua.c b/src/sctp_m2ua.c
index 017f65e..cdcf8cf 100644
--- a/src/sctp_m2ua.c
+++ b/src/sctp_m2ua.c
@@ -32,6 +32,18 @@
#define SCTP_PPID_M2UA 2
+
+int sctp_m2ua_conn_count(struct sctp_m2ua_transport *trans)
+{
+ int count = 0;
+ struct sctp_m2ua_conn *conn;
+
+ llist_for_each_entry(conn, &trans->conns, entry)
+ count += 1;
+
+ return count;
+}
+
static struct mtp_m2ua_link *find_m2ua_link(struct sctp_m2ua_transport *trans, int link_index)
{
struct mtp_m2ua_link *link;
@@ -650,7 +662,7 @@ static int sctp_trans_accept(struct osmo_fd *fd, unsigned int what)
struct sctp_m2ua_conn *conn;
struct sockaddr_in addr;
socklen_t len;
- int s, ret;
+ int s, ret, count;
len = sizeof(addr);
s = accept(fd->fd, (struct sockaddr *) &addr, &len);
@@ -700,6 +712,10 @@ static int sctp_trans_accept(struct osmo_fd *fd, unsigned int what)
}
llist_add_tail(&conn->entry, &trans->conns);
+
+
+ count = sctp_m2ua_conn_count(trans);
+ LOGP(DINP, LOGL_NOTICE, "Now having %d SCTP connection(s).\n", count);
return 0;
}
diff --git a/src/vty_interface_cmds.c b/src/vty_interface_cmds.c
index ef8fa95..56b8ada 100644
--- a/src/vty_interface_cmds.c
+++ b/src/vty_interface_cmds.c
@@ -22,6 +22,7 @@
#include <bsc_data.h>
#include <mtp_pcap.h>
#include <msc_connection.h>
+#include <sctp_m2ua.h>
#include <osmocom/core/rate_ctr.h>
@@ -252,6 +253,15 @@ DEFUN(allow_inject, allow_inject_cmd,
return CMD_SUCCESS;
}
+DEFUN(show_sctp, show_sctp_cmd,
+ "show sctp-connections",
+ SHOW_STR "Active SCTP connections\n")
+{
+ int count = sctp_m2ua_conn_count(bsc->m2ua_trans);
+ vty_out(vty, "Active SCTP connections are: %d.%s", count, VTY_NEWLINE);
+ return CMD_SUCCESS;
+}
+
void cell_vty_init_cmds(void)
{
/* special commands */
@@ -268,4 +278,5 @@ void cell_vty_init_cmds(void)
install_element_ve(&show_slc_cmd);
install_element_ve(&show_msc_cmd);
+ install_element_ve(&show_sctp_cmd);
}