blob: 39c5ee446a980bff9903168c54e0b018f14f9781 [file] [log] [blame]
Jacob Erlbeck62e96a32015-06-04 09:42:14 +02001/* pcu_vty_functions.cpp
2 *
3 * Copyright (C) 2015 by Sysmocom s.f.m.c. GmbH
4 * Author: Jacob Erlbeck <jerlbeck@sysmocom.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20/* OsmoBTS VTY interface */
21
22
23#include <stdint.h>
24#include <stdlib.h>
25#include "pcu_vty_functions.h"
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020026#include "bts.h"
27#include "gprs_ms_storage.h"
28#include "gprs_ms.h"
29#include "cxx_linuxlist.h"
Jacob Erlbeck62e96a32015-06-04 09:42:14 +020030
31extern "C" {
32# include <osmocom/vty/command.h>
33# include <osmocom/vty/logging.h>
34# include <osmocom/vty/misc.h>
35}
36
37int pcu_vty_config_write_pcu_ext(struct vty *vty)
38{
39 return CMD_SUCCESS;
40}
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020041
42int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data)
43{
44 BTS *bts = bts_data->bts;
45 LListHead<GprsMs> *ms_iter;
46
47 llist_for_each(ms_iter, &bts->ms_store().ms_list()) {
48 GprsMs *ms = ms_iter->entry();
49
50 vty_out(vty, "MS TLLI=%08x, TA=%d, CS-UL=%d, CS-DL=%d, IMSI=%s%s",
51 ms->tlli(),
52 ms->ta(), ms->current_cs_ul(), ms->current_cs_dl(),
53 ms->imsi(),
54 VTY_NEWLINE);
55 }
56 return CMD_SUCCESS;
57}
Jacob Erlbeck37e896d2015-06-05 16:33:33 +020058
59static int show_ms(struct vty *vty, GprsMs *ms)
60{
61 vty_out(vty, "MS TLLI=%08x, IMSI=%s%s", ms->tlli(), ms->imsi(), VTY_NEWLINE);
62 vty_out(vty, " Timing advance (TA): %d%s", ms->ta(), VTY_NEWLINE);
63 vty_out(vty, " Coding scheme uplink: CS-%d%s", ms->current_cs_ul(),
64 VTY_NEWLINE);
65 vty_out(vty, " Coding scheme downlink: CS-%d%s", ms->current_cs_dl(),
66 VTY_NEWLINE);
67 vty_out(vty, " MS class: %d%s", ms->ms_class(), VTY_NEWLINE);
68 vty_out(vty, " LLC queue length: %d%s", ms->llc_queue()->size(),
69 VTY_NEWLINE);
70 if (ms->ul_tbf())
71 vty_out(vty, " Uplink TBF: TFI=%d, state=%s%s",
72 ms->ul_tbf()->tfi(),
73 ms->ul_tbf()->state_name(),
74 VTY_NEWLINE);
75 if (ms->dl_tbf())
76 vty_out(vty, " Downlink TBF: TFI=%d, state=%s%s",
77 ms->dl_tbf()->tfi(),
78 ms->dl_tbf()->state_name(),
79 VTY_NEWLINE);
80
81 return CMD_SUCCESS;
82}
83
84int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
85 uint32_t tlli)
86{
87 BTS *bts = bts_data->bts;
88 GprsMs *ms = bts->ms_store().get_ms(tlli);
89 if (!ms) {
90 vty_out(vty, "Unknown TLLI %08x.%s", tlli, VTY_NEWLINE);
91 return CMD_WARNING;
92 }
93
94 return show_ms(vty, ms);
95}
96
97int pcu_vty_show_ms_by_imsi(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
98 const char *imsi)
99{
100 BTS *bts = bts_data->bts;
101 GprsMs *ms = bts->ms_store().get_ms(0, 0, imsi);
102 if (!ms) {
103 vty_out(vty, "Unknown IMSI '%s'.%s", imsi, VTY_NEWLINE);
104 return CMD_WARNING;
105 }
106
107 return show_ms(vty, ms);
108}