Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 1 | /* VTY code for the osmo-stp */ |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 2 | /* |
Holger Hans Peter Freyther | a310e53 | 2011-01-22 16:34:16 +0100 | [diff] [blame] | 3 | * (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 4 | * (C) 2010-2011 by On-Waves |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 5 | * All Rights Reserved |
| 6 | * |
Holger Hans Peter Freyther | de56c22 | 2011-01-16 17:45:14 +0100 | [diff] [blame] | 7 | * This program is free software: you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU Affero General Public License as published by |
| 9 | * the Free Software Foundation, either version 3 of the License, or |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Holger Hans Peter Freyther | de56c22 | 2011-01-16 17:45:14 +0100 | [diff] [blame] | 15 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 16 | * |
Holger Hans Peter Freyther | de56c22 | 2011-01-16 17:45:14 +0100 | [diff] [blame] | 17 | * You should have received a copy of the GNU Affero General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <bsc_data.h> |
Holger Hans Peter Freyther | 5b2fe8d | 2011-01-22 21:09:53 +0100 | [diff] [blame] | 23 | #include <mtp_pcap.h> |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 24 | #include <msc_connection.h> |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 25 | #include <sctp_m2ua.h> |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 26 | #include <ss7_application.h> |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 27 | #include <ss7_vty.h> |
| 28 | #include <cellmgr_debug.h> |
| 29 | #include <snmp_mtp.h> |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 30 | |
Harald Welte | ff397ed | 2011-05-08 10:29:23 +0200 | [diff] [blame] | 31 | #include <osmocom/core/talloc.h> |
| 32 | #include <osmocom/gsm/gsm48.h> |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 33 | |
| 34 | #include <osmocom/vty/command.h> |
Holger Hans Peter Freyther | fca7b12 | 2011-01-22 23:19:44 +0100 | [diff] [blame] | 35 | #include <osmocom/vty/logging.h> |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 36 | #include <osmocom/vty/vty.h> |
| 37 | |
| 38 | #include <unistd.h> |
| 39 | #include <netdb.h> |
| 40 | |
| 41 | #undef PACKAGE_NAME |
| 42 | #undef PACKAGE_VERSION |
| 43 | #undef PACKAGE_BUGREPORT |
| 44 | #undef PACKAGE_TARNAME |
| 45 | #undef PACKAGE_STRING |
| 46 | #include <cellmgr_config.h> |
| 47 | |
Holger Hans Peter Freyther | 2ff47b8 | 2011-02-15 20:25:10 +0100 | [diff] [blame] | 48 | extern struct bsc_data *bsc; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 49 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 50 | static enum node_type ss7_go_parent(struct vty *vty) |
| 51 | { |
| 52 | switch (vty->node) { |
| 53 | case LINK_NODE: |
| 54 | vty->node = LINKSETS_NODE; |
| 55 | { |
| 56 | struct mtp_link *lnk = vty->index; |
| 57 | vty->index = lnk->set; |
| 58 | vty->index_sub = &lnk->set->name; |
| 59 | } |
| 60 | break; |
| 61 | case MSC_NODE: |
| 62 | case APP_NODE: |
| 63 | case LINKSETS_NODE: |
| 64 | vty->node = SS7_NODE; |
| 65 | vty->index = NULL; |
| 66 | vty->index_sub = NULL; |
| 67 | break; |
| 68 | case SS7_NODE: |
| 69 | default: |
| 70 | vty->node = CONFIG_NODE; |
| 71 | vty->index = NULL; |
| 72 | vty->index_sub = NULL; |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | return vty->node; |
| 77 | } |
| 78 | |
| 79 | |
| 80 | DEFUN(node_exit, node_exit_cmd, |
| 81 | "exit", "Exit the current node\n") |
| 82 | { |
| 83 | ss7_go_parent(vty); |
| 84 | return CMD_SUCCESS; |
| 85 | } |
| 86 | |
| 87 | DEFUN(node_end, node_end_cmd, |
| 88 | "end", "End the current mode and change to the enable node\n") |
| 89 | { |
| 90 | switch (vty->node) { |
| 91 | case VIEW_NODE: |
| 92 | case ENABLE_NODE: |
| 93 | break; |
| 94 | default: |
| 95 | vty_config_unlock(vty); |
| 96 | vty->node = ENABLE_NODE; |
| 97 | vty->index = NULL; |
| 98 | vty->index_sub = NULL; |
| 99 | break; |
| 100 | } |
| 101 | return CMD_SUCCESS; |
| 102 | } |
| 103 | |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 104 | static struct vty_app_info vty_info = { |
| 105 | .name = "Cellmgr-ng", |
| 106 | .version = VERSION, |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 107 | .go_parent_cb = ss7_go_parent, |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | /* vty code */ |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 111 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 112 | static struct cmd_node ss7_node = { |
| 113 | SS7_NODE, |
| 114 | "%s(ss7)#", |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 115 | 1, |
| 116 | }; |
| 117 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 118 | static struct cmd_node linkset_node = { |
| 119 | LINKSETS_NODE, |
| 120 | "%s(linkset)#", |
| 121 | 1, |
| 122 | }; |
| 123 | |
| 124 | static struct cmd_node link_node = { |
| 125 | LINK_NODE, |
| 126 | "%s(link)#", |
| 127 | 1, |
| 128 | }; |
| 129 | |
| 130 | static struct cmd_node msc_node = { |
| 131 | MSC_NODE, |
| 132 | "%s(msc)#", |
| 133 | 1, |
| 134 | }; |
| 135 | |
| 136 | static struct cmd_node app_node = { |
| 137 | APP_NODE, |
| 138 | "%s(application)#", |
| 139 | 1, |
| 140 | }; |
| 141 | |
| 142 | static int dummy_write(struct vty *vty) |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 143 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 144 | return CMD_SUCCESS; |
| 145 | } |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 146 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 147 | static int config_write_ss7(struct vty *vty) |
| 148 | { |
| 149 | vty_out(vty, "ss7%s", VTY_NEWLINE); |
| 150 | vty_out(vty, " udp src-port %d%s", bsc->udp_src_port, VTY_NEWLINE); |
| 151 | vty_out(vty, " m2ua src-port %d%s", bsc->m2ua_src_port, VTY_NEWLINE); |
| 152 | return CMD_SUCCESS; |
| 153 | } |
Holger Hans Peter Freyther | 2656e8f | 2010-09-30 00:41:37 +0800 | [diff] [blame] | 154 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 155 | static void write_link(struct vty *vty, struct mtp_link *link) |
| 156 | { |
| 157 | const char *name = link->name ? link->name : ""; |
| 158 | struct mtp_udp_link *ulnk; |
| 159 | struct mtp_m2ua_link *m2ua; |
| 160 | |
| 161 | vty_out(vty, " link %d%s", link->nr, VTY_NEWLINE); |
| 162 | vty_out(vty, " description %s%s", name, VTY_NEWLINE); |
| 163 | |
| 164 | switch (link->type) { |
| 165 | case SS7_LTYPE_UDP: |
| 166 | ulnk = (struct mtp_udp_link *) link->data; |
| 167 | vty_out(vty, " ss7-transport udp%s", VTY_NEWLINE); |
| 168 | vty_out(vty, " udp dest ip %s%s", |
| 169 | inet_ntoa(ulnk->remote.sin_addr), VTY_NEWLINE); |
| 170 | vty_out(vty, " udp dest port %d%s", |
| 171 | ntohs(ulnk->remote.sin_port), VTY_NEWLINE); |
| 172 | vty_out(vty, " udp reset-timeout %d%s", |
| 173 | ulnk->reset_timeout, VTY_NEWLINE); |
| 174 | vty_out(vty, " udp link-index %d%s", |
| 175 | ulnk->link_index, VTY_NEWLINE); |
| 176 | break; |
| 177 | case SS7_LTYPE_M2UA: |
| 178 | m2ua = (struct mtp_m2ua_link *) link->data; |
| 179 | vty_out(vty, " ss7-transport m2ua%s", VTY_NEWLINE); |
| 180 | |
| 181 | if (m2ua->as) |
| 182 | vty_out(vty, " m2ua application-server %s%s", |
| 183 | m2ua->as, VTY_NEWLINE); |
| 184 | vty_out(vty, " m2ua link-index %d%s", |
| 185 | m2ua->link_index, VTY_NEWLINE); |
| 186 | break; |
| 187 | case SS7_LTYPE_NONE: |
| 188 | break; |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | static void write_linkset(struct vty *vty, struct mtp_link_set *set) |
| 193 | { |
| 194 | const char *name = set->name ? set->name : ""; |
| 195 | struct mtp_link *link; |
| 196 | int i; |
| 197 | |
| 198 | vty_out(vty, " linkset %d%s", set->nr, VTY_NEWLINE); |
| 199 | vty_out(vty, " description %s%s", name, VTY_NEWLINE); |
| 200 | vty_out(vty, " mtp3 dpc %d%s", set->dpc, VTY_NEWLINE); |
| 201 | vty_out(vty, " mtp3 opc %d%s", set->opc, VTY_NEWLINE); |
| 202 | vty_out(vty, " mtp3 ni %d%s", set->ni, VTY_NEWLINE); |
| 203 | vty_out(vty, " mtp3 spare %d%s", set->spare, VTY_NEWLINE); |
| 204 | vty_out(vty, " mtp3 sltm-once %d%s", set->sltm_once, VTY_NEWLINE); |
Holger Hans Peter Freyther | 47c9faa | 2011-02-23 11:25:45 +0100 | [diff] [blame] | 205 | vty_out(vty, " mtp3 timeout t18 %d%s", |
| 206 | set->timeout_t18, VTY_NEWLINE); |
| 207 | vty_out(vty, " mtp3 timeout t20 %d%s", |
| 208 | set->timeout_t20, VTY_NEWLINE); |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 209 | |
| 210 | for (i = 0; i < ARRAY_SIZE(set->supported_ssn); ++i) { |
| 211 | if (!set->supported_ssn[i]) |
| 212 | continue; |
| 213 | vty_out(vty, " mtp3 ssn %d%s", i, VTY_NEWLINE); |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 214 | } |
| 215 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 216 | llist_for_each_entry(link, &set->links, entry) |
| 217 | write_link(vty, link); |
| 218 | } |
| 219 | |
| 220 | static int config_write_linkset(struct vty *vty) |
| 221 | { |
| 222 | struct mtp_link_set *set; |
| 223 | |
| 224 | llist_for_each_entry(set, &bsc->linksets, entry) |
| 225 | write_linkset(vty, set); |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 226 | |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 227 | return CMD_SUCCESS; |
| 228 | } |
| 229 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 230 | static void write_msc(struct vty *vty, struct msc_connection *msc) |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 231 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 232 | const char *name = msc->name ? msc->name : ""; |
| 233 | |
| 234 | vty_out(vty, " msc %d%s", msc->nr, VTY_NEWLINE); |
| 235 | vty_out(vty, " description %s%s", name, VTY_NEWLINE); |
| 236 | vty_out(vty, " ip %s%s", msc->ip, VTY_NEWLINE); |
| 237 | vty_out(vty, " token %s%s", msc->token, VTY_NEWLINE); |
| 238 | vty_out(vty, " dscp %d%s", msc->dscp, VTY_NEWLINE); |
| 239 | vty_out(vty, " timeout ping %d%s", msc->ping_time, VTY_NEWLINE); |
| 240 | vty_out(vty, " timeout pong %d%s", msc->pong_time, VTY_NEWLINE); |
| 241 | vty_out(vty, " timeout restart %d%s", msc->msc_time, VTY_NEWLINE); |
| 242 | } |
| 243 | |
| 244 | static int config_write_msc(struct vty *vty) |
| 245 | { |
| 246 | struct msc_connection *msc; |
| 247 | |
| 248 | llist_for_each_entry(msc, &bsc->mscs, entry) |
| 249 | write_msc(vty, msc); |
| 250 | return 0; |
| 251 | } |
| 252 | |
| 253 | static const char *app_type(enum ss7_app_type type) |
| 254 | { |
| 255 | switch (type) { |
| 256 | case APP_NONE: |
| 257 | return "none"; |
| 258 | case APP_CELLMGR: |
| 259 | return "msc"; |
| 260 | case APP_RELAY: |
| 261 | return "relay"; |
| 262 | case APP_STP: |
| 263 | return "stp"; |
| 264 | default: |
| 265 | LOGP(DINP, LOGL_ERROR, "Should no be reached.\n"); |
| 266 | return ""; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | static const char *link_type(enum ss7_set_type type) |
| 271 | { |
| 272 | switch (type) { |
| 273 | case SS7_SET_LINKSET: |
| 274 | return "linkset"; |
| 275 | case SS7_SET_MSC: |
| 276 | return "msc"; |
| 277 | default: |
| 278 | LOGP(DINP, LOGL_ERROR, "Should no be reached.\n"); |
| 279 | return ""; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | static void write_application(struct vty *vty, struct ss7_application *app) |
| 284 | { |
| 285 | const char *name = app->name ? app->name : ""; |
| 286 | |
| 287 | vty_out(vty, " application %d%s", app->nr, VTY_NEWLINE); |
| 288 | vty_out(vty, " description %s%s", name, VTY_NEWLINE); |
| 289 | vty_out(vty, " type %s%s", app_type(app->type), VTY_NEWLINE); |
| 290 | |
| 291 | if (app->type == APP_STP) |
| 292 | vty_out(vty, " isup-pass-through %d%s", app->isup_pass, VTY_NEWLINE); |
| 293 | |
Holger Hans Peter Freyther | fc98ce2 | 2011-09-13 20:08:57 +0200 | [diff] [blame^] | 294 | if (app->type == APP_CELLMGR && app->mgcp_domain_name) { |
| 295 | vty_out(vty, " domain-name %s%s", |
| 296 | app->mgcp_domain_name, VTY_NEWLINE); |
| 297 | } |
| 298 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 299 | if (app->route_is_set) { |
| 300 | vty_out(vty, " route %s %d %s %d%s", |
| 301 | link_type(app->route_src.type), app->route_src.nr, |
| 302 | link_type(app->route_dst.type), app->route_dst.nr, |
| 303 | VTY_NEWLINE); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | static int config_write_app(struct vty *vty) |
| 308 | { |
| 309 | struct ss7_application *app; |
| 310 | |
| 311 | llist_for_each_entry(app, &bsc->apps, entry) |
| 312 | write_application(vty, app); |
| 313 | |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 314 | return CMD_SUCCESS; |
| 315 | } |
| 316 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 317 | DEFUN(cfg_ss7, cfg_ss7_cmd, |
| 318 | "ss7", "Configure the application\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 319 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 320 | vty->node = SS7_NODE; |
| 321 | return CMD_SUCCESS; |
| 322 | } |
| 323 | |
| 324 | DEFUN(cfg_ss7_udp_src_port, cfg_ss7_udp_src_port_cmd, |
| 325 | "udp src-port <1-65535>", |
| 326 | "UDP related commands\n" |
| 327 | "Source port for SS7 via UDP transport\n" |
| 328 | "Port to bind to\n") |
| 329 | { |
| 330 | bsc->udp_src_port = atoi(argv[0]); |
| 331 | return CMD_SUCCESS; |
| 332 | } |
| 333 | |
| 334 | DEFUN(cfg_ss7_m2ua_src_port, cfg_ss7_m2ua_src_port_cmd, |
| 335 | "m2ua src-port <1-65535>", |
| 336 | "M2UA related commands\n" |
| 337 | "Source port for SS7 via M2UA\n" |
| 338 | "Port to bind to\n") |
| 339 | { |
| 340 | bsc->m2ua_src_port = atoi(argv[0]); |
| 341 | return CMD_SUCCESS; |
| 342 | } |
| 343 | |
| 344 | DEFUN(cfg_ss7_linkset, cfg_ss7_linkset_cmd, |
| 345 | "linkset <0-100>", |
| 346 | "Linkset commands\n" "Linkset number\n") |
| 347 | { |
| 348 | struct mtp_link_set *set; |
| 349 | int nr; |
| 350 | |
| 351 | nr = atoi(argv[0]); |
| 352 | if (nr > bsc->num_linksets) { |
| 353 | vty_out(vty, "%% The next unused Linkset number is %u%s", |
| 354 | bsc->num_linksets, VTY_NEWLINE); |
| 355 | return CMD_WARNING; |
| 356 | } else if (nr == bsc->num_linksets) { |
| 357 | set = mtp_link_set_alloc(bsc); |
| 358 | } else |
| 359 | set = mtp_link_set_num(bsc, nr); |
| 360 | |
| 361 | if (!set) { |
| 362 | vty_out(vty, "%% Unable to allocate Linkset %u%s", |
| 363 | nr, VTY_NEWLINE); |
| 364 | return CMD_WARNING; |
| 365 | } |
| 366 | |
| 367 | vty->node = LINKSETS_NODE; |
| 368 | vty->index = set; |
| 369 | vty->index_sub = &set->name; |
| 370 | return CMD_SUCCESS; |
| 371 | } |
| 372 | |
| 373 | DEFUN(cfg_linkset_mtp3_dpc, cfg_linkset_mtp3_dpc_cmd, |
Holger Hans Peter Freyther | af3faf8 | 2011-02-23 16:59:45 +0100 | [diff] [blame] | 374 | "mtp3 dpc <0-8191>", |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 375 | "MTP Level3\n" "Destination Point Code\n" "Point Code\n") |
| 376 | { |
| 377 | struct mtp_link_set *set = vty->index; |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 378 | set->dpc = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 379 | return CMD_SUCCESS; |
| 380 | } |
| 381 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 382 | DEFUN(cfg_linkset_mtp3_opc, cfg_linkset_mtp3_opc_cmd, |
Holger Hans Peter Freyther | af3faf8 | 2011-02-23 16:59:45 +0100 | [diff] [blame] | 383 | "mtp3 opc <0-8191>", |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 384 | "MTP Level3\n" "Originating Point Code\n" "Point Code\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 385 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 386 | struct mtp_link_set *set = vty->index; |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 387 | set->opc = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 388 | return CMD_SUCCESS; |
| 389 | } |
| 390 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 391 | DEFUN(cfg_linkset_mtp3_ni, cfg_linkset_mtp3_ni_cmd, |
| 392 | "mtp3 ni <0-3>", |
| 393 | "MTP Level3\n" "NI for the address\n" "NI\n") |
Holger Hans Peter Freyther | 7a72556 | 2011-01-01 13:34:58 +0100 | [diff] [blame] | 394 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 395 | struct mtp_link_set *set = vty->index; |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 396 | set->ni = atoi(argv[0]); |
Holger Hans Peter Freyther | b38b33b | 2010-11-26 21:21:04 +0100 | [diff] [blame] | 397 | return CMD_SUCCESS; |
| 398 | } |
| 399 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 400 | DEFUN(cfg_linkset_mtp3_spare, cfg_linkset_mtp3_spare_cmd, |
| 401 | "mtp3 spare <0-3>", |
| 402 | "MTP Level3\n" "Spare for the address\n" "Spare\n") |
Holger Hans Peter Freyther | b38b33b | 2010-11-26 21:21:04 +0100 | [diff] [blame] | 403 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 404 | struct mtp_link_set *set = vty->index; |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 405 | set->spare = atoi(argv[0]); |
Holger Hans Peter Freyther | b38b33b | 2010-11-26 21:21:04 +0100 | [diff] [blame] | 406 | return CMD_SUCCESS; |
| 407 | } |
| 408 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 409 | DEFUN(cfg_linkset_mtp3_ssn, cfg_linkset_mtp3_ssn_cmd, |
| 410 | "mtp3 ssn <0-255>", |
| 411 | "MTP Level3\n" "SSN supported\n" "SSN\n") |
| 412 | { |
| 413 | struct mtp_link_set *set = vty->index; |
| 414 | set->supported_ssn[atoi(argv[0])] = 1; |
| 415 | return CMD_SUCCESS; |
| 416 | } |
Holger Hans Peter Freyther | b38b33b | 2010-11-26 21:21:04 +0100 | [diff] [blame] | 417 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 418 | DEFUN(cfg_linkset_no_mtp3_ssn, cfg_linkset_no_mtp3_ssn_cmd, |
| 419 | "no mtp3 ssn <0-255>", |
| 420 | "MTP Level3\n" "SSN supported\n" "SSN\n") |
| 421 | { |
| 422 | struct mtp_link_set *set = vty->index; |
| 423 | set->supported_ssn[atoi(argv[0])] = 0; |
| 424 | return CMD_SUCCESS; |
| 425 | } |
| 426 | |
| 427 | DEFUN(cfg_linkset_sltm_once, cfg_linkset_sltm_once_cmd, |
| 428 | "mtp3 sltm-once (0|1)", |
| 429 | "MTP Level3\n" "Test the link once\n" "Continous testing\n" "Test once\n") |
| 430 | { |
| 431 | struct mtp_link_set *set = vty->index; |
| 432 | set->sltm_once = !!atoi(argv[0]); |
| 433 | |
| 434 | return CMD_SUCCESS; |
| 435 | } |
| 436 | |
Holger Hans Peter Freyther | 47c9faa | 2011-02-23 11:25:45 +0100 | [diff] [blame] | 437 | DEFUN(cfg_linkset_t18, cfg_linkset_t18_cmd, |
| 438 | "mtp3 timeout t18 <0-1000>", |
| 439 | "MTP Level3\n" "Timeouts\n" "T18 link restart timeout\n" "Seconds\n") |
| 440 | { |
| 441 | struct mtp_link_set *set = vty->index; |
| 442 | set->timeout_t18 = atoi(argv[0]); |
| 443 | return CMD_SUCCESS; |
| 444 | } |
| 445 | |
| 446 | DEFUN(cfg_linkset_t20, cfg_linkset_t20_cmd, |
| 447 | "mtp3 timeout t20 <0-1000>", |
| 448 | "MTP Level3\n" "Timeouts\n" "T20 link restart timeout\n" "Seconds\n") |
| 449 | { |
| 450 | struct mtp_link_set *set = vty->index; |
| 451 | set->timeout_t20 = atoi(argv[0]); |
| 452 | return CMD_SUCCESS; |
| 453 | } |
| 454 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 455 | DEFUN(cfg_linkset_link, cfg_linkset_link_cmd, |
| 456 | "link <0-100>", |
| 457 | "Link\n" "Link number\n") |
| 458 | { |
| 459 | struct mtp_link_set *set = vty->index; |
| 460 | |
| 461 | struct mtp_link *lnk; |
| 462 | int nr; |
| 463 | |
| 464 | nr = atoi(argv[0]); |
| 465 | if (nr > set->nr_links) { |
| 466 | vty_out(vty, "%% The next unused Link number is %u%s", |
| 467 | set->nr_links, VTY_NEWLINE); |
| 468 | return CMD_WARNING; |
| 469 | } else if (nr == set->nr_links) { |
| 470 | lnk = mtp_link_alloc(set); |
| 471 | } else |
| 472 | lnk = mtp_link_num(set, nr); |
| 473 | |
| 474 | if (!set) { |
| 475 | vty_out(vty, "%% Unable to allocate Link %u%s", |
| 476 | nr, VTY_NEWLINE); |
| 477 | return CMD_WARNING; |
| 478 | } |
| 479 | |
| 480 | vty->node = LINK_NODE; |
| 481 | vty->index = lnk; |
| 482 | vty->index_sub = &lnk->name; |
| 483 | return CMD_SUCCESS; |
| 484 | } |
| 485 | |
| 486 | DEFUN(cfg_link_ss7_transport, cfg_link_ss7_transport_cmd, |
| 487 | "ss7-transport (none|udp|m2ua)", |
| 488 | "SS7 transport for the link\n" |
| 489 | "No transport\n" "MTP over UDP\n" "SCTP M2UA\n") |
| 490 | { |
| 491 | int wanted = SS7_LTYPE_NONE; |
| 492 | struct mtp_link *link; |
| 493 | |
| 494 | link = vty->index; |
| 495 | |
| 496 | if (strcmp("udp", argv[0]) == 0) |
| 497 | wanted = SS7_LTYPE_UDP; |
| 498 | else if (strcmp("m2ua", argv[0]) == 0) |
| 499 | wanted = SS7_LTYPE_M2UA; |
| 500 | |
| 501 | if (link->type != wanted && link->type != SS7_LTYPE_NONE) { |
| 502 | vty_out(vty, "%%Can not change the type of a link.\n"); |
| 503 | return CMD_WARNING; |
| 504 | } |
| 505 | |
| 506 | switch (wanted) { |
| 507 | case SS7_LTYPE_UDP: |
| 508 | link->data = mtp_udp_link_init(link); |
| 509 | break; |
| 510 | case SS7_LTYPE_M2UA: |
| 511 | link->data = mtp_m2ua_link_init(link); |
| 512 | break; |
| 513 | case SS7_LTYPE_NONE: |
| 514 | /* nothing */ |
| 515 | break; |
| 516 | } |
| 517 | |
| 518 | if (!link->data) { |
| 519 | vty_out(vty, "Failed to allocate the link type.%s", VTY_NEWLINE); |
| 520 | return CMD_WARNING; |
| 521 | } |
| 522 | |
| 523 | return CMD_SUCCESS; |
| 524 | } |
| 525 | |
| 526 | DEFUN(cfg_link_udp_dest_ip, cfg_link_udp_dest_ip_cmd, |
| 527 | "udp dest ip HOST_NAME", |
| 528 | "UDP Transport\n" "IP\n" "Hostname\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 529 | { |
| 530 | struct hostent *hosts; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 531 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 532 | struct mtp_link *link = vty->index; |
| 533 | struct mtp_udp_link *ulnk; |
| 534 | |
| 535 | if (link->type != SS7_LTYPE_UDP) { |
| 536 | vty_out(vty, "%%This only applies to UDP links.%s", VTY_NEWLINE); |
| 537 | return CMD_WARNING; |
| 538 | } |
| 539 | |
| 540 | ulnk = link->data; |
| 541 | |
| 542 | if (ulnk->dest) |
| 543 | talloc_free(ulnk->dest); |
| 544 | ulnk->dest = talloc_strdup(ulnk, argv[0]); |
| 545 | |
| 546 | hosts = gethostbyname(ulnk->dest); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 547 | if (!hosts || hosts->h_length < 1 || hosts->h_addrtype != AF_INET) { |
| 548 | vty_out(vty, "Failed to resolve '%s'%s", argv[0], VTY_NEWLINE); |
| 549 | return CMD_WARNING; |
| 550 | } |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 551 | ulnk->remote.sin_addr = * (struct in_addr *) hosts->h_addr_list[0]; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 552 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 553 | if (snmp_mtp_peer_name(ulnk->session, ulnk->dest) != 0) { |
| 554 | vty_out(vty, "%%Failed to open SNMP port on link %d.%s", |
| 555 | link->nr, VTY_NEWLINE); |
| 556 | return CMD_WARNING; |
| 557 | } |
| 558 | |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 559 | return CMD_SUCCESS; |
| 560 | } |
| 561 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 562 | DEFUN(cfg_link_udp_dest_port, cfg_link_udp_dest_port_cmd, |
| 563 | "udp dest port <1-65535>", |
| 564 | "UDP Transport\n" "Set the port number\n" "Port\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 565 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 566 | struct mtp_link *link = vty->index; |
| 567 | struct mtp_udp_link *ulnk; |
| 568 | |
| 569 | if (link->type != SS7_LTYPE_UDP) { |
| 570 | vty_out(vty, "%%This only applies to UDP links.%s", VTY_NEWLINE); |
| 571 | return CMD_WARNING; |
| 572 | } |
| 573 | |
| 574 | ulnk = link->data; |
| 575 | ulnk->remote.sin_port = htons(atoi(argv[0])); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 576 | return CMD_SUCCESS; |
| 577 | } |
| 578 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 579 | DEFUN(cfg_link_udp_reset, cfg_link_udp_reset_cmd, |
| 580 | "udp reset-timeout <1-65535>", |
| 581 | "UDP Transport\n" "Reset timeout after a failure\n" "Seconds\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 582 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 583 | struct mtp_link *link = vty->index; |
| 584 | struct mtp_udp_link *ulnk; |
| 585 | |
| 586 | if (link->type != SS7_LTYPE_UDP) { |
| 587 | vty_out(vty, "%%This only applies to UDP links.%s", VTY_NEWLINE); |
| 588 | return CMD_WARNING; |
| 589 | } |
| 590 | |
| 591 | ulnk = link->data; |
| 592 | ulnk->reset_timeout = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 593 | return CMD_SUCCESS; |
| 594 | } |
| 595 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 596 | DEFUN(cfg_link_udp_link_index, cfg_link_udp_link_index_cmd, |
| 597 | "udp link-index <0-65535>", |
| 598 | "UDP Transport\n" "Link index\n" "Index\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 599 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 600 | struct mtp_link *link = vty->index; |
| 601 | struct mtp_udp_link *ulnk; |
| 602 | |
| 603 | if (link->type != SS7_LTYPE_UDP) { |
| 604 | vty_out(vty, "%%This only applies to UDP links.%s", VTY_NEWLINE); |
| 605 | return CMD_WARNING; |
| 606 | } |
| 607 | |
| 608 | ulnk = link->data; |
| 609 | ulnk->link_index = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 610 | return CMD_SUCCESS; |
| 611 | } |
| 612 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 613 | DEFUN(cfg_link_m2ua_as, cfg_link_m2ua_as_cmd, |
| 614 | "m2ua application-server NAME", |
| 615 | "M2UA Transport\n" "Application Server Name\n" "Name\n") |
Holger Hans Peter Freyther | c6bfa27 | 2011-01-22 17:06:34 +0100 | [diff] [blame] | 616 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 617 | struct mtp_link *link = vty->index; |
| 618 | struct mtp_m2ua_link *m2ua; |
| 619 | |
| 620 | if (link->type != SS7_LTYPE_M2UA) { |
| 621 | vty_out(vty, "%%This only applies to M2UA links.%s", VTY_NEWLINE); |
| 622 | return CMD_WARNING; |
| 623 | } |
| 624 | |
| 625 | m2ua = link->data; |
| 626 | if (m2ua->as) |
| 627 | talloc_free(m2ua->as); |
| 628 | m2ua->as = talloc_strdup(m2ua, argv[0]); |
Holger Hans Peter Freyther | c6bfa27 | 2011-01-22 17:06:34 +0100 | [diff] [blame] | 629 | return CMD_SUCCESS; |
| 630 | } |
| 631 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 632 | DEFUN(cfg_link_m2ua_link_index, cfg_link_m2ua_link_index_cmd, |
| 633 | "m2ua link-index <0-65535>", |
| 634 | "M2UA Transport\n" "Link index\n" "Index\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 635 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 636 | struct mtp_link *link = vty->index; |
| 637 | struct mtp_m2ua_link *m2ua; |
| 638 | |
| 639 | if (link->type != SS7_LTYPE_M2UA) { |
| 640 | vty_out(vty, "%%This only applies to M2UA links.%s", VTY_NEWLINE); |
| 641 | return CMD_WARNING; |
| 642 | } |
| 643 | |
| 644 | m2ua = link->data; |
| 645 | m2ua->link_index = atoi(argv[0]); |
| 646 | return CMD_SUCCESS; |
| 647 | } |
| 648 | |
| 649 | DEFUN(cfg_ss7_msc, cfg_ss7_msc_cmd, |
| 650 | "msc <0-100>", |
| 651 | "MSC Connection\n" "MSC Number\n") |
| 652 | { |
| 653 | struct msc_connection *msc; |
| 654 | int nr; |
| 655 | |
| 656 | nr = atoi(argv[0]); |
| 657 | if (nr > bsc->num_mscs) { |
| 658 | vty_out(vty, "%% The next unused MSC number is %u%s", |
| 659 | bsc->num_mscs, VTY_NEWLINE); |
| 660 | return CMD_WARNING; |
| 661 | } else if (nr == bsc->num_mscs) { |
| 662 | msc = msc_connection_create(bsc, 1); |
| 663 | } else |
| 664 | msc = msc_connection_num(bsc, nr); |
| 665 | |
| 666 | if (!msc) { |
| 667 | vty_out(vty, "%% Unable to allocate MSC %u%s", |
| 668 | nr, VTY_NEWLINE); |
| 669 | return CMD_WARNING; |
| 670 | } |
| 671 | |
| 672 | vty->node = MSC_NODE; |
| 673 | vty->index = msc; |
| 674 | vty->index_sub = &msc->name; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 675 | return CMD_SUCCESS; |
| 676 | } |
| 677 | |
| 678 | DEFUN(cfg_msc_ip, cfg_msc_ip_cmd, |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 679 | "ip ADDR", |
| 680 | "IP Address of the MSC\n" "Address\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 681 | { |
| 682 | struct hostent *hosts; |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 683 | struct msc_connection *msc; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 684 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 685 | msc = vty->index; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 686 | hosts = gethostbyname(argv[0]); |
| 687 | if (!hosts || hosts->h_length < 1 || hosts->h_addrtype != AF_INET) { |
| 688 | vty_out(vty, "Failed to resolve '%s'%s", argv[0], VTY_NEWLINE); |
| 689 | return CMD_WARNING; |
| 690 | } |
| 691 | |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 692 | if (msc->ip) |
| 693 | talloc_free(msc->ip); |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 694 | |
| 695 | msc->ip = talloc_strdup(msc, |
| 696 | inet_ntoa(*((struct in_addr *) hosts->h_addr_list[0]))); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 697 | return CMD_SUCCESS; |
| 698 | } |
| 699 | |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 700 | DEFUN(cfg_msc_token, cfg_msc_token_cmd, |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 701 | "token TOKEN", |
| 702 | "Token for the MSC\n" "The token\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 703 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 704 | struct msc_connection *msc = vty->index; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 705 | |
| 706 | if (msc->token) |
| 707 | talloc_free(msc->token); |
| 708 | msc->token = talloc_strdup(msc, argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 709 | return CMD_SUCCESS; |
| 710 | } |
| 711 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 712 | DEFUN(cfg_msc_dscp, cfg_msc_dscp_cmd, |
| 713 | "dscp <0-255>", |
| 714 | "DSCP for the IP Connection\n" "Nr\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 715 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 716 | struct msc_connection *msc = vty->index; |
| 717 | msc->dscp = atoi(argv[0]); |
| 718 | return CMD_SUCCESS; |
| 719 | } |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 720 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 721 | DEFUN(cfg_msc_timeout_ping, cfg_msc_timeout_ping_cmd, |
| 722 | "timeout ping <1-65535>", |
| 723 | "Timeout commands\n" "Time between pings\n" "Seconds\n") |
| 724 | { |
| 725 | struct msc_connection *msc = vty->index; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 726 | msc->ping_time = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 727 | return CMD_SUCCESS; |
| 728 | } |
| 729 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 730 | DEFUN(cfg_msc_timeout_pong, cfg_msc_timeout_pong_cmd, |
| 731 | "timeout pong <1-65535>", |
| 732 | "Timeout commands\n" "Time between pongs\n" "Seconds\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 733 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 734 | struct msc_connection *msc = vty->index; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 735 | msc->pong_time = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 736 | return CMD_SUCCESS; |
| 737 | } |
| 738 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 739 | DEFUN(cfg_msc_timeout_restart, cfg_msc_timeout_restart_cmd, |
| 740 | "timeout restart <1-65535>", |
| 741 | "Timeout commands\n" "Time between restarts\n" "Seconds\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 742 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 743 | struct msc_connection *msc = vty->index; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 744 | msc->msc_time = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 745 | return CMD_SUCCESS; |
| 746 | } |
| 747 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 748 | DEFUN(cfg_ss7_app, cfg_ss7_app_cmd, |
| 749 | "application <0-100>", |
| 750 | "Application Commands\n" "Number\n") |
Holger Hans Peter Freyther | f603f28 | 2011-01-30 00:24:15 +0100 | [diff] [blame] | 751 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 752 | struct ss7_application *app; |
| 753 | int nr; |
| 754 | |
| 755 | nr = atoi(argv[0]); |
| 756 | if (nr > bsc->num_apps) { |
| 757 | vty_out(vty, "%% The next unused Application number is %u%s", |
| 758 | bsc->num_apps, VTY_NEWLINE); |
| 759 | return CMD_WARNING; |
| 760 | } else if (nr == bsc->num_apps) { |
| 761 | app = ss7_application_alloc(bsc); |
| 762 | } else |
| 763 | app = ss7_application_num(bsc, nr); |
| 764 | |
| 765 | if (!app) { |
| 766 | vty_out(vty, "%% Unable to allocate Application %u%s", |
| 767 | nr, VTY_NEWLINE); |
| 768 | return CMD_WARNING; |
| 769 | } |
| 770 | |
| 771 | vty->node = APP_NODE; |
| 772 | vty->index = app; |
| 773 | vty->index_sub = &app->name; |
| 774 | return CMD_SUCCESS; |
| 775 | } |
| 776 | |
| 777 | DEFUN(cfg_app_type, cfg_app_type_cmd, |
| 778 | "type (none|stp|relay|msc)", |
| 779 | "Type of Application\n" |
| 780 | "No type\n" "Signalling Transfer Point\n" |
| 781 | "Relay SCCP/ISUP messages\n" "MSC connector with state\n") |
| 782 | { |
| 783 | enum ss7_app_type type; |
| 784 | struct ss7_application *app = vty->index; |
| 785 | |
| 786 | switch (argv[0][0]) { |
| 787 | case 'm': |
| 788 | type = APP_CELLMGR; |
| 789 | break; |
| 790 | case 'r': |
| 791 | type = APP_RELAY; |
| 792 | break; |
| 793 | case 's': |
| 794 | type = APP_STP; |
| 795 | break; |
| 796 | default: |
| 797 | case 'n': |
| 798 | type = APP_NONE; |
| 799 | break; |
| 800 | } |
| 801 | |
| 802 | if (app->type != APP_NONE && app->type != type) { |
| 803 | vty_out(vty, "The type can not be changed at runtime on app %d.%s", |
| 804 | app->nr, VTY_NEWLINE); |
| 805 | return CMD_WARNING; |
| 806 | } |
| 807 | |
| 808 | app->type = type; |
| 809 | return CMD_SUCCESS; |
| 810 | } |
| 811 | |
| 812 | DEFUN(cfg_app_isup_pass, cfg_app_isup_pass_cmd, |
| 813 | "isup-pass-through (0|1)", |
| 814 | "Pass all ISUP messages\n" "Handle some ISUP locally\n" "Pass all messages\n") |
| 815 | { |
| 816 | struct ss7_application *app = vty->index; |
| 817 | |
| 818 | if (app->type != APP_STP) { |
| 819 | vty_out(vty, "%%Need to use the 'stp' app for this option on app %d.%s", |
| 820 | app->nr, VTY_NEWLINE); |
| 821 | return CMD_WARNING; |
| 822 | } |
| 823 | |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 824 | ss7_application_pass_isup(app, atoi(argv[0])); |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 825 | return CMD_SUCCESS; |
| 826 | } |
| 827 | |
| 828 | DEFUN(cfg_app_route, cfg_app_route_cmd, |
| 829 | "route linkset <0-100> msc <0-100>", |
| 830 | "Routing commands\n" "Source Linkset\n" "Linkset Nr\n" |
| 831 | "Dest MSC\n" "MSC Nr\n") |
| 832 | { |
| 833 | struct ss7_application *app = vty->index; |
| 834 | |
| 835 | if (app->type != APP_CELLMGR && app->type != APP_RELAY) { |
| 836 | vty_out(vty, "The app type needs to be 'relay' or 'msc'.%s", VTY_NEWLINE); |
| 837 | return CMD_WARNING; |
| 838 | } |
| 839 | |
| 840 | if (ss7_application_setup(app, app->type, |
| 841 | SS7_SET_LINKSET, atoi(argv[0]), |
| 842 | SS7_SET_MSC, atoi(argv[1])) != 0) { |
| 843 | vty_out(vty, "Failed to route linkset %d to msc %d.%s", |
| 844 | atoi(argv[0]), atoi(argv[1]), VTY_NEWLINE); |
| 845 | return CMD_WARNING; |
| 846 | } |
Holger Hans Peter Freyther | f603f28 | 2011-01-30 00:24:15 +0100 | [diff] [blame] | 847 | |
| 848 | return CMD_SUCCESS; |
| 849 | } |
| 850 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 851 | DEFUN(cfg_app_route_ls, cfg_app_route_ls_cmd, |
| 852 | "route linkset <0-100> linkset <0-100>", |
| 853 | "Routing commands\n" "Source Linkset\n" "Linkset Nr\n" |
| 854 | "Dest Linkset\n" "Linkset Nr\n" ) |
| 855 | { |
| 856 | struct ss7_application *app = vty->index; |
| 857 | |
| 858 | if (app->type != APP_STP) { |
| 859 | vty_out(vty, "The app type needs to be 'stp'.%s", VTY_NEWLINE); |
| 860 | return CMD_WARNING; |
| 861 | } |
| 862 | |
| 863 | if (ss7_application_setup(app, app->type, |
| 864 | SS7_SET_LINKSET, atoi(argv[0]), |
| 865 | SS7_SET_LINKSET, atoi(argv[1])) != 0) { |
| 866 | vty_out(vty, "Failed to route linkset %d to linkset %d.%s", |
| 867 | atoi(argv[0]), atoi(argv[1]), VTY_NEWLINE); |
| 868 | return CMD_WARNING; |
| 869 | } |
| 870 | |
| 871 | return CMD_SUCCESS; |
| 872 | } |
| 873 | |
Holger Hans Peter Freyther | fc98ce2 | 2011-09-13 20:08:57 +0200 | [diff] [blame^] | 874 | #define MGCP_DOMAIN_STR "MGCP domain name to use\n" |
| 875 | |
| 876 | DEFUN(cfg_app_domain_name, cfg_app_domain_name_cmd, |
| 877 | "domain-name NAME", |
| 878 | MGCP_DOMAIN_STR "Domain Name\n") |
| 879 | { |
| 880 | struct ss7_application *app = vty->index; |
| 881 | |
| 882 | if (app->type != APP_CELLMGR) { |
| 883 | vty_out(vty, "The app type needs to be 'msc'.%s", VTY_NEWLINE); |
| 884 | return CMD_WARNING; |
| 885 | } |
| 886 | |
| 887 | if (ss7_application_mgcp_domain_name(app, argv[0]) != 0) { |
| 888 | vty_out(vty, "Failed to set the domain name.%s", VTY_NEWLINE); |
| 889 | return CMD_WARNING; |
| 890 | } |
| 891 | |
| 892 | return CMD_SUCCESS; |
| 893 | } |
| 894 | |
| 895 | DEFUN(cfg_app_no_domain_name, cfg_app_no_domain_name_cmd, |
| 896 | "no domain-name", |
| 897 | NO_STR MGCP_DOMAIN_STR) |
| 898 | { |
| 899 | struct ss7_application *app = vty->index; |
| 900 | |
| 901 | if (app->type != APP_CELLMGR) { |
| 902 | vty_out(vty, "The app type needs to be 'msc'.%s", VTY_NEWLINE); |
| 903 | return CMD_WARNING; |
| 904 | } |
| 905 | |
| 906 | talloc_free(app->mgcp_domain_name); |
| 907 | app->mgcp_domain_name = NULL; |
| 908 | return CMD_SUCCESS; |
| 909 | } |
| 910 | |
| 911 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 912 | static void install_defaults(int node) |
| 913 | { |
| 914 | install_default(node); |
| 915 | install_element(node, &node_exit_cmd); |
| 916 | install_element(node, &node_end_cmd); |
| 917 | install_element(node, &cfg_description_cmd); |
| 918 | install_element(node, &cfg_no_description_cmd); |
| 919 | } |
| 920 | |
Holger Hans Peter Freyther | 2917644 | 2011-02-22 16:00:36 +0100 | [diff] [blame] | 921 | extern void cell_vty_init_cmds(void); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 922 | void cell_vty_init(void) |
| 923 | { |
| 924 | cmd_init(1); |
| 925 | vty_init(&vty_info); |
Harald Welte | ff397ed | 2011-05-08 10:29:23 +0200 | [diff] [blame] | 926 | logging_vty_add_cmds(&log_info); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 927 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 928 | install_element(CONFIG_NODE, &cfg_ss7_cmd); |
| 929 | install_node(&ss7_node, config_write_ss7); |
| 930 | install_defaults(SS7_NODE); |
| 931 | install_element(SS7_NODE, &cfg_ss7_udp_src_port_cmd); |
| 932 | install_element(SS7_NODE, &cfg_ss7_m2ua_src_port_cmd); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 933 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 934 | install_element(SS7_NODE, &cfg_ss7_linkset_cmd); |
| 935 | install_node(&linkset_node, config_write_linkset); |
| 936 | install_defaults(LINKSETS_NODE); |
| 937 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_dpc_cmd); |
| 938 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_opc_cmd); |
| 939 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_ni_cmd); |
| 940 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_spare_cmd); |
| 941 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_ssn_cmd); |
| 942 | install_element(LINKSETS_NODE, &cfg_linkset_no_mtp3_ssn_cmd); |
| 943 | install_element(LINKSETS_NODE, &cfg_linkset_sltm_once_cmd); |
Holger Hans Peter Freyther | 47c9faa | 2011-02-23 11:25:45 +0100 | [diff] [blame] | 944 | install_element(LINKSETS_NODE, &cfg_linkset_t18_cmd); |
| 945 | install_element(LINKSETS_NODE, &cfg_linkset_t20_cmd); |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 946 | |
| 947 | install_element(LINKSETS_NODE, &cfg_linkset_link_cmd); |
| 948 | install_node(&link_node, dummy_write); |
| 949 | install_defaults(LINK_NODE); |
| 950 | install_element(LINK_NODE, &cfg_link_ss7_transport_cmd); |
| 951 | install_element(LINK_NODE, &cfg_link_udp_dest_ip_cmd); |
| 952 | install_element(LINK_NODE, &cfg_link_udp_dest_port_cmd); |
| 953 | install_element(LINK_NODE, &cfg_link_udp_reset_cmd); |
| 954 | install_element(LINK_NODE, &cfg_link_udp_link_index_cmd); |
| 955 | install_element(LINK_NODE, &cfg_link_m2ua_as_cmd); |
| 956 | install_element(LINK_NODE, &cfg_link_m2ua_link_index_cmd); |
| 957 | |
| 958 | install_element(SS7_NODE, &cfg_ss7_msc_cmd); |
| 959 | install_node(&msc_node, config_write_msc); |
| 960 | install_defaults(MSC_NODE); |
| 961 | install_element(MSC_NODE, &cfg_msc_ip_cmd); |
| 962 | install_element(MSC_NODE, &cfg_msc_token_cmd); |
| 963 | install_element(MSC_NODE, &cfg_msc_dscp_cmd); |
| 964 | install_element(MSC_NODE, &cfg_msc_timeout_ping_cmd); |
| 965 | install_element(MSC_NODE, &cfg_msc_timeout_pong_cmd); |
| 966 | install_element(MSC_NODE, &cfg_msc_timeout_restart_cmd); |
| 967 | |
| 968 | install_element(SS7_NODE, &cfg_ss7_app_cmd); |
| 969 | install_node(&app_node, config_write_app); |
| 970 | install_defaults(APP_NODE); |
| 971 | install_element(APP_NODE, &cfg_app_type_cmd); |
| 972 | install_element(APP_NODE, &cfg_app_isup_pass_cmd); |
| 973 | install_element(APP_NODE, &cfg_app_route_cmd); |
| 974 | install_element(APP_NODE, &cfg_app_route_ls_cmd); |
Holger Hans Peter Freyther | fc98ce2 | 2011-09-13 20:08:57 +0200 | [diff] [blame^] | 975 | install_element(APP_NODE, &cfg_app_domain_name_cmd); |
| 976 | install_element(APP_NODE, &cfg_app_no_domain_name_cmd); |
Holger Hans Peter Freyther | 51b9e7a | 2011-01-22 16:02:13 +0100 | [diff] [blame] | 977 | |
Holger Hans Peter Freyther | 2917644 | 2011-02-22 16:00:36 +0100 | [diff] [blame] | 978 | cell_vty_init_cmds(); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | const char *openbsc_copyright = ""; |