Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 1 | /* HNB-GW interface to quagga VTY */ |
| 2 | |
| 3 | /* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 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 |
| 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 |
| 14 | * GNU Affero General Public License for more details. |
| 15 | * |
| 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/>. |
| 18 | * |
| 19 | */ |
| 20 | |
Harald Welte | da86fe5 | 2017-11-21 08:14:37 +0100 | [diff] [blame] | 21 | #include <string.h> |
| 22 | |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 23 | #include <osmocom/core/socket.h> |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 24 | #include <osmocom/vty/command.h> |
| 25 | |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 26 | #include <osmocom/iuh/vty.h> |
| 27 | |
Neels Hofmeyr | df63de2 | 2016-08-18 13:13:55 +0200 | [diff] [blame] | 28 | #include <osmocom/iuh/hnbgw.h> |
| 29 | #include <osmocom/iuh/context_map.h> |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 30 | #include <osmocom/sigtran/protocol/sua.h> |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 31 | #include <osmocom/sigtran/sccp_helpers.h> |
| 32 | #include <osmocom/netif/stream.h> |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 33 | |
| 34 | static void *tall_hnb_ctx = NULL; |
| 35 | static struct hnb_gw *g_hnb_gw = NULL; |
| 36 | |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 37 | static struct cmd_node hnbgw_node = { |
| 38 | HNBGW_NODE, |
| 39 | "%s(config-hnbgw)# ", |
| 40 | 1, |
| 41 | }; |
| 42 | |
| 43 | DEFUN(cfg_hnbgw, cfg_hnbgw_cmd, |
| 44 | "hnbgw", "Configure HNBGW options") |
| 45 | { |
| 46 | vty->node = HNBGW_NODE; |
| 47 | return CMD_SUCCESS; |
| 48 | } |
| 49 | |
| 50 | static struct cmd_node iuh_node = { |
| 51 | IUH_NODE, |
| 52 | "%s(config-hnbgw-iuh)# ", |
| 53 | 1, |
| 54 | }; |
| 55 | |
| 56 | DEFUN(cfg_hnbgw_iuh, cfg_hnbgw_iuh_cmd, |
| 57 | "iuh", "Configure Iuh options") |
| 58 | { |
| 59 | vty->node = IUH_NODE; |
| 60 | return CMD_SUCCESS; |
| 61 | } |
| 62 | |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 63 | static struct cmd_node iucs_node = { |
| 64 | IUCS_NODE, |
| 65 | "%s(config-hnbgw-iucs)# ", |
| 66 | 1, |
| 67 | }; |
| 68 | |
| 69 | DEFUN(cfg_hnbgw_iucs, cfg_hnbgw_iucs_cmd, |
| 70 | "iucs", "Configure IuCS options") |
| 71 | { |
| 72 | vty->node = IUCS_NODE; |
| 73 | return CMD_SUCCESS; |
| 74 | } |
| 75 | |
| 76 | static struct cmd_node iups_node = { |
| 77 | IUPS_NODE, |
| 78 | "%s(config-hnbgw-iups)# ", |
| 79 | 1, |
| 80 | }; |
| 81 | |
| 82 | DEFUN(cfg_hnbgw_iups, cfg_hnbgw_iups_cmd, |
| 83 | "iups", "Configure IuPS options") |
| 84 | { |
| 85 | vty->node = IUPS_NODE; |
| 86 | return CMD_SUCCESS; |
| 87 | } |
| 88 | |
Neels Hofmeyr | c510fc2 | 2016-10-13 16:58:04 +0200 | [diff] [blame] | 89 | int hnbgw_vty_go_parent(struct vty *vty) |
| 90 | { |
| 91 | switch (vty->node) { |
| 92 | case IUH_NODE: |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 93 | case IUCS_NODE: |
| 94 | case IUPS_NODE: |
Neels Hofmeyr | c510fc2 | 2016-10-13 16:58:04 +0200 | [diff] [blame] | 95 | vty->node = HNBGW_NODE; |
| 96 | vty->index = NULL; |
| 97 | break; |
Neels Hofmeyr | c510fc2 | 2016-10-13 16:58:04 +0200 | [diff] [blame] | 98 | case HNBGW_NODE: |
| 99 | vty->node = CONFIG_NODE; |
| 100 | vty->index = NULL; |
| 101 | break; |
| 102 | case CONFIG_NODE: |
| 103 | vty->node = ENABLE_NODE; |
| 104 | vty->index = NULL; |
| 105 | break; |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 106 | default: |
| 107 | osmo_ss7_vty_go_parent(vty); |
| 108 | break; |
Neels Hofmeyr | c510fc2 | 2016-10-13 16:58:04 +0200 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | return vty->node; |
| 112 | } |
| 113 | |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 114 | DEFUN(show_cnlink, show_cnlink_cmd, "show cnlink", |
| 115 | SHOW_STR "Display information on core network link\n") |
| 116 | { |
| 117 | struct osmo_ss7_route *rt; |
| 118 | struct osmo_ss7_instance *ss7 = osmo_sccp_get_ss7(g_hnb_gw->sccp.client); |
| 119 | int i; |
| 120 | #define GUARD(STR) \ |
| 121 | STR ? STR : "", \ |
| 122 | STR ? ":" : "" |
| 123 | |
| 124 | vty_out(vty, "IuCS: %s <->", |
| 125 | osmo_sccp_user_name(g_hnb_gw->sccp.cnlink->sccp_user)); |
| 126 | vty_out(vty, " %s%s%s%s", |
| 127 | GUARD(g_hnb_gw->config.iucs_remote_addr_name), |
| 128 | osmo_sccp_inst_addr_name(g_hnb_gw->sccp.client, &g_hnb_gw->sccp.iucs_remote_addr), |
| 129 | VTY_NEWLINE); |
| 130 | |
| 131 | rt = osmo_ss7_route_lookup(ss7, g_hnb_gw->sccp.iucs_remote_addr.pc); |
| 132 | vty_out(vty, " SS7 route: %s%s", osmo_ss7_route_name(rt, true), VTY_NEWLINE); |
| 133 | |
| 134 | vty_out(vty, "IuPS: %s <->", |
| 135 | osmo_sccp_user_name(g_hnb_gw->sccp.cnlink->sccp_user)); |
| 136 | vty_out(vty, " %s%s%s%s", |
| 137 | GUARD(g_hnb_gw->config.iups_remote_addr_name), |
| 138 | osmo_sccp_inst_addr_name(g_hnb_gw->sccp.client, &g_hnb_gw->sccp.iups_remote_addr), |
| 139 | VTY_NEWLINE); |
| 140 | |
| 141 | rt = osmo_ss7_route_lookup(ss7, g_hnb_gw->sccp.iups_remote_addr.pc); |
| 142 | vty_out(vty, " SS7 route: %s%s", osmo_ss7_route_name(rt, true), VTY_NEWLINE); |
| 143 | |
| 144 | #undef GUARD |
| 145 | return CMD_SUCCESS; |
| 146 | } |
| 147 | |
| 148 | static void vty_out_ofd_addr(struct vty *vty, struct osmo_fd *ofd) |
| 149 | { |
Harald Welte | 8e88d37 | 2017-12-26 21:38:49 +0100 | [diff] [blame] | 150 | char *name; |
| 151 | if (!ofd || ofd->fd < 0 |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 152 | || !(name = osmo_sock_get_name(vty, ofd->fd))) { |
| 153 | vty_out(vty, "(no addr)"); |
| 154 | return; |
Harald Welte | 8e88d37 | 2017-12-26 21:38:49 +0100 | [diff] [blame] | 155 | } |
Harald Welte | f8b73b1 | 2017-12-26 21:39:53 +0100 | [diff] [blame] | 156 | vty_out(vty, "%s", name); |
Harald Welte | 8e88d37 | 2017-12-26 21:38:49 +0100 | [diff] [blame] | 157 | talloc_free(name); |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 158 | } |
| 159 | |
Neels Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 160 | static void vty_dump_hnb_info__map_states(struct vty *vty, const char *name, unsigned int count, |
| 161 | unsigned int state_count[]) |
| 162 | { |
| 163 | unsigned int i; |
| 164 | if (!count) |
| 165 | return; |
| 166 | vty_out(vty, " %s: %u contexts:", name, count); |
| 167 | for (i = 0; i <= MAP_S_NUM_STATES; i++) { |
| 168 | if (!state_count[i]) |
| 169 | continue; |
| 170 | vty_out(vty, " %s:%u", hnbgw_context_map_state_name(i), state_count[i]); |
| 171 | } |
| 172 | vty_out(vty, VTY_NEWLINE); |
| 173 | } |
| 174 | |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 175 | static void vty_dump_hnb_info(struct vty *vty, struct hnb_context *hnb) |
| 176 | { |
| 177 | struct hnbgw_context_map *map; |
Neels Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 178 | unsigned int map_count[2] = {}; |
| 179 | unsigned int state_count[2][MAP_S_NUM_STATES + 1] = {}; |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 180 | |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 181 | vty_out(vty, "HNB "); |
| 182 | vty_out_ofd_addr(vty, hnb->conn? osmo_stream_srv_get_ofd(hnb->conn) : NULL); |
| 183 | vty_out(vty, " \"%s\"%s", hnb->identity_info, VTY_NEWLINE); |
Neels Hofmeyr | 3bd8a55 | 2017-12-25 15:24:33 +0100 | [diff] [blame] | 184 | vty_out(vty, " MCC %u MNC %u LAC %u RAC %u SAC %u CID %u SCTP-stream:HNBAP=%u,RUA=%u%s", |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 185 | hnb->id.mcc, hnb->id.mnc, hnb->id.lac, hnb->id.rac, hnb->id.sac, hnb->id.cid, |
| 186 | hnb->hnbap_stream, hnb->rua_stream, VTY_NEWLINE); |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 187 | |
| 188 | llist_for_each_entry(map, &hnb->map_list, hnb_list) { |
Neels Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 189 | map_count[map->is_ps? 1 : 0]++; |
| 190 | state_count[map->is_ps? 1 : 0] |
| 191 | [(map->state >= 0 && map->state < MAP_S_NUM_STATES)? |
| 192 | map->state : MAP_S_NUM_STATES]++; |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 193 | } |
Neels Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 194 | vty_dump_hnb_info__map_states(vty, "IuCS", map_count[0], state_count[0]); |
| 195 | vty_dump_hnb_info__map_states(vty, "IuPS", map_count[1], state_count[1]); |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | static void vty_dump_ue_info(struct vty *vty, struct ue_context *ue) |
| 199 | { |
| 200 | vty_out(vty, "UE IMSI \"%s\" context ID %u%s", ue->imsi, ue->context_id, VTY_NEWLINE); |
| 201 | } |
| 202 | |
Stefan Sperling | 319c285 | 2018-10-29 18:19:14 +0100 | [diff] [blame] | 203 | DEFUN(show_hnb, show_hnb_cmd, "show hnb all", SHOW_STR "Display information about all HNB") |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 204 | { |
| 205 | struct hnb_context *hnb; |
Neels Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 206 | unsigned int count = 0; |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 207 | |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 208 | if (llist_empty(&g_hnb_gw->hnb_list)) { |
| 209 | vty_out(vty, "No HNB connected%s", VTY_NEWLINE); |
| 210 | return CMD_SUCCESS; |
| 211 | } |
| 212 | |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 213 | llist_for_each_entry(hnb, &g_hnb_gw->hnb_list, list) { |
| 214 | vty_dump_hnb_info(vty, hnb); |
Neels Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 215 | count++; |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 216 | } |
| 217 | |
Neels Hofmeyr | 9e17e05 | 2017-12-25 00:35:05 +0100 | [diff] [blame] | 218 | vty_out(vty, "%u HNB connected%s", count, VTY_NEWLINE); |
| 219 | |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 220 | return CMD_SUCCESS; |
| 221 | } |
| 222 | |
Stefan Sperling | 319c285 | 2018-10-29 18:19:14 +0100 | [diff] [blame] | 223 | DEFUN(show_one_hnb, show_one_hnb_cmd, "show hnb NAME ", SHOW_STR "Display information about a HNB") |
| 224 | { |
| 225 | struct hnb_context *hnb; |
| 226 | int found = 0; |
| 227 | const char *identity_info = argv[0]; |
| 228 | |
| 229 | if (llist_empty(&g_hnb_gw->hnb_list)) { |
| 230 | vty_out(vty, "No HNB connected%s", VTY_NEWLINE); |
| 231 | return CMD_SUCCESS; |
| 232 | } |
| 233 | |
| 234 | hnb = hnb_context_by_identity_info(&g_hnb_gw, identity_info); |
| 235 | if (hnb == NULL) { |
| 236 | vty_out(vty, "No HNB found with identity '%s'%s", identity_info, VTY_NEWLINE); |
| 237 | return CMD_SUCCESS; |
| 238 | } |
| 239 | |
| 240 | vty_dump_hnb_info(vty, hnb); |
| 241 | return CMD_SUCCESS; |
| 242 | } |
| 243 | |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 244 | DEFUN(show_ue, show_ue_cmd, "show ue all", SHOW_STR "Display information about a UE") |
| 245 | { |
| 246 | struct ue_context *ue; |
| 247 | |
| 248 | llist_for_each_entry(ue, &g_hnb_gw->ue_list, list) { |
| 249 | vty_dump_ue_info(vty, ue); |
| 250 | } |
| 251 | |
| 252 | return CMD_SUCCESS; |
| 253 | } |
| 254 | |
| 255 | DEFUN(show_talloc, show_talloc_cmd, "show talloc", SHOW_STR "Display talloc info") |
| 256 | { |
| 257 | talloc_report_full(tall_hnb_ctx, stderr); |
| 258 | talloc_report_full(talloc_asn1_ctx, stderr); |
| 259 | |
| 260 | return CMD_SUCCESS; |
| 261 | } |
| 262 | |
Neels Hofmeyr | da58d26 | 2017-12-25 00:01:37 +0100 | [diff] [blame] | 263 | DEFUN(cfg_hnbgw_rnc_id, cfg_hnbgw_rnc_id_cmd, |
| 264 | "rnc-id <0-65535>", |
| 265 | "Configure the HNBGW's RNC Id, the common RNC Id used for all connected hNodeB. It is sent to" |
| 266 | " each hNodeB upon HNBAP HNB-Register-Accept, and the hNodeB will subsequently send this as" |
| 267 | " RANAP InitialUE Messages' GlobalRNC-ID IE. Takes effect as soon as the hNodeB re-registers.\n" |
| 268 | "RNC Id value\n") |
| 269 | { |
| 270 | g_hnb_gw->config.rnc_id = atoi(argv[0]); |
| 271 | return CMD_SUCCESS; |
| 272 | } |
| 273 | |
Neels Hofmeyr | 39ee926 | 2016-09-26 01:07:19 +0200 | [diff] [blame] | 274 | DEFUN(cfg_hnbgw_iuh_local_ip, cfg_hnbgw_iuh_local_ip_cmd, "local-ip A.B.C.D", |
Neels Hofmeyr | f495b23 | 2016-08-18 02:18:00 +0200 | [diff] [blame] | 275 | "Accept Iuh connections on local interface\n" |
Neels Hofmeyr | c7ccdd4 | 2016-10-13 14:43:49 +0200 | [diff] [blame] | 276 | "Local interface IP address (default: " HNBGW_LOCAL_IP_DEFAULT ")") |
Neels Hofmeyr | f495b23 | 2016-08-18 02:18:00 +0200 | [diff] [blame] | 277 | { |
Neels Hofmeyr | c7ccdd4 | 2016-10-13 14:43:49 +0200 | [diff] [blame] | 278 | talloc_free((void*)g_hnb_gw->config.iuh_local_ip); |
| 279 | g_hnb_gw->config.iuh_local_ip = talloc_strdup(tall_hnb_ctx, argv[0]); |
Neels Hofmeyr | f495b23 | 2016-08-18 02:18:00 +0200 | [diff] [blame] | 280 | return CMD_SUCCESS; |
| 281 | } |
| 282 | |
Neels Hofmeyr | 9153de6 | 2016-10-13 15:11:07 +0200 | [diff] [blame] | 283 | DEFUN(cfg_hnbgw_iuh_local_port, cfg_hnbgw_iuh_local_port_cmd, "local-port <1-65535>", |
| 284 | "Accept Iuh connections on local port\n" |
| 285 | "Local interface port (default: 29169)") |
| 286 | { |
| 287 | g_hnb_gw->config.iuh_local_port = atoi(argv[0]); |
| 288 | return CMD_SUCCESS; |
| 289 | } |
| 290 | |
Neels Hofmeyr | 12181a9 | 2016-04-25 15:05:32 +0200 | [diff] [blame] | 291 | DEFUN(cfg_hnbgw_iuh_hnbap_allow_tmsi, cfg_hnbgw_iuh_hnbap_allow_tmsi_cmd, |
| 292 | "hnbap-allow-tmsi (0|1)", |
| 293 | "Allow HNBAP UE Register messages with TMSI or PTMSI identity\n" |
| 294 | "Only accept IMSI identity, reject TMSI or PTMSI\n" |
| 295 | "Accept IMSI, TMSI or PTMSI as UE identity\n") |
| 296 | { |
| 297 | g_hnb_gw->config.hnbap_allow_tmsi = (*argv[0] == '1'); |
| 298 | return CMD_SUCCESS; |
| 299 | } |
| 300 | |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 301 | DEFUN(cfg_hnbgw_iucs_remote_addr, |
| 302 | cfg_hnbgw_iucs_remote_addr_cmd, |
| 303 | "remote-addr NAME", |
| 304 | "SCCP address to send IuCS to (MSC)\n" |
| 305 | "SCCP address book entry name (see 'cs7-instance')\n") |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 306 | { |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 307 | g_hnb_gw->config.iucs_remote_addr_name = talloc_strdup(g_hnb_gw, argv[0]); |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 308 | return CMD_SUCCESS; |
| 309 | } |
| 310 | |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 311 | DEFUN(cfg_hnbgw_iups_remote_addr, |
| 312 | cfg_hnbgw_iups_remote_addr_cmd, |
| 313 | "remote-addr NAME", |
| 314 | "SCCP address to send IuPS to (SGSN)\n" |
| 315 | "SCCP address book entry name (see 'cs7-instance')\n") |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 316 | { |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 317 | g_hnb_gw->config.iups_remote_addr_name = talloc_strdup(g_hnb_gw, argv[0]); |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 318 | return CMD_SUCCESS; |
| 319 | } |
| 320 | |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 321 | static int config_write_hnbgw(struct vty *vty) |
| 322 | { |
| 323 | vty_out(vty, "hnbgw%s", VTY_NEWLINE); |
| 324 | return CMD_SUCCESS; |
| 325 | } |
| 326 | |
| 327 | static int config_write_hnbgw_iuh(struct vty *vty) |
| 328 | { |
Neels Hofmeyr | f495b23 | 2016-08-18 02:18:00 +0200 | [diff] [blame] | 329 | const char *addr; |
Neels Hofmeyr | 9153de6 | 2016-10-13 15:11:07 +0200 | [diff] [blame] | 330 | uint16_t port; |
Neels Hofmeyr | f495b23 | 2016-08-18 02:18:00 +0200 | [diff] [blame] | 331 | |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 332 | vty_out(vty, " iuh%s", VTY_NEWLINE); |
Neels Hofmeyr | f495b23 | 2016-08-18 02:18:00 +0200 | [diff] [blame] | 333 | |
Neels Hofmeyr | c7ccdd4 | 2016-10-13 14:43:49 +0200 | [diff] [blame] | 334 | addr = g_hnb_gw->config.iuh_local_ip; |
| 335 | if (addr && (strcmp(addr, HNBGW_LOCAL_IP_DEFAULT) != 0)) |
Neels Hofmeyr | 39ee926 | 2016-09-26 01:07:19 +0200 | [diff] [blame] | 336 | vty_out(vty, " local-ip %s%s", addr, VTY_NEWLINE); |
Neels Hofmeyr | f495b23 | 2016-08-18 02:18:00 +0200 | [diff] [blame] | 337 | |
Neels Hofmeyr | 9153de6 | 2016-10-13 15:11:07 +0200 | [diff] [blame] | 338 | port = g_hnb_gw->config.iuh_local_port; |
| 339 | if (port && port != IUH_DEFAULT_SCTP_PORT) |
| 340 | vty_out(vty, " local-port %u%s", port, VTY_NEWLINE); |
| 341 | |
Neels Hofmeyr | 12181a9 | 2016-04-25 15:05:32 +0200 | [diff] [blame] | 342 | if (g_hnb_gw->config.hnbap_allow_tmsi) |
| 343 | vty_out(vty, " hnbap-allow-tmsi 1%s", VTY_NEWLINE); |
| 344 | |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 345 | return CMD_SUCCESS; |
| 346 | } |
| 347 | |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 348 | static int config_write_hnbgw_iucs(struct vty *vty) |
| 349 | { |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 350 | if (!g_hnb_gw->config.iucs_remote_addr_name) |
| 351 | return CMD_SUCCESS; |
| 352 | |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 353 | vty_out(vty, " iucs%s", VTY_NEWLINE); |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 354 | vty_out(vty, " remote-addr %s%s", g_hnb_gw->config.iucs_remote_addr_name, |
| 355 | VTY_NEWLINE); |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 356 | |
| 357 | return CMD_SUCCESS; |
| 358 | } |
| 359 | |
| 360 | static int config_write_hnbgw_iups(struct vty *vty) |
| 361 | { |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 362 | if (!g_hnb_gw->config.iups_remote_addr_name) |
| 363 | return CMD_SUCCESS; |
| 364 | |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 365 | vty_out(vty, " iups%s", VTY_NEWLINE); |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 366 | vty_out(vty, " remote-addr %s%s", g_hnb_gw->config.iups_remote_addr_name, |
| 367 | VTY_NEWLINE); |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 368 | |
| 369 | return CMD_SUCCESS; |
| 370 | } |
| 371 | |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 372 | void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx) |
| 373 | { |
| 374 | g_hnb_gw = gw; |
| 375 | tall_hnb_ctx = tall_ctx; |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 376 | |
| 377 | install_element(CONFIG_NODE, &cfg_hnbgw_cmd); |
| 378 | install_node(&hnbgw_node, config_write_hnbgw); |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 379 | |
Neels Hofmeyr | da58d26 | 2017-12-25 00:01:37 +0100 | [diff] [blame] | 380 | install_element(HNBGW_NODE, &cfg_hnbgw_rnc_id_cmd); |
| 381 | |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 382 | install_element(HNBGW_NODE, &cfg_hnbgw_iuh_cmd); |
| 383 | install_node(&iuh_node, config_write_hnbgw_iuh); |
Neels Hofmeyr | 12181a9 | 2016-04-25 15:05:32 +0200 | [diff] [blame] | 384 | |
Neels Hofmeyr | 39ee926 | 2016-09-26 01:07:19 +0200 | [diff] [blame] | 385 | install_element(IUH_NODE, &cfg_hnbgw_iuh_local_ip_cmd); |
Neels Hofmeyr | 9153de6 | 2016-10-13 15:11:07 +0200 | [diff] [blame] | 386 | install_element(IUH_NODE, &cfg_hnbgw_iuh_local_port_cmd); |
Neels Hofmeyr | 12181a9 | 2016-04-25 15:05:32 +0200 | [diff] [blame] | 387 | install_element(IUH_NODE, &cfg_hnbgw_iuh_hnbap_allow_tmsi_cmd); |
Neels Hofmeyr | 926153b | 2016-08-18 02:15:56 +0200 | [diff] [blame] | 388 | |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 389 | install_element(HNBGW_NODE, &cfg_hnbgw_iucs_cmd); |
| 390 | install_node(&iucs_node, config_write_hnbgw_iucs); |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 391 | |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 392 | install_element(IUCS_NODE, &cfg_hnbgw_iucs_remote_addr_cmd); |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 393 | |
| 394 | install_element(HNBGW_NODE, &cfg_hnbgw_iups_cmd); |
| 395 | install_node(&iups_node, config_write_hnbgw_iups); |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 396 | |
Neels Hofmeyr | ecbdc5c | 2017-07-31 13:13:24 +0200 | [diff] [blame] | 397 | install_element(IUPS_NODE, &cfg_hnbgw_iups_remote_addr_cmd); |
Neels Hofmeyr | 5ee050c | 2016-10-13 15:12:18 +0200 | [diff] [blame] | 398 | |
Neels Hofmeyr | 140f38c | 2017-12-20 23:48:02 +0100 | [diff] [blame] | 399 | install_element_ve(&show_cnlink_cmd); |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 400 | install_element_ve(&show_hnb_cmd); |
Stefan Sperling | 319c285 | 2018-10-29 18:19:14 +0100 | [diff] [blame] | 401 | install_element_ve(&show_one_hnb_cmd); |
Neels Hofmeyr | 4d8eb4c | 2016-08-18 01:03:44 +0200 | [diff] [blame] | 402 | install_element_ve(&show_ue_cmd); |
| 403 | install_element_ve(&show_talloc_cmd); |
| 404 | } |