diff mbox

[3/3] Add vty command to explicitly reset given BVCI

Message ID 1457522965-27238-3-git-send-email-msuraev@sysmocom.de
State Changes Requested, archived
Headers show

Commit Message

Max March 9, 2016, 11:29 a.m. UTC
From: Max <msuraev@sysmocom.de>

It's useful for debugging and is similar to existing nsvc reset vty
command.
---
 src/gb/gprs_bssgp_vty.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Harald Welte March 11, 2016, 3:47 p.m. UTC | #1
Hi Max,

On Wed, Mar 09, 2016 at 12:29:25PM +0100, msuraev@sysmocom.de wrote:
> +		vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, VTY_NEWLINE);
> +	vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, VTY_NEWLINE);

* long lines were not wrapped 
* compilation causes warning:

gprs_bssgp_vty.c: In function 'bvc_reset':
gprs_bssgp_vty.c:134:10: warning: implicit declaration of function
'bssgp_tx_bvc_reset' [-Wimplicit-function-declaration]
  int r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV);

please always make sure to check if patches cause new warnings before
submitting them.
diff mbox

Patch

diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c
index 080867b..4f53ae7 100644
--- a/src/gb/gprs_bssgp_vty.c
+++ b/src/gb/gprs_bssgp_vty.c
@@ -113,6 +113,29 @@  static void dump_bssgp(struct vty *vty, int stats)
 	}
 }
 
+DEFUN(bvc_reset, bvc_reset_cmd,
+	"bvc reset nsei <0-65535> bvci <0-65535>",
+	"Initiate BVC RESET procedure for a given NSEI and BVCI\n")
+{
+	uint16_t nsei = atoi(argv[0]), bvci = atoi(argv[1]);
+	struct bssgp_bvc_ctx *bvc;
+
+	if (!strcmp(argv[0], "reset"))
+		return CMD_WARNING;
+
+	if (argc != 2)
+		return CMD_WARNING;
+
+	bvc = btsctx_by_bvci_nsei(bvci, nsei);
+	if (!bvc) {
+		vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+	int r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV);
+	vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, VTY_NEWLINE);
+	return CMD_SUCCESS;
+}
+
 #define BSSGP_STR "Show information about the BSSGP protocol\n"
 
 DEFUN(show_bssgp, show_bssgp_cmd, "show bssgp",
@@ -185,6 +208,7 @@  int bssgp_vty_init(void)
 	install_element_ve(&show_bssgp_stats_cmd);
 	install_element_ve(&show_bvc_cmd);
 	install_element_ve(&logging_fltr_bvc_cmd);
+	install_element_ve(&bvc_reset_cmd);
 
 	install_element(CFG_LOG_NODE, &logging_fltr_bvc_cmd);