Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 1 | /* gprs_debug.cpp |
| 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> |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 5 | * |
| 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 Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 20 | |
Vadim Yanitskiy | d2e50e7 | 2020-03-29 01:46:27 +0700 | [diff] [blame] | 21 | extern "C" { |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 22 | #include <osmocom/core/utils.h> |
| 23 | #include <osmocom/core/logging.h> |
Vadim Yanitskiy | d2e50e7 | 2020-03-29 01:46:27 +0700 | [diff] [blame] | 24 | } |
| 25 | |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 26 | #include <gprs_debug.h> |
| 27 | |
| 28 | /* default categories */ |
| 29 | |
| 30 | static const struct log_info_cat default_categories[] = { |
Harald Welte | 48b1e7a | 2019-03-21 22:33:36 +0100 | [diff] [blame] | 31 | [DCSN1] = { |
| 32 | .name = "DCSN1", |
| 33 | .color = "\033[1;31m", |
| 34 | .description = "Concrete Syntax Notation One (CSN1)", |
| 35 | .loglevel = LOGL_INFO, |
| 36 | .enabled = 0, |
| 37 | }, |
| 38 | [DL1IF] = { |
| 39 | .name = "DL1IF", |
| 40 | .color = "\033[1;32m", |
| 41 | .description = "GPRS PCU L1 interface (L1IF)", |
| 42 | .loglevel = LOGL_INFO, |
| 43 | .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)", |
| 84 | .loglevel = LOGL_INFO, |
| 85 | .enabled = 1, |
| 86 | }, |
| 87 | [DTBF] = { |
| 88 | .name = "DTBF", |
| 89 | .color = "\033[1;34m", |
| 90 | .description = "Temporary Block Flow (TBF)", |
| 91 | .loglevel = LOGL_INFO, |
| 92 | .enabled = 1, |
| 93 | }, |
| 94 | [DTBFDL] = { |
| 95 | .name = "DTBFDL", |
| 96 | .color = "\033[1;34m", |
| 97 | .description = "Temporary Block Flow (TBF) Downlink", |
| 98 | .loglevel = LOGL_INFO, |
| 99 | .enabled = 1, |
| 100 | }, |
| 101 | [DTBFUL] = { |
| 102 | .name = "DTBFUL", |
| 103 | .color = "\033[1;34m", |
| 104 | .description = "Temporary Block Flow (TBF) Uplink", |
| 105 | .loglevel = LOGL_INFO, |
| 106 | .enabled = 1, |
| 107 | }, |
| 108 | [DNS] = { |
| 109 | .name = "DNS", |
| 110 | .color = "\033[1;34m", |
| 111 | .description = "GPRS Network Service Protocol (NS)", |
| 112 | .loglevel = LOGL_INFO, |
| 113 | .enabled = 1, |
| 114 | }, |
| 115 | [DBSSGP] = { |
| 116 | .name = "DBSSGP", |
| 117 | .color = "\033[1;34m", |
| 118 | .description = "GPRS BSS Gateway Protocol (BSSGP)", |
| 119 | .loglevel = LOGL_INFO, |
| 120 | .enabled = 1, |
| 121 | }, |
| 122 | [DPCU] = { |
| 123 | .name = "DPCU", |
| 124 | .color = "\033[1;35m", |
| 125 | .description = "GPRS Packet Control Unit (PCU)", |
| 126 | .loglevel = LOGL_NOTICE, |
| 127 | .enabled = 1, |
| 128 | }, |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 129 | }; |
| 130 | |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 131 | static int filter_fn(const struct log_context *ctx, |
| 132 | struct log_target *tar) |
| 133 | { |
Neels Hofmeyr | a01e2ee | 2017-02-23 18:10:13 +0100 | [diff] [blame] | 134 | const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[LOG_CTX_GB_NSVC]; |
| 135 | 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] | 136 | |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 137 | /* Filter on the NS Virtual Connection */ |
Neels Hofmeyr | a01e2ee | 2017-02-23 18:10:13 +0100 | [diff] [blame] | 138 | if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0 |
| 139 | && nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC])) |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 140 | return 1; |
| 141 | |
| 142 | /* Filter on the BVC */ |
Neels Hofmeyr | a01e2ee | 2017-02-23 18:10:13 +0100 | [diff] [blame] | 143 | if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0 |
| 144 | && bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC])) |
Ivan Kluchnikov | 6043718 | 2012-05-24 22:07:15 +0400 | [diff] [blame] | 145 | return 1; |
| 146 | |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | const struct log_info gprs_log_info = { |
| 151 | filter_fn, |
| 152 | (struct log_info_cat*)default_categories, |
| 153 | ARRAY_SIZE(default_categories), |
| 154 | }; |