[GPRS] NS: Allow filtering of log messages by NSVC / NSEI
diff --git a/openbsc/src/debug.c b/openbsc/src/debug.c
index 1ef5c73..31694f3 100644
--- a/openbsc/src/debug.c
+++ b/openbsc/src/debug.c
@@ -176,17 +176,24 @@
enum log_filter {
_FLT_ALL = LOG_FILTER_ALL, /* libosmocore */
FLT_IMSI = 1,
+ FLT_NSVC = 1,
};
static int filter_fn(const struct log_context *ctx,
struct log_target *tar)
{
struct gsm_subscriber *subscr = ctx->ctx[BSC_CTX_SUBSCR];
+ const struct gprs_nsvc *nsvc = ctx->ctx[BSC_CTX_NSVC];
if ((tar->filter_map & (1 << FLT_IMSI)) != 0
&& subscr && strcmp(subscr->imsi, tar->filter_data[FLT_IMSI]) == 0)
return 1;
+ /* Filter on the NS Virtual Connection */
+ if ((tar->filter_map & (1 << FLT_NSVC)) != 0
+ && nsvc && (nsvc == tar->filter_data[FLT_NSVC]))
+ return 1;
+
return 0;
}
@@ -207,3 +214,15 @@
target->filter_data[FLT_IMSI] = NULL;
}
}
+
+void log_set_nsvc_filter(struct log_target *target,
+ const struct gprs_nsvc *nsvc)
+{
+ if (nsvc) {
+ target->filter_map |= (1 << FLT_NSVC);
+ target->filter_data[FLT_NSVC] = nsvc;
+ } else if (target->filter_data[FLT_NSVC]) {
+ target->filter_map = ~(1 << FLT_NSVC);
+ target->filter_data[FLT_NSVC] = NULL;
+ }
+}