Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 1 | /* OpenBSC Debugging/Logging support code */ |
| 2 | |
| 3 | /* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> |
Holger Freyther | d546e31 | 2008-12-27 12:03:07 +0000 | [diff] [blame] | 4 | * (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org> |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 8 | * it under the terms of the GNU Affero General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 10 | * (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 |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 15 | * GNU Affero General Public License for more details. |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 16 | * |
Harald Welte | 9af6ddf | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 17 | * You should have received a copy of the GNU Affero General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <stdarg.h> |
Holger Freyther | d546e31 | 2008-12-27 12:03:07 +0000 | [diff] [blame] | 23 | #include <stdlib.h> |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 24 | #include <stdio.h> |
| 25 | #include <string.h> |
Holger Freyther | d546e31 | 2008-12-27 12:03:07 +0000 | [diff] [blame] | 26 | #include <strings.h> |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 27 | #include <time.h> |
Harald Welte (local) | b79bdd9 | 2009-12-26 19:45:22 +0100 | [diff] [blame] | 28 | #include <errno.h> |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 29 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 30 | #include <osmocom/core/talloc.h> |
| 31 | #include <osmocom/core/utils.h> |
| 32 | #include <osmocom/core/logging.h> |
Harald Welte | 68d85d5 | 2012-06-16 17:45:59 +0800 | [diff] [blame] | 33 | #include <osmocom/gprs/gprs_msgb.h> |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 34 | #include <osmocom/msc/gsm_data.h> |
| 35 | #include <osmocom/msc/debug.h> |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 36 | |
Holger Hans Peter Freyther | b61e3b2 | 2009-12-22 22:32:51 +0100 | [diff] [blame] | 37 | /* default categories */ |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 38 | static const struct log_info_cat default_categories[] = { |
| 39 | [DRLL] = { |
| 40 | .name = "DRLL", |
Harald Welte | f171a6e | 2010-05-11 10:51:30 +0200 | [diff] [blame] | 41 | .description = "A-bis Radio Link Layer (RLL)", |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 42 | .color = "\033[1;31m", |
| 43 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 44 | }, |
| 45 | [DCC] = { |
| 46 | .name = "DCC", |
Harald Welte | f171a6e | 2010-05-11 10:51:30 +0200 | [diff] [blame] | 47 | .description = "Layer3 Call Control (CC)", |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 48 | .color = "\033[1;32m", |
| 49 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 50 | }, |
| 51 | [DMM] = { |
| 52 | .name = "DMM", |
Harald Welte | f171a6e | 2010-05-11 10:51:30 +0200 | [diff] [blame] | 53 | .description = "Layer3 Mobility Management (MM)", |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 54 | .color = "\033[1;33m", |
| 55 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 56 | }, |
| 57 | [DRR] = { |
| 58 | .name = "DRR", |
Harald Welte | f171a6e | 2010-05-11 10:51:30 +0200 | [diff] [blame] | 59 | .description = "Layer3 Radio Resource (RR)", |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 60 | .color = "\033[1;34m", |
| 61 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 62 | }, |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 63 | [DMNCC] = { |
| 64 | .name = "DMNCC", |
Harald Welte | f171a6e | 2010-05-11 10:51:30 +0200 | [diff] [blame] | 65 | .description = "MNCC API for Call Control application", |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 66 | .color = "\033[1;39m", |
| 67 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 68 | }, |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 69 | [DPAG] = { |
| 70 | .name = "DPAG", |
Harald Welte | f171a6e | 2010-05-11 10:51:30 +0200 | [diff] [blame] | 71 | .description = "Paging Subsystem", |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 72 | .color = "\033[1;38m", |
| 73 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 74 | }, |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 75 | [DMSC] = { |
| 76 | .name = "DMSC", |
| 77 | .description = "Mobile Switching Center", |
| 78 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 79 | }, |
| 80 | [DMGCP] = { |
| 81 | .name = "DMGCP", |
| 82 | .description = "Media Gateway Control Protocol", |
| 83 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 84 | }, |
| 85 | [DHO] = { |
| 86 | .name = "DHO", |
| 87 | .description = "Hand-Over", |
| 88 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 89 | }, |
| 90 | [DDB] = { |
| 91 | .name = "DDB", |
Harald Welte | f171a6e | 2010-05-11 10:51:30 +0200 | [diff] [blame] | 92 | .description = "Database Layer", |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 93 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 94 | }, |
| 95 | [DREF] = { |
| 96 | .name = "DREF", |
| 97 | .description = "Reference Counting", |
| 98 | .enabled = 0, .loglevel = LOGL_NOTICE, |
| 99 | }, |
Daniel Willmann | 1c33d4c | 2011-07-19 12:14:34 +0200 | [diff] [blame] | 100 | [DCTRL] = { |
| 101 | .name = "DCTRL", |
| 102 | .description = "Control interface", |
| 103 | .enabled = 1, .loglevel = LOGL_NOTICE, |
| 104 | }, |
Harald Welte | f1033cc | 2012-11-08 16:14:37 +0100 | [diff] [blame] | 105 | [DSMPP] = { |
| 106 | .name = "DSMPP", |
| 107 | .description = "SMPP interface for external SMS apps", |
| 108 | .enabled = 1, .loglevel = LOGL_DEBUG, |
| 109 | }, |
Daniel Willmann | 35a65ed | 2016-05-20 21:59:45 +0200 | [diff] [blame] | 110 | [DRANAP] = { |
| 111 | .name = "DRANAP", |
| 112 | .description = "Radio Access Network Application Part Protocol", |
| 113 | .enabled = 1, .loglevel = LOGL_DEBUG, |
| 114 | }, |
Harald Welte | b8b85a1 | 2016-06-17 00:06:42 +0200 | [diff] [blame] | 115 | [DVLR] = { |
| 116 | .name = "DVLR", |
| 117 | .description = "Visitor Location Register", |
| 118 | .enabled = 1, .loglevel = LOGL_DEBUG, |
| 119 | }, |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 120 | [DIUCS] = { |
| 121 | .name = "DIUCS", |
| 122 | .description = "Iu-CS Protocol", |
| 123 | .enabled = 1, .loglevel = LOGL_DEBUG, |
| 124 | }, |
Holger Hans Peter Freyther | b61e3b2 | 2009-12-22 22:32:51 +0100 | [diff] [blame] | 125 | }; |
Holger Freyther | 32636e8 | 2008-12-27 11:07:15 +0000 | [diff] [blame] | 126 | |
Neels Hofmeyr | 94f49a4 | 2017-02-17 17:06:59 +0100 | [diff] [blame] | 127 | static int filter_fn(const struct log_context *ctx, struct log_target *tar) |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 128 | { |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 129 | const struct vlr_subscr *vsub = ctx->ctx[LOG_CTX_VLR_SUBSCR]; |
Holger Hans Peter Freyther | b61e3b2 | 2009-12-22 22:32:51 +0100 | [diff] [blame] | 130 | |
Neels Hofmeyr | 89a8e72 | 2017-02-23 18:00:51 +0100 | [diff] [blame] | 131 | if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0 |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 132 | && vsub && vsub == tar->filter_data[LOG_FLT_VLR_SUBSCR]) |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 133 | return 1; |
Holger Freyther | d546e31 | 2008-12-27 12:03:07 +0000 | [diff] [blame] | 134 | |
Harald Welte | dc5062b | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | const struct log_info log_info = { |
| 139 | .filter_fn = filter_fn, |
| 140 | .cat = default_categories, |
| 141 | .num_cat = ARRAY_SIZE(default_categories), |
Holger Freyther | d546e31 | 2008-12-27 12:03:07 +0000 | [diff] [blame] | 142 | }; |