Added PCU debugging/logging support code based on osmocom logging system.
This commit is contained in:
parent
835f91e8f8
commit
6043718c73
15
Makefile.am
15
Makefile.am
|
@ -26,6 +26,7 @@ AM_CXXFLAGS = -Wall -ldl -pthread
|
||||||
noinst_LTLIBRARIES = libgprs.la
|
noinst_LTLIBRARIES = libgprs.la
|
||||||
|
|
||||||
libgprs_la_SOURCES = \
|
libgprs_la_SOURCES = \
|
||||||
|
gprs_debug.cpp \
|
||||||
csn1.cpp \
|
csn1.cpp \
|
||||||
gsm_rlcmac.cpp \
|
gsm_rlcmac.cpp \
|
||||||
gprs_bssgp_pcu.cpp \
|
gprs_bssgp_pcu.cpp \
|
||||||
|
@ -39,6 +40,7 @@ noinst_PROGRAMS = \
|
||||||
pcu
|
pcu
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
|
gprs_debug.h \
|
||||||
csn1.h \
|
csn1.h \
|
||||||
gsm_rlcmac.h \
|
gsm_rlcmac.h \
|
||||||
gprs_bssgp_pcu.h \
|
gprs_bssgp_pcu.h \
|
||||||
|
@ -47,13 +49,15 @@ noinst_HEADERS = \
|
||||||
gsm_timer.h \
|
gsm_timer.h \
|
||||||
bitvector.h
|
bitvector.h
|
||||||
|
|
||||||
|
OPENBSC_DIR = /home/ivan/work/openbsc/openbsc/openbsc
|
||||||
|
OPENGGSN_DIR = /home/ivan/work/openbsc/openggsn
|
||||||
|
OSMOCORE_DIR = /home/ivan/work/openbsc/libosmocore
|
||||||
|
|
||||||
RLCMACTest_SOURCES = RLCMACTest.cpp
|
RLCMACTest_SOURCES = RLCMACTest.cpp
|
||||||
RLCMACTest_LDADD = \
|
RLCMACTest_LDADD = \
|
||||||
libgprs.la \
|
libgprs.la \
|
||||||
$(COMMON_LA)
|
-losmocore \
|
||||||
|
$(COMMON_LA)
|
||||||
OPENBSC_DIR = /home/ivan/work/openbsc/openbsc/openbsc
|
|
||||||
OPENGGSN_DIR = /home/ivan/work/openbsc/openggsn
|
|
||||||
|
|
||||||
pcu_SOURCES = pcu_main.cpp
|
pcu_SOURCES = pcu_main.cpp
|
||||||
pcu_LDADD = \
|
pcu_LDADD = \
|
||||||
|
@ -76,9 +80,10 @@ pcu_LDADD = \
|
||||||
$(OPENBSC_DIR)/src/gprs/gprs_sgsn.o \
|
$(OPENBSC_DIR)/src/gprs/gprs_sgsn.o \
|
||||||
$(OPENBSC_DIR)/src/libcommon/socket.o \
|
$(OPENBSC_DIR)/src/libcommon/socket.o \
|
||||||
$(OPENBSC_DIR)/src/libcommon/debug.o \
|
$(OPENBSC_DIR)/src/libcommon/debug.o \
|
||||||
|
$(OSMOCORE_DIR)/src/bitvec.o \
|
||||||
|
$(OSMOCORE_DIR)/src/talloc.o \
|
||||||
-losmocore \
|
-losmocore \
|
||||||
-losmogsm \
|
-losmogsm \
|
||||||
$(COMMON_LA)
|
$(COMMON_LA)
|
||||||
|
|
||||||
#MOSTLYCLEANFILES += testSource testDestination
|
#MOSTLYCLEANFILES += testSource testDestination
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/* gprs_debug.cpp
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (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
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <osmocom/core/talloc.h>
|
||||||
|
#include <osmocom/core/utils.h>
|
||||||
|
#include <osmocom/core/logging.h>
|
||||||
|
#include <openbsc/gsm_data.h>
|
||||||
|
#include <openbsc/gsm_subscriber.h>
|
||||||
|
#include <gprs_debug.h>
|
||||||
|
|
||||||
|
/* default categories */
|
||||||
|
|
||||||
|
static const struct log_info_cat default_categories[] = {
|
||||||
|
{"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_NOTICE, 1},
|
||||||
|
{"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_NOTICE, 1},
|
||||||
|
{"DRLCMAC", "\033[1;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_NOTICE, 1},
|
||||||
|
{"DRLCMACDATA", "\033[1;36m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_NOTICE, 1},
|
||||||
|
{"DBSSGP", "\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_NOTICE , 1},
|
||||||
|
{"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1}
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
_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 = (struct gsm_subscriber*)ctx->ctx[BSC_CTX_SUBSCR];
|
||||||
|
const struct gprs_nsvc *nsvc = (const struct gprs_nsvc*)ctx->ctx[BSC_CTX_NSVC];
|
||||||
|
const struct gprs_nsvc *bvc = (const struct gprs_nsvc*)ctx->ctx[BSC_CTX_BVC];
|
||||||
|
|
||||||
|
if ((tar->filter_map & (1 << FLT_IMSI)) != 0
|
||||||
|
&& subscr && strcmp(subscr->imsi, (const char*)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;
|
||||||
|
|
||||||
|
/* Filter on the BVC */
|
||||||
|
if ((tar->filter_map & (1 << FLT_BVC)) != 0
|
||||||
|
&& bvc && (bvc == tar->filter_data[FLT_BVC]))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct log_info gprs_log_info = {
|
||||||
|
filter_fn,
|
||||||
|
(struct log_info_cat*)default_categories,
|
||||||
|
ARRAY_SIZE(default_categories),
|
||||||
|
};
|
|
@ -0,0 +1,68 @@
|
||||||
|
/* gprs_debug.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (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
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GPRS_DEBUG_H
|
||||||
|
#define GPRS_DEBUG_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
extern "C" {
|
||||||
|
#include <osmocom/core/linuxlist.h>
|
||||||
|
#include <osmocom/core/logging.h>
|
||||||
|
};
|
||||||
|
/* Debug Areas of the code */
|
||||||
|
enum {
|
||||||
|
DCSN1,
|
||||||
|
DL1IF,
|
||||||
|
DRLCMAC,
|
||||||
|
DRLCMACDATA,
|
||||||
|
DBSSGP,
|
||||||
|
DPCU,
|
||||||
|
aDebug_LastEntry
|
||||||
|
};
|
||||||
|
|
||||||
|
/* context */
|
||||||
|
#define BSC_CTX_SUBSCR 1
|
||||||
|
#define BSC_CTX_NSVC 4
|
||||||
|
#define BSC_CTX_BVC 5
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
void log_set_imsi_filter(struct log_target *target, const char *imsi);
|
||||||
|
void log_set_nsvc_filter(struct log_target *target,
|
||||||
|
struct gprs_nsvc *nsvc);
|
||||||
|
void log_set_bvc_filter(struct log_target *target,
|
||||||
|
struct bssgp_bvc_ctx *bctx);
|
||||||
|
|
||||||
|
extern const struct log_info gprs_log_info;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // GPRS_DEBUG_H
|
Loading…
Reference in New Issue