Jacob Erlbeck | 62e96a3 | 2015-06-04 09:42:14 +0200 | [diff] [blame] | 1 | /* 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 Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 26 | #include "bts.h" |
| 27 | #include "gprs_ms_storage.h" |
| 28 | #include "gprs_ms.h" |
| 29 | #include "cxx_linuxlist.h" |
Jacob Erlbeck | 62e96a3 | 2015-06-04 09:42:14 +0200 | [diff] [blame] | 30 | |
| 31 | extern "C" { |
| 32 | # include <osmocom/vty/command.h> |
| 33 | # include <osmocom/vty/logging.h> |
| 34 | # include <osmocom/vty/misc.h> |
| 35 | } |
| 36 | |
| 37 | int pcu_vty_config_write_pcu_ext(struct vty *vty) |
| 38 | { |
| 39 | return CMD_SUCCESS; |
| 40 | } |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 41 | |
| 42 | int 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 Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 58 | |
| 59 | static 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); |
Jacob Erlbeck | e4bcb62 | 2015-06-08 11:26:38 +0200 | [diff] [blame^] | 70 | if (ms->l1_meas()->have_rssi) |
| 71 | vty_out(vty, " RSSI: %d dBm%s", |
| 72 | ms->l1_meas()->rssi, VTY_NEWLINE); |
| 73 | if (ms->l1_meas()->have_ber) |
| 74 | vty_out(vty, " Bit error rate: %d %%%s", |
| 75 | ms->l1_meas()->ber, VTY_NEWLINE); |
| 76 | if (ms->l1_meas()->have_link_qual) |
| 77 | vty_out(vty, " Link quality: %d dB%s", |
| 78 | ms->l1_meas()->link_qual, VTY_NEWLINE); |
| 79 | if (ms->l1_meas()->have_bto) |
| 80 | vty_out(vty, " Burst timing offset: %d/4 bit%s", |
| 81 | ms->l1_meas()->bto, VTY_NEWLINE); |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 82 | if (ms->ul_tbf()) |
| 83 | vty_out(vty, " Uplink TBF: TFI=%d, state=%s%s", |
| 84 | ms->ul_tbf()->tfi(), |
| 85 | ms->ul_tbf()->state_name(), |
| 86 | VTY_NEWLINE); |
| 87 | if (ms->dl_tbf()) |
| 88 | vty_out(vty, " Downlink TBF: TFI=%d, state=%s%s", |
| 89 | ms->dl_tbf()->tfi(), |
| 90 | ms->dl_tbf()->state_name(), |
| 91 | VTY_NEWLINE); |
| 92 | |
| 93 | return CMD_SUCCESS; |
| 94 | } |
| 95 | |
| 96 | int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data, |
| 97 | uint32_t tlli) |
| 98 | { |
| 99 | BTS *bts = bts_data->bts; |
| 100 | GprsMs *ms = bts->ms_store().get_ms(tlli); |
| 101 | if (!ms) { |
| 102 | vty_out(vty, "Unknown TLLI %08x.%s", tlli, VTY_NEWLINE); |
| 103 | return CMD_WARNING; |
| 104 | } |
| 105 | |
| 106 | return show_ms(vty, ms); |
| 107 | } |
| 108 | |
| 109 | int pcu_vty_show_ms_by_imsi(struct vty *vty, struct gprs_rlcmac_bts *bts_data, |
| 110 | const char *imsi) |
| 111 | { |
| 112 | BTS *bts = bts_data->bts; |
| 113 | GprsMs *ms = bts->ms_store().get_ms(0, 0, imsi); |
| 114 | if (!ms) { |
| 115 | vty_out(vty, "Unknown IMSI '%s'.%s", imsi, VTY_NEWLINE); |
| 116 | return CMD_WARNING; |
| 117 | } |
| 118 | |
| 119 | return show_ms(vty, ms); |
| 120 | } |