blob: 91933a20daee7abb318bb10980ad41afa322cc23 [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
Ivan Kluchnikov60437182012-05-24 22:07:15 +040021#include <osmocom/core/utils.h>
22#include <osmocom/core/logging.h>
Ivan Kluchnikov60437182012-05-24 22:07:15 +040023#include <gprs_debug.h>
24
25/* default categories */
26
27static const struct log_info_cat default_categories[] = {
Harald Welte48b1e7a2019-03-21 22:33:36 +010028 [DCSN1] = {
29 .name = "DCSN1",
30 .color = "\033[1;31m",
31 .description = "Concrete Syntax Notation One (CSN1)",
32 .loglevel = LOGL_INFO,
33 .enabled = 0,
34 },
35 [DL1IF] = {
36 .name = "DL1IF",
37 .color = "\033[1;32m",
38 .description = "GPRS PCU L1 interface (L1IF)",
39 .loglevel = LOGL_INFO,
40 .enabled = 1,
41 },
42 [DRLCMAC] = {
43 .name = "DRLCMAC",
44 .color = "\033[0;33m",
45 .description = "GPRS RLC/MAC layer (RLCMAC)",
46 .loglevel = LOGL_NOTICE,
47 .enabled = 1,
48 },
49 [DRLCMACDATA] = {
50 .name = "DRLCMACDATA",
51 .color = "\033[0;33m",
52 .description = "GPRS RLC/MAC layer Data (RLCMAC)",
53 .loglevel = LOGL_NOTICE,
54 .enabled = 1,
55 },
56 [DRLCMACDL] = {
57 .name = "DRLCMACDL",
58 .color = "\033[1;33m",
59 .description = "GPRS RLC/MAC layer Downlink (RLCMAC)",
60 .loglevel = LOGL_NOTICE,
61 .enabled = 1,
62 },
63 [DRLCMACUL] = {
64 .name = "DRLCMACUL",
65 .color = "\033[1;36m",
66 .description = "GPRS RLC/MAC layer Uplink (RLCMAC)",
67 .loglevel = LOGL_NOTICE,
68 .enabled = 1,
69 },
70 [DRLCMACSCHED] = {
71 .name = "DRLCMACSCHED",
72 .color = "\033[0;36m",
73 .description = "GPRS RLC/MAC layer Scheduling (RLCMAC)",
74 .loglevel = LOGL_NOTICE,
75 .enabled = 1,
76 },
77 [DRLCMACMEAS] = {
78 .name = "DRLCMACMEAS",
79 .color = "\033[1;31m",
80 .description = "GPRS RLC/MAC layer Measurements (RLCMAC)",
81 .loglevel = LOGL_INFO,
82 .enabled = 1,
83 },
84 [DTBF] = {
85 .name = "DTBF",
86 .color = "\033[1;34m",
87 .description = "Temporary Block Flow (TBF)",
88 .loglevel = LOGL_INFO,
89 .enabled = 1,
90 },
91 [DTBFDL] = {
92 .name = "DTBFDL",
93 .color = "\033[1;34m",
94 .description = "Temporary Block Flow (TBF) Downlink",
95 .loglevel = LOGL_INFO,
96 .enabled = 1,
97 },
98 [DTBFUL] = {
99 .name = "DTBFUL",
100 .color = "\033[1;34m",
101 .description = "Temporary Block Flow (TBF) Uplink",
102 .loglevel = LOGL_INFO,
103 .enabled = 1,
104 },
105 [DNS] = {
106 .name = "DNS",
107 .color = "\033[1;34m",
108 .description = "GPRS Network Service Protocol (NS)",
109 .loglevel = LOGL_INFO,
110 .enabled = 1,
111 },
112 [DBSSGP] = {
113 .name = "DBSSGP",
114 .color = "\033[1;34m",
115 .description = "GPRS BSS Gateway Protocol (BSSGP)",
116 .loglevel = LOGL_INFO,
117 .enabled = 1,
118 },
119 [DPCU] = {
120 .name = "DPCU",
121 .color = "\033[1;35m",
122 .description = "GPRS Packet Control Unit (PCU)",
123 .loglevel = LOGL_NOTICE,
124 .enabled = 1,
125 },
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400126};
127
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400128static int filter_fn(const struct log_context *ctx,
129 struct log_target *tar)
130{
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100131 const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_NSVC];
132 const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_BVC];
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400133
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400134 /* Filter on the NS Virtual Connection */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100135 if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
136 && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400137 return 1;
138
139 /* Filter on the BVC */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100140 if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
141 && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400142 return 1;
143
144 return 0;
145}
146
147const struct log_info gprs_log_info = {
148 filter_fn,
149 (struct log_info_cat*)default_categories,
150 ARRAY_SIZE(default_categories),
151};