gbproxy: Add a command to delete peers from the GBProxy
This just deletes the peer entry based on NSEI and BVCI. The NS-VC
are not touched.
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 16a77b4..a7640f0 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -1,7 +1,8 @@
/* NS-over-IP proxy */
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
- * (C) 2010 by On-Waves
+ * (C) 2010-2013 by On-Waves
+ * (C) 2013 by Holger Hans Peter Freyther
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -204,7 +205,6 @@
return peer;
}
-static void peer_free(struct gbprox_peer *peer) __attribute__((__unused__));
static void peer_free(struct gbprox_peer *peer)
{
rate_ctr_group_free(peer->ctrg);
@@ -910,3 +910,26 @@
}
return CMD_SUCCESS;
}
+
+gDEFUN(delete_gb, delete_gb_cmd,
+ "delete-gbproxy-peer <0-65534> bvci <0-65534>",
+ "Delete a GBProxy peer by NSEI and BVCI\n"
+ "NSEI number\n"
+ "BVCI\n"
+ "BVCI number\n")
+{
+ struct gbprox_peer *peer, *tmp;
+ const uint16_t nsei = atoi(argv[0]);
+ const uint16_t bvci = atoi(argv[1]);
+
+ llist_for_each_entry_safe(peer, tmp, &gbprox_bts_peers, list) {
+ if (peer->bvci != bvci)
+ continue;
+ if (peer->nsei != nsei)
+ continue;
+
+ peer_free(peer);
+ }
+
+ return CMD_SUCCESS;
+}
diff --git a/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c
index 63546d3..176ea65 100644
--- a/openbsc/src/gprs/gb_proxy_vty.c
+++ b/openbsc/src/gprs/gb_proxy_vty.c
@@ -80,6 +80,8 @@
{
install_element_ve(&show_gbproxy_cmd);
+ install_element(ENABLE_NODE, &delete_gb_cmd);
+
install_element(CONFIG_NODE, &cfg_gbproxy_cmd);
install_node(&gbproxy_node, config_write_gbproxy);
bsc_install_default(GBPROXY_NODE);