aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-23 11:24:17 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-24 08:22:45 +0200
commit90267a961c8254b5a01daa1bc8e90fd4c470d7ed (patch)
tree743c247e84c730775a6129b26024852d7cedc5e6
parent02ca7783ab73724b292bc46015df21f0474c34e5 (diff)
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.
-rw-r--r--openbsc/include/openbsc/gb_proxy.h1
-rw-r--r--openbsc/src/gprs/gb_proxy.c27
-rw-r--r--openbsc/src/gprs/gb_proxy_vty.c2
3 files changed, 28 insertions, 2 deletions
diff --git a/openbsc/include/openbsc/gb_proxy.h b/openbsc/include/openbsc/gb_proxy.h
index 7b14a099a..e51dd4744 100644
--- a/openbsc/include/openbsc/gb_proxy.h
+++ b/openbsc/include/openbsc/gb_proxy.h
@@ -17,6 +17,7 @@ struct gbproxy_config {
extern struct gbproxy_config gbcfg;
extern struct cmd_element show_gbproxy_cmd;
+extern struct cmd_element delete_gb_cmd;
/* gb_proxy_vty .c */
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 16a77b456..a7640f0f7 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 @@ static struct gbprox_peer *peer_alloc(uint16_t bvci)
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 @@ gDEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy [stats]",
}
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 63546d3f9..176ea65eb 100644
--- a/openbsc/src/gprs/gb_proxy_vty.c
+++ b/openbsc/src/gprs/gb_proxy_vty.c
@@ -80,6 +80,8 @@ int gbproxy_vty_init(void)
{
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);