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