| 1 |
/* Copyright (C) 2015 by Yves Godin <[email protected]> |
| 2 |
* |
| 3 |
* Based on sysmoBTS: |
| 4 |
* sysmobts_mgr_vty.c |
| 5 |
* (C) 2014 by oc2gcom - s.f.m.c. GmbH |
| 6 |
* |
| 7 |
* All Rights Reserved |
| 8 |
* |
| 9 |
* Author: Alvaro Neira Ayuso <[email protected]> |
| 10 |
* |
| 11 |
* This program is free software; you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU Affero General Public License as published by |
| 13 |
* the Free Software Foundation; either version 3 of the License, or |
| 14 |
* (at your option) any later version. |
| 15 |
* |
| 16 |
* This program is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU Affero General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU Affero General Public License |
| 22 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#include <stdlib.h> |
| 27 |
#include <unistd.h> |
| 28 |
#include <errno.h> |
| 29 |
#include <stdint.h> |
| 30 |
#include <ctype.h> |
| 31 |
#include <string.h> |
| 32 |
#include <sys/socket.h> |
| 33 |
#include <netinet/in.h> |
| 34 |
#include <arpa/inet.h> |
| 35 |
#include <inttypes.h> |
| 36 |
|
| 37 |
#include <osmocom/vty/vty.h> |
| 38 |
#include <osmocom/vty/command.h> |
| 39 |
#include <osmocom/vty/misc.h> |
| 40 |
|
| 41 |
#include <osmo-bts/logging.h> |
| 42 |
|
| 43 |
#include "oc2gbts_misc.h" |
| 44 |
#include "oc2gbts_mgr.h" |
| 45 |
#include "oc2gbts_temp.h" |
| 46 |
#include "oc2gbts_power.h" |
| 47 |
#include "oc2gbts_bid.h" |
| 48 |
#include "oc2gbts_led.h" |
| 49 |
#include "btsconfig.h" |
| 50 |
|
| 51 |
static struct oc2gbts_mgr_instance *s_mgr; |
| 52 |
|
| 53 |
static const char copyright[] = |
| 54 |
"(C) 2012 by Harald Welte <[email protected]>\r\n" |
| 55 |
"(C) 2014 by Holger Hans Peter Freyther\r\n" |
| 56 |
"(C) 2015 by Yves Godin <[email protected]>\r\n" |
| 57 |
"License AGPLv3+: GNU AGPL version 2 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n" |
| 58 |
"This is free software: you are free to change and redistribute it.\r\n" |
| 59 |
"There is NO WARRANTY, to the extent permitted by law.\r\n"; |
| 60 |
|
| 61 |
static int go_to_parent(struct vty *vty) |
| 62 |
{ |
| 63 |
switch (vty->node) { |
| 64 |
case MGR_NODE: |
| 65 |
vty->node = CONFIG_NODE; |
| 66 |
break; |
| 67 |
case ACT_NORM_NODE: |
| 68 |
case ACT_WARN_NODE: |
| 69 |
case ACT_CRIT_NODE: |
| 70 |
case LIMIT_SUPPLY_TEMP_NODE: |
| 71 |
case LIMIT_SOC_NODE: |
| 72 |
case LIMIT_FPGA_NODE: |
| 73 |
case LIMIT_RMSDET_NODE: |
| 74 |
case LIMIT_OCXO_NODE: |
| 75 |
case LIMIT_TX_TEMP_NODE: |
| 76 |
case LIMIT_PA_TEMP_NODE: |
| 77 |
case LIMIT_SUPPLY_VOLT_NODE: |
| 78 |
case LIMIT_VSWR_NODE: |
| 79 |
case LIMIT_SUPPLY_PWR_NODE: |
| 80 |
case LIMIT_PA_PWR_NODE: |
| 81 |
vty->node = MGR_NODE; |
| 82 |
break; |
| 83 |
default: |
| 84 |
vty->node = CONFIG_NODE; |
| 85 |
} |
| 86 |
return vty->node; |
| 87 |
} |
| 88 |
|
| 89 |
static struct vty_app_info vty_info = { |
| 90 |
.name = "oc2gbts-mgr", |
| 91 |
.version = PACKAGE_VERSION, |
| 92 |
.go_parent_cb = go_to_parent, |
| 93 |
.copyright = copyright, |
| 94 |
}; |
| 95 |
|
| 96 |
|
| 97 |
#define MGR_STR "Configure oc2gbts-mgr\n" |
| 98 |
|
| 99 |
static struct cmd_node mgr_node = { |
| 100 |
MGR_NODE, |
| 101 |
"%s(oc2gbts-mgr)# ", |
| 102 |
1, |
| 103 |
}; |
| 104 |
|
| 105 |
static struct cmd_node act_norm_node = { |
| 106 |
ACT_NORM_NODE, |
| 107 |
"%s(actions-normal)# ", |
| 108 |
1, |
| 109 |
}; |
| 110 |
|
| 111 |
static struct cmd_node act_warn_node = { |
| 112 |
ACT_WARN_NODE, |
| 113 |
"%s(actions-warn)# ", |
| 114 |
1, |
| 115 |
}; |
| 116 |
|
| 117 |
static struct cmd_node act_crit_node = { |
| 118 |
ACT_CRIT_NODE, |
| 119 |
"%s(actions-critical)# ", |
| 120 |
1, |
| 121 |
}; |
| 122 |
|
| 123 |
static struct cmd_node limit_supply_temp_node = { |
| 124 |
LIMIT_SUPPLY_TEMP_NODE, |
| 125 |
"%s(limit-supply-temp)# ", |
| 126 |
1, |
| 127 |
}; |
| 128 |
|
| 129 |
static struct cmd_node limit_soc_node = { |
| 130 |
LIMIT_SOC_NODE, |
| 131 |
"%s(limit-soc)# ", |
| 132 |
1, |
| 133 |
}; |
| 134 |
|
| 135 |
static struct cmd_node limit_fpga_node = { |
| 136 |
LIMIT_FPGA_NODE, |
| 137 |
"%s(limit-fpga)# ", |
| 138 |
1, |
| 139 |
}; |
| 140 |
|
| 141 |
static struct cmd_node limit_rmsdet_node = { |
| 142 |
LIMIT_RMSDET_NODE, |
| 143 |
"%s(limit-rmsdet)# ", |
| 144 |
1, |
| 145 |
}; |
| 146 |
|
| 147 |
static struct cmd_node limit_ocxo_node = { |
| 148 |
LIMIT_OCXO_NODE, |
| 149 |
"%s(limit-ocxo)# ", |
| 150 |
1, |
| 151 |
}; |
| 152 |
|
| 153 |
static struct cmd_node limit_tx_temp_node = { |
| 154 |
LIMIT_TX_TEMP_NODE, |
| 155 |
"%s(limit-tx-temp)# ", |
| 156 |
1, |
| 157 |
}; |
| 158 |
static struct cmd_node limit_pa_temp_node = { |
| 159 |
LIMIT_PA_TEMP_NODE, |
| 160 |
"%s(limit-pa-temp)# ", |
| 161 |
1, |
| 162 |
}; |
| 163 |
static struct cmd_node limit_supply_volt_node = { |
| 164 |
LIMIT_SUPPLY_VOLT_NODE, |
| 165 |
"%s(limit-supply-volt)# ", |
| 166 |
1, |
| 167 |
}; |
| 168 |
static struct cmd_node limit_vswr_node = { |
| 169 |
LIMIT_VSWR_NODE, |
| 170 |
"%s(limit-vswr)# ", |
| 171 |
1, |
| 172 |
}; |
| 173 |
static struct cmd_node limit_supply_pwr_node = { |
| 174 |
LIMIT_SUPPLY_PWR_NODE, |
| 175 |
"%s(limit-supply-pwr)# ", |
| 176 |
1, |
| 177 |
}; |
| 178 |
static struct cmd_node limit_pa_pwr_node = { |
| 179 |
LIMIT_PA_PWR_NODE, |
| 180 |
"%s(limit-pa-pwr)# ", |
| 181 |
1, |
| 182 |
}; |
| 183 |
|
| 184 |
static struct cmd_node limit_gps_fix_node = { |
| 185 |
LIMIT_GPS_FIX_NODE, |
| 186 |
"%s(limit-gps-fix)# ", |
| 187 |
1, |
| 188 |
}; |
| 189 |
|
| 190 |
DEFUN(cfg_mgr, cfg_mgr_cmd, |
| 191 |
"oc2gbts-mgr", |
| 192 |
MGR_STR) |
| 193 |
{ |
| 194 |
vty->node = MGR_NODE; |
| 195 |
return CMD_SUCCESS; |
| 196 |
} |
| 197 |
|
| 198 |
static void write_volt_limit(struct vty *vty, const char *name, |
| 199 |
struct oc2gbts_volt_limit *limit) |
| 200 |
{ |
| 201 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 202 |
vty_out(vty, " threshold warning min %d%s", |
| 203 |
limit->thresh_warn_min, VTY_NEWLINE); |
| 204 |
vty_out(vty, " threshold critical min %d%s", |
| 205 |
limit->thresh_crit_min, VTY_NEWLINE); |
| 206 |
} |
| 207 |
|
| 208 |
static void write_vswr_limit(struct vty *vty, const char *name, |
| 209 |
struct oc2gbts_vswr_limit *limit) |
| 210 |
{ |
| 211 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 212 |
vty_out(vty, " threshold warning max %d%s", |
| 213 |
limit->thresh_warn_max, VTY_NEWLINE); |
| 214 |
} |
| 215 |
|
| 216 |
static void write_pwr_limit(struct vty *vty, const char *name, |
| 217 |
struct oc2gbts_pwr_limit *limit) |
| 218 |
{ |
| 219 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 220 |
vty_out(vty, " threshold warning max %d%s", |
| 221 |
limit->thresh_warn_max, VTY_NEWLINE); |
| 222 |
vty_out(vty, " threshold critical max %d%s", |
| 223 |
limit->thresh_crit_max, VTY_NEWLINE); |
| 224 |
} |
| 225 |
|
| 226 |
static void write_norm_action(struct vty *vty, const char *name, int actions) |
| 227 |
{ |
| 228 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 229 |
vty_out(vty, " %spa-on%s", |
| 230 |
(actions & SENSOR_ACT_NORM_PA_ON) ? "" : "no ", VTY_NEWLINE); |
| 231 |
vty_out(vty, " %sbts-service-on%s", |
| 232 |
(actions & SENSOR_ACT_NORM_BTS_SRV_ON) ? "" : "no ", VTY_NEWLINE); |
| 233 |
} |
| 234 |
|
| 235 |
static void write_action(struct vty *vty, const char *name, int actions) |
| 236 |
{ |
| 237 |
vty_out(vty, " %s%s", name, VTY_NEWLINE); |
| 238 |
vty_out(vty, " %spa-off%s", |
| 239 |
(actions & SENSOR_ACT_PA_OFF) ? "" : "no ", VTY_NEWLINE); |
| 240 |
vty_out(vty, " %sbts-service-off%s", |
| 241 |
(actions & SENSOR_ACT_BTS_SRV_OFF) ? "" : "no ", VTY_NEWLINE); |
| 242 |
} |
| 243 |
|
| 244 |
static int config_write_mgr(struct vty *vty) |
| 245 |
{ |
| 246 |
vty_out(vty, "oc2gbts-mgr%s", VTY_NEWLINE); |
| 247 |
|
| 248 |
write_volt_limit(vty, "limits supply_volt", &s_mgr->volt.supply_volt_limit); |
| 249 |
write_pwr_limit(vty, "limits supply_pwr", &s_mgr->pwr.supply_pwr_limit); |
| 250 |
write_vswr_limit(vty, "limits vswr", &s_mgr->vswr.vswr_limit); |
| 251 |
|
| 252 |
write_norm_action(vty, "actions normal", s_mgr->state.action_norm); |
| 253 |
write_action(vty, "actions warn", s_mgr->state.action_warn); |
| 254 |
write_action(vty, "actions critical", s_mgr->state.action_crit); |
| 255 |
|
| 256 |
return CMD_SUCCESS; |
| 257 |
} |
| 258 |
|
| 259 |
static int config_write_dummy(struct vty *vty) |
| 260 |
{ |
| 261 |
return CMD_SUCCESS; |
| 262 |
} |
| 263 |
|
| 264 |
#define CFG_LIMIT_TEMP(name, expl, switch_to, variable) \ |
| 265 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 266 |
"limits " #name, \ |
| 267 |
"Configure Limits\n" expl) \ |
| 268 |
{ \ |
| 269 |
vty->node = switch_to; \ |
| 270 |
vty->index = &s_mgr->temp.variable; \ |
| 271 |
return CMD_SUCCESS; \ |
| 272 |
} |
| 273 |
|
| 274 |
CFG_LIMIT_TEMP(supply_temp, "SUPPLY TEMP\n", LIMIT_SUPPLY_TEMP_NODE, supply_temp_limit) |
| 275 |
CFG_LIMIT_TEMP(soc_temp, "SOC TEMP\n", LIMIT_SOC_NODE, soc_temp_limit) |
| 276 |
CFG_LIMIT_TEMP(fpga_temp, "FPGA TEMP\n", LIMIT_FPGA_NODE, fpga_temp_limit) |
| 277 |
CFG_LIMIT_TEMP(rmsdet_temp, "RMSDET TEMP\n", LIMIT_RMSDET_NODE, rmsdet_temp_limit) |
| 278 |
CFG_LIMIT_TEMP(ocxo_temp, "OCXO TEMP\n", LIMIT_OCXO_NODE, ocxo_temp_limit) |
| 279 |
CFG_LIMIT_TEMP(tx_temp, "TX TEMP\n", LIMIT_TX_TEMP_NODE, tx_temp_limit) |
| 280 |
CFG_LIMIT_TEMP(pa_temp, "PA TEMP\n", LIMIT_PA_TEMP_NODE, pa_temp_limit) |
| 281 |
#undef CFG_LIMIT_TEMP |
| 282 |
|
| 283 |
#define CFG_LIMIT_VOLT(name, expl, switch_to, variable) \ |
| 284 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 285 |
"limits " #name, \ |
| 286 |
"Configure Limits\n" expl) \ |
| 287 |
{ \ |
| 288 |
vty->node = switch_to; \ |
| 289 |
vty->index = &s_mgr->volt.variable; \ |
| 290 |
return CMD_SUCCESS; \ |
| 291 |
} |
| 292 |
|
| 293 |
CFG_LIMIT_VOLT(supply_volt, "SUPPLY VOLT\n", LIMIT_SUPPLY_VOLT_NODE, supply_volt_limit) |
| 294 |
#undef CFG_LIMIT_VOLT |
| 295 |
|
| 296 |
#define CFG_LIMIT_VSWR(name, expl, switch_to, variable) \ |
| 297 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 298 |
"limits " #name, \ |
| 299 |
"Configure Limits\n" expl) \ |
| 300 |
{ \ |
| 301 |
vty->node = switch_to; \ |
| 302 |
vty->index = &s_mgr->vswr.variable; \ |
| 303 |
return CMD_SUCCESS; \ |
| 304 |
} |
| 305 |
|
| 306 |
CFG_LIMIT_VSWR(vswr, "VSWR\n", LIMIT_VSWR_NODE, vswr_limit) |
| 307 |
#undef CFG_LIMIT_VSWR |
| 308 |
|
| 309 |
#define CFG_LIMIT_PWR(name, expl, switch_to, variable) \ |
| 310 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 311 |
"limits " #name, \ |
| 312 |
"Configure Limits\n" expl) \ |
| 313 |
{ \ |
| 314 |
vty->node = switch_to; \ |
| 315 |
vty->index = &s_mgr->pwr.variable; \ |
| 316 |
return CMD_SUCCESS; \ |
| 317 |
} |
| 318 |
|
| 319 |
CFG_LIMIT_PWR(supply_pwr, "SUPPLY PWR\n", LIMIT_SUPPLY_PWR_NODE, supply_pwr_limit) |
| 320 |
CFG_LIMIT_PWR(pa_pwr, "PA PWR\n", LIMIT_PA_PWR_NODE, pa_pwr_limit) |
| 321 |
#undef CFG_LIMIT_PWR |
| 322 |
|
| 323 |
#define CFG_LIMIT_GPS_FIX(name, expl, switch_to, variable) \ |
| 324 |
DEFUN(cfg_limit_##name, cfg_limit_##name##_cmd, \ |
| 325 |
"limits " #name, \ |
| 326 |
"Configure Limits\n" expl) \ |
| 327 |
{ \ |
| 328 |
vty->node = switch_to; \ |
| 329 |
vty->index = &s_mgr->gps.variable; \ |
| 330 |
return CMD_SUCCESS; \ |
| 331 |
} |
| 332 |
|
| 333 |
CFG_LIMIT_GPS_FIX(gps_fix, "GPS FIX\n", LIMIT_GPS_FIX_NODE, gps_fix_limit) |
| 334 |
#undef CFG_LIMIT_GPS_FIX |
| 335 |
|
| 336 |
DEFUN(cfg_limit_volt_warn_min, cfg_thresh_volt_warn_min_cmd, |
| 337 |
"threshold warning min <0-48000>", |
| 338 |
"Threshold to reach\n" "Warning level\n" "Range\n") |
| 339 |
{ |
| 340 |
struct oc2gbts_volt_limit *limit = vty->index; |
| 341 |
limit->thresh_warn_min = atoi(argv[0]); |
| 342 |
return CMD_SUCCESS; |
| 343 |
} |
| 344 |
|
| 345 |
DEFUN(cfg_limit_volt_crit_min, cfg_thresh_volt_crit_min_cmd, |
| 346 |
"threshold critical min <0-48000>", |
| 347 |
"Threshold to reach\n" "Critical level\n" "Range\n") |
| 348 |
{ |
| 349 |
struct oc2gbts_volt_limit *limit = vty->index; |
| 350 |
limit->thresh_crit_min = atoi(argv[0]); |
| 351 |
return CMD_SUCCESS; |
| 352 |
} |
| 353 |
|
| 354 |
DEFUN(cfg_limit_vswr_warn_max, cfg_thresh_vswr_warn_max_cmd, |
| 355 |
"threshold warning max <1000-200000>", |
| 356 |
"Threshold to reach\n" "Warning level\n" "Range\n") |
| 357 |
{ |
| 358 |
struct oc2gbts_vswr_limit *limit = vty->index; |
| 359 |
limit->thresh_warn_max = atoi(argv[0]); |
| 360 |
return CMD_SUCCESS; |
| 361 |
} |
| 362 |
|
| 363 |
DEFUN(cfg_limit_vswr_crit_max, cfg_thresh_vswr_crit_max_cmd, |
| 364 |
"threshold critical max <1000-200000>", |
| 365 |
"Threshold to reach\n" "Warning level\n" "Range\n") |
| 366 |
{ |
| 367 |
struct oc2gbts_vswr_limit *limit = vty->index; |
| 368 |
limit->thresh_crit_max = atoi(argv[0]); |
| 369 |
return CMD_SUCCESS; |
| 370 |
} |
| 371 |
|
| 372 |
DEFUN(cfg_limit_pwr_warn_max, cfg_thresh_pwr_warn_max_cmd, |
| 373 |
"threshold warning max <0-200>", |
| 374 |
"Threshold to reach\n" "Warning level\n" "Range\n") |
| 375 |
{ |
| 376 |
struct oc2gbts_pwr_limit *limit = vty->index; |
| 377 |
limit->thresh_warn_max = atoi(argv[0]); |
| 378 |
return CMD_SUCCESS; |
| 379 |
} |
| 380 |
|
| 381 |
DEFUN(cfg_limit_pwr_crit_max, cfg_thresh_pwr_crit_max_cmd, |
| 382 |
"threshold critical max <0-200>", |
| 383 |
"Threshold to reach\n" "Warning level\n" "Range\n") |
| 384 |
{ |
| 385 |
struct oc2gbts_pwr_limit *limit = vty->index; |
| 386 |
limit->thresh_crit_max = atoi(argv[0]); |
| 387 |
return CMD_SUCCESS; |
| 388 |
} |
| 389 |
|
| 390 |
#define CFG_ACTION(name, expl, switch_to, variable) \ |
| 391 |
DEFUN(cfg_action_##name, cfg_action_##name##_cmd, \ |
| 392 |
"actions " #name, \ |
| 393 |
"Configure Actions\n" expl) \ |
| 394 |
{ \ |
| 395 |
vty->node = switch_to; \ |
| 396 |
vty->index = &s_mgr->state.variable; \ |
| 397 |
return CMD_SUCCESS; \ |
| 398 |
} |
| 399 |
CFG_ACTION(normal, "Normal Actions\n", ACT_NORM_NODE, action_norm) |
| 400 |
CFG_ACTION(warn, "Warning Actions\n", ACT_WARN_NODE, action_warn) |
| 401 |
CFG_ACTION(critical, "Critical Actions\n", ACT_CRIT_NODE, action_crit) |
| 402 |
#undef CFG_ACTION |
| 403 |
|
| 404 |
DEFUN(cfg_action_pa_on, cfg_action_pa_on_cmd, |
| 405 |
"pa-on", |
| 406 |
"Switch the Power Amplifier on\n") |
| 407 |
{ |
| 408 |
int *action = vty->index; |
| 409 |
*action |= SENSOR_ACT_NORM_PA_ON; |
| 410 |
return CMD_SUCCESS; |
| 411 |
} |
| 412 |
|
| 413 |
DEFUN(cfg_no_action_pa_on, cfg_no_action_pa_on_cmd, |
| 414 |
"no pa-on", |
| 415 |
NO_STR "Switch the Power Amplifier on\n") |
| 416 |
{ |
| 417 |
int *action = vty->index; |
| 418 |
*action &= ~SENSOR_ACT_NORM_PA_ON; |
| 419 |
return CMD_SUCCESS; |
| 420 |
} |
| 421 |
|
| 422 |
DEFUN(cfg_action_bts_srv_on, cfg_action_bts_srv_on_cmd, |
| 423 |
"bts-service-on", |
| 424 |
"Start the systemd oc2gbts.service\n") |
| 425 |
{ |
| 426 |
int *action = vty->index; |
| 427 |
*action |= SENSOR_ACT_NORM_BTS_SRV_ON; |
| 428 |
return CMD_SUCCESS; |
| 429 |
} |
| 430 |
|
| 431 |
DEFUN(cfg_no_action_bts_srv_on, cfg_no_action_bts_srv_on_cmd, |
| 432 |
"no bts-service-on", |
| 433 |
NO_STR "Start the systemd oc2gbts.service\n") |
| 434 |
{ |
| 435 |
int *action = vty->index; |
| 436 |
*action &= ~SENSOR_ACT_NORM_BTS_SRV_ON; |
| 437 |
return CMD_SUCCESS; |
| 438 |
} |
| 439 |
|
| 440 |
DEFUN(cfg_action_pa_off, cfg_action_pa_off_cmd, |
| 441 |
"pa-off", |
| 442 |
"Switch the Power Amplifier off\n") |
| 443 |
{ |
| 444 |
int *action = vty->index; |
| 445 |
*action |= SENSOR_ACT_PA_OFF; |
| 446 |
return CMD_SUCCESS; |
| 447 |
} |
| 448 |
|
| 449 |
DEFUN(cfg_no_action_pa_off, cfg_no_action_pa_off_cmd, |
| 450 |
"no pa-off", |
| 451 |
NO_STR "Do not switch off the Power Amplifier\n") |
| 452 |
{ |
| 453 |
int *action = vty->index; |
| 454 |
*action &= ~SENSOR_ACT_PA_OFF; |
| 455 |
return CMD_SUCCESS; |
| 456 |
} |
| 457 |
|
| 458 |
DEFUN(cfg_action_bts_srv_off, cfg_action_bts_srv_off_cmd, |
| 459 |
"bts-service-off", |
| 460 |
"Stop the systemd oc2gbts.service\n") |
| 461 |
{ |
| 462 |
int *action = vty->index; |
| 463 |
*action |= SENSOR_ACT_BTS_SRV_OFF; |
| 464 |
return CMD_SUCCESS; |
| 465 |
} |
| 466 |
|
| 467 |
DEFUN(cfg_no_action_bts_srv_off, cfg_no_action_bts_srv_off_cmd, |
| 468 |
"no bts-service-off", |
| 469 |
NO_STR "Stop the systemd oc2gbts.service\n") |
| 470 |
{ |
| 471 |
int *action = vty->index; |
| 472 |
*action &= ~SENSOR_ACT_BTS_SRV_OFF; |
| 473 |
return CMD_SUCCESS; |
| 474 |
} |
| 475 |
|
| 476 |
DEFUN(show_mgr, show_mgr_cmd, "show manager", |
| 477 |
SHOW_STR "Display information about the manager") |
| 478 |
{ |
| 479 |
int temp, volt, current, power, vswr; |
| 480 |
vty_out(vty, "Warning alarm flags: 0x%08x%s", |
| 481 |
s_mgr->oc2gbts_ctrl.warn_flags, VTY_NEWLINE); |
| 482 |
vty_out(vty, "Critical alarm flags: 0x%08x%s", |
| 483 |
s_mgr->oc2gbts_ctrl.crit_flags, VTY_NEWLINE); |
| 484 |
vty_out(vty, "Preventive action retried: %d%s", |
| 485 |
s_mgr->alarms.preventive_retry, VTY_NEWLINE); |
| 486 |
vty_out(vty, "Temperature control state: %s%s", |
| 487 |
oc2gbts_mgr_sensor_get_state(s_mgr->state.state), VTY_NEWLINE); |
| 488 |
vty_out(vty, "Current Temperatures%s", VTY_NEWLINE); |
| 489 |
oc2gbts_temp_get(OC2GBTS_TEMP_SUPPLY, &temp); |
| 490 |
vty_out(vty, " Main Supply : %4.2f Celsius%s", |
| 491 |
temp/ 1000.0f, |
| 492 |
VTY_NEWLINE); |
| 493 |
oc2gbts_temp_get(OC2GBTS_TEMP_SOC, &temp); |
| 494 |
vty_out(vty, " SoC : %4.2f Celsius%s", |
| 495 |
temp / 1000.0f, |
| 496 |
VTY_NEWLINE); |
| 497 |
oc2gbts_temp_get(OC2GBTS_TEMP_FPGA, &temp); |
| 498 |
vty_out(vty, " FPGA : %4.2f Celsius%s", |
| 499 |
temp / 1000.0f, |
| 500 |
VTY_NEWLINE); |
| 501 |
if (oc2gbts_option_get(OC2GBTS_OPTION_RMS_FWD) || |
| 502 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_REFL)) { |
| 503 |
oc2gbts_temp_get(OC2GBTS_TEMP_RMSDET, &temp); |
| 504 |
vty_out(vty, " RMSDet : %4.2f Celsius%s", |
| 505 |
temp / 1000.0f, |
| 506 |
VTY_NEWLINE); |
| 507 |
} |
| 508 |
oc2gbts_temp_get(OC2GBTS_TEMP_OCXO, &temp); |
| 509 |
vty_out(vty, " OCXO : %4.2f Celsius%s", |
| 510 |
temp / 1000.0f, |
| 511 |
VTY_NEWLINE); |
| 512 |
oc2gbts_temp_get(OC2GBTS_TEMP_TX, &temp); |
| 513 |
vty_out(vty, " TX : %4.2f Celsius%s", |
| 514 |
temp / 1000.0f, |
| 515 |
VTY_NEWLINE); |
| 516 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA_TEMP)) { |
| 517 |
oc2gbts_temp_get(OC2GBTS_TEMP_PA, &temp); |
| 518 |
vty_out(vty, " Power Amp : %4.2f Celsius%s", |
| 519 |
temp / 1000.0f, |
| 520 |
VTY_NEWLINE); |
| 521 |
} |
| 522 |
vty_out(vty, "Power Status%s", VTY_NEWLINE); |
| 523 |
oc2gbts_power_sensor_get(OC2GBTS_POWER_SUPPLY, |
| 524 |
OC2GBTS_POWER_VOLTAGE, &volt); |
| 525 |
oc2gbts_power_sensor_get(OC2GBTS_POWER_SUPPLY, |
| 526 |
OC2GBTS_POWER_CURRENT, ¤t); |
| 527 |
oc2gbts_power_sensor_get(OC2GBTS_POWER_SUPPLY, |
| 528 |
OC2GBTS_POWER_POWER, &power); |
| 529 |
vty_out(vty, " Main Supply : ON [%6.2f Vdc, %4.2f A, %6.2f W]%s", |
| 530 |
volt /1000.0f, |
| 531 |
current /1000.0f, |
| 532 |
power /1000000.0f, |
| 533 |
VTY_NEWLINE); |
| 534 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA)) { |
| 535 |
oc2gbts_power_sensor_get(OC2GBTS_POWER_PA, |
| 536 |
OC2GBTS_POWER_VOLTAGE, &volt); |
| 537 |
oc2gbts_power_sensor_get(OC2GBTS_POWER_PA, |
| 538 |
OC2GBTS_POWER_CURRENT, ¤t); |
| 539 |
oc2gbts_power_sensor_get(OC2GBTS_POWER_PA, |
| 540 |
OC2GBTS_POWER_POWER, &power); |
| 541 |
vty_out(vty, " Power Amp : %s [%6.2f Vdc, %4.2f A, %6.2f W]%s", |
| 542 |
oc2gbts_power_get(OC2GBTS_POWER_PA) ? "ON " : "OFF", |
| 543 |
volt /1000.0f, |
| 544 |
current /1000.0f, |
| 545 |
power /1000000.0f, |
| 546 |
VTY_NEWLINE); |
| 547 |
} |
| 548 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA) && |
| 549 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_FWD) && |
| 550 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_REFL)) { |
| 551 |
vty_out(vty, "VSWR Status%s", VTY_NEWLINE); |
| 552 |
oc2gbts_vswr_get(OC2GBTS_VSWR, &vswr); |
| 553 |
vty_out(vty, " VSWR : %f %s", |
| 554 |
vswr / 1000.0f, |
| 555 |
VTY_NEWLINE); |
| 556 |
} |
| 557 |
return CMD_SUCCESS; |
| 558 |
} |
| 559 |
|
| 560 |
DEFUN(show_thresh, show_thresh_cmd, "show thresholds", |
| 561 |
SHOW_STR "Display information about the thresholds") |
| 562 |
{ |
| 563 |
vty_out(vty, "Temperature limits (Celsius)%s", VTY_NEWLINE); |
| 564 |
vty_out(vty, " Main supply%s", VTY_NEWLINE); |
| 565 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.supply_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 566 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.supply_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 567 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.supply_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 568 |
vty_out(vty, " SoC%s", VTY_NEWLINE); |
| 569 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.soc_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 570 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.soc_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 571 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.soc_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 572 |
vty_out(vty, " FPGA%s", VTY_NEWLINE); |
| 573 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.fpga_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 574 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.fpga_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 575 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.fpga_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 576 |
if (oc2gbts_option_get(OC2GBTS_OPTION_RMS_FWD) || |
| 577 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_REFL)) { |
| 578 |
vty_out(vty, " RMSDet%s", VTY_NEWLINE); |
| 579 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.rmsdet_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 580 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.rmsdet_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 581 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.rmsdet_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 582 |
} |
| 583 |
vty_out(vty, " OCXO%s", VTY_NEWLINE); |
| 584 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.ocxo_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 585 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.ocxo_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 586 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.ocxo_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 587 |
vty_out(vty, " TX%s", VTY_NEWLINE); |
| 588 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.tx_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 589 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.tx_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 590 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.tx_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 591 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA_TEMP)) { |
| 592 |
vty_out(vty, " PA%s", VTY_NEWLINE); |
| 593 |
vty_out(vty, " Critical max : %d%s",s_mgr->temp.pa_temp_limit.thresh_crit_max, VTY_NEWLINE); |
| 594 |
vty_out(vty, " Warning max : %d%s",s_mgr->temp.pa_temp_limit.thresh_warn_max, VTY_NEWLINE); |
| 595 |
vty_out(vty, " Warning min : %d%s",s_mgr->temp.pa_temp_limit.thresh_warn_min, VTY_NEWLINE); |
| 596 |
} |
| 597 |
vty_out(vty, "Power limits%s", VTY_NEWLINE); |
| 598 |
vty_out(vty, " Main supply (mV)%s", VTY_NEWLINE); |
| 599 |
vty_out(vty, " Critical max : %d%s",s_mgr->volt.supply_volt_limit.thresh_crit_max, VTY_NEWLINE); |
| 600 |
vty_out(vty, " Warning max : %d%s",s_mgr->volt.supply_volt_limit.thresh_warn_max, VTY_NEWLINE); |
| 601 |
vty_out(vty, " Warning min : %d%s",s_mgr->volt.supply_volt_limit.thresh_warn_min, VTY_NEWLINE); |
| 602 |
vty_out(vty, " Critical min : %d%s",s_mgr->volt.supply_volt_limit.thresh_crit_min, VTY_NEWLINE); |
| 603 |
vty_out(vty, " Main supply power (W)%s", VTY_NEWLINE); |
| 604 |
vty_out(vty, " Critical max : %d%s",s_mgr->pwr.supply_pwr_limit.thresh_crit_max, VTY_NEWLINE); |
| 605 |
vty_out(vty, " Warning max : %d%s",s_mgr->pwr.supply_pwr_limit.thresh_warn_max, VTY_NEWLINE); |
| 606 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA)) { |
| 607 |
vty_out(vty, " PA power (W)%s", VTY_NEWLINE); |
| 608 |
vty_out(vty, " Critical max : %d%s",s_mgr->pwr.pa_pwr_limit.thresh_crit_max, VTY_NEWLINE); |
| 609 |
vty_out(vty, " Warning max : %d%s",s_mgr->pwr.pa_pwr_limit.thresh_warn_max, VTY_NEWLINE); |
| 610 |
} |
| 611 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA) && |
| 612 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_FWD) && |
| 613 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_REFL)) { |
| 614 |
vty_out(vty, "VSWR limits%s", VTY_NEWLINE); |
| 615 |
vty_out(vty, " TX%s", VTY_NEWLINE); |
| 616 |
vty_out(vty, " Critical max : %d%s",s_mgr->vswr.vswr_limit.thresh_crit_max, VTY_NEWLINE); |
| 617 |
vty_out(vty, " Warning max : %d%s",s_mgr->vswr.vswr_limit.thresh_warn_max, VTY_NEWLINE); |
| 618 |
} |
| 619 |
vty_out(vty, "Days since last GPS 3D fix%s", VTY_NEWLINE); |
| 620 |
vty_out(vty, " Warning max : %d%s",s_mgr->gps.gps_fix_limit.thresh_warn_max, VTY_NEWLINE); |
| 621 |
|
| 622 |
return CMD_SUCCESS; |
| 623 |
} |
| 624 |
|
| 625 |
DEFUN(calibrate_clock, calibrate_clock_cmd, |
| 626 |
"calibrate clock", |
| 627 |
"Calibration commands\n" |
| 628 |
"Calibrate clock against GPS PPS\n") |
| 629 |
{ |
| 630 |
if (oc2gbts_mgr_calib_run(s_mgr) < 0) { |
| 631 |
vty_out(vty, "%%Failed to start calibration.%s", VTY_NEWLINE); |
| 632 |
return CMD_WARNING; |
| 633 |
} |
| 634 |
return CMD_SUCCESS; |
| 635 |
} |
| 636 |
|
| 637 |
DEFUN(set_led_pattern, set_led_pattern_cmd, |
| 638 |
"set led pattern <0-255>", |
| 639 |
"Set LED pattern\n" |
| 640 |
"Set LED pattern for debugging purpose only. This pattern will be overridden after 60 seconds by LED pattern of actual system state\n") |
| 641 |
{ |
| 642 |
int pattern_id = atoi(argv[0]); |
| 643 |
|
| 644 |
if ((pattern_id < 0) || (pattern_id > BLINK_PATTERN_MAX_ITEM)) { |
| 645 |
vty_out(vty, "%%Invalid LED pattern ID. It must be in range of %d..%d %s", 0, BLINK_PATTERN_MAX_ITEM - 1, VTY_NEWLINE); |
| 646 |
return CMD_WARNING; |
| 647 |
} |
| 648 |
|
| 649 |
led_set(s_mgr, pattern_id); |
| 650 |
return CMD_SUCCESS; |
| 651 |
} |
| 652 |
|
| 653 |
DEFUN(force_mgr_state, force_mgr_state_cmd, |
| 654 |
"force manager state <0-255>", |
| 655 |
"Force BTS manager state\n" |
| 656 |
"Force BTS manager state for debugging purpose only\n") |
| 657 |
{ |
| 658 |
int state = atoi(argv[0]); |
| 659 |
|
| 660 |
if ((state < 0) || (state > STATE_CRITICAL)) { |
| 661 |
vty_out(vty, "%%Invalid BTS manager state. It must be in range of %d..%d %s", 0, STATE_CRITICAL, VTY_NEWLINE); |
| 662 |
return CMD_WARNING; |
| 663 |
} |
| 664 |
|
| 665 |
s_mgr->state.state = state; |
| 666 |
return CMD_SUCCESS; |
| 667 |
} |
| 668 |
|
| 669 |
#define LIMIT_TEMP(name, limit, expl, variable, criticity, min_max) \ |
| 670 |
DEFUN(limit_temp_##name##_##variable, limit_temp_##name##_##variable##_cmd, \ |
| 671 |
"limit temp " #name " " #criticity " " #min_max " <-200-200>", \ |
| 672 |
"Limit to reach\n" expl) \ |
| 673 |
{ \ |
| 674 |
s_mgr->temp.limit.variable = atoi(argv[0]); \ |
| 675 |
return CMD_SUCCESS; \ |
| 676 |
} |
| 677 |
|
| 678 |
LIMIT_TEMP(supply, supply_temp_limit, "SUPPLY TEMP\n", thresh_warn_max, warning, max) |
| 679 |
LIMIT_TEMP(supply, supply_temp_limit, "SUPPLY TEMP\n", thresh_crit_max, critical, max) |
| 680 |
LIMIT_TEMP(supply, supply_temp_limit, "SUPPLY TEMP\n", thresh_warn_min, warning, min) |
| 681 |
LIMIT_TEMP(soc, supply_temp_limit, "SOC TEMP\n", thresh_warn_max, warning, max) |
| 682 |
LIMIT_TEMP(soc, supply_temp_limit, "SOC TEMP\n", thresh_crit_max, critical, max) |
| 683 |
LIMIT_TEMP(soc, supply_temp_limit, "SOC TEMP\n", thresh_warn_min, warning, min) |
| 684 |
LIMIT_TEMP(fpga, fpga_temp_limit, "FPGA TEMP\n", thresh_warn_max, warning, max) |
| 685 |
LIMIT_TEMP(fpga, fpga_temp_limit, "FPGA TEMP\n", thresh_crit_max, critical, max) |
| 686 |
LIMIT_TEMP(fpga, fpga_temp_limit, "FPGA TEMP\n", thresh_warn_min, warning, min) |
| 687 |
LIMIT_TEMP(rmsdet, rmsdet_temp_limit, "RMSDET TEMP\n", thresh_warn_max, warning, max) |
| 688 |
LIMIT_TEMP(rmsdet, rmsdet_temp_limit, "RMSDET TEMP\n", thresh_crit_max, critical, max) |
| 689 |
LIMIT_TEMP(rmsdet, rmsdet_temp_limit, "RMSDET TEMP\n", thresh_warn_min, warning, min) |
| 690 |
LIMIT_TEMP(ocxo, ocxo_temp_limit, "OCXO TEMP\n", thresh_warn_max, warning, max) |
| 691 |
LIMIT_TEMP(ocxo, ocxo_temp_limit, "OCXO TEMP\n", thresh_crit_max, critical, max) |
| 692 |
LIMIT_TEMP(ocxo, ocxo_temp_limit, "OCXO TEMP\n", thresh_warn_min, warning, min) |
| 693 |
LIMIT_TEMP(tx, tx_temp_limit, "TX TEMP\n", thresh_warn_max, warning, max) |
| 694 |
LIMIT_TEMP(tx, tx_temp_limit, "TX TEMP\n", thresh_crit_max, critical, max) |
| 695 |
LIMIT_TEMP(tx, tx_temp_limit, "TX TEMP\n", thresh_warn_min, warning, min) |
| 696 |
LIMIT_TEMP(pa, pa_temp_limit, "PA TEMP\n", thresh_warn_max, warning, max) |
| 697 |
LIMIT_TEMP(pa, pa_temp_limit, "PA TEMP\n", thresh_crit_max, critical, max) |
| 698 |
LIMIT_TEMP(pa, pa_temp_limit, "PA TEMP\n", thresh_warn_min, warning, min) |
| 699 |
#undef LIMIT_TEMP |
| 700 |
|
| 701 |
#define LIMIT_VOLT(name, limit, expl, variable, criticity, min_max) \ |
| 702 |
DEFUN(limit_volt_##name##_##variable, limit_volt_##name##_##variable##_cmd, \ |
| 703 |
"limit " #name " " #criticity " " #min_max " <0-48000>", \ |
| 704 |
"Limit to reach\n" expl) \ |
| 705 |
{ \ |
| 706 |
s_mgr->volt.limit.variable = atoi(argv[0]); \ |
| 707 |
return CMD_SUCCESS; \ |
| 708 |
} |
| 709 |
|
| 710 |
LIMIT_VOLT(supply, supply_volt_limit, "SUPPLY VOLT\n", thresh_warn_max, warning, max) |
| 711 |
LIMIT_VOLT(supply, supply_volt_limit, "SUPPLY VOLT\n", thresh_crit_max, critical, max) |
| 712 |
LIMIT_VOLT(supply, supply_volt_limit, "SUPPLY VOLT\n", thresh_warn_min, warning, min) |
| 713 |
LIMIT_VOLT(supply, supply_volt_limit, "SUPPLY VOLT\n", thresh_crit_min, critical, min) |
| 714 |
#undef LIMIT_VOLT |
| 715 |
|
| 716 |
#define LIMIT_PWR(name, limit, expl, variable, criticity, min_max) \ |
| 717 |
DEFUN(limit_pwr_##name##_##variable, limit_pwr_##name##_##variable##_cmd, \ |
| 718 |
"limit power " #name " " #criticity " " #min_max " <0-200>", \ |
| 719 |
"Limit to reach\n" expl) \ |
| 720 |
{ \ |
| 721 |
s_mgr->pwr.limit.variable = atoi(argv[0]); \ |
| 722 |
return CMD_SUCCESS; \ |
| 723 |
} |
| 724 |
|
| 725 |
LIMIT_PWR(supply, supply_pwr_limit, "SUPPLY PWR\n", thresh_warn_max, warning, max) |
| 726 |
LIMIT_PWR(supply, supply_pwr_limit, "SUPPLY PWR\n", thresh_crit_max, critical, max) |
| 727 |
LIMIT_PWR(pa, pa_pwr_limit, "PA PWR\n", thresh_warn_max, warning, max) |
| 728 |
LIMIT_PWR(pa, pa_pwr_limit, "PA PWR\n", thresh_crit_max, critical, max) |
| 729 |
#undef LIMIT_PWR |
| 730 |
|
| 731 |
#define LIMIT_VSWR(limit, expl, variable, criticity, min_max) \ |
| 732 |
DEFUN(limit_vswr_##variable, limit_vswr_##variable##_cmd, \ |
| 733 |
"limit vswr " #criticity " " #min_max " <1000-200000>", \ |
| 734 |
"Limit to reach\n" expl) \ |
| 735 |
{ \ |
| 736 |
s_mgr->vswr.limit.variable = atoi(argv[0]); \ |
| 737 |
return CMD_SUCCESS; \ |
| 738 |
} |
| 739 |
|
| 740 |
LIMIT_VSWR(vswr_limit, "VSWR\n", thresh_warn_max, warning, max) |
| 741 |
LIMIT_VSWR(vswr_limit, "VSWR\n", thresh_crit_max, critical, max) |
| 742 |
#undef LIMIT_VSWR |
| 743 |
|
| 744 |
#define LIMIT_GPSFIX(limit, expl, variable, criticity, min_max) \ |
| 745 |
DEFUN(limit_gpsfix_##variable, limit_gpsfix_##variable##_cmd, \ |
| 746 |
"limit gpsfix " #criticity " " #min_max " <0-365>", \ |
| 747 |
"Limit to reach\n" expl) \ |
| 748 |
{ \ |
| 749 |
s_mgr->gps.limit.variable = atoi(argv[0]); \ |
| 750 |
return CMD_SUCCESS; \ |
| 751 |
} |
| 752 |
|
| 753 |
LIMIT_GPSFIX(gps_fix_limit, "GPS FIX\n", thresh_warn_max, warning, max) |
| 754 |
#undef LIMIT_GPSFIX |
| 755 |
|
| 756 |
static void register_limit(int limit, uint32_t unit) |
| 757 |
{ |
| 758 |
switch (unit) { |
| 759 |
case MGR_LIMIT_TYPE_VOLT: |
| 760 |
install_element(limit, &cfg_thresh_volt_warn_min_cmd); |
| 761 |
install_element(limit, &cfg_thresh_volt_crit_min_cmd); |
| 762 |
break; |
| 763 |
case MGR_LIMIT_TYPE_VSWR: |
| 764 |
install_element(limit, &cfg_thresh_vswr_warn_max_cmd); |
| 765 |
install_element(limit, &cfg_thresh_vswr_crit_max_cmd); |
| 766 |
break; |
| 767 |
case MGR_LIMIT_TYPE_PWR: |
| 768 |
install_element(limit, &cfg_thresh_pwr_warn_max_cmd); |
| 769 |
install_element(limit, &cfg_thresh_pwr_crit_max_cmd); |
| 770 |
break; |
| 771 |
default: |
| 772 |
break; |
| 773 |
} |
| 774 |
} |
| 775 |
|
| 776 |
static void register_normal_action(int act) |
| 777 |
{ |
| 778 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA)) { |
| 779 |
install_element(act, &cfg_action_pa_on_cmd); |
| 780 |
install_element(act, &cfg_no_action_pa_on_cmd); |
| 781 |
} |
| 782 |
install_element(act, &cfg_action_bts_srv_on_cmd); |
| 783 |
install_element(act, &cfg_no_action_bts_srv_on_cmd); |
| 784 |
} |
| 785 |
|
| 786 |
static void register_action(int act) |
| 787 |
{ |
| 788 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA)) { |
| 789 |
install_element(act, &cfg_action_pa_off_cmd); |
| 790 |
install_element(act, &cfg_no_action_pa_off_cmd); |
| 791 |
} |
| 792 |
install_element(act, &cfg_action_bts_srv_off_cmd); |
| 793 |
install_element(act, &cfg_no_action_bts_srv_off_cmd); |
| 794 |
} |
| 795 |
|
| 796 |
static void register_hidden_commands() |
| 797 |
{ |
| 798 |
install_element(ENABLE_NODE, &limit_temp_supply_thresh_warn_max_cmd); |
| 799 |
install_element(ENABLE_NODE, &limit_temp_supply_thresh_crit_max_cmd); |
| 800 |
install_element(ENABLE_NODE, &limit_temp_supply_thresh_warn_min_cmd); |
| 801 |
install_element(ENABLE_NODE, &limit_temp_soc_thresh_warn_max_cmd); |
| 802 |
install_element(ENABLE_NODE, &limit_temp_soc_thresh_crit_max_cmd); |
| 803 |
install_element(ENABLE_NODE, &limit_temp_soc_thresh_warn_min_cmd); |
| 804 |
install_element(ENABLE_NODE, &limit_temp_fpga_thresh_warn_max_cmd); |
| 805 |
install_element(ENABLE_NODE, &limit_temp_fpga_thresh_crit_max_cmd); |
| 806 |
install_element(ENABLE_NODE, &limit_temp_fpga_thresh_warn_min_cmd); |
| 807 |
install_element(ENABLE_NODE, &limit_temp_rmsdet_thresh_warn_max_cmd); |
| 808 |
install_element(ENABLE_NODE, &limit_temp_rmsdet_thresh_crit_max_cmd); |
| 809 |
install_element(ENABLE_NODE, &limit_temp_rmsdet_thresh_warn_min_cmd); |
| 810 |
install_element(ENABLE_NODE, &limit_temp_ocxo_thresh_warn_max_cmd); |
| 811 |
install_element(ENABLE_NODE, &limit_temp_ocxo_thresh_crit_max_cmd); |
| 812 |
install_element(ENABLE_NODE, &limit_temp_ocxo_thresh_warn_min_cmd); |
| 813 |
install_element(ENABLE_NODE, &limit_temp_tx_thresh_warn_max_cmd); |
| 814 |
install_element(ENABLE_NODE, &limit_temp_tx_thresh_crit_max_cmd); |
| 815 |
install_element(ENABLE_NODE, &limit_temp_tx_thresh_warn_min_cmd); |
| 816 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA_TEMP)) { |
| 817 |
install_element(ENABLE_NODE, &limit_temp_pa_thresh_warn_max_cmd); |
| 818 |
install_element(ENABLE_NODE, &limit_temp_pa_thresh_crit_max_cmd); |
| 819 |
install_element(ENABLE_NODE, &limit_temp_pa_thresh_warn_min_cmd); |
| 820 |
} |
| 821 |
|
| 822 |
install_element(ENABLE_NODE, &limit_volt_supply_thresh_warn_max_cmd); |
| 823 |
install_element(ENABLE_NODE, &limit_volt_supply_thresh_crit_max_cmd); |
| 824 |
install_element(ENABLE_NODE, &limit_volt_supply_thresh_warn_min_cmd); |
| 825 |
install_element(ENABLE_NODE, &limit_volt_supply_thresh_crit_min_cmd); |
| 826 |
|
| 827 |
install_element(ENABLE_NODE, &limit_pwr_supply_thresh_warn_max_cmd); |
| 828 |
install_element(ENABLE_NODE, &limit_pwr_supply_thresh_crit_max_cmd); |
| 829 |
|
| 830 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA)) { |
| 831 |
install_element(ENABLE_NODE, &limit_pwr_pa_thresh_warn_max_cmd); |
| 832 |
install_element(ENABLE_NODE, &limit_pwr_pa_thresh_crit_max_cmd); |
| 833 |
} |
| 834 |
|
| 835 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA) && |
| 836 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_FWD) && |
| 837 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_REFL)) { |
| 838 |
install_element(ENABLE_NODE, &limit_vswr_thresh_warn_max_cmd); |
| 839 |
install_element(ENABLE_NODE, &limit_vswr_thresh_crit_max_cmd); |
| 840 |
} |
| 841 |
|
| 842 |
install_element(ENABLE_NODE, &limit_gpsfix_thresh_warn_max_cmd); |
| 843 |
} |
| 844 |
|
| 845 |
int oc2gbts_mgr_vty_init(void) |
| 846 |
{ |
| 847 |
vty_init(&vty_info); |
| 848 |
|
| 849 |
install_element_ve(&show_mgr_cmd); |
| 850 |
install_element_ve(&show_thresh_cmd); |
| 851 |
|
| 852 |
install_element(ENABLE_NODE, &calibrate_clock_cmd); |
| 853 |
|
| 854 |
install_node(&mgr_node, config_write_mgr); |
| 855 |
install_element(CONFIG_NODE, &cfg_mgr_cmd); |
| 856 |
|
| 857 |
/* install the limit nodes */ |
| 858 |
install_node(&limit_supply_temp_node, config_write_dummy); |
| 859 |
install_element(MGR_NODE, &cfg_limit_supply_temp_cmd); |
| 860 |
|
| 861 |
install_node(&limit_soc_node, config_write_dummy); |
| 862 |
install_element(MGR_NODE, &cfg_limit_soc_temp_cmd); |
| 863 |
|
| 864 |
install_node(&limit_fpga_node, config_write_dummy); |
| 865 |
install_element(MGR_NODE, &cfg_limit_fpga_temp_cmd); |
| 866 |
|
| 867 |
if (oc2gbts_option_get(OC2GBTS_OPTION_RMS_FWD) || |
| 868 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_REFL)) { |
| 869 |
install_node(&limit_rmsdet_node, config_write_dummy); |
| 870 |
install_element(MGR_NODE, &cfg_limit_rmsdet_temp_cmd); |
| 871 |
} |
| 872 |
|
| 873 |
install_node(&limit_ocxo_node, config_write_dummy); |
| 874 |
install_element(MGR_NODE, &cfg_limit_ocxo_temp_cmd); |
| 875 |
|
| 876 |
install_node(&limit_tx_temp_node, config_write_dummy); |
| 877 |
install_element(MGR_NODE, &cfg_limit_tx_temp_cmd); |
| 878 |
|
| 879 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA_TEMP)) { |
| 880 |
install_node(&limit_pa_temp_node, config_write_dummy); |
| 881 |
install_element(MGR_NODE, &cfg_limit_pa_temp_cmd); |
| 882 |
} |
| 883 |
|
| 884 |
install_node(&limit_supply_volt_node, config_write_dummy); |
| 885 |
install_element(MGR_NODE, &cfg_limit_supply_volt_cmd); |
| 886 |
register_limit(LIMIT_SUPPLY_VOLT_NODE, MGR_LIMIT_TYPE_VOLT); |
| 887 |
|
| 888 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA) && |
| 889 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_FWD) && |
| 890 |
oc2gbts_option_get(OC2GBTS_OPTION_RMS_REFL)) { |
| 891 |
install_node(&limit_vswr_node, config_write_dummy); |
| 892 |
install_element(MGR_NODE, &cfg_limit_vswr_cmd); |
| 893 |
register_limit(LIMIT_VSWR_NODE, MGR_LIMIT_TYPE_VSWR); |
| 894 |
} |
| 895 |
|
| 896 |
install_node(&limit_supply_pwr_node, config_write_dummy); |
| 897 |
install_element(MGR_NODE, &cfg_limit_supply_pwr_cmd); |
| 898 |
register_limit(LIMIT_SUPPLY_PWR_NODE, MGR_LIMIT_TYPE_PWR); |
| 899 |
|
| 900 |
if (oc2gbts_option_get(OC2GBTS_OPTION_PA)) { |
| 901 |
install_node(&limit_pa_pwr_node, config_write_dummy); |
| 902 |
install_element(MGR_NODE, &cfg_limit_pa_pwr_cmd); |
| 903 |
} |
| 904 |
|
| 905 |
install_node(&limit_gps_fix_node, config_write_dummy); |
| 906 |
install_element(MGR_NODE, &cfg_limit_gps_fix_cmd); |
| 907 |
|
| 908 |
/* install the normal node */ |
| 909 |
install_node(&act_norm_node, config_write_dummy); |
| 910 |
install_element(MGR_NODE, &cfg_action_normal_cmd); |
| 911 |
register_normal_action(ACT_NORM_NODE); |
| 912 |
|
| 913 |
/* install the warning and critical node */ |
| 914 |
install_node(&act_warn_node, config_write_dummy); |
| 915 |
install_element(MGR_NODE, &cfg_action_warn_cmd); |
| 916 |
register_action(ACT_WARN_NODE); |
| 917 |
|
| 918 |
install_node(&act_crit_node, config_write_dummy); |
| 919 |
install_element(MGR_NODE, &cfg_action_critical_cmd); |
| 920 |
register_action(ACT_CRIT_NODE); |
| 921 |
|
| 922 |
/* install LED pattern command for debugging purpose */ |
| 923 |
install_element_ve(&set_led_pattern_cmd); |
| 924 |
install_element_ve(&force_mgr_state_cmd); |
| 925 |
|
| 926 |
register_hidden_commands(); |
| 927 |
|
| 928 |
return 0; |
| 929 |
} |
| 930 |
|
| 931 |
int oc2gbts_mgr_parse_config(struct oc2gbts_mgr_instance *manager) |
| 932 |
{ |
| 933 |
int rc; |
| 934 |
|
| 935 |
s_mgr = manager; |
| 936 |
rc = vty_read_config_file(s_mgr->config_file, NULL); |
| 937 |
if (rc < 0) { |
| 938 |
fprintf(stderr, "Failed to parse the config file: '%s'\n", |
| 939 |
s_mgr->config_file); |
| 940 |
return rc; |
| 941 |
} |
| 942 |
|
| 943 |
return 0; |
| 944 |
} |