Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file common_vty.c |
| 2 | * OpenBSC VTY common helpers. */ |
| 3 | /* |
| 4 | * (C) 2009-2012 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 5 | * (C) 2009-2010 by Holger Hans Peter Freyther |
| 6 | * All Rights Reserved |
| 7 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
| 9 | * |
Harald Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 10 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 7fa89c2 | 2014-10-26 20:33:09 +0100 | [diff] [blame] | 11 | * 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 Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 13 | * (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 Welte | 7fa89c2 | 2014-10-26 20:33:09 +0100 | [diff] [blame] | 18 | * GNU General Public License for more details. |
Harald Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 19 | * |
Harald Welte | 7fa89c2 | 2014-10-26 20:33:09 +0100 | [diff] [blame] | 20 | * You should have received a copy of the GNU General Public License |
Harald Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 21 | * 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 Welte | 8eda90d | 2012-06-17 12:58:46 +0800 | [diff] [blame] | 29 | #include <osmocom/core/logging.h> |
Harald Welte | 4f5883b | 2012-06-16 16:54:06 +0800 | [diff] [blame] | 30 | |
| 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 Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 36 | #include <osmocom/gprs/gprs_msgb.h> |
| 37 | |
| 38 | #include "common_vty.h" |
| 39 | |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 40 | int gprs_log_filter_fn(const struct log_context *ctx, |
| 41 | struct log_target *tar) |
| 42 | { |
Daniel Willmann | 751977b | 2020-12-02 18:59:44 +0100 | [diff] [blame] | 43 | const void *nse = ctx->ctx[LOG_CTX_GB_NSE]; |
Alexander Couzens | 3b68883 | 2020-09-03 17:37:36 +0200 | [diff] [blame] | 44 | const void *nsvc = ctx->ctx[LOG_CTX_GB_NSVC]; |
| 45 | const void *bvc = ctx->ctx[LOG_CTX_GB_BVC]; |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 46 | |
Daniel Willmann | 751977b | 2020-12-02 18:59:44 +0100 | [diff] [blame] | 47 | /* 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 Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 52 | /* Filter on the NS Virtual Connection */ |
Neels Hofmeyr | 8b86cd7 | 2017-02-23 18:03:28 +0100 | [diff] [blame] | 53 | if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 |
| 54 | && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 55 | return 1; |
| 56 | |
Daniel Willmann | 751977b | 2020-12-02 18:59:44 +0100 | [diff] [blame] | 57 | /* Filter on the BSSGP Virtual Connection */ |
Neels Hofmeyr | 8b86cd7 | 2017-02-23 18:03:28 +0100 | [diff] [blame] | 58 | if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 |
| 59 | && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) |
Harald Welte | f543036 | 2012-06-17 12:25:53 +0800 | [diff] [blame] | 60 | return 1; |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | |
Harald Welte | fde19ed | 2020-12-07 21:43:51 +0100 | [diff] [blame] | 66 | int DNS; |