libosmocore[master]: VTY: implement talloc context introspection command

2017-09-25 Thread Vadim Yanitskiy

Patch Set 3:

(3 comments)

https://gerrit.osmocom.org/#/c/4018/3/src/vty/talloc_ctx_vty.c
File src/vty/talloc_ctx_vty.c:

Line 103:   size_t chunk_blocks = talloc_total_blocks(chunk);
> we generally have all variable declarations at the top of the functions.  Y
Done.


Line 153:   "show talloc-context (application|all) (full|brief|DEPTH)",
> might make sense to also include "vty" here to show the tall_vty_ctx.
I would suggest to go a bit different way. There is a lot
of internal talloc contexts within the library (e.g. tall_msgb_ctx).
Some of them could be easily bound to application's context,
but some couldn't.

Do we have any common talloc context export policy? If don't,
I think we can discuss / implement it, and add corresponding
changes here in a separate commit. What do you think?


Line 183:   "Application's context\nAll contexts, "
> please make a new line also in the source code, not a \n in the middle of a
Thanks, done.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


[PATCH] libosmocore[master]: VTY: implement talloc context introspection command

2017-09-25 Thread Vadim Yanitskiy
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/4018

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

VTY: implement talloc context introspection command

This change introduces a new command, which could be used to
inspect the application's talloc context directly from VTY.
To enable this feature, an application need to provide it's
context via the 'vty_app_info' struct, and register the VTY
command by calling the osmo_talloc_vty_add_cmds().

The new command is a sub-command of 'show':

  show talloc-context   [filter]

Currently the following contexts may be inspected:

  - application - a context provided by an application;
  - null - all contexts, if NULL-context tracking is enabled.

A report depth is defined by the next parameter, and could be:

  - full - full tree report, as the talloc_report_full() does;
  - brief - brief tree report, as the talloc_report() does;
  - DEPTH - user defined maximal report depth.

Also, there are two optional report filters:

  - regexp - print only contexts, matching a regular expression;
  - tree - print a specific context, pointed by specified address.

The command output is formatted the same way as in case of calling
the talloc_report() or talloc_report_full().

Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
---
M include/osmocom/vty/misc.h
M src/vty/Makefile.am
A src/vty/talloc_ctx_vty.c
3 files changed, 282 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/4018/4

diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h
index 545955c..335558d 100644
--- a/include/osmocom/vty/misc.h
+++ b/include/osmocom/vty/misc.h
@@ -28,6 +28,7 @@
 void vty_out_fsm(struct vty *vty, struct osmo_fsm *fsm);
 void vty_out_fsm_inst(struct vty *vty, struct osmo_fsm_inst *fsmi);
 void osmo_fsm_vty_add_cmds(void);
+void osmo_talloc_vty_add_cmds(void);
 
 
 int osmo_vty_write_config_file(const char *filename);
diff --git a/src/vty/Makefile.am b/src/vty/Makefile.am
index e083a1c..1dc76c3 100644
--- a/src/vty/Makefile.am
+++ b/src/vty/Makefile.am
@@ -10,7 +10,8 @@
 lib_LTLIBRARIES = libosmovty.la
 
 libosmovty_la_SOURCES = buffer.c command.c vty.c vector.c utils.c \
-   telnet_interface.c logging_vty.c stats_vty.c fsm_vty.c
+   telnet_interface.c logging_vty.c stats_vty.c \
+   fsm_vty.c talloc_ctx_vty.c
 libosmovty_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined 
$(TALLOC_LIBS)
 libosmovty_la_LIBADD = $(top_builddir)/src/libosmocore.la
 endif
diff --git a/src/vty/talloc_ctx_vty.c b/src/vty/talloc_ctx_vty.c
new file mode 100644
index 000..136a1b4
--- /dev/null
+++ b/src/vty/talloc_ctx_vty.c
@@ -0,0 +1,279 @@
+/*! \file talloc_ctx_vty.c
+ * Osmocom talloc context introspection via VTY. */
+/*
+ * (C) 2017 by Vadim Yanitskiy 
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+extern void *tall_vty_ctx;
+extern struct host host;
+
+enum walk_filter_type {
+   WALK_FILTER_NONE = 0,
+   WALK_FILTER_REGEXP,
+   WALK_FILTER_TREE,
+};
+
+struct walk_cb_params {
+   enum walk_filter_type filter;
+   unsigned int depth_pass;
+   const void *chunk_ptr;
+   struct vty *vty;
+   regex_t regexp;
+};
+
+/*!
+ * Print a talloc memory hierarchy to the given VTY.
+ * To be called by the talloc_report_depth_cb().
+ * If one of supported filters is specified, then
+ * only satisfying memory trees would be printed.
+ *
+ * @param chunk The talloc chunk to be printed
+ * @param depth Current depth value
+ * @param max_depth Maximal depth of report (negative means full)
+ * @param is_refIs this chunk a reference?
+ * @param data  The walk_cb_params struct instance
+ */
+static void talloc_ctx_walk_cb(const void *chunk, int depth,
+   int max_depth, int is_ref, void *data)
+{
+   struct walk_cb_params *p = (struct walk_cb_params *) data;
+   const char *chunk_name = talloc_get_name(chunk);
+   struct vty *vty = p->vty;
+   size_t chunk_blocks;
+   size_t chunk_size;
+   int rc;
+
+   if (depth > 0 && p->filter) {
+   /**
+   

[ABANDON] libosmocore[master]: bitvec: implement write L or H value to vector

2017-09-25 Thread Harald Welte
Harald Welte has abandoned this change.

Change subject: bitvec: implement write L or H value to vector
..


Abandoned

As discussed in https://gerrit.osmocom.org/#/c/3991/ we already have similar 
API in libosmocore and prefer to use that.  Minh agrees that this is a good 
idea, so let's abandon this patch.

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

Gerrit-MessageType: abandon
Gerrit-Change-Id: I36a76916a5986f098b6be6b5b779639c470725ef
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Minh-Quang Nguyen 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 


libosmocore[master]: VTY: implement talloc context introspection command

2017-09-25 Thread Harald Welte

Patch Set 3: Code-Review+1

(3 comments)

Thanks a lot for your work on this extremely useful feature!

Some minor coding style comments below, please kindly update accordingly.

https://gerrit.osmocom.org/#/c/4018/3/src/vty/talloc_ctx_vty.c
File src/vty/talloc_ctx_vty.c:

Line 103:   size_t chunk_blocks = talloc_total_blocks(chunk);
we generally have all variable declarations at the top of the functions.  Yes, 
it's arguable (like all coding style), but I would prefer to have all code the 
same style. Thanks!


Line 153:   "show talloc-context (application|all) (full|brief|DEPTH)",
might make sense to also include "vty" here to show the tall_vty_ctx.


Line 183:   "Application's context\nAll contexts, "
please make a new line also in the source code, not a \n in the middle of a 
string constant.

In general, as you're using the same strings from multiple DEFUN(), please 
#define the string once and refer to it from the DEFUN() - We do this all over 
the Osmocom programs.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


libosmocore[master]: vty/vty.c: do not bind vty context to application's one

2017-09-25 Thread Harald Welte

Patch Set 1: Code-Review+2

I think we can do this, but actually only as 'tall_vty_ctx' is already exported 
globally, i.e. an application or even library code can use this global variable 
to refer to the talloc VTY context.  So there's no need to have it as a sibling 
to the applications context.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9cb6ce9f24dbae400029e2d9f9c933fbfb16248f
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


libosmocore[master]: Add time conversion helpers

2017-09-25 Thread Harald Welte

Patch Set 2: Code-Review+2

one could argue if its "timer.h" and shouldn't rather go into utils.h or 
something more general, but it's fine for me as-is.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[MERGED] osmo-msc[master]: fix debian: fix erratic doc/examples install path

2017-09-25 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: fix debian: fix erratic doc/examples install path
..


fix debian: fix erratic doc/examples install path

Change-Id: I8fc3d50b95649145e45ea6b56792ddbaf0548050
---
M debian/osmo-msc.install
1 file changed, 1 insertion(+), 1 deletion(-)

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



diff --git a/debian/osmo-msc.install b/debian/osmo-msc.install
index 145d25d..3e289b2 100644
--- a/debian/osmo-msc.install
+++ b/debian/osmo-msc.install
@@ -1,2 +1,2 @@
 usr/bin/osmo-msc
-usr/share/doc/openbsc/examples/osmo-msc/osmo-msc.cfg
+usr/share/doc/osmo-msc/examples/osmo-msc/osmo-msc.cfg

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8fc3d50b95649145e45ea6b56792ddbaf0548050
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


osmo-gsm-manuals[master]: add OsmoMSC manual

2017-09-25 Thread Harald Welte

Patch Set 3:

(1 comment)

> The differences between Osmo{NITB,MSC}/chapters/mncc.adoc are 32
 > occurences of the name OsmoNITB replaced with OsmoMSC, [...]

Pau has solved this by some variable substitution in the sysmoBTS user manuals, 
please see related examples as an idea to use here.  But yes, your re-wording 
proposal would also work. Up to you.

https://gerrit.osmocom.org/#/c/4012/3/OsmoMSC/chapters/smpp.adoc
File OsmoMSC/chapters/smpp.adoc:

Line 2: == Short Message Peer to Peer (SMPP)
this is yet another copied chapter, isn't it?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9ecff2837fbf5fdc19675a726f6d70c21eb178ee
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


osmo-sgsn[master]: Remove unneeded dep libdbi

2017-09-25 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


osmo-gsm-manuals[master]: move mncc.adoc to common chapters

2017-09-25 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I404758ff7f1372e841ffe33c75455f513fff3caf
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-hlr[master]: comment: ctrl: explain why status-ps is a SET cmd

2017-09-25 Thread Harald Welte

Patch Set 1: Code-Review+2

(1 comment)

https://gerrit.osmocom.org/#/c/4062/1/src/ctrl.c
File src/ctrl.c:

Line 80:  * name. */
this sounds like a rather ugly work-around. I would consider this deserves some 
kind of a discussion on the mailing list and an investigation if we can change 
the control interface protocol


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I1ccf6affaf3c5f2096fd3eb36454b18c3670a1b0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: Yes


osmo-hlr[master]: add CTRL tests for enable-/disable-/status-ps

2017-09-25 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


osmo-hlr[master]: add basic CTRL interface tests

2017-09-25 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


[PATCH] osmo-hlr[master]: comment: ctrl: explain why status-ps is a SET cmd

2017-09-25 Thread Neels Hofmeyr

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

comment: ctrl: explain why status-ps is a SET cmd

Change-Id: I1ccf6affaf3c5f2096fd3eb36454b18c3670a1b0
---
M src/ctrl.c
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/62/4062/1

diff --git a/src/ctrl.c b/src/ctrl.c
index 81de961..40c1e53 100644
--- a/src/ctrl.c
+++ b/src/ctrl.c
@@ -74,6 +74,10 @@
return handle_cmd_ps(data, cmd, false);
 }
 
+/* NOTE: Even though status-ps is actually a read-only operation, it is
+ * implemented as a 'SET' command, so that we are able to pass the IMSI as
+ * argument. 'GET' commands cannot be passed arguments besides the variable
+ * name. */
 CTRL_CMD_DEFINE_WO_NOVRF(status_ps, "status-ps");
 static int set_status_ps(struct ctrl_cmd *cmd, void *data)
 {

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

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


[PATCH] osmo-hlr[master]: add basic CTRL interface tests

2017-09-25 Thread Neels Hofmeyr

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

add basic CTRL interface tests

Prepare for adding tests of enable-/disable-/status-ps CTRL commands.

Change-Id: Ie195169c574716b514da7e04a3ce9727ef70a55e
---
M configure.ac
A contrib/ipa.py
M tests/Makefile.am
A tests/ctrl_test_runner.py
A tests/test_subscriber.sql
5 files changed, 515 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/63/4063/1

diff --git a/configure.ac b/configure.ac
index 6532940..167d7f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,21 @@
 dnl checks for header files
 AC_HEADER_STDC
 
+AC_ARG_ENABLE([external_tests],
+   AC_HELP_STRING([--enable-external-tests],
+   [Include the VTY/CTRL tests in make check 
[default=no]]),
+   [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
+if test "x$enable_ext_tests" = "xyes" ; then
+   AM_PATH_PYTHON
+   AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
+if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
+   AC_MSG_ERROR([Please install 
git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
+   fi
+fi
+AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
+AC_MSG_RESULT([$enable_ext_tests])
+AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
+
 AC_OUTPUT(
Makefile
src/Makefile
diff --git a/contrib/ipa.py b/contrib/ipa.py
new file mode 100755
index 000..71cbf45
--- /dev/null
+++ b/contrib/ipa.py
@@ -0,0 +1,278 @@
+#!/usr/bin/python3
+# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
+"""
+/*
+ * Copyright (C) 2016 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 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+"""
+
+import struct, random, sys
+
+class IPA(object):
+"""
+Stateless IPA protocol multiplexer: add/remove/parse (extended) header
+"""
+version = "0.0.5"
+TCP_PORT_OML = 3002
+TCP_PORT_RSL = 3003
+# OpenBSC extensions: OSMO, MGCP_OLD
+PROTO = dict(RSL=0x00, CCM=0xFE, SCCP=0xFD, OML=0xFF, OSMO=0xEE, 
MGCP_OLD=0xFC)
+# ...OML Router Control, GSUP GPRS extension, Osmocom Authn Protocol
+EXT = dict(CTRL=0, MGCP=1, LAC=2, SMSC=3, ORC=4, GSUP=5, OAP=6)
+# OpenBSC extension: SCCP_OLD
+MSGT = dict(PING=0x00, PONG=0x01, ID_GET=0x04, ID_RESP=0x05, ID_ACK=0x06, 
SCCP_OLD=0xFF)
+_IDTAG = dict(SERNR=0, UNITNAME=1, LOCATION=2, TYPE=3, EQUIPVERS=4, 
SWVERSION=5, IPADDR=6, MACADDR=7, UNIT=8)
+CTRL_GET = 'GET'
+CTRL_SET = 'SET'
+CTRL_REP = 'REPLY'
+CTRL_ERR = 'ERR'
+CTRL_TRAP = 'TRAP'
+
+def _l(self, d, p):
+"""
+Reverse dictionary lookup: return key for a given value
+"""
+if p is None:
+return 'UNKNOWN'
+return list(d.keys())[list(d.values()).index(p)]
+
+def _tag(self, t, v):
+"""
+Create TAG as TLV data
+"""
+return struct.pack(">HB", len(v) + 1, t) + v
+
+def proto(self, p):
+"""
+Lookup protocol name
+"""
+return self._l(self.PROTO, p)
+
+def ext(self, p):
+"""
+Lookup protocol extension name
+"""
+return self._l(self.EXT, p)
+
+def msgt(self, p):
+"""
+Lookup message type name
+"""
+return self._l(self.MSGT, p)
+
+def idtag(self, p):
+"""
+Lookup ID tag name
+"""
+return self._l(self._IDTAG, p)
+
+def ext_name(self, proto, exten):
+"""
+Return proper extension byte name depending on the protocol used
+"""
+if self.PROTO['CCM'] == proto:
+return self.msgt(exten)
+if self.PROTO['OSMO'] == proto:
+return self.ext(exten)
+return None
+
+def add_header(self, data, proto, ext=None):
+"""
+Add IPA header (with extension if necessary), data must be represented 
as bytes
+"""
+if ext is None:
+return struct.pack(">HB", len(data) + 1, proto) + data
+return struct.pack(">HBB", len(data) + 1, proto, ext) + data
+
+def del_header(self, data):
+"""
+Strip IPA protocol header correctly removing extension if present
+Returns data length, IPA protocol, extension (or None if not 

[PATCH] osmo-hlr[master]: add CTRL tests for enable-/disable-/status-ps

2017-09-25 Thread Neels Hofmeyr

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

add CTRL tests for enable-/disable-/status-ps

Change-Id: I014437db9c0f15d818e04810f6cb14bf475ee002
---
M tests/ctrl_test_runner.py
1 file changed, 42 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/64/4064/1

diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
index d453197..7c14f50 100644
--- a/tests/ctrl_test_runner.py
+++ b/tests/ctrl_test_runner.py
@@ -163,6 +163,46 @@
 return responses
 
 
+class TestCtrlHLR(TestCtrlBase):
+
+HLR_DB = 'hlr_ctrl_test.db'
+HLR_SQL = '%s/sql/hlr.sql' % confpath
+HLR_TEST_SQL = '%s/tests/test_subscriber.sql' % confpath
+
+def setUp(self):
+print('\n')
+print(os.getcwd())
+assert subprocess.call('sqlite3 %s < %s' % (self.HLR_DB, 
self.HLR_SQL), shell=True) == 0
+assert subprocess.call('sqlite3 %s < %s' % (self.HLR_DB, 
self.HLR_TEST_SQL), shell=True) == 0
+super(TestCtrlHLR, self).setUp()
+
+def tearDown(self):
+super(TestCtrlHLR, self).tearDown()
+os.unlink("hlr_ctrl_test.db")
+
+def ctrl_command(self):
+return ["./src/osmo-hlr", "-c", "doc/examples/osmo-hlr.cfg", '-l', 
'hlr_ctrl_test.db']
+
+def ctrl_app(self):
+return (4259, "./src/osmo-hlr", "OsmoHLR", "hlr")
+
+def testCtrlErrs(self):
+r = self.do_get('invalid')
+self.assertEquals(r['mtype'], 'ERROR')
+self.assertEquals(r['error'], 'Command not found')
+
+def testEnableDisablePs(self):
+self.assert_set('enable-ps', '9019901', 'OK')
+self.assert_set('status-ps', '9019901', '1')
+self.assert_set('enable-ps', '9019901', 'OK')
+self.assert_set('status-ps', '9019901', '1')
+self.assert_set('disable-ps', '9019901', 'OK')
+self.assert_set('status-ps', '9019901', '0')
+self.assert_set('disable-ps', '9019901', 'OK')
+self.assert_set('status-ps', '9019901', '0')
+self.assert_set('enable-ps', '9019901', 'OK')
+self.assert_set('status-ps', '9019901', '1')
+
 if __name__ == '__main__':
 import argparse
 import sys
@@ -193,6 +233,8 @@
 os.chdir(workdir)
 print "Running tests for specific control commands"
 suite = unittest.TestSuite()
+test = unittest.TestLoader().loadTestsFromTestCase(TestCtrlHLR)
+suite.addTest(test)
 res = unittest.TextTestRunner(verbosity=verbose_level).run(suite)
 sys.exit(len(res.errors) + len(res.failures))
 

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

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


libosmocore[master]: VTY: implement talloc context introspection command

2017-09-25 Thread Vadim Yanitskiy

Patch Set 3:

(4 comments)

https://gerrit.osmocom.org/#/c/4018/3/src/vty/talloc_ctx_vty.c
File src/vty/talloc_ctx_vty.c:

Line 56:  * @param depth Current depth value
> What's the meaning of negative depth?
There is no meaning.


Line 58:  * @param is_refIs this chunk a reference?
> So it's always used as boolean? Than the type should be bool.
Well, this way I would have to rewrite the talloc library API.
This definition was taken from the talloc documentation,
and by changing types we will get a compiler warning. No way ;)


Line 73:p->depth_pass = 0;
> Sorry, I'm still kinda lost between all the goto and checks. Here you assig
No problem, I will add a brief description here.
Read the bottom comment first, please.

So, a filter is being bypassed while current depth value is
higher than the 'depth_pass', i.e. the callback does processing
the child memory chunks. As soon as this condition becomes false,
we need to 'enable' a filter, and resume the processing other chunks.


Line 92:p->depth_pass = depth;
> But here it's overwritten unless the return was triggered inside the switch
In short, as soon as a filter passes any chunk, all the memory
tree starting from one would be printed. To do that, we need to
temporary 'disable' a filter for child chunks (depth > current).

So, the 'depth_pass' is used to store a depth value, from which
a filter is being bypassed.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


[PATCH] osmo-sgsn[master]: Remove unneeded dep libdbi

2017-09-25 Thread Pau Espin Pedrol

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

Remove unneeded dep libdbi

This dependency is not needed and it's most probably a left over from
openbsc git repository split.

Change-Id: I84b0e2851dc89dca39e87215c71e93457acb884f
---
M configure.ac
M debian/control
2 files changed, 0 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/61/4061/1

diff --git a/configure.ac b/configure.ac
index d5d80cc..532b977 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,6 @@
 
 dnl checks for header files
 AC_HEADER_STDC
-AC_CHECK_HEADERS(dbi/dbd.h,,AC_MSG_ERROR(DBI library is not installed))
 
 found_pcap=yes
 AC_CHECK_HEADERS(pcap/pcap.h,,found_pcap=no)
diff --git a/debian/control b/debian/control
index 4a3a07f..ce2167a 100644
--- a/debian/control
+++ b/debian/control
@@ -13,8 +13,6 @@
libtalloc-dev,
libc-ares-dev,
libgtp-dev,
-   libdbi-dev,
-   libdbd-sqlite3,
libosmocore-dev,
libosmo-abis-dev,
libosmo-ranap-dev,

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

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


libosmocore[master]: Add time conversion helpers

2017-09-25 Thread Pau Espin Pedrol

Patch Set 2: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[PATCH] libosmocore[master]: Add time conversion helpers

2017-09-25 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/4060

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

Add time conversion helpers

Add macros to break down absolute time in seconds into days/hours/minutes
passed.

Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
---
M include/osmocom/core/timer.h
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/4060/2

diff --git a/include/osmocom/core/timer.h b/include/osmocom/core/timer.h
index 40b39b9..4958efb 100644
--- a/include/osmocom/core/timer.h
+++ b/include/osmocom/core/timer.h
@@ -45,6 +45,11 @@
 #include 
 #include 
 
+/* convert absolute time (in seconds) to elapsed days/hours/minutes */
+#define OSMO_SEC2MIN(sec) ((sec % (60 * 60)) / 60)
+#define OSMO_SEC2HRS(sec) ((sec % (60 * 60 * 24)) / (60 * 60))
+#define OSMO_SEC2DAY(sec) ((sec % (60 * 60 * 24 * 365)) / (60 * 60 * 24)) /* 
we ignore leap year for simplicity */
+
 /*! A structure representing a single instance of a timer */
 struct osmo_timer_list {
struct rb_node node;  /*!< rb-tree node header */

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] libosmocore[master]: Add time conversion helpers

2017-09-25 Thread Max

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

Add time conversion helpers

Add macros to break down absolute time in seconds into days/hors/minutes
passed.

Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
---
M include/osmocom/core/timer.h
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/4060/1

diff --git a/include/osmocom/core/timer.h b/include/osmocom/core/timer.h
index 40b39b9..4958efb 100644
--- a/include/osmocom/core/timer.h
+++ b/include/osmocom/core/timer.h
@@ -45,6 +45,11 @@
 #include 
 #include 
 
+/* convert absolute time (in seconds) to elapsed days/hours/minutes */
+#define OSMO_SEC2MIN(sec) ((sec % (60 * 60)) / 60)
+#define OSMO_SEC2HRS(sec) ((sec % (60 * 60 * 24)) / (60 * 60))
+#define OSMO_SEC2DAY(sec) ((sec % (60 * 60 * 24 * 365)) / (60 * 60 * 24)) /* 
we ignore leap year for simplicity */
+
 /*! A structure representing a single instance of a timer */
 struct osmo_timer_list {
struct rb_node node;  /*!< rb-tree node header */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46b9a405c18ed9da8f31b7d5b6dcece5468bafbf
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 


osmo-pcu[master]: EDGE: fix wrong encoding of LH bits

2017-09-25 Thread Minh-Quang Nguyen

Patch Set 1:

> (2 comments)

Using two successive "bitvec_set_bit(dest, H)" will be a good idea to avoid to 
introduce a new API in libosmocore.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I75dd5bebc74eea85edf9582607c774d0bba0d2a6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Minh-Quang Nguyen 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Minh-Quang Nguyen 
Gerrit-HasComments: No


osmo-bsc[master]: Show OML link uptime in vty

2017-09-25 Thread Pau Espin Pedrol

Patch Set 3: Code-Review-1

(3 comments)

https://gerrit.osmocom.org/#/c/4009/3/src/libbsc/bsc_vty.c
File src/libbsc/bsc_vty.c:

Line 317:   sec = (unsigned long 
long)difftime(tp.tv_sec, bts->uptime);
Make sure bts->uptime is also taken from MONOTONIC clock, otherwise you can get 
strange values with difftime. You should definetly not mix times using 
different clock sources. Specially because later on, you use ctime() with 
bts->uptime. So, as conclusion, one of the two parts of the code is wrong.
I think it makes sense to use a monotonic clock to print the elapsed time, but 
you should be using a wall clock to print the ctime part, because a monotonic 
clock doesn't need to contain similar values than a wall clock (which would 
print really weird dates). This way it can also be seen easily if there has 
been some type of big clock drift and understand better the real time it has 
been up.


Strictly speaking I am not sure it's actually good using difftime for this, 
because according to man page it expects calendar clocks and afaik MONOTONIC 
clock doesn't follow that rule. Anyway, implementation wise it's only 
substracting one with another which seems like the expected behaviour.


Line 318:   vty_out(vty, " %llu days %llu 
hours %llu min. %llu sec. since %s",
All this code in here looks like a good candidate to be moved to its own 
function. libosmocore ./include/osmocom/core/timer.h (or a new time_util.h) may 
be a good idea.

function timespec_to_elapsed(char *buf, timespec *tp) or similar?


Line 319:   (sec % (60 * 60 * 24 * 
365)) / (60 * 60 * 24),
may be nice to also move all this operations to different macros in the same 
header file? may come handy later in other parts.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9e4e8504afe8ca467b68d41826f61654e24d9600
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


[PATCH] libosmocore[master]: VTY: implement talloc context introspection command

2017-09-25 Thread Vadim Yanitskiy
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/4018

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

VTY: implement talloc context introspection command

This change introduces a new command, which could be used to
inspect the application's talloc context directly from VTY.
To enable this feature, an application need to provide it's
context via the 'vty_app_info' struct, and register the VTY
command by calling the osmo_talloc_vty_add_cmds().

The new command is a sub-command of 'show':

  show talloc-context   [filter]

Currently the following contexts may be inspected:

  - application - a context provided by an application;
  - null - all contexts, if NULL-context tracking is enabled.

A report depth is defined by the next parameter, and could be:

  - full - full tree report, as the talloc_report_full() does;
  - brief - brief tree report, as the talloc_report() does;
  - DEPTH - user defined maximal report depth.

Also, there are two optional report filters:

  - regexp - print only contexts, matching a regular expression;
  - tree - print a specific context, pointed by specified address.

The command output is formatted the same way as in case of calling
the talloc_report() or talloc_report_full().

Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
---
M include/osmocom/vty/misc.h
M src/vty/Makefile.am
A src/vty/talloc_ctx_vty.c
3 files changed, 274 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/4018/3

diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h
index 545955c..335558d 100644
--- a/include/osmocom/vty/misc.h
+++ b/include/osmocom/vty/misc.h
@@ -28,6 +28,7 @@
 void vty_out_fsm(struct vty *vty, struct osmo_fsm *fsm);
 void vty_out_fsm_inst(struct vty *vty, struct osmo_fsm_inst *fsmi);
 void osmo_fsm_vty_add_cmds(void);
+void osmo_talloc_vty_add_cmds(void);
 
 
 int osmo_vty_write_config_file(const char *filename);
diff --git a/src/vty/Makefile.am b/src/vty/Makefile.am
index e083a1c..1dc76c3 100644
--- a/src/vty/Makefile.am
+++ b/src/vty/Makefile.am
@@ -10,7 +10,8 @@
 lib_LTLIBRARIES = libosmovty.la
 
 libosmovty_la_SOURCES = buffer.c command.c vty.c vector.c utils.c \
-   telnet_interface.c logging_vty.c stats_vty.c fsm_vty.c
+   telnet_interface.c logging_vty.c stats_vty.c \
+   fsm_vty.c talloc_ctx_vty.c
 libosmovty_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined 
$(TALLOC_LIBS)
 libosmovty_la_LIBADD = $(top_builddir)/src/libosmocore.la
 endif
diff --git a/src/vty/talloc_ctx_vty.c b/src/vty/talloc_ctx_vty.c
new file mode 100644
index 000..7652200
--- /dev/null
+++ b/src/vty/talloc_ctx_vty.c
@@ -0,0 +1,271 @@
+/*! \file talloc_ctx_vty.c
+ * Osmocom talloc context introspection via VTY. */
+/*
+ * (C) 2017 by Vadim Yanitskiy 
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+extern void *tall_vty_ctx;
+extern struct host host;
+
+enum walk_filter_type {
+   WALK_FILTER_NONE = 0,
+   WALK_FILTER_REGEXP,
+   WALK_FILTER_TREE,
+};
+
+struct walk_cb_params {
+   enum walk_filter_type filter;
+   unsigned int depth_pass;
+   const void *chunk_ptr;
+   struct vty *vty;
+   regex_t regexp;
+};
+
+/*!
+ * Print a talloc memory hierarchy to the given VTY.
+ * To be called by the talloc_report_depth_cb().
+ * If one of supported filters is specified, then
+ * only satisfying memory trees would be printed.
+ *
+ * @param chunk The talloc chunk to be printed
+ * @param depth Current depth value
+ * @param max_depth Maximal depth of report (negative means full)
+ * @param is_refIs this chunk a reference?
+ * @param data  The walk_cb_params struct instance
+ */
+static void talloc_ctx_walk_cb(const void *chunk, int depth,
+   int max_depth, int is_ref, void *data)
+{
+   struct walk_cb_params *p = (struct walk_cb_params *) data;
+   const char *chunk_name = talloc_get_name(chunk);
+   struct vty *vty = p->vty;
+   int rc;
+
+   if (depth > 0 && p->filter) {
+   if (p->depth_pass && depth > p->depth_pass)
+   goto 

[PATCH] libosmocore[master]: VTY: implement talloc context introspection command

2017-09-25 Thread Vadim Yanitskiy
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/4018

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

VTY: implement talloc context introspection command

This change introduces a new command, which could be used to
inspect the application's talloc context directly from VTY.
To enable this feature, an application need to provide it's
context via the 'vty_app_info' struct, and register the VTY
command by calling the osmo_talloc_vty_add_cmds().

The new command is a sub-command of 'show':

  show talloc-context   [filter]

Currently the following contexts may be inspected:

  - application - a context provided by an application;
  - null - all contexts, if NULL-context tracking is enabled.

A report depth is defined by the next parameter, and could be:

  - full - full tree report, as the talloc_report_full() does;
  - brief - brief tree report, as the talloc_report() does;
  - DEPTH - user defined maximal report depth.

Also, there are two optional report filters:

  - regexp - print only contexts, matching a regular expression;
  - tree - print a specific context, pointed by specified address.

Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
---
M include/osmocom/vty/misc.h
M src/vty/Makefile.am
A src/vty/talloc_ctx_vty.c
3 files changed, 274 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/4018/2

diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h
index 545955c..335558d 100644
--- a/include/osmocom/vty/misc.h
+++ b/include/osmocom/vty/misc.h
@@ -28,6 +28,7 @@
 void vty_out_fsm(struct vty *vty, struct osmo_fsm *fsm);
 void vty_out_fsm_inst(struct vty *vty, struct osmo_fsm_inst *fsmi);
 void osmo_fsm_vty_add_cmds(void);
+void osmo_talloc_vty_add_cmds(void);
 
 
 int osmo_vty_write_config_file(const char *filename);
diff --git a/src/vty/Makefile.am b/src/vty/Makefile.am
index e083a1c..1dc76c3 100644
--- a/src/vty/Makefile.am
+++ b/src/vty/Makefile.am
@@ -10,7 +10,8 @@
 lib_LTLIBRARIES = libosmovty.la
 
 libosmovty_la_SOURCES = buffer.c command.c vty.c vector.c utils.c \
-   telnet_interface.c logging_vty.c stats_vty.c fsm_vty.c
+   telnet_interface.c logging_vty.c stats_vty.c \
+   fsm_vty.c talloc_ctx_vty.c
 libosmovty_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined 
$(TALLOC_LIBS)
 libosmovty_la_LIBADD = $(top_builddir)/src/libosmocore.la
 endif
diff --git a/src/vty/talloc_ctx_vty.c b/src/vty/talloc_ctx_vty.c
new file mode 100644
index 000..7652200
--- /dev/null
+++ b/src/vty/talloc_ctx_vty.c
@@ -0,0 +1,271 @@
+/*! \file talloc_ctx_vty.c
+ * Osmocom talloc context introspection via VTY. */
+/*
+ * (C) 2017 by Vadim Yanitskiy 
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+extern void *tall_vty_ctx;
+extern struct host host;
+
+enum walk_filter_type {
+   WALK_FILTER_NONE = 0,
+   WALK_FILTER_REGEXP,
+   WALK_FILTER_TREE,
+};
+
+struct walk_cb_params {
+   enum walk_filter_type filter;
+   unsigned int depth_pass;
+   const void *chunk_ptr;
+   struct vty *vty;
+   regex_t regexp;
+};
+
+/*!
+ * Print a talloc memory hierarchy to the given VTY.
+ * To be called by the talloc_report_depth_cb().
+ * If one of supported filters is specified, then
+ * only satisfying memory trees would be printed.
+ *
+ * @param chunk The talloc chunk to be printed
+ * @param depth Current depth value
+ * @param max_depth Maximal depth of report (negative means full)
+ * @param is_refIs this chunk a reference?
+ * @param data  The walk_cb_params struct instance
+ */
+static void talloc_ctx_walk_cb(const void *chunk, int depth,
+   int max_depth, int is_ref, void *data)
+{
+   struct walk_cb_params *p = (struct walk_cb_params *) data;
+   const char *chunk_name = talloc_get_name(chunk);
+   struct vty *vty = p->vty;
+   int rc;
+
+   if (depth > 0 && p->filter) {
+   if (p->depth_pass && depth > p->depth_pass)
+   goto filter_bypass;
+   else
+   p->depth_pass = 0;
+
+   switch (p->filter) {

libosmocore[master]: VTY: implement talloc context introspection command

2017-09-25 Thread Max

Patch Set 1:

> The output is the same as in case of calling the talloc_report() or 
> talloc_report_full().

Just add this to commit message.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-bsc[master]: Show OML link uptime in vty

2017-09-25 Thread Max
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/4009

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

Show OML link uptime in vty

Save the time when OML link to BTS was established and show it in
vty. That's useful when troubleshooting issues like periodic/sporadic
BTS restart.

Related: SYS#3889
Change-Id: I9e4e8504afe8ca467b68d41826f61654e24d9600
---
M include/osmocom/bsc/gsm_data_shared.h
M src/libbsc/bsc_vty.c
M src/libbsc/bts_ipaccess_nanobts.c
M src/libbsc/e1_config.c
4 files changed, 33 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/09/4009/3

diff --git a/include/osmocom/bsc/gsm_data_shared.h 
b/include/osmocom/bsc/gsm_data_shared.h
index 6ce571e..f41bac4 100644
--- a/include/osmocom/bsc/gsm_data_shared.h
+++ b/include/osmocom/bsc/gsm_data_shared.h
@@ -722,6 +722,8 @@
struct gsm_e1_subslot oml_e1_link;
uint8_t oml_tei;
struct e1inp_sign_link *oml_link;
+   /* when OML link was established */
+   time_t uptime;
 
/* Abis network management O handle */
struct abis_nm_h *nmh;
diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 3a80f06..addf97a 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -234,6 +235,9 @@
 static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
 {
struct pchan_load pl;
+   unsigned long long sec;
+   struct timespec tp;
+   int rc;
 
vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
"BSIC %u (NCC=%u, BCC=%u) and %u TRX%s",
@@ -304,8 +308,22 @@
paging_pending_requests_nr(bts),
bts->paging.available_slots, VTY_NEWLINE);
if (is_ipaccess_bts(bts)) {
-   vty_out(vty, "  OML Link state: %s.%s",
-   bts->oml_link ? "connected" : "disconnected", 
VTY_NEWLINE);
+   vty_out(vty, "  OML Link state: ");
+   if (bts->oml_link) {
+   vty_out(vty, "connected");
+   if (bts->uptime) {
+   rc = clock_gettime(CLOCK_MONOTONIC, );
+   if (rc == 0) { /* monotonic clock helps to 
ensure that conversion below is valid */
+   sec = (unsigned long 
long)difftime(tp.tv_sec, bts->uptime);
+   vty_out(vty, " %llu days %llu hours 
%llu min. %llu sec. since %s",
+   (sec % (60 * 60 * 24 * 365)) / 
(60 * 60 * 24),
+   (sec % (60 * 60 * 24)) / (60 * 
60),
+   (sec % (60 * 60)) / 60, sec % 
60, ctime(&(bts->uptime)));
+   }
+   }
+   vty_out(vty, "%s", VTY_NEWLINE);
+   } else
+   vty_out(vty, "disconnected.%s", VTY_NEWLINE);
} else {
vty_out(vty, "  E1 Signalling Link:%s", VTY_NEWLINE);
e1isl_dump_vty(vty, bts->oml_link);
diff --git a/src/libbsc/bts_ipaccess_nanobts.c 
b/src/libbsc/bts_ipaccess_nanobts.c
index 1f203f5..87ec7b2 100644
--- a/src/libbsc/bts_ipaccess_nanobts.c
+++ b/src/libbsc/bts_ipaccess_nanobts.c
@@ -20,6 +20,7 @@
  */
 
 #include 
+#include 
 
 #include 
 
@@ -364,6 +365,7 @@
 
e1inp_sign_link_destroy(bts->oml_link);
bts->oml_link = NULL;
+   bts->uptime = 0;
 
/* we have issues reconnecting RSL, drop everything. */
llist_for_each_entry(trx, >trx_list, list)
@@ -395,6 +397,8 @@
struct gsm_bts *bts;
struct ipaccess_unit *dev = unit_data;
struct e1inp_sign_link *sign_link = NULL;
+   struct timespec tp;
+   int rc;
 
bts = find_bts_by_unitid(bsc_gsmnet, dev->site_id, dev->bts_id);
if (!bts) {
@@ -423,6 +427,8 @@
e1inp_sign_link_create(>ts[E1INP_SIGN_OML - 1],
E1INP_SIGN_OML, bts->c0,
bts->oml_tei, 0);
+   rc = clock_gettime(CLOCK_MONOTONIC, );
+   bts->uptime = (rc < 0) ? 0 : tp.tv_sec; /* we don't need 
sub-second precision for uptime */
break;
case E1INP_SIGN_RSL: {
struct e1inp_ts *ts;
diff --git a/src/libbsc/e1_config.c b/src/libbsc/e1_config.c
index 1923efd..3656315 100644
--- a/src/libbsc/e1_config.c
+++ b/src/libbsc/e1_config.c
@@ -20,7 +20,7 @@
 
 #include 
 #include 
-
+#include 
 #include 
 
 #include 
@@ -160,6 +160,8 @@
struct e1inp_line *line;
struct e1inp_sign_link *oml_link;
struct gsm_bts_trx *trx;
+   struct timespec tp;
+   int rc;
 
DEBUGP(DLMI, "e1_reconfig_bts(%u)\n", bts->nr);
 
@@ -201,6 +203,8 @@
if 

[PATCH] openbsc[master]: Show OML link uptime in vty

2017-09-25 Thread Max
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/4008

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

Show OML link uptime in vty

Save the time when OML link to BTS was established and show it in
vty. That's useful when troubleshooting issues like periodic/sporadic
BTS restart.

Related: SYS#3889
Change-Id: I9e4e8504afe8ca467b68d41826f61654e24d9600
---
M openbsc/include/openbsc/gsm_data_shared.h
M openbsc/src/libbsc/bsc_vty.c
M openbsc/src/libbsc/bts_ipaccess_nanobts.c
M openbsc/src/libbsc/e1_config.c
4 files changed, 33 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/08/4008/3

diff --git a/openbsc/include/openbsc/gsm_data_shared.h 
b/openbsc/include/openbsc/gsm_data_shared.h
index 6b2269e..c19b125 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -715,6 +715,8 @@
struct gsm_e1_subslot oml_e1_link;
uint8_t oml_tei;
struct e1inp_sign_link *oml_link;
+   /* when OML link was established */
+   time_t uptime;
 
/* Abis network management O handle */
struct abis_nm_h *nmh;
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index c6ff6d5..ada2f3c 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -237,6 +238,9 @@
 static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
 {
struct pchan_load pl;
+   unsigned long long sec;
+   struct timespec tp;
+   int rc;
 
vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
"BSIC %u (NCC=%u, BCC=%u) and %u TRX%s",
@@ -307,8 +311,22 @@
paging_pending_requests_nr(bts),
bts->paging.available_slots, VTY_NEWLINE);
if (is_ipaccess_bts(bts)) {
-   vty_out(vty, "  OML Link state: %s.%s",
-   bts->oml_link ? "connected" : "disconnected", 
VTY_NEWLINE);
+   vty_out(vty, "  OML Link state: ");
+   if (bts->oml_link) {
+   vty_out(vty, "connected");
+   if (bts->uptime) {
+   rc = clock_gettime(CLOCK_MONOTONIC, );
+   if (rc == 0) { /* monotonic clock helps to 
ensure that conversion below is valid */
+   sec = (unsigned long 
long)difftime(tp.tv_sec, bts->uptime);
+   vty_out(vty, " %llu days %llu hours 
%llu min. %llu sec. since %s",
+   (sec % (60 * 60 * 24 * 365)) / 
(60 * 60 * 24),
+   (sec % (60 * 60 * 24)) / (60 * 
60),
+   (sec % (60 * 60)) / 60, sec % 
60, ctime(&(bts->uptime)));
+   }
+   }
+   vty_out(vty, "%s", VTY_NEWLINE);
+   } else
+   vty_out(vty, "disconnected.%s", VTY_NEWLINE);
} else {
vty_out(vty, "  E1 Signalling Link:%s", VTY_NEWLINE);
e1isl_dump_vty(vty, bts->oml_link);
diff --git a/openbsc/src/libbsc/bts_ipaccess_nanobts.c 
b/openbsc/src/libbsc/bts_ipaccess_nanobts.c
index a1bde77..64eb4f2 100644
--- a/openbsc/src/libbsc/bts_ipaccess_nanobts.c
+++ b/openbsc/src/libbsc/bts_ipaccess_nanobts.c
@@ -20,6 +20,7 @@
  */
 
 #include 
+#include 
 
 #include 
 
@@ -364,6 +365,7 @@
 
e1inp_sign_link_destroy(bts->oml_link);
bts->oml_link = NULL;
+   bts->uptime = 0;
 
/* we have issues reconnecting RSL, drop everything. */
llist_for_each_entry(trx, >trx_list, list)
@@ -395,6 +397,8 @@
struct gsm_bts *bts;
struct ipaccess_unit *dev = unit_data;
struct e1inp_sign_link *sign_link = NULL;
+   struct timespec tp;
+   int rc;
 
bts = find_bts_by_unitid(bsc_gsmnet, dev->site_id, dev->bts_id);
if (!bts) {
@@ -423,6 +427,8 @@
e1inp_sign_link_create(>ts[E1INP_SIGN_OML - 1],
E1INP_SIGN_OML, bts->c0,
bts->oml_tei, 0);
+   rc = clock_gettime(CLOCK_MONOTONIC, );
+   bts->uptime = (rc < 0) ? 0 : tp.tv_sec; /* we don't need 
sub-second precision for uptime */
break;
case E1INP_SIGN_RSL: {
struct e1inp_ts *ts;
diff --git a/openbsc/src/libbsc/e1_config.c b/openbsc/src/libbsc/e1_config.c
index d57dec5..92b2475 100644
--- a/openbsc/src/libbsc/e1_config.c
+++ b/openbsc/src/libbsc/e1_config.c
@@ -20,7 +20,7 @@
 
 #include 
 #include 
-
+#include 
 #include 
 
 #include 
@@ -160,6 +160,8 @@
struct e1inp_line *line;
struct e1inp_sign_link *oml_link;
struct gsm_bts_trx *trx;
+   

osmo-ci[master]: Prepare to deprecate legacy GPRS projects

2017-09-25 Thread André Boddenberg

Patch Set 2: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia49969cbfb9ef57b635a3b5759f411f71a54f8e1
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: André Boddenberg 
Gerrit-Reviewer: blobb 
Gerrit-Reviewer: lynxis lazus 
Gerrit-HasComments: No


[PATCH] osmo-ci[master]: Prepare to deprecate legacy GPRS projects

2017-09-25 Thread Max

Prepare to deprecate legacy GPRS projects

* use coverity check on osmo-ggsn instead of openggsn
* move osmo-sgsn and osmo-ggsn from nightly-split into nightly

Change-Id: Ia49969cbfb9ef57b635a3b5759f411f71a54f8e1
---
M coverity/build_Osmocom.sh
M coverity/prepare_source_Osmcocom.sh
M scripts/osmocom-nightly-nitb-split.sh
M scripts/osmocom-nightly-packages.sh
4 files changed, 6 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/56/4056/2

diff --git a/coverity/build_Osmocom.sh b/coverity/build_Osmocom.sh
index 58a74f2..bccd7ea 100755
--- a/coverity/build_Osmocom.sh
+++ b/coverity/build_Osmocom.sh
@@ -69,8 +69,8 @@
popd
 }
 
-build_openggsn() {
-   pushd openggsn
+build_osmoggsn() {
+   pushd osmo-ggsn
do_build
popd
 }
@@ -155,7 +155,7 @@
 build_libosmonetif
 build_libosmosccp
 build_libsmpp34
-build_openggsn
+build_osmoggsn
 #IU build_osmoiuh
 build_osmopcu
 build_osmobts
diff --git a/coverity/prepare_source_Osmcocom.sh 
b/coverity/prepare_source_Osmcocom.sh
index 6d226b2..386e16e 100755
--- a/coverity/prepare_source_Osmcocom.sh
+++ b/coverity/prepare_source_Osmcocom.sh
@@ -13,7 +13,7 @@
   libosmo-sccp \
   libsmpp34 \
   openbsc \
-  openggsn \
+  osmo-ggsn \
   osmo-bts \
   osmo-gmr \
   osmo-iuh \
diff --git a/scripts/osmocom-nightly-nitb-split.sh 
b/scripts/osmocom-nightly-nitb-split.sh
index 3b547bf..4484214 100755
--- a/scripts/osmocom-nightly-nitb-split.sh
+++ b/scripts/osmocom-nightly-nitb-split.sh
@@ -90,11 +90,9 @@
   checkout libasn1c
   checkout osmo-iuh
   checkout osmo-hlr
-  checkout osmo-ggsn
   checkout osmo-mgw
   checkout osmo-bsc
   checkout osmo-msc
-  checkout osmo-sgsn
 
   build libosmocore
   build libosmo-abis
@@ -104,11 +102,9 @@
   build libasn1c
   build osmo-iuh
   build osmo-hlr
-  build osmo-ggsn
   build osmo-mgw
   build osmo-bsc
   build osmo-msc
-  build osmo-sgsn
 
   post
 }
diff --git a/scripts/osmocom-nightly-packages.sh 
b/scripts/osmocom-nightly-packages.sh
index 84cf6e4..032bd49 100755
--- a/scripts/osmocom-nightly-packages.sh
+++ b/scripts/osmocom-nightly-packages.sh
@@ -14,7 +14,7 @@
 git clone git://git.osmocom.org/libosmo-abis
 git clone git://git.osmocom.org/libosmo-netif
 git clone git://git.osmocom.org/libsmpp34
-git clone git://git.osmocom.org/openggsn
+git clone git://git.osmocom.org/osmo-sgsn
 git clone git://git.osmocom.org/osmo-ggsn
 git clone git://git.osmocom.org/openbsc
 git clone git://git.osmocom.org/osmo-pcap
@@ -51,7 +51,7 @@
 build libosmo-abis
 build libosmo-netif
 build libsmpp34
-build openggsn
+build osmo-sgsn
 build osmo-ggsn
 build openbsc
 build osmo-pcap

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia49969cbfb9ef57b635a3b5759f411f71a54f8e1
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: blobb 
Gerrit-Reviewer: lynxis lazus 


osmo-mgw[master]: Initially implement the new osmo-mgw and libosmo-mgcp

2017-09-25 Thread Neels Hofmeyr

Patch Set 6:

(last patch set pushed by me for pmaier, from osmo-mgw/pmaier/mgw5)

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie008599136c7ed8a0dfbb0cf803188975a499fc5
Gerrit-PatchSet: 6
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[PATCH] osmo-mgw[master]: Initially implement the new osmo-mgw and libosmo-mgcp

2017-09-25 Thread Neels Hofmeyr
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/4003

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

Initially implement the new osmo-mgw and libosmo-mgcp

Leave the old osmo-bsc_mgcp and libosmo-legacy-mgcp as it is; on a copy thereof
(added by a previous commit), apply changes to initially implement the new
osmo-mgw.

Adjust build system and debian packaging to accomodate the new libosmo-mgcp and
osmo-mgw.

The main differences:

*) use a list to manage rtp connections.

Aggregate all rtp related information inside a single struct.

Use a linked list to manage the both connections (net and bts).
The idea behind using a list is that we might support conference
calls at some later point.

Store the linked list in struct mgcp_endpoint, have a private linked
list for each endpoint. The list contains connection items which are
implemented in struct mgcp_conn. A connection is allocated and freed
using the functions in mgcp_conn.c. A connection is allocated on the
reception of a CRCX command and freed with the reception of a DLCX
command.

*) remove external transcoder feature

Fortunatelly the external transcoder feature is not needed
anymore. This patch removes the related code.

*) vty: get rid of CONN_BTS and CONN_NET

Since the new connection model does not make a difference
between BTS and NET connections the VTY should not use
the fixed CONN_BTS and CONN_NET constants.

- Handle the conns list inside the endpoint directly
- introduce function to dump basic rtp connection info
- introduce human readable names for connections

Parts of the code adjusted to use generalized connections instead of explicit
BTS/NET ones:

- teach mgcp_send_dummy() to send dummy packets to any RTP connection
- network: generalize mgcp_bind_net/bts_rtp_port()
- network: generalize mgcp_send()
- tap: generalize call tapping feature
- stat: generalize statistics
- Replace rtp_data_net() and rtp_data_bts() with generalized rtp_data_rx()

*) mgcp_protocol.c fixes:

- check ci string before it is converted:
  In case of missing ci, a nullpointer is delivered to strtoul().
  Add a function that takes ci, checks it and converts it to an
  uint32_t. Use the return code to react on missing ci.
- output error message on missing CI.
- when parsing the mode, print log message when mode is missing.
- use mode_orig when mode is missing.
- fix ptime formatstring to use %u rather than %d.
- cosmetic: log when connection is deleted on DLCX.
- change loglevels of CRCX, MDCX, DLCX events from DEBUG to NOTICE.

*) mgcp_test

- apply rename of strline_r() to mgcp_strline().
- MGCP command macros:
  - Add 'I: 1' parameters.
  - Use proper port numbers:
from m=audio 0 RTP/AVP 126
to   m=audio 16002 RTP/AVP 128
  - Change ptime to 'a=ptime:40' because this is what the MGW currently
returns.  CRCX generally feed a ptime:40 and this is expected to be
returned.
- struct mgcp_test: Use only one ptype, there are no explicit BTS and NET
  endpoints anymore.
  Hence remove one column from tests[].
- test_messages():
  - Enable: remove '#if 0'
  - Remove concept of BTS and NET endpoints: test only one conn, as they are
now interchangeable anyway.
  - remove endpoint init, now done internally.
  - add false asserts in error cases.
- test_retransmission():
  - remove endpoint init, now done internally.
  - add false asserts in error cases.
- test_packet_error_detection():
  - Remove concept of BTS and NET endpoints: test only one conn, as they are
now interchangeable anyway. Use arbitrary conn ids (e.g. 4711).
  - remove endpoint init, now done internally.
  - add false assert in error case.
  - Assert that a conn really vanishes on DLCX, previously the conn would
remain and just be unused, now it is actually discarded.
- test_no_cycle()
  - Remove concept of BTS and NET endpoints: test only one conn, as they are
now interchangeable anyway. Use arbitrary conn ids (e.g. 4711).
- test_no_name()
  - Enable: remove '#if 0'.
  - remove endpoint init, now done internally.
  - add false assert in error case.
- mgcp_test.ok: adjust expected results to status quo:
  - We now see two dummy packets instead of one, now sent to both sides because
we don't know of BTS or NET side. (maybe drop dummy packets later...)
  - packet duration, conn mode: now sane defaults show instead of unset.
- various whitespace and formatting changes from lindent.

Change-Id: Ie008599136c7ed8a0dfbb0cf803188975a499fc5
---
M Makefile.am
M configure.ac
M debian/control
A debian/libosmo-mgcp-dev.install
A debian/libosmo-mgcp0.install
M doc/examples/osmo-mgw/osmo-mgw.cfg
M include/Makefile.am
M include/osmocom/Makefile.am
M include/osmocom/mgcp/Makefile.am
M include/osmocom/mgcp/mgcp.h
A include/osmocom/mgcp/mgcp_conn.h
M include/osmocom/mgcp/mgcp_internal.h
A include/osmocom/mgcp/mgcp_msg.h
A include/osmocom/mgcp/mgcp_stat.h
D include/osmocom/mgcp/mgcp_transcode.h
M include/osmocom/mgcp/osmux.h
A libosmo-mgcp.pc.in
M 

[PATCH] osmo-bts[master]: Remove dead code

2017-09-25 Thread Max

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

Remove dead code

If I understood correctly, it's just leftover from copy-paste from
corresponding OpenBSC code which is untouched for years.

Change-Id: Ia5e3dc10efe2b5ab212cab1518a10d36b20b8bb2
---
M src/common/vty.c
1 file changed, 0 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/57/4057/1

diff --git a/src/common/vty.c b/src/common/vty.c
index de9b23f..444b19c 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -762,24 +762,6 @@
VTY_NEWLINE);
vty_out(vty, "  CBCH backlog queue length: %u%s",
llist_length(>smscb_state.queue), VTY_NEWLINE);
-#if 0
-   vty_out(vty, "  Paging: %u pending requests, %u free slots%s",
-   paging_pending_requests_nr(bts),
-   bts->paging.available_slots, VTY_NEWLINE);
-   if (is_ipaccess_bts(bts)) {
-   vty_out(vty, "  OML Link state: %s.%s",
-   bts->oml_link ? "connected" : "disconnected", 
VTY_NEWLINE);
-   } else {
-   vty_out(vty, "  E1 Signalling Link:%s", VTY_NEWLINE);
-   e1isl_dump_vty(vty, bts->oml_link);
-   }
-
-   /* FIXME: chan_desc */
-   memset(, 0, sizeof(pl));
-   bts_chan_load(, bts);
-   vty_out(vty, "  Current Channel Load:%s", VTY_NEWLINE);
-   dump_pchan_load_vty(vty, "", );
-#endif
 }
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5e3dc10efe2b5ab212cab1518a10d36b20b8bb2
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-bts[master]: vty: print version and description for each phy

2017-09-25 Thread Max

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

vty: print version and description for each phy

When printing BTS via 'show bts ..' let's also print each TRX, why phy
number and version it uses and its description. It's helpful in
troubleshooting low-level issues as it allows vendor-specific code to
easily expose firmware version.

Related: SYS#3884
Change-Id: Iabcc862566b40a9314f3e1d17fda61d8ab24a3cd
---
M src/common/vty.c
1 file changed, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/58/4058/1

diff --git a/src/common/vty.c b/src/common/vty.c
index 444b19c..6714041 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -730,6 +730,7 @@
 static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
 {
struct gsm_bts_role_bts *btsb = bts->role;
+   struct gsm_bts_trx *trx;
 
vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
"BSIC %u and %u TRX%s",
@@ -762,6 +763,17 @@
VTY_NEWLINE);
vty_out(vty, "  CBCH backlog queue length: %u%s",
llist_length(>smscb_state.queue), VTY_NEWLINE);
+
+   llist_for_each_entry(trx, >trx_list, list) {
+   struct phy_instance *pinst = trx_phy_instance(trx);
+   vty_out(vty, "  TRX %u%s", trx->nr, VTY_NEWLINE);
+   if (pinst) {
+   vty_out(vty, "phy %d %s", pinst->num, 
pinst->version);
+   if (pinst->description)
+   vty_out(vty, " (%s)", pinst->description);
+   vty_out(vty, "%s", VTY_NEWLINE);
+   }
+   }
 }
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iabcc862566b40a9314f3e1d17fda61d8ab24a3cd
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 


libosmocore[master]: VTY: implement talloc context introspection command

2017-09-25 Thread Max

Patch Set 1:

(5 comments)

Also, example output of 'sh talloc-context ..' in commit message would be nice.

https://gerrit.osmocom.org/#/c/4018/1/src/vty/talloc_ctx_vty.c
File src/vty/talloc_ctx_vty.c:

Line 48: 
I think it's big enough to warrant doxygen header with explanation of what it 
does and what's the meaning of parameters.


Line 50:int max_depth, int is_ref, void *data)
If it's 'int' than it means that it could be negative. Please either explain 
when this is the case or use unsigned type.


Line 63:if (p->filter == WALK_FILTER_REGEXP) {
So you explicitly check for 2 possible enum values and implicitly for 3rd one. 
I think switch() would be easier to read because all possible values are 
checked explicitly.


Line 139:   params = talloc_zero(tall_vty_ctx, struct walk_cb_params);
Will this allocation be included in the report too?


Line 229:   talloc_free(params);
The params are always alloced/freed in the same function. Do we have to use 
dynamic allocation? What would be disadvantage of having 'params' as local 
variable which address is passed down to talloc_ctx_walk()?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I43fc42880b22294d83c565ae600ac65e4f38b30d
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: Yes


[MERGED] libosmo-sccp[master]: simple client: prevent overwriting asp settings

2017-09-25 Thread dexter
dexter has submitted this change and it was merged.

Change subject: simple client: prevent overwriting asp settings
..


simple client: prevent overwriting asp settings

If the user does not create an AS, but creates an ASP with a name
that is equal to the default name, then the simple client detects
that and trys to use this ASP. However, unfortunately it then
overwrites the settings of the ASP with the default settings.

If the detected ASP is not created by the simple client, use it,
but preseve the settings of that ASP.

Change-Id: I53d73059f804c3bbea6cb43dc73ad49a753b3b15
---
M src/sccp_user.c
1 file changed, 27 insertions(+), 12 deletions(-)

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



diff --git a/src/sccp_user.c b/src/sccp_user.c
index 06a7174..21b2eed 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -414,20 +414,35 @@
 * we intend to use. */
asp = osmo_ss7_asp_find_by_proto(as, prot);
if (!asp) {
-   LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating ASP instance\n",
-name);
+   /* Check if the user has already created an ASP elsewhere under
+* the default asp name. */
asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name);
-   asp =
-   osmo_ss7_asp_find_or_create(ss7, asp_name,
-   default_remote_port,
-   default_local_port, prot);
-   talloc_free(asp_name);
-   if (!asp)
-   goto out_rt;
-   asp_created = true;
+   asp = osmo_ss7_asp_find_by_name(ss7, asp_name);
+   if (!asp) {
+   LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating ASP instance\n",
+name);
+   asp =
+   osmo_ss7_asp_find_or_create(ss7, asp_name,
+   default_remote_port,
+   default_local_port,
+   prot);
+   talloc_free(asp_name);
+   if (!asp)
+   goto out_rt;
+   asp_created = true;
 
-   asp->cfg.local.host = default_local_ip ? talloc_strdup(asp, 
default_local_ip) : NULL;
-   asp->cfg.remote.host = default_remote_ip ? talloc_strdup(asp, 
default_remote_ip) : NULL;
+   asp->cfg.local.host = NULL;
+   asp->cfg.remote.host = NULL;
+   if (default_local_ip) {
+   asp->cfg.local.host =
+   talloc_strdup(asp, default_local_ip);
+   }
+   if (default_remote_ip) {
+   asp->cfg.remote.host =
+   talloc_strdup(asp, default_remote_ip);
+   }
+   } else
+   talloc_free(asp_name);
 
osmo_ss7_as_add_asp(as, asp->cfg.name);
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I53d73059f804c3bbea6cb43dc73ad49a753b3b15
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 


[ABANDON] libosmo-sccp[master]: vty: command to set local ip of ASP

2017-09-25 Thread dexter
dexter has abandoned this change.

Change subject: vty: command to set local ip of ASP
..


Abandoned

This change violates the command concept of Cisco ITP

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

Gerrit-MessageType: abandon
Gerrit-Change-Id: I115b87b08bdc4b07772b7afb9c25bc713e79945a
Gerrit-PatchSet: 3
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter 


libosmocore[master]: vty/vty.c: do not bind vty context to application's one

2017-09-25 Thread Max

Patch Set 1: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9cb6ce9f24dbae400029e2d9f9c933fbfb16248f
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[PATCH] osmo-ggsn[master]: Move extended PDP logging macro to header

2017-09-25 Thread Max
Hello Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/3961

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

Move extended PDP logging macro to header

It might be useful for any user of libgtp who uses libosmocore so let's
make generalized version of it available as part of installable header.

Change-Id: I79aba10ef989384a28f059c30899e65c771ae5e1
Related: SYS#3610
---
M TODO-RELEASE
M ggsn/ggsn.c
M gtp/pdp.h
3 files changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/61/3961/4

diff --git a/TODO-RELEASE b/TODO-RELEASE
index e38e18c..1009c44 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -8,3 +8,4 @@
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library   whatdescription / commit summary line
 libgtp pdp.h   Addition of new tx_gpdu_seq struct member member
+libgtp pdp.h   add LOGPDPX() helper to public API
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 780a0c2..462b395 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -83,8 +83,7 @@
 #define LOGPGGSN(level, ggsn, fmt, args...)\
LOGP(DGGSN, level, "GGSN(%s): " fmt, (ggsn)->cfg.name, ## args)
 
-#define LOGPPDP(level, pdp, fmt, args...)  \
-   LOGP(DGGSN, level, "PDP(%s:%u): " fmt, imsi_gtp2str(&(pdp)->imsi), 
(pdp)->nsapi, ## args)
+#define LOGPPDP(level, pdp, fmt, args...) LOGPDPX(DGGSN, level, pdp, fmt, ## 
args)
 
 static int ggsn_tun_fd_cb(struct osmo_fd *fd, unsigned int what);
 static int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len);
diff --git a/gtp/pdp.h b/gtp/pdp.h
index f8b0df8..106d544 100644
--- a/gtp/pdp.h
+++ b/gtp/pdp.h
@@ -17,6 +17,9 @@
 
 struct gsn_t;
 
+#define LOGPDPX(ss, level, pdp, fmt, args...)  \
+   LOGP(ss, level, "PDP(%s:%u): " fmt, imsi_gtp2str(&(pdp)->imsi), 
(pdp)->nsapi, ## args)
+
 #define PDP_MAX 1024   /* Max number of PDP contexts */
 #define PDP_MAXNSAPI 16/* Max number of NSAPI */
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I79aba10ef989384a28f059c30899e65c771ae5e1
Gerrit-PatchSet: 4
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[MERGED] osmo-gsm-manuals[master]: Expand OsmoGGSN manual

2017-09-25 Thread Max
Max has submitted this change and it was merged.

Change subject: Expand OsmoGGSN manual
..


Expand OsmoGGSN manual

* add cross-references
* add example of running without root priviledges

Change-Id: I1743f370ee2b351d2847f2e29e0f59f35cd401f4
---
M OsmoGGSN/chapters/configuration.adoc
M common/chapters/bibliography.adoc
2 files changed, 55 insertions(+), 8 deletions(-)

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



diff --git a/OsmoGGSN/chapters/configuration.adoc 
b/OsmoGGSN/chapters/configuration.adoc
index e37b709..9e07fb6 100644
--- a/OsmoGGSN/chapters/configuration.adoc
+++ b/OsmoGGSN/chapters/configuration.adoc
@@ -1,7 +1,7 @@
 == Configuring OsmoGGSN
 
 All configuration of OsmoGGSN is performed using the VTY. For more
-general information on the VTY interface, see FIXME.
+general information on the VTY interface, see <>.
 
 === Configuring a virtual GGSN instance
 
@@ -49,7 +49,7 @@
 configure the properties of this GGSN instance.
 
 NOTE:: After creating a new GGSN instance, it is in `shutdown` mode. See
-FIXME to take it out of shutdown, but make sure to configure it fully
+<> to take it out of shutdown, but make sure to configure it 
fully
 before taking it out of shutdown.
 
  Configuring a GGSN instance
@@ -66,7 +66,7 @@
 
 There are some further configuration statements that can be used at the
 GGSN node, some examples are given below.  For a full list, see the
-OpenGGSN VTY reference manual (FIXME).
+_OsmoGGSN VTY reference manual_ <>.
 
 
 OsmoGGSN(config-ggsn)# default-apn foobar <1>
@@ -152,7 +152,7 @@
 <5> Your prompt is now in the `ggsn` config node, where you can
 configure the properties of this GGSN instance.
 
-NOTE:: The newly-create APN is created in `shutdown` mode. See FIXME to take it
+NOTE:: The newly-create APN is created in `shutdown` mode. See 
<> to take it
 out of shutdown.
 
 
@@ -178,7 +178,7 @@
 NOTE:: If you use the optional `ip ifconfig` command to set the network
 device address/mask, OsmoGGSN must run with root or `CAP_NET_ADMIN`
 support.  It might be better to configure related tun devices at system
-startup and run OsmoGGSN as non-privileged user.  See FIXME for more
+startup and run OsmoGGSN as non-privileged user.  See <> for more
 details.
 
 
@@ -198,7 +198,7 @@
 <3> Enter the config node of the GGSN instance `ggsn0`
 <4> Delete the APN `internet`
 
-
+[[unshutdown_apn]]
  Taking an APN out of shutdown
 
 In order to bring a deactived APN in `shutdown` state into active
@@ -241,3 +241,48 @@
 <4> Enter the config ndoe of the APN `internet`
 <5> Shut down the APN
 
+[[ggsn_no_root]]
+=== Configuring for running without root priveleges
+
+It's possible to run OsmoGGSN without root privileges if the tun devices are 
already configured.
+
+.Example: device config via systemd-networkd using ggsn.netdev
+
+[NetDev]
+Name=ggsn
+Kind=tun
+
+[Tun]
+User=username
+Group=username
+
+
+.Example: network settings via systemd-networkd using ggsn.network
+
+[Match]
+Name=ggsn
+
+[Network]
+Address=192.168.7.1
+IPMasquerade=yes
+
+
+The pair of the configuration files above allows you to create and configure 
tun device which can be
+used by OsmoGGSN as follows.
+
+.Example: using externally configured tun device as non-root
+
+ggsn ggsn0
+ gtp state-dir /tmp
+ gtp bind-ip 127.0.0.6
+ apn internet
+  gtpu-mode tun
+  tun-device ggsn
+  type-support v4
+  ip prefix dynamic 192.168.7.0/24
+  ip dns 0 192.168.100.1
+  ip dns 1 8.8.8.8
+  no shutdown
+ default-apn internet
+ no shutdown ggsn
+
diff --git a/common/chapters/bibliography.adoc 
b/common/chapters/bibliography.adoc
index a3c6436..9d4c234 100644
--- a/common/chapters/bibliography.adoc
+++ b/common/chapters/bibliography.adoc
@@ -26,8 +26,10 @@
   http://ftp.osmocom.org/docs/latest/osmosgsn-usermanual.pdf
 - [[[vty-ref-osmosgsn]]] Osmocom Project: OsmoSGSN VTY Reference Manual.
   http://ftp.osmocom.org/docs/latest/osmonitb-vty-reference.pdf
-//- [[[userman-openggsn]]] Osmocom Project: OpenGGSN User Manual.
-
+- [[[userman-osmoggsn]]] Osmocom Project: OpenGGSN User Manual.
+  http://ftp.osmocom.org/docs/latest/osmoggsn-usermanual.pdf
+- [[[vty-ref-osmoggsn]]] Osmocom Project: OsmoGGSN VTY Reference Manual.
+  http://ftp.osmocom.org/docs/latest/osmoggsn-vty-reference.pdf
 - [[[3gpp-ts-23-048]]] 3GPP TS 23.048: Security mechanisms for the
   (U)SIM application toolkit; Stage 2
   http://www.3gpp.org/DynaReport/23048.htm

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1743f370ee2b351d2847f2e29e0f59f35cd401f4
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: 

[MERGED] osmo-sgsn[master]: gbproxy: ensure peer allocation result

2017-09-25 Thread Max
Max has submitted this change and it was merged.

Change subject: gbproxy: ensure peer allocation result
..


gbproxy: ensure peer allocation result

gbproxy_peer_alloc() could return NULL which wasn't checked and used
right away. Fix it by making this assumption explicit with
OSMO_ASSERT(); While at it, also format log messages consistently.

Change-Id: Ib10c954e17a479baef31ded54370b35938e00018
---
M src/gprs/gb_proxy.c
1 file changed, 2 insertions(+), 2 deletions(-)

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



diff --git a/src/gprs/gb_proxy.c b/src/gprs/gb_proxy.c
index eb2bbcc..17a0109 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -1018,9 +1018,9 @@
if (!from_peer) {
/* if a PTP-BVC is reset, and we don't know that
 * PTP-BVCI yet, we should allocate a new peer 
*/
-   LOGP(DGPRS, LOGL_INFO, "Allocationg new peer 
for "
-"BVCI=%u via NSEI=%u\n", bvci, nsei);
+   LOGP(DGPRS, LOGL_INFO, "Allocationg new peer 
for BVCI=%u via NSEI=%u\n", bvci, nsei);
from_peer = gbproxy_peer_alloc(cfg, bvci);
+   OSMO_ASSERT(from_peer);
from_peer->nsei = nsei;
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib10c954e17a479baef31ded54370b35938e00018
Gerrit-PatchSet: 2
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 


[MERGED] osmo-bsc[master]: CTRL: cleanup write-only command functions

2017-09-25 Thread Max
Max has submitted this change and it was merged.

Change subject: CTRL: cleanup write-only command functions
..


CTRL: cleanup write-only command functions

Remove trivial functions by using more specific defines for CTRL
commands.

Change-Id: I10d6d18663aed87324d60472a0fc3bd1d0961dea
---
M src/osmo-bsc/osmo_bsc_ctrl.c
1 file changed, 3 insertions(+), 31 deletions(-)

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



diff --git a/src/osmo-bsc/osmo_bsc_ctrl.c b/src/osmo-bsc/osmo_bsc_ctrl.c
index 2446312..6330892 100644
--- a/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -466,13 +466,7 @@
return 1;
 }
 
-CTRL_CMD_DEFINE(net_notification, "notification");
-static int get_net_notification(struct ctrl_cmd *cmd, void *data)
-{
-   cmd->reply = "There is nothing to read";
-   return CTRL_CMD_ERROR;
-}
-
+CTRL_CMD_DEFINE_WO_NOVRF(net_notification, "notification");
 static int set_net_notification(struct ctrl_cmd *cmd, void *data)
 {
struct ctrl_cmd *trap;
@@ -502,18 +496,7 @@
return CTRL_CMD_HANDLED;
 }
 
-static int verify_net_notification(struct ctrl_cmd *cmd, const char *value, 
void *data)
-{
-   return 0;
-}
-
-CTRL_CMD_DEFINE(net_inform_msc, "inform-msc-v1");
-static int get_net_inform_msc(struct ctrl_cmd *cmd, void *data)
-{
-   cmd->reply = "There is nothing to read";
-   return CTRL_CMD_ERROR;
-}
-
+CTRL_CMD_DEFINE_WO_NOVRF(net_inform_msc, "inform-msc-v1");
 static int set_net_inform_msc(struct ctrl_cmd *cmd, void *data)
 {
struct gsm_network *net;
@@ -540,18 +523,7 @@
return CTRL_CMD_HANDLED;
 }
 
-static int verify_net_inform_msc(struct ctrl_cmd *cmd, const char *value, void 
*data)
-{
-   return 0;
-}
-
-CTRL_CMD_DEFINE(net_ussd_notify, "ussd-notify-v1");
-static int get_net_ussd_notify(struct ctrl_cmd *cmd, void *data)
-{
-   cmd->reply = "There is nothing to read";
-   return CTRL_CMD_ERROR;
-}
-
+CTRL_CMD_DEFINE_WO(net_ussd_notify, "ussd-notify-v1");
 static int set_net_ussd_notify(struct ctrl_cmd *cmd, void *data)
 {
struct gsm_subscriber_connection *conn;

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

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


[MERGED] openbsc[master]: CTRL: cleanup write-only command functions

2017-09-25 Thread Max
Max has submitted this change and it was merged.

Change subject: CTRL: cleanup write-only command functions
..


CTRL: cleanup write-only command functions

Remove trivial functions by using more specific defines for CTRL
commands.

Change-Id: I719b75b6ca1e9372ea11e7e9ff7896021f357035
---
M openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
1 file changed, 3 insertions(+), 31 deletions(-)

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



diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c 
b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
index c23ed21..423ed34 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -466,13 +466,7 @@
return 1;
 }
 
-CTRL_CMD_DEFINE(net_notification, "notification");
-static int get_net_notification(struct ctrl_cmd *cmd, void *data)
-{
-   cmd->reply = "There is nothing to read";
-   return CTRL_CMD_ERROR;
-}
-
+CTRL_CMD_DEFINE_WO_NOVRF(net_notification, "notification");
 static int set_net_notification(struct ctrl_cmd *cmd, void *data)
 {
struct ctrl_cmd *trap;
@@ -502,18 +496,7 @@
return CTRL_CMD_HANDLED;
 }
 
-static int verify_net_notification(struct ctrl_cmd *cmd, const char *value, 
void *data)
-{
-   return 0;
-}
-
-CTRL_CMD_DEFINE(net_inform_msc, "inform-msc-v1");
-static int get_net_inform_msc(struct ctrl_cmd *cmd, void *data)
-{
-   cmd->reply = "There is nothing to read";
-   return CTRL_CMD_ERROR;
-}
-
+CTRL_CMD_DEFINE_WO_NOVRF(net_inform_msc, "inform-msc-v1");
 static int set_net_inform_msc(struct ctrl_cmd *cmd, void *data)
 {
struct gsm_network *net;
@@ -540,18 +523,7 @@
return CTRL_CMD_HANDLED;
 }
 
-static int verify_net_inform_msc(struct ctrl_cmd *cmd, const char *value, void 
*data)
-{
-   return 0;
-}
-
-CTRL_CMD_DEFINE(net_ussd_notify, "ussd-notify-v1");
-static int get_net_ussd_notify(struct ctrl_cmd *cmd, void *data)
-{
-   cmd->reply = "There is nothing to read";
-   return CTRL_CMD_ERROR;
-}
-
+CTRL_CMD_DEFINE_WO(net_ussd_notify, "ussd-notify-v1");
 static int set_net_ussd_notify(struct ctrl_cmd *cmd, void *data)
 {
struct gsm_subscriber_connection *conn;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I719b75b6ca1e9372ea11e7e9ff7896021f357035
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 


[MERGED] osmo-bsc[master]: Further cleanup leftovers from BSC/MSC split

2017-09-25 Thread Max
Max has submitted this change and it was merged.

Change subject: Further cleanup leftovers from BSC/MSC split
..


Further cleanup leftovers from BSC/MSC split

* drop unused header
* fix name of jenkins test
* remove dead code

Change-Id: I986904864741995910b6ba92173b9f7b1b03e2f1
---
M contrib/jenkins.sh
M include/osmocom/bsc/Makefile.am
M include/osmocom/bsc/gsm_data.h
D include/osmocom/bsc/osmo_msc.h
M src/libbsc/bsc_init.c
M tests/gsm0408/gsm0408_test.c
6 files changed, 1 insertion(+), 131 deletions(-)

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



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 2685d04..eb302d1 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -33,7 +33,7 @@
 echo
 echo
 echo
-echo " === osmo-msc 
==="
+echo " === osmo-bsc 
==="
 echo
 set -x
 
diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am
index 3b8dbdf..8ad2b5d 100644
--- a/include/osmocom/bsc/Makefile.am
+++ b/include/osmocom/bsc/Makefile.am
@@ -42,7 +42,6 @@
osmo_bsc.h \
osmo_bsc_grace.h \
osmo_bsc_rf.h \
-   osmo_msc.h \
osmo_bsc_sigtran.h \
bsc_msc_data.h \
osmux.h \
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index d7f7667..4e56db5 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -670,7 +670,6 @@
 
 /* control interface handling */
 int bsc_base_ctrl_cmds_install(void);
-int msc_ctrl_cmds_install(struct gsm_network *net);
 
 /* dependency handling */
 void bts_depend_mark(struct gsm_bts *bts, int dep);
diff --git a/include/osmocom/bsc/osmo_msc.h b/include/osmocom/bsc/osmo_msc.h
deleted file mode 100644
index c08cb26..000
--- a/include/osmocom/bsc/osmo_msc.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Routines for the MSC handling */
-
-#ifndef OSMO_MSC_H
-#define OSMO_MSC_H
-
-#include 
-#include 
-
-#include 
-
-#include "bsc_api.h"
-
-#define MSC_HLR_REMOTE_IP_DEFAULT "127.0.0.1"
-#define MSC_HLR_REMOTE_PORT_DEFAULT OSMO_GSUP_PORT
-
-enum subscr_conn_fsm_event {
-   /* Mark 0 as invalid to catch uninitialized vars */
-   SUBSCR_CONN_E_INVALID = 0,
-   /* Timeout on connection establishment starts */
-   SUBSCR_CONN_E_START,
-   /* LU or Process Access FSM has determined that this conn is good */
-   SUBSCR_CONN_E_ACCEPTED,
-   /* received first reply from MS in "real" CC, SMS, USSD communication */
-   SUBSCR_CONN_E_COMMUNICATING,
-   /* Some async action has completed, check again whether all is done */
-   SUBSCR_CONN_E_BUMP,
-   /* MS/BTS/BSC originated close request */
-   SUBSCR_CONN_E_MO_CLOSE,
-   /* MSC originated close request, e.g. failed authentication */
-   SUBSCR_CONN_E_CN_CLOSE,
-};
-
-enum subscr_conn_fsm_state {
-   SUBSCR_CONN_S_INIT,
-   SUBSCR_CONN_S_NEW,
-   SUBSCR_CONN_S_ACCEPTED,
-   SUBSCR_CONN_S_COMMUNICATING,
-   SUBSCR_CONN_S_RELEASED,
-};
-
-enum subscr_conn_from {
-   SUBSCR_CONN_FROM_INVALID,
-   SUBSCR_CONN_FROM_LU,
-   SUBSCR_CONN_FROM_CM_SERVICE_REQ,
-   SUBSCR_CONN_FROM_PAGING_RESP,
-};
-
-extern const struct value_string subscr_conn_from_names[];
-static inline const char *subscr_conn_from_name(enum subscr_conn_from val)
-{
-   return get_value_string(subscr_conn_from_names, val);
-}
-
-enum msc_compl_l3_rc {
-   MSC_CONN_ACCEPT = 0,
-   MSC_CONN_REJECT = 1,
-};
-
-struct bsc_api *msc_bsc_api();
-
-int msc_create_conn_fsm(struct gsm_subscriber_connection *conn, const char 
*id);
-
-int msc_vlr_alloc(struct gsm_network *net);
-int msc_vlr_start(struct gsm_network *net);
-
-void msc_sapi_n_reject(struct gsm_subscriber_connection *conn, int dlci);
-int msc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause);
-int msc_compl_l3(struct gsm_subscriber_connection *conn,
-struct msgb *msg, uint16_t chosen_channel);
-void msc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id,
- struct msgb *msg);
-void msc_cipher_mode_compl(struct gsm_subscriber_connection *conn,
-  struct msgb *msg, uint8_t alg_id);
-void msc_rx_sec_mode_compl(struct gsm_subscriber_connection *conn);
-void msc_classmark_chg(struct gsm_subscriber_connection *conn,
-  const uint8_t *cm2, uint8_t cm2_len,
-  const uint8_t *cm3, uint8_t cm3_len);
-void msc_assign_fail(struct gsm_subscriber_connection *conn,
-uint8_t cause, uint8_t *rr_cause);
-
-void msc_subscr_conn_init(void);
-bool msc_subscr_conn_is_accepted(struct gsm_subscriber_connection *conn);
-void msc_subscr_conn_communicating(struct gsm_subscriber_connection *conn);
-void msc_subscr_conn_close(struct gsm_subscriber_connection *conn,
-  

[PATCH] osmo-ci[master]: Prepare to deprecate legacy GPRS projects

2017-09-25 Thread Max

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

Prepare to deprecate legacy GPRS projects

* use coverity check on osmo-ggsn instead of openggsn
* move osmo-sgsn from nightly-split into nightly

Change-Id: Ia49969cbfb9ef57b635a3b5759f411f71a54f8e1
---
M coverity/build_Osmocom.sh
M coverity/prepare_source_Osmcocom.sh
M scripts/osmocom-nightly-nitb-split.sh
M scripts/osmocom-nightly-packages.sh
4 files changed, 6 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/56/4056/1

diff --git a/coverity/build_Osmocom.sh b/coverity/build_Osmocom.sh
index 58a74f2..bccd7ea 100755
--- a/coverity/build_Osmocom.sh
+++ b/coverity/build_Osmocom.sh
@@ -69,8 +69,8 @@
popd
 }
 
-build_openggsn() {
-   pushd openggsn
+build_osmoggsn() {
+   pushd osmo-ggsn
do_build
popd
 }
@@ -155,7 +155,7 @@
 build_libosmonetif
 build_libosmosccp
 build_libsmpp34
-build_openggsn
+build_osmoggsn
 #IU build_osmoiuh
 build_osmopcu
 build_osmobts
diff --git a/coverity/prepare_source_Osmcocom.sh 
b/coverity/prepare_source_Osmcocom.sh
index 6d226b2..386e16e 100755
--- a/coverity/prepare_source_Osmcocom.sh
+++ b/coverity/prepare_source_Osmcocom.sh
@@ -13,7 +13,7 @@
   libosmo-sccp \
   libsmpp34 \
   openbsc \
-  openggsn \
+  osmo-ggsn \
   osmo-bts \
   osmo-gmr \
   osmo-iuh \
diff --git a/scripts/osmocom-nightly-nitb-split.sh 
b/scripts/osmocom-nightly-nitb-split.sh
index 3b547bf..8448459 100755
--- a/scripts/osmocom-nightly-nitb-split.sh
+++ b/scripts/osmocom-nightly-nitb-split.sh
@@ -94,7 +94,6 @@
   checkout osmo-mgw
   checkout osmo-bsc
   checkout osmo-msc
-  checkout osmo-sgsn
 
   build libosmocore
   build libosmo-abis
@@ -108,7 +107,6 @@
   build osmo-mgw
   build osmo-bsc
   build osmo-msc
-  build osmo-sgsn
 
   post
 }
diff --git a/scripts/osmocom-nightly-packages.sh 
b/scripts/osmocom-nightly-packages.sh
index 84cf6e4..032bd49 100755
--- a/scripts/osmocom-nightly-packages.sh
+++ b/scripts/osmocom-nightly-packages.sh
@@ -14,7 +14,7 @@
 git clone git://git.osmocom.org/libosmo-abis
 git clone git://git.osmocom.org/libosmo-netif
 git clone git://git.osmocom.org/libsmpp34
-git clone git://git.osmocom.org/openggsn
+git clone git://git.osmocom.org/osmo-sgsn
 git clone git://git.osmocom.org/osmo-ggsn
 git clone git://git.osmocom.org/openbsc
 git clone git://git.osmocom.org/osmo-pcap
@@ -51,7 +51,7 @@
 build libosmo-abis
 build libosmo-netif
 build libsmpp34
-build openggsn
+build osmo-sgsn
 build osmo-ggsn
 build openbsc
 build osmo-pcap

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia49969cbfb9ef57b635a3b5759f411f71a54f8e1
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Owner: Max 


osmo-mgw[master]: Initially implement the new osmo-mgw and libosmo-mgcp

2017-09-25 Thread dexter

Patch Set 5:

(20 comments)

> New patch set from dexter's branch pmaier/mgw4 and my own
 > adjustments. For the record, submitted the patch set without asking
 > dexter first, I hope it's not premature.

Thanks for adjusting the patch. My main concern at the moment is how to move on 
with OSMUX. I think I can not fix the OSMUX related issues on the short run. I 
would need to learn more about osmox, how it works, how it is used. I would 
prefer to merge the patch without addressing the OSMUX issues at the moment.

https://gerrit.osmocom.org/#/c/4003/4/include/osmocom/mgcp/mgcp.h
File include/osmocom/mgcp/mgcp.h:

Line 37: 
> why do we have a default range end of only 10 ports higher than the start p
Done


https://gerrit.osmocom.org/#/c/4003/4/include/osmocom/mgcp/mgcp_internal.h
File include/osmocom/mgcp/mgcp_internal.h:

Line 114:   /* Each end has a separate socket for RTP and RTCP */
> separate
Done


Line 149:   /* Specific connection type */
> the 'rtp_end' structure made sense when we had a bts_end and a net_end. Now
I think so too, removing one level would make handling the struct a lot easier. 
I will keep that in in mind.


Line 193:   /*!< Backpointer to the endpoint where the conn belongs to */
> should this be some enum? or at least the comment above state what kind of 
Done


Line 223:(e.g mgcp_dispatch_rtp_bridge_cb, see below) */
> if it's an endpoint type, mgcp_endpoint_type might be a better name
having enum mgcp_type here type is wrong. This is something that is specific to 
an RTP connection only. I have moved it.


https://gerrit.osmocom.org/#/c/4003/4/src/libosmo-mgcp/mgcp_conn.c
File src/libosmo-mgcp/mgcp_conn.c:

Line 72: /*! \brief allocate a new connection list entry
> as the connection list is per endpoint, it might make sense to pass in the 
Done


Line 82:struct mgcp_conn *conn;
> this is something specific to the "rtp bridge/proxy" endpoint type.  I sugg
Done


Line 93:return NULL;
> rather than the enum, this would be a pointer to the 'const struct rtp_endp
This sets the type of the connection, so its not about the endpoint here. (We 
mainly use this to determine how to access the union.) However, this brings me 
to another thought. If we have various possible connection types. 
rtp_endpoint_type should have some bitfield with allowed connection types. But 
thats is not in the scope of this patch I think.


Line 105:   strcpy(conn->name, name);
> why does mgpc_rtp_end_reset() not set those -1 values above?
Done


Line 123: /*! \brief find a connection by its ID
> Is there a connection list outside of the context of a struct mgcp_endpoint
Done


PS4, Line 169: ns.next != NULL && endp
> I wonder when do we need this.  The below linear iteration seems quite expe
Done


Line 225: }
> What if the list is empty?
Done


https://gerrit.osmocom.org/#/c/4003/4/src/libosmo-mgcp/mgcp_network.c
File src/libosmo-mgcp/mgcp_network.c:

Line 704: 
> using an any of the libosmocore counters might be an idea here, rather than
I think its best to solve this in a separate patch. I have created a task, so 
we do not forget about this. https://osmocom.org/issues/2517


Line 806:ENDPOINT_NUMBER(endp));
> see my other comment, as the socket/fd is part of the mgcp connection, priv
Done


Line 889:* port and IP-Address make sense at all. If not, we will be 
unable
> see my other comment, this is a highly inefficient lookup, and we appear to
Done


Line 911:   }
> This lookup and the code below is again specific to the endpoint type. I wo
Done


https://gerrit.osmocom.org/#/c/4003/4/src/libosmo-mgcp/mgcp_osmux.c
File src/libosmo-mgcp/mgcp_osmux.c:

Line 126:   h->in->osmux_seq = 0;
> (whitespace)
Done


Line 205: 
> (whitespace)
Done


Line 585:   return;
> whitespace
Done


Line 613: 
> whitespace
Done


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie008599136c7ed8a0dfbb0cf803188975a499fc5
Gerrit-PatchSet: 5
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes