Change in osmo-bsc[master]: vty: introduce and use GPRS_CHECK_ENABLED() macro

2020-08-11 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/19552 )

Change subject: vty: introduce and use GPRS_CHECK_ENABLED() macro
..

vty: introduce and use GPRS_CHECK_ENABLED() macro

Change-Id: I39907a569e80344fc73596bea32a1b474ec720e0
---
M src/osmo-bsc/bsc_vty.c
1 file changed, 21 insertions(+), 48 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index fc4ebd6..16935d3 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -2916,6 +2916,15 @@

 #define GPRS_TEXT  "GPRS Packet Network\n"

+#define GPRS_CHECK_ENABLED(bts) \
+   do { \
+   if (bts->gprs.mode == BTS_GPRS_NONE) { \
+   vty_out(vty, "%% GPRS is not enabled on BTS %u%s", \
+   bts->nr, VTY_NEWLINE); \
+   return CMD_WARNING; \
+   } \
+   } while (0)
+
 DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
"gprs cell bvci <2-65535>",
GPRS_TEXT
@@ -2926,10 +2935,7 @@
/* ETSI TS 101 343: values 0 and 1 are reserved for signalling and PTM 
*/
struct gsm_bts *bts = vty->index;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.cell.bvci = atoi(argv[0]);

@@ -2944,10 +2950,7 @@
 {
struct gsm_bts *bts = vty->index;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.nse.nsei = atoi(argv[0]);

@@ -2966,10 +2969,7 @@
struct gsm_bts *bts = vty->index;
int idx = atoi(argv[0]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);

@@ -2987,10 +2987,7 @@
struct gsm_bts *bts = vty->index;
int idx = atoi(argv[0]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.nsvc[idx].local_port = atoi(argv[1]);

@@ -3008,10 +3005,7 @@
struct gsm_bts *bts = vty->index;
int idx = atoi(argv[0]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);

@@ -3029,10 +3023,7 @@
int idx = atoi(argv[0]);
struct in_addr ia;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

inet_aton(argv[1], );
bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
@@ -3062,10 +3053,7 @@
int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
int val = atoi(argv[1]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
return CMD_WARNING;
@@ -3099,10 +3087,7 @@
int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
int val = atoi(argv[1]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
return CMD_WARNING;
@@ -3121,10 +3106,7 @@
 {
struct gsm_bts *bts = vty->index;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.rac = atoi(argv[0]);

@@ -3138,10 +3120,7 @@
 {
struct gsm_bts *bts = vty->index;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.ctrl_ack_type_use_block = false;

@@ -3155,10 +3134,7 @@
 {
struct gsm_bts *bts = vty->index;

-   if 

Change in osmo-bsc[master]: vty: introduce and use GPRS_CHECK_ENABLED() macro

2020-08-11 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/19552 )

Change subject: vty: introduce and use GPRS_CHECK_ENABLED() macro
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/19552
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I39907a569e80344fc73596bea32a1b474ec720e0
Gerrit-Change-Number: 19552
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Tue, 11 Aug 2020 06:33:25 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-bsc[master]: vty: introduce and use GPRS_CHECK_ENABLED() macro

2020-08-09 Thread fixeria
fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/19552 )


Change subject: vty: introduce and use GPRS_CHECK_ENABLED() macro
..

vty: introduce and use GPRS_CHECK_ENABLED() macro

Change-Id: I39907a569e80344fc73596bea32a1b474ec720e0
---
M src/osmo-bsc/bsc_vty.c
1 file changed, 21 insertions(+), 48 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/52/19552/1

diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index fc4ebd6..16935d3 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -2916,6 +2916,15 @@

 #define GPRS_TEXT  "GPRS Packet Network\n"

+#define GPRS_CHECK_ENABLED(bts) \
+   do { \
+   if (bts->gprs.mode == BTS_GPRS_NONE) { \
+   vty_out(vty, "%% GPRS is not enabled on BTS %u%s", \
+   bts->nr, VTY_NEWLINE); \
+   return CMD_WARNING; \
+   } \
+   } while (0)
+
 DEFUN(cfg_bts_prs_bvci, cfg_bts_gprs_bvci_cmd,
"gprs cell bvci <2-65535>",
GPRS_TEXT
@@ -2926,10 +2935,7 @@
/* ETSI TS 101 343: values 0 and 1 are reserved for signalling and PTM 
*/
struct gsm_bts *bts = vty->index;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.cell.bvci = atoi(argv[0]);

@@ -2944,10 +2950,7 @@
 {
struct gsm_bts *bts = vty->index;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.nse.nsei = atoi(argv[0]);

@@ -2966,10 +2969,7 @@
struct gsm_bts *bts = vty->index;
int idx = atoi(argv[0]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.nsvc[idx].nsvci = atoi(argv[1]);
 
@@ -2987,10 +2987,7 @@
struct gsm_bts *bts = vty->index;
int idx = atoi(argv[0]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.nsvc[idx].local_port = atoi(argv[1]);

@@ -3008,10 +3005,7 @@
struct gsm_bts *bts = vty->index;
int idx = atoi(argv[0]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);
 
bts->gprs.nsvc[idx].remote_port = atoi(argv[1]);

@@ -3029,10 +3023,7 @@
int idx = atoi(argv[0]);
struct in_addr ia;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

inet_aton(argv[1], );
bts->gprs.nsvc[idx].remote_ip = ntohl(ia.s_addr);
@@ -3062,10 +3053,7 @@
int idx = get_string_value(gprs_ns_timer_strs, argv[0]);
int val = atoi(argv[1]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.nse.timer))
return CMD_WARNING;
@@ -3099,10 +3087,7 @@
int idx = get_string_value(gprs_bssgp_cfg_strs, argv[0]);
int val = atoi(argv[1]);

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

if (idx < 0 || idx >= ARRAY_SIZE(bts->gprs.cell.timer))
return CMD_WARNING;
@@ -3121,10 +3106,7 @@
 {
struct gsm_bts *bts = vty->index;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.rac = atoi(argv[0]);

@@ -3138,10 +3120,7 @@
 {
struct gsm_bts *bts = vty->index;

-   if (bts->gprs.mode == BTS_GPRS_NONE) {
-   vty_out(vty, "%% GPRS not enabled on BTS %u%s", bts->nr, 
VTY_NEWLINE);
-   return CMD_WARNING;
-   }
+   GPRS_CHECK_ENABLED(bts);

bts->gprs.ctrl_ack_type_use_block = false;

@@ -3155,10 +3134,7 @@
 {
struct gsm_bts *bts = vty->index;
 
-