blob: f1ae6ad6f3c4df53d81899cb633022e79b001762 [file] [log] [blame]
Ivan Kluchnikov60437182012-05-24 22:07:15 +04001/* gprs_debug.cpp
2 *
3 * Copyright (C) 2012 Ivan Klyuchnikov
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
Ivan Kluchnikov60437182012-05-24 22:07:15 +040019
Ivan Kluchnikov60437182012-05-24 22:07:15 +040020#include <osmocom/core/utils.h>
21#include <osmocom/core/logging.h>
Ivan Kluchnikov60437182012-05-24 22:07:15 +040022#include <gprs_debug.h>
23
24/* default categories */
25
26static const struct log_info_cat default_categories[] = {
Andreas Eversberg0e403092012-07-06 11:04:57 +020027 {"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0},
28 {"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_INFO, 1},
Andreas Eversbergd87b4682012-11-04 12:51:42 +010029 {"DRLCMAC", "\033[0;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_NOTICE, 1},
30 {"DRLCMACDATA", "\033[0;33m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_NOTICE, 1},
31 {"DRLCMACDL", "\033[1;33m", "GPRS RLC/MAC layer Downlink (RLCMAC)", LOGL_NOTICE, 1},
32 {"DRLCMACUL", "\033[1;36m", "GPRS RLC/MAC layer Uplink (RLCMAC)", LOGL_NOTICE, 1},
33 {"DRLCMACSCHED", "\033[0;36m", "GPRS RLC/MAC layer Scheduling (RLCMAC)", LOGL_NOTICE, 1},
Andreas Eversberg050ace22013-03-16 16:22:02 +010034 {"DRLCMACMEAS", "\033[1;31m", "GPRS RLC/MAC layer Measurements (RLCMAC)", LOGL_INFO, 1},
Max0524e382018-01-19 18:22:25 +010035 {"DTBF","\033[1;34m", "Temporary Block Flow (TBF)", LOGL_INFO , 1},
36 {"DTBFDL","\033[1;34m", "Temporary Block Flow (TBF) Downlink", LOGL_INFO , 1},
37 {"DTBFUL","\033[1;34m", "Temporary Block Flow (TBF) Uplink", LOGL_INFO , 1},
Jacob Erlbeck56af6d52015-08-17 14:06:21 +020038 {"DNS","\033[1;34m", "GPRS Network Service Protocol (NS)", LOGL_INFO , 1},
Andreas Eversbergd87b4682012-11-04 12:51:42 +010039 {"DBSSGP","\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO , 1},
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020040 {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1},
Ivan Kluchnikov60437182012-05-24 22:07:15 +040041};
42
Ivan Kluchnikov60437182012-05-24 22:07:15 +040043static int filter_fn(const struct log_context *ctx,
44 struct log_target *tar)
45{
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +010046 const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_NSVC];
47 const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_BVC];
Ivan Kluchnikov60437182012-05-24 22:07:15 +040048
Ivan Kluchnikov60437182012-05-24 22:07:15 +040049 /* Filter on the NS Virtual Connection */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +010050 if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
51 && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +040052 return 1;
53
54 /* Filter on the BVC */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +010055 if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
56 && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +040057 return 1;
58
59 return 0;
60}
61
62const struct log_info gprs_log_info = {
63 filter_fn,
64 (struct log_info_cat*)default_categories,
65 ARRAY_SIZE(default_categories),
66};