blob: 03ef083072083a3794bb6e78473fab9f374fcd8b [file] [log] [blame]
Pau Espin Pedrol4f29fe72022-11-21 13:06:36 +01001/* gprs_debug.c
Ivan Kluchnikov60437182012-05-24 22:07:15 +04002 *
3 * Copyright (C) 2012 Ivan Klyuchnikov
Harald Welte48b1e7a2019-03-21 22:33:36 +01004 * Copyright (C) 2019 Harald Welte <laforge@gnumonks.org>
Pau Espin Pedrol4f29fe72022-11-21 13:06:36 +01005 * Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
Ivan Kluchnikov60437182012-05-24 22:07:15 +04006 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Ivan Kluchnikov60437182012-05-24 22:07:15 +040016 */
Ivan Kluchnikov60437182012-05-24 22:07:15 +040017
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
Ivan Kluchnikov60437182012-05-24 22:07:15 +040021#include <gprs_debug.h>
22
23/* default categories */
24
25static const struct log_info_cat default_categories[] = {
Harald Welte48b1e7a2019-03-21 22:33:36 +010026 [DCSN1] = {
27 .name = "DCSN1",
28 .color = "\033[1;31m",
29 .description = "Concrete Syntax Notation One (CSN1)",
Philipp Maierde0e5582020-03-25 12:23:52 +010030 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010031 .enabled = 0,
32 },
33 [DL1IF] = {
34 .name = "DL1IF",
35 .color = "\033[1;32m",
36 .description = "GPRS PCU L1 interface (L1IF)",
Philipp Maierde0e5582020-03-25 12:23:52 +010037 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010038 .enabled = 1,
39 },
40 [DRLCMAC] = {
41 .name = "DRLCMAC",
42 .color = "\033[0;33m",
43 .description = "GPRS RLC/MAC layer (RLCMAC)",
44 .loglevel = LOGL_NOTICE,
45 .enabled = 1,
46 },
47 [DRLCMACDATA] = {
48 .name = "DRLCMACDATA",
49 .color = "\033[0;33m",
50 .description = "GPRS RLC/MAC layer Data (RLCMAC)",
51 .loglevel = LOGL_NOTICE,
52 .enabled = 1,
53 },
54 [DRLCMACDL] = {
55 .name = "DRLCMACDL",
56 .color = "\033[1;33m",
57 .description = "GPRS RLC/MAC layer Downlink (RLCMAC)",
58 .loglevel = LOGL_NOTICE,
59 .enabled = 1,
60 },
61 [DRLCMACUL] = {
62 .name = "DRLCMACUL",
63 .color = "\033[1;36m",
64 .description = "GPRS RLC/MAC layer Uplink (RLCMAC)",
65 .loglevel = LOGL_NOTICE,
66 .enabled = 1,
67 },
68 [DRLCMACSCHED] = {
69 .name = "DRLCMACSCHED",
70 .color = "\033[0;36m",
71 .description = "GPRS RLC/MAC layer Scheduling (RLCMAC)",
72 .loglevel = LOGL_NOTICE,
73 .enabled = 1,
74 },
75 [DRLCMACMEAS] = {
76 .name = "DRLCMACMEAS",
77 .color = "\033[1;31m",
78 .description = "GPRS RLC/MAC layer Measurements (RLCMAC)",
Philipp Maierde0e5582020-03-25 12:23:52 +010079 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010080 .enabled = 1,
81 },
82 [DTBF] = {
83 .name = "DTBF",
84 .color = "\033[1;34m",
85 .description = "Temporary Block Flow (TBF)",
Philipp Maierde0e5582020-03-25 12:23:52 +010086 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010087 .enabled = 1,
88 },
89 [DTBFDL] = {
90 .name = "DTBFDL",
91 .color = "\033[1;34m",
92 .description = "Temporary Block Flow (TBF) Downlink",
Philipp Maierde0e5582020-03-25 12:23:52 +010093 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +010094 .enabled = 1,
95 },
96 [DTBFUL] = {
97 .name = "DTBFUL",
98 .color = "\033[1;34m",
99 .description = "Temporary Block Flow (TBF) Uplink",
Philipp Maierde0e5582020-03-25 12:23:52 +0100100 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +0100101 .enabled = 1,
102 },
103 [DNS] = {
104 .name = "DNS",
105 .color = "\033[1;34m",
106 .description = "GPRS Network Service Protocol (NS)",
Philipp Maierde0e5582020-03-25 12:23:52 +0100107 .loglevel = LOGL_NOTICE,
Harald Welte48b1e7a2019-03-21 22:33:36 +0100108 .enabled = 1,
109 },
Harald Welte48b1e7a2019-03-21 22:33:36 +0100110 [DPCU] = {
111 .name = "DPCU",
112 .color = "\033[1;35m",
113 .description = "GPRS Packet Control Unit (PCU)",
114 .loglevel = LOGL_NOTICE,
115 .enabled = 1,
116 },
Pau Espin Pedrolc0a250d2021-01-21 18:46:13 +0100117 [DNACC] = {
118 .name = "DNACC",
119 .color = "\033[1;37m",
120 .description = "Network Assisted Cell Change (NACC)",
121 .loglevel = LOGL_NOTICE,
122 .enabled = 1,
123 },
Pau Espin Pedrol3a271022021-01-21 18:44:23 +0100124 [DRIM] = {
125 .name = "DRIM",
126 .color = "\033[1;38m",
127 .description = "RAN Information Management (RIM)",
128 .loglevel = LOGL_NOTICE,
129 .enabled = 1,
130 },
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400131};
132
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400133static int filter_fn(const struct log_context *ctx,
134 struct log_target *tar)
135{
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100136 const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_NSVC];
137 const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_BVC];
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400138
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400139 /* Filter on the NS Virtual Connection */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100140 if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
141 && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400142 return 1;
143
144 /* Filter on the BVC */
Neels Hofmeyra01e2ee2017-02-23 18:10:13 +0100145 if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
146 && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
Ivan Kluchnikov60437182012-05-24 22:07:15 +0400147 return 1;
148
149 return 0;
150}
151
152const struct log_info gprs_log_info = {
153 filter_fn,
154 (struct log_info_cat*)default_categories,
155 ARRAY_SIZE(default_categories),
156};