diff options
Diffstat (limited to 'openbsc/src/osmo-bsc/osmo_bsc_vty.c')
-rw-r--r-- | openbsc/src/osmo-bsc/osmo_bsc_vty.c | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c index 1fb1d6400..055f27ddb 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c @@ -1,6 +1,6 @@ /* Osmo BSC VTY Configuration */ /* (C) 2009-2011 by Holger Hans Peter Freyther - * (C) 2009-2010 by On-Waves + * (C) 2009-2011 by On-Waves * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -51,6 +51,7 @@ DEFUN(cfg_net_msc, cfg_net_msc_cmd, static int config_write_msc(struct vty *vty) { + struct bsc_msc_dest *dest; struct osmo_msc_data *data = osmo_msc_data(vty); vty_out(vty, "msc%s", VTY_NEWLINE); @@ -63,9 +64,6 @@ static int config_write_msc(struct vty *vty) vty_out(vty, " core-mobile-country-code %d%s", data->core_mcc, VTY_NEWLINE); vty_out(vty, " ip.access rtp-base %d%s", data->rtp_base, VTY_NEWLINE); - vty_out(vty, " ip %s%s", data->msc_ip, VTY_NEWLINE); - vty_out(vty, " port %d%s", data->msc_port, VTY_NEWLINE); - vty_out(vty, " ip-dscp %d%s", data->msc_ip_dscp, VTY_NEWLINE); vty_out(vty, " timeout-ping %d%s", data->ping_timeout, VTY_NEWLINE); vty_out(vty, " timeout-pong %d%s", data->pong_timeout, VTY_NEWLINE); if (data->mid_call_txt) @@ -94,6 +92,10 @@ static int config_write_msc(struct vty *vty) } + llist_for_each_entry(dest, &data->dests, list) + vty_out(vty, " dest %s %d %d%s", dest->ip, dest->port, + dest->dscp, VTY_NEWLINE); + return CMD_SUCCESS; } @@ -200,34 +202,55 @@ error: return CMD_ERR_INCOMPLETE; } -DEFUN(cfg_net_msc_ip, - cfg_net_msc_ip_cmd, - "ip A.B.C.D", "Set the MSC/MUX IP address.") +DEFUN(cfg_net_msc_dest, + cfg_net_msc_dest_cmd, + "dest A.B.C.D <1-65000> <0-255>", + "Add a destination to a MUX/MSC\n" + "IP Address\n" "Port\n" "DSCP\n") { + struct bsc_msc_dest *dest; struct osmo_msc_data *data = osmo_msc_data(vty); - bsc_replace_string(data, &data->msc_ip, argv[0]); + dest = talloc_zero(data, struct bsc_msc_dest); + if (!dest) { + vty_out(vty, "%%Failed to create structure.%s", VTY_NEWLINE); + return CMD_WARNING; + } + + dest->ip = talloc_strdup(data, argv[0]); + if (!dest->ip) { + vty_out(vty, "%%Failed to copy dest ip.%s", VTY_NEWLINE); + talloc_free(dest); + return CMD_WARNING; + } + + dest->port = atoi(argv[1]); + dest->dscp = atoi(argv[2]); + llist_add_tail(&dest->list, &data->dests); return CMD_SUCCESS; } -DEFUN(cfg_net_msc_port, - cfg_net_msc_port_cmd, - "port <1-65000>", - "Set the MSC/MUX port.") +DEFUN(cfg_net_msc_no_dest, + cfg_net_msc_no_dest_cmd, + "no dest A.B.C.D <1-65000> <0-255>", + NO_STR "Remove a destination to a MUX/MSC\n" + "IP Address\n" "Port\n" "DSCP\n") { + struct bsc_msc_dest *dest, *tmp; struct osmo_msc_data *data = osmo_msc_data(vty); - data->msc_port = atoi(argv[0]); - return CMD_SUCCESS; -} + int port = atoi(argv[1]); + int dscp = atoi(argv[2]); + + llist_for_each_entry_safe(dest, tmp, &data->dests, list) { + if (port != dest->port || dscp != dest->dscp + || strcmp(dest->ip, argv[0]) != 0) + continue; + + llist_del(&dest->list); + talloc_free(dest); + } -DEFUN(cfg_net_msc_prio, - cfg_net_msc_prio_cmd, - "ip-dscp <0-255>", - "Set the IP_TOS socket attribite") -{ - struct osmo_msc_data *data = osmo_msc_data(vty); - data->msc_ip_dscp = atoi(argv[0]); return CMD_SUCCESS; } @@ -312,9 +335,8 @@ int bsc_vty_init_extra(void) install_element(MSC_NODE, &cfg_net_bsc_mcc_cmd); install_element(MSC_NODE, &cfg_net_bsc_rtp_base_cmd); install_element(MSC_NODE, &cfg_net_bsc_codec_list_cmd); - install_element(MSC_NODE, &cfg_net_msc_ip_cmd); - install_element(MSC_NODE, &cfg_net_msc_port_cmd); - install_element(MSC_NODE, &cfg_net_msc_prio_cmd); + install_element(MSC_NODE, &cfg_net_msc_dest_cmd); + install_element(MSC_NODE, &cfg_net_msc_no_dest_cmd); install_element(MSC_NODE, &cfg_net_msc_ping_time_cmd); install_element(MSC_NODE, &cfg_net_msc_pong_time_cmd); install_element(MSC_NODE, &cfg_net_msc_mid_call_text_cmd); |