blob: 6f0de046e084a2de0361a84a7ecf44b1d82d0aaf [file] [log] [blame]
Harald Welte2e918a82010-05-18 12:20:12 +02001/* VTY interface for our GPRS LLC implementation */
2
3/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
4 *
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22
23#include <stdlib.h>
24#include <unistd.h>
25#include <errno.h>
26#include <stdint.h>
27
28#include <arpa/inet.h>
29
30#include <openbsc/gsm_data.h>
31#include <osmocore/msgb.h>
32#include <osmocore/tlv.h>
33#include <osmocore/talloc.h>
34#include <osmocore/select.h>
35#include <osmocore/rate_ctr.h>
36#include <openbsc/debug.h>
37#include <openbsc/signal.h>
38#include <openbsc/gprs_llc.h>
39
Harald Welte4b037e42010-05-19 19:45:32 +020040#include <osmocom/vty/vty.h>
41#include <osmocom/vty/command.h>
Harald Welte2e918a82010-05-18 12:20:12 +020042
43struct value_string gprs_llc_state_strs[] = {
Harald Welte807a5d82010-06-01 11:53:01 +020044 { GPRS_LLES_UNASSIGNED, "TLLI Unassigned" },
45 { GPRS_LLES_ASSIGNED_ADM, "TLLI Assigned" },
46 { GPRS_LLES_LOCAL_EST, "Local Establishment" },
47 { GPRS_LLES_REMOTE_EST, "Remote Establishment" },
48 { GPRS_LLES_ABM, "Asynchronous Balanced Mode" },
49 { GPRS_LLES_LOCAL_REL, "Local Release" },
50 { GPRS_LLES_TIMER_REC, "Timer Recovery" },
Harald Welte2e918a82010-05-18 12:20:12 +020051};
52
53static void vty_dump_lle(struct vty *vty, struct gprs_llc_lle *lle)
54{
Harald Welte807a5d82010-06-01 11:53:01 +020055 vty_out(vty, " SAPI %2u State %s VUsend=%u, VUrecv=%u", lle->sapi,
56 get_value_string(gprs_llc_state_strs, lle->state),
57 lle->vu_send, lle->vu_recv);
58 vty_out(vty, " Vsent=%u Vack=%u Vrecv=%u, N200=%u, RetransCtr=%u%s",
Harald Welte2e918a82010-05-18 12:20:12 +020059 lle->v_sent, lle->v_ack, lle->v_recv, lle->n200,
60 lle->retrans_ctr, VTY_NEWLINE);
61}
62
Harald Welte807a5d82010-06-01 11:53:01 +020063static void vty_dump_llme(struct vty *vty, struct gprs_llc_llme *llme)
64{
65 unsigned int i;
66
67 vty_out(vty, "TLLI %08x (Old TLLI %08x) BVCI=%u NSEI=%u: State %s%s",
68 llme->tlli, llme->old_tlli, llme->bvci, llme->nsei,
69 get_value_string(gprs_llc_state_strs, llme->state), VTY_NEWLINE);
70 for (i = 0; i < ARRAY_SIZE(llme->lle); i++) {
71 struct gprs_llc_lle *lle = &llme->lle[i];
72 vty_dump_lle(vty, lle);
73 }
74}
75
76
Harald Welte2e918a82010-05-18 12:20:12 +020077DEFUN(show_llc, show_llc_cmd,
78 "show llc",
79 SHOW_STR "Display information about the LLC protocol")
80{
Harald Welte807a5d82010-06-01 11:53:01 +020081 struct gprs_llc_llme *llme;
Harald Welte2e918a82010-05-18 12:20:12 +020082
83 vty_out(vty, "State of LLC Entities%s", VTY_NEWLINE);
Harald Welte807a5d82010-06-01 11:53:01 +020084 llist_for_each_entry(llme, &gprs_llc_llmes, list) {
85 vty_dump_llme(vty, llme);
Harald Welte2e918a82010-05-18 12:20:12 +020086 }
87 return CMD_SUCCESS;
88}
89
90int gprs_llc_vty_init(void)
91{
92 install_element_ve(&show_llc_cmd);
93
94 return 0;
95}