aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Kluchnikov <kluchnikovi@gmail.com>2014-01-15 11:49:53 +0400
committerIvan Kluchnikov <kluchnikovi@gmail.com>2014-01-15 11:49:53 +0400
commit63f50e6f8cb73bb6d7c1f67f9ef5282e2e38a647 (patch)
treecf9ae82e5eb419ebff3f00e5e56b7c45ec58126d
parente5300aed655c1256fa98d82ee4cf076e5e270aaf (diff)
nitb: Minor code optimization for ctrl commands
-rw-r--r--openbsc/include/openbsc/control_cmd.h12
-rw-r--r--openbsc/src/osmo-nitb/ctrl_commands.c72
2 files changed, 24 insertions, 60 deletions
diff --git a/openbsc/include/openbsc/control_cmd.h b/openbsc/include/openbsc/control_cmd.h
index 4931a8a5a..af42ca95c 100644
--- a/openbsc/include/openbsc/control_cmd.h
+++ b/openbsc/include/openbsc/control_cmd.h
@@ -187,6 +187,18 @@ static struct ctrl_cmd_element cmd_##cmdname = { \
.verify = NULL, \
}
+#define CTRL_HELPER_SET_STATUS(cmdname) \
+static int set_##cmdname(struct ctrl_cmd *cmd, void *_data) \
+{ \
+ cmd->reply = "Read only attribute"; \
+ return CTRL_CMD_ERROR; \
+}
+#define CTRL_HELPER_VERIFY_STATUS(cmdname) \
+static int verify_##cmdname(struct ctrl_cmd *cmd, const char *value, void *_data) \
+{ \
+ return 0;\
+}
+
#define CTRL_CMD_RAW(cmdname, cmdstr, cmdget, cmdset, cmdverify) \
static struct ctrl_cmd_element cmd_##cmdname = { \
.name = cmdstr, \
diff --git a/openbsc/src/osmo-nitb/ctrl_commands.c b/openbsc/src/osmo-nitb/ctrl_commands.c
index 2b1843204..c791584c6 100644
--- a/openbsc/src/osmo-nitb/ctrl_commands.c
+++ b/openbsc/src/osmo-nitb/ctrl_commands.c
@@ -162,16 +162,8 @@ static int set_net_apply_config(struct ctrl_cmd *cmd, void *data)
CTRL_CMD_DEFINE(net_apply_config, "apply-configuration");
-static int verify_net_channels_load(struct ctrl_cmd *cmd, const char *v, void *d)
-{
- return 0;
-}
-
-static int set_net_channels_load(struct ctrl_cmd *cmd, void *data)
-{
- cmd->reply = "Read only attribute";
- return CTRL_CMD_ERROR;
-}
+CTRL_HELPER_VERIFY_STATUS(net_channels_load);
+CTRL_HELPER_SET_STATUS(net_channels_load);
static int get_net_channels_load(struct ctrl_cmd *cmd, void *data)
{
@@ -208,16 +200,8 @@ static int get_net_channels_load(struct ctrl_cmd *cmd, void *data)
CTRL_CMD_DEFINE(net_channels_load, "channels-load");
-static int verify_net_lchan_summary(struct ctrl_cmd *cmd, const char *v, void *d)
-{
- return 0;
-}
-
-static int set_net_lchan_summary(struct ctrl_cmd *cmd, void *data)
-{
- cmd->reply = "Read only attribute";
- return CTRL_CMD_ERROR;
-}
+CTRL_HELPER_VERIFY_STATUS(net_lchan_summary);
+CTRL_HELPER_SET_STATUS(net_lchan_summary);
static int get_net_lchan_summary(struct ctrl_cmd *cmd, void *data)
{
@@ -303,16 +287,8 @@ static int get_net_lchan_summary(struct ctrl_cmd *cmd, void *data)
CTRL_CMD_DEFINE(net_lchan_summary, "lchan-summary");
-static int verify_net_paging(struct ctrl_cmd *cmd, const char *v, void *d)
-{
- return 0;
-}
-
-static int set_net_paging(struct ctrl_cmd *cmd, void *data)
-{
- cmd->reply = "Read only attribute";
- return CTRL_CMD_ERROR;
-}
+CTRL_HELPER_VERIFY_STATUS(net_paging);
+CTRL_HELPER_SET_STATUS(net_paging);
static int get_net_paging(struct ctrl_cmd *cmd, void *data)
{
@@ -341,16 +317,8 @@ static int get_net_paging(struct ctrl_cmd *cmd, void *data)
CTRL_CMD_DEFINE(net_paging, "paging");
-static int verify_net_oml_link(struct ctrl_cmd *cmd, const char *v, void *d)
-{
- return 0;
-}
-
-static int set_net_oml_link(struct ctrl_cmd *cmd, void *data)
-{
- cmd->reply = "Read only attribute";
- return CTRL_CMD_ERROR;
-}
+CTRL_HELPER_VERIFY_STATUS(net_oml_link);
+CTRL_HELPER_SET_STATUS(net_oml_link);
static int get_net_oml_link(struct ctrl_cmd *cmd, void *data)
{
@@ -374,16 +342,8 @@ static int get_net_oml_link(struct ctrl_cmd *cmd, void *data)
CTRL_CMD_DEFINE(net_oml_link, "oml_link");
-static int verify_net_smsqueue(struct ctrl_cmd *cmd, const char *v, void *d)
-{
- return 0;
-}
-
-static int set_net_smsqueue(struct ctrl_cmd *cmd, void *data)
-{
- cmd->reply = "Read only attribute";
- return CTRL_CMD_ERROR;
-}
+CTRL_HELPER_VERIFY_STATUS(net_smsqueue);
+CTRL_HELPER_SET_STATUS(net_smsqueue);
static int get_net_smsqueue(struct ctrl_cmd *cmd, void *data)
{
@@ -464,16 +424,8 @@ CTRL_CMD_VTY_COUNTER(net_call_mt_setup, "call.mt_setup",
CTRL_CMD_VTY_COUNTER(net_call_mt_connect, "call.mt_connect",
struct gsm_network, stats.call.mt_connect);
-static int verify_net_status(struct ctrl_cmd *cmd, const char *v, void *d)
-{
- return 0;
-}
-
-static int set_net_status(struct ctrl_cmd *cmd, void *data)
-{
- cmd->reply = "Read only attribute";
- return CTRL_CMD_ERROR;
-}
+CTRL_HELPER_VERIFY_STATUS(net_status);
+CTRL_HELPER_SET_STATUS(net_status);
static int get_net_status(struct ctrl_cmd *cmd, void *data)
{