aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2017-09-08 03:38:50 +0200
committerDaniel Willmann <dwillmann@sysmocom.de>2018-01-30 18:59:28 +0100
commit3f734d27a556be774e86c07534593390095e3595 (patch)
tree7878bc3f44ace1251014a8d69c311cfe617d177d /openbsc
parentf585ee7ef8793e89e287f54a8e0b01c4343fcf2b (diff)
libmgcp: Allow to get the mgcp_config by number
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/mgcp.h1
-rw-r--r--openbsc/src/libmgcp/mgcp_vty.c18
2 files changed, 10 insertions, 9 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index 4400fb2ad..cdc6f033c 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -242,6 +242,7 @@ struct mgcp_config {
/* config management */
struct mgcp_config *mgcp_config_alloc(void);
+struct mgcp_config *mgcp_config_by_num(struct llist_head *configs, int index);
int mgcp_parse_config(const char *config_file, struct llist_head *cfg,
enum mgcp_role role);
int mgcp_vty_init(void);
diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c
index a80c6b98d..ff8477932 100644
--- a/openbsc/src/libmgcp/mgcp_vty.c
+++ b/openbsc/src/libmgcp/mgcp_vty.c
@@ -234,11 +234,11 @@ static void dump_trunk(struct vty *vty, struct mgcp_trunk_config *cfg, int verbo
}
}
-static struct mgcp_config *mgcp_config_num(int index)
+struct mgcp_config *mgcp_config_by_num(struct llist_head *configs, int index)
{
struct mgcp_config *mgcp;
- llist_for_each_entry(mgcp, &mgcp_configs, entry)
+ llist_for_each_entry(mgcp, configs, entry)
if (mgcp->nr == index)
return mgcp;
@@ -255,7 +255,7 @@ DEFUN(show_mcgp, show_mgcp_cmd,
struct mgcp_config *mgcp;
int show_stats = argc >= 2;
- mgcp = mgcp_config_num(atoi(argv[0]));
+ mgcp = mgcp_config_by_num(&mgcp_configs, atoi(argv[0]));
dump_trunk(vty, &mgcp->trunk, show_stats);
@@ -287,7 +287,7 @@ DEFUN(cfg_mgcp,
_num_mgcp++;
mgcp->nr = mgcp_nr;
} else {
- mgcp = mgcp_config_num(mgcp_nr);
+ mgcp = mgcp_config_by_num(&mgcp_configs, mgcp_nr);
vty->index = mgcp;
vty->node = MGCP_NODE;
}
@@ -1219,7 +1219,7 @@ DEFUN(loop_endp,
struct mgcp_trunk_config *trunk;
struct mgcp_endpoint *endp;
- cfg = mgcp_config_num(atoi(argv[0]));
+ cfg = mgcp_config_by_num(&mgcp_configs, atoi(argv[0]));
if (!cfg) {
vty_out(vty, "%%MGCP %d not found in config. %s",
atoi(argv[0]), VTY_NEWLINE);
@@ -1278,7 +1278,7 @@ DEFUN(tap_call,
struct mgcp_endpoint *endp;
int port = 0;
- cfg = mgcp_config_num(atoi(argv[0]));
+ cfg = mgcp_config_by_num(&mgcp_configs, atoi(argv[0]));
if (!cfg) {
vty_out(vty, "%%MGCP %d not found in config. %s",
atoi(argv[0]), VTY_NEWLINE);
@@ -1336,7 +1336,7 @@ DEFUN(free_endp, free_endp_cmd,
struct mgcp_trunk_config *trunk;
struct mgcp_endpoint *endp;
- cfg = mgcp_config_num(atoi(argv[0]));
+ cfg = mgcp_config_by_num(&mgcp_configs, atoi(argv[0]));
if (!cfg) {
vty_out(vty, "%%MGCP %d not found in config. %s",
atoi(argv[0]), VTY_NEWLINE);
@@ -1377,7 +1377,7 @@ DEFUN(reset_endp, reset_endp_cmd,
struct mgcp_endpoint *endp;
int endp_no, rc;
- cfg = mgcp_config_num(atoi(argv[0]));
+ cfg = mgcp_config_by_num(&mgcp_configs, atoi(argv[0]));
if (!cfg) {
vty_out(vty, "%%MGCP %d not found in config. %s",
atoi(argv[0]), VTY_NEWLINE);
@@ -1419,7 +1419,7 @@ DEFUN(reset_all_endp, reset_all_endp_cmd,
int rc;
struct mgcp_config *cfg;
- cfg = mgcp_config_num(atoi(argv[0]));
+ cfg = mgcp_config_by_num(&mgcp_configs, atoi(argv[0]));
if (!cfg) {
vty_out(vty, "%%MGCP %d not found in config. %s",
atoi(argv[0]), VTY_NEWLINE);