aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2017-09-08 03:38:50 +0200
committerMax <msuraev@sysmocom.de>2017-09-19 18:27:25 +0200
commitc7f87833fbbf96c670c8a4e93af3294cb6a8410e (patch)
tree6998cb71e2a9473c5c4634d28acc8ce48de90324
parent9d15dac0e6f9756151f1f5518f59a56346704319 (diff)
libmgcp: Allow to get the mgcp_config by number
Adjusted by Max <msuraev@sysmocom.de> Change-Id: I9567b168696bc43c8f74cf0da9a4c647e8bdd822
-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..8f5d97bd4 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, unsigned 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 f27174cf0..2a743527e 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, unsigned 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;
}
@@ -1227,7 +1227,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);
@@ -1286,7 +1286,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);
@@ -1344,7 +1344,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);
@@ -1385,7 +1385,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);
@@ -1427,7 +1427,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);