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