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