diff options
Diffstat (limited to 'openbsc/src/vty_interface.c')
-rw-r--r-- | openbsc/src/vty_interface.c | 175 |
1 files changed, 172 insertions, 3 deletions
diff --git a/openbsc/src/vty_interface.c b/openbsc/src/vty_interface.c index 897ed2f69..94b177ef3 100644 --- a/openbsc/src/vty_interface.c +++ b/openbsc/src/vty_interface.c @@ -100,6 +100,7 @@ static void dump_pchan_load_vty(struct vty *vty, char *prefix, static void net_dump_vty(struct vty *vty, struct gsm_network *net) { + int i; struct pchan_load pl; vty_out(vty, "BSC is on Country Code %u, Network Code %u " @@ -117,6 +118,8 @@ static void net_dump_vty(struct vty *vty, struct gsm_network *net) VTY_NEWLINE); vty_out(vty, " NECI (TCH/H): %u%s", net->neci, VTY_NEWLINE); + vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch, + VTY_NEWLINE); vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode), VTY_NEWLINE); vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off", @@ -126,6 +129,12 @@ static void net_dump_vty(struct vty *vty, struct gsm_network *net) network_chan_load(&pl, net); vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE); dump_pchan_load_vty(vty, " ", &pl); + + vty_out(vty, " Allowed Audio Codecs: "); + for (i = 0; i < net->audio_length; ++i) + vty_out(vty, "hr: %d ver: %d, ", + net->audio_support[i]->hr, net->audio_support[i]->ver); + vty_out(vty, "%s", VTY_NEWLINE); } DEFUN(show_net, show_net_cmd, "show network", @@ -358,7 +367,11 @@ static int config_write_net(struct vty *vty) { vty_out(vty, "network%s", VTY_NEWLINE); vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE); + if (gsmnet->core_country_code > 0) + vty_out(vty, " core network country code %u%s", gsmnet->core_country_code, VTY_NEWLINE); vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE); + if (gsmnet->core_network_code > 0) + vty_out(vty, " core mobile network code %u%s", gsmnet->core_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); vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE); @@ -366,6 +379,7 @@ static int config_write_net(struct vty *vty) gsmnet->reject_cause, VTY_NEWLINE); vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE); vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE); + vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE); vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode), VTY_NEWLINE); vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE); @@ -393,6 +407,28 @@ static int config_write_net(struct vty *vty) vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE); vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE); vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE); + vty_out(vty, " ipacc rtp_payload %u%s", gsmnet->rtp_payload, VTY_NEWLINE); + vty_out(vty, " rtp base %u%s", gsmnet->rtp_base_port, VTY_NEWLINE); + + if (gsmnet->audio_length != 0) { + int i; + + vty_out(vty, " codec_list "); + for (i = 0; i < gsmnet->audio_length; ++i) { + printf("I... %d %d\n", i, gsmnet->audio_length); + if (i != 0) + vty_out(vty, ", "); + + if (gsmnet->audio_support[i]->hr) + vty_out(vty, "hr%.1u", gsmnet->audio_support[i]->ver); + else + vty_out(vty, "fr%.1u", gsmnet->audio_support[i]->ver); + } + vty_out(vty, "%s", VTY_NEWLINE); + } + + if (gsmnet->bsc_token) + vty_out(vty, " bsc_token %s%s", gsmnet->bsc_token, VTY_NEWLINE); return CMD_SUCCESS; } @@ -941,6 +977,16 @@ DEFUN(cfg_net_ncc, return CMD_SUCCESS; } +DEFUN(cfg_core_net_ncc, + cfg_core_net_ncc_cmd, + "core network country code <1-999>", + "Set the GSM country code to be used in the MSC connection") +{ + gsmnet->core_country_code = atoi(argv[0]); + + return CMD_SUCCESS; +} + DEFUN(cfg_net_mnc, cfg_net_mnc_cmd, "mobile network code <1-999>", @@ -951,6 +997,16 @@ DEFUN(cfg_net_mnc, return CMD_SUCCESS; } +DEFUN(cfg_core_net_mnc, + cfg_core_net_mnc_cmd, + "core mobile network code <1-999>", + "Set the GSM mobile network code to be used in the MSC connection") +{ + gsmnet->core_network_code = atoi(argv[0]); + + return CMD_SUCCESS; +} + DEFUN(cfg_net_name_short, cfg_net_name_short_cmd, "short name NAME", @@ -1015,6 +1071,7 @@ DEFUN(cfg_net_neci, "Set if NECI of cell selection is to be set") { gsmnet->neci = atoi(argv[0]); + gsm_net_update_ctype(gsmnet); return CMD_SUCCESS; } @@ -1101,6 +1158,112 @@ DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd, return CMD_SUCCESS; } +DEFUN(cfg_net_supported_codecs, + cfg_net_supported_codecs_cmd, + "codec_list .LIST", + "Set the three preferred audio codecs.\n" + "Codec List") +{ + int saw_fr, saw_hr; + int i; + + saw_fr = saw_hr = 0; + + /* free the old list... if it exists */ + if (gsmnet->audio_support) { + talloc_free(gsmnet->audio_support); + gsmnet->audio_support = NULL; + gsmnet->audio_length = 0; + } + + /* create a new array */ + gsmnet->audio_support = + talloc_zero_array(gsmnet, struct gsm_audio_support *, argc); + gsmnet->audio_length = argc; + + for (i = 0; i < argc; ++i) { + /* check for hrX or frX */ + if (strlen(argv[i]) != 3 + || argv[i][1] != 'r' + || (argv[i][0] != 'h' && argv[i][0] != 'f') + || argv[i][2] < 0x30 + || argv[i][2] > 0x39) + goto error; + + gsmnet->audio_support[i] = talloc_zero(gsmnet->audio_support, + struct gsm_audio_support); + gsmnet->audio_support[i]->ver = atoi(argv[i] + 2); + + if (strncmp("hr", argv[i], 2) == 0) { + gsmnet->audio_support[i]->hr = 1; + saw_hr = 1; + } else if (strncmp("fr", argv[i], 2) == 0) { + gsmnet->audio_support[i]->hr = 0; + saw_fr = 1; + } + + if (saw_hr && saw_fr) { + vty_out(vty, "Can not have full-rate and half-rate codec.%s", + VTY_NEWLINE); + return CMD_ERR_INCOMPLETE; + } + } + + return CMD_SUCCESS; + +error: + vty_out(vty, "Codec name must be hrX or frX. Was '%s'%s", + argv[i], VTY_NEWLINE); + return CMD_ERR_INCOMPLETE; +} + +DEFUN(cfg_net_ipacc_rtp_payload, + cfg_net_ipacc_rtp_payload_cmd, + "ipacc rtp_payload <0-256>", + "Override the RTP payload to use") +{ + gsmnet->rtp_payload = atoi(argv[0]) & 0xff; + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_rtp_base_port, + cfg_net_rtp_base_port_cmd, + "rtp base <0-65534>", + "Base port to use for MGCP RTP") +{ + unsigned int port = atoi(argv[0]); + if (port > 65534) { + vty_out(vty, "%% wrong base port '%s'%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + gsmnet->rtp_base_port = port; + return CMD_SUCCESS; +} + +DEFUN(cfg_net_bsc_token, + cfg_net_bsc_token_cmd, + "bsc_token TOKEN", + "A token for the BSC to be sent to the MSC") +{ + if (gsmnet->bsc_token) + talloc_free(gsmnet->bsc_token); + gsmnet->bsc_token = talloc_strdup(gsmnet, argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_pag_any_tch, + cfg_net_pag_any_tch_cmd, + "paging any use tch (0|1)", + "Assign a TCH when receiving a Paging Any request") +{ + gsmnet->pag_any_tch = atoi(argv[0]); + gsm_net_update_ctype(gsmnet); + return CMD_SUCCESS; +} + #define DECLARE_TIMER(number, doc) \ DEFUN(cfg_net_T##number, \ cfg_net_T##number##_cmd, \ @@ -1111,7 +1274,7 @@ DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd, \ if (value < 0 || value > 65535) { \ vty_out(vty, "Timer value %s out of range.%s", \ - argv[0], VTY_NEWLINE); \ + argv[0], VTY_NEWLINE); \ return CMD_WARNING; \ } \ \ @@ -1131,7 +1294,6 @@ DECLARE_TIMER(3117, "Currently not used.") DECLARE_TIMER(3119, "Currently not used.") DECLARE_TIMER(3141, "Currently not used.") - /* per-BTS configuration */ DEFUN(cfg_bts, cfg_bts_cmd, @@ -1761,12 +1923,14 @@ int bsc_vty_init(struct gsm_network *net) install_element(VIEW_NODE, &show_stats_cmd); openbsc_vty_add_cmds(); - + install_element(CONFIG_NODE, &cfg_net_cmd); install_node(&net_node, config_write_net); install_default(GSMNET_NODE); install_element(GSMNET_NODE, &cfg_net_ncc_cmd); + install_element(GSMNET_NODE, &cfg_core_net_ncc_cmd); install_element(GSMNET_NODE, &cfg_net_mnc_cmd); + install_element(GSMNET_NODE, &cfg_core_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_net_auth_policy_cmd); @@ -1782,6 +1946,9 @@ int bsc_vty_init(struct gsm_network *net) install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd); install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd); install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd); + install_element(GSMNET_NODE, &cfg_net_supported_codecs_cmd); + install_element(GSMNET_NODE, &cfg_net_ipacc_rtp_payload_cmd); + install_element(GSMNET_NODE, &cfg_net_rtp_base_port_cmd); install_element(GSMNET_NODE, &cfg_net_T3101_cmd); install_element(GSMNET_NODE, &cfg_net_T3103_cmd); install_element(GSMNET_NODE, &cfg_net_T3105_cmd); @@ -1793,6 +1960,8 @@ int bsc_vty_init(struct gsm_network *net) install_element(GSMNET_NODE, &cfg_net_T3117_cmd); install_element(GSMNET_NODE, &cfg_net_T3119_cmd); install_element(GSMNET_NODE, &cfg_net_T3141_cmd); + install_element(GSMNET_NODE, &cfg_net_bsc_token_cmd); + install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd); install_element(GSMNET_NODE, &cfg_bts_cmd); install_node(&bts_node, config_write_bts); |