blob: 61c1c87e3b29373bdfeb5478c148e54a4418f545 [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.
Ivan Kluchnikov60437182012-05-24 22:07:15 +040015 */
Ivan Kluchnikov60437182012-05-24 22:07:15 +040016
Vadim Yanitskiyd2e50e72020-03-29 01:46:27 +070017extern "C" {
Ivan Kluchnikov60437182012-05-24 22:07:15 +040018#include <osmocom/core/utils.h>
19#include <osmocom/core/logging.h>
Vadim Yanitskiyd2e50e72020-03-29 01:46:27 +070020}
21
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[] = {
Harald Welte48b1e7a2019-03-21 22:33:36 +010027 [DCSN1] = {
28 .name = "DCSN1",
29 .color = "\033[1;31m",
30 .description = "Concrete Syntax Notation One (CSN1)",
Philipp Maierde0e5582020-03-25 12:23:52 +010031 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010032 .enabled = 0,
33 },
34 [DL1IF] = {
35 .name = "DL1IF",
36 .color = "\033[1;32m",
37 .description = "GPRS PCU L1 interface (L1IF)",
Philipp Maierde0e5582020-03-25 12:23:52 +010038 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010039 .enabled = 1,
40 },
41 [DRLCMAC] = {
42 .name = "DRLCMAC",
43 .color = "\033[0;33m",
44 .description = "GPRS RLC/MAC layer (RLCMAC)",
45 .loglevel = LOGL_NOTICE,
46 .enabled = 1,
47 },
48 [DRLCMACDATA] = {
49 .name = "DRLCMACDATA",
50 .color = "\033[0;33m",
51 .description = "GPRS RLC/MAC layer Data (RLCMAC)",
52 .loglevel = LOGL_NOTICE,
53 .enabled = 1,
54 },
55 [DRLCMACDL] = {
56 .name = "DRLCMACDL",
57 .color = "\033[1;33m",
58 .description = "GPRS RLC/MAC layer Downlink (RLCMAC)",
59 .loglevel = LOGL_NOTICE,
60 .enabled = 1,
61 },
62 [DRLCMACUL] = {
63 .name = "DRLCMACUL",
64 .color = "\033[1;36m",
65 .description = "GPRS RLC/MAC layer Uplink (RLCMAC)",
66 .loglevel = LOGL_NOTICE,
67 .enabled = 1,
68 },
69 [DRLCMACSCHED] = {
70 .name = "DRLCMACSCHED",
71 .color = "\033[0;36m",
72 .description = "GPRS RLC/MAC layer Scheduling (RLCMAC)",
73 .loglevel = LOGL_NOTICE,
74 .enabled = 1,
75 },
76 [DRLCMACMEAS] = {
77 .name = "DRLCMACMEAS",
78 .color = "\033[1;31m",
79 .description = "GPRS RLC/MAC layer Measurements (RLCMAC)",
Philipp Maierde0e5582020-03-25 12:23:52 +010080 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010081 .enabled = 1,
82 },
83 [DTBF] = {
84 .name = "DTBF",
85 .color = "\033[1;34m",
86 .description = "Temporary Block Flow (TBF)",
Philipp Maierde0e5582020-03-25 12:23:52 +010087 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010088 .enabled = 1,
89 },
90 [DTBFDL] = {
91 .name = "DTBFDL",
92 .color = "\033[1;34m",
93 .description = "Temporary Block Flow (TBF) Downlink",
Philipp Maierde0e5582020-03-25 12:23:52 +010094 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010095 .enabled = 1,
96 },
97 [DTBFUL] = {
98 .name = "DTBFUL",
99 .color = "\033[1;34m",
100 .description = "Temporary Block Flow (TBF) Uplink",
Philipp Maierde0e5582020-03-25 12:23:52 +0100101 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +0100102 .enabled = 1,
103 },
104 [DNS] = {
105 .name = "DNS",
106 .color = "\033[1;34m",
107 .description = "GPRS Network Service Protocol (NS)",
Philipp Maierde0e5582020-03-25 12:23:52 +0100108 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +0100109 .enabled = 1,
110 },
Harald Welte48b1e7a2019-03-21 22:33:36 +0100111 [DPCU] = {
112 .name = "DPCU",
113 .color = "\033[1;35m",
114 .description = "GPRS Packet Control Unit (PCU)",
115 .loglevel = LOGL_NOTICE,
116 .enabled = 1,
117 },
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +0100118 [DNACC] = {
119 .name = "DNACC",
120 .color = "\033[1;37m",
121 .description = "Network Assisted Cell Change (NACC)",
122 .loglevel = LOGL_NOTICE,
123 .enabled = 1,
124 },
Pau Espin Pedrol3a271022021-01-21 18:44:23 +0100125 [DRIM] = {
126 .name = "DRIM",
127 .color = "\033[1;38m",
128 .description = "RAN Information Management (RIM)",
129 .loglevel = LOGL_NOTICE,
130 .enabled = 1,
131 },
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400132};
133
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400134static int filter_fn(const struct log_context *ctx,
135 struct log_target *tar)
136{
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100137 const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_NSVC];
138 const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_BVC];
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400139
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400140 /* Filter on the NS Virtual Connection */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100141 if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
142 && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400143 return 1;
144
145 /* Filter on the BVC */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100146 if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
147 && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400148 return 1;
149
150 return 0;
151}
152
153const struct log_info gprs_log_info = {
154 filter_fn,
155 (struct log_info_cat*)default_categories,
156 ARRAY_SIZE(default_categories),
157};