diff options
author | Harald Welte <laforge@netfilter.org> | 2009-08-07 13:29:14 +0200 |
---|---|---|
committer | Harald Welte <laforge@netfilter.org> | 2009-08-07 13:29:14 +0200 |
commit | 5013b2ad42c1a63e2f168d3d8a6021e4763446f0 (patch) | |
tree | 1c27e108dad6509f5dc2e4ec076104d3d5768a60 | |
parent | c7c19822fd43a01c54a445addb1e8a82067d82a4 (diff) |
introduce new GSMNET node for the GSM network
-rw-r--r-- | openbsc/include/vty/command.h | 1 | ||||
-rw-r--r-- | openbsc/src/vty/command.c | 12 | ||||
-rw-r--r-- | openbsc/src/vty_interface.c | 109 |
3 files changed, 106 insertions, 16 deletions
diff --git a/openbsc/include/vty/command.h b/openbsc/include/vty/command.h index f536f2e02..1be05aa8e 100644 --- a/openbsc/include/vty/command.h +++ b/openbsc/include/vty/command.h @@ -61,6 +61,7 @@ struct host { /* There are some command levels which called from command node. */ enum node_type { + GSMNET_NODE, BTS_NODE, TRX_NODE, TS_NODE, diff --git a/openbsc/src/vty/command.c b/openbsc/src/vty/command.c index 4c9d2db8e..16e0dfb36 100644 --- a/openbsc/src/vty/command.c +++ b/openbsc/src/vty/command.c @@ -2288,10 +2288,18 @@ DEFUN(config_exit, config_exit_cmd, "exit", "Exit current mode and down to previous mode\n") { switch (vty->node) { - case BTS_NODE: - vty->node = VIEW_NODE; + case GSMNET_NODE: + vty->node = CONFIG_NODE; vty->index = NULL; break; + case BTS_NODE: + vty->node = GSMNET_NODE; + { + /* set vty->index correctly ! */ + struct gsm_bts *bts = vty->index; + vty->index = bts->network; + } + break; case TRX_NODE: vty->node = BTS_NODE; { diff --git a/openbsc/src/vty_interface.c b/openbsc/src/vty_interface.c index fa049d6d6..7213edfa8 100644 --- a/openbsc/src/vty_interface.c +++ b/openbsc/src/vty_interface.c @@ -33,9 +33,16 @@ #include <openbsc/e1_input.h> #include <openbsc/abis_nm.h> #include <openbsc/db.h> +#include <openbsc/talloc.h> static struct gsm_network *gsmnet; +struct cmd_node net_node = { + GSMNET_NODE, + "%s(network)#", + 1, +}; + struct cmd_node bts_node = { BTS_NODE, "%s(bts)#", @@ -159,10 +166,10 @@ DEFUN(show_bts, show_bts_cmd, "show bts [number]", static void config_write_ts_single(struct vty *vty, struct gsm_bts_trx_ts *ts) { - vty_out(vty, "\t\tts %u%s", ts->nr, VTY_NEWLINE); - vty_out(vty, "\t\t\tphys_chan_config %s%s", gsm_pchan_name(ts->pchan), + vty_out(vty, " ts %u%s", ts->nr, VTY_NEWLINE); + vty_out(vty, " phys_chan_config %s%s", gsm_pchan_name(ts->pchan), VTY_NEWLINE); - vty_out(vty, "\t\t\te1_subslot %u %u %u%s", ts->e1_link.e1_nr, + vty_out(vty, " e1_subslot %u %u %u%s", ts->e1_link.e1_nr, ts->e1_link.e1_ts, ts->e1_link.e1_ts_ss, VTY_NEWLINE); } @@ -170,9 +177,9 @@ static void config_write_trx_single(struct vty *vty, struct gsm_bts_trx *trx) { int i; - vty_out(vty, "\ttrx %u%s", trx->nr, VTY_NEWLINE); - vty_out(vty, "\t\tarfcn %u%s", trx->arfcn, VTY_NEWLINE); - vty_out(vty, "\t\tmax_power_red %u%s", trx->max_power_red, VTY_NEWLINE); + vty_out(vty, " trx %u%s", trx->nr, VTY_NEWLINE); + vty_out(vty, " arfcn %u%s", trx->arfcn, VTY_NEWLINE); + vty_out(vty, " max_power_red %u%s", trx->max_power_red, VTY_NEWLINE); for (i = 0; i < TRX_NR_TS; i++) config_write_ts_single(vty, &trx->ts[i]); @@ -182,15 +189,15 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts) { struct gsm_bts_trx *trx; - vty_out(vty, "bts %u%s", bts->nr, VTY_NEWLINE); - vty_out(vty, "\ttype %s%s", btstype2str(bts->type), VTY_NEWLINE); - vty_out(vty, "\tband %s%s", gsm_band_name(bts->band), VTY_NEWLINE); - vty_out(vty, "\tlocation_area_code %u%s", bts->location_area_code, + vty_out(vty, " bts %u%s", bts->nr, VTY_NEWLINE); + vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE); + vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE); + vty_out(vty, " location_area_code %u%s", bts->location_area_code, VTY_NEWLINE); - vty_out(vty, "\ttraining_sequence_code %u%s", bts->tsc, VTY_NEWLINE); - vty_out(vty, "\tbase_station_id_code %u%s", bts->bsic, VTY_NEWLINE); + vty_out(vty, " training_sequence_code %u%s", bts->tsc, VTY_NEWLINE); + vty_out(vty, " base_station_id_code %u%s", bts->bsic, VTY_NEWLINE); if (is_ipaccess_bts(bts)) - vty_out(vty, "\tunit_id %u %u%s", + vty_out(vty, " ip.access unit_id %u %u%s", bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE); llist_for_each_entry(trx, &bts->trx_list, list) @@ -207,6 +214,16 @@ static int config_write_bts(struct vty *v) return CMD_SUCCESS; } +static int config_write_net(struct vty *vty) +{ + vty_out(vty, "network%s", VTY_NEWLINE); + vty_out(vty, " country code %u%s", gsmnet->country_code, VTY_NEWLINE); + vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE); + vty_out(vty, " short name '%s'%s", gsmnet->name_short, VTY_NEWLINE); + vty_out(vty, " long name '%s'%s", gsmnet->name_long, VTY_NEWLINE); + + return CMD_SUCCESS; +} static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx) { @@ -654,6 +671,63 @@ DEFUN(cfg_subscr, return CMD_SUCCESS; } +DEFUN(cfg_net, + cfg_net_cmd, + "network", + "Configure the GSM network") +{ + vty->index = gsmnet; + vty->node = GSMNET_NODE; + + return CMD_SUCCESS; +} + + +DEFUN(cfg_net_ncc, + cfg_net_ncc_cmd, + "network country code <1-999>", + "Set the GSM network country code") +{ + gsmnet->country_code = atoi(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_mnc, + cfg_net_mnc_cmd, + "mobile network code <1-999>", + "Set the GSM mobile network code") +{ + gsmnet->network_code = atoi(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_name_short, + cfg_net_name_short_cmd, + "short name NAME", + "Set the short GSM network name") +{ + if (gsmnet->name_short) + talloc_free(gsmnet->name_short); + + gsmnet->name_short = talloc_strdup(gsmnet, argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_name_long, + cfg_net_name_long_cmd, + "long name NAME", + "Set the long GSM network name") +{ + if (gsmnet->name_long) + talloc_free(gsmnet->name_long); + + gsmnet->name_long = talloc_strdup(gsmnet, argv[0]); + + return CMD_SUCCESS; +} /* per-BTS configuration */ DEFUN(cfg_bts, @@ -1029,7 +1103,14 @@ int bsc_vty_init(struct gsm_network *net) install_element(VIEW_NODE, &show_subscr_cmd); - install_element(CONFIG_NODE, &cfg_bts_cmd); + install_element(CONFIG_NODE, &cfg_net_cmd); + install_node(&net_node, config_write_net); + install_default(GSMNET_NODE); + install_element(GSMNET_NODE, &cfg_net_mnc_cmd); + install_element(GSMNET_NODE, &cfg_net_name_short_cmd); + install_element(GSMNET_NODE, &cfg_net_name_long_cmd); + + install_element(GSMNET_NODE, &cfg_bts_cmd); install_node(&bts_node, config_write_bts); install_default(BTS_NODE); install_element(BTS_NODE, &cfg_bts_type_cmd); |