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 | |
| 31 | #include <osmocore/talloc.h> |
Holger Hans Peter Freyther | 0e4e35f | 2010-09-30 03:04:28 +0800 | [diff] [blame] | 32 | #include <osmocore/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 | |
| 294 | if (app->route_is_set) { |
| 295 | vty_out(vty, " route %s %d %s %d%s", |
| 296 | link_type(app->route_src.type), app->route_src.nr, |
| 297 | link_type(app->route_dst.type), app->route_dst.nr, |
| 298 | VTY_NEWLINE); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | static int config_write_app(struct vty *vty) |
| 303 | { |
| 304 | struct ss7_application *app; |
| 305 | |
| 306 | llist_for_each_entry(app, &bsc->apps, entry) |
| 307 | write_application(vty, app); |
| 308 | |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 309 | return CMD_SUCCESS; |
| 310 | } |
| 311 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 312 | DEFUN(cfg_ss7, cfg_ss7_cmd, |
| 313 | "ss7", "Configure the application\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 314 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 315 | vty->node = SS7_NODE; |
| 316 | return CMD_SUCCESS; |
| 317 | } |
| 318 | |
| 319 | DEFUN(cfg_ss7_udp_src_port, cfg_ss7_udp_src_port_cmd, |
| 320 | "udp src-port <1-65535>", |
| 321 | "UDP related commands\n" |
| 322 | "Source port for SS7 via UDP transport\n" |
| 323 | "Port to bind to\n") |
| 324 | { |
| 325 | bsc->udp_src_port = atoi(argv[0]); |
| 326 | return CMD_SUCCESS; |
| 327 | } |
| 328 | |
| 329 | DEFUN(cfg_ss7_m2ua_src_port, cfg_ss7_m2ua_src_port_cmd, |
| 330 | "m2ua src-port <1-65535>", |
| 331 | "M2UA related commands\n" |
| 332 | "Source port for SS7 via M2UA\n" |
| 333 | "Port to bind to\n") |
| 334 | { |
| 335 | bsc->m2ua_src_port = atoi(argv[0]); |
| 336 | return CMD_SUCCESS; |
| 337 | } |
| 338 | |
| 339 | DEFUN(cfg_ss7_linkset, cfg_ss7_linkset_cmd, |
| 340 | "linkset <0-100>", |
| 341 | "Linkset commands\n" "Linkset number\n") |
| 342 | { |
| 343 | struct mtp_link_set *set; |
| 344 | int nr; |
| 345 | |
| 346 | nr = atoi(argv[0]); |
| 347 | if (nr > bsc->num_linksets) { |
| 348 | vty_out(vty, "%% The next unused Linkset number is %u%s", |
| 349 | bsc->num_linksets, VTY_NEWLINE); |
| 350 | return CMD_WARNING; |
| 351 | } else if (nr == bsc->num_linksets) { |
| 352 | set = mtp_link_set_alloc(bsc); |
| 353 | } else |
| 354 | set = mtp_link_set_num(bsc, nr); |
| 355 | |
| 356 | if (!set) { |
| 357 | vty_out(vty, "%% Unable to allocate Linkset %u%s", |
| 358 | nr, VTY_NEWLINE); |
| 359 | return CMD_WARNING; |
| 360 | } |
| 361 | |
| 362 | vty->node = LINKSETS_NODE; |
| 363 | vty->index = set; |
| 364 | vty->index_sub = &set->name; |
| 365 | return CMD_SUCCESS; |
| 366 | } |
| 367 | |
| 368 | DEFUN(cfg_linkset_mtp3_dpc, cfg_linkset_mtp3_dpc_cmd, |
Holger Hans Peter Freyther | af3faf8 | 2011-02-23 16:59:45 +0100 | [diff] [blame] | 369 | "mtp3 dpc <0-8191>", |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 370 | "MTP Level3\n" "Destination Point Code\n" "Point Code\n") |
| 371 | { |
| 372 | struct mtp_link_set *set = vty->index; |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 373 | set->dpc = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 374 | return CMD_SUCCESS; |
| 375 | } |
| 376 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 377 | DEFUN(cfg_linkset_mtp3_opc, cfg_linkset_mtp3_opc_cmd, |
Holger Hans Peter Freyther | af3faf8 | 2011-02-23 16:59:45 +0100 | [diff] [blame] | 378 | "mtp3 opc <0-8191>", |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 379 | "MTP Level3\n" "Originating Point Code\n" "Point Code\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 380 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 381 | struct mtp_link_set *set = vty->index; |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 382 | set->opc = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 383 | return CMD_SUCCESS; |
| 384 | } |
| 385 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 386 | DEFUN(cfg_linkset_mtp3_ni, cfg_linkset_mtp3_ni_cmd, |
| 387 | "mtp3 ni <0-3>", |
| 388 | "MTP Level3\n" "NI for the address\n" "NI\n") |
Holger Hans Peter Freyther | 7a72556 | 2011-01-01 13:34:58 +0100 | [diff] [blame] | 389 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 390 | struct mtp_link_set *set = vty->index; |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 391 | set->ni = atoi(argv[0]); |
Holger Hans Peter Freyther | b38b33b | 2010-11-26 21:21:04 +0100 | [diff] [blame] | 392 | return CMD_SUCCESS; |
| 393 | } |
| 394 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 395 | DEFUN(cfg_linkset_mtp3_spare, cfg_linkset_mtp3_spare_cmd, |
| 396 | "mtp3 spare <0-3>", |
| 397 | "MTP Level3\n" "Spare for the address\n" "Spare\n") |
Holger Hans Peter Freyther | b38b33b | 2010-11-26 21:21:04 +0100 | [diff] [blame] | 398 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 399 | struct mtp_link_set *set = vty->index; |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 400 | set->spare = atoi(argv[0]); |
Holger Hans Peter Freyther | b38b33b | 2010-11-26 21:21:04 +0100 | [diff] [blame] | 401 | return CMD_SUCCESS; |
| 402 | } |
| 403 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 404 | DEFUN(cfg_linkset_mtp3_ssn, cfg_linkset_mtp3_ssn_cmd, |
| 405 | "mtp3 ssn <0-255>", |
| 406 | "MTP Level3\n" "SSN supported\n" "SSN\n") |
| 407 | { |
| 408 | struct mtp_link_set *set = vty->index; |
| 409 | set->supported_ssn[atoi(argv[0])] = 1; |
| 410 | return CMD_SUCCESS; |
| 411 | } |
Holger Hans Peter Freyther | b38b33b | 2010-11-26 21:21:04 +0100 | [diff] [blame] | 412 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 413 | DEFUN(cfg_linkset_no_mtp3_ssn, cfg_linkset_no_mtp3_ssn_cmd, |
| 414 | "no mtp3 ssn <0-255>", |
| 415 | "MTP Level3\n" "SSN supported\n" "SSN\n") |
| 416 | { |
| 417 | struct mtp_link_set *set = vty->index; |
| 418 | set->supported_ssn[atoi(argv[0])] = 0; |
| 419 | return CMD_SUCCESS; |
| 420 | } |
| 421 | |
| 422 | DEFUN(cfg_linkset_sltm_once, cfg_linkset_sltm_once_cmd, |
| 423 | "mtp3 sltm-once (0|1)", |
| 424 | "MTP Level3\n" "Test the link once\n" "Continous testing\n" "Test once\n") |
| 425 | { |
| 426 | struct mtp_link_set *set = vty->index; |
| 427 | set->sltm_once = !!atoi(argv[0]); |
| 428 | |
| 429 | return CMD_SUCCESS; |
| 430 | } |
| 431 | |
Holger Hans Peter Freyther | 47c9faa | 2011-02-23 11:25:45 +0100 | [diff] [blame] | 432 | DEFUN(cfg_linkset_t18, cfg_linkset_t18_cmd, |
| 433 | "mtp3 timeout t18 <0-1000>", |
| 434 | "MTP Level3\n" "Timeouts\n" "T18 link restart timeout\n" "Seconds\n") |
| 435 | { |
| 436 | struct mtp_link_set *set = vty->index; |
| 437 | set->timeout_t18 = atoi(argv[0]); |
| 438 | return CMD_SUCCESS; |
| 439 | } |
| 440 | |
| 441 | DEFUN(cfg_linkset_t20, cfg_linkset_t20_cmd, |
| 442 | "mtp3 timeout t20 <0-1000>", |
| 443 | "MTP Level3\n" "Timeouts\n" "T20 link restart timeout\n" "Seconds\n") |
| 444 | { |
| 445 | struct mtp_link_set *set = vty->index; |
| 446 | set->timeout_t20 = atoi(argv[0]); |
| 447 | return CMD_SUCCESS; |
| 448 | } |
| 449 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 450 | DEFUN(cfg_linkset_link, cfg_linkset_link_cmd, |
| 451 | "link <0-100>", |
| 452 | "Link\n" "Link number\n") |
| 453 | { |
| 454 | struct mtp_link_set *set = vty->index; |
| 455 | |
| 456 | struct mtp_link *lnk; |
| 457 | int nr; |
| 458 | |
| 459 | nr = atoi(argv[0]); |
| 460 | if (nr > set->nr_links) { |
| 461 | vty_out(vty, "%% The next unused Link number is %u%s", |
| 462 | set->nr_links, VTY_NEWLINE); |
| 463 | return CMD_WARNING; |
| 464 | } else if (nr == set->nr_links) { |
| 465 | lnk = mtp_link_alloc(set); |
| 466 | } else |
| 467 | lnk = mtp_link_num(set, nr); |
| 468 | |
| 469 | if (!set) { |
| 470 | vty_out(vty, "%% Unable to allocate Link %u%s", |
| 471 | nr, VTY_NEWLINE); |
| 472 | return CMD_WARNING; |
| 473 | } |
| 474 | |
| 475 | vty->node = LINK_NODE; |
| 476 | vty->index = lnk; |
| 477 | vty->index_sub = &lnk->name; |
| 478 | return CMD_SUCCESS; |
| 479 | } |
| 480 | |
| 481 | DEFUN(cfg_link_ss7_transport, cfg_link_ss7_transport_cmd, |
| 482 | "ss7-transport (none|udp|m2ua)", |
| 483 | "SS7 transport for the link\n" |
| 484 | "No transport\n" "MTP over UDP\n" "SCTP M2UA\n") |
| 485 | { |
| 486 | int wanted = SS7_LTYPE_NONE; |
| 487 | struct mtp_link *link; |
| 488 | |
| 489 | link = vty->index; |
| 490 | |
| 491 | if (strcmp("udp", argv[0]) == 0) |
| 492 | wanted = SS7_LTYPE_UDP; |
| 493 | else if (strcmp("m2ua", argv[0]) == 0) |
| 494 | wanted = SS7_LTYPE_M2UA; |
| 495 | |
| 496 | if (link->type != wanted && link->type != SS7_LTYPE_NONE) { |
| 497 | vty_out(vty, "%%Can not change the type of a link.\n"); |
| 498 | return CMD_WARNING; |
| 499 | } |
| 500 | |
| 501 | switch (wanted) { |
| 502 | case SS7_LTYPE_UDP: |
| 503 | link->data = mtp_udp_link_init(link); |
| 504 | break; |
| 505 | case SS7_LTYPE_M2UA: |
| 506 | link->data = mtp_m2ua_link_init(link); |
| 507 | break; |
| 508 | case SS7_LTYPE_NONE: |
| 509 | /* nothing */ |
| 510 | break; |
| 511 | } |
| 512 | |
| 513 | if (!link->data) { |
| 514 | vty_out(vty, "Failed to allocate the link type.%s", VTY_NEWLINE); |
| 515 | return CMD_WARNING; |
| 516 | } |
| 517 | |
| 518 | return CMD_SUCCESS; |
| 519 | } |
| 520 | |
| 521 | DEFUN(cfg_link_udp_dest_ip, cfg_link_udp_dest_ip_cmd, |
| 522 | "udp dest ip HOST_NAME", |
| 523 | "UDP Transport\n" "IP\n" "Hostname\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 524 | { |
| 525 | struct hostent *hosts; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 526 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 527 | struct mtp_link *link = vty->index; |
| 528 | struct mtp_udp_link *ulnk; |
| 529 | |
| 530 | if (link->type != SS7_LTYPE_UDP) { |
| 531 | vty_out(vty, "%%This only applies to UDP links.%s", VTY_NEWLINE); |
| 532 | return CMD_WARNING; |
| 533 | } |
| 534 | |
| 535 | ulnk = link->data; |
| 536 | |
| 537 | if (ulnk->dest) |
| 538 | talloc_free(ulnk->dest); |
| 539 | ulnk->dest = talloc_strdup(ulnk, argv[0]); |
| 540 | |
| 541 | hosts = gethostbyname(ulnk->dest); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 542 | if (!hosts || hosts->h_length < 1 || hosts->h_addrtype != AF_INET) { |
| 543 | vty_out(vty, "Failed to resolve '%s'%s", argv[0], VTY_NEWLINE); |
| 544 | return CMD_WARNING; |
| 545 | } |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 546 | 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] | 547 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 548 | if (snmp_mtp_peer_name(ulnk->session, ulnk->dest) != 0) { |
| 549 | vty_out(vty, "%%Failed to open SNMP port on link %d.%s", |
| 550 | link->nr, VTY_NEWLINE); |
| 551 | return CMD_WARNING; |
| 552 | } |
| 553 | |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 554 | return CMD_SUCCESS; |
| 555 | } |
| 556 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 557 | DEFUN(cfg_link_udp_dest_port, cfg_link_udp_dest_port_cmd, |
| 558 | "udp dest port <1-65535>", |
| 559 | "UDP Transport\n" "Set the port number\n" "Port\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 560 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 561 | struct mtp_link *link = vty->index; |
| 562 | struct mtp_udp_link *ulnk; |
| 563 | |
| 564 | if (link->type != SS7_LTYPE_UDP) { |
| 565 | vty_out(vty, "%%This only applies to UDP links.%s", VTY_NEWLINE); |
| 566 | return CMD_WARNING; |
| 567 | } |
| 568 | |
| 569 | ulnk = link->data; |
| 570 | ulnk->remote.sin_port = htons(atoi(argv[0])); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 571 | return CMD_SUCCESS; |
| 572 | } |
| 573 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 574 | DEFUN(cfg_link_udp_reset, cfg_link_udp_reset_cmd, |
| 575 | "udp reset-timeout <1-65535>", |
| 576 | "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] | 577 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 578 | struct mtp_link *link = vty->index; |
| 579 | struct mtp_udp_link *ulnk; |
| 580 | |
| 581 | if (link->type != SS7_LTYPE_UDP) { |
| 582 | vty_out(vty, "%%This only applies to UDP links.%s", VTY_NEWLINE); |
| 583 | return CMD_WARNING; |
| 584 | } |
| 585 | |
| 586 | ulnk = link->data; |
| 587 | ulnk->reset_timeout = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 588 | return CMD_SUCCESS; |
| 589 | } |
| 590 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 591 | DEFUN(cfg_link_udp_link_index, cfg_link_udp_link_index_cmd, |
| 592 | "udp link-index <0-65535>", |
| 593 | "UDP Transport\n" "Link index\n" "Index\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 594 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 595 | struct mtp_link *link = vty->index; |
| 596 | struct mtp_udp_link *ulnk; |
| 597 | |
| 598 | if (link->type != SS7_LTYPE_UDP) { |
| 599 | vty_out(vty, "%%This only applies to UDP links.%s", VTY_NEWLINE); |
| 600 | return CMD_WARNING; |
| 601 | } |
| 602 | |
| 603 | ulnk = link->data; |
| 604 | ulnk->link_index = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 605 | return CMD_SUCCESS; |
| 606 | } |
| 607 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 608 | DEFUN(cfg_link_m2ua_as, cfg_link_m2ua_as_cmd, |
| 609 | "m2ua application-server NAME", |
| 610 | "M2UA Transport\n" "Application Server Name\n" "Name\n") |
Holger Hans Peter Freyther | c6bfa27 | 2011-01-22 17:06:34 +0100 | [diff] [blame] | 611 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 612 | struct mtp_link *link = vty->index; |
| 613 | struct mtp_m2ua_link *m2ua; |
| 614 | |
| 615 | if (link->type != SS7_LTYPE_M2UA) { |
| 616 | vty_out(vty, "%%This only applies to M2UA links.%s", VTY_NEWLINE); |
| 617 | return CMD_WARNING; |
| 618 | } |
| 619 | |
| 620 | m2ua = link->data; |
| 621 | if (m2ua->as) |
| 622 | talloc_free(m2ua->as); |
| 623 | m2ua->as = talloc_strdup(m2ua, argv[0]); |
Holger Hans Peter Freyther | c6bfa27 | 2011-01-22 17:06:34 +0100 | [diff] [blame] | 624 | return CMD_SUCCESS; |
| 625 | } |
| 626 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 627 | DEFUN(cfg_link_m2ua_link_index, cfg_link_m2ua_link_index_cmd, |
| 628 | "m2ua link-index <0-65535>", |
| 629 | "M2UA Transport\n" "Link index\n" "Index\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 630 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 631 | struct mtp_link *link = vty->index; |
| 632 | struct mtp_m2ua_link *m2ua; |
| 633 | |
| 634 | if (link->type != SS7_LTYPE_M2UA) { |
| 635 | vty_out(vty, "%%This only applies to M2UA links.%s", VTY_NEWLINE); |
| 636 | return CMD_WARNING; |
| 637 | } |
| 638 | |
| 639 | m2ua = link->data; |
| 640 | m2ua->link_index = atoi(argv[0]); |
| 641 | return CMD_SUCCESS; |
| 642 | } |
| 643 | |
| 644 | DEFUN(cfg_ss7_msc, cfg_ss7_msc_cmd, |
| 645 | "msc <0-100>", |
| 646 | "MSC Connection\n" "MSC Number\n") |
| 647 | { |
| 648 | struct msc_connection *msc; |
| 649 | int nr; |
| 650 | |
| 651 | nr = atoi(argv[0]); |
| 652 | if (nr > bsc->num_mscs) { |
| 653 | vty_out(vty, "%% The next unused MSC number is %u%s", |
| 654 | bsc->num_mscs, VTY_NEWLINE); |
| 655 | return CMD_WARNING; |
| 656 | } else if (nr == bsc->num_mscs) { |
| 657 | msc = msc_connection_create(bsc, 1); |
| 658 | } else |
| 659 | msc = msc_connection_num(bsc, nr); |
| 660 | |
| 661 | if (!msc) { |
| 662 | vty_out(vty, "%% Unable to allocate MSC %u%s", |
| 663 | nr, VTY_NEWLINE); |
| 664 | return CMD_WARNING; |
| 665 | } |
| 666 | |
| 667 | vty->node = MSC_NODE; |
| 668 | vty->index = msc; |
| 669 | vty->index_sub = &msc->name; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 670 | return CMD_SUCCESS; |
| 671 | } |
| 672 | |
| 673 | DEFUN(cfg_msc_ip, cfg_msc_ip_cmd, |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 674 | "ip ADDR", |
| 675 | "IP Address of the MSC\n" "Address\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 676 | { |
| 677 | struct hostent *hosts; |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 678 | struct msc_connection *msc; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 679 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 680 | msc = vty->index; |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 681 | hosts = gethostbyname(argv[0]); |
| 682 | if (!hosts || hosts->h_length < 1 || hosts->h_addrtype != AF_INET) { |
| 683 | vty_out(vty, "Failed to resolve '%s'%s", argv[0], VTY_NEWLINE); |
| 684 | return CMD_WARNING; |
| 685 | } |
| 686 | |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 687 | if (msc->ip) |
| 688 | talloc_free(msc->ip); |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 689 | |
| 690 | msc->ip = talloc_strdup(msc, |
| 691 | inet_ntoa(*((struct in_addr *) hosts->h_addr_list[0]))); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 692 | return CMD_SUCCESS; |
| 693 | } |
| 694 | |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 695 | DEFUN(cfg_msc_token, cfg_msc_token_cmd, |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 696 | "token TOKEN", |
| 697 | "Token for the MSC\n" "The token\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 698 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 699 | struct msc_connection *msc = vty->index; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 700 | |
| 701 | if (msc->token) |
| 702 | talloc_free(msc->token); |
| 703 | msc->token = talloc_strdup(msc, argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 704 | return CMD_SUCCESS; |
| 705 | } |
| 706 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 707 | DEFUN(cfg_msc_dscp, cfg_msc_dscp_cmd, |
| 708 | "dscp <0-255>", |
| 709 | "DSCP for the IP Connection\n" "Nr\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 710 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 711 | struct msc_connection *msc = vty->index; |
| 712 | msc->dscp = atoi(argv[0]); |
| 713 | return CMD_SUCCESS; |
| 714 | } |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 715 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 716 | DEFUN(cfg_msc_timeout_ping, cfg_msc_timeout_ping_cmd, |
| 717 | "timeout ping <1-65535>", |
| 718 | "Timeout commands\n" "Time between pings\n" "Seconds\n") |
| 719 | { |
| 720 | struct msc_connection *msc = vty->index; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 721 | msc->ping_time = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 722 | return CMD_SUCCESS; |
| 723 | } |
| 724 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 725 | DEFUN(cfg_msc_timeout_pong, cfg_msc_timeout_pong_cmd, |
| 726 | "timeout pong <1-65535>", |
| 727 | "Timeout commands\n" "Time between pongs\n" "Seconds\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 728 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 729 | struct msc_connection *msc = vty->index; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 730 | msc->pong_time = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 731 | return CMD_SUCCESS; |
| 732 | } |
| 733 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 734 | DEFUN(cfg_msc_timeout_restart, cfg_msc_timeout_restart_cmd, |
| 735 | "timeout restart <1-65535>", |
| 736 | "Timeout commands\n" "Time between restarts\n" "Seconds\n") |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 737 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 738 | struct msc_connection *msc = vty->index; |
Holger Hans Peter Freyther | 84ec871 | 2011-02-15 20:01:47 +0100 | [diff] [blame] | 739 | msc->msc_time = atoi(argv[0]); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 740 | return CMD_SUCCESS; |
| 741 | } |
| 742 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 743 | DEFUN(cfg_ss7_app, cfg_ss7_app_cmd, |
| 744 | "application <0-100>", |
| 745 | "Application Commands\n" "Number\n") |
Holger Hans Peter Freyther | f603f28 | 2011-01-30 00:24:15 +0100 | [diff] [blame] | 746 | { |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 747 | struct ss7_application *app; |
| 748 | int nr; |
| 749 | |
| 750 | nr = atoi(argv[0]); |
| 751 | if (nr > bsc->num_apps) { |
| 752 | vty_out(vty, "%% The next unused Application number is %u%s", |
| 753 | bsc->num_apps, VTY_NEWLINE); |
| 754 | return CMD_WARNING; |
| 755 | } else if (nr == bsc->num_apps) { |
| 756 | app = ss7_application_alloc(bsc); |
| 757 | } else |
| 758 | app = ss7_application_num(bsc, nr); |
| 759 | |
| 760 | if (!app) { |
| 761 | vty_out(vty, "%% Unable to allocate Application %u%s", |
| 762 | nr, VTY_NEWLINE); |
| 763 | return CMD_WARNING; |
| 764 | } |
| 765 | |
| 766 | vty->node = APP_NODE; |
| 767 | vty->index = app; |
| 768 | vty->index_sub = &app->name; |
| 769 | return CMD_SUCCESS; |
| 770 | } |
| 771 | |
| 772 | DEFUN(cfg_app_type, cfg_app_type_cmd, |
| 773 | "type (none|stp|relay|msc)", |
| 774 | "Type of Application\n" |
| 775 | "No type\n" "Signalling Transfer Point\n" |
| 776 | "Relay SCCP/ISUP messages\n" "MSC connector with state\n") |
| 777 | { |
| 778 | enum ss7_app_type type; |
| 779 | struct ss7_application *app = vty->index; |
| 780 | |
| 781 | switch (argv[0][0]) { |
| 782 | case 'm': |
| 783 | type = APP_CELLMGR; |
| 784 | break; |
| 785 | case 'r': |
| 786 | type = APP_RELAY; |
| 787 | break; |
| 788 | case 's': |
| 789 | type = APP_STP; |
| 790 | break; |
| 791 | default: |
| 792 | case 'n': |
| 793 | type = APP_NONE; |
| 794 | break; |
| 795 | } |
| 796 | |
| 797 | if (app->type != APP_NONE && app->type != type) { |
| 798 | vty_out(vty, "The type can not be changed at runtime on app %d.%s", |
| 799 | app->nr, VTY_NEWLINE); |
| 800 | return CMD_WARNING; |
| 801 | } |
| 802 | |
| 803 | app->type = type; |
| 804 | return CMD_SUCCESS; |
| 805 | } |
| 806 | |
| 807 | DEFUN(cfg_app_isup_pass, cfg_app_isup_pass_cmd, |
| 808 | "isup-pass-through (0|1)", |
| 809 | "Pass all ISUP messages\n" "Handle some ISUP locally\n" "Pass all messages\n") |
| 810 | { |
| 811 | struct ss7_application *app = vty->index; |
| 812 | |
| 813 | if (app->type != APP_STP) { |
| 814 | vty_out(vty, "%%Need to use the 'stp' app for this option on app %d.%s", |
| 815 | app->nr, VTY_NEWLINE); |
| 816 | return CMD_WARNING; |
| 817 | } |
| 818 | |
Holger Hans Peter Freyther | cfe9d71 | 2011-02-17 20:32:09 +0100 | [diff] [blame] | 819 | ss7_application_pass_isup(app, atoi(argv[0])); |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 820 | return CMD_SUCCESS; |
| 821 | } |
| 822 | |
| 823 | DEFUN(cfg_app_route, cfg_app_route_cmd, |
| 824 | "route linkset <0-100> msc <0-100>", |
| 825 | "Routing commands\n" "Source Linkset\n" "Linkset Nr\n" |
| 826 | "Dest MSC\n" "MSC Nr\n") |
| 827 | { |
| 828 | struct ss7_application *app = vty->index; |
| 829 | |
| 830 | if (app->type != APP_CELLMGR && app->type != APP_RELAY) { |
| 831 | vty_out(vty, "The app type needs to be 'relay' or 'msc'.%s", VTY_NEWLINE); |
| 832 | return CMD_WARNING; |
| 833 | } |
| 834 | |
| 835 | if (ss7_application_setup(app, app->type, |
| 836 | SS7_SET_LINKSET, atoi(argv[0]), |
| 837 | SS7_SET_MSC, atoi(argv[1])) != 0) { |
| 838 | vty_out(vty, "Failed to route linkset %d to msc %d.%s", |
| 839 | atoi(argv[0]), atoi(argv[1]), VTY_NEWLINE); |
| 840 | return CMD_WARNING; |
| 841 | } |
Holger Hans Peter Freyther | f603f28 | 2011-01-30 00:24:15 +0100 | [diff] [blame] | 842 | |
| 843 | return CMD_SUCCESS; |
| 844 | } |
| 845 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 846 | DEFUN(cfg_app_route_ls, cfg_app_route_ls_cmd, |
| 847 | "route linkset <0-100> linkset <0-100>", |
| 848 | "Routing commands\n" "Source Linkset\n" "Linkset Nr\n" |
| 849 | "Dest Linkset\n" "Linkset Nr\n" ) |
| 850 | { |
| 851 | struct ss7_application *app = vty->index; |
| 852 | |
| 853 | if (app->type != APP_STP) { |
| 854 | vty_out(vty, "The app type needs to be 'stp'.%s", VTY_NEWLINE); |
| 855 | return CMD_WARNING; |
| 856 | } |
| 857 | |
| 858 | if (ss7_application_setup(app, app->type, |
| 859 | SS7_SET_LINKSET, atoi(argv[0]), |
| 860 | SS7_SET_LINKSET, atoi(argv[1])) != 0) { |
| 861 | vty_out(vty, "Failed to route linkset %d to linkset %d.%s", |
| 862 | atoi(argv[0]), atoi(argv[1]), VTY_NEWLINE); |
| 863 | return CMD_WARNING; |
| 864 | } |
| 865 | |
| 866 | return CMD_SUCCESS; |
| 867 | } |
| 868 | |
| 869 | static void install_defaults(int node) |
| 870 | { |
| 871 | install_default(node); |
| 872 | install_element(node, &node_exit_cmd); |
| 873 | install_element(node, &node_end_cmd); |
| 874 | install_element(node, &cfg_description_cmd); |
| 875 | install_element(node, &cfg_no_description_cmd); |
| 876 | } |
| 877 | |
Holger Hans Peter Freyther | 2917644 | 2011-02-22 16:00:36 +0100 | [diff] [blame] | 878 | extern void cell_vty_init_cmds(void); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 879 | void cell_vty_init(void) |
| 880 | { |
| 881 | cmd_init(1); |
| 882 | vty_init(&vty_info); |
Holger Hans Peter Freyther | fca7b12 | 2011-01-22 23:19:44 +0100 | [diff] [blame] | 883 | logging_vty_add_cmds(); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 884 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 885 | install_element(CONFIG_NODE, &cfg_ss7_cmd); |
| 886 | install_node(&ss7_node, config_write_ss7); |
| 887 | install_defaults(SS7_NODE); |
| 888 | install_element(SS7_NODE, &cfg_ss7_udp_src_port_cmd); |
| 889 | install_element(SS7_NODE, &cfg_ss7_m2ua_src_port_cmd); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 890 | |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 891 | install_element(SS7_NODE, &cfg_ss7_linkset_cmd); |
| 892 | install_node(&linkset_node, config_write_linkset); |
| 893 | install_defaults(LINKSETS_NODE); |
| 894 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_dpc_cmd); |
| 895 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_opc_cmd); |
| 896 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_ni_cmd); |
| 897 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_spare_cmd); |
| 898 | install_element(LINKSETS_NODE, &cfg_linkset_mtp3_ssn_cmd); |
| 899 | install_element(LINKSETS_NODE, &cfg_linkset_no_mtp3_ssn_cmd); |
| 900 | install_element(LINKSETS_NODE, &cfg_linkset_sltm_once_cmd); |
Holger Hans Peter Freyther | 47c9faa | 2011-02-23 11:25:45 +0100 | [diff] [blame] | 901 | install_element(LINKSETS_NODE, &cfg_linkset_t18_cmd); |
| 902 | install_element(LINKSETS_NODE, &cfg_linkset_t20_cmd); |
Holger Hans Peter Freyther | 7176030 | 2011-02-22 20:57:08 +0100 | [diff] [blame] | 903 | |
| 904 | install_element(LINKSETS_NODE, &cfg_linkset_link_cmd); |
| 905 | install_node(&link_node, dummy_write); |
| 906 | install_defaults(LINK_NODE); |
| 907 | install_element(LINK_NODE, &cfg_link_ss7_transport_cmd); |
| 908 | install_element(LINK_NODE, &cfg_link_udp_dest_ip_cmd); |
| 909 | install_element(LINK_NODE, &cfg_link_udp_dest_port_cmd); |
| 910 | install_element(LINK_NODE, &cfg_link_udp_reset_cmd); |
| 911 | install_element(LINK_NODE, &cfg_link_udp_link_index_cmd); |
| 912 | install_element(LINK_NODE, &cfg_link_m2ua_as_cmd); |
| 913 | install_element(LINK_NODE, &cfg_link_m2ua_link_index_cmd); |
| 914 | |
| 915 | install_element(SS7_NODE, &cfg_ss7_msc_cmd); |
| 916 | install_node(&msc_node, config_write_msc); |
| 917 | install_defaults(MSC_NODE); |
| 918 | install_element(MSC_NODE, &cfg_msc_ip_cmd); |
| 919 | install_element(MSC_NODE, &cfg_msc_token_cmd); |
| 920 | install_element(MSC_NODE, &cfg_msc_dscp_cmd); |
| 921 | install_element(MSC_NODE, &cfg_msc_timeout_ping_cmd); |
| 922 | install_element(MSC_NODE, &cfg_msc_timeout_pong_cmd); |
| 923 | install_element(MSC_NODE, &cfg_msc_timeout_restart_cmd); |
| 924 | |
| 925 | install_element(SS7_NODE, &cfg_ss7_app_cmd); |
| 926 | install_node(&app_node, config_write_app); |
| 927 | install_defaults(APP_NODE); |
| 928 | install_element(APP_NODE, &cfg_app_type_cmd); |
| 929 | install_element(APP_NODE, &cfg_app_isup_pass_cmd); |
| 930 | install_element(APP_NODE, &cfg_app_route_cmd); |
| 931 | install_element(APP_NODE, &cfg_app_route_ls_cmd); |
Holger Hans Peter Freyther | 51b9e7a | 2011-01-22 16:02:13 +0100 | [diff] [blame] | 932 | |
Holger Hans Peter Freyther | 2917644 | 2011-02-22 16:00:36 +0100 | [diff] [blame] | 933 | cell_vty_init_cmds(); |
Holger Hans Peter Freyther | 7942abc | 2010-09-30 00:34:46 +0800 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | const char *openbsc_copyright = ""; |