Pau Espin Pedrol | 4f29fe7 | 2022-11-21 13:06:36 +0100 | [diff] [blame] | 1 | /* gprs_debug.c |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 2 | * |
| 3 | * Copyright (C) 2012 Ivan Klyuchnikov |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 4 | * Copyright (C) 2019 Harald Welte <laforge@gnumonks.org> |
Pau Espin Pedrol | 4f29fe7 | 2022-11-21 13:06:36 +0100 | [diff] [blame] | 5 | * Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 6 | * |
| 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 Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 16 | */ |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 17 | |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 18 | #include <osmocom/core/utils.h> |
| 19 | #include <osmocom/core/logging.h> |
Vadim Yanitskiy | d2e50e7 | 2020-03-29 01:46:27 +0700 | [diff] [blame] | 20 | |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 21 | #include <gprs_debug.h> |
| 22 | |
| 23 | /* default categories */ |
| 24 | |
| 25 | static const struct log_info_cat default_categories[] = { |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 26 | [DCSN1] = { |
| 27 | .name = "DCSN1", |
| 28 | .color = "\033[1;31m", |
| 29 | .description = "Concrete Syntax Notation One (CSN1)", |
Philipp Maier | de0e558 | 2020-03-25 12:23:52 +0100 | [diff] [blame] | 30 | .loglevel = LOGL_NOTICE, |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 31 | .enabled = 0, |
| 32 | }, |
| 33 | [DL1IF] = { |
| 34 | .name = "DL1IF", |
| 35 | .color = "\033[1;32m", |
| 36 | .description = "GPRS PCU L1 interface (L1IF)", |
Philipp Maier | de0e558 | 2020-03-25 12:23:52 +0100 | [diff] [blame] | 37 | .loglevel = LOGL_NOTICE, |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 38 | .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 Maier | de0e558 | 2020-03-25 12:23:52 +0100 | [diff] [blame] | 79 | .loglevel = LOGL_NOTICE, |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 80 | .enabled = 1, |
| 81 | }, |
| 82 | [DTBF] = { |
| 83 | .name = "DTBF", |
| 84 | .color = "\033[1;34m", |
| 85 | .description = "Temporary Block Flow (TBF)", |
Philipp Maier | de0e558 | 2020-03-25 12:23:52 +0100 | [diff] [blame] | 86 | .loglevel = LOGL_NOTICE, |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 87 | .enabled = 1, |
| 88 | }, |
| 89 | [DTBFDL] = { |
| 90 | .name = "DTBFDL", |
| 91 | .color = "\033[1;34m", |
| 92 | .description = "Temporary Block Flow (TBF) Downlink", |
Philipp Maier | de0e558 | 2020-03-25 12:23:52 +0100 | [diff] [blame] | 93 | .loglevel = LOGL_NOTICE, |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 94 | .enabled = 1, |
| 95 | }, |
| 96 | [DTBFUL] = { |
| 97 | .name = "DTBFUL", |
| 98 | .color = "\033[1;34m", |
| 99 | .description = "Temporary Block Flow (TBF) Uplink", |
Philipp Maier | de0e558 | 2020-03-25 12:23:52 +0100 | [diff] [blame] | 100 | .loglevel = LOGL_NOTICE, |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 101 | .enabled = 1, |
| 102 | }, |
| 103 | [DNS] = { |
| 104 | .name = "DNS", |
| 105 | .color = "\033[1;34m", |
| 106 | .description = "GPRS Network Service Protocol (NS)", |
Philipp Maier | de0e558 | 2020-03-25 12:23:52 +0100 | [diff] [blame] | 107 | .loglevel = LOGL_NOTICE, |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 108 | .enabled = 1, |
| 109 | }, |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 110 | [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 Pedrol | c0a250d | 2021-01-21 18:46:13 +0100 | [diff] [blame] | 117 | [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 Pedrol | 3a27102 | 2021-01-21 18:44:23 +0100 | [diff] [blame] | 124 | [DRIM] = { |
| 125 | .name = "DRIM", |
| 126 | .color = "\033[1;38m", |
| 127 | .description = "RAN Information Management (RIM)", |
| 128 | .loglevel = LOGL_NOTICE, |
| 129 | .enabled = 1, |
| 130 | }, |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 131 | }; |
| 132 | |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 133 | static int filter_fn(const struct log_context *ctx, |
| 134 | struct log_target *tar) |
| 135 | { |
Neels Hofmeyr | a01e2ee | 2017-02-23 18:10:13 +0100 | [diff] [blame] | 136 | 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 Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 138 | |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 139 | /* Filter on the NS Virtual Connection */ |
Neels Hofmeyr | a01e2ee | 2017-02-23 18:10:13 +0100 | [diff] [blame] | 140 | if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 |
| 141 | && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 142 | return 1; |
| 143 | |
| 144 | /* Filter on the BVC */ |
Neels Hofmeyr | a01e2ee | 2017-02-23 18:10:13 +0100 | [diff] [blame] | 145 | if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 |
| 146 | && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 147 | return 1; |
| 148 | |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | const struct log_info gprs_log_info = { |
| 153 | filter_fn, |
| 154 | (struct log_info_cat*)default_categories, |
| 155 | ARRAY_SIZE(default_categories), |
| 156 | }; |