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.
This commit is contained in:
Holger Hans Peter Freyther 2013-10-23 11:24:17 +02:00
parent 02ca7783ab
commit 90267a961c
3 changed files with 28 additions and 2 deletions

View File

@ -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 */

View File

@ -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;
}

View File

@ -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);