2010-03-26 13:28:59 +00:00
|
|
|
/* OpenBSC Debugging/Logging support code */
|
|
|
|
|
|
|
|
/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
|
2008-12-27 12:03:07 +00:00
|
|
|
* (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
|
2008-12-27 11:07:15 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-12-27 11:07:15 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2008-12-27 11:07:15 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-12-27 11:07:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2008-12-27 12:03:07 +00:00
|
|
|
#include <stdlib.h>
|
2008-12-27 11:07:15 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2008-12-27 12:03:07 +00:00
|
|
|
#include <strings.h>
|
2008-12-27 11:07:15 +00:00
|
|
|
#include <time.h>
|
2009-12-26 18:45:22 +00:00
|
|
|
#include <errno.h>
|
2008-12-27 11:07:15 +00:00
|
|
|
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/talloc.h>
|
|
|
|
#include <osmocom/core/utils.h>
|
|
|
|
#include <osmocom/core/logging.h>
|
2012-06-16 09:45:59 +00:00
|
|
|
#include <osmocom/gprs/gprs_msgb.h>
|
2009-12-22 21:32:51 +00:00
|
|
|
#include <openbsc/gsm_data.h>
|
|
|
|
#include <openbsc/gsm_subscriber.h>
|
2010-03-26 13:28:59 +00:00
|
|
|
#include <openbsc/debug.h>
|
2008-12-27 11:07:15 +00:00
|
|
|
|
2009-12-22 21:32:51 +00:00
|
|
|
/* default categories */
|
2010-03-26 13:28:59 +00:00
|
|
|
static const struct log_info_cat default_categories[] = {
|
|
|
|
[DRLL] = {
|
|
|
|
.name = "DRLL",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "A-bis Radio Link Layer (RLL)",
|
2010-03-26 13:28:59 +00:00
|
|
|
.color = "\033[1;31m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DCC] = {
|
|
|
|
.name = "DCC",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "Layer3 Call Control (CC)",
|
2010-03-26 13:28:59 +00:00
|
|
|
.color = "\033[1;32m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DMM] = {
|
|
|
|
.name = "DMM",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "Layer3 Mobility Management (MM)",
|
2010-03-26 13:28:59 +00:00
|
|
|
.color = "\033[1;33m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DRR] = {
|
|
|
|
.name = "DRR",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "Layer3 Radio Resource (RR)",
|
2010-03-26 13:28:59 +00:00
|
|
|
.color = "\033[1;34m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DRSL] = {
|
|
|
|
.name = "DRSL",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "A-bis Radio Siganlling Link (RSL)",
|
2010-03-26 13:28:59 +00:00
|
|
|
.color = "\033[1;35m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DNM] = {
|
|
|
|
.name = "DNM",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "A-bis Network Management / O&M (NM/OML)",
|
2010-03-26 13:28:59 +00:00
|
|
|
.color = "\033[1;36m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_INFO,
|
|
|
|
},
|
|
|
|
[DMNCC] = {
|
|
|
|
.name = "DMNCC",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "MNCC API for Call Control application",
|
2010-03-26 13:28:59 +00:00
|
|
|
.color = "\033[1;39m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DPAG] = {
|
|
|
|
.name = "DPAG",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "Paging Subsystem",
|
2010-03-26 13:28:59 +00:00
|
|
|
.color = "\033[1;38m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DMEAS] = {
|
|
|
|
.name = "DMEAS",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "Radio Measurement Processing",
|
2010-03-26 13:28:59 +00:00
|
|
|
.enabled = 0, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DSCCP] = {
|
|
|
|
.name = "DSCCP",
|
|
|
|
.description = "SCCP Protocol",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DMSC] = {
|
|
|
|
.name = "DMSC",
|
|
|
|
.description = "Mobile Switching Center",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DMGCP] = {
|
|
|
|
.name = "DMGCP",
|
|
|
|
.description = "Media Gateway Control Protocol",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DHO] = {
|
|
|
|
.name = "DHO",
|
|
|
|
.description = "Hand-Over",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DDB] = {
|
|
|
|
.name = "DDB",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "Database Layer",
|
2010-03-26 13:28:59 +00:00
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DREF] = {
|
|
|
|
.name = "DREF",
|
|
|
|
.description = "Reference Counting",
|
|
|
|
.enabled = 0, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
2010-03-28 09:44:55 +00:00
|
|
|
[DGPRS] = {
|
|
|
|
.name = "DGPRS",
|
|
|
|
.description = "GPRS Packet Service",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
2010-05-11 03:54:22 +00:00
|
|
|
[DNS] = {
|
|
|
|
.name = "DNS",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "GPRS Network Service (NS)",
|
2010-05-13 17:47:01 +00:00
|
|
|
.enabled = 1, .loglevel = LOGL_INFO,
|
2010-05-11 03:54:22 +00:00
|
|
|
},
|
|
|
|
[DBSSGP] = {
|
|
|
|
.name = "DBSSGP",
|
2010-05-11 08:51:30 +00:00
|
|
|
.description = "GPRS BSS Gateway Protocol (BSSGP)",
|
2010-05-11 03:54:22 +00:00
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
2010-05-13 17:47:01 +00:00
|
|
|
[DLLC] = {
|
|
|
|
.name = "DLLC",
|
|
|
|
.description = "GPRS Logical Link Control Protocol (LLC)",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
|
|
|
[DSNDCP] = {
|
|
|
|
.name = "DSNDCP",
|
|
|
|
.description = "GPRS Sub-Network Dependent Control Protocol (SNDCP)",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
2010-06-15 11:27:25 +00:00
|
|
|
[DNAT] = {
|
|
|
|
.name = "DNAT",
|
2013-01-10 22:46:17 +00:00
|
|
|
.description = "GSM 08.08 NAT/Multiplexer",
|
2010-06-15 11:27:25 +00:00
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
2011-07-19 10:14:34 +00:00
|
|
|
[DCTRL] = {
|
|
|
|
.name = "DCTRL",
|
|
|
|
.description = "Control interface",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
2012-11-08 15:14:37 +00:00
|
|
|
[DSMPP] = {
|
|
|
|
.name = "DSMPP",
|
|
|
|
.description = "SMPP interface for external SMS apps",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
2015-04-05 17:34:12 +00:00
|
|
|
[DFILTER] = {
|
|
|
|
.name = "DFILTER",
|
|
|
|
.description = "BSC/NAT IMSI based filtering",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
2016-05-20 19:59:45 +00:00
|
|
|
[DRANAP] = {
|
|
|
|
.name = "DRANAP",
|
|
|
|
.description = "Radio Access Network Application Part Protocol",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
2016-05-20 19:59:35 +00:00
|
|
|
[DSUA] = {
|
|
|
|
.name = "DSUA",
|
|
|
|
.description = "SCCP User Adaptation Protocol",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
2016-10-26 13:19:41 +00:00
|
|
|
[DPCU] = {
|
|
|
|
.name = "DPCU",
|
|
|
|
.description = "PCU Interface",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
2008-12-27 12:03:07 +00:00
|
|
|
};
|
|
|
|
|
2017-02-17 16:06:59 +00:00
|
|
|
static int filter_fn(const struct log_context *ctx, struct log_target *tar)
|
2009-12-22 21:32:51 +00:00
|
|
|
{
|
2017-02-23 17:00:51 +00:00
|
|
|
const struct gsm_subscriber *subscr = ctx->ctx[LOG_CTX_VLR_SUBSCR];
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
const struct bsc_subscr *bsub = ctx->ctx[LOG_CTX_BSC_SUBSCR];
|
2017-02-23 17:00:51 +00:00
|
|
|
const struct gprs_nsvc *nsvc = ctx->ctx[LOG_CTX_GB_NSVC];
|
|
|
|
const struct gprs_nsvc *bvc = ctx->ctx[LOG_CTX_GB_BVC];
|
2009-12-22 21:32:51 +00:00
|
|
|
|
2017-02-23 17:00:51 +00:00
|
|
|
if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0
|
|
|
|
&& subscr && subscr == tar->filter_data[LOG_FLT_VLR_SUBSCR])
|
2010-03-26 13:28:59 +00:00
|
|
|
return 1;
|
2009-12-22 21:32:51 +00:00
|
|
|
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
if ((tar->filter_map & (1 << LOG_FLT_BSC_SUBSCR)) != 0
|
|
|
|
&& bsub && bsub == tar->filter_data[LOG_FLT_BSC_SUBSCR])
|
|
|
|
return 1;
|
|
|
|
|
2010-05-15 21:52:02 +00:00
|
|
|
/* Filter on the NS Virtual Connection */
|
2017-02-23 17:00:51 +00:00
|
|
|
if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
|
|
|
|
&& nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
|
2010-05-15 21:52:02 +00:00
|
|
|
return 1;
|
|
|
|
|
2010-05-17 21:41:43 +00:00
|
|
|
/* Filter on the NS Virtual Connection */
|
2017-02-23 17:00:51 +00:00
|
|
|
if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
|
|
|
|
&& bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
|
2010-05-17 21:41:43 +00:00
|
|
|
return 1;
|
|
|
|
|
2010-03-26 13:28:59 +00:00
|
|
|
return 0;
|
2009-12-22 21:32:51 +00:00
|
|
|
}
|
|
|
|
|
2010-03-26 13:28:59 +00:00
|
|
|
const struct log_info log_info = {
|
|
|
|
.filter_fn = filter_fn,
|
|
|
|
.cat = default_categories,
|
|
|
|
.num_cat = ARRAY_SIZE(default_categories),
|
|
|
|
};
|
2009-12-22 21:32:51 +00:00
|
|
|
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
void log_set_filter_vlr_subscr(struct log_target *target,
|
|
|
|
struct gsm_subscriber *vlr_subscr)
|
2009-12-22 21:32:51 +00:00
|
|
|
{
|
2017-02-23 17:00:51 +00:00
|
|
|
struct gsm_subscriber **fsub = (void*)&target->filter_data[LOG_FLT_VLR_SUBSCR];
|
2017-02-17 16:05:40 +00:00
|
|
|
|
2014-12-28 17:54:32 +00:00
|
|
|
/* free the old data */
|
2017-02-17 16:05:40 +00:00
|
|
|
if (*fsub) {
|
|
|
|
subscr_put(*fsub);
|
|
|
|
*fsub = NULL;
|
2014-12-28 17:54:32 +00:00
|
|
|
}
|
|
|
|
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
if (vlr_subscr) {
|
2017-02-23 17:00:51 +00:00
|
|
|
target->filter_map |= (1 << LOG_FLT_VLR_SUBSCR);
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
*fsub = subscr_get(vlr_subscr);
|
2017-02-17 16:05:40 +00:00
|
|
|
} else
|
2017-02-23 17:00:51 +00:00
|
|
|
target->filter_map &= ~(1 << LOG_FLT_VLR_SUBSCR);
|
2009-12-22 21:32:51 +00:00
|
|
|
}
|