fixeria has uploaded this change for review.

View Change

fixup! mobile: vty: rework support enable/disable commands

FIXME: pass the item description (as a 'char *' pointer?)
TODO: some fields are uint8_t, some bool

Change-Id: Ie47d2eadf8e9736280fd75f52f2956910585d131
---
M src/host/layer23/src/mobile/vty_interface.c
1 file changed, 41 insertions(+), 24 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/36/34836/1
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 1766071..ff2ffd5 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -2011,24 +2011,37 @@
return CMD_SUCCESS;
}

+/* helper function for SUP_{EN,DI} macros */
+static int _cfg_ms_sup_en_di(struct vty *vty,
+ uint8_t *sup_field, uint8_t *set_field,
+ uint8_t en_di_val, bool restart)
+{
+ struct osmocom_ms *ms = vty->index;
+
+ if (!*sup_field) {
+ vty_out(vty, "FIXME not supported%s", VTY_NEWLINE);
+ if (l23_vty_reading)
+ return CMD_SUCCESS;
+ return CMD_WARNING;
+ }
+
+ if (restart)
+ vty_restart(vty, ms);
+ *set_field = en_di_val;
+
+ return CMD_SUCCESS;
+}
+
#define SUP_EN(item, cmd, desc, restart) \
DEFUN(cfg_ms_sup_en_##item, \
cfg_ms_sup_en_##item##_cmd, \
cmd, "Enable " desc "support") \
{ \
struct osmocom_ms *ms = vty->index; \
- struct gsm_settings *set = &ms->settings; \
- struct gsm_support *sup = &ms->support; \
- if (!sup->item) { \
- vty_out(vty, desc " not supported%s", VTY_NEWLINE); \
- if (l23_vty_reading) \
- return CMD_SUCCESS; \
- return CMD_WARNING; \
- } \
- if (restart) \
- vty_restart(vty, ms); \
- set->item = 1; \
- return CMD_SUCCESS; \
+ return _cfg_ms_sup_en_di(vty, \
+ &ms->support.item, \
+ &ms->settings.item, \
+ 1, restart); \
}

#define SUP_DI(item, cmd, desc, restart) \
@@ -2037,18 +2050,10 @@
"no " cmd, NO_STR "Disable " desc " support") \
{ \
struct osmocom_ms *ms = vty->index; \
- struct gsm_settings *set = &ms->settings; \
- struct gsm_support *sup = &ms->support; \
- if (!sup->item) { \
- vty_out(vty, desc " not supported%s", VTY_NEWLINE); \
- if (l23_vty_reading) \
- return CMD_SUCCESS; \
- return CMD_WARNING; \
- } \
- if (restart) \
- vty_restart(vty, ms); \
- set->item = 0; \
- return CMD_SUCCESS; \
+ return _cfg_ms_sup_en_di(vty, \
+ &ms->support.item, \
+ &ms->settings.item, \
+ 0, restart); \
}

#define SUP_EN_DI(item, cmd, desc, restart) \

To view, visit change 34836. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ie47d2eadf8e9736280fd75f52f2956910585d131
Gerrit-Change-Number: 34836
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-MessageType: newchange