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