blob: 179080bbe7a93f46358e7d0b5919e2085b743b8b [file] [log] [blame]
Andreas Eversberg12942562012-07-12 14:31:57 +02001/* OsmoBTS VTY interface */
2
Andreas Eversberg12942562012-07-12 14:31:57 +02003
Andreas Eversberg8b761a32012-07-20 21:50:31 +02004#include <stdint.h>
Andreas Eversberg12942562012-07-12 14:31:57 +02005#include <osmocom/vty/logging.h>
Andreas Eversberg8b761a32012-07-20 21:50:31 +02006#include <osmocom/core/linuxlist.h>
Andreas Eversberg12942562012-07-12 14:31:57 +02007#include "pcu_vty.h"
Andreas Eversberg8b761a32012-07-20 21:50:31 +02008#include "gprs_rlcmac.h"
Andreas Eversberg12942562012-07-12 14:31:57 +02009
10enum node_type pcu_vty_go_parent(struct vty *vty)
11{
12 switch (vty->node) {
13#if 0
14 case TRX_NODE:
Andreas Eversberg8b761a32012-07-20 21:50:31 +020015 vty->node = PCU_NODE;
Andreas Eversberg12942562012-07-12 14:31:57 +020016 {
17 struct gsm_bts_trx *trx = vty->index;
18 vty->index = trx->bts;
19 }
20 break;
21#endif
22 default:
23 vty->node = CONFIG_NODE;
24 }
Andreas Eversberg8b761a32012-07-20 21:50:31 +020025 return (enum node_type) vty->node;
Andreas Eversberg12942562012-07-12 14:31:57 +020026}
27
28int pcu_vty_is_config_node(struct vty *vty, int node)
29{
30 switch (node) {
Andreas Eversberg8b761a32012-07-20 21:50:31 +020031 case PCU_NODE:
Andreas Eversberg12942562012-07-12 14:31:57 +020032 return 1;
Andreas Eversberg12942562012-07-12 14:31:57 +020033 default:
34 return 0;
35 }
36}
37
Andreas Eversberg8b761a32012-07-20 21:50:31 +020038static struct cmd_node pcu_node = {
39 (enum node_type) PCU_NODE,
40 "%s(pcu)#",
41 1,
42};
43
Andreas Eversberg12942562012-07-12 14:31:57 +020044gDEFUN(ournode_exit, ournode_exit_cmd, "exit",
45 "Exit current node, go down to provious node")
46{
47 switch (vty->node) {
48#if 0
49 case TRXV_NODE:
Andreas Eversberg8b761a32012-07-20 21:50:31 +020050 vty->node = PCU_NODE;
Andreas Eversberg12942562012-07-12 14:31:57 +020051 {
52 struct gsm_bts_trx *trx = vty->index;
53 vty->index = trx->bts;
54 }
55 break;
56#endif
57 default:
58 break;
59 }
60 return CMD_SUCCESS;
61}
62
63gDEFUN(ournode_end, ournode_end_cmd, "end",
64 "End current mode and change to enable mode")
65{
66 switch (vty->node) {
67 default:
68 vty_config_unlock(vty);
69 vty->node = ENABLE_NODE;
70 vty->index = NULL;
71 vty->index_sub = NULL;
72 break;
73 }
74 return CMD_SUCCESS;
75}
76
Andreas Eversberg8b761a32012-07-20 21:50:31 +020077static int config_write_pcu(struct vty *vty)
78{
79 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
80
81 vty_out(vty, "pcu%s", VTY_NEWLINE);
82 if (bts->force_cs)
83 vty_out(vty, " cs %d%s", bts->initial_cs, VTY_NEWLINE);
84}
85
86/* per-BTS configuration */
87DEFUN(cfg_pcu,
88 cfg_pcu_cmd,
89 "pcu",
90 "BTS specific configure")
91{
92 vty->node = PCU_NODE;
93
94 return CMD_SUCCESS;
95}
96
97DEFUN(cfg_pcu_cs,
98 cfg_pcu_cs_cmd,
99 "cs <1-4>",
100 "Set the Coding Scheme to be used, (overrides BTS config)\n")
101{
102 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
103 uint8_t cs = atoi(argv[0]);
104
105 bts->force_cs = 1;
106 bts->initial_cs = cs;
107
108 return CMD_SUCCESS;
109}
110
111DEFUN(cfg_pcu_no_cs,
112 cfg_pcu_no_cs_cmd,
113 "no cs",
114 NO_STR "Don't force given Coding Scheme, (use BTS config)\n")
115{
116 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
117
118 bts->force_cs = 0;
119
120 return CMD_SUCCESS;
121}
122
Andreas Eversberg12942562012-07-12 14:31:57 +0200123static const char pcu_copyright[] =
124 "Copyright (C) 2012 by ...\r\n"
125 "License GNU GPL version 2 or later\r\n"
126 "This is free software: you are free to change and redistribute it.\r\n"
127 "There is NO WARRANTY, to the extent permitted by law.\r\n";
128
129struct vty_app_info pcu_vty_info = {
130 .name = "Osmo-PCU",
131 .version = PACKAGE_VERSION,
132 .copyright = pcu_copyright,
133 .go_parent_cb = pcu_vty_go_parent,
134 .is_config_node = pcu_vty_is_config_node,
135};
136
137int pcu_vty_init(const struct log_info *cat)
138{
139// install_element_ve(&show_pcu_cmd);
140
141 logging_vty_add_cmds(cat);
142
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200143 install_node(&pcu_node, config_write_pcu);
144 install_element(CONFIG_NODE, &cfg_pcu_cmd);
145 install_default(PCU_NODE);
146 install_element(PCU_NODE, &cfg_pcu_cs_cmd);
147 install_element(PCU_NODE, &cfg_pcu_no_cs_cmd);
148 install_element(PCU_NODE, &ournode_end_cmd);
149
Andreas Eversberg12942562012-07-12 14:31:57 +0200150 return 0;
151}