blob: 8c0e7875ee2e83376321787fa8411faed1ab2be6 [file] [log] [blame]
Harald Weltedc5062b2010-03-26 21:28:59 +08001/* OpenBSC Debugging/Logging support code */
2
3/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
Holger Freytherd546e312008-12-27 12:03:07 +00004 * (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
Holger Freyther32636e82008-12-27 11:07:15 +00005 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01008 * 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 Freyther32636e82008-12-27 11:07:15 +000010 * (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 Welte9af6ddf2011-01-01 15:25:50 +010015 * GNU Affero General Public License for more details.
Holger Freyther32636e82008-12-27 11:07:15 +000016 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010017 * 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 Freyther32636e82008-12-27 11:07:15 +000019 *
20 */
21
22#include <stdarg.h>
Holger Freytherd546e312008-12-27 12:03:07 +000023#include <stdlib.h>
Holger Freyther32636e82008-12-27 11:07:15 +000024#include <stdio.h>
25#include <string.h>
Holger Freytherd546e312008-12-27 12:03:07 +000026#include <strings.h>
Holger Freyther32636e82008-12-27 11:07:15 +000027#include <time.h>
Harald Welte (local)b79bdd92009-12-26 19:45:22 +010028#include <errno.h>
Holger Freyther32636e82008-12-27 11:07:15 +000029
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010030#include <osmocom/core/talloc.h>
31#include <osmocom/core/utils.h>
32#include <osmocom/core/logging.h>
Harald Welte68d85d52012-06-16 17:45:59 +080033#include <osmocom/gprs/gprs_msgb.h>
Neels Hofmeyr90843962017-09-04 15:04:35 +020034#include <osmocom/msc/gsm_data.h>
35#include <osmocom/msc/debug.h>
Holger Freyther32636e82008-12-27 11:07:15 +000036
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +010037/* default categories */
Harald Weltedc5062b2010-03-26 21:28:59 +080038static const struct log_info_cat default_categories[] = {
39 [DRLL] = {
40 .name = "DRLL",
Harald Weltef171a6e2010-05-11 10:51:30 +020041 .description = "A-bis Radio Link Layer (RLL)",
Harald Weltedc5062b2010-03-26 21:28:59 +080042 .color = "\033[1;31m",
43 .enabled = 1, .loglevel = LOGL_NOTICE,
44 },
45 [DCC] = {
46 .name = "DCC",
Harald Weltef171a6e2010-05-11 10:51:30 +020047 .description = "Layer3 Call Control (CC)",
Harald Weltedc5062b2010-03-26 21:28:59 +080048 .color = "\033[1;32m",
49 .enabled = 1, .loglevel = LOGL_NOTICE,
50 },
51 [DMM] = {
52 .name = "DMM",
Harald Weltef171a6e2010-05-11 10:51:30 +020053 .description = "Layer3 Mobility Management (MM)",
Harald Weltedc5062b2010-03-26 21:28:59 +080054 .color = "\033[1;33m",
55 .enabled = 1, .loglevel = LOGL_NOTICE,
56 },
57 [DRR] = {
58 .name = "DRR",
Harald Weltef171a6e2010-05-11 10:51:30 +020059 .description = "Layer3 Radio Resource (RR)",
Harald Weltedc5062b2010-03-26 21:28:59 +080060 .color = "\033[1;34m",
61 .enabled = 1, .loglevel = LOGL_NOTICE,
62 },
Harald Weltedc5062b2010-03-26 21:28:59 +080063 [DMNCC] = {
64 .name = "DMNCC",
Harald Weltef171a6e2010-05-11 10:51:30 +020065 .description = "MNCC API for Call Control application",
Harald Weltedc5062b2010-03-26 21:28:59 +080066 .color = "\033[1;39m",
67 .enabled = 1, .loglevel = LOGL_NOTICE,
68 },
Harald Weltedc5062b2010-03-26 21:28:59 +080069 [DPAG] = {
70 .name = "DPAG",
Harald Weltef171a6e2010-05-11 10:51:30 +020071 .description = "Paging Subsystem",
Harald Weltedc5062b2010-03-26 21:28:59 +080072 .color = "\033[1;38m",
73 .enabled = 1, .loglevel = LOGL_NOTICE,
74 },
Harald Weltedc5062b2010-03-26 21:28:59 +080075 [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 Weltef171a6e2010-05-11 10:51:30 +020092 .description = "Database Layer",
Harald Weltedc5062b2010-03-26 21:28:59 +080093 .enabled = 1, .loglevel = LOGL_NOTICE,
94 },
95 [DREF] = {
96 .name = "DREF",
97 .description = "Reference Counting",
98 .enabled = 0, .loglevel = LOGL_NOTICE,
99 },
Daniel Willmann1c33d4c2011-07-19 12:14:34 +0200100 [DCTRL] = {
101 .name = "DCTRL",
102 .description = "Control interface",
103 .enabled = 1, .loglevel = LOGL_NOTICE,
104 },
Harald Weltef1033cc2012-11-08 16:14:37 +0100105 [DSMPP] = {
106 .name = "DSMPP",
107 .description = "SMPP interface for external SMS apps",
108 .enabled = 1, .loglevel = LOGL_DEBUG,
109 },
Daniel Willmann35a65ed2016-05-20 21:59:45 +0200110 [DRANAP] = {
111 .name = "DRANAP",
112 .description = "Radio Access Network Application Part Protocol",
113 .enabled = 1, .loglevel = LOGL_DEBUG,
114 },
Harald Welteb8b85a12016-06-17 00:06:42 +0200115 [DVLR] = {
116 .name = "DVLR",
117 .description = "Visitor Location Register",
118 .enabled = 1, .loglevel = LOGL_DEBUG,
119 },
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200120 [DIUCS] = {
121 .name = "DIUCS",
122 .description = "Iu-CS Protocol",
123 .enabled = 1, .loglevel = LOGL_DEBUG,
124 },
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +0100125};
Holger Freyther32636e82008-12-27 11:07:15 +0000126
Neels Hofmeyr94f49a42017-02-17 17:06:59 +0100127static int filter_fn(const struct log_context *ctx, struct log_target *tar)
Harald Weltedc5062b2010-03-26 21:28:59 +0800128{
Harald Welte2483f1b2016-06-19 18:06:02 +0200129 const struct vlr_subscr *vsub = ctx->ctx[LOG_CTX_VLR_SUBSCR];
Holger Hans Peter Freytherb61e3b22009-12-22 22:32:51 +0100130
Neels Hofmeyr89a8e722017-02-23 18:00:51 +0100131 if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0
Harald Welte2483f1b2016-06-19 18:06:02 +0200132 && vsub && vsub == tar->filter_data[LOG_FLT_VLR_SUBSCR])
Harald Weltedc5062b2010-03-26 21:28:59 +0800133 return 1;
Holger Freytherd546e312008-12-27 12:03:07 +0000134
Harald Weltedc5062b2010-03-26 21:28:59 +0800135 return 0;
136}
137
138const struct log_info log_info = {
139 .filter_fn = filter_fn,
140 .cat = default_categories,
141 .num_cat = ARRAY_SIZE(default_categories),
Holger Freytherd546e312008-12-27 12:03:07 +0000142};