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