Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1 | /* OpenBSC NAT interface to quagga VTY */ |
Holger Hans Peter Freyther | 694d980 | 2015-06-08 18:33:28 +0200 | [diff] [blame] | 2 | /* (C) 2010-2015 by Holger Hans Peter Freyther |
| 3 | * (C) 2010-2015 by On-Waves |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 7 | * it under the terms of the GNU Affero General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 14 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 15 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * You should have received a copy of the GNU Affero General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 18 | * |
| 19 | */ |
| 20 | |
Holger Hans Peter Freyther | 1398f13 | 2010-06-15 20:14:08 +0800 | [diff] [blame] | 21 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 22 | #include <openbsc/gsm_data.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 23 | #include <openbsc/bsc_nat.h> |
Holger Hans Peter Freyther | c2b31ed | 2010-07-31 05:17:17 +0800 | [diff] [blame] | 24 | #include <openbsc/bsc_nat_sccp.h> |
Holger Hans Peter Freyther | 973dbae | 2015-04-04 20:47:03 +0200 | [diff] [blame] | 25 | #include <openbsc/bsc_msg_filter.h> |
Holger Hans Peter Freyther | aad82ce | 2010-05-11 19:07:39 +0800 | [diff] [blame] | 26 | #include <openbsc/bsc_msc.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 27 | #include <openbsc/gsm_04_08.h> |
Holger Hans Peter Freyther | f7d3335 | 2010-06-15 18:50:26 +0800 | [diff] [blame] | 28 | #include <openbsc/mgcp.h> |
Holger Hans Peter Freyther | 5f291d5 | 2010-04-06 12:01:15 +0200 | [diff] [blame] | 29 | #include <openbsc/vty.h> |
Holger Hans Peter Freyther | ddf191e | 2013-06-25 11:44:01 +0200 | [diff] [blame] | 30 | #include <openbsc/nat_rewrite_trie.h> |
Holger Hans Peter Freyther | 6c45f2e | 2010-06-15 19:06:18 +0800 | [diff] [blame] | 31 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 32 | #include <osmocom/core/talloc.h> |
| 33 | #include <osmocom/core/rate_ctr.h> |
| 34 | #include <osmocom/core/utils.h> |
Pablo Neira Ayuso | 739a566 | 2011-03-09 13:36:32 +0100 | [diff] [blame] | 35 | #include <osmocom/vty/logging.h> |
Pablo Neira Ayuso | 6110a3f | 2011-03-28 19:35:00 +0200 | [diff] [blame] | 36 | #include <osmocom/vty/misc.h> |
Pablo Neira Ayuso | 8be171e | 2014-08-27 14:58:43 +0200 | [diff] [blame] | 37 | #include <openbsc/osmux.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 38 | |
Harald Welte | d5db12c | 2010-08-03 15:11:51 +0200 | [diff] [blame] | 39 | #include <osmocom/sccp/sccp.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 40 | |
| 41 | #include <stdlib.h> |
Max | 4936448 | 2016-04-13 11:36:39 +0200 | [diff] [blame] | 42 | #include <stdbool.h> |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 43 | |
| 44 | static struct bsc_nat *_nat; |
| 45 | |
Holger Hans Peter Freyther | c0370e4 | 2011-05-17 19:28:07 +0200 | [diff] [blame] | 46 | |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 47 | #define BSC_STR "Information about BSCs\n" |
| 48 | #define MGCP_STR "MGCP related status\n" |
Holger Hans Peter Freyther | c0370e4 | 2011-05-17 19:28:07 +0200 | [diff] [blame] | 49 | #define PAGING_STR "Paging\n" |
Holger Hans Peter Freyther | e36b487 | 2011-05-31 00:35:46 +0200 | [diff] [blame] | 50 | #define SMSC_REWRITE "SMSC Rewriting\n" |
Holger Hans Peter Freyther | c0370e4 | 2011-05-17 19:28:07 +0200 | [diff] [blame] | 51 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 52 | static struct cmd_node nat_node = { |
| 53 | NAT_NODE, |
Harald Welte | 570ce24 | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 54 | "%s(config-nat)# ", |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 55 | 1, |
| 56 | }; |
| 57 | |
| 58 | static struct cmd_node bsc_node = { |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 59 | NAT_BSC_NODE, |
Harald Welte | 570ce24 | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 60 | "%s(config-nat-bsc)# ", |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 61 | 1, |
| 62 | }; |
| 63 | |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 64 | static struct cmd_node pgroup_node = { |
| 65 | PGROUP_NODE, |
Harald Welte | 570ce24 | 2012-08-17 13:16:10 +0200 | [diff] [blame] | 66 | "%s(config-nat-paging-group)# ", |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 67 | 1, |
| 68 | }; |
| 69 | |
| 70 | static int config_write_pgroup(struct vty *vty) |
| 71 | { |
| 72 | return CMD_SUCCESS; |
| 73 | } |
| 74 | |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 75 | static void dump_lac(struct vty *vty, struct llist_head *head) |
| 76 | { |
| 77 | struct bsc_lac_entry *lac; |
| 78 | llist_for_each_entry(lac, head, entry) |
| 79 | vty_out(vty, " location_area_code %u%s", lac->lac, VTY_NEWLINE); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | static void write_pgroup_lst(struct vty *vty, struct bsc_nat_paging_group *pgroup) |
| 84 | { |
| 85 | vty_out(vty, " paging-group %d%s", pgroup->nr, VTY_NEWLINE); |
| 86 | dump_lac(vty, &pgroup->lists); |
| 87 | } |
| 88 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 89 | static int config_write_nat(struct vty *vty) |
| 90 | { |
Holger Hans Peter Freyther | a1e6bd6 | 2015-04-04 22:40:12 +0200 | [diff] [blame] | 91 | struct bsc_msg_acc_lst *lst; |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 92 | struct bsc_nat_paging_group *pgroup; |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 93 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 94 | vty_out(vty, "nat%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | e188010 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 95 | vty_out(vty, " msc ip %s%s", _nat->main_dest->ip, VTY_NEWLINE); |
| 96 | vty_out(vty, " msc port %d%s", _nat->main_dest->port, VTY_NEWLINE); |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 97 | vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE); |
| 98 | vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE); |
| 99 | vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE); |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 100 | if (_nat->include_file) |
| 101 | vty_out(vty, " bscs-config-file %s%s", _nat->include_file, VTY_NEWLINE); |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 102 | if (_nat->token) |
| 103 | vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE); |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 104 | vty_out(vty, " ip-dscp %d%s", _nat->bsc_ip_dscp, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 105 | if (_nat->acc_lst_name) |
| 106 | vty_out(vty, " access-list-name %s%s", _nat->acc_lst_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 107 | if (_nat->imsi_black_list_fn) |
| 108 | vty_out(vty, " imsi-black-list-file-name %s%s", |
| 109 | _nat->imsi_black_list_fn, VTY_NEWLINE); |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 110 | if (_nat->ussd_lst_name) |
| 111 | vty_out(vty, " ussd-list-name %s%s", _nat->ussd_lst_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame] | 112 | if (_nat->ussd_query) |
| 113 | vty_out(vty, " ussd-query %s%s", _nat->ussd_query, VTY_NEWLINE); |
Holger Hans Peter Freyther | e393f27 | 2010-10-12 18:25:52 +0200 | [diff] [blame] | 114 | if (_nat->ussd_token) |
| 115 | vty_out(vty, " ussd-token %s%s", _nat->ussd_token, VTY_NEWLINE); |
| 116 | if (_nat->ussd_local) |
| 117 | vty_out(vty, " ussd-local-ip %s%s", _nat->ussd_local, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 118 | |
Holger Hans Peter Freyther | 7642439 | 2010-10-21 10:59:54 +0200 | [diff] [blame] | 119 | if (_nat->num_rewr_name) |
| 120 | vty_out(vty, " number-rewrite %s%s", _nat->num_rewr_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 67e423c | 2013-06-25 15:38:31 +0200 | [diff] [blame] | 121 | if (_nat->num_rewr_post_name) |
| 122 | vty_out(vty, " number-rewrite-post %s%s", |
| 123 | _nat->num_rewr_post_name, VTY_NEWLINE); |
| 124 | |
Holger Hans Peter Freyther | e36b487 | 2011-05-31 00:35:46 +0200 | [diff] [blame] | 125 | if (_nat->smsc_rewr_name) |
| 126 | vty_out(vty, " rewrite-smsc addr %s%s", |
| 127 | _nat->smsc_rewr_name, VTY_NEWLINE); |
| 128 | if (_nat->tpdest_match_name) |
| 129 | vty_out(vty, " rewrite-smsc tp-dest-match %s%s", |
| 130 | _nat->tpdest_match_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 68368dd | 2012-01-10 22:39:07 +0100 | [diff] [blame] | 131 | if (_nat->sms_clear_tp_srr_name) |
| 132 | vty_out(vty, " sms-clear-tp-srr %s%s", |
| 133 | _nat->sms_clear_tp_srr_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 7d60bdb | 2012-01-18 20:40:01 +0100 | [diff] [blame] | 134 | if (_nat->sms_num_rewr_name) |
| 135 | vty_out(vty, " sms-number-rewrite %s%s", |
| 136 | _nat->sms_num_rewr_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | ddf191e | 2013-06-25 11:44:01 +0200 | [diff] [blame] | 137 | if (_nat->num_rewr_trie_name) |
| 138 | vty_out(vty, " prefix-tree %s%s", |
| 139 | _nat->num_rewr_trie_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 7642439 | 2010-10-21 10:59:54 +0200 | [diff] [blame] | 140 | |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 141 | llist_for_each_entry(lst, &_nat->access_lists, list) |
Holger Hans Peter Freyther | a1e6bd6 | 2015-04-04 22:40:12 +0200 | [diff] [blame] | 142 | bsc_msg_acc_lst_write(vty, lst); |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 143 | llist_for_each_entry(pgroup, &_nat->paging_groups, entry) |
| 144 | write_pgroup_lst(vty, pgroup); |
Holger Hans Peter Freyther | c327187 | 2012-11-05 14:54:56 +0100 | [diff] [blame] | 145 | if (_nat->mgcp_ipa) |
Jacob Erlbeck | 4c9dff5 | 2013-09-02 13:17:17 +0200 | [diff] [blame] | 146 | vty_out(vty, " use-msc-ipa-for-mgcp%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 7f100c9 | 2015-04-23 20:25:17 -0400 | [diff] [blame] | 147 | vty_out(vty, " %ssdp-ensure-amr-mode-set%s", |
| 148 | _nat->sdp_ensure_amr_mode_set ? "" : "no ", VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 149 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 150 | return CMD_SUCCESS; |
| 151 | } |
| 152 | |
| 153 | static void config_write_bsc_single(struct vty *vty, struct bsc_config *bsc) |
| 154 | { |
| 155 | vty_out(vty, " bsc %u%s", bsc->nr, VTY_NEWLINE); |
| 156 | vty_out(vty, " token %s%s", bsc->token, VTY_NEWLINE); |
Holger Hans Peter Freyther | 694d980 | 2015-06-08 18:33:28 +0200 | [diff] [blame] | 157 | if (bsc->key_present) |
| 158 | vty_out(vty, " auth-key %s%s", osmo_hexdump(bsc->key, 16), VTY_NEWLINE); |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 159 | dump_lac(vty, &bsc->lac_list); |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 160 | if (bsc->description) |
| 161 | vty_out(vty, " description %s%s", bsc->description, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 162 | if (bsc->acc_lst_name) |
Holger Hans Peter Freyther | 27d36de | 2010-06-08 11:18:26 +0800 | [diff] [blame] | 163 | vty_out(vty, " access-list-name %s%s", bsc->acc_lst_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 9ec030d | 2011-02-27 11:04:27 +0100 | [diff] [blame] | 164 | vty_out(vty, " max-endpoints %d%s", bsc->max_endpoints, VTY_NEWLINE); |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 165 | if (bsc->paging_group != -1) |
Holger Hans Peter Freyther | c0370e4 | 2011-05-17 19:28:07 +0200 | [diff] [blame] | 166 | vty_out(vty, " paging group %d%s", bsc->paging_group, VTY_NEWLINE); |
| 167 | vty_out(vty, " paging forbidden %d%s", bsc->forbid_paging, VTY_NEWLINE); |
Holger Hans Peter Freyther | 20626dd | 2015-10-02 18:15:18 +0200 | [diff] [blame] | 168 | switch (bsc->osmux) { |
| 169 | case OSMUX_USAGE_ON: |
Pablo Neira Ayuso | cab6e75 | 2014-02-05 18:56:17 +0100 | [diff] [blame] | 170 | vty_out(vty, " osmux on%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 20626dd | 2015-10-02 18:15:18 +0200 | [diff] [blame] | 171 | break; |
| 172 | case OSMUX_USAGE_ONLY: |
| 173 | vty_out(vty, " osmux only%s", VTY_NEWLINE); |
| 174 | break; |
| 175 | } |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static int config_write_bsc(struct vty *vty) |
| 179 | { |
| 180 | struct bsc_config *bsc; |
| 181 | |
| 182 | llist_for_each_entry(bsc, &_nat->bsc_configs, entry) |
| 183 | config_write_bsc_single(vty, bsc); |
| 184 | return CMD_SUCCESS; |
| 185 | } |
| 186 | |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 187 | DEFUN(show_bscs, show_bscs_cmd, "show bscs-config", |
| 188 | SHOW_STR "Show configured BSCs\n" |
| 189 | "Both from included file and vty\n") |
| 190 | { |
| 191 | vty_out(vty, "BSCs configuration loaded from %s:%s", _nat->resolved_path, |
| 192 | VTY_NEWLINE); |
| 193 | return config_write_bsc(vty); |
| 194 | } |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 195 | |
Holger Hans Peter Freyther | 01a0b1b | 2010-04-19 16:06:43 +0800 | [diff] [blame] | 196 | DEFUN(show_sccp, show_sccp_cmd, "show sccp connections", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 197 | SHOW_STR "Display information about SCCP\n" |
| 198 | "All active connections\n") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 199 | { |
Holger Hans Peter Freyther | c279e39 | 2013-04-16 09:53:13 +0200 | [diff] [blame] | 200 | struct nat_sccp_connection *con; |
Holger Hans Peter Freyther | 85804a8 | 2010-09-15 19:01:31 +0800 | [diff] [blame] | 201 | vty_out(vty, "Listing all open SCCP connections%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 4bd2294 | 2010-04-27 13:11:18 +0800 | [diff] [blame] | 202 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 203 | llist_for_each_entry(con, &_nat->sccp_connections, list_entry) { |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 204 | vty_out(vty, "For BSC Nr: %d BSC ref: 0x%x; MUX ref: 0x%x; Network has ref: %d ref: 0x%x MSC/BSC mux: 0x%x/0x%x type: %s%s", |
Holger Hans Peter Freyther | 47dd494 | 2010-04-06 15:11:34 +0200 | [diff] [blame] | 205 | con->bsc->cfg ? con->bsc->cfg->nr : -1, |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 206 | sccp_src_ref_to_int(&con->real_ref), |
Holger Hans Peter Freyther | 32d3436 | 2010-04-05 10:10:33 +0200 | [diff] [blame] | 207 | sccp_src_ref_to_int(&con->patched_ref), |
Holger Hans Peter Freyther | 4bd2294 | 2010-04-27 13:11:18 +0800 | [diff] [blame] | 208 | con->has_remote_ref, |
| 209 | sccp_src_ref_to_int(&con->remote_ref), |
Holger Hans Peter Freyther | f4b3439 | 2010-08-28 16:08:39 +0800 | [diff] [blame] | 210 | con->msc_endp, con->bsc_endp, |
Holger Hans Peter Freyther | c652913 | 2015-04-05 21:03:49 +0200 | [diff] [blame] | 211 | bsc_con_type_to_string(con->filter_state.con_type), |
Holger Hans Peter Freyther | 32d3436 | 2010-04-05 10:10:33 +0200 | [diff] [blame] | 212 | VTY_NEWLINE); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | return CMD_SUCCESS; |
| 216 | } |
| 217 | |
Max | e5686f2 | 2016-04-06 17:25:44 +0200 | [diff] [blame] | 218 | DEFUN(show_nat_bsc, show_nat_bsc_cmd, "show nat num-bscs-configured", |
| 219 | SHOW_STR "Display NAT configuration details\n" |
| 220 | "BSCs-related\n") |
| 221 | { |
| 222 | vty_out(vty, "%d BSCs configured%s", _nat->num_bsc, VTY_NEWLINE); |
| 223 | return CMD_SUCCESS; |
| 224 | } |
| 225 | |
Holger Hans Peter Freyther | 01a0b1b | 2010-04-19 16:06:43 +0800 | [diff] [blame] | 226 | DEFUN(show_bsc, show_bsc_cmd, "show bsc connections", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 227 | SHOW_STR BSC_STR |
| 228 | "All active connections\n") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 229 | { |
| 230 | struct bsc_connection *con; |
Holger Hans Peter Freyther | 870663a | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 231 | struct sockaddr_in sock; |
| 232 | socklen_t len = sizeof(sock); |
| 233 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 234 | llist_for_each_entry(con, &_nat->bsc_connections, list_entry) { |
Holger Hans Peter Freyther | 870663a | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 235 | getpeername(con->write_queue.bfd.fd, (struct sockaddr *) &sock, &len); |
Holger Hans Peter Freyther | 462b7d7 | 2012-10-24 21:53:40 +0200 | [diff] [blame] | 236 | vty_out(vty, "BSC nr: %d auth: %d fd: %d peername: %s pending-stats: %u%s", |
Holger Hans Peter Freyther | 47dd494 | 2010-04-06 15:11:34 +0200 | [diff] [blame] | 237 | con->cfg ? con->cfg->nr : -1, |
Holger Hans Peter Freyther | 870663a | 2010-04-08 10:35:20 +0200 | [diff] [blame] | 238 | con->authenticated, con->write_queue.bfd.fd, |
Holger Hans Peter Freyther | 462b7d7 | 2012-10-24 21:53:40 +0200 | [diff] [blame] | 239 | inet_ntoa(sock.sin_addr), con->pending_dlcx_count, |
| 240 | VTY_NEWLINE); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | return CMD_SUCCESS; |
| 244 | } |
| 245 | |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 246 | DEFUN(show_bsc_mgcp, show_bsc_mgcp_cmd, "show bsc mgcp NR", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 247 | SHOW_STR BSC_STR MGCP_STR "Identifier of the BSC\n") |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 248 | { |
| 249 | struct bsc_connection *con; |
| 250 | int nr = atoi(argv[0]); |
Holger Hans Peter Freyther | a9e9331 | 2011-02-26 11:38:00 +0100 | [diff] [blame] | 251 | int i, j, endp; |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 252 | |
| 253 | llist_for_each_entry(con, &_nat->bsc_connections, list_entry) { |
Holger Hans Peter Freyther | 9ec030d | 2011-02-27 11:04:27 +0100 | [diff] [blame] | 254 | int max; |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 255 | if (!con->cfg) |
| 256 | continue; |
| 257 | if (con->cfg->nr != nr) |
| 258 | continue; |
| 259 | |
Holger Hans Peter Freyther | ed500e3 | 2011-02-25 17:09:07 +0100 | [diff] [blame] | 260 | /* this bsc has no audio endpoints yet */ |
| 261 | if (!con->_endpoint_status) |
| 262 | continue; |
| 263 | |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 264 | vty_out(vty, "MGCP Status for %d%s", con->cfg->nr, VTY_NEWLINE); |
Holger Hans Peter Freyther | 9ec030d | 2011-02-27 11:04:27 +0100 | [diff] [blame] | 265 | max = bsc_mgcp_nr_multiplexes(con->max_endpoints); |
| 266 | for (i = 0; i < max; ++i) { |
Jacob Erlbeck | 9ed6fd2 | 2015-04-07 17:49:47 +0200 | [diff] [blame] | 267 | for (j = 1; j < 32; ++j) { |
Holger Hans Peter Freyther | a9e9331 | 2011-02-26 11:38:00 +0100 | [diff] [blame] | 268 | endp = mgcp_timeslot_to_endpoint(i, j); |
| 269 | vty_out(vty, " Endpoint 0x%x %s%s", endp, |
| 270 | con->_endpoint_status[endp] == 0 |
| 271 | ? "free" : "allocated", |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 272 | VTY_NEWLINE); |
Holger Hans Peter Freyther | a9e9331 | 2011-02-26 11:38:00 +0100 | [diff] [blame] | 273 | } |
| 274 | } |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 275 | break; |
| 276 | } |
| 277 | |
| 278 | return CMD_SUCCESS; |
| 279 | } |
| 280 | |
Holger Hans Peter Freyther | ab7539c | 2010-04-22 13:36:46 +0800 | [diff] [blame] | 281 | DEFUN(show_bsc_cfg, show_bsc_cfg_cmd, "show bsc config", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 282 | SHOW_STR BSC_STR "Configuration of BSCs\n") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 283 | { |
| 284 | struct bsc_config *conf; |
| 285 | llist_for_each_entry(conf, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 286 | vty_out(vty, "BSC token: '%s' nr: %u%s", |
| 287 | conf->token, conf->nr, VTY_NEWLINE); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 288 | if (conf->acc_lst_name) |
| 289 | vty_out(vty, " access-list: %s%s", |
| 290 | conf->acc_lst_name, VTY_NEWLINE); |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 291 | vty_out(vty, " paging forbidden: %d%s", |
| 292 | conf->forbid_paging, VTY_NEWLINE); |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 293 | if (conf->description) |
| 294 | vty_out(vty, " description: %s%s", conf->description, VTY_NEWLINE); |
| 295 | else |
| 296 | vty_out(vty, " No description.%s", VTY_NEWLINE); |
| 297 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | return CMD_SUCCESS; |
| 301 | } |
| 302 | |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 303 | static void dump_stat_total(struct vty *vty, struct bsc_nat *nat) |
| 304 | { |
| 305 | vty_out(vty, "NAT statistics%s", VTY_NEWLINE); |
| 306 | vty_out(vty, " SCCP Connections %lu total, %lu calls%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 307 | osmo_counter_get(nat->stats.sccp.conn), |
| 308 | osmo_counter_get(nat->stats.sccp.calls), VTY_NEWLINE); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 309 | vty_out(vty, " MSC Connections %lu%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 310 | osmo_counter_get(nat->stats.msc.reconn), VTY_NEWLINE); |
Holger Hans Peter Freyther | cbfd098 | 2010-08-04 02:34:10 +0800 | [diff] [blame] | 311 | vty_out(vty, " MSC Connected: %d%s", |
Holger Hans Peter Freyther | 5741256 | 2013-08-27 08:47:23 +0200 | [diff] [blame] | 312 | bsc_nat_msc_is_connected(nat), VTY_NEWLINE); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 313 | vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s", |
Pablo Neira Ayuso | dfb342c | 2011-05-06 12:13:10 +0200 | [diff] [blame] | 314 | osmo_counter_get(nat->stats.bsc.reconn), |
| 315 | osmo_counter_get(nat->stats.bsc.auth_fail), VTY_NEWLINE); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | static void dump_stat_bsc(struct vty *vty, struct bsc_config *conf) |
| 319 | { |
Holger Hans Peter Freyther | f21e453 | 2010-07-22 20:37:35 +0800 | [diff] [blame] | 320 | int connected = 0; |
| 321 | struct bsc_connection *con; |
| 322 | |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 323 | vty_out(vty, " BSC nr: %d%s", |
| 324 | conf->nr, VTY_NEWLINE); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 325 | vty_out_rate_ctr_group(vty, " ", conf->stats.ctrg); |
Holger Hans Peter Freyther | f21e453 | 2010-07-22 20:37:35 +0800 | [diff] [blame] | 326 | |
| 327 | llist_for_each_entry(con, &conf->nat->bsc_connections, list_entry) { |
| 328 | if (con->cfg != conf) |
| 329 | continue; |
| 330 | connected = 1; |
| 331 | break; |
| 332 | } |
| 333 | |
Holger Hans Peter Freyther | 03a0ad0 | 2010-08-04 02:29:03 +0800 | [diff] [blame] | 334 | vty_out(vty, " Connected: %d%s", connected, VTY_NEWLINE); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 335 | } |
| 336 | |
Holger Hans Peter Freyther | bcfebb2 | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 337 | DEFUN(show_stats, |
| 338 | show_stats_cmd, |
Holger Hans Peter Freyther | 314191d | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 339 | "show statistics [NR]", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 340 | SHOW_STR "Display network statistics\n" |
| 341 | "Number of the BSC\n") |
Holger Hans Peter Freyther | bcfebb2 | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 342 | { |
| 343 | struct bsc_config *conf; |
| 344 | |
Holger Hans Peter Freyther | 314191d | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 345 | int nr = -1; |
| 346 | |
| 347 | if (argc == 1) |
| 348 | nr = atoi(argv[0]); |
| 349 | |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 350 | dump_stat_total(vty, _nat); |
Holger Hans Peter Freyther | bcfebb2 | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 351 | llist_for_each_entry(conf, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 314191d | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 352 | if (argc == 1 && nr != conf->nr) |
| 353 | continue; |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 354 | dump_stat_bsc(vty, conf); |
| 355 | } |
Holger Hans Peter Freyther | 314191d | 2010-05-02 18:59:24 +0800 | [diff] [blame] | 356 | |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 357 | return CMD_SUCCESS; |
| 358 | } |
| 359 | |
| 360 | DEFUN(show_stats_lac, |
| 361 | show_stats_lac_cmd, |
| 362 | "show statistics-by-lac <0-65535>", |
| 363 | SHOW_STR "Display network statistics by lac\n" |
| 364 | "The lac of the BSC\n") |
| 365 | { |
| 366 | int lac; |
| 367 | struct bsc_config *conf; |
| 368 | |
| 369 | lac = atoi(argv[0]); |
| 370 | |
| 371 | dump_stat_total(vty, _nat); |
| 372 | llist_for_each_entry(conf, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 373 | if (!bsc_config_handles_lac(conf, lac)) |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 374 | continue; |
| 375 | dump_stat_bsc(vty, conf); |
Holger Hans Peter Freyther | bcfebb2 | 2010-04-12 12:33:27 +0200 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | return CMD_SUCCESS; |
| 379 | } |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 380 | |
Holger Hans Peter Freyther | aad82ce | 2010-05-11 19:07:39 +0800 | [diff] [blame] | 381 | DEFUN(show_msc, |
| 382 | show_msc_cmd, |
| 383 | "show msc connection", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 384 | SHOW_STR "MSC related information\n" |
| 385 | "Status of the A-link connection\n") |
Holger Hans Peter Freyther | aad82ce | 2010-05-11 19:07:39 +0800 | [diff] [blame] | 386 | { |
| 387 | if (!_nat->msc_con) { |
Holger Hans Peter Freyther | 9962151 | 2013-08-13 11:36:33 +0200 | [diff] [blame] | 388 | vty_out(vty, "The MSC is not yet configured.%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | aad82ce | 2010-05-11 19:07:39 +0800 | [diff] [blame] | 389 | return CMD_WARNING; |
| 390 | } |
| 391 | |
Holger Hans Peter Freyther | 9962151 | 2013-08-13 11:36:33 +0200 | [diff] [blame] | 392 | vty_out(vty, "MSC is connected: %d%s", |
Holger Hans Peter Freyther | 5741256 | 2013-08-27 08:47:23 +0200 | [diff] [blame] | 393 | bsc_nat_msc_is_connected(_nat), VTY_NEWLINE); |
Holger Hans Peter Freyther | aad82ce | 2010-05-11 19:07:39 +0800 | [diff] [blame] | 394 | return CMD_SUCCESS; |
| 395 | } |
| 396 | |
Holger Hans Peter Freyther | 2f9dcf0 | 2010-04-27 13:21:39 +0800 | [diff] [blame] | 397 | DEFUN(close_bsc, |
| 398 | close_bsc_cmd, |
| 399 | "close bsc connection BSC_NR", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 400 | "Close\n" "A-link\n" "Connection\n" "Identifier of the BSC\n") |
Holger Hans Peter Freyther | 2f9dcf0 | 2010-04-27 13:21:39 +0800 | [diff] [blame] | 401 | { |
| 402 | struct bsc_connection *bsc; |
| 403 | int bsc_nr = atoi(argv[0]); |
| 404 | |
| 405 | llist_for_each_entry(bsc, &_nat->bsc_connections, list_entry) { |
| 406 | if (!bsc->cfg || bsc->cfg->nr != bsc_nr) |
| 407 | continue; |
| 408 | bsc_close_connection(bsc); |
| 409 | break; |
| 410 | } |
| 411 | |
| 412 | return CMD_SUCCESS; |
| 413 | } |
| 414 | |
Holger Hans Peter Freyther | 9962151 | 2013-08-13 11:36:33 +0200 | [diff] [blame] | 415 | DEFUN(cfg_nat, cfg_nat_cmd, "nat", "Configure the NAT") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 416 | { |
| 417 | vty->index = _nat; |
| 418 | vty->node = NAT_NODE; |
| 419 | |
| 420 | return CMD_SUCCESS; |
| 421 | } |
| 422 | |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 423 | DEFUN(cfg_nat_msc_ip, |
| 424 | cfg_nat_msc_ip_cmd, |
Holger Hans Peter Freyther | d8b8206 | 2010-05-14 02:36:42 +0800 | [diff] [blame] | 425 | "msc ip A.B.C.D", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 426 | "MSC related configuration\n" |
| 427 | "Configure the IP address\n" IP_STR) |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 428 | { |
| 429 | bsc_nat_set_msc_ip(_nat, argv[0]); |
| 430 | return CMD_SUCCESS; |
| 431 | } |
| 432 | |
Holger Hans Peter Freyther | 8139553 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 433 | DEFUN(cfg_nat_msc_port, |
| 434 | cfg_nat_msc_port_cmd, |
| 435 | "msc port <1-65500>", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 436 | "MSC related configuration\n" |
| 437 | "Configure the port\n" |
| 438 | "Port number\n") |
Holger Hans Peter Freyther | 8139553 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 439 | { |
Holger Hans Peter Freyther | e188010 | 2011-04-23 23:31:31 +0200 | [diff] [blame] | 440 | _nat->main_dest->port = atoi(argv[0]); |
Holger Hans Peter Freyther | 8139553 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 441 | return CMD_SUCCESS; |
| 442 | } |
| 443 | |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 444 | DEFUN(cfg_nat_auth_time, |
| 445 | cfg_nat_auth_time_cmd, |
| 446 | "timeout auth <1-256>", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 447 | "Timeout configuration\n" |
| 448 | "Authentication timeout\n" |
| 449 | "Timeout in seconds\n") |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 450 | { |
| 451 | _nat->auth_timeout = atoi(argv[0]); |
| 452 | return CMD_SUCCESS; |
| 453 | } |
| 454 | |
| 455 | DEFUN(cfg_nat_ping_time, |
| 456 | cfg_nat_ping_time_cmd, |
| 457 | "timeout ping NR", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 458 | "Timeout configuration\n" |
| 459 | "Time between two pings\n" |
| 460 | "Timeout in seconds\n") |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 461 | { |
| 462 | _nat->ping_timeout = atoi(argv[0]); |
| 463 | return CMD_SUCCESS; |
| 464 | } |
| 465 | |
| 466 | DEFUN(cfg_nat_pong_time, |
| 467 | cfg_nat_pong_time_cmd, |
| 468 | "timeout pong NR", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 469 | "Timeout configuration\n" |
| 470 | "Waiting for pong timeout\n" |
| 471 | "Timeout in seconds\n") |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 472 | { |
| 473 | _nat->pong_timeout = atoi(argv[0]); |
| 474 | return CMD_SUCCESS; |
| 475 | } |
| 476 | |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 477 | DEFUN(cfg_nat_token, cfg_nat_token_cmd, |
| 478 | "token TOKEN", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 479 | "Authentication token configuration\n" |
| 480 | "Token of the BSC, currently transferred in cleartext\n") |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 481 | { |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 482 | bsc_replace_string(_nat, &_nat->token, argv[0]); |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 483 | return CMD_SUCCESS; |
| 484 | } |
| 485 | |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 486 | DEFUN(cfg_nat_bsc_ip_dscp, cfg_nat_bsc_ip_dscp_cmd, |
| 487 | "ip-dscp <0-255>", |
| 488 | "Set the IP DSCP for the BSCs to use\n" "Set the IP_TOS attribute") |
Holger Hans Peter Freyther | 078321a | 2010-05-31 10:36:35 +0800 | [diff] [blame] | 489 | { |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 490 | _nat->bsc_ip_dscp = atoi(argv[0]); |
Holger Hans Peter Freyther | 078321a | 2010-05-31 10:36:35 +0800 | [diff] [blame] | 491 | return CMD_SUCCESS; |
| 492 | } |
| 493 | |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 494 | ALIAS_DEPRECATED(cfg_nat_bsc_ip_dscp, cfg_nat_bsc_ip_tos_cmd, |
| 495 | "ip-tos <0-255>", |
| 496 | "Use ip-dscp in the future.\n" "Set the DSCP\n") |
| 497 | |
| 498 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 499 | DEFUN(cfg_nat_acc_lst_name, |
| 500 | cfg_nat_acc_lst_name_cmd, |
| 501 | "access-list-name NAME", |
| 502 | "Set the name of the access list to use.\n" |
| 503 | "The name of the to be used access list.") |
| 504 | { |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 505 | bsc_replace_string(_nat, &_nat->acc_lst_name, argv[0]); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 506 | return CMD_SUCCESS; |
| 507 | } |
| 508 | |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 509 | DEFUN(cfg_nat_include, |
| 510 | cfg_nat_include_cmd, |
| 511 | "bscs-config-file NAME", |
| 512 | "Set the filename of the BSC configuration to include.\n" |
| 513 | "The filename to be included.") |
| 514 | { |
| 515 | char *path; |
| 516 | int rc; |
Max | 4936448 | 2016-04-13 11:36:39 +0200 | [diff] [blame] | 517 | struct bsc_config *cf1, *cf2; |
| 518 | struct bsc_connection *con1, *con2; |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 519 | |
| 520 | if ('/' == argv[0][0]) |
| 521 | bsc_replace_string(_nat, &_nat->resolved_path, argv[0]); |
| 522 | else { |
| 523 | path = talloc_asprintf(_nat, "%s/%s", _nat->include_base, |
| 524 | argv[0]); |
| 525 | bsc_replace_string(_nat, &_nat->resolved_path, path); |
| 526 | talloc_free(path); |
| 527 | } |
| 528 | |
Max | 4936448 | 2016-04-13 11:36:39 +0200 | [diff] [blame] | 529 | llist_for_each_entry_safe(cf1, cf2, &_nat->bsc_configs, entry) { |
| 530 | cf1->remove = true; |
| 531 | cf1->token_updated = false; |
| 532 | } |
| 533 | |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 534 | rc = vty_read_config_file(_nat->resolved_path, NULL); |
| 535 | if (rc < 0) { |
| 536 | vty_out(vty, "Failed to parse the config file %s: %s%s", |
| 537 | _nat->resolved_path, strerror(-rc), VTY_NEWLINE); |
| 538 | return CMD_WARNING; |
| 539 | } |
Max | 4936448 | 2016-04-13 11:36:39 +0200 | [diff] [blame] | 540 | |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 541 | bsc_replace_string(_nat, &_nat->include_file, argv[0]); |
Max | 4936448 | 2016-04-13 11:36:39 +0200 | [diff] [blame] | 542 | |
| 543 | llist_for_each_entry_safe(con1, con2, &_nat->bsc_connections, |
| 544 | list_entry) { |
| 545 | if (con1->cfg) |
| 546 | if (con1->cfg->token_updated || con1->cfg->remove) |
| 547 | bsc_close_connection(con1); |
| 548 | } |
| 549 | |
| 550 | llist_for_each_entry_safe(cf1, cf2, &_nat->bsc_configs, entry) { |
| 551 | if (cf1->remove) |
| 552 | bsc_config_free(cf1); |
| 553 | } |
| 554 | |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 555 | return CMD_SUCCESS; |
| 556 | } |
| 557 | |
Holger Hans Peter Freyther | 6a7babd | 2011-03-29 17:14:34 +0200 | [diff] [blame] | 558 | DEFUN(cfg_nat_no_acc_lst_name, |
| 559 | cfg_nat_no_acc_lst_name_cmd, |
| 560 | "no access-list-name", |
| 561 | NO_STR "Remove the access list from the NAT.\n") |
| 562 | { |
| 563 | if (_nat->acc_lst_name) { |
| 564 | talloc_free(_nat->acc_lst_name); |
| 565 | _nat->acc_lst_name = NULL; |
| 566 | } |
| 567 | |
Holger Hans Peter Freyther | 9e7e55f | 2011-04-01 16:22:51 +0200 | [diff] [blame] | 568 | return CMD_SUCCESS; |
Holger Hans Peter Freyther | 6a7babd | 2011-03-29 17:14:34 +0200 | [diff] [blame] | 569 | } |
| 570 | |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 571 | DEFUN(cfg_nat_imsi_black_list_fn, |
| 572 | cfg_nat_imsi_black_list_fn_cmd, |
| 573 | "imsi-black-list-file-name NAME", |
| 574 | "IMSI black listing\n" "Filename IMSI and reject-cause\n") |
| 575 | { |
| 576 | |
| 577 | bsc_replace_string(_nat, &_nat->imsi_black_list_fn, argv[0]); |
| 578 | if (_nat->imsi_black_list_fn) { |
| 579 | int rc; |
| 580 | struct osmo_config_list *rewr = NULL; |
| 581 | rewr = osmo_config_list_parse(_nat, _nat->imsi_black_list_fn); |
Holger Hans Peter Freyther | c36a6d5 | 2015-04-05 16:55:28 +0200 | [diff] [blame] | 582 | rc = bsc_filter_barr_adapt(_nat, &_nat->imsi_black_list, rewr); |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 583 | if (rc != 0) { |
| 584 | vty_out(vty, "%%There was an error parsing the list." |
| 585 | " Please see the error log.%s", VTY_NEWLINE); |
| 586 | return CMD_WARNING; |
| 587 | } |
| 588 | |
| 589 | return CMD_SUCCESS; |
| 590 | } |
| 591 | |
Holger Hans Peter Freyther | c36a6d5 | 2015-04-05 16:55:28 +0200 | [diff] [blame] | 592 | bsc_filter_barr_adapt(_nat, &_nat->imsi_black_list, NULL); |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 593 | return CMD_SUCCESS; |
| 594 | } |
| 595 | |
| 596 | DEFUN(cfg_nat_no_imsi_black_list_fn, |
| 597 | cfg_nat_no_imsi_black_list_fn_cmd, |
| 598 | "no imsi-black-list-file-name", |
| 599 | NO_STR "Remove the imsi-black-list\n") |
| 600 | { |
| 601 | talloc_free(_nat->imsi_black_list_fn); |
| 602 | _nat->imsi_black_list_fn = NULL; |
Holger Hans Peter Freyther | c36a6d5 | 2015-04-05 16:55:28 +0200 | [diff] [blame] | 603 | bsc_filter_barr_adapt(_nat, &_nat->imsi_black_list, NULL); |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 604 | return CMD_SUCCESS; |
| 605 | } |
| 606 | |
Holger Hans Peter Freyther | e36b487 | 2011-05-31 00:35:46 +0200 | [diff] [blame] | 607 | static int replace_rules(struct bsc_nat *nat, char **name, |
| 608 | struct llist_head *head, const char *file) |
| 609 | { |
| 610 | struct osmo_config_list *rewr = NULL; |
| 611 | |
| 612 | bsc_replace_string(nat, name, file); |
| 613 | if (*name) { |
| 614 | rewr = osmo_config_list_parse(nat, *name); |
| 615 | bsc_nat_num_rewr_entry_adapt(nat, head, rewr); |
| 616 | talloc_free(rewr); |
| 617 | return CMD_SUCCESS; |
| 618 | } else { |
| 619 | bsc_nat_num_rewr_entry_adapt(nat, head, NULL); |
| 620 | return CMD_SUCCESS; |
| 621 | } |
| 622 | } |
| 623 | |
Holger Hans Peter Freyther | 7642439 | 2010-10-21 10:59:54 +0200 | [diff] [blame] | 624 | DEFUN(cfg_nat_number_rewrite, |
| 625 | cfg_nat_number_rewrite_cmd, |
| 626 | "number-rewrite FILENAME", |
| 627 | "Set the file with rewriting rules.\n" "Filename") |
| 628 | { |
Holger Hans Peter Freyther | e36b487 | 2011-05-31 00:35:46 +0200 | [diff] [blame] | 629 | return replace_rules(_nat, &_nat->num_rewr_name, |
| 630 | &_nat->num_rewr, argv[0]); |
| 631 | } |
Holger Hans Peter Freyther | ad75eab | 2011-05-27 12:38:58 +0200 | [diff] [blame] | 632 | |
Holger Hans Peter Freyther | b718ad3 | 2013-06-25 09:08:02 +0200 | [diff] [blame] | 633 | DEFUN(cfg_nat_no_number_rewrite, |
| 634 | cfg_nat_no_number_rewrite_cmd, |
| 635 | "no number-rewrite", |
| 636 | NO_STR "Set the file with rewriting rules.\n") |
| 637 | { |
| 638 | talloc_free(_nat->num_rewr_name); |
| 639 | _nat->num_rewr_name = NULL; |
| 640 | |
| 641 | bsc_nat_num_rewr_entry_adapt(NULL, &_nat->num_rewr, NULL); |
| 642 | return CMD_SUCCESS; |
| 643 | } |
| 644 | |
Holger Hans Peter Freyther | 67e423c | 2013-06-25 15:38:31 +0200 | [diff] [blame] | 645 | DEFUN(cfg_nat_number_rewrite_post, |
| 646 | cfg_nat_number_rewrite_post_cmd, |
| 647 | "number-rewrite-post FILENAME", |
| 648 | "Set the file with post-routing rewriting rules.\n" "Filename") |
| 649 | { |
| 650 | return replace_rules(_nat, &_nat->num_rewr_post_name, |
| 651 | &_nat->num_rewr_post, argv[0]); |
| 652 | } |
| 653 | |
| 654 | DEFUN(cfg_nat_no_number_rewrite_post, |
| 655 | cfg_nat_no_number_rewrite_post_cmd, |
| 656 | "no number-rewrite-post", |
| 657 | NO_STR "Set the file with post-routing rewriting rules.\n") |
| 658 | { |
| 659 | talloc_free(_nat->num_rewr_post_name); |
| 660 | _nat->num_rewr_post_name = NULL; |
| 661 | |
| 662 | bsc_nat_num_rewr_entry_adapt(NULL, &_nat->num_rewr_post, NULL); |
| 663 | return CMD_SUCCESS; |
| 664 | } |
| 665 | |
Holger Hans Peter Freyther | e36b487 | 2011-05-31 00:35:46 +0200 | [diff] [blame] | 666 | DEFUN(cfg_nat_smsc_addr, |
| 667 | cfg_nat_smsc_addr_cmd, |
| 668 | "rewrite-smsc addr FILENAME", |
| 669 | SMSC_REWRITE |
| 670 | "The SMSC Address to match and replace in RP-DATA\n" |
| 671 | "File with rules for the SMSC Address replacing\n") |
| 672 | { |
| 673 | return replace_rules(_nat, &_nat->smsc_rewr_name, |
| 674 | &_nat->smsc_rewr, argv[0]); |
| 675 | } |
| 676 | |
| 677 | DEFUN(cfg_nat_smsc_tpdest, |
| 678 | cfg_nat_smsc_tpdest_cmd, |
| 679 | "rewrite-smsc tp-dest-match FILENAME", |
| 680 | SMSC_REWRITE |
| 681 | "Match TP-Destination of a SMS.\n" |
| 682 | "File with rules for matching MSISDN and TP-DEST\n") |
| 683 | { |
| 684 | return replace_rules(_nat, &_nat->tpdest_match_name, |
| 685 | &_nat->tpdest_match, argv[0]); |
Holger Hans Peter Freyther | 7642439 | 2010-10-21 10:59:54 +0200 | [diff] [blame] | 686 | } |
| 687 | |
Holger Hans Peter Freyther | 68368dd | 2012-01-10 22:39:07 +0100 | [diff] [blame] | 688 | DEFUN(cfg_nat_sms_clear_tpsrr, |
| 689 | cfg_nat_sms_clear_tpsrr_cmd, |
| 690 | "sms-clear-tp-srr FILENAME", |
| 691 | "SMS TPDU Sender Report Request clearing\n" |
| 692 | "Files with rules for matching MSISDN\n") |
| 693 | { |
| 694 | return replace_rules(_nat, &_nat->sms_clear_tp_srr_name, |
| 695 | &_nat->sms_clear_tp_srr, argv[0]); |
| 696 | } |
| 697 | |
| 698 | DEFUN(cfg_nat_no_sms_clear_tpsrr, |
| 699 | cfg_nat_no_sms_clear_tpsrr_cmd, |
Holger Hans Peter Freyther | 2718845 | 2012-01-18 20:34:08 +0100 | [diff] [blame] | 700 | "no sms-clear-tp-srr", |
Holger Hans Peter Freyther | 68368dd | 2012-01-10 22:39:07 +0100 | [diff] [blame] | 701 | NO_STR |
| 702 | "SMS TPDU Sender Report Request clearing\n") |
| 703 | { |
| 704 | talloc_free(_nat->sms_clear_tp_srr_name); |
| 705 | _nat->sms_clear_tp_srr_name = NULL; |
| 706 | |
| 707 | bsc_nat_num_rewr_entry_adapt(NULL, &_nat->sms_clear_tp_srr, NULL); |
| 708 | return CMD_SUCCESS; |
| 709 | } |
| 710 | |
Holger Hans Peter Freyther | 7d60bdb | 2012-01-18 20:40:01 +0100 | [diff] [blame] | 711 | DEFUN(cfg_nat_sms_number_rewrite, |
| 712 | cfg_nat_sms_number_rewrite_cmd, |
| 713 | "sms-number-rewrite FILENAME", |
| 714 | "SMS TP-DA Number rewriting\n" |
| 715 | "Files with rules for matching MSISDN\n") |
| 716 | { |
| 717 | return replace_rules(_nat, &_nat->sms_num_rewr_name, |
| 718 | &_nat->sms_num_rewr, argv[0]); |
| 719 | } |
| 720 | |
| 721 | DEFUN(cfg_nat_no_sms_number_rewrite, |
| 722 | cfg_nat_no_sms_number_rewrite_cmd, |
| 723 | "no sms-number-rewrite", |
| 724 | NO_STR "Disable SMS TP-DA rewriting\n") |
| 725 | { |
| 726 | talloc_free(_nat->sms_num_rewr_name); |
| 727 | _nat->sms_num_rewr_name = NULL; |
| 728 | |
| 729 | bsc_nat_num_rewr_entry_adapt(NULL, &_nat->sms_num_rewr, NULL); |
| 730 | return CMD_SUCCESS; |
| 731 | } |
| 732 | |
Holger Hans Peter Freyther | ddf191e | 2013-06-25 11:44:01 +0200 | [diff] [blame] | 733 | DEFUN(cfg_nat_prefix_trie, |
| 734 | cfg_nat_prefix_trie_cmd, |
| 735 | "prefix-tree FILENAME", |
| 736 | "Prefix tree for number rewriting\n" "File to load\n") |
| 737 | { |
| 738 | /* give up the old data */ |
| 739 | talloc_free(_nat->num_rewr_trie); |
| 740 | _nat->num_rewr_trie = NULL; |
| 741 | |
| 742 | /* replace the file name */ |
| 743 | bsc_replace_string(_nat, &_nat->num_rewr_trie_name, argv[0]); |
| 744 | if (!_nat->num_rewr_trie_name) { |
| 745 | vty_out(vty, "%% prefix-tree no filename is present.%s", VTY_NEWLINE); |
| 746 | return CMD_WARNING; |
| 747 | } |
| 748 | |
| 749 | _nat->num_rewr_trie = nat_rewrite_parse(_nat, _nat->num_rewr_trie_name); |
| 750 | if (!_nat->num_rewr_trie) { |
| 751 | vty_out(vty, "%% prefix-tree parsing has failed.%s", VTY_NEWLINE); |
| 752 | return CMD_WARNING; |
| 753 | } |
| 754 | |
| 755 | vty_out(vty, "%% prefix-tree loaded %zu rules.%s", |
| 756 | _nat->num_rewr_trie->prefixes, VTY_NEWLINE); |
| 757 | return CMD_SUCCESS; |
| 758 | } |
| 759 | |
| 760 | DEFUN(cfg_nat_no_prefix_trie, cfg_nat_no_prefix_trie_cmd, |
| 761 | "no prefix-tree", |
| 762 | NO_STR "Prefix tree for number rewriting\n") |
| 763 | { |
| 764 | talloc_free(_nat->num_rewr_trie); |
| 765 | _nat->num_rewr_trie = NULL; |
| 766 | talloc_free(_nat->num_rewr_trie_name); |
| 767 | _nat->num_rewr_trie_name = NULL; |
| 768 | |
| 769 | return CMD_SUCCESS; |
| 770 | } |
| 771 | |
| 772 | DEFUN(show_prefix_tree, show_prefix_tree_cmd, |
| 773 | "show prefix-tree", |
| 774 | SHOW_STR "Prefix tree for number rewriting\n") |
| 775 | { |
| 776 | if (!_nat->num_rewr_trie) { |
| 777 | vty_out(vty, "%% there is now prefix tree loaded.%s", |
| 778 | VTY_NEWLINE); |
| 779 | return CMD_WARNING; |
| 780 | } |
| 781 | |
| 782 | nat_rewrite_dump_vty(vty, _nat->num_rewr_trie); |
| 783 | return CMD_SUCCESS; |
| 784 | } |
| 785 | |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 786 | DEFUN(cfg_nat_ussd_lst_name, |
| 787 | cfg_nat_ussd_lst_name_cmd, |
| 788 | "ussd-list-name NAME", |
| 789 | "Set the name of the access list to check for IMSIs for USSD message\n" |
| 790 | "The name of the access list for HLR USSD handling") |
| 791 | { |
Holger Hans Peter Freyther | 64b1292 | 2010-10-12 21:31:02 +0200 | [diff] [blame] | 792 | bsc_replace_string(_nat, &_nat->ussd_lst_name, argv[0]); |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 793 | return CMD_SUCCESS; |
| 794 | } |
| 795 | |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame] | 796 | DEFUN(cfg_nat_ussd_query, |
| 797 | cfg_nat_ussd_query_cmd, |
Holger Hans Peter Freyther | a18b116 | 2011-04-01 17:32:21 +0200 | [diff] [blame] | 798 | "ussd-query REGEXP", |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame] | 799 | "Set the USSD query to match with the ussd-list-name\n" |
| 800 | "The query to match") |
| 801 | { |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 802 | if (gsm_parse_reg(_nat, &_nat->ussd_query_re, &_nat->ussd_query, argc, argv) != 0) |
Holger Hans Peter Freyther | 4c9557e | 2011-04-04 19:19:26 +0200 | [diff] [blame] | 803 | return CMD_WARNING; |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame] | 804 | return CMD_SUCCESS; |
| 805 | } |
| 806 | |
Holger Hans Peter Freyther | e393f27 | 2010-10-12 18:25:52 +0200 | [diff] [blame] | 807 | DEFUN(cfg_nat_ussd_token, |
| 808 | cfg_nat_ussd_token_cmd, |
| 809 | "ussd-token TOKEN", |
| 810 | "Set the token used to identify the USSD module\n" "Secret key\n") |
| 811 | { |
Holger Hans Peter Freyther | 64b1292 | 2010-10-12 21:31:02 +0200 | [diff] [blame] | 812 | bsc_replace_string(_nat, &_nat->ussd_token, argv[0]); |
Holger Hans Peter Freyther | e393f27 | 2010-10-12 18:25:52 +0200 | [diff] [blame] | 813 | return CMD_SUCCESS; |
| 814 | } |
| 815 | |
| 816 | DEFUN(cfg_nat_ussd_local, |
| 817 | cfg_nat_ussd_local_cmd, |
| 818 | "ussd-local-ip A.B.C.D", |
| 819 | "Set the IP to listen for the USSD Provider\n" "IP Address\n") |
| 820 | { |
Holger Hans Peter Freyther | 64b1292 | 2010-10-12 21:31:02 +0200 | [diff] [blame] | 821 | bsc_replace_string(_nat, &_nat->ussd_local, argv[0]); |
Holger Hans Peter Freyther | e393f27 | 2010-10-12 18:25:52 +0200 | [diff] [blame] | 822 | return CMD_SUCCESS; |
| 823 | } |
| 824 | |
Jacob Erlbeck | 4c9dff5 | 2013-09-02 13:17:17 +0200 | [diff] [blame] | 825 | DEFUN(cfg_nat_use_ipa_for_mgcp, |
| 826 | cfg_nat_use_ipa_for_mgcp_cmd, |
| 827 | "use-msc-ipa-for-mgcp", |
Holger Hans Peter Freyther | c327187 | 2012-11-05 14:54:56 +0100 | [diff] [blame] | 828 | "This needs to be set at start. Handle MGCP messages through " |
| 829 | "the IPA protocol and not through the UDP socket.\n") |
| 830 | { |
| 831 | if (_nat->mgcp_cfg->data) |
| 832 | vty_out(vty, |
| 833 | "%%the setting will not be applied right now.%s", |
| 834 | VTY_NEWLINE); |
| 835 | _nat->mgcp_ipa = 1; |
| 836 | return CMD_SUCCESS; |
| 837 | } |
| 838 | |
Holger Hans Peter Freyther | 7f100c9 | 2015-04-23 20:25:17 -0400 | [diff] [blame] | 839 | DEFUN(cfg_nat_sdp_amr_mode_set, |
| 840 | cfg_nat_sdp_amr_mode_set_cmd, |
| 841 | "sdp-ensure-amr-mode-set", |
| 842 | "Ensure that SDP records include a mode-set\n") |
| 843 | { |
| 844 | _nat->sdp_ensure_amr_mode_set = 1; |
| 845 | return CMD_SUCCESS; |
| 846 | } |
| 847 | |
| 848 | DEFUN(cfg_nat_no_sdp_amr_mode_set, |
| 849 | cfg_nat_no_sdp_amr_mode_set_cmd, |
| 850 | "no sdp-ensure-amr-mode-set", |
| 851 | NO_STR "Ensure that SDP records include a mode-set\n") |
| 852 | { |
| 853 | _nat->sdp_ensure_amr_mode_set = 0; |
| 854 | return CMD_SUCCESS; |
| 855 | } |
| 856 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 857 | /* per BSC configuration */ |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 858 | DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", |
| 859 | "BSC configuration\n" "Identifier of the BSC\n") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 860 | { |
| 861 | int bsc_nr = atoi(argv[0]); |
Max | 714b170 | 2016-04-07 12:27:11 +0200 | [diff] [blame] | 862 | struct bsc_config *bsc = bsc_config_num(_nat, bsc_nr); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 863 | |
Max | 714b170 | 2016-04-07 12:27:11 +0200 | [diff] [blame] | 864 | /* allocate a new one */ |
| 865 | if (!bsc) |
| 866 | bsc = bsc_config_alloc(_nat, "unknown", bsc_nr); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 867 | |
| 868 | if (!bsc) |
| 869 | return CMD_WARNING; |
| 870 | |
Max | 4936448 | 2016-04-13 11:36:39 +0200 | [diff] [blame] | 871 | bsc->remove = false; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 872 | vty->index = bsc; |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 873 | vty->node = NAT_BSC_NODE; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 874 | |
| 875 | return CMD_SUCCESS; |
| 876 | } |
| 877 | |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 878 | DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", |
| 879 | "Authentication token configuration\n" |
| 880 | "Token of the BSC, currently transferred in cleartext\n") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 881 | { |
| 882 | struct bsc_config *conf = vty->index; |
| 883 | |
Holger Hans Peter Freyther | e43f8e0 | 2016-04-16 12:52:55 -0400 | [diff] [blame] | 884 | if (strncmp(conf->token, argv[0], 128) != 0) |
Max | 4936448 | 2016-04-13 11:36:39 +0200 | [diff] [blame] | 885 | conf->token_updated = true; |
Max | 4936448 | 2016-04-13 11:36:39 +0200 | [diff] [blame] | 886 | |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 887 | bsc_replace_string(conf, &conf->token, argv[0]); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 888 | return CMD_SUCCESS; |
| 889 | } |
| 890 | |
Holger Hans Peter Freyther | 694d980 | 2015-06-08 18:33:28 +0200 | [diff] [blame] | 891 | DEFUN(cfg_bsc_auth_key, cfg_bsc_auth_key_cmd, |
| 892 | "auth-key KEY", |
| 893 | "Authentication (secret) key configuration\n" |
| 894 | "Non null security key\n") |
| 895 | { |
| 896 | struct bsc_config *conf = vty->index; |
| 897 | |
| 898 | memset(conf->key, 0, sizeof(conf->key)); |
| 899 | osmo_hexparse(argv[0], conf->key, sizeof(conf->key)); |
| 900 | conf->key_present = 1; |
| 901 | return CMD_SUCCESS; |
| 902 | } |
| 903 | |
| 904 | DEFUN(cfg_bsc_no_auth_key, cfg_bsc_no_auth_key_cmd, |
| 905 | "no auth-key", |
| 906 | NO_STR "Authentication (secret) key configuration\n") |
| 907 | { |
| 908 | struct bsc_config *conf = vty->index; |
| 909 | |
| 910 | memset(conf->key, 0, sizeof(conf->key)); |
| 911 | conf->key_present = 0; |
| 912 | return CMD_SUCCESS; |
| 913 | } |
| 914 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 915 | DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>", |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 916 | "Add the Location Area Code (LAC) of this BSC\n" "LAC\n") |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 917 | { |
Holger Hans Peter Freyther | 39ee877 | 2010-03-30 06:08:56 +0200 | [diff] [blame] | 918 | struct bsc_config *tmp; |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 919 | struct bsc_config *conf = vty->index; |
| 920 | |
| 921 | int lac = atoi(argv[0]); |
| 922 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 923 | if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) { |
| 924 | vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s", |
| 925 | lac, VTY_NEWLINE); |
| 926 | return CMD_WARNING; |
| 927 | } |
| 928 | |
Holger Hans Peter Freyther | 39ee877 | 2010-03-30 06:08:56 +0200 | [diff] [blame] | 929 | /* verify that the LACs are unique */ |
| 930 | llist_for_each_entry(tmp, &_nat->bsc_configs, entry) { |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 931 | if (bsc_config_handles_lac(tmp, lac)) { |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 932 | if (tmp->nr != conf->nr) { |
| 933 | vty_out(vty, "%% LAC %d is already used.%s", lac, |
| 934 | VTY_NEWLINE); |
| 935 | return CMD_ERR_INCOMPLETE; |
| 936 | } |
Holger Hans Peter Freyther | 39ee877 | 2010-03-30 06:08:56 +0200 | [diff] [blame] | 937 | } |
| 938 | } |
| 939 | |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 940 | bsc_config_add_lac(conf, lac); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 941 | |
| 942 | return CMD_SUCCESS; |
| 943 | } |
| 944 | |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 945 | DEFUN(cfg_bsc_no_lac, cfg_bsc_no_lac_cmd, |
| 946 | "no location_area_code <0-65535>", |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 947 | NO_STR "Remove the Location Area Code (LAC) of this BSC\n" "LAC\n") |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 948 | { |
| 949 | int lac = atoi(argv[0]); |
| 950 | struct bsc_config *conf = vty->index; |
| 951 | |
| 952 | bsc_config_del_lac(conf, lac); |
| 953 | return CMD_SUCCESS; |
| 954 | } |
| 955 | |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 956 | DEFUN(show_bar_lst, |
| 957 | show_bar_lst_cmd, |
| 958 | "show imsi-black-list", |
| 959 | SHOW_STR "IMSIs barred from the network\n") |
| 960 | { |
| 961 | struct rb_node *node; |
| 962 | |
| 963 | vty_out(vty, "IMSIs barred from the network:%s", VTY_NEWLINE); |
| 964 | |
| 965 | for (node = rb_first(&_nat->imsi_black_list); node; node = rb_next(node)) { |
Holger Hans Peter Freyther | c36a6d5 | 2015-04-05 16:55:28 +0200 | [diff] [blame] | 966 | struct bsc_filter_barr_entry *entry; |
| 967 | entry = rb_entry(node, struct bsc_filter_barr_entry, node); |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 968 | |
| 969 | vty_out(vty, " IMSI(%s) CM-Reject-Cause(%d) LU-Reject-Cause(%d)%s", |
| 970 | entry->imsi, entry->cm_reject_cause, entry->lu_reject_cause, |
| 971 | VTY_NEWLINE); |
| 972 | } |
| 973 | |
| 974 | return CMD_SUCCESS; |
| 975 | } |
| 976 | |
Holger Hans Peter Freyther | 520c1f1 | 2010-09-25 16:25:47 +0800 | [diff] [blame] | 977 | |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 978 | DEFUN(cfg_bsc_acc_lst_name, |
| 979 | cfg_bsc_acc_lst_name_cmd, |
| 980 | "access-list-name NAME", |
| 981 | "Set the name of the access list to use.\n" |
| 982 | "The name of the to be used access list.") |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 983 | { |
| 984 | struct bsc_config *conf = vty->index; |
| 985 | |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 986 | bsc_replace_string(conf, &conf->acc_lst_name, argv[0]); |
Holger Hans Peter Freyther | c16cf27 | 2010-04-13 09:24:37 +0200 | [diff] [blame] | 987 | return CMD_SUCCESS; |
| 988 | } |
| 989 | |
Holger Hans Peter Freyther | 6a7babd | 2011-03-29 17:14:34 +0200 | [diff] [blame] | 990 | DEFUN(cfg_bsc_no_acc_lst_name, |
| 991 | cfg_bsc_no_acc_lst_name_cmd, |
| 992 | "no access-list-name", |
Holger Hans Peter Freyther | a64037c | 2011-04-13 20:58:14 +0200 | [diff] [blame] | 993 | NO_STR "Do not use an access-list for the BSC.\n") |
Holger Hans Peter Freyther | 6a7babd | 2011-03-29 17:14:34 +0200 | [diff] [blame] | 994 | { |
| 995 | struct bsc_config *conf = vty->index; |
| 996 | |
| 997 | if (conf->acc_lst_name) { |
| 998 | talloc_free(conf->acc_lst_name); |
| 999 | conf->acc_lst_name = NULL; |
| 1000 | } |
| 1001 | |
| 1002 | return CMD_SUCCESS; |
| 1003 | } |
| 1004 | |
Holger Hans Peter Freyther | 9ec030d | 2011-02-27 11:04:27 +0100 | [diff] [blame] | 1005 | DEFUN(cfg_bsc_max_endps, cfg_bsc_max_endps_cmd, |
| 1006 | "max-endpoints <1-1024>", |
| 1007 | "Highest endpoint to use (exclusively)\n" "Number of ports\n") |
Holger Hans Peter Freyther | 7b07b2d | 2011-02-25 20:38:15 +0100 | [diff] [blame] | 1008 | { |
| 1009 | struct bsc_config *conf = vty->index; |
| 1010 | |
Holger Hans Peter Freyther | 9ec030d | 2011-02-27 11:04:27 +0100 | [diff] [blame] | 1011 | conf->max_endpoints = atoi(argv[0]); |
Holger Hans Peter Freyther | 7b07b2d | 2011-02-25 20:38:15 +0100 | [diff] [blame] | 1012 | return CMD_SUCCESS; |
| 1013 | } |
| 1014 | |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 1015 | DEFUN(cfg_bsc_paging, |
| 1016 | cfg_bsc_paging_cmd, |
| 1017 | "paging forbidden (0|1)", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 1018 | PAGING_STR "Forbid sending PAGING REQUESTS to the BSC.\n" |
| 1019 | "Do not forbid\n" "Forbid\n") |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 1020 | { |
| 1021 | struct bsc_config *conf = vty->index; |
| 1022 | |
Holger Hans Peter Freyther | 834f1df | 2010-04-21 20:07:07 +0800 | [diff] [blame] | 1023 | if (strcmp("1", argv[0]) == 0) |
Holger Hans Peter Freyther | 62e5843 | 2010-04-21 19:05:14 +0800 | [diff] [blame] | 1024 | conf->forbid_paging = 1; |
| 1025 | else |
| 1026 | conf->forbid_paging = 0; |
| 1027 | |
| 1028 | return CMD_SUCCESS; |
| 1029 | } |
| 1030 | |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 1031 | DEFUN(cfg_bsc_desc, |
| 1032 | cfg_bsc_desc_cmd, |
| 1033 | "description DESC", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 1034 | "Provide a description for the given BSC.\n" "Description\n") |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 1035 | { |
| 1036 | struct bsc_config *conf = vty->index; |
| 1037 | |
Holger Hans Peter Freyther | 3e9a7f8 | 2010-10-12 23:21:54 +0200 | [diff] [blame] | 1038 | bsc_replace_string(conf, &conf->description, argv[0]); |
Holger Hans Peter Freyther | b606101 | 2010-05-14 22:06:28 +0800 | [diff] [blame] | 1039 | return CMD_SUCCESS; |
| 1040 | } |
| 1041 | |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1042 | DEFUN(cfg_bsc_paging_grp, |
| 1043 | cfg_bsc_paging_grp_cmd, |
Holger Hans Peter Freyther | c0370e4 | 2011-05-17 19:28:07 +0200 | [diff] [blame] | 1044 | "paging group <0-1000>", |
| 1045 | PAGING_STR "Use a paging group\n" "Paging Group to use\n") |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1046 | { |
| 1047 | struct bsc_config *conf = vty->index; |
| 1048 | conf->paging_group = atoi(argv[0]); |
| 1049 | return CMD_SUCCESS; |
| 1050 | } |
| 1051 | |
Holger Hans Peter Freyther | c0370e4 | 2011-05-17 19:28:07 +0200 | [diff] [blame] | 1052 | ALIAS_DEPRECATED(cfg_bsc_paging_grp, cfg_bsc_old_grp_cmd, |
| 1053 | "paging-group <0-1000>", |
| 1054 | "Use a paging group\n" "Paging Group to use\n") |
| 1055 | |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1056 | DEFUN(cfg_bsc_no_paging_grp, |
| 1057 | cfg_bsc_no_paging_grp_cmd, |
Holger Hans Peter Freyther | c0370e4 | 2011-05-17 19:28:07 +0200 | [diff] [blame] | 1058 | "no paging group", |
| 1059 | NO_STR PAGING_STR "Disable the usage of a paging group.\n") |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1060 | { |
| 1061 | struct bsc_config *conf = vty->index; |
| 1062 | conf->paging_group = PAGIN_GROUP_UNASSIGNED; |
| 1063 | return CMD_SUCCESS; |
| 1064 | } |
| 1065 | |
Holger Hans Peter Freyther | 52c4ba0 | 2010-05-14 23:43:12 +0800 | [diff] [blame] | 1066 | DEFUN(test_regex, test_regex_cmd, |
| 1067 | "test regex PATTERN STRING", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 1068 | "Test utilities\n" |
| 1069 | "Regexp testing\n" "The regexp pattern\n" |
| 1070 | "The string to match\n") |
Holger Hans Peter Freyther | 52c4ba0 | 2010-05-14 23:43:12 +0800 | [diff] [blame] | 1071 | { |
| 1072 | regex_t reg; |
| 1073 | char *str = NULL; |
| 1074 | |
| 1075 | memset(®, 0, sizeof(reg)); |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 1076 | if (gsm_parse_reg(_nat, ®, &str, 1, argv) != 0) |
Holger Hans Peter Freyther | 4c9557e | 2011-04-04 19:19:26 +0200 | [diff] [blame] | 1077 | return CMD_WARNING; |
Holger Hans Peter Freyther | 52c4ba0 | 2010-05-14 23:43:12 +0800 | [diff] [blame] | 1078 | |
| 1079 | vty_out(vty, "String matches allow pattern: %d%s", |
| 1080 | regexec(®, argv[1], 0, NULL, 0) == 0, VTY_NEWLINE); |
| 1081 | |
| 1082 | talloc_free(str); |
| 1083 | regfree(®); |
| 1084 | return CMD_SUCCESS; |
| 1085 | } |
| 1086 | |
Holger Hans Peter Freyther | dfdf8d9 | 2011-02-28 01:07:13 +0100 | [diff] [blame] | 1087 | DEFUN(set_last_endp, set_last_endp_cmd, |
| 1088 | "set bsc last-used-endpoint <0-9999999999> <0-1024>", |
| 1089 | "Set a value\n" "Operate on a BSC\n" |
| 1090 | "Last used endpoint for an assignment\n" "BSC configuration number\n" |
| 1091 | "Endpoint number used\n") |
| 1092 | { |
| 1093 | struct bsc_connection *con; |
| 1094 | int nr = atoi(argv[0]); |
| 1095 | int endp = atoi(argv[1]); |
| 1096 | |
| 1097 | |
| 1098 | llist_for_each_entry(con, &_nat->bsc_connections, list_entry) { |
| 1099 | if (!con->cfg) |
| 1100 | continue; |
| 1101 | if (con->cfg->nr != nr) |
| 1102 | continue; |
| 1103 | |
| 1104 | con->last_endpoint = endp; |
| 1105 | vty_out(vty, "Updated the last endpoint for %d to %d.%s", |
| 1106 | con->cfg->nr, con->last_endpoint, VTY_NEWLINE); |
| 1107 | } |
| 1108 | |
| 1109 | return CMD_SUCCESS; |
| 1110 | } |
| 1111 | |
Holger Hans Peter Freyther | de2b860 | 2011-04-23 23:55:14 +0200 | [diff] [blame] | 1112 | DEFUN(block_new_conn, block_new_conn_cmd, |
| 1113 | "nat-block (block|unblock)", |
| 1114 | "Block the NAT for new connections\n" |
| 1115 | "Block\n" "Unblock\n") |
| 1116 | { |
| 1117 | _nat->blocked = argv[0][0] == 'b'; |
| 1118 | vty_out(vty, "%%Going to %s the NAT.%s", |
| 1119 | _nat->blocked ? "block" : "unblock", VTY_NEWLINE); |
| 1120 | return CMD_SUCCESS; |
| 1121 | } |
| 1122 | |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1123 | /* paging group */ |
| 1124 | DEFUN(cfg_nat_pgroup, cfg_nat_pgroup_cmd, |
| 1125 | "paging-group <0-1000>", |
| 1126 | "Create a Paging Group\n" "Number of the Group\n") |
| 1127 | { |
| 1128 | int group = atoi(argv[0]); |
| 1129 | struct bsc_nat_paging_group *pgroup; |
| 1130 | pgroup = bsc_nat_paging_group_num(_nat, group); |
| 1131 | if (!pgroup) |
| 1132 | pgroup = bsc_nat_paging_group_create(_nat, group); |
| 1133 | if (!pgroup) { |
| 1134 | vty_out(vty, "Failed to create the group.%s", VTY_NEWLINE); |
| 1135 | return CMD_WARNING; |
| 1136 | } |
| 1137 | |
| 1138 | vty->index = pgroup; |
| 1139 | vty->node = PGROUP_NODE; |
| 1140 | return CMD_SUCCESS; |
| 1141 | } |
| 1142 | |
| 1143 | DEFUN(cfg_nat_no_pgroup, cfg_nat_no_pgroup_cmd, |
| 1144 | "no paging-group <0-1000>", |
Holger Hans Peter Freyther | 1a6b83c | 2012-07-28 16:14:04 +0200 | [diff] [blame] | 1145 | NO_STR "Delete paging-group\n" "Paging-group number\n") |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1146 | { |
| 1147 | int group = atoi(argv[0]); |
| 1148 | struct bsc_nat_paging_group *pgroup; |
| 1149 | pgroup = bsc_nat_paging_group_num(_nat, group); |
| 1150 | if (!pgroup) { |
| 1151 | vty_out(vty, "No such paging group %d.%s", group, VTY_NEWLINE); |
| 1152 | return CMD_WARNING; |
| 1153 | } |
| 1154 | |
| 1155 | bsc_nat_paging_group_delete(pgroup); |
| 1156 | return CMD_SUCCESS; |
| 1157 | } |
| 1158 | |
| 1159 | DEFUN(cfg_pgroup_lac, cfg_pgroup_lac_cmd, |
| 1160 | "location_area_code <0-65535>", |
| 1161 | "Add the Location Area Code (LAC)\n" "LAC\n") |
| 1162 | { |
| 1163 | struct bsc_nat_paging_group *pgroup = vty->index; |
| 1164 | |
| 1165 | int lac = atoi(argv[0]); |
| 1166 | if (lac == GSM_LAC_RESERVED_DETACHED || lac == GSM_LAC_RESERVED_ALL_BTS) { |
| 1167 | vty_out(vty, "%% LAC %d is reserved by GSM 04.08%s", |
| 1168 | lac, VTY_NEWLINE); |
| 1169 | return CMD_WARNING; |
| 1170 | } |
| 1171 | |
| 1172 | bsc_nat_paging_group_add_lac(pgroup, lac); |
| 1173 | return CMD_SUCCESS; |
| 1174 | } |
| 1175 | |
| 1176 | DEFUN(cfg_pgroup_no_lac, cfg_pgroup_no_lac_cmd, |
| 1177 | "no location_area_code <0-65535>", |
| 1178 | NO_STR "Remove the Location Area Code (LAC)\n" "LAC\n") |
| 1179 | { |
| 1180 | int lac = atoi(argv[0]); |
| 1181 | struct bsc_nat_paging_group *pgroup = vty->index; |
| 1182 | |
| 1183 | bsc_nat_paging_group_del_lac(pgroup, lac); |
| 1184 | return CMD_SUCCESS; |
| 1185 | } |
| 1186 | |
Jacob Erlbeck | 6cb2ccc | 2013-08-14 11:10:34 +0200 | [diff] [blame] | 1187 | DEFUN(show_ussd_connection, |
| 1188 | show_ussd_connection_cmd, |
| 1189 | "show ussd-connection", |
| 1190 | SHOW_STR "USSD connection related information\n") |
| 1191 | { |
| 1192 | vty_out(vty, "The USSD side channel provider is %sconnected and %sauthorized.%s", |
| 1193 | _nat->ussd_con ? "" : "not ", |
| 1194 | _nat->ussd_con && _nat->ussd_con->authorized? "" : "not ", |
| 1195 | VTY_NEWLINE); |
| 1196 | return CMD_SUCCESS; |
| 1197 | } |
| 1198 | |
Holger Hans Peter Freyther | 6019b5a | 2014-07-04 20:09:55 +0200 | [diff] [blame] | 1199 | #define OSMUX_STR "RTP multiplexing\n" |
Pablo Neira Ayuso | cab6e75 | 2014-02-05 18:56:17 +0100 | [diff] [blame] | 1200 | DEFUN(cfg_bsc_osmux, |
| 1201 | cfg_bsc_osmux_cmd, |
Holger Hans Peter Freyther | 20626dd | 2015-10-02 18:15:18 +0200 | [diff] [blame] | 1202 | "osmux (on|off|only)", |
| 1203 | OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n" "Only OSMUX\n") |
Pablo Neira Ayuso | cab6e75 | 2014-02-05 18:56:17 +0100 | [diff] [blame] | 1204 | { |
| 1205 | struct bsc_config *conf = vty->index; |
Pablo Neira Ayuso | 8be171e | 2014-08-27 14:58:43 +0200 | [diff] [blame] | 1206 | int old = conf->osmux; |
Pablo Neira Ayuso | cab6e75 | 2014-02-05 18:56:17 +0100 | [diff] [blame] | 1207 | |
| 1208 | if (strcmp(argv[0], "on") == 0) |
Holger Hans Peter Freyther | 20626dd | 2015-10-02 18:15:18 +0200 | [diff] [blame] | 1209 | conf->osmux = OSMUX_USAGE_ON; |
Pablo Neira Ayuso | cab6e75 | 2014-02-05 18:56:17 +0100 | [diff] [blame] | 1210 | else if (strcmp(argv[0], "off") == 0) |
Holger Hans Peter Freyther | 20626dd | 2015-10-02 18:15:18 +0200 | [diff] [blame] | 1211 | conf->osmux = OSMUX_USAGE_OFF; |
| 1212 | else if (strcmp(argv[0], "only") == 0) |
| 1213 | conf->osmux = OSMUX_USAGE_ONLY; |
Pablo Neira Ayuso | cab6e75 | 2014-02-05 18:56:17 +0100 | [diff] [blame] | 1214 | |
Holger Hans Peter Freyther | 20626dd | 2015-10-02 18:15:18 +0200 | [diff] [blame] | 1215 | if (old == 0 && conf->osmux > 0 && !conf->nat->mgcp_cfg->osmux_init) { |
Holger Hans Peter Freyther | 9d1a17e | 2015-01-21 16:53:53 +0100 | [diff] [blame] | 1216 | LOGP(DMGCP, LOGL_NOTICE, "Setting up OSMUX socket\n"); |
Pablo Neira Ayuso | 8be171e | 2014-08-27 14:58:43 +0200 | [diff] [blame] | 1217 | if (osmux_init(OSMUX_ROLE_BSC_NAT, conf->nat->mgcp_cfg) < 0) { |
| 1218 | LOGP(DMGCP, LOGL_ERROR, "Cannot init OSMUX\n"); |
Holger Hans Peter Freyther | 9d1a17e | 2015-01-21 16:53:53 +0100 | [diff] [blame] | 1219 | vty_out(vty, "%% failed to create Osmux socket%s", |
| 1220 | VTY_NEWLINE); |
| 1221 | return CMD_WARNING; |
Pablo Neira Ayuso | 8be171e | 2014-08-27 14:58:43 +0200 | [diff] [blame] | 1222 | } |
Holger Hans Peter Freyther | 20626dd | 2015-10-02 18:15:18 +0200 | [diff] [blame] | 1223 | } else if (old > 0 && conf->osmux == 0) { |
Pablo Neira Ayuso | 8be171e | 2014-08-27 14:58:43 +0200 | [diff] [blame] | 1224 | LOGP(DMGCP, LOGL_NOTICE, "Disabling OSMUX socket\n"); |
| 1225 | /* Don't stop the socket, we may already have ongoing voice |
| 1226 | * flows already using Osmux. This just switch indicates that |
| 1227 | * new upcoming flows should use RTP. |
| 1228 | */ |
| 1229 | } |
| 1230 | |
Pablo Neira Ayuso | cab6e75 | 2014-02-05 18:56:17 +0100 | [diff] [blame] | 1231 | return CMD_SUCCESS; |
| 1232 | } |
| 1233 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1234 | int bsc_nat_vty_init(struct bsc_nat *nat) |
| 1235 | { |
| 1236 | _nat = nat; |
| 1237 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1238 | /* show commands */ |
Holger Hans Peter Freyther | 1398f13 | 2010-06-15 20:14:08 +0800 | [diff] [blame] | 1239 | install_element_ve(&show_sccp_cmd); |
| 1240 | install_element_ve(&show_bsc_cmd); |
Max | e5686f2 | 2016-04-06 17:25:44 +0200 | [diff] [blame] | 1241 | install_element_ve(&show_nat_bsc_cmd); |
Holger Hans Peter Freyther | 1398f13 | 2010-06-15 20:14:08 +0800 | [diff] [blame] | 1242 | install_element_ve(&show_bsc_cfg_cmd); |
| 1243 | install_element_ve(&show_stats_cmd); |
Holger Hans Peter Freyther | c95cfda | 2010-07-22 20:26:10 +0800 | [diff] [blame] | 1244 | install_element_ve(&show_stats_lac_cmd); |
Holger Hans Peter Freyther | 1398f13 | 2010-06-15 20:14:08 +0800 | [diff] [blame] | 1245 | install_element_ve(&close_bsc_cmd); |
| 1246 | install_element_ve(&show_msc_cmd); |
| 1247 | install_element_ve(&test_regex_cmd); |
Holger Hans Peter Freyther | 0d8330c | 2010-08-28 18:33:34 +0800 | [diff] [blame] | 1248 | install_element_ve(&show_bsc_mgcp_cmd); |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 1249 | install_element_ve(&show_bscs_cmd); |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 1250 | install_element_ve(&show_bar_lst_cmd); |
Holger Hans Peter Freyther | ddf191e | 2013-06-25 11:44:01 +0200 | [diff] [blame] | 1251 | install_element_ve(&show_prefix_tree_cmd); |
Jacob Erlbeck | 6cb2ccc | 2013-08-14 11:10:34 +0200 | [diff] [blame] | 1252 | install_element_ve(&show_ussd_connection_cmd); |
Holger Hans Peter Freyther | 5f291d5 | 2010-04-06 12:01:15 +0200 | [diff] [blame] | 1253 | |
Holger Hans Peter Freyther | dfdf8d9 | 2011-02-28 01:07:13 +0100 | [diff] [blame] | 1254 | install_element(ENABLE_NODE, &set_last_endp_cmd); |
Holger Hans Peter Freyther | de2b860 | 2011-04-23 23:55:14 +0200 | [diff] [blame] | 1255 | install_element(ENABLE_NODE, &block_new_conn_cmd); |
Holger Hans Peter Freyther | dfdf8d9 | 2011-02-28 01:07:13 +0100 | [diff] [blame] | 1256 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1257 | /* nat group */ |
| 1258 | install_element(CONFIG_NODE, &cfg_nat_cmd); |
| 1259 | install_node(&nat_node, config_write_nat); |
Jacob Erlbeck | 36722e1 | 2013-10-29 09:30:30 +0100 | [diff] [blame] | 1260 | vty_install_default(NAT_NODE); |
Holger Hans Peter Freyther | a88742c | 2010-06-15 18:51:04 +0800 | [diff] [blame] | 1261 | install_element(NAT_NODE, &cfg_nat_msc_ip_cmd); |
Holger Hans Peter Freyther | 8139553 | 2010-04-17 07:48:45 +0200 | [diff] [blame] | 1262 | install_element(NAT_NODE, &cfg_nat_msc_port_cmd); |
Holger Hans Peter Freyther | da35a8d | 2010-05-05 16:57:38 +0800 | [diff] [blame] | 1263 | install_element(NAT_NODE, &cfg_nat_auth_time_cmd); |
| 1264 | install_element(NAT_NODE, &cfg_nat_ping_time_cmd); |
| 1265 | install_element(NAT_NODE, &cfg_nat_pong_time_cmd); |
Holger Hans Peter Freyther | e635dab | 2010-05-15 00:14:58 +0800 | [diff] [blame] | 1266 | install_element(NAT_NODE, &cfg_nat_token_cmd); |
Holger Hans Peter Freyther | 6b77107 | 2010-07-27 19:21:53 +0800 | [diff] [blame] | 1267 | install_element(NAT_NODE, &cfg_nat_bsc_ip_dscp_cmd); |
Holger Hans Peter Freyther | 078321a | 2010-05-31 10:36:35 +0800 | [diff] [blame] | 1268 | install_element(NAT_NODE, &cfg_nat_bsc_ip_tos_cmd); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 1269 | install_element(NAT_NODE, &cfg_nat_acc_lst_name_cmd); |
Holger Hans Peter Freyther | 6a7babd | 2011-03-29 17:14:34 +0200 | [diff] [blame] | 1270 | install_element(NAT_NODE, &cfg_nat_no_acc_lst_name_cmd); |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 1271 | install_element(NAT_NODE, &cfg_nat_include_cmd); |
Holger Hans Peter Freyther | 1f8276e | 2013-01-01 11:25:09 +0100 | [diff] [blame] | 1272 | install_element(NAT_NODE, &cfg_nat_imsi_black_list_fn_cmd); |
| 1273 | install_element(NAT_NODE, &cfg_nat_no_imsi_black_list_fn_cmd); |
Holger Hans Peter Freyther | d1effd8 | 2010-10-10 17:29:20 +0200 | [diff] [blame] | 1274 | install_element(NAT_NODE, &cfg_nat_ussd_lst_name_cmd); |
Holger Hans Peter Freyther | c1578bc | 2010-10-11 10:06:39 +0200 | [diff] [blame] | 1275 | install_element(NAT_NODE, &cfg_nat_ussd_query_cmd); |
Holger Hans Peter Freyther | e393f27 | 2010-10-12 18:25:52 +0200 | [diff] [blame] | 1276 | install_element(NAT_NODE, &cfg_nat_ussd_token_cmd); |
| 1277 | install_element(NAT_NODE, &cfg_nat_ussd_local_cmd); |
Jacob Erlbeck | 4c9dff5 | 2013-09-02 13:17:17 +0200 | [diff] [blame] | 1278 | install_element(NAT_NODE, &cfg_nat_use_ipa_for_mgcp_cmd); |
Holger Hans Peter Freyther | 8affef5 | 2010-06-01 01:03:13 +0800 | [diff] [blame] | 1279 | |
Holger Hans Peter Freyther | a1e6bd6 | 2015-04-04 22:40:12 +0200 | [diff] [blame] | 1280 | bsc_msg_lst_vty_init(nat, &nat->access_lists, NAT_NODE); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1281 | |
Holger Hans Peter Freyther | 7642439 | 2010-10-21 10:59:54 +0200 | [diff] [blame] | 1282 | /* number rewriting */ |
| 1283 | install_element(NAT_NODE, &cfg_nat_number_rewrite_cmd); |
Holger Hans Peter Freyther | b718ad3 | 2013-06-25 09:08:02 +0200 | [diff] [blame] | 1284 | install_element(NAT_NODE, &cfg_nat_no_number_rewrite_cmd); |
Holger Hans Peter Freyther | 67e423c | 2013-06-25 15:38:31 +0200 | [diff] [blame] | 1285 | install_element(NAT_NODE, &cfg_nat_number_rewrite_post_cmd); |
| 1286 | install_element(NAT_NODE, &cfg_nat_no_number_rewrite_post_cmd); |
Holger Hans Peter Freyther | e36b487 | 2011-05-31 00:35:46 +0200 | [diff] [blame] | 1287 | install_element(NAT_NODE, &cfg_nat_smsc_addr_cmd); |
| 1288 | install_element(NAT_NODE, &cfg_nat_smsc_tpdest_cmd); |
Holger Hans Peter Freyther | 68368dd | 2012-01-10 22:39:07 +0100 | [diff] [blame] | 1289 | install_element(NAT_NODE, &cfg_nat_sms_clear_tpsrr_cmd); |
| 1290 | install_element(NAT_NODE, &cfg_nat_no_sms_clear_tpsrr_cmd); |
Holger Hans Peter Freyther | 7d60bdb | 2012-01-18 20:40:01 +0100 | [diff] [blame] | 1291 | install_element(NAT_NODE, &cfg_nat_sms_number_rewrite_cmd); |
| 1292 | install_element(NAT_NODE, &cfg_nat_no_sms_number_rewrite_cmd); |
Holger Hans Peter Freyther | ddf191e | 2013-06-25 11:44:01 +0200 | [diff] [blame] | 1293 | install_element(NAT_NODE, &cfg_nat_prefix_trie_cmd); |
| 1294 | install_element(NAT_NODE, &cfg_nat_no_prefix_trie_cmd); |
Holger Hans Peter Freyther | 7642439 | 2010-10-21 10:59:54 +0200 | [diff] [blame] | 1295 | |
Holger Hans Peter Freyther | 7f100c9 | 2015-04-23 20:25:17 -0400 | [diff] [blame] | 1296 | install_element(NAT_NODE, &cfg_nat_sdp_amr_mode_set_cmd); |
| 1297 | install_element(NAT_NODE, &cfg_nat_no_sdp_amr_mode_set_cmd); |
| 1298 | |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1299 | install_element(NAT_NODE, &cfg_nat_pgroup_cmd); |
| 1300 | install_element(NAT_NODE, &cfg_nat_no_pgroup_cmd); |
| 1301 | install_node(&pgroup_node, config_write_pgroup); |
Jacob Erlbeck | 36722e1 | 2013-10-29 09:30:30 +0100 | [diff] [blame] | 1302 | vty_install_default(PGROUP_NODE); |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1303 | install_element(PGROUP_NODE, &cfg_pgroup_lac_cmd); |
| 1304 | install_element(PGROUP_NODE, &cfg_pgroup_no_lac_cmd); |
| 1305 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1306 | /* BSC subgroups */ |
| 1307 | install_element(NAT_NODE, &cfg_bsc_cmd); |
Max | 82f5ecd | 2016-04-12 16:59:25 +0200 | [diff] [blame] | 1308 | install_node(&bsc_node, NULL); |
Jacob Erlbeck | 36722e1 | 2013-10-29 09:30:30 +0100 | [diff] [blame] | 1309 | vty_install_default(NAT_BSC_NODE); |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 1310 | install_element(NAT_BSC_NODE, &cfg_bsc_token_cmd); |
Holger Hans Peter Freyther | 694d980 | 2015-06-08 18:33:28 +0200 | [diff] [blame] | 1311 | install_element(NAT_BSC_NODE, &cfg_bsc_auth_key_cmd); |
| 1312 | install_element(NAT_BSC_NODE, &cfg_bsc_no_auth_key_cmd); |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 1313 | install_element(NAT_BSC_NODE, &cfg_bsc_lac_cmd); |
Holger Hans Peter Freyther | 0bd60f3 | 2010-10-08 22:08:29 +0800 | [diff] [blame] | 1314 | install_element(NAT_BSC_NODE, &cfg_bsc_no_lac_cmd); |
Holger Hans Peter Freyther | 7b4a53d | 2010-06-17 14:42:20 +0800 | [diff] [blame] | 1315 | install_element(NAT_BSC_NODE, &cfg_bsc_paging_cmd); |
| 1316 | install_element(NAT_BSC_NODE, &cfg_bsc_desc_cmd); |
| 1317 | install_element(NAT_BSC_NODE, &cfg_bsc_acc_lst_name_cmd); |
Holger Hans Peter Freyther | 6a7babd | 2011-03-29 17:14:34 +0200 | [diff] [blame] | 1318 | install_element(NAT_BSC_NODE, &cfg_bsc_no_acc_lst_name_cmd); |
Holger Hans Peter Freyther | 9ec030d | 2011-02-27 11:04:27 +0100 | [diff] [blame] | 1319 | install_element(NAT_BSC_NODE, &cfg_bsc_max_endps_cmd); |
Holger Hans Peter Freyther | c0370e4 | 2011-05-17 19:28:07 +0200 | [diff] [blame] | 1320 | install_element(NAT_BSC_NODE, &cfg_bsc_old_grp_cmd); |
Holger Hans Peter Freyther | 6860c44 | 2011-05-02 19:16:13 +0200 | [diff] [blame] | 1321 | install_element(NAT_BSC_NODE, &cfg_bsc_paging_grp_cmd); |
| 1322 | install_element(NAT_BSC_NODE, &cfg_bsc_no_paging_grp_cmd); |
Pablo Neira Ayuso | cab6e75 | 2014-02-05 18:56:17 +0100 | [diff] [blame] | 1323 | install_element(NAT_BSC_NODE, &cfg_bsc_osmux_cmd); |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1324 | |
Holger Hans Peter Freyther | f7d3335 | 2010-06-15 18:50:26 +0800 | [diff] [blame] | 1325 | mgcp_vty_init(); |
| 1326 | |
Holger Hans Peter Freyther | 9a85ef3 | 2010-06-15 18:46:11 +0800 | [diff] [blame] | 1327 | return 0; |
| 1328 | } |
| 1329 | |
| 1330 | |
| 1331 | /* called by the telnet interface... we have our own init above */ |
Neels Hofmeyr | 43d86bf | 2016-05-10 13:40:19 +0200 | [diff] [blame^] | 1332 | int bsc_vty_init(const struct log_info *cat, struct gsm_network *network) |
Holger Hans Peter Freyther | 6c79a68 | 2011-02-24 14:33:09 +0100 | [diff] [blame] | 1333 | { |
Pablo Neira Ayuso | 739a566 | 2011-03-09 13:36:32 +0100 | [diff] [blame] | 1334 | logging_vty_add_cmds(cat); |
Holger Hans Peter Freyther | 6c79a68 | 2011-02-24 14:33:09 +0100 | [diff] [blame] | 1335 | return 0; |
| 1336 | } |