blob: ad3dea23d669541868d7dcd952fba051c21c2bcb [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file common_vty.c
2 * OpenBSC VTY common helpers. */
3/*
4 * (C) 2009-2012 by Harald Welte <laforge@gnumonks.org>
Harald Welte4f5883b2012-06-16 16:54:06 +08005 * (C) 2009-2010 by Holger Hans Peter Freyther
6 * All Rights Reserved
7 *
Harald Weltee08da972017-11-13 01:00:26 +09008 * SPDX-License-Identifier: GPL-2.0+
9 *
Harald Welte4f5883b2012-06-16 16:54:06 +080010 * This program is free software; you can redistribute it and/or modify
Harald Welte7fa89c22014-10-26 20:33:09 +010011 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
Harald Welte4f5883b2012-06-16 16:54:06 +080013 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte7fa89c22014-10-26 20:33:09 +010018 * GNU General Public License for more details.
Harald Welte4f5883b2012-06-16 16:54:06 +080019 *
Harald Welte7fa89c22014-10-26 20:33:09 +010020 * You should have received a copy of the GNU General Public License
Harald Welte4f5883b2012-06-16 16:54:06 +080021 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#include <stdlib.h>
26#include <string.h>
27
28#include <osmocom/core/talloc.h>
Harald Welte8eda90d2012-06-17 12:58:46 +080029#include <osmocom/core/logging.h>
Harald Welte4f5883b2012-06-16 16:54:06 +080030
31#include <osmocom/vty/telnet_interface.h>
32#include <osmocom/vty/command.h>
33#include <osmocom/vty/buffer.h>
34#include <osmocom/vty/vty.h>
35
Harald Weltef5430362012-06-17 12:25:53 +080036#include <osmocom/gprs/gprs_msgb.h>
37
38#include "common_vty.h"
39
Harald Weltef5430362012-06-17 12:25:53 +080040int gprs_log_filter_fn(const struct log_context *ctx,
41 struct log_target *tar)
42{
Daniel Willmann751977b2020-12-02 18:59:44 +010043 const void *nse = ctx->ctx[LOG_CTX_GB_NSE];
Alexander Couzens3b688832020-09-03 17:37:36 +020044 const void *nsvc = ctx->ctx[LOG_CTX_GB_NSVC];
45 const void *bvc = ctx->ctx[LOG_CTX_GB_BVC];
Harald Weltef5430362012-06-17 12:25:53 +080046
Daniel Willmann751977b2020-12-02 18:59:44 +010047 /* Filter on the NS Entity */
48 if ((tar->filter_map & (1 << LOG_FLT_GB_NSE)) != 0
49 && nse && (nse == tar->filter_data[LOG_FLT_GB_NSE]))
50 return 1;
51
Harald Weltef5430362012-06-17 12:25:53 +080052 /* Filter on the NS Virtual Connection */
Neels Hofmeyr8b86cd72017-02-23 18:03:28 +010053 if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
54 && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
Harald Weltef5430362012-06-17 12:25:53 +080055 return 1;
56
Daniel Willmann751977b2020-12-02 18:59:44 +010057 /* Filter on the BSSGP Virtual Connection */
Neels Hofmeyr8b86cd72017-02-23 18:03:28 +010058 if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
59 && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
Harald Weltef5430362012-06-17 12:25:53 +080060 return 1;
61
62 return 0;
63}
64
65
Harald Weltefde19ed2020-12-07 21:43:51 +010066int DNS;