blob: 0cbc4880da6cb62d5d020d9af879460fabef99e1 [file] [log] [blame]
Ivan Kluchnikov60437182012-05-24 22:07:15 +04001/* gprs_debug.cpp
2 *
3 * Copyright (C) 2012 Ivan Klyuchnikov
Harald Welte48b1e7a2019-03-21 22:33:36 +01004 * Copyright (C) 2019 Harald Welte <laforge@gnumonks.org>
Ivan Kluchnikov60437182012-05-24 22:07:15 +04005 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (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 General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
Ivan Kluchnikov60437182012-05-24 22:07:15 +040020
Vadim Yanitskiyd2e50e72020-03-29 01:46:27 +070021extern "C" {
Ivan Kluchnikov60437182012-05-24 22:07:15 +040022#include <osmocom/core/utils.h>
23#include <osmocom/core/logging.h>
Vadim Yanitskiyd2e50e72020-03-29 01:46:27 +070024}
25
Ivan Kluchnikov60437182012-05-24 22:07:15 +040026#include <gprs_debug.h>
27
28/* default categories */
29
30static const struct log_info_cat default_categories[] = {
Harald Welte48b1e7a2019-03-21 22:33:36 +010031 [DCSN1] = {
32 .name = "DCSN1",
33 .color = "\033[1;31m",
34 .description = "Concrete Syntax Notation One (CSN1)",
Philipp Maierde0e5582020-03-25 12:23:52 +010035 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010036 .enabled = 0,
37 },
38 [DL1IF] = {
39 .name = "DL1IF",
40 .color = "\033[1;32m",
41 .description = "GPRS PCU L1 interface (L1IF)",
Philipp Maierde0e5582020-03-25 12:23:52 +010042 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010043 .enabled = 1,
44 },
45 [DRLCMAC] = {
46 .name = "DRLCMAC",
47 .color = "\033[0;33m",
48 .description = "GPRS RLC/MAC layer (RLCMAC)",
49 .loglevel = LOGL_NOTICE,
50 .enabled = 1,
51 },
52 [DRLCMACDATA] = {
53 .name = "DRLCMACDATA",
54 .color = "\033[0;33m",
55 .description = "GPRS RLC/MAC layer Data (RLCMAC)",
56 .loglevel = LOGL_NOTICE,
57 .enabled = 1,
58 },
59 [DRLCMACDL] = {
60 .name = "DRLCMACDL",
61 .color = "\033[1;33m",
62 .description = "GPRS RLC/MAC layer Downlink (RLCMAC)",
63 .loglevel = LOGL_NOTICE,
64 .enabled = 1,
65 },
66 [DRLCMACUL] = {
67 .name = "DRLCMACUL",
68 .color = "\033[1;36m",
69 .description = "GPRS RLC/MAC layer Uplink (RLCMAC)",
70 .loglevel = LOGL_NOTICE,
71 .enabled = 1,
72 },
73 [DRLCMACSCHED] = {
74 .name = "DRLCMACSCHED",
75 .color = "\033[0;36m",
76 .description = "GPRS RLC/MAC layer Scheduling (RLCMAC)",
77 .loglevel = LOGL_NOTICE,
78 .enabled = 1,
79 },
80 [DRLCMACMEAS] = {
81 .name = "DRLCMACMEAS",
82 .color = "\033[1;31m",
83 .description = "GPRS RLC/MAC layer Measurements (RLCMAC)",
Philipp Maierde0e5582020-03-25 12:23:52 +010084 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010085 .enabled = 1,
86 },
87 [DTBF] = {
88 .name = "DTBF",
89 .color = "\033[1;34m",
90 .description = "Temporary Block Flow (TBF)",
Philipp Maierde0e5582020-03-25 12:23:52 +010091 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010092 .enabled = 1,
93 },
94 [DTBFDL] = {
95 .name = "DTBFDL",
96 .color = "\033[1;34m",
97 .description = "Temporary Block Flow (TBF) Downlink",
Philipp Maierde0e5582020-03-25 12:23:52 +010098 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010099 .enabled = 1,
100 },
101 [DTBFUL] = {
102 .name = "DTBFUL",
103 .color = "\033[1;34m",
104 .description = "Temporary Block Flow (TBF) Uplink",
Philipp Maierde0e5582020-03-25 12:23:52 +0100105 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +0100106 .enabled = 1,
107 },
108 [DNS] = {
109 .name = "DNS",
110 .color = "\033[1;34m",
111 .description = "GPRS Network Service Protocol (NS)",
Philipp Maierde0e5582020-03-25 12:23:52 +0100112 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +0100113 .enabled = 1,
114 },
Harald Welte48b1e7a2019-03-21 22:33:36 +0100115 [DPCU] = {
116 .name = "DPCU",
117 .color = "\033[1;35m",
118 .description = "GPRS Packet Control Unit (PCU)",
119 .loglevel = LOGL_NOTICE,
120 .enabled = 1,
121 },
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +0100122 [DNACC] = {
123 .name = "DNACC",
124 .color = "\033[1;37m",
125 .description = "Network Assisted Cell Change (NACC)",
126 .loglevel = LOGL_NOTICE,
127 .enabled = 1,
128 },
Pau Espin Pedrol3a271022021-01-21 18:44:23 +0100129 [DRIM] = {
130 .name = "DRIM",
131 .color = "\033[1;38m",
132 .description = "RAN Information Management (RIM)",
133 .loglevel = LOGL_NOTICE,
134 .enabled = 1,
135 },
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400136};
137
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400138static int filter_fn(const struct log_context *ctx,
139 struct log_target *tar)
140{
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100141 const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_NSVC];
142 const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_BVC];
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400143
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400144 /* Filter on the NS Virtual Connection */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100145 if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
146 && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400147 return 1;
148
149 /* Filter on the BVC */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100150 if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
151 && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400152 return 1;
153
154 return 0;
155}
156
157const struct log_info gprs_log_info = {
158 filter_fn,
159 (struct log_info_cat*)default_categories,
160 ARRAY_SIZE(default_categories),
161};