Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 1 | /* OsmoBTS VTY interface */ |
| 2 | |
| 3 | #include <sys/socket.h> |
| 4 | #include <netinet/in.h> |
| 5 | #include <arpa/inet.h> |
| 6 | |
| 7 | #include <osmocom/core/talloc.h> |
| 8 | #include <osmocom/gsm/abis_nm.h> |
| 9 | #include <osmocom/vty/vty.h> |
| 10 | #include <osmocom/vty/command.h> |
| 11 | #include <osmocom/vty/logging.h> |
| 12 | |
| 13 | #include <osmocom/trau/osmo_ortp.h> |
| 14 | |
| 15 | |
| 16 | #include "pcu_vty.h" |
| 17 | |
| 18 | |
| 19 | enum node_type pcu_vty_go_parent(struct vty *vty) |
| 20 | { |
| 21 | switch (vty->node) { |
| 22 | #if 0 |
| 23 | case TRX_NODE: |
| 24 | vty->node = BTS_NODE; |
| 25 | { |
| 26 | struct gsm_bts_trx *trx = vty->index; |
| 27 | vty->index = trx->bts; |
| 28 | } |
| 29 | break; |
| 30 | #endif |
| 31 | default: |
| 32 | vty->node = CONFIG_NODE; |
| 33 | } |
| 34 | return vty->node; |
| 35 | } |
| 36 | |
| 37 | int pcu_vty_is_config_node(struct vty *vty, int node) |
| 38 | { |
| 39 | switch (node) { |
| 40 | #if 0 |
| 41 | case TRX_NODE: |
| 42 | case BTS_NODE: |
| 43 | return 1; |
| 44 | #endif |
| 45 | default: |
| 46 | return 0; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | gDEFUN(ournode_exit, ournode_exit_cmd, "exit", |
| 51 | "Exit current node, go down to provious node") |
| 52 | { |
| 53 | switch (vty->node) { |
| 54 | #if 0 |
| 55 | case TRXV_NODE: |
| 56 | vty->node = BTS_NODE; |
| 57 | { |
| 58 | struct gsm_bts_trx *trx = vty->index; |
| 59 | vty->index = trx->bts; |
| 60 | } |
| 61 | break; |
| 62 | #endif |
| 63 | default: |
| 64 | break; |
| 65 | } |
| 66 | return CMD_SUCCESS; |
| 67 | } |
| 68 | |
| 69 | gDEFUN(ournode_end, ournode_end_cmd, "end", |
| 70 | "End current mode and change to enable mode") |
| 71 | { |
| 72 | switch (vty->node) { |
| 73 | default: |
| 74 | vty_config_unlock(vty); |
| 75 | vty->node = ENABLE_NODE; |
| 76 | vty->index = NULL; |
| 77 | vty->index_sub = NULL; |
| 78 | break; |
| 79 | } |
| 80 | return CMD_SUCCESS; |
| 81 | } |
| 82 | |
| 83 | static const char pcu_copyright[] = |
| 84 | "Copyright (C) 2012 by ...\r\n" |
| 85 | "License GNU GPL version 2 or later\r\n" |
| 86 | "This is free software: you are free to change and redistribute it.\r\n" |
| 87 | "There is NO WARRANTY, to the extent permitted by law.\r\n"; |
| 88 | |
| 89 | struct vty_app_info pcu_vty_info = { |
| 90 | .name = "Osmo-PCU", |
| 91 | .version = PACKAGE_VERSION, |
| 92 | .copyright = pcu_copyright, |
| 93 | .go_parent_cb = pcu_vty_go_parent, |
| 94 | .is_config_node = pcu_vty_is_config_node, |
| 95 | }; |
| 96 | |
| 97 | int pcu_vty_init(const struct log_info *cat) |
| 98 | { |
| 99 | // install_element_ve(&show_pcu_cmd); |
| 100 | |
| 101 | logging_vty_add_cmds(cat); |
| 102 | |
| 103 | return 0; |
| 104 | } |