aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-01-20 21:54:21 +0100
committerHarald Welte <laforge@gnumonks.org>2016-02-15 14:27:16 +0100
commit38933afdd95f9e809c2e3a15ff860d22b22f27c4 (patch)
treea90f70e2bf43158a5527b0965b6ad5dc724cb18d /src
parent6a0f0f9e21e46055dd8481036c75f49d89863639 (diff)
introduce + use new generic vty_get_phy_instance()
this function is intended to be used by VTY commands that need to resolve a given PHY interface.
Diffstat (limited to 'src')
-rw-r--r--src/common/vty.c20
-rw-r--r--src/osmo-bts-litecell15/lc15bts_vty.c28
-rw-r--r--src/osmo-bts-sysmo/sysmobts_vty.c28
3 files changed, 30 insertions, 46 deletions
diff --git a/src/common/vty.c b/src/common/vty.c
index 94ccdbe7..7488fbba 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -51,6 +51,26 @@
#include <osmo-bts/vty.h>
#include <osmo-bts/l1sap.h>
+struct phy_instance *vty_get_phy_instance(struct vty *vty, int phy_nr, int inst_nr)
+{
+ struct phy_link *plink = phy_link_by_num(phy_nr);
+ struct phy_instance *pinst;
+
+ if (!plink) {
+ vty_out(vty, "Cannot find PHY link number %d%s",
+ phy_nr, VTY_NEWLINE);
+ return NULL;
+ }
+
+ pinst = phy_instance_by_num(plink, inst_nr);
+ if (!pinst) {
+ vty_out(vty, "Cannot find PHY instance number %d%s",
+ inst_nr, VTY_NEWLINE);
+ return NULL;
+ }
+ return pinst;
+}
+
int bts_vty_go_parent(struct vty *vty)
{
switch (vty->node) {
diff --git a/src/osmo-bts-litecell15/lc15bts_vty.c b/src/osmo-bts-litecell15/lc15bts_vty.c
index be0bd441..90607965 100644
--- a/src/osmo-bts-litecell15/lc15bts_vty.c
+++ b/src/osmo-bts-litecell15/lc15bts_vty.c
@@ -171,23 +171,13 @@ DEFUN(show_dsp_trace_f, show_dsp_trace_f_cmd,
DEFUN(dsp_trace_f, dsp_trace_f_cmd, "HIDDEN", TRX_STR)
{
int phy_nr = atoi(argv[0]);
- struct phy_link *plink = phy_link_by_num(phy_nr);
struct phy_instance *pinst;
struct lc15l1_hdl *fl1h;
unsigned int flag ;
- if (!plink) {
- vty_out(vty, "Cannot find PHY link number %u%s",
- phy_nr, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- pinst = phy_instance_by_num(plink, 0);
- if (!pinst) {
- vty_out(vty, "Cannot find PHY instance number 0%s",
- VTY_NEWLINE);
+ pinst = vty_get_phy_instance(vty, phy_nr, 0);
+ if (!pinst)
return CMD_WARNING;
- }
fl1h = pinst->u.lc15.hdl;
flag = get_string_value(lc15bts_tracef_names, argv[1]);
@@ -199,23 +189,13 @@ DEFUN(dsp_trace_f, dsp_trace_f_cmd, "HIDDEN", TRX_STR)
DEFUN(no_dsp_trace_f, no_dsp_trace_f_cmd, "HIDDEN", NO_STR TRX_STR)
{
int phy_nr = atoi(argv[0]);
- struct phy_link *plink = phy_link_by_num(phy_nr);
struct phy_instance *pinst;
struct lc15l1_hdl *fl1h;
unsigned int flag ;
- if (!plink) {
- vty_out(vty, "Cannot find PHY link number %u%s",
- phy_nr, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- pinst = phy_instance_by_num(plink, 0);
- if (!pinst) {
- vty_out(vty, "Cannot find PHY instance number 0%s",
- VTY_NEWLINE);
+ pinst = vty_get_phy_instance(vty, phy_nr, 0);
+ if (!pinst)
return CMD_WARNING;
- }
fl1h = pinst->u.lc15.hdl;
flag = get_string_value(lc15bts_tracef_names, argv[1]);
diff --git a/src/osmo-bts-sysmo/sysmobts_vty.c b/src/osmo-bts-sysmo/sysmobts_vty.c
index 19122dc8..ced8f8e0 100644
--- a/src/osmo-bts-sysmo/sysmobts_vty.c
+++ b/src/osmo-bts-sysmo/sysmobts_vty.c
@@ -288,22 +288,14 @@ DEFUN(show_dsp_trace_f, show_dsp_trace_f_cmd,
DEFUN(dsp_trace_f, dsp_trace_f_cmd, "HIDDEN", TRX_STR)
{
int phy_nr = atoi(argv[0]);
- struct phy_link *plink = phy_link_by_num(phy_nr);
struct phy_instance *pinst;
struct femtol1_hdl *fl1h;
unsigned int flag ;
- if (!plink) {
- vty_out(vty, "Cannot find PHY link number %u%s",
- phy_nr, VTY_NEWLINE);
- return CMD_WARNING;
- }
- pinst = phy_instance_by_num(plink, 0);
- if (!pinst) {
- vty_out(vty, "Cannot find PHY instance number 0%s",
- VTY_NEWLINE);
+ pinst = vty_get_phy_instance(vty, phy_nr, 0);
+ if (!pinst)
return CMD_WARNING;
- }
+
fl1h = pinst->u.sysmobts.hdl;
flag = get_string_value(femtobts_tracef_names, argv[1]);
l1if_set_trace_flags(fl1h, fl1h->dsp_trace_f | flag);
@@ -314,22 +306,14 @@ DEFUN(dsp_trace_f, dsp_trace_f_cmd, "HIDDEN", TRX_STR)
DEFUN(no_dsp_trace_f, no_dsp_trace_f_cmd, "HIDDEN", NO_STR TRX_STR)
{
int phy_nr = atoi(argv[0]);
- struct phy_link *plink = phy_link_by_num(phy_nr);
struct phy_instance *pinst;
struct femtol1_hdl *fl1h;
unsigned int flag ;
- if (!plink) {
- vty_out(vty, "Cannot find PHY link number %u%s",
- phy_nr, VTY_NEWLINE);
- return CMD_WARNING;
- }
- pinst = phy_instance_by_num(plink, 0);
- if (!pinst) {
- vty_out(vty, "Cannot find PHY instance number 0%s",
- VTY_NEWLINE);
+ pinst = vty_get_phy_instance(vty, phy_nr, 0);
+ if (!pinst)
return CMD_WARNING;
- }
+
fl1h = pinst->u.sysmobts.hdl;
flag = get_string_value(femtobts_tracef_names, argv[1]);
l1if_set_trace_flags(fl1h, fl1h->dsp_trace_f & ~flag);