osmo-msc[master]: mcgp: let the MGW allocate the MGCP endpoint

2018-02-20 Thread Neels Hofmeyr

Patch Set 1:

(3 comments)

https://gerrit.osmocom.org/#/c/6319/1//COMMIT_MSG
Commit Message:

Line 18: OS#2710
in order to be easily picked up by robots, please put this on the same line. 
Also drop the blank line between this and the Change-Id.


https://gerrit.osmocom.org/#/c/6319/1/src/libmsc/msc_mgcp.c
File src/libmsc/msc_mgcp.c:

Line 237:   .call_id = 12345,
wait, what? If it's correct, explain in a code comment?


Line 240:   osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
> This change removes a check for truncation. Is this intended?
(fine difference that it's osmo_strlcpy(), but it does follow the BSD strlcpy 
signature, so I agree with stsp that truncation still deserves a 
handle_error(); and probably that case also deserves a unit test of sorts?)


-- 
To view, visit https://gerrit.osmocom.org/6319
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iee3e446b6689626516f01c521abe3d4603cd3e13
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


[PATCH] osmo-trx[master]: Depend on libosmocore and enable talloc reports

2018-02-20 Thread Pau Espin Pedrol
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6618

to look at the new patch set (#4).

Depend on libosmocore and enable talloc reports

Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
---
M Transceiver52M/Makefile.am
M Transceiver52M/osmo-trx.cpp
M configure.ac
M contrib/jenkins.sh
4 files changed, 61 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/18/6618/4

diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am
index f36f4d4..21104dc 100644
--- a/Transceiver52M/Makefile.am
+++ b/Transceiver52M/Makefile.am
@@ -22,7 +22,7 @@
 include $(top_srcdir)/Makefile.common
 
 AM_CPPFLAGS = -Wall $(STD_DEFINES_AND_INCLUDES) -I${srcdir}/common
-AM_CXXFLAGS = -lpthread
+AM_CXXFLAGS = -lpthread $(LIBOSMOCORE_CFLAGS)
 
 SUBDIRS = arm x86
 
@@ -92,7 +92,8 @@
$(ARCH_LA) \
$(GSM_LA) \
$(COMMON_LA) \
-   $(FFTWF_LIBS)
+   $(FFTWF_LIBS) \
+   $(LIBOSMOCORE_LIBS)
 
 if USRP1
 libtransceiver_la_SOURCES += USRPDevice.cpp
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 16866f4..40269e1 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -37,6 +37,9 @@
 #include 
 
 extern "C" {
+#include 
+#include 
+#include 
 #include "convolve.h"
 #include "convert.h"
 }
@@ -88,6 +91,8 @@
 };
 
 volatile bool gshutdown = false;
+
+static void *tall_trx_ctx;
 
 /* Setup configuration values
  * Don't query the existence of the Log.Level because it's a
@@ -240,20 +245,35 @@
 
 static void sig_handler(int signo)
 {
-   fprintf(stdout, "Received shutdown signal");
-   gshutdown = true;
+   fprintf(stdout, "signal %d received\n", signo);
+   switch (signo) {
+   case SIGINT:
+   case SIGTERM:
+   fprintf(stdout, "SIGINT received, shutting down\n");
+   gshutdown = true;
+   break;
+   case SIGABRT:
+   case SIGUSR1:
+   talloc_report(tall_trx_ctx, stderr);
+   talloc_report_full(tall_trx_ctx, stderr);
+   break;
+   case SIGUSR2:
+   talloc_report_full(tall_trx_ctx, stderr);
+   break;
+   default:
+   break;
+   }
 }
 
 static void setup_signal_handlers()
 {
-   if (signal(SIGINT, sig_handler) == SIG_ERR) {
-   fprintf(stderr, "Failed to install SIGINT signal handler\n");
-   exit(EXIT_FAILURE);
-   }
-   if (signal(SIGTERM, sig_handler) == SIG_ERR) {
-   fprintf(stderr, "Couldn't install SIGTERM signal handler\n");
-   exit( EXIT_FAILURE);
-   }
+   /* Handle keyboard interrupt SIGINT */
+   signal(SIGINT, _handler);
+   signal(SIGTERM, _handler);
+   signal(SIGABRT, _handler);
+   signal(SIGUSR1, _handler);
+   signal(SIGUSR2, _handler);
+   osmo_init_ignore_signals();
 }
 
 
@@ -478,6 +498,10 @@
RadioDevice::InterfaceType iface = RadioDevice::NORMAL;
struct trx_config config;
 
+   tall_trx_ctx = talloc_named_const(NULL, 0, "OsmoTRX");
+   msgb_talloc_ctx_init(tall_trx_ctx, 0);
+   setup_signal_handlers();
+
 #ifdef HAVE_SSE3
printf("Info: SSE3 support compiled in");
 #ifdef HAVE___BUILTIN_CPU_SUPPORTS
@@ -511,8 +535,6 @@
if (set_sched_rr(config.sched_rr) < 0)
return EXIT_FAILURE;
}
-
-   setup_signal_handlers();
 
/* Check database sanity */
if (!trx_setup_config()) {
diff --git a/configure.ac b/configure.ac
index 5c034e5..cba4a0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,8 @@
 AC_HEADER_TIME
 AC_C_BIGENDIAN
 
+PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.10.0)
+
 AC_ARG_WITH(usrp1, [
 AS_HELP_STRING([--with-usrp1],
 [enable USRP1 gnuradio based transceiver])
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 11def5c..5f1eed9 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -15,6 +15,11 @@
 mychroot_nocwd -w / "$@"
 }
 
+base="$PWD"
+deps="$base/deps"
+inst="$deps/install"
+export deps inst
+
 if [ -z "${INSIDE_CHROOT}" ]; then
 
 osmo-clean-workspace.sh
@@ -49,8 +54,24 @@
 fi
 fi
 
-### BUILD osmo-trx
+mkdir "$deps" || true
 
+osmo-build-dep.sh libosmocore "" --disable-doxygen
+
+verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
+
+export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
+export LD_LIBRARY_PATH="$inst/lib"
+
+set +x
+echo
+echo
+echo
+echo " === osmo-trx 
==="
+echo
+set -x
+
+cd "$base"
 autoreconf --install --force
 ./configure $INSTR
 $MAKE $PARALLEL_MAKE

-- 
To view, visit https://gerrit.osmocom.org/6618
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
Gerrit-PatchSet: 4
Gerrit-Project: osmo-trx

[PATCH] osmo-trx[master]: Logger: Use libosmocore logging system

2018-02-20 Thread Pau Espin Pedrol
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6620

to look at the new patch set (#4).

Logger: Use libosmocore logging system

We still need an intermediate class Logger due to osmo-trx being
multi-threaded and requiring to have a lock to use libosmocore, which is
not thread safe.

Change-Id: I30baac89f53e927f8699d0586b43cccf88ecd493
---
M CommonLibs/Logger.cpp
M CommonLibs/Logger.h
M CommonLibs/Makefile.am
M Transceiver52M/osmo-trx.cpp
M tests/CommonLibs/LogTest.cpp
M tests/CommonLibs/LogTest.err
M tests/CommonLibs/LogTest.ok
M tests/CommonLibs/Makefile.am
8 files changed, 64 insertions(+), 187 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/20/6620/4

diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 4c2a2d3..d6125a7 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -39,55 +39,6 @@
 
 Mutex gLogToLock;
 
-// Global log level threshold:
-int config_log_level;
-
-/** Names of the logging levels. */
-const char *levelNames[] = {
-   "EMERG", "ALERT", "CRIT", "ERR", "WARNING", "NOTICE", "INFO", "DEBUG"
-};
-int numLevels = 8;
-
-
-int levelStringToInt(const string& name)
-{
-   // Reverse search, since the numerically larger levels are more common.
-   for (int i=numLevels-1; i>=0; i--) {
-   if (name == levelNames[i]) return i;
-   }
-
-   // Common substitutions.
-   if (name=="INFORMATION") return 6;
-   if (name=="WARN") return 4;
-   if (name=="ERROR") return 3;
-   if (name=="CRITICAL") return 2;
-   if (name=="EMERGENCY") return 0;
-
-   // Unknown level.
-   return -1;
-}
-
-static std::string format(const char *fmt, ...)
-{
-   va_list ap;
-   char buf[300];
-   va_start(ap,fmt);
-   int n = vsnprintf(buf,300,fmt,ap);
-   va_end(ap);
-   if (n >= (300-4)) { strcpy([(300-4)],"..."); }
-   return std::string(buf);
-}
-
-const std::string timestr()
-{
-   struct timeval tv;
-   struct tm tm;
-   gettimeofday(,NULL);
-   localtime_r(_sec,);
-   unsigned tenths = tv.tv_usec / 10;  // Rounding down is ok.
-   return format(" 
%02d:%02d:%02d.%1d",tm.tm_hour,tm.tm_min,tm.tm_sec,tenths);
-}
-
 std::ostream& operator<<(std::ostream& os, std::ostringstream& ss)
 {
return os << ss.str();
@@ -95,34 +46,18 @@
 
 Log::~Log()
 {
-   // Anything at or above LOG_CRIT is an "alarm".
-   if (mPriority <= LOG_ERR) {
-   cerr << mStream.str() << endl;
-   }
-
int mlen = mStream.str().size();
int neednl = (mlen==0 || mStream.str()[mlen-1] != '\n');
+   const char *fmt = neednl ? "%s\n" : "%s";
ScopedLock lock(gLogToLock);
// The COUT() macro prevents messages from stomping each other but adds 
uninteresting thread numbers,
// so just use std::cout.
-   std::cout << mStream.str();
-   if (neednl) std::cout<<"\n";
+   LOGP(mCategory, mPriority, fmt, mStream.str().c_str());
 }
 
 ostringstream& Log::get()
 {
-   assert(mPriority=LOG_##wLevel)
-
-#ifdef NDEBUG
-#define LOG(wLevel) \
-   if (LOG_##wLevel!=LOG_DEBUG && IS_LOG_LEVEL(wLevel)) _LOG(wLevel)
-#else
-#define LOG(wLevel) \
-   if (IS_LOG_LEVEL(wLevel)) _LOG(wLevel)
+/* Translation for old log statements */
+#ifndef LOGL_ALERT
+#define LOGL_ALERT LOGL_FATAL
 #endif
+#ifndef LOGL_ERR
+#define LOGL_ERR 

[PATCH] osmo-trx[master]: Add initial support for logging, vty, ctrl

2018-02-20 Thread Pau Espin Pedrol
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6619

to look at the new patch set (#4).

Add initial support for logging, vty, ctrl

Up to this point, the logging system, vty and ctrl are initialized and
can be used fine, though they don't have a lot of use yet.

Depends on libosmocore Change-Id Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9

Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
---
M CommonLibs/Makefile.am
A CommonLibs/debug.c
A CommonLibs/debug.h
A CommonLibs/trx_vty.c
A CommonLibs/trx_vty.h
M Transceiver52M/Makefile.am
M Transceiver52M/osmo-trx.cpp
M configure.ac
A doc/examples/osmo-trx-limesdr.cfg
9 files changed, 290 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/19/6619/4

diff --git a/CommonLibs/Makefile.am b/CommonLibs/Makefile.am
index fa0b285..843bc38 100644
--- a/CommonLibs/Makefile.am
+++ b/CommonLibs/Makefile.am
@@ -23,6 +23,7 @@
 
 AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
 AM_CXXFLAGS = -Wall -O3 -g -lpthread
+AM_CFLAGS = $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOVTY_CFLAGS)
 
 EXTRA_DIST = \
example.config \
@@ -36,7 +37,9 @@
Sockets.cpp \
Threads.cpp \
Timeval.cpp \
-   Logger.cpp
+   Logger.cpp \
+   trx_vty.c \
+   debug.c
 
 noinst_HEADERS = \
BitVector.h \
@@ -47,4 +50,6 @@
Threads.h \
Timeval.h \
Vector.h \
-   Logger.h
+   Logger.h \
+   trx_vty.h \
+   debug.h
diff --git a/CommonLibs/debug.c b/CommonLibs/debug.c
new file mode 100644
index 000..3c5f6ba
--- /dev/null
+++ b/CommonLibs/debug.c
@@ -0,0 +1,18 @@
+#include 
+#include 
+#include "debug.h"
+
+/* default categories */
+static const struct log_info_cat default_categories[] = {
+   [DTRX] = {
+   .name = "DTRX",
+   .description = "Transciever",
+   .color = NULL,
+   .enabled = 1, .loglevel = LOGL_NOTICE,
+   },
+};
+
+const struct log_info log_info = {
+   .cat = default_categories,
+   .num_cat = ARRAY_SIZE(default_categories),
+};
diff --git a/CommonLibs/debug.h b/CommonLibs/debug.h
new file mode 100644
index 000..408efc9
--- /dev/null
+++ b/CommonLibs/debug.h
@@ -0,0 +1,8 @@
+#pragma once
+
+extern const struct log_info log_info;
+
+/* Debug Areas of the code */
+enum {
+   DTRX,
+};
diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
new file mode 100644
index 000..6193635
--- /dev/null
+++ b/CommonLibs/trx_vty.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2012-2017 sysmocom - s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * 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, see .
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "trx_vty.h"
+#include "../config.h"
+
+static struct trx_ctx* g_trx_ctx;
+
+struct trx_ctx *trx_from_vty(struct vty *v)
+{
+/* It can't hurt to force callers to continue to pass the vty instance
+ * to this function, in case we'd like to retrieve the global
+ * trx instance from the vty at some point in the future. But
+ * until then, just return the global pointer, which should have been
+ * initialized by trx_vty_init().
+ */
+OSMO_ASSERT(g_trx_ctx);
+return g_trx_ctx;
+}
+
+enum trx_vty_node {
+   TRX_NODE = _LAST_OSMOVTY_NODE + 1,
+   APN_NODE,
+};
+/* TRX Node */
+
+static struct cmd_node trx_node = {
+   TRX_NODE,
+   "%s(config-trx)# ",
+   1,
+};
+
+DEFUN(cfg_trx, cfg_trx_cmd,
+   "trx",
+   "Configure the TRX\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (!trx)
+   return CMD_WARNING;
+
+   vty->node = TRX_NODE;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_bind_ip, cfg_bind_ip_cmd,
+   "bind-ip A.B.C.D",
+   "Set the IP address for the local GTP bind\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.bind_addr = talloc_strdup(trx, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+static int config_write_trx(struct vty *vty)
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   vty_out(vty, "trx%s", VTY_NEWLINE);
+   if (trx->cfg.bind_addr)
+   vty_out(vty, " bind-ip %s%s", trx->cfg.bind_addr, 

[PATCH] osmo-trx[master]: Logger: Drop syslog support

2018-02-20 Thread Pau Espin Pedrol
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6613

to look at the new patch set (#2).

Logger: Drop syslog support

This feature is currently not being used, so let's drop it to make it
easier to integrate into libosmocore logging system in the future.

Change-Id: I8282745ef0282d41599eaf94fe460a1d29b18e2a
---
M CommonLibs/Logger.cpp
M CommonLibs/Logger.h
M INSTALLATION
M Transceiver52M/osmo-trx.cpp
M tests/CommonLibs/LogTest.cpp
5 files changed, 14 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/13/6613/2

diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 4bfb782..2cdd158 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -39,7 +39,6 @@
 
 // Switches to enable/disable logging targets
 bool gLogToConsole = true;
-bool gLogToSyslog = false;
 FILE *gLogToFile = NULL;
 Mutex gLogToLock;
 
@@ -99,15 +98,9 @@
 
 Log::~Log()
 {
-   if (mDummyInit) return;
// Anything at or above LOG_CRIT is an "alarm".
if (mPriority <= LOG_ERR) {
cerr << mStream.str() << endl;
-   }
-   // Current logging level was already checked by the macro. So just log.
-   // Log to syslog
-   if (gLogToSyslog) {
-   syslog(mPriority, "%s", mStream.str().c_str());
}
// Log to file and console
if (gLogToConsole||gLogToFile) {
@@ -128,14 +121,6 @@
}
 }
 
-
-Log::Log(const char* name, const char* level, int facility)
-{
-   mDummyInit = true;
-   gLogInit(name, level, facility);
-}
-
-
 ostringstream& Log::get()
 {
assert(mPriority

[PATCH] osmo-trx[master]: Add initial support for logging, vty, ctrl

2018-02-20 Thread Pau Espin Pedrol
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6619

to look at the new patch set (#3).

Add initial support for logging, vty, ctrl

Up to this point, the logging system, vty and ctrl are initialized and
can be used fine, though they don't have a lot of use yet.

Depends on libosmocore Change-Id Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9

Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
---
M CommonLibs/Makefile.am
A CommonLibs/debug.c
A CommonLibs/debug.h
A CommonLibs/trx_vty.c
A CommonLibs/trx_vty.h
M Transceiver52M/Makefile.am
M Transceiver52M/osmo-trx.cpp
M configure.ac
M contrib/jenkins.sh
A doc/examples/osmo-trx-limesdr.cfg
10 files changed, 295 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/19/6619/3

diff --git a/CommonLibs/Makefile.am b/CommonLibs/Makefile.am
index fa0b285..843bc38 100644
--- a/CommonLibs/Makefile.am
+++ b/CommonLibs/Makefile.am
@@ -23,6 +23,7 @@
 
 AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
 AM_CXXFLAGS = -Wall -O3 -g -lpthread
+AM_CFLAGS = $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOVTY_CFLAGS)
 
 EXTRA_DIST = \
example.config \
@@ -36,7 +37,9 @@
Sockets.cpp \
Threads.cpp \
Timeval.cpp \
-   Logger.cpp
+   Logger.cpp \
+   trx_vty.c \
+   debug.c
 
 noinst_HEADERS = \
BitVector.h \
@@ -47,4 +50,6 @@
Threads.h \
Timeval.h \
Vector.h \
-   Logger.h
+   Logger.h \
+   trx_vty.h \
+   debug.h
diff --git a/CommonLibs/debug.c b/CommonLibs/debug.c
new file mode 100644
index 000..3c5f6ba
--- /dev/null
+++ b/CommonLibs/debug.c
@@ -0,0 +1,18 @@
+#include 
+#include 
+#include "debug.h"
+
+/* default categories */
+static const struct log_info_cat default_categories[] = {
+   [DTRX] = {
+   .name = "DTRX",
+   .description = "Transciever",
+   .color = NULL,
+   .enabled = 1, .loglevel = LOGL_NOTICE,
+   },
+};
+
+const struct log_info log_info = {
+   .cat = default_categories,
+   .num_cat = ARRAY_SIZE(default_categories),
+};
diff --git a/CommonLibs/debug.h b/CommonLibs/debug.h
new file mode 100644
index 000..408efc9
--- /dev/null
+++ b/CommonLibs/debug.h
@@ -0,0 +1,8 @@
+#pragma once
+
+extern const struct log_info log_info;
+
+/* Debug Areas of the code */
+enum {
+   DTRX,
+};
diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
new file mode 100644
index 000..6193635
--- /dev/null
+++ b/CommonLibs/trx_vty.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2012-2017 sysmocom - s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * 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, see .
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "trx_vty.h"
+#include "../config.h"
+
+static struct trx_ctx* g_trx_ctx;
+
+struct trx_ctx *trx_from_vty(struct vty *v)
+{
+/* It can't hurt to force callers to continue to pass the vty instance
+ * to this function, in case we'd like to retrieve the global
+ * trx instance from the vty at some point in the future. But
+ * until then, just return the global pointer, which should have been
+ * initialized by trx_vty_init().
+ */
+OSMO_ASSERT(g_trx_ctx);
+return g_trx_ctx;
+}
+
+enum trx_vty_node {
+   TRX_NODE = _LAST_OSMOVTY_NODE + 1,
+   APN_NODE,
+};
+/* TRX Node */
+
+static struct cmd_node trx_node = {
+   TRX_NODE,
+   "%s(config-trx)# ",
+   1,
+};
+
+DEFUN(cfg_trx, cfg_trx_cmd,
+   "trx",
+   "Configure the TRX\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (!trx)
+   return CMD_WARNING;
+
+   vty->node = TRX_NODE;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_bind_ip, cfg_bind_ip_cmd,
+   "bind-ip A.B.C.D",
+   "Set the IP address for the local GTP bind\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.bind_addr = talloc_strdup(trx, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+static int config_write_trx(struct vty *vty)
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   vty_out(vty, "trx%s", VTY_NEWLINE);
+   if (trx->cfg.bind_addr)
+   vty_out(vty, " bind-ip %s%s", 

osmo-trx[master]: Add initial support for logging, vty, ctrl

2018-02-20 Thread Pau Espin Pedrol

Patch Set 2:

Depends on libosmocore Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9 (6623)

-- 
To view, visit https://gerrit.osmocom.org/6619
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[PATCH] osmo-iuh[master]: contrib: jenkins.sh: Disable doxygen in libosmocore build

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6624

contrib: jenkins.sh: Disable doxygen in libosmocore build

Change-Id: I12d995c0c993483ed940fc173904d6e686fbe0ab
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/24/6624/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index c739f7f..617aeac 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -16,7 +16,7 @@
 export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
 export LD_LIBRARY_PATH="$inst/lib"
 
-osmo-build-dep.sh libosmocore
+osmo-build-dep.sh libosmocore "" --disable-doxygen
 osmo-build-dep.sh libosmo-abis
 osmo-build-dep.sh libosmo-netif
 osmo-build-dep.sh libosmo-sccp

-- 
To view, visit https://gerrit.osmocom.org/6624
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12d995c0c993483ed940fc173904d6e686fbe0ab
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] osmo-sip-connector[master]: contrib: jenkins.sh: Disable doxygen in libosmocore build

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6625

contrib: jenkins.sh: Disable doxygen in libosmocore build

Change-Id: I7befa0cb4e72a6ad086e3c2d290546dbf22f1676
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector 
refs/changes/25/6625/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index a2f7ee9..0b11ef3 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -11,7 +11,7 @@
 
 mkdir "$deps" || true
 
-osmo-build-dep.sh libosmocore
+osmo-build-dep.sh libosmocore  "" --disable-doxygen
 
 verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
 

-- 
To view, visit https://gerrit.osmocom.org/6625
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7befa0cb4e72a6ad086e3c2d290546dbf22f1676
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] libosmocore[master]: ports.h: Add VTY and CTRL ports for osmo-trx

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6623

ports.h: Add VTY and CTRL ports for osmo-trx

Change-Id: Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9
---
M include/osmocom/ctrl/ports.h
M include/osmocom/vty/ports.h
2 files changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/23/6623/1

diff --git a/include/osmocom/ctrl/ports.h b/include/osmocom/ctrl/ports.h
index 4e93190..ba0bb92 100644
--- a/include/osmocom/ctrl/ports.h
+++ b/include/osmocom/ctrl/ports.h
@@ -18,4 +18,6 @@
 #define OSMO_CTRL_PORT_GGSN4257
 #define OSMO_CTRL_PORT_HLR 4259
 #define OSMO_CTRL_PORT_HNBGW   4262
+/* 4263 used by VTY interface */
+#define OSMO_CTRL_PORT_TRX 4264
 /* When adding/changing port numbers, keep docs and wiki in sync. See above. */
diff --git a/include/osmocom/vty/ports.h b/include/osmocom/vty/ports.h
index 4819b87..c3f84cc 100644
--- a/include/osmocom/vty/ports.h
+++ b/include/osmocom/vty/ports.h
@@ -31,4 +31,6 @@
 #define OSMO_VTY_PORT_GGSN 4260
 #define OSMO_VTY_PORT_HNBGW4261
 /* 4262 used by control interface */
+#define OSMO_VTY_PORT_TRX  4263
+/* 4264 used by control interface */
 /* When adding/changing port numbers, keep docs and wiki in sync. See above. */

-- 
To view, visit https://gerrit.osmocom.org/6623
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] libosmo-abis[master]: contrib: jenkins.sh: Disable doxygen in libosmocore build

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6622

contrib: jenkins.sh: Disable doxygen in libosmocore build

Change-Id: I52fc3931ef072075561858bb7173f58a8503e499
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/22/6622/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index ff83984..45e540e 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -19,7 +19,7 @@
 
 verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
 
-osmo-build-dep.sh libosmocore
+osmo-build-dep.sh libosmocore "" --disable-doxygen
 
 export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
 export LD_LIBRARY_PATH="$inst/lib"

-- 
To view, visit https://gerrit.osmocom.org/6622
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I52fc3931ef072075561858bb7173f58a8503e499
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] libosmo-sccp[master]: contrib: jenkins.sh: Disable doxygen in libosmocore build

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6621

contrib: jenkins.sh: Disable doxygen in libosmocore build

Change-Id: I7abc8862a63d448408ae43802da689fe436a0ff0
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/21/6621/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 0d68f7c..ecaa1fe 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -23,7 +23,7 @@
 export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
 export LD_LIBRARY_PATH="$inst/lib"
 
-osmo-build-dep.sh libosmocore
+osmo-build-dep.sh libosmocore "" --disable-doxygen
 osmo-build-dep.sh libosmo-abis
 osmo-build-dep.sh libosmo-netif
 

-- 
To view, visit https://gerrit.osmocom.org/6621
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7abc8862a63d448408ae43802da689fe436a0ff0
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] osmo-trx[master]: Depend on libosmocore and enable talloc reports

2018-02-20 Thread Pau Espin Pedrol

Depend on libosmocore and enable talloc reports

Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
---
M Transceiver52M/Makefile.am
M Transceiver52M/osmo-trx.cpp
M configure.ac
M contrib/jenkins.sh
4 files changed, 56 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/18/6618/2

diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am
index f36f4d4..21104dc 100644
--- a/Transceiver52M/Makefile.am
+++ b/Transceiver52M/Makefile.am
@@ -22,7 +22,7 @@
 include $(top_srcdir)/Makefile.common
 
 AM_CPPFLAGS = -Wall $(STD_DEFINES_AND_INCLUDES) -I${srcdir}/common
-AM_CXXFLAGS = -lpthread
+AM_CXXFLAGS = -lpthread $(LIBOSMOCORE_CFLAGS)
 
 SUBDIRS = arm x86
 
@@ -92,7 +92,8 @@
$(ARCH_LA) \
$(GSM_LA) \
$(COMMON_LA) \
-   $(FFTWF_LIBS)
+   $(FFTWF_LIBS) \
+   $(LIBOSMOCORE_LIBS)
 
 if USRP1
 libtransceiver_la_SOURCES += USRPDevice.cpp
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 16866f4..40269e1 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -37,6 +37,9 @@
 #include 
 
 extern "C" {
+#include 
+#include 
+#include 
 #include "convolve.h"
 #include "convert.h"
 }
@@ -88,6 +91,8 @@
 };
 
 volatile bool gshutdown = false;
+
+static void *tall_trx_ctx;
 
 /* Setup configuration values
  * Don't query the existence of the Log.Level because it's a
@@ -240,20 +245,35 @@
 
 static void sig_handler(int signo)
 {
-   fprintf(stdout, "Received shutdown signal");
-   gshutdown = true;
+   fprintf(stdout, "signal %d received\n", signo);
+   switch (signo) {
+   case SIGINT:
+   case SIGTERM:
+   fprintf(stdout, "SIGINT received, shutting down\n");
+   gshutdown = true;
+   break;
+   case SIGABRT:
+   case SIGUSR1:
+   talloc_report(tall_trx_ctx, stderr);
+   talloc_report_full(tall_trx_ctx, stderr);
+   break;
+   case SIGUSR2:
+   talloc_report_full(tall_trx_ctx, stderr);
+   break;
+   default:
+   break;
+   }
 }
 
 static void setup_signal_handlers()
 {
-   if (signal(SIGINT, sig_handler) == SIG_ERR) {
-   fprintf(stderr, "Failed to install SIGINT signal handler\n");
-   exit(EXIT_FAILURE);
-   }
-   if (signal(SIGTERM, sig_handler) == SIG_ERR) {
-   fprintf(stderr, "Couldn't install SIGTERM signal handler\n");
-   exit( EXIT_FAILURE);
-   }
+   /* Handle keyboard interrupt SIGINT */
+   signal(SIGINT, _handler);
+   signal(SIGTERM, _handler);
+   signal(SIGABRT, _handler);
+   signal(SIGUSR1, _handler);
+   signal(SIGUSR2, _handler);
+   osmo_init_ignore_signals();
 }
 
 
@@ -478,6 +498,10 @@
RadioDevice::InterfaceType iface = RadioDevice::NORMAL;
struct trx_config config;
 
+   tall_trx_ctx = talloc_named_const(NULL, 0, "OsmoTRX");
+   msgb_talloc_ctx_init(tall_trx_ctx, 0);
+   setup_signal_handlers();
+
 #ifdef HAVE_SSE3
printf("Info: SSE3 support compiled in");
 #ifdef HAVE___BUILTIN_CPU_SUPPORTS
@@ -511,8 +535,6 @@
if (set_sched_rr(config.sched_rr) < 0)
return EXIT_FAILURE;
}
-
-   setup_signal_handlers();
 
/* Check database sanity */
if (!trx_setup_config()) {
diff --git a/configure.ac b/configure.ac
index 5c034e5..cba4a0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,8 @@
 AC_HEADER_TIME
 AC_C_BIGENDIAN
 
+PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.10.0)
+
 AC_ARG_WITH(usrp1, [
 AS_HELP_STRING([--with-usrp1],
 [enable USRP1 gnuradio based transceiver])
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 11def5c..123ab10 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -15,6 +15,11 @@
 mychroot_nocwd -w / "$@"
 }
 
+base="$PWD"
+deps="$base/deps"
+inst="$deps/install"
+export deps inst
+
 if [ -z "${INSIDE_CHROOT}" ]; then
 
 osmo-clean-workspace.sh
@@ -49,8 +54,19 @@
 fi
 fi
 
-### BUILD osmo-trx
+mkdir "$deps" || true
 
+osmo-build-dep.sh libosmocore "" --disable-doxygen
+
+set +x
+echo
+echo
+echo
+echo " === osmo-trx 
==="
+echo
+set -x
+
+cd "$base"
 autoreconf --install --force
 ./configure $INSTR
 $MAKE $PARALLEL_MAKE

-- 
To view, visit https://gerrit.osmocom.org/6618
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-trx[master]: Logger: Use libosmocore logging system

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6620

Logger: Use libosmocore logging system

We still need an intermediate class Logger due to osmo-trx being
multi-threaded and requiring to have a lock to use libosmocore, which is
not thread safe.

Change-Id: I30baac89f53e927f8699d0586b43cccf88ecd493
---
M CommonLibs/Logger.cpp
M CommonLibs/Logger.h
M CommonLibs/Makefile.am
M Transceiver52M/osmo-trx.cpp
M tests/CommonLibs/LogTest.cpp
M tests/CommonLibs/LogTest.err
M tests/CommonLibs/LogTest.ok
M tests/CommonLibs/Makefile.am
8 files changed, 64 insertions(+), 187 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/20/6620/1

diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 868f795..d6125a7 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -39,55 +39,6 @@
 
 Mutex gLogToLock;
 
-// Global log level threshold:
-int config_log_level;
-
-/** Names of the logging levels. */
-const char *levelNames[] = {
-   "EMERG", "ALERT", "CRIT", "ERR", "WARNING", "NOTICE", "INFO", "DEBUG"
-};
-int numLevels = 8;
-
-
-int levelStringToInt(const string& name)
-{
-   // Reverse search, since the numerically larger levels are more common.
-   for (int i=numLevels-1; i>=0; i--) {
-   if (name == levelNames[i]) return i;
-   }
-
-   // Common substitutions.
-   if (name=="INFORMATION") return 6;
-   if (name=="WARN") return 4;
-   if (name=="ERROR") return 3;
-   if (name=="CRITICAL") return 2;
-   if (name=="EMERGENCY") return 0;
-
-   // Unknown level.
-   return -1;
-}
-
-static std::string format(const char *fmt, ...)
-{
-   va_list ap;
-   char buf[300];
-   va_start(ap,fmt);
-   int n = vsnprintf(buf,300,fmt,ap);
-   va_end(ap);
-   if (n >= (300-4)) { strcpy([(300-4)],"..."); }
-   return std::string(buf);
-}
-
-const std::string timestr()
-{
-   struct timeval tv;
-   struct tm tm;
-   gettimeofday(,NULL);
-   localtime_r(_sec,);
-   unsigned tenths = tv.tv_usec / 10;  // Rounding down is ok.
-   return format(" 
%02d:%02d:%02d.%1d",tm.tm_hour,tm.tm_min,tm.tm_sec,tenths);
-}
-
 std::ostream& operator<<(std::ostream& os, std::ostringstream& ss)
 {
return os << ss.str();
@@ -95,34 +46,18 @@
 
 Log::~Log()
 {
-   // Anything at or above LOG_CRIT is an "alarm".
-   if (mPriority <= LOG_ERR) {
-   cerr << mStream.str() << endl;
-   }
-
int mlen = mStream.str().size();
int neednl = (mlen==0 || mStream.str()[mlen-1] != '\n');
+   const char *fmt = neednl ? "%s\n" : "%s";
ScopedLock lock(gLogToLock);
// The COUT() macro prevents messages from stomping each other but adds 
uninteresting thread numbers,
// so just use std::cout.
-   std::cout << mStream.str();
-   if (neednl) std::cout<<"\n";
+   LOGP(mCategory, mPriority, fmt, mStream.str().c_str());
 }
 
 ostringstream& Log::get()
 {
-   assert(mPriority=LOG_##wLevel)
-
-#ifdef NDEBUG
-#define LOG(wLevel) \
-   if (LOG_##wLevel!=LOG_DEBUG && IS_LOG_LEVEL(wLevel)) _LOG(wLevel)
-#else
-#define LOG(wLevel) \
-   if (IS_LOG_LEVEL(wLevel)) _LOG(wLevel)
+/* Translation for old log statements */
+#ifndef LOGL_ALERT
+#define LOGL_ALERT LOGL_FATAL
 #endif
+#ifndef LOGL_ERR
+#define LOGL_ERR LOGL_ERROR
+#endif
+#ifndef LOGL_WARNING
+#define LOGL_WARNING LOGL_NOTICE
+#endif
+
+#define LOG(level) \
+   

osmo-trx[master]: Add initial support for logging, vty, ctrl

2018-02-20 Thread Pau Espin Pedrol

Patch Set 1: Code-Review-1

Don't merge yet starting from this commit, since VTY parameter reading is still 
not done. It will come in next commits together with dropping parameters other 
than -C (which will be reconverted to -c).

-- 
To view, visit https://gerrit.osmocom.org/6619
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[PATCH] osmo-trx[master]: Add initial support for logging, vty, ctrl

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6619

Add initial support for logging, vty, ctrl

Up to this point, the logging system, vty and ctrl are initialized and
can be used fine, though they don't have a lot of use yet.

Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
---
M CommonLibs/Makefile.am
A CommonLibs/debug.c
A CommonLibs/debug.h
A CommonLibs/trx_vty.c
A CommonLibs/trx_vty.h
M Transceiver52M/Makefile.am
M Transceiver52M/osmo-trx.cpp
M configure.ac
A doc/examples/osmo-trx-limesdr.cfg
9 files changed, 290 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/19/6619/1

diff --git a/CommonLibs/Makefile.am b/CommonLibs/Makefile.am
index fa0b285..843bc38 100644
--- a/CommonLibs/Makefile.am
+++ b/CommonLibs/Makefile.am
@@ -23,6 +23,7 @@
 
 AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES)
 AM_CXXFLAGS = -Wall -O3 -g -lpthread
+AM_CFLAGS = $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOVTY_CFLAGS)
 
 EXTRA_DIST = \
example.config \
@@ -36,7 +37,9 @@
Sockets.cpp \
Threads.cpp \
Timeval.cpp \
-   Logger.cpp
+   Logger.cpp \
+   trx_vty.c \
+   debug.c
 
 noinst_HEADERS = \
BitVector.h \
@@ -47,4 +50,6 @@
Threads.h \
Timeval.h \
Vector.h \
-   Logger.h
+   Logger.h \
+   trx_vty.h \
+   debug.h
diff --git a/CommonLibs/debug.c b/CommonLibs/debug.c
new file mode 100644
index 000..3c5f6ba
--- /dev/null
+++ b/CommonLibs/debug.c
@@ -0,0 +1,18 @@
+#include 
+#include 
+#include "debug.h"
+
+/* default categories */
+static const struct log_info_cat default_categories[] = {
+   [DTRX] = {
+   .name = "DTRX",
+   .description = "Transciever",
+   .color = NULL,
+   .enabled = 1, .loglevel = LOGL_NOTICE,
+   },
+};
+
+const struct log_info log_info = {
+   .cat = default_categories,
+   .num_cat = ARRAY_SIZE(default_categories),
+};
diff --git a/CommonLibs/debug.h b/CommonLibs/debug.h
new file mode 100644
index 000..408efc9
--- /dev/null
+++ b/CommonLibs/debug.h
@@ -0,0 +1,8 @@
+#pragma once
+
+extern const struct log_info log_info;
+
+/* Debug Areas of the code */
+enum {
+   DTRX,
+};
diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
new file mode 100644
index 000..6193635
--- /dev/null
+++ b/CommonLibs/trx_vty.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2012-2017 sysmocom - s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * 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, see .
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "trx_vty.h"
+#include "../config.h"
+
+static struct trx_ctx* g_trx_ctx;
+
+struct trx_ctx *trx_from_vty(struct vty *v)
+{
+/* It can't hurt to force callers to continue to pass the vty instance
+ * to this function, in case we'd like to retrieve the global
+ * trx instance from the vty at some point in the future. But
+ * until then, just return the global pointer, which should have been
+ * initialized by trx_vty_init().
+ */
+OSMO_ASSERT(g_trx_ctx);
+return g_trx_ctx;
+}
+
+enum trx_vty_node {
+   TRX_NODE = _LAST_OSMOVTY_NODE + 1,
+   APN_NODE,
+};
+/* TRX Node */
+
+static struct cmd_node trx_node = {
+   TRX_NODE,
+   "%s(config-trx)# ",
+   1,
+};
+
+DEFUN(cfg_trx, cfg_trx_cmd,
+   "trx",
+   "Configure the TRX\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (!trx)
+   return CMD_WARNING;
+
+   vty->node = TRX_NODE;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_bind_ip, cfg_bind_ip_cmd,
+   "bind-ip A.B.C.D",
+   "Set the IP address for the local GTP bind\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.bind_addr = talloc_strdup(trx, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+static int config_write_trx(struct vty *vty)
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   vty_out(vty, "trx%s", VTY_NEWLINE);
+   if (trx->cfg.bind_addr)
+   vty_out(vty, " bind-ip %s%s", trx->cfg.bind_addr, VTY_NEWLINE);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(show_trx, show_trx_cmd,
+   "show trx",
+   SHOW_STR "Display information on the TRX\n")
+{
+   struct trx_ctx *trx = 

[PATCH] osmo-trx[master]: Logger: Remove unused includes

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6615

Logger: Remove unused includes

Change-Id: I4d26c0b4f36ee3c66ed1a9e2e9fa2fa8272da16d
---
M CommonLibs/Logger.h
1 file changed, 0 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/15/6615/1

diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h
index 648b160..453e19d 100644
--- a/CommonLibs/Logger.h
+++ b/CommonLibs/Logger.h
@@ -35,8 +35,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 extern int config_log_level;
@@ -63,8 +61,6 @@
 #define LOG(wLevel) \
if (IS_LOG_LEVEL(wLevel)) _LOG(wLevel)
 #endif
-
-#include "Threads.h"   // must be after defines above, if these files 
are to be allowed to use LOG()
 
 /**
A C++ stream-based thread-safe logger.

-- 
To view, visit https://gerrit.osmocom.org/6615
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4d26c0b4f36ee3c66ed1a9e2e9fa2fa8272da16d
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-trx[master]: Logger: Remove gLogToConsole flag

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6616

Logger: Remove gLogToConsole flag

No code is using it and we always lock to console anyways.

Change-Id: I5fde99c6af5a845e635b5d27abab855682071f14
---
M CommonLibs/Logger.cpp
M CommonLibs/Logger.h
2 files changed, 8 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/16/6616/1

diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 463b6e0..868f795 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -37,8 +37,6 @@
 
 using namespace std;
 
-// Switches to enable/disable logging targets
-bool gLogToConsole = true;
 Mutex gLogToLock;
 
 // Global log level threshold:
@@ -101,18 +99,14 @@
if (mPriority <= LOG_ERR) {
cerr << mStream.str() << endl;
}
-   // Log to file and console
-   if (gLogToConsole) {
-   int mlen = mStream.str().size();
-   int neednl = (mlen==0 || mStream.str()[mlen-1] != '\n');
-   ScopedLock lock(gLogToLock);
-   if (gLogToConsole) {
-   // The COUT() macro prevents messages from stomping 
each other but adds uninteresting thread numbers,
-   // so just use std::cout.
-   std::cout << mStream.str();
-   if (neednl) std::cout<<"\n";
-   }
-   }
+
+   int mlen = mStream.str().size();
+   int neednl = (mlen==0 || mStream.str()[mlen-1] != '\n');
+   ScopedLock lock(gLogToLock);
+   // The COUT() macro prevents messages from stomping each other but adds 
uninteresting thread numbers,
+   // so just use std::cout.
+   std::cout << mStream.str();
+   if (neednl) std::cout<<"\n";
 }
 
 ostringstream& Log::get()
diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h
index 453e19d..4e5c6af 100644
--- a/CommonLibs/Logger.h
+++ b/CommonLibs/Logger.h
@@ -88,7 +88,6 @@
 
std::ostringstream& get();
 };
-extern bool gLogToConsole; // Output log messages to stdout
 
 const std::string timestr();   // A timestamp to print in messages.
 std::ostream& operator<<(std::ostream& os, std::ostringstream& ss);

-- 
To view, visit https://gerrit.osmocom.org/6616
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5fde99c6af5a845e635b5d27abab855682071f14
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-trx[master]: configure.ac: Check for pkg-config

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6617

configure.ac: Check for pkg-config

Change-Id: I1a851181a99f2f35ea4ff1b38c7afe27a04e5f18
---
M configure.ac
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/17/6617/1

diff --git a/configure.ac b/configure.ac
index 7d26ced..5c034e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,13 @@
 AC_PROG_INSTALL
 AC_PATH_PROG([RM_PROG], [rm])
 
+dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
+AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
+if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
+AC_MSG_WARN([You need to install pkg-config])
+fi
+PKG_PROG_PKG_CONFIG([0.20])
+
 AC_LIBTOOL_WIN32_DLL
 AC_ENABLE_SHARED   dnl do build shared libraries
 AC_DISABLE_STATIC  dnl don't build static libraries

-- 
To view, visit https://gerrit.osmocom.org/6617
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a851181a99f2f35ea4ff1b38c7afe27a04e5f18
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-trx[master]: Depend on libosmocore and enable talloc reports

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6618

Depend on libosmocore and enable talloc reports

Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
---
M Transceiver52M/Makefile.am
M Transceiver52M/osmo-trx.cpp
M configure.ac
3 files changed, 39 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/18/6618/1

diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am
index f36f4d4..21104dc 100644
--- a/Transceiver52M/Makefile.am
+++ b/Transceiver52M/Makefile.am
@@ -22,7 +22,7 @@
 include $(top_srcdir)/Makefile.common
 
 AM_CPPFLAGS = -Wall $(STD_DEFINES_AND_INCLUDES) -I${srcdir}/common
-AM_CXXFLAGS = -lpthread
+AM_CXXFLAGS = -lpthread $(LIBOSMOCORE_CFLAGS)
 
 SUBDIRS = arm x86
 
@@ -92,7 +92,8 @@
$(ARCH_LA) \
$(GSM_LA) \
$(COMMON_LA) \
-   $(FFTWF_LIBS)
+   $(FFTWF_LIBS) \
+   $(LIBOSMOCORE_LIBS)
 
 if USRP1
 libtransceiver_la_SOURCES += USRPDevice.cpp
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 16866f4..40269e1 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -37,6 +37,9 @@
 #include 
 
 extern "C" {
+#include 
+#include 
+#include 
 #include "convolve.h"
 #include "convert.h"
 }
@@ -88,6 +91,8 @@
 };
 
 volatile bool gshutdown = false;
+
+static void *tall_trx_ctx;
 
 /* Setup configuration values
  * Don't query the existence of the Log.Level because it's a
@@ -240,20 +245,35 @@
 
 static void sig_handler(int signo)
 {
-   fprintf(stdout, "Received shutdown signal");
-   gshutdown = true;
+   fprintf(stdout, "signal %d received\n", signo);
+   switch (signo) {
+   case SIGINT:
+   case SIGTERM:
+   fprintf(stdout, "SIGINT received, shutting down\n");
+   gshutdown = true;
+   break;
+   case SIGABRT:
+   case SIGUSR1:
+   talloc_report(tall_trx_ctx, stderr);
+   talloc_report_full(tall_trx_ctx, stderr);
+   break;
+   case SIGUSR2:
+   talloc_report_full(tall_trx_ctx, stderr);
+   break;
+   default:
+   break;
+   }
 }
 
 static void setup_signal_handlers()
 {
-   if (signal(SIGINT, sig_handler) == SIG_ERR) {
-   fprintf(stderr, "Failed to install SIGINT signal handler\n");
-   exit(EXIT_FAILURE);
-   }
-   if (signal(SIGTERM, sig_handler) == SIG_ERR) {
-   fprintf(stderr, "Couldn't install SIGTERM signal handler\n");
-   exit( EXIT_FAILURE);
-   }
+   /* Handle keyboard interrupt SIGINT */
+   signal(SIGINT, _handler);
+   signal(SIGTERM, _handler);
+   signal(SIGABRT, _handler);
+   signal(SIGUSR1, _handler);
+   signal(SIGUSR2, _handler);
+   osmo_init_ignore_signals();
 }
 
 
@@ -478,6 +498,10 @@
RadioDevice::InterfaceType iface = RadioDevice::NORMAL;
struct trx_config config;
 
+   tall_trx_ctx = talloc_named_const(NULL, 0, "OsmoTRX");
+   msgb_talloc_ctx_init(tall_trx_ctx, 0);
+   setup_signal_handlers();
+
 #ifdef HAVE_SSE3
printf("Info: SSE3 support compiled in");
 #ifdef HAVE___BUILTIN_CPU_SUPPORTS
@@ -511,8 +535,6 @@
if (set_sched_rr(config.sched_rr) < 0)
return EXIT_FAILURE;
}
-
-   setup_signal_handlers();
 
/* Check database sanity */
if (!trx_setup_config()) {
diff --git a/configure.ac b/configure.ac
index 5c034e5..cba4a0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,8 @@
 AC_HEADER_TIME
 AC_C_BIGENDIAN
 
+PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.10.0)
+
 AC_ARG_WITH(usrp1, [
 AS_HELP_STRING([--with-usrp1],
 [enable USRP1 gnuradio based transceiver])

-- 
To view, visit https://gerrit.osmocom.org/6618
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-trx[master]: Logger: Drop support to log into file

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6614

Logger: Drop support to log into file

This feature is currently not being used, so let's simplify current code
to move to libosmocore logging system in the future.

Change-Id: If2c77c776823f595130edac963be953026049423
---
M CommonLibs/Logger.cpp
1 file changed, 1 insertion(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/14/6614/1

diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index d10ad02..463b6e0 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -39,7 +39,6 @@
 
 // Switches to enable/disable logging targets
 bool gLogToConsole = true;
-FILE *gLogToFile = NULL;
 Mutex gLogToLock;
 
 // Global log level threshold:
@@ -103,7 +102,7 @@
cerr << mStream.str() << endl;
}
// Log to file and console
-   if (gLogToConsole||gLogToFile) {
+   if (gLogToConsole) {
int mlen = mStream.str().size();
int neednl = (mlen==0 || mStream.str()[mlen-1] != '\n');
ScopedLock lock(gLogToLock);
@@ -112,11 +111,6 @@
// so just use std::cout.
std::cout << mStream.str();
if (neednl) std::cout<<"\n";
-   }
-   if (gLogToFile) {
-   fputs(mStream.str().c_str(),gLogToFile);
-   if (neednl) {fputc('\n',gLogToFile);}
-   fflush(gLogToFile);
}
}
 }
@@ -135,18 +129,6 @@
// Set the level if one has been specified.
if (level)
config_log_level = levelStringToInt(level);
-
-   // Both the transceiver and OpenBTS use this same facility, but only 
OpenBTS/OpenNodeB may use this log file:
-   if (!gLogToFile && fn) {
-   gLogToFile = fopen(fn,"w"); // New log file each time we start.
-   if (gLogToFile) {
-   time_t now;
-   time();
-   fprintf(gLogToFile,"Starting at %s",ctime());
-   fflush(gLogToFile);
-   std::cout << "Logging to file: " << fn << "\n";
-   }
-   }
 }
 
 // vim: ts=4 sw=4

-- 
To view, visit https://gerrit.osmocom.org/6614
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2c77c776823f595130edac963be953026049423
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-trx[master]: Logger: get rid of alarm APIs

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6612

Logger: get rid of alarm APIs

It's only used internally inside the Logger module, and in case there's
an "alarm" (level more than critical) we still print on cerr, so we can
just rely on our system catching stderr instead of stdout to handle it.

Change-Id: I6d6df1578c3a4c1a37bd0d69952d443f62eed2ab
---
M CommonLibs/Logger.cpp
M CommonLibs/Logger.h
M tests/CommonLibs/LogTest.cpp
M tests/CommonLibs/LogTest.ok
4 files changed, 0 insertions(+), 97 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/12/6612/1

diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index ee607fd..4bfb782 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -35,8 +35,6 @@
 #include "Logger.h"
 #include "Threads.h"   // pat added
 
-#define MAX_ALARMS 20
-
 using namespace std;
 
 // Switches to enable/disable logging targets
@@ -47,26 +45,6 @@
 
 // Global log level threshold:
 int config_log_level;
-
-/**@ The global alarms table. */
-//@{
-Mutex   alarmsLock;
-listalarmsList;
-voidaddAlarm(const string&);
-//@}
-
-
-
-// (pat) If Log messages are printed before the classes in this module are 
inited
-// (which happens when static classes have constructors that do work)
-// the OpenBTS just crashes.
-// Prevent that by setting sLoggerInited to true when this module is inited.
-static bool sLoggerInited = 0;
-static struct CheckLoggerInitStatus {
-   CheckLoggerInitStatus() { sLoggerInited = 1; }
-} sCheckloggerInitStatus;
-
-
 
 /** Names of the logging levels. */
 const char *levelNames[] = {
@@ -119,36 +97,11 @@
return os << ss.str();
 }
 
-// copies the alarm list and returns it. list supposed to be small.
-list gGetLoggerAlarms()
-{
-alarmsLock.lock();
-list ret;
-// excuse the "complexity", but to use std::copy with a list you need
-// an insert_iterator - copy technically overwrites, doesn't insert.
-insert_iterator< list > ii(ret, ret.begin());
-copy(alarmsList.begin(), alarmsList.end(), ii);
-alarmsLock.unlock();
-return ret;
-}
-
-/** Add an alarm to the alarm list. */
-void addAlarm(const string& s)
-{
-alarmsLock.lock();
-alarmsList.push_back(s);
-while (alarmsList.size() > MAX_ALARMS) alarmsList.pop_front();
-alarmsLock.unlock();
-}
-
-
 Log::~Log()
 {
if (mDummyInit) return;
// Anything at or above LOG_CRIT is an "alarm".
-   // Save alarms in the local list and echo them to stderr.
if (mPriority <= LOG_ERR) {
-   if (sLoggerInited) addAlarm(mStream.str().c_str());
cerr << mStream.str() << endl;
}
// Current logging level was already checked by the macro. So just log.
diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h
index ef11932..7b208fa 100644
--- a/CommonLibs/Logger.h
+++ b/CommonLibs/Logger.h
@@ -103,10 +103,6 @@
 extern bool gLogToConsole; // Output log messages to stdout
 extern bool gLogToSyslog;  // Output log messages to syslog
 
-
-
-std::list gGetLoggerAlarms(); ///< Get a copy of the 
recent alarm list.
-
 const std::string timestr();   // A timestamp to print in messages.
 std::ostream& operator<<(std::ostream& os, std::ostringstream& ss);
 
diff --git a/tests/CommonLibs/LogTest.cpp b/tests/CommonLibs/LogTest.cpp
index f64041d..5d1dd2c 100644
--- a/tests/CommonLibs/LogTest.cpp
+++ b/tests/CommonLibs/LogTest.cpp
@@ -29,14 +29,6 @@
 
 #include "Logger.h"
 
-void printAlarms()
-{
-std::ostream_iterator output( std::cout, "\n" );
-std::list alarms = gGetLoggerAlarms();
-std::cout << "# alarms = " << alarms.size() << std::endl;
-std::copy( alarms.begin(), alarms.end(), output );
-}
-
 int main(int argc, char *argv[])
 {
gLogInit("LogTest","NOTICE",LOG_LOCAL7);
@@ -49,14 +41,8 @@
Log(LOG_NOTICE).get() << " testing the logger.";
Log(LOG_INFO).get() << " testing the logger.";
 Log(LOG_DEBUG).get() << " testing the logger.";
-std::cout << "\n\n\n";
-std::cout << "testing Alarms\n";
-std::cout << "you should see three lines:" << std::endl;
-printAlarms();
 std::cout << "--- generating 20 alarms --" << std::endl;
 for (int i = 0 ; i < 20 ; ++i) {
 Log(LOG_ALERT).get() << i;
 }
-std::cout << "you should see ten lines with the numbers 10..19:" << 
std::endl;
-printAlarms();
 }
diff --git a/tests/CommonLibs/LogTest.ok b/tests/CommonLibs/LogTest.ok
index e1211b0..ac60314 100644
--- a/tests/CommonLibs/LogTest.ok
+++ b/tests/CommonLibs/LogTest.ok
@@ -6,39 +6,7 @@
 NOTICE  testing the logger.
 INFO  testing the logger.
 DEBUG  testing the logger.
-
-
-
-testing Alarms
-you should see three lines:
-# alarms = 4
-EMERG  testing the logger.
-ALERT  testing the logger.
-CRIT  testing the logger.
-ERR  testing the logger.
 --- generating 20 alarms --
-ALERT 0
-ALERT 1
-ALERT 2
-ALERT 3
-ALERT 4
-ALERT 5
-ALERT 6
-ALERT 7
-ALERT 

[PATCH] osmo-trx[master]: Logger: Drop syslog support

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6613

Logger: Drop syslog support

This feature is currently not being used, so let's drop it to make it
easier to integrate into libosmocore logging system in the future.

Change-Id: I8282745ef0282d41599eaf94fe460a1d29b18e2a
---
M CommonLibs/Logger.cpp
M CommonLibs/Logger.h
M INSTALLATION
M Transceiver52M/osmo-trx.cpp
M tests/CommonLibs/LogTest.cpp
5 files changed, 14 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/13/6613/1

diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 4bfb782..d10ad02 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -39,7 +39,6 @@
 
 // Switches to enable/disable logging targets
 bool gLogToConsole = true;
-bool gLogToSyslog = false;
 FILE *gLogToFile = NULL;
 Mutex gLogToLock;
 
@@ -99,15 +98,9 @@
 
 Log::~Log()
 {
-   if (mDummyInit) return;
// Anything at or above LOG_CRIT is an "alarm".
if (mPriority <= LOG_ERR) {
cerr << mStream.str() << endl;
-   }
-   // Current logging level was already checked by the macro. So just log.
-   // Log to syslog
-   if (gLogToSyslog) {
-   syslog(mPriority, "%s", mStream.str().c_str());
}
// Log to file and console
if (gLogToConsole||gLogToFile) {
@@ -128,14 +121,6 @@
}
 }
 
-
-Log::Log(const char* name, const char* level, int facility)
-{
-   mDummyInit = true;
-   gLogInit(name, level, facility);
-}
-
-
 ostringstream& Log::get()
 {
assert(mPriority

[PATCH] osmo-trx[master]: Logger: Remove unused logging macros

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6611

Logger: Remove unused logging macros

Change-Id: I1133e181183bec8dabe2fa77d0385f783458503f
---
M CommonLibs/Logger.h
1 file changed, 0 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/11/6611/1

diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h
index 9743b88..ef11932 100644
--- a/CommonLibs/Logger.h
+++ b/CommonLibs/Logger.h
@@ -66,23 +66,6 @@
 // LOG_INFO6  informational message
 // LOG_DEBUG   7  debug-level message
 
-// (pat) added - print out a var and its name.
-// Use like this: int descriptive_name; LOG(INFO)<


[PATCH] osmo-trx[master]: Logger: Drop unused gLogEarly

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6610

Logger: Drop unused gLogEarly

Change-Id: I2c8f24fbf453e0a94d7a95c3df7cc75f0e4bd456
---
M CommonLibs/Logger.cpp
M CommonLibs/Logger.h
2 files changed, 0 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/10/6610/1

diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp
index 5b8da99..ee607fd 100644
--- a/CommonLibs/Logger.cpp
+++ b/CommonLibs/Logger.cpp
@@ -214,37 +214,4 @@
openlog(name,0,facility);
 }
 
-
-void gLogEarly(int level, const char *fmt, ...)
-{
-   va_list args;
-
-   va_start(args, fmt);
-
-   if (gLogToSyslog) {
-   va_list args_copy;
-   va_copy(args_copy, args);
-   vsyslog(level | LOG_USER, fmt, args_copy);
-   va_end(args_copy);
-   }
-
-   if (gLogToConsole) {
-   va_list args_copy;
-   va_copy(args_copy, args);
-   vprintf(fmt, args_copy);
-   printf("\n");
-   va_end(args_copy);
-   }
-
-   if (gLogToFile) {
-   va_list args_copy;
-   va_copy(args_copy, args);
-   vfprintf(gLogToFile, fmt, args_copy);
-   fprintf(gLogToFile, "\n");
-   va_end(args_copy);
-   }
-
-   va_end(args);
-}
-
 // vim: ts=4 sw=4
diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h
index 099d300..9743b88 100644
--- a/CommonLibs/Logger.h
+++ b/CommonLibs/Logger.h
@@ -131,8 +131,6 @@
 //@{
 /** Initialize the global logging system. */
 void gLogInit(const char* name, const char* level=NULL, int facility=LOG_USER, 
char* fn=NULL);
-/** Allow early logging when still in constructors */
-void gLogEarly(int level, const char *fmt, ...) __attribute__((format(printf, 
2, 3)));
 //@}
 
 

-- 
To view, visit https://gerrit.osmocom.org/6610
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c8f24fbf453e0a94d7a95c3df7cc75f0e4bd456
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[MERGED] osmo-mgw[master]: legacy: mgcp_protocol: Don't print osmux stats if it is off

2018-02-20 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged.

Change subject: legacy: mgcp_protocol: Don't print osmux stats if it is off
..


legacy: mgcp_protocol: Don't print osmux stats if it is off

Otherwise we get Osmux stats during a session using RTP, which is
confusing.

Forward-ported from openbsc e39e18992a3b966581f06fa632d6342643996aaa.

Change-Id: I9031350242dd37ce255631c20eed33976887faa6
---
M src/libosmo-legacy-mgcp/mgcp_protocol.c
M tests/legacy_mgcp/mgcp_test.c
2 files changed, 21 insertions(+), 17 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/libosmo-legacy-mgcp/mgcp_protocol.c 
b/src/libosmo-legacy-mgcp/mgcp_protocol.c
index d2df5f7..4e82233 100644
--- a/src/libosmo-legacy-mgcp/mgcp_protocol.c
+++ b/src/libosmo-legacy-mgcp/mgcp_protocol.c
@@ -1588,24 +1588,26 @@
msg += nchars;
size -= nchars;
 
-   /* Error Counter */
-   nchars = snprintf(msg, size,
- "\r\nX-Osmo-CP: EC TIS=%u, TOS=%u, TIR=%u, TOR=%u",
- endp->net_state.in_stream.err_ts_counter,
- endp->net_state.out_stream.err_ts_counter,
- endp->bts_state.in_stream.err_ts_counter,
- endp->bts_state.out_stream.err_ts_counter);
-   if (nchars < 0 || nchars >= size)
-   goto truncate;
+   if (endp->cfg->osmux != OSMUX_USAGE_OFF) {
+   /* Error Counter */
+   nchars = snprintf(msg, size,
+ "\r\nX-Osmo-CP: EC TIS=%u, TOS=%u, TIR=%u, 
TOR=%u",
+ endp->net_state.in_stream.err_ts_counter,
+ endp->net_state.out_stream.err_ts_counter,
+ endp->bts_state.in_stream.err_ts_counter,
+ endp->bts_state.out_stream.err_ts_counter);
+   if (nchars < 0 || nchars >= size)
+   goto truncate;
 
-   msg += nchars;
-   size -= nchars;
+   msg += nchars;
+   size -= nchars;
 
-   if (endp->osmux.state == OSMUX_STATE_ENABLED) {
-   snprintf(msg, size,
-"\r\nX-Osmux-ST: CR=%u, BR=%u",
-endp->osmux.stats.chunks,
-endp->osmux.stats.octets);
+   if (endp->osmux.state == OSMUX_STATE_ENABLED) {
+   snprintf(msg, size,
+"\r\nX-Osmux-ST: CR=%u, BR=%u",
+endp->osmux.stats.chunks,
+endp->osmux.stats.octets);
+   }
}
 truncate:
msg[size - 1] = '\0';
diff --git a/tests/legacy_mgcp/mgcp_test.c b/tests/legacy_mgcp/mgcp_test.c
index a540b5f..1a4513e 100644
--- a/tests/legacy_mgcp/mgcp_test.c
+++ b/tests/legacy_mgcp/mgcp_test.c
@@ -268,7 +268,9 @@
 "C: 2\r\n"
 
 #define DLCX_RET "250 7 OK\r\n"\
-"P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n" \
+"P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n"
+
+ #define DLCX_RET_OSMUX DLCX_RET \
 "X-Osmo-CP: EC TIS=0, TOS=0, TIR=0, TOR=0\r\n"
 
 #define RQNT"RQNT 186908780 1@mgw MGCP 1.0\r\n"\

-- 
To view, visit https://gerrit.osmocom.org/6604
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9031350242dd37ce255631c20eed33976887faa6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 


[MERGED] osmo-mgw[master]: mgcp_stat: Don't print osmux stats if it is off

2018-02-20 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged.

Change subject: mgcp_stat: Don't print osmux stats if it is off
..


mgcp_stat: Don't print osmux stats if it is off

Otherwise we get Osmux stats during a session using RTP, which is
confusing.

Change-Id: I6fcd680a073fbf8769488ffa2b2b32098c87edf4
---
M src/libosmo-mgcp/mgcp_stat.c
M tests/mgcp/mgcp_test.c
M tests/mgcp/mgcp_test.ok
3 files changed, 19 insertions(+), 15 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/libosmo-mgcp/mgcp_stat.c b/src/libosmo-mgcp/mgcp_stat.c
index 88a2d69..581130c 100644
--- a/src/libosmo-mgcp/mgcp_stat.c
+++ b/src/libosmo-mgcp/mgcp_stat.c
@@ -23,6 +23,7 @@
  */
 
 #include 
+#include 
 #include 
 
 /* Helper function for mgcp_format_stats_rtp() to calculate packet loss */
@@ -83,21 +84,23 @@
str += nchars;
str_len -= nchars;
 
-   /* Error Counter */
-   nchars = snprintf(str, str_len,
- "\r\nX-Osmo-CP: EC TI=%u, TO=%u",
- conn->state.in_stream.err_ts_counter,
- conn->state.out_stream.err_ts_counter);
-   if (nchars < 0 || nchars >= str_len)
-   goto truncate;
+   if (conn->conn->endp->cfg->osmux != OSMUX_USAGE_OFF) {
+   /* Error Counter */
+   nchars = snprintf(str, str_len,
+ "\r\nX-Osmo-CP: EC TI=%u, TO=%u",
+ conn->state.in_stream.err_ts_counter,
+ conn->state.out_stream.err_ts_counter);
+   if (nchars < 0 || nchars >= str_len)
+   goto truncate;
 
-   str += nchars;
-   str_len -= nchars;
+   str += nchars;
+   str_len -= nchars;
 
-   if (conn->osmux.state == OSMUX_STATE_ENABLED) {
-   snprintf(str, str_len,
-"\r\nX-Osmux-ST: CR=%u, BR=%u",
-conn->osmux.stats.chunks, conn->osmux.stats.octets);
+   if (conn->osmux.state == OSMUX_STATE_ENABLED) {
+   snprintf(str, str_len,
+"\r\nX-Osmux-ST: CR=%u, BR=%u",
+conn->osmux.stats.chunks, 
conn->osmux.stats.octets);
+   }
}
 
 truncate:
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 38a0a46..e1e6290 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -314,7 +314,9 @@
 
 #define DLCX_RET \
"250 7 OK\r\n" \
-   "P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n" \
+   "P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n"
+
+ #define DLCX_RET_OSMUX DLCX_RET \
"X-Osmo-CP: EC TI=0, TO=0\r\n"
 
 #define RQNT \
diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok
index 09ad9e1..d2879ad 100644
--- a/tests/mgcp/mgcp_test.ok
+++ b/tests/mgcp/mgcp_test.ok
@@ -569,7 +569,6 @@
 -8<-
 250 7 OK
 P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0
-X-Osmo-CP: EC TI=0, TO=0
 
 -8<-
 Parsing result: 0

-- 
To view, visit https://gerrit.osmocom.org/6605
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6fcd680a073fbf8769488ffa2b2b32098c87edf4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 


[MERGED] osmo-bsc[master]: drop unused libbsc/meas_proc.c

2018-02-20 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: drop unused libbsc/meas_proc.c
..


drop unused libbsc/meas_proc.c

The file meas_proc.c seems to be an earlier stage of development of the meas
rep handling now in handover_decision.c, and to have been inadvertently added
to the git tree in:

  commit 9af6ddfcec25f43c5b50a6c5a6b80e341ab9a8a7
  Date:   Sat Jan 1 15:25:50 2011 +0100
  License change: We are now AGPLv3+ instead of GPLv2+

The file has never been part of Makefile.am.

Change-Id: If30724e3c638b191d20d00b897731762fb4896d5
---
D src/libbsc/meas_proc.c
1 file changed, 0 insertions(+), 84 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/libbsc/meas_proc.c b/src/libbsc/meas_proc.c
deleted file mode 100644
index efc3fd0..000
--- a/src/libbsc/meas_proc.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Measurement Processing */
-
-/* (C) 2009 by Harald Welte 
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * 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
- * (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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see .
- *
- */
-
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/* process an already parsed measurement report */
-static int process_meas_rep(struct gsm_meas_rep *mr)
-{
-   struct gsm_meas_rep_cell *mr_cell = NULL;
-   unsigned int best_better_db;
-   int i;
-
-   /* FIXME: implement actual averaging over multiple measurement
-* reports */
-
-   /* find the best cell in this report that is at least RXLEV_HYST
-* better than the current serving cell */
-   for (i = 0; i < mr->num_cell; i++) {
-   unsigned int better;
-   if (mr->cell[i].rxlev < mr->dl.full.rx_lev + RXLEV_HYST)
-   continue;
-
-   better = mr->cell[i].rxlev - mr->dl.full.rx_lev;
-   if (better > best_better_db) {
-   mr_cell = >cell[i];
-   best_better_db = better;
-   }
-   }
-
-   if (mr_cell)
-   return handover_to_arfcn_bsic(mr->lchan, mr_cell->arfcn,
-   mr_cell->bsic);
-   return 0;
-}
-
-static int meas_proc_sig_cb(unsigned int subsys, unsigned int signal,
-  void *handler_data, void *signal_data)
-{
-   struct gsm_lchan *lchan;
-   struct gsm_meas_rep *mr;
-
-   if (subsys != SS_LCHAN)
-   return 0;
-
-   switch (signal) {
-   case S_LCHAN_MEAS_REP:
-   mr = signal_data;
-   process_meas_rep(mr);
-   break;
-   }
-
-   return 0;
-}
-
-static __attribute__((constructor)) void on_dso_load_meas(void)
-{
-   osmo_signal_register_handler(SS_LCHAN, meas_proc_sig_cb, NULL);
-}

-- 
To view, visit https://gerrit.osmocom.org/6603
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If30724e3c638b191d20d00b897731762fb4896d5
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-bsc[master]: drop unused libbsc/meas_proc.c

2018-02-20 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/6603
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If30724e3c638b191d20d00b897731762fb4896d5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-mgw[master]: mgcp_stat: Don't print osmux stats if it is off

2018-02-20 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/6605
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I6fcd680a073fbf8769488ffa2b2b32098c87edf4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-mgw[master]: legacy: mgcp_protocol: Don't print osmux stats if it is off

2018-02-20 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/6604
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I9031350242dd37ce255631c20eed33976887faa6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-ttcn3-hacks[master]: IPA_Emulation: Make dependencies to RSL/MGCP/SCCP/GSUP condi...

2018-02-20 Thread Harald Welte

Review at  https://gerrit.osmocom.org/6608

IPA_Emulation: Make dependencies to RSL/MGCP/SCCP/GSUP conditional

Let's use the preprocessor to avoid IPA_Emulation pulling *all*
dependencies into each and any of our projects.  The code readability
suffers a bit from the many #ifdefs, but compilation speed increases
if we don't have to pull in all those (recursive) dependencies.

After all, a BTS test case will never need SCCP, GSUP or MGCP.

Change-Id: Ic0231adbd2171214de133d26b3fbf36130ee8aa0
---
M bsc-nat/gen_links.sh
M bsc-nat/regen_makefile.sh
M bsc/gen_links.sh
M bsc/regen_makefile.sh
D hlr/Makefile
M hlr/gen_links.sh
M hlr/regen_makefile.sh
R library/IPA_Emulation.ttcnpp
M msc/gen_links.sh
M msc/regen_makefile.sh
M regen-makefile.sh
M selftest/Selftest.ttcn
M selftest/gen_links.sh
M selftest/regen_makefile.sh
M sgsn/gen_links.sh
M sgsn/regen_makefile.sh
16 files changed, 130 insertions(+), 267 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/08/6608/1

diff --git a/bsc-nat/gen_links.sh b/bsc-nat/gen_links.sh
index d27c092..e9280e6 100755
--- a/bsc-nat/gen_links.sh
+++ b/bsc-nat/gen_links.sh
@@ -55,5 +55,5 @@
 gen_links $DIR $FILES
 
 DIR=../library
-FILES="General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn IPA_Types.ttcn 
IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc 
IPA_Emulation.ttcn L3_Templates.ttcn BSSMAP_Templates.ttcn 
BSSMAP_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn 
MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc RSL_Types.ttcn 
Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn BSSAP_CodecPort.ttcn 
GSUP_Types.ttcn"
+FILES="General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn IPA_Types.ttcn 
IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc 
IPA_Emulation.ttcnpp L3_Templates.ttcn BSSMAP_Templates.ttcn 
BSSMAP_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn 
MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc 
Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn BSSAP_CodecPort.ttcn"
 gen_links $DIR $FILES
diff --git a/bsc-nat/regen_makefile.sh b/bsc-nat/regen_makefile.sh
index a3c6243..3d17cfe 100755
--- a/bsc-nat/regen_makefile.sh
+++ b/bsc-nat/regen_makefile.sh
@@ -2,6 +2,8 @@
 
 MAIN=IPA_Test.ttcn
 
-FILES="*.ttcn SCCP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc 
IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc RTP_EncDec.cc 
SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc"
+FILES="*.ttcn *.ttcnpp SCCP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc 
IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc 
RTP_EncDec.cc SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc"
+
+export CPPFLAGS_TTCN3="-DIPA_EMULATION_SCCP -DIPA_EMULATION_MGCP"
 
 ../regen-makefile.sh $MAIN $FILES
diff --git a/bsc/gen_links.sh b/bsc/gen_links.sh
index c80ae64..a173aac 100755
--- a/bsc/gen_links.sh
+++ b/bsc/gen_links.sh
@@ -80,5 +80,5 @@
 gen_links $DIR $FILES
 
 DIR=../library
-FILES="General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn 
Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc 
IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcn L3_Templates.ttcn 
BSSMAP_Templates.ttcn BSSMAP_Emulation.ttcn RLCMAC_CSN1_Types.ttcn 
GSM_RR_Types.ttcn RSL_Types.ttcn RSL_Emulation.ttcn MGCP_Emulation.ttcn 
MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn 
MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc 
BSSAP_CodecPort.ttcn BSSAP_Adapter.ttcn Osmocom_CTRL_Types.ttcn 
Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn RTP_CodecPort.ttcn 
RTP_CodecPort_CtrlFunct.ttcn RTP_CodecPort_CtrlFunctDef.cc RTP_Emulation.ttcn 
IuUP_Types.ttcn IuUP_EncDec.cc IuUP_Emulation.ttcn GSUP_Types.ttcn"
+FILES="General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn 
Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc 
IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn 
BSSMAP_Templates.ttcn BSSMAP_Emulation.ttcn RLCMAC_CSN1_Types.ttcn 
GSM_RR_Types.ttcn RSL_Types.ttcn RSL_Emulation.ttcn MGCP_Emulation.ttcn 
MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn 
MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc 
BSSAP_CodecPort.ttcn BSSAP_Adapter.ttcn Osmocom_CTRL_Types.ttcn 
Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn RTP_CodecPort.ttcn 
RTP_CodecPort_CtrlFunct.ttcn RTP_CodecPort_CtrlFunctDef.cc RTP_Emulation.ttcn 
IuUP_Types.ttcn IuUP_EncDec.cc IuUP_Emulation.ttcn "
 gen_links $DIR $FILES
diff --git a/bsc/regen_makefile.sh b/bsc/regen_makefile.sh
index 0b8e1fa..e9eb808 100755
--- a/bsc/regen_makefile.sh
+++ b/bsc/regen_makefile.sh
@@ -2,6 +2,8 @@
 
 MAIN=BSC_Tests.ttcn
 
-FILES="*.ttcn IPA_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc IPL4asp_discovery.cc 
TCCConversion.cc TCCInterface.cc SCTPasp_PT.cc RTP_EncDec.cc SDP_EncDec.cc 

[PATCH] osmo-ttcn3-hacks[master]: RSL_Types: Add templates for "BSC side"

2018-02-20 Thread Harald Welte

Review at  https://gerrit.osmocom.org/6607

RSL_Types: Add templates for "BSC side"

So far, the RSL templates have been used for BSC testing, i.e.
TTCN3 behaving like a BTS.  Now we want to test the BTS, so we
have to "invert" the receive/send direction and hence also need
the inverse templates.

This doesn't add *all* of them, but a sufficiently large number for our
first testcases against OsmoBTS.

Change-Id: Ica9cfae5a691e4d967d046b04e5bb16a71a89adf
---
M library/RSL_Types.ttcn
1 file changed, 211 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/07/6607/1

diff --git a/library/RSL_Types.ttcn b/library/RSL_Types.ttcn
index 765a91e..b1716fd 100644
--- a/library/RSL_Types.ttcn
+++ b/library/RSL_Types.ttcn
@@ -405,10 +405,24 @@
t2 := fn mod 26
}
 
+   function tr_RSL_IE_FrameNumber(template GsmFrameNumber fn) return 
template RSL_IE_FrameNumber {
+   if (istemplatekind(fn, "?")) {
+   return ?;
+   } else {
+   return ts_RSL_IE_FrameNumber(valueof(fn));
+   }
+   }
+
template RSL_IE_RequestRef ts_RSL_IE_ReqRef(OCT1 ra, GsmFrameNumber 
frame_nr) := {
ra := ra,
frame_nr := ts_RSL_IE_FrameNumber(frame_nr)
}
+
+   template RSL_IE_RequestRef tr_RSL_IE_ReqRef(template OCT1 ra, template 
GsmFrameNumber frame_nr) := {
+   ra := ra,
+   frame_nr := tr_RSL_IE_FrameNumber(frame_nr)
+   }
+
 
/* 9.3.26 */
type enumerated RSL_Cause {
@@ -463,6 +477,13 @@
 
template RSL_IE_Cause ts_RSL_IE_Cause(RSL_Cause cause) := {
len := 0, /* overwritten */
+   e := 0,
+   cause := cause,
+   cause_ext := omit
+   }
+
+   template RSL_IE_Cause tr_RSL_IE_Cause(template RSL_Cause cause) := {
+   len := ?,
e := 0,
cause := cause,
cause_ext := omit
@@ -749,6 +770,16 @@
t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := 
ts_RSL_L16V(l3_info)})
}
}
+   template RSL_Message tr_RSL_DATA_IND(template RslChannelNr chan_nr, 
template RslLinkId link_id,
+template octetstring l3_info := ?) 
:= {
+   msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, true),
+   msg_type := RSL_MT_DATA_IND,
+   ies :={
+   tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
+   tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
+   tr_RSL_IE(RSL_IE_Body:{l3_info := tr_RSL_L16V(l3_info)})
+   }
+   }
 
/* 8.3.3 BTS -> BSC */
template RSL_Message ts_RSL_ERROR_IND(RslChannelNr chan_nr, RslLinkId 
link_id, RSL_Cause cause) := {
@@ -760,6 +791,16 @@
t_RSL_IE(RSL_IE_CAUSE, RSL_IE_Body:{cause := 
ts_RSL_IE_Cause(cause)})
}
}
+   template RSL_Message tr_RSL_ERROR_IND(template RslChannelNr chan_nr, 
template RslLinkId link_id,
+   template RSL_Cause cause := ?) 
:= {
+   msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
+   msg_type := RSL_MT_ERROR_IND,
+   ies :={
+   tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
+   tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
+   tr_RSL_IE(RSL_IE_Body:{cause := tr_RSL_IE_Cause(cause)})
+   }
+   }
 
/* 8.3.6 BTS -> BSC */
template RSL_Message ts_RSL_EST_IND(RslChannelNr chan_nr, RslLinkId 
link_id, octetstring l3_info) := {
@@ -769,6 +810,16 @@
t_RSL_IE(RSL_IE_CHAN_NR, RSL_IE_Body:{chan_nr := 
chan_nr}),
t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := 
link_id}),
t_RSL_IE(RSL_IE_L3_INFO, RSL_IE_Body:{l3_info := 
ts_RSL_L16V(l3_info)})
+   }
+   }
+   template RSL_Message tr_RSL_EST_IND(template RslChannelNr chan_nr, 
template RslLinkId link_id,
+   template octetstring l3_info := 
?) := {
+   msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
+   msg_type := RSL_MT_EST_IND,
+   ies := {
+   tr_RSL_IE(RSL_IE_Body:{chan_nr := chan_nr}),
+   tr_RSL_IE(RSL_IE_Body:{link_id := link_id}),
+   tr_RSL_IE(RSL_IE_Body:{l3_info := tr_RSL_L16V(l3_info)})
}
}
 
@@ -801,6 +852,14 @@
t_RSL_IE(RSL_IE_LINK_IDENT, RSL_IE_Body:{link_id := 
link_id})
}
}
+   template RSL_Message tr_RSL_REL_CONF(template RslChannelNr chan_nr, 
template RslLinkId link_id) := {
+   msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RLL, false),
+   msg_type := 

osmo-bsc[master]: fix handover_test link error

2018-02-20 Thread Neels Hofmeyr

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/6606
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie7e1d4815d72b8e0bbc6ccd68078a78de19d73b0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[MERGED] osmo-bsc[master]: fix handover_test link error

2018-02-20 Thread Neels Hofmeyr
Neels Hofmeyr has submitted this change and it was merged.

Change subject: fix handover_test link error
..


fix handover_test link error

Fix undefined references during link stage when building handover_test.
The archive libbsc.a needs to be listed before the various .so files.

Change-Id: Ie7e1d4815d72b8e0bbc6ccd68078a78de19d73b0
---
M tests/handover/Makefile.am
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/handover/Makefile.am b/tests/handover/Makefile.am
index 4dd5223..5cdc0b0 100644
--- a/tests/handover/Makefile.am
+++ b/tests/handover/Makefile.am
@@ -28,8 +28,8 @@
$(NULL)
 
 handover_test_LDADD = \
+   $(top_builddir)/src/libbsc/libbsc.a \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOABIS_LIBS) \
-   $(top_builddir)/src/libbsc/libbsc.a \
$(NULL)

-- 
To view, visit https://gerrit.osmocom.org/6606
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie7e1d4815d72b8e0bbc6ccd68078a78de19d73b0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[PATCH] osmo-bsc[master]: fix handover_test link error

2018-02-20 Thread Stefan Sperling

Review at  https://gerrit.osmocom.org/6606

fix handover_test link error

Fix undefined references during link stage when building handover_test.
The archive libbsc.a needs to be listed before the various .so files.

Change-Id: Ie7e1d4815d72b8e0bbc6ccd68078a78de19d73b0
---
M tests/handover/Makefile.am
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/06/6606/1

diff --git a/tests/handover/Makefile.am b/tests/handover/Makefile.am
index 4dd5223..5cdc0b0 100644
--- a/tests/handover/Makefile.am
+++ b/tests/handover/Makefile.am
@@ -28,8 +28,8 @@
$(NULL)
 
 handover_test_LDADD = \
+   $(top_builddir)/src/libbsc/libbsc.a \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOABIS_LIBS) \
-   $(top_builddir)/src/libbsc/libbsc.a \
$(NULL)

-- 
To view, visit https://gerrit.osmocom.org/6606
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie7e1d4815d72b8e0bbc6ccd68078a78de19d73b0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 


osmo-msc[master]: mcgp: let the MGW allocate the MGCP endpoint

2018-02-20 Thread Stefan Sperling

Patch Set 1:

(5 comments)

https://gerrit.osmocom.org/#/c/6319/1/src/libmsc/msc_mgcp.c
File src/libmsc/msc_mgcp.c:

Line 240:   osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
This change removes a check for truncation. Is this intended?

You could keep the >= MGCP_ENDPOINT_MAXLEN check as it is, because snprintf and 
strlcpy have the same semantics in this regard.


Line 332:   osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
Another removed truncation check.


Line 606:   osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
Same.


Line 683:   osmo_strlcpy(mgcp_msg.endpoint, mgcp_ctx->rtp_endpoint, 
sizeof(mgcp_msg.endpoint));
Same.


Line 888:   osmo_strlcpy(mgcp_ctx->rtp_endpoint, ENDPOINT_ID, 
sizeof(mgcp_ctx->rtp_endpoint));
Check for truncation here?


-- 
To view, visit https://gerrit.osmocom.org/6319
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iee3e446b6689626516f01c521abe3d4603cd3e13
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


[PATCH] osmo-mgw[master]: legacy: mgcp_protocol: Don't print osmux stats if it is off

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6604

legacy: mgcp_protocol: Don't print osmux stats if it is off

Otherwise we get Osmux stats during a session using RTP, which is
confusing.

Forward-ported from openbsc e39e18992a3b966581f06fa632d6342643996aaa.

Change-Id: I9031350242dd37ce255631c20eed33976887faa6
---
M src/libosmo-legacy-mgcp/mgcp_protocol.c
M tests/legacy_mgcp/mgcp_test.c
2 files changed, 21 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/04/6604/1

diff --git a/src/libosmo-legacy-mgcp/mgcp_protocol.c 
b/src/libosmo-legacy-mgcp/mgcp_protocol.c
index d2df5f7..4e82233 100644
--- a/src/libosmo-legacy-mgcp/mgcp_protocol.c
+++ b/src/libosmo-legacy-mgcp/mgcp_protocol.c
@@ -1588,24 +1588,26 @@
msg += nchars;
size -= nchars;
 
-   /* Error Counter */
-   nchars = snprintf(msg, size,
- "\r\nX-Osmo-CP: EC TIS=%u, TOS=%u, TIR=%u, TOR=%u",
- endp->net_state.in_stream.err_ts_counter,
- endp->net_state.out_stream.err_ts_counter,
- endp->bts_state.in_stream.err_ts_counter,
- endp->bts_state.out_stream.err_ts_counter);
-   if (nchars < 0 || nchars >= size)
-   goto truncate;
+   if (endp->cfg->osmux != OSMUX_USAGE_OFF) {
+   /* Error Counter */
+   nchars = snprintf(msg, size,
+ "\r\nX-Osmo-CP: EC TIS=%u, TOS=%u, TIR=%u, 
TOR=%u",
+ endp->net_state.in_stream.err_ts_counter,
+ endp->net_state.out_stream.err_ts_counter,
+ endp->bts_state.in_stream.err_ts_counter,
+ endp->bts_state.out_stream.err_ts_counter);
+   if (nchars < 0 || nchars >= size)
+   goto truncate;
 
-   msg += nchars;
-   size -= nchars;
+   msg += nchars;
+   size -= nchars;
 
-   if (endp->osmux.state == OSMUX_STATE_ENABLED) {
-   snprintf(msg, size,
-"\r\nX-Osmux-ST: CR=%u, BR=%u",
-endp->osmux.stats.chunks,
-endp->osmux.stats.octets);
+   if (endp->osmux.state == OSMUX_STATE_ENABLED) {
+   snprintf(msg, size,
+"\r\nX-Osmux-ST: CR=%u, BR=%u",
+endp->osmux.stats.chunks,
+endp->osmux.stats.octets);
+   }
}
 truncate:
msg[size - 1] = '\0';
diff --git a/tests/legacy_mgcp/mgcp_test.c b/tests/legacy_mgcp/mgcp_test.c
index a540b5f..1a4513e 100644
--- a/tests/legacy_mgcp/mgcp_test.c
+++ b/tests/legacy_mgcp/mgcp_test.c
@@ -268,7 +268,9 @@
 "C: 2\r\n"
 
 #define DLCX_RET "250 7 OK\r\n"\
-"P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n" \
+"P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n"
+
+ #define DLCX_RET_OSMUX DLCX_RET \
 "X-Osmo-CP: EC TIS=0, TOS=0, TIR=0, TOR=0\r\n"
 
 #define RQNT"RQNT 186908780 1@mgw MGCP 1.0\r\n"\

-- 
To view, visit https://gerrit.osmocom.org/6604
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9031350242dd37ce255631c20eed33976887faa6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] osmo-mgw[master]: mgcp_stat: Don't print osmux stats if it is off

2018-02-20 Thread Pau Espin Pedrol

Review at  https://gerrit.osmocom.org/6605

mgcp_stat: Don't print osmux stats if it is off

Otherwise we get Osmux stats during a session using RTP, which is
confusing.

Change-Id: I6fcd680a073fbf8769488ffa2b2b32098c87edf4
---
M src/libosmo-mgcp/mgcp_stat.c
M tests/mgcp/mgcp_test.c
M tests/mgcp/mgcp_test.ok
3 files changed, 19 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/05/6605/1

diff --git a/src/libosmo-mgcp/mgcp_stat.c b/src/libosmo-mgcp/mgcp_stat.c
index 88a2d69..581130c 100644
--- a/src/libosmo-mgcp/mgcp_stat.c
+++ b/src/libosmo-mgcp/mgcp_stat.c
@@ -23,6 +23,7 @@
  */
 
 #include 
+#include 
 #include 
 
 /* Helper function for mgcp_format_stats_rtp() to calculate packet loss */
@@ -83,21 +84,23 @@
str += nchars;
str_len -= nchars;
 
-   /* Error Counter */
-   nchars = snprintf(str, str_len,
- "\r\nX-Osmo-CP: EC TI=%u, TO=%u",
- conn->state.in_stream.err_ts_counter,
- conn->state.out_stream.err_ts_counter);
-   if (nchars < 0 || nchars >= str_len)
-   goto truncate;
+   if (conn->conn->endp->cfg->osmux != OSMUX_USAGE_OFF) {
+   /* Error Counter */
+   nchars = snprintf(str, str_len,
+ "\r\nX-Osmo-CP: EC TI=%u, TO=%u",
+ conn->state.in_stream.err_ts_counter,
+ conn->state.out_stream.err_ts_counter);
+   if (nchars < 0 || nchars >= str_len)
+   goto truncate;
 
-   str += nchars;
-   str_len -= nchars;
+   str += nchars;
+   str_len -= nchars;
 
-   if (conn->osmux.state == OSMUX_STATE_ENABLED) {
-   snprintf(str, str_len,
-"\r\nX-Osmux-ST: CR=%u, BR=%u",
-conn->osmux.stats.chunks, conn->osmux.stats.octets);
+   if (conn->osmux.state == OSMUX_STATE_ENABLED) {
+   snprintf(str, str_len,
+"\r\nX-Osmux-ST: CR=%u, BR=%u",
+conn->osmux.stats.chunks, 
conn->osmux.stats.octets);
+   }
}
 
 truncate:
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 38a0a46..e1e6290 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -314,7 +314,9 @@
 
 #define DLCX_RET \
"250 7 OK\r\n" \
-   "P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n" \
+   "P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n"
+
+ #define DLCX_RET_OSMUX DLCX_RET \
"X-Osmo-CP: EC TI=0, TO=0\r\n"
 
 #define RQNT \
diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok
index 09ad9e1..d2879ad 100644
--- a/tests/mgcp/mgcp_test.ok
+++ b/tests/mgcp/mgcp_test.ok
@@ -569,7 +569,6 @@
 -8<-
 250 7 OK
 P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0
-X-Osmo-CP: EC TI=0, TO=0
 
 -8<-
 Parsing result: 0

-- 
To view, visit https://gerrit.osmocom.org/6605
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6fcd680a073fbf8769488ffa2b2b32098c87edf4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[MERGED] osmo-pcu[master]: Simplify TS alloc: don't use PDCH for free TFI

2018-02-20 Thread Max
Max has submitted this change and it was merged.

Change subject: Simplify TS alloc: don't use PDCH for free TFI
..


Simplify TS alloc: don't use PDCH for free TFI

Don't use PDCH from free TFI lookup routine. This allows for simpler
function which can be moved to mslot_class.c alongside with other
similar helpers.

Change-Id: Ie154866900453d232a890f7b9a30911b451525a1
Related: OS#2282
---
M src/bts.h
M src/gprs_rlcmac_ts_alloc.cpp
M src/mslot_class.c
M src/mslot_class.h
4 files changed, 21 insertions(+), 19 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/bts.h b/src/bts.h
index 9c75369..df81440 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+   #include 
 }
 
 #include 
@@ -45,7 +46,6 @@
 #define LLC_CODEL_DISABLE 0
 #define LLC_CODEL_USE_DEFAULT (-1)
 #define MAX_GPRS_CS 9
-#define NO_FREE_TFI 0x
 
 /* see bts->gsmtap_categ_mask */
 enum pcu_gsmtap_category {
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 29e41f5..6791b03 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -62,23 +62,6 @@
return was_set;
 }
 
-static inline int8_t find_free_tfi(const struct gprs_rlcmac_pdch *pdch, enum 
gprs_rlcmac_tbf_direction dir)
-{
-   uint32_t tfi_map = pdch->assigned_tfi(dir);
-   int8_t tfi;
-
-   if (tfi_map == NO_FREE_TFI)
-   return -1;
-
-   /* look for USF, don't use USF=7 */
-   for (tfi = 0; tfi < 32; tfi++) {
-   if (!(tfi_map & (1 << tfi)))
-   return tfi;
-   }
-
-   return -1;
-}
-
 static int find_possible_pdchs(const struct gprs_rlcmac_trx *trx, size_t 
max_slots, uint8_t mask,
   const char *mask_reason = NULL)
 {
@@ -187,7 +170,7 @@
/* We have found a candidate */
/* Make sure that a TFI is available */
if (free_tfi) {
-   tfi = find_free_tfi(pdch, dir);
+   tfi = find_free_tfi(pdch->assigned_tfi(dir));
if (tfi < 0) {
LOGP(DRLCMAC, LOGL_DEBUG,
"- Skipping TS %d, because "
diff --git a/src/mslot_class.c b/src/mslot_class.c
index 6a7e25b..d49d411 100644
--- a/src/mslot_class.c
+++ b/src/mslot_class.c
@@ -229,6 +229,22 @@
return -1;
 }
 
+/* look for USF, don't use USF=7 */
+int8_t find_free_tfi(uint32_t tfi_map)
+{
+   int8_t tfi;
+
+   if (tfi_map == NO_FREE_TFI)
+   return -1;
+
+   for (tfi = 0; tfi < 32; tfi++) {
+   if (!(tfi_map & (1 << tfi)))
+   return tfi;
+   }
+
+   return -1;
+}
+
 void masked_override_with(char *buf, uint8_t mask, char set_char)
 {
int i;
diff --git a/src/mslot_class.h b/src/mslot_class.h
index c274337..97b865b 100644
--- a/src/mslot_class.h
+++ b/src/mslot_class.h
@@ -36,6 +36,8 @@
 
 #define DEFAULT_MSLOT_CLASS 12
 
+#define NO_FREE_TFI 0x
+
 enum { MASK_TT = 0, MASK_TR = 1 };
 
 /* multislot class selection routines */
@@ -52,4 +54,5 @@
 /* multislot allocation helper routines */
 void mslot_fill_rx_mask(uint8_t mslot_class, uint8_t num_tx, uint8_t *rx_mask);
 int8_t find_free_usf(uint8_t usf_map);
+int8_t find_free_tfi(uint32_t tfi_map);
 void masked_override_with(char *buf, uint8_t mask, char set_char);

-- 
To view, visit https://gerrit.osmocom.org/6223
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie154866900453d232a890f7b9a30911b451525a1
Gerrit-PatchSet: 4
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 


[MERGED] osmo-pcu[master]: Simplify TS alloc: constify max dl slot func

2018-02-20 Thread Max
Max has submitted this change and it was merged.

Change subject: Simplify TS alloc: constify max dl slot func
..


Simplify TS alloc: constify max dl slot func

Constify parameters of gprs_alloc_max_dl_slots_per_ms().

Change-Id: Ic90930d98560459eab0054cb9e1625cb99db61c8
Related: OS#2282
---
M src/gprs_rlcmac.h
M src/gprs_rlcmac_ts_alloc.cpp
2 files changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 33dd9fd..8ff3c90 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -97,7 +97,7 @@
uint8_t trx, uint8_t ts,
 uint32_t fn, uint8_t block_nr);
 
-int gprs_alloc_max_dl_slots_per_ms(struct gprs_rlcmac_bts *bts,
+int gprs_alloc_max_dl_slots_per_ms(const struct gprs_rlcmac_bts *bts,
uint8_t ms_class = 0);
 
 extern "C" {
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 6791b03..f26b27c 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -1017,7 +1017,7 @@
return alloc_algorithm_a(bts, ms_, tbf_, single, use_trx);
 }
 
-int gprs_alloc_max_dl_slots_per_ms(struct gprs_rlcmac_bts *bts, uint8_t 
ms_class)
+int gprs_alloc_max_dl_slots_per_ms(const struct gprs_rlcmac_bts *bts, uint8_t 
ms_class)
 {
int rx = mslot_class_get_rx(ms_class);
 

-- 
To view, visit https://gerrit.osmocom.org/6224
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic90930d98560459eab0054cb9e1625cb99db61c8
Gerrit-PatchSet: 4
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 


[PATCH] libosmocore[master]: support for more cell ID list types in libosmocore

2018-02-20 Thread Stefan Sperling
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/6509

to look at the new patch set (#6).

support for more cell ID list types in libosmocore

Extend gsm0808_dec_cell_id_list() with support for additional types of
cell identifier lists. The new parsing routines are based on similar
routines used by the paging code in osmo-bsc's osmo_bsc_bssap.c.

Likewise, extend gsm0808_enc_cell_id_list() with support for the
same additional types of cell identifier lists.

There is an API change in struct gsm0808_cell_id_list.
The previous definition was insufficient because it assumed that all
decoded cell ID types could be represented with a single uint16_t.
It was declared in a GSM protocol header (gsm/protocol/gsm_08_08.h)
despite being a host-side representation of data in an IE.
The only user I am aware of is in osmo-msc, where this struct is used
for one local variable.
This API user is fixed by https://gerrit.osmocom.org/#/c/6518/

Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb
Related: OS#2847
---
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm0808_utils.h
M include/osmocom/gsm/protocol/gsm_08_08.h
M src/gsm/gsm0808_utils.c
M tests/gsm0808/gsm0808_test.c
5 files changed, 255 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/09/6509/6

diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 3deee70..219e339 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -28,6 +28,7 @@
 struct sockaddr_storage;
 
 struct msgb;
+struct gsm0808_cell_id_list;
 
 struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc,
   uint16_t cc, int lac, uint16_t _ci);
diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 7432164..3efadf8 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -26,6 +26,62 @@
 struct sockaddr_storage;
 
 #include 
+#include 
+
+/* 3GPP TS 48.008 3.2.2.27 Cell Identifier List */
+
+/*
+ * The structs below are parsed representations of data in the corresponding 
IE.
+ * All fields are in host byte-order.
+ *
+ * The functions gsm0808_dec_cell_id_list() and gsm0808_enc_cell_id_list()
+ * convert these structs from/to a network byte-order data stream.
+ */
+
+/* Parsed Cell Global Identification (CELL_IDENT_WHOLE_GLOBAL)
+ * uses struct osmo_cell_global_id. */
+
+/* Parsed Location Area Code and Cell Identity (CELL_IDENT_LAC_AND_CI) */
+struct gsm0808_cell_id_lac_and_ci {
+   uint16_t lac;
+   uint16_t ci;
+};
+
+/* Parsed Cell Identity (CELL_IDENT_CI) */
+struct gsm0808_cell_id_ci {
+   uint16_t ci;
+};
+
+/* Parsed Location Area Identification and Location Area Code 
(CELL_IDENT_LAI_AND_LAC)
+ * uses struct osmo_location_area_id. */
+
+/* Parsed Location Area Code (CELL_IDENT_LAC) */
+struct gsm0808_cell_id_lac {
+   uint16_t lac;
+};
+
+#define CELL_ID_LIST_MAXLEN254 /* implementation-defined 
limit, in bytes */
+#define CELL_ID_LIST_GLOBAL_MAXLEN (CELL_ID_LIST_MAXLEN / sizeof(struct 
osmo_cell_global_id))
+#define CELL_ID_LIST_LAC_AND_CI_MAXLEN (CELL_ID_LIST_MAXLEN / sizeof(struct 
gsm0808_cell_id_lac_and_ci))
+#define CELL_ID_LIST_CI_MAXLEN (CELL_ID_LIST_MAXLEN / sizeof(struct 
gsm0808_cell_id_ci))
+#define CELL_ID_LIST_LAI_AND_LAC_MAXLEN(CELL_ID_LIST_MAXLEN / 
sizeof(struct osmo_location_area_id))
+#define CELL_ID_LIST_LAC_MAXLEN(CELL_ID_LIST_MAXLEN / 
sizeof(struct gsm0808_cell_id_lac))
+struct gsm0808_cell_id_list {
+   uint8_t id_discr;
+   union {
+   /*
+* All struct fields in elements of these arrays are in 
host-byte order,
+* ie. contain parsed representations of the data in the 
corresponding IE.
+*/
+   struct osmo_cell_global_id  
id_list_global[CELL_ID_LIST_GLOBAL_MAXLEN];
+   struct gsm0808_cell_id_lac_and_ci   
id_list_lac_and_ci[CELL_ID_LIST_LAC_AND_CI_MAXLEN];
+   struct gsm0808_cell_id_ci   
id_list_ci[CELL_ID_LIST_CI_MAXLEN];
+   struct osmo_location_area_id
id_list_lai_and_lac[CELL_ID_LIST_LAI_AND_LAC_MAXLEN];
+   struct gsm0808_cell_id_lac  
id_list_lac[CELL_ID_LIST_LAC_MAXLEN];
+   } id_list;
+   unsigned int id_list_len;
+};
+
 
 uint8_t gsm0808_enc_aoip_trasp_addr(struct msgb *msg,
const struct sockaddr_storage *ss);
diff --git a/include/osmocom/gsm/protocol/gsm_08_08.h 
b/include/osmocom/gsm/protocol/gsm_08_08.h
index ba347ef..e8d6911 100644
--- a/include/osmocom/gsm/protocol/gsm_08_08.h
+++ b/include/osmocom/gsm/protocol/gsm_08_08.h
@@ -500,11 +500,3 @@
uint8_t key[ENCRY_INFO_KEY_MAXLEN];
unsigned int key_len;
 };
-
-/* 3GPP TS 48.008 3.2.2.27 Cell Identifier List */
-#define 

[PATCH] osmo-bsc[master]: drop unused libbsc/meas_proc.c

2018-02-20 Thread Neels Hofmeyr

Review at  https://gerrit.osmocom.org/6603

drop unused libbsc/meas_proc.c

The file meas_proc.c seems to be an earlier stage of development of the meas
rep handling now in handover_decision.c, and to have been inadvertently added
to the git tree in:

  commit 9af6ddfcec25f43c5b50a6c5a6b80e341ab9a8a7
  Date:   Sat Jan 1 15:25:50 2011 +0100
  License change: We are now AGPLv3+ instead of GPLv2+

The file has never been part of Makefile.am.

Change-Id: If30724e3c638b191d20d00b897731762fb4896d5
---
D src/libbsc/meas_proc.c
1 file changed, 0 insertions(+), 84 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/03/6603/1

diff --git a/src/libbsc/meas_proc.c b/src/libbsc/meas_proc.c
deleted file mode 100644
index efc3fd0..000
--- a/src/libbsc/meas_proc.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Measurement Processing */
-
-/* (C) 2009 by Harald Welte 
- *
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * 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
- * (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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see .
- *
- */
-
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-/* process an already parsed measurement report */
-static int process_meas_rep(struct gsm_meas_rep *mr)
-{
-   struct gsm_meas_rep_cell *mr_cell = NULL;
-   unsigned int best_better_db;
-   int i;
-
-   /* FIXME: implement actual averaging over multiple measurement
-* reports */
-
-   /* find the best cell in this report that is at least RXLEV_HYST
-* better than the current serving cell */
-   for (i = 0; i < mr->num_cell; i++) {
-   unsigned int better;
-   if (mr->cell[i].rxlev < mr->dl.full.rx_lev + RXLEV_HYST)
-   continue;
-
-   better = mr->cell[i].rxlev - mr->dl.full.rx_lev;
-   if (better > best_better_db) {
-   mr_cell = >cell[i];
-   best_better_db = better;
-   }
-   }
-
-   if (mr_cell)
-   return handover_to_arfcn_bsic(mr->lchan, mr_cell->arfcn,
-   mr_cell->bsic);
-   return 0;
-}
-
-static int meas_proc_sig_cb(unsigned int subsys, unsigned int signal,
-  void *handler_data, void *signal_data)
-{
-   struct gsm_lchan *lchan;
-   struct gsm_meas_rep *mr;
-
-   if (subsys != SS_LCHAN)
-   return 0;
-
-   switch (signal) {
-   case S_LCHAN_MEAS_REP:
-   mr = signal_data;
-   process_meas_rep(mr);
-   break;
-   }
-
-   return 0;
-}
-
-static __attribute__((constructor)) void on_dso_load_meas(void)
-{
-   osmo_signal_register_handler(SS_LCHAN, meas_proc_sig_cb, NULL);
-}

-- 
To view, visit https://gerrit.osmocom.org/6603
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If30724e3c638b191d20d00b897731762fb4896d5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr