blob: 2413f21d9c95b4f6cd85b4c799fcf0303aad1ce8 [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);
Andreas Eversberg24131bf2012-07-21 11:09:58 +020084 if (bts->force_llc_lifetime == 0xffff)
85 vty_out(vty, " queue lifetime infinite%s", VTY_NEWLINE);
86 else if (bts->force_llc_lifetime)
87 vty_out(vty, " queue lifetime %d%s", bts->force_llc_lifetime,
88 VTY_NEWLINE);
Andreas Eversberg8b761a32012-07-20 21:50:31 +020089}
90
91/* per-BTS configuration */
92DEFUN(cfg_pcu,
93 cfg_pcu_cmd,
94 "pcu",
95 "BTS specific configure")
96{
97 vty->node = PCU_NODE;
98
99 return CMD_SUCCESS;
100}
101
102DEFUN(cfg_pcu_cs,
103 cfg_pcu_cs_cmd,
104 "cs <1-4>",
105 "Set the Coding Scheme to be used, (overrides BTS config)\n")
106{
107 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
108 uint8_t cs = atoi(argv[0]);
109
110 bts->force_cs = 1;
111 bts->initial_cs = cs;
112
113 return CMD_SUCCESS;
114}
115
116DEFUN(cfg_pcu_no_cs,
117 cfg_pcu_no_cs_cmd,
118 "no cs",
119 NO_STR "Don't force given Coding Scheme, (use BTS config)\n")
120{
121 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
122
123 bts->force_cs = 0;
124
125 return CMD_SUCCESS;
126}
127
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200128#define QUEUE_STR "Packet queue options\n"
129#define LIFETIME_STR "Set lifetime limit of LLC frame in centi-seconds " \
130 "(overrides the value given by SGSN)\n"
131
132DEFUN(cfg_pcu_queue_lifetime,
133 cfg_pcu_queue_lifetime_cmd,
134 "queue lifetime <1-65534>",
135 QUEUE_STR LIFETIME_STR "Lifetime in centi-seconds")
136{
137 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
138 uint8_t csec = atoi(argv[0]);
139
140 bts->force_llc_lifetime = csec;
141
142 return CMD_SUCCESS;
143}
144
145DEFUN(cfg_pcu_queue_lifetime_inf,
146 cfg_pcu_queue_lifetime_inf_cmd,
147 "queue lifetime infinite",
148 QUEUE_STR LIFETIME_STR "Infinite lifetime")
149{
150 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
151
152 bts->force_llc_lifetime = 0xffff;
153
154 return CMD_SUCCESS;
155}
156
157DEFUN(cfg_pcu_no_queue_lifetime,
158 cfg_pcu_no_queue_lifetime_cmd,
159 "no queue lifetime",
160 NO_STR QUEUE_STR "Disable lifetime limit of LLC frame (use value given "
161 "by SGSN)\n")
162{
163 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
164
165 bts->force_llc_lifetime = 0;
166
167 return CMD_SUCCESS;
168}
169
Andreas Eversberg12942562012-07-12 14:31:57 +0200170static const char pcu_copyright[] =
171 "Copyright (C) 2012 by ...\r\n"
172 "License GNU GPL version 2 or later\r\n"
173 "This is free software: you are free to change and redistribute it.\r\n"
174 "There is NO WARRANTY, to the extent permitted by law.\r\n";
175
176struct vty_app_info pcu_vty_info = {
177 .name = "Osmo-PCU",
178 .version = PACKAGE_VERSION,
179 .copyright = pcu_copyright,
180 .go_parent_cb = pcu_vty_go_parent,
181 .is_config_node = pcu_vty_is_config_node,
182};
183
184int pcu_vty_init(const struct log_info *cat)
185{
186// install_element_ve(&show_pcu_cmd);
187
188 logging_vty_add_cmds(cat);
189
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200190 install_node(&pcu_node, config_write_pcu);
191 install_element(CONFIG_NODE, &cfg_pcu_cmd);
192 install_default(PCU_NODE);
193 install_element(PCU_NODE, &cfg_pcu_cs_cmd);
194 install_element(PCU_NODE, &cfg_pcu_no_cs_cmd);
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200195 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_cmd);
196 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_inf_cmd);
197 install_element(PCU_NODE, &cfg_pcu_no_queue_lifetime_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200198 install_element(PCU_NODE, &ournode_end_cmd);
199
Andreas Eversberg12942562012-07-12 14:31:57 +0200200 return 0;
201}