logging: use central filter and ctx consts from libosmocore

The LCHAN and BTS filter contexts are actually never used, so drop them until
someone adds them properly.

For now use only LOGGING_{FILTER,CTX}_VLR_SUBSCR. Some of these will change to
_BSC_SUBSCR once struct bsc_subscriber is introduced, and later on, struct
gsm_subscriber will be replaced by vlr_subscriber so that the names will match.

Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067
Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b
This commit is contained in:
Neels Hofmeyr 2017-02-17 17:05:40 +01:00
parent a66d8cfcb5
commit f13b3c968f
7 changed files with 32 additions and 55 deletions

View File

@ -41,21 +41,6 @@ enum {
Debug_LastEntry,
};
/* context */
#define BSC_CTX_LCHAN 0
#define BSC_CTX_SUBSCR 1
#define BSC_CTX_BTS 2
#define BSC_CTX_SCCP 3
/* target */
enum {
//DEBUG_FILTER_ALL = 1 << 0,
LOG_FILTER_IMSI = 1 << 1,
LOG_FILTER_NSVC = 1 << 2,
LOG_FILTER_BVC = 1 << 3,
};
/* we don't need a header dependency for this... */
struct gprs_nsvc;
struct bssgp_bvc_ctx;

View File

@ -158,9 +158,8 @@ static struct gsm_lchan *lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n",
gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr);
log_set_context(BSC_CTX_LCHAN, lchan);
if (lchan->conn)
log_set_context(BSC_CTX_SUBSCR, lchan->conn->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, lchan->conn->subscr);
return lchan;
}

View File

@ -134,7 +134,6 @@ static int bts_isdn_sign_link(struct msgb *msg)
struct e1inp_sign_link *link = msg->dst;
struct gsm_bts *bts;
log_set_context(BSC_CTX_BTS, link->trx->bts);
switch (link->type) {
case E1INP_SIGN_OML:
bts = link->trx->bts;

View File

@ -77,7 +77,7 @@ static void page_ms(struct gsm_paging_request *request)
if (!bts->oml_link)
return;
log_set_context(BSC_CTX_SUBSCR, request->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, request->subscr);
LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: %s tmsi: "
"0x%x for ch. type %d (attempt %d)\n", request->subscr->imsi,
@ -91,7 +91,7 @@ static void page_ms(struct gsm_paging_request *request)
page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc,
str_to_imsi(request->subscr->imsi));
gsm0808_page(bts, page_group, mi_len, mi, request->chan_type);
log_set_context(BSC_CTX_SUBSCR, NULL);
log_set_context(LOGGING_CTX_VLR_SUBSCR, NULL);
}
static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts)
@ -255,7 +255,7 @@ static void paging_T3113_expired(void *data)
gsm_cbfn *cbfn;
int msg;
log_set_context(BSC_CTX_SUBSCR, req->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, req->subscr);
LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n",
req, req->subscr->imsi);
@ -394,7 +394,7 @@ void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr,
{
struct gsm_bts *bts;
log_set_context(BSC_CTX_SUBSCR, subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr);
/* Stop this first and dispatch the request */
if (_bts)

View File

@ -177,32 +177,25 @@ static const struct log_info_cat default_categories[] = {
},
};
enum log_filter {
_FLT_ALL = LOG_FILTER_ALL, /* libosmocore */
FLT_IMSI = 1,
FLT_NSVC = 2,
FLT_BVC = 3,
};
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[GPRS_CTX_NSVC];
const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC];
const struct gsm_subscriber *subscr = ctx->ctx[LOGGING_CTX_VLR_SUBSCR];
const struct gprs_nsvc *nsvc = ctx->ctx[LOGGING_CTX_GB_NSVC];
const struct gprs_nsvc *bvc = ctx->ctx[LOGGING_CTX_GB_BVC];
if ((tar->filter_map & (1 << FLT_IMSI)) != 0
&& subscr && subscr == tar->filter_data[FLT_IMSI])
if ((tar->filter_map & (1 << LOGGING_FILTER_VLR_SUBSCR)) != 0
&& subscr && subscr == tar->filter_data[LOGGING_FILTER_VLR_SUBSCR])
return 1;
/* Filter on the NS Virtual Connection */
if ((tar->filter_map & (1 << FLT_NSVC)) != 0
&& nsvc && (nsvc == tar->filter_data[FLT_NSVC]))
if ((tar->filter_map & (1 << LOGGING_FILTER_GB_NSVC)) != 0
&& nsvc && (nsvc == tar->filter_data[LOGGING_FILTER_GB_NSVC]))
return 1;
/* Filter on the NS Virtual Connection */
if ((tar->filter_map & (1 << FLT_BVC)) != 0
&& bvc && (bvc == tar->filter_data[FLT_BVC]))
if ((tar->filter_map & (1 << LOGGING_FILTER_GB_BVC)) != 0
&& bvc && (bvc == tar->filter_data[LOGGING_FILTER_GB_BVC]))
return 1;
return 0;
@ -216,16 +209,17 @@ const struct log_info log_info = {
void log_set_imsi_filter(struct log_target *target, struct gsm_subscriber *subscr)
{
struct gsm_subscriber **fsub = (void*)&target->filter_data[LOGGING_FILTER_VLR_SUBSCR];
/* free the old data */
if (target->filter_data[FLT_IMSI]) {
subscr_put(target->filter_data[FLT_IMSI]);
target->filter_data[FLT_IMSI] = NULL;
if (*fsub) {
subscr_put(*fsub);
*fsub = NULL;
}
if (subscr) {
target->filter_map |= (1 << FLT_IMSI);
target->filter_data[FLT_IMSI] = subscr_get(subscr);
} else {
target->filter_map &= ~(1 << FLT_IMSI);
}
target->filter_map |= (1 << LOGGING_FILTER_VLR_SUBSCR);
*fsub = subscr_get(subscr);
} else
target->filter_map &= ~(1 << LOGGING_FILTER_VLR_SUBSCR);
}

View File

@ -1457,7 +1457,7 @@ static int gsm48_rx_rr_pag_resp(struct gsm_subscriber_connection *conn, struct m
/* FIXME: request id? close channel? */
return -EINVAL;
}
log_set_context(BSC_CTX_SUBSCR, subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr);
DEBUGP(DRR, "<- Channel was requested by %s\n",
subscr->name && strlen(subscr->name) ? subscr->name : subscr->imsi);
@ -1982,7 +1982,7 @@ static int tch_bridge(struct gsm_network *net, struct gsm_mncc_bridge *bridge)
return -EIO;
/* Which subscriber do we want to track trans1 or trans2? */
log_set_context(BSC_CTX_SUBSCR, trans1->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, trans1->subscr);
/* through-connect channel */
return tch_map(trans1->conn->lchan, trans2->conn->lchan);
@ -2003,7 +2003,7 @@ static int tch_recv_mncc(struct gsm_network *net, uint32_t callref, int enable)
if (!trans->conn)
return 0;
log_set_context(BSC_CTX_SUBSCR, trans->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr);
lchan = trans->conn->lchan;
bts = lchan->ts->trx->bts;
@ -3339,7 +3339,7 @@ static int tch_rtp_create(struct gsm_network *net, uint32_t callref)
mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE);
return -EIO;
}
log_set_context(BSC_CTX_SUBSCR, trans->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr);
if (!trans->conn) {
LOGP(DMNCC, LOGL_NOTICE, "RTP create for trans without conn\n");
mncc_recv_rtp_err(net, callref, MNCC_RTP_CREATE);
@ -3395,7 +3395,7 @@ static int tch_rtp_connect(struct gsm_network *net, void *arg)
mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT);
return -EIO;
}
log_set_context(BSC_CTX_SUBSCR, trans->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr);
if (!trans->conn) {
LOGP(DMNCC, LOGL_ERROR, "RTP connect for trans without conn\n");
mncc_recv_rtp_err(net, rtp->callref, MNCC_RTP_CONNECT);
@ -3572,7 +3572,7 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
LOGP(DMNCC, LOGL_ERROR, "TCH frame for non-existing trans\n");
return -EIO;
}
log_set_context(BSC_CTX_SUBSCR, trans->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr);
if (!trans->conn) {
LOGP(DMNCC, LOGL_NOTICE, "TCH frame for trans without conn\n");
return 0;
@ -3646,7 +3646,7 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
data->imsi);
/* update the subscriber we deal with */
log_set_context(BSC_CTX_SUBSCR, subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr);
/* If subscriber is not found */
if (!subscr) {
@ -3724,7 +3724,7 @@ int mncc_tx_to_cc(struct gsm_network *net, int msg_type, void *arg)
subscr_put(subscr);
} else {
/* update the subscriber we deal with */
log_set_context(BSC_CTX_SUBSCR, trans->subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, trans->subscr);
}
if (trans->conn)

View File

@ -67,7 +67,7 @@ static struct gsm_subscriber *subscr_by_dst(struct gsm_network *net,
}
/* tag the context in case we know it */
log_set_context(BSC_CTX_SUBSCR, subscr);
log_set_context(LOGGING_CTX_VLR_SUBSCR, subscr);
return subscr;
}