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

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

Change subject: Add initial support for logging, vty, ctrl
..


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

Related: OS#2184

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
8 files changed, 269 insertions(+), 6 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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..e4db2f3
--- /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[] = {
+   [DMAIN] = {
+   .name = "DMAIN",
+   .description = "Main generic category",
+   .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..7038f4c
--- /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 {
+   DMAIN,
+};
diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
new file mode 100644
index 000..b16cd24
--- /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,
+};
+
+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 bind\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, >cfg.bind_addr, 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 

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

2018-02-26 Thread Harald Welte

Patch Set 9: Code-Review+2

-- 
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: 9
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


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

2018-02-22 Thread Pau Espin Pedrol

Patch Set 5:

(2 comments)

https://gerrit.osmocom.org/#/c/6619/5/CommonLibs/trx_vty.h
File CommonLibs/trx_vty.h:

Line 7: struct trx_ctx {
> Please add a comment with brief description of this
Initially I thought it would make sesne to move the Trasnciever, RadioDevice 
and RadioInterface pointers in here, but I'm still unsure if it's finally going 
to handle more stuff because in order to introduce those I'd need to compile 
everything to c++.

I'm still unsure if it makes sense to slowly try to isolate c++ parts in favor 
of c or just try to compile everything as c++.


https://gerrit.osmocom.org/#/c/6619/5/Transceiver52M/osmo-trx.cpp
File Transceiver52M/osmo-trx.cpp:

Line 345:   config->config_file = (char *)DEFAULT_CONFIG_FILE;
> Why do we need this cast?
Not in C++ apparently, I was hitting this compiler warning: 
https://stackoverflow.com/questions/20944784/why-is-conversion-from-string-constant-to-char-valid-in-c-but-invalid-in-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: 5
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


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

2018-02-21 Thread Vadim Yanitskiy

Patch Set 5: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/#/c/6619/5/Transceiver52M/osmo-trx.cpp
File Transceiver52M/osmo-trx.cpp:

Line 345:   config->config_file = (char *)DEFAULT_CONFIG_FILE;
Why do we need this cast?
It should already be (char *), am I wrong?


-- 
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: 5
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


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

2018-02-21 Thread Vadim Yanitskiy

Patch Set 5:

(1 comment)

https://gerrit.osmocom.org/#/c/6619/5/CommonLibs/trx_vty.h
File CommonLibs/trx_vty.h:

Line 7: struct trx_ctx {
Please add a comment with brief description of this
structure and further plans, i.e. what is it going
to be used for?


-- 
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: 5
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


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

2018-02-21 Thread Vadim Yanitskiy

Patch Set 4:

(2 comments)

https://gerrit.osmocom.org/#/c/6619/4/Transceiver52M/osmo-trx.cpp
File Transceiver52M/osmo-trx.cpp:

Line 79: #define DEFAULT_CONFIG_FILE"/etc/osmocom/osmo-trx.cfg"
I am not sure, is this common for Osmocom projects to
keep the configuration files in '/etc/osmocom/'?

For example, the way of OsmoBTS:

  static const char *config_file = "osmo-bts.cfg";

so, if a configuration file isn't specified by user,
the program will look for "osmo-bts.cfg" in
a current directory.


https://gerrit.osmocom.org/#/c/6619/4/doc/examples/osmo-trx-limesdr.cfg
File doc/examples/osmo-trx-limesdr.cfg:

Line 1: log stderr
This file is definitely unrelated to the change,
and could be a part of another one...


-- 
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: 4
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


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

2018-02-21 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 (#5).

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

Related: OS#2184

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
8 files changed, 269 insertions(+), 6 deletions(-)


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

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..e4db2f3
--- /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[] = {
+   [DMAIN] = {
+   .name = "DMAIN",
+   .description = "Main generic category",
+   .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..7038f4c
--- /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 {
+   DMAIN,
+};
diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
new file mode 100644
index 000..b16cd24
--- /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,
+};
+
+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 bind\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, >cfg.bind_addr, 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;

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

2018-02-21 Thread Pau Espin Pedrol

Patch Set 4:

(2 comments)

https://gerrit.osmocom.org/#/c/6619/4/CommonLibs/debug.c
File CommonLibs/debug.c:

Line 9: .description = "Transciever",
> _ei_ not _ie_ because its receiver, not reciever and "Transceiver" is from 
Typo indeed :-)


https://gerrit.osmocom.org/#/c/6619/4/CommonLibs/debug.h
File CommonLibs/debug.h:

Line 7: DTRX,
> I'm honestly not sure if it makes sense to start a category with this name.
I don't want to add even more changes to a lot of lines now to set different 
categories for each log line, so I'll use DMAIN for now and future commits can 
work on this.


-- 
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: 4
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


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

2018-02-21 Thread Harald Welte

Patch Set 4:

(4 comments)

https://gerrit.osmocom.org/#/c/6619/4//COMMIT_MSG
Commit Message:

Line 12: Depends on libosmocore Change-Id 
Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9
Related: OS#2184


https://gerrit.osmocom.org/#/c/6619/4/CommonLibs/debug.c
File CommonLibs/debug.c:

Line 9: .description = "Transciever",
_ei_ not _ie_ because its receiver, not reciever and "Transceiver" is from 
Transmitter + Receiver.


https://gerrit.osmocom.org/#/c/6619/4/CommonLibs/debug.h
File CommonLibs/debug.h:

Line 7: DTRX,
I'm honestly not sure if it makes sense to start a category with this name.  
The program is called "OsmoTRX/Trnsceiver", it implements one or multiple GSM 
TRXs, but then only the lower layers of it.  What exactly wold go in here?

I think it makes sense to straight ahead add meaningful categories for 
idividual code sub-sections.  And if you must add a global one, I would simply 
call it DMAIN or DGLOBAL or DMISC or whatever...


https://gerrit.osmocom.org/#/c/6619/4/CommonLibs/trx_vty.c
File CommonLibs/trx_vty.c:

Line 138:   "Copyright (C) 2013 Thomas Tsou \r\n"
I think this should state all major copyright holders. Doing some research on 
the Copyright statements in the source, there is:
* FSF
* Ettus
* Tom Tsou
* sysmocom

I guess we can leave out the folling names:
* Range (only GSMCommon.cpp that is *very* small, and Logger.cpp, which we will 
no longer use?)
* Kestrel (only in LogTest.cpp, which is not part of the binary program that 
prints the above message
* Alexander Chemersi (only copyright claim is in PRBSTest.cpp, whcih is also 
not part of the osmo-trx binary)


-- 
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: 4
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


[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]: 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


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 =