blob: 408dddf75a067e2f1013a69e63c972a219355811 [file] [log] [blame]
Harald Welte4f5883b2012-06-16 16:54:06 +08001/* OpenBSC VTY common helpers */
2/* (C) 2009-2012 by Harald Welte <laforge@gnumonks.org>
3 * (C) 2009-2010 by Holger Hans Peter Freyther
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (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 Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <stdlib.h>
22#include <string.h>
23
24#include <osmocom/core/talloc.h>
25
26#include <osmocom/vty/telnet_interface.h>
27#include <osmocom/vty/command.h>
28#include <osmocom/vty/buffer.h>
29#include <osmocom/vty/vty.h>
30
Harald Weltef5430362012-06-17 12:25:53 +080031#include <osmocom/gprs/gprs_msgb.h>
32
33#include "common_vty.h"
34
Harald Welte4f5883b2012-06-16 16:54:06 +080035/* Down vty node level. */
36gDEFUN(libgb_exit,
37 libgb_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
38{
39 switch (vty->node) {
40 case L_NS_NODE:
41 case L_BSSGP_NODE:
42 vty->node = CONFIG_NODE;
43 vty->index = NULL;
44 break;
45 default:
46 break;
47 }
48 return CMD_SUCCESS;
49}
50
51/* End of configuration. */
52gDEFUN(libgb_end,
53 libgb_end_cmd, "end", "End current mode and change to enable mode.")
54{
55 switch (vty->node) {
56 case L_NS_NODE:
57 case L_BSSGP_NODE:
58 vty_config_unlock(vty);
59 vty->node = ENABLE_NODE;
60 vty->index = NULL;
61 vty->index_sub = NULL;
62 break;
63 default:
64 break;
65 }
66 return CMD_SUCCESS;
67}
Harald Weltecca49632012-06-16 17:45:59 +080068
Harald Weltef5430362012-06-17 12:25:53 +080069int gprs_log_filter_fn(const struct log_context *ctx,
70 struct log_target *tar)
71{
72 const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC];
73 const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC];
74
75 /* Filter on the NS Virtual Connection */
76 if ((tar->filter_map & (1 << FLT_NSVC)) != 0
77 && nsvc && (nsvc == tar->filter_data[FLT_NSVC]))
78 return 1;
79
80 /* Filter on the NS Virtual Connection */
81 if ((tar->filter_map & (1 << FLT_BVC)) != 0
82 && bvc && (bvc == tar->filter_data[FLT_BVC]))
83 return 1;
84
85 return 0;
86}
87
88
Harald Weltecca49632012-06-16 17:45:59 +080089int DNS, DBSSGP;