Change in python/osmo-python-tests[master]: ctrl2cgi: properly limit number of requests

2018-12-05 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12139


Change subject: ctrl2cgi: properly limit number of requests
..

ctrl2cgi: properly limit number of requests

Manual acquire()/release() of semaphore does not limit number of
concurrent requests when combined with explicit yield. Fix this by using
semaphore.run() and removing inilineCallbacks decorator.

Change-Id: I47b8b9f5b726ca0905bb7c023d63b325c7f7d85f
Related: SYS#4399
---
M scripts/ctrl2cgi.py
1 file changed, 9 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/39/12139/1

diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 1d90ee0..676fc11 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -60,6 +60,12 @@
 #print('HASH: \nparams="%r"\ninput="%s" \nres="%s"' %(params, input, res))
 return res

+def make_async_req(dst, par, f_write, f_log):
+d = post(dst, par)
+d.addCallback(collect, partial(handle_reply, f_write, f_log)) # treq's 
collect helper is handy to get all reply content at once
+d.addErrback(lambda e: f_log.critical("HTTP POST error %s while trying to 
register BSC %s on %s" % (e, par['bsc_id'], dst))) # handle HTTP errors
+return d
+
 class Trap(CTRL):
 """
 TRAP handler (agnostic to factory's client object)
@@ -93,7 +99,6 @@
 self.factory.log.info("Connected to CTRL@%s:%d" % 
(self.factory.addr_ctrl, self.factory.port_ctrl))
 super(CTRL, self).connectionMade()

-@defer.inlineCallbacks
 def handle_locationstate(self, net, bsc, bts, trx, data):
 """
 Handle location-state TRAP: parse trap content, build CGI Request and 
use treq's routines to post it while setting up async handlers
@@ -101,13 +106,8 @@
 params = make_params(bsc, data)
 self.factory.log.debug('location-state@%s.%s.%s.%s (%s) => %s' % (net, 
bsc, bts, trx, params['time_stamp'], data))
 params['h'] = gen_hash(params, self.factory.secret_key)
-d = post(self.factory.location, params)
-d.addCallback(collect, partial(handle_reply, self.transport.write, 
self.factory.log)) # treq's collect helper is handy to get all reply content at 
once
-d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error 
%s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), 
bsc) # handle HTTP errors
 # Ensure that we run only limited number of requests in parallel:
-yield self.factory.semaphore.acquire()
-yield d # we end up here only if semaphore is available which means 
it's ok to fire the request without exceeding the limit
-self.factory.semaphore.release()
+self.factory.semaphore.run(make_async_req, self.factory.location, 
params, self.transport.write, self.factory.log)

 def handle_notificationrejectionv1(self, net, bsc, bts, trx, data):
 """
@@ -121,7 +121,6 @@
 Store CGI information so TRAP handler can use it for requests
 """
 def __init__(self, proto, log):
-self.semaphore = defer.DeferredSemaphore(self.num_max_conn)
 self.log = log
 level = self.log.getEffectiveLevel()
 self.log.setLevel(logging.WARNING) # we do not need excessive debug 
from lower levels
@@ -155,6 +154,8 @@
 T.num_max_conn = config['main'].getint('num_max_conn', T.num_max_conn)
 T.secret_key = config['main'].get('secret_key', T.secret_key)

+T.semaphore = defer.DeferredSemaphore(T.num_max_conn)
+
 log.info("CGI proxy v%s starting with PID %d:" % (__version__, 
os.getpid()))
 log.info("destination %s (concurrency %d)" % (T.location, T.num_max_conn))
 log.info("connecting to %s:%d..." % (T.addr_ctrl, T.port_ctrl))

--
To view, visit https://gerrit.osmocom.org/12139
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I47b8b9f5b726ca0905bb7c023d63b325c7f7d85f
Gerrit-Change-Number: 12139
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in python/osmo-python-tests[master]: ctrl2cgi: fix broken config override

2018-12-05 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12134


Change subject: ctrl2cgi: fix broken config override
..

ctrl2cgi: fix broken config override

Previously command-line arguments without defaults took precedence over
config file variables while values from config file which had
command-line counterparts with default value were silently ignored.

Let's fix this by making config file values to be always preferred over
command-line equivalents.

The easiest way is to use TrapFactory as argparse namespace. This means
that some parameter values won't be known initially so logging is moved
directly to main.

Change-Id: I471b5a6497eadce6456e835233fdaba88a593324
Related: SYS#4399
---
M scripts/ctrl2cgi.py
1 file changed, 21 insertions(+), 39 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/34/12134/1

diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 1d6813d..89cbf50 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -22,7 +22,7 @@
  */
 """

-__version__ = "0.0.4" # bump this on every non-trivial change
+__version__ = "0.0.5" # bump this on every non-trivial change

 import argparse, os, logging, logging.handlers
 import hashlib
@@ -90,7 +90,7 @@
 """
 Logging wrapper, calling super() is necessary not to break 
reconnection logic
 """
-self.factory.log.info("Connected to CTRL@%s:%d" % (self.factory.host, 
self.factory.port))
+self.factory.log.info("Connected to CTRL@%s:%d" % 
(self.factory.addr_ctrl, self.factory.port_ctrl))
 super(CTRL, self).connectionMade()

 @defer.inlineCallbacks
@@ -120,25 +120,14 @@
 """
 Store CGI information so TRAP handler can use it for requests
 """
-location = None
-log = None
-semaphore = None
-client = None
-host = None
-port = None
-secret_key = None
-def __init__(self, host, port, proto, semaphore, log, location, 
secret_key):
-self.host = host # for logging only,
-self.port = port # seems to be no way to get it from 
ReconnectingClientFactory
+def __init__(self, proto, log):
+self.semaphore = defer.DeferredSemaphore(self.num_max_conn)
 self.log = log
-self.semaphore = semaphore
-self.location = location
-self.secret_key = secret_key
 level = self.log.getEffectiveLevel()
 self.log.setLevel(logging.WARNING) # we do not need excessive debug 
from lower levels
 super(TrapFactory, self).__init__(proto, self.log)
 self.log.setLevel(level)
-self.log.debug("Using IPA %s, CGI server: %s" % (Ctrl.version, 
self.location))
+self.log.debug("Using Osmocom IPA library v%s" % Ctrl.version)


 if __name__ == '__main__':
@@ -151,31 +140,24 @@
 p.add_argument('-o', '--output', action='store_true', help="Log to STDOUT 
in addition to SYSLOG")
 p.add_argument('-l', '--location', help="Location URL of the CGI server")
 p.add_argument('-s', '--secret-key', help="Secret key used to generate 
verification token")
-p.add_argument('-c', '--config-file', help="Path Config file. Cmd line 
args override values in config file")
-args = p.parse_args()
+p.add_argument('-c', '--config-file', help="Path to config file (in INI 
format). Values from config file override command line options.")
+args = p.parse_args(namespace=TrapFactory)

 log = debug_init('CTRL2CGI', args.debug, args.output)

-location_cfgfile = None
-secret_key_cfgfile = None
-port_ctrl_cfgfile = None
-addr_ctrl_cfgfile = None
-num_max_conn_cfgfile = None
-if args.config_file:
-config = configparser.ConfigParser()
-config.read(args.config_file)
-if 'main' in config:
-location_cfgfile = config['main'].get('location', None)
-secret_key_cfgfile = config['main'].get('secret_key', None)
-addr_ctrl_cfgfile = config['main'].get('addr_ctrl', None)
-port_ctrl_cfgfile = config['main'].get('port_ctrl', None)
-num_max_conn_cfgfile = config['main'].get('num_max_conn', None)
-location = args.location if args.location is not None else location_cfgfile
-secret_key = args.secret_key  if args.secret_key is not None else 
secret_key_cfgfile
-addr_ctrl = args.addr_ctrl if args.addr_ctrl is not None else 
addr_ctrl_cfgfile
-port_ctrl = args.port_ctrl if args.port_ctrl is not None else 
port_ctrl_cfgfile
-num_max_conn 

Change in python/osmo-python-tests[master]: Trap handlers: always log to stdout

2018-12-05 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12135


Change subject: Trap handlers: always log to stdout
..

Trap handlers: always log to stdout

Since the scripts are intended to be used as systemd services, there's
no need in separate logging via syslog: systemd will take care of
properly collecting and storing script output. Hence we can drop extra
options and function parameters.

Change-Id: Ifcad1877d45d43b3a2e617775a1c9b256e190591
Related: SYS#4399
---
M contrib/systemd/osmo-ctrl2cgi.service
M osmopy/trap_helper.py
M scripts/ctrl2cgi.py
M scripts/soap.py
4 files changed, 5 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/35/12135/1

diff --git a/contrib/systemd/osmo-ctrl2cgi.service 
b/contrib/systemd/osmo-ctrl2cgi.service
index 8563c66..f82e1e9 100644
--- a/contrib/systemd/osmo-ctrl2cgi.service
+++ b/contrib/systemd/osmo-ctrl2cgi.service
@@ -4,7 +4,7 @@
 [Service]
 Type=simple
 Restart=always
-ExecStart=/usr/bin/ctrl2cgi.py -o -d -c /etc/osmocom/ctrl2cgi.ini
+ExecStart=/usr/bin/ctrl2cgi.py -d -c /etc/osmocom/ctrl2cgi.ini
 RestartSec=2

 [Install]
diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index d4a3b75..45dc527 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -95,7 +95,7 @@
 sys.argv.remove(dbg2)
 os.execl(path, script, *sys.argv[1:])

-def debug_init(name, is_debug, output):
+def debug_init(name, is_debug):
 """
 Initialize signal handlers and logging
 """
@@ -104,9 +104,7 @@
 log.setLevel(logging.DEBUG)
 else:
 log.setLevel(logging.INFO)
-log.addHandler(logging.handlers.SysLogHandler('/dev/log'))
-if output:
-log.addHandler(logging.StreamHandler(sys.stdout))
+log.addHandler(logging.StreamHandler(sys.stdout))

 reboot = partial(reloader, os.path.abspath(__file__), 
os.path.basename(__file__), log, '-d', '--debug') # keep in sync with caller's 
add_argument()
 signal.signal(signal.SIGHUP, reboot)
diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 89cbf50..1d90ee0 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -137,13 +137,12 @@
 p.add_argument('-p', '--port-ctrl', type=int, default=4250, help="Port to 
use for CTRL interface, defaults to 4250")
 p.add_argument('-n', '--num-max-conn', type=int, default=5, help="Max 
number of concurrent HTTP requests to CGI server")
 p.add_argument('-d', '--debug', action='store_true', help="Enable debug 
log") # keep in sync with debug_init call below
-p.add_argument('-o', '--output', action='store_true', help="Log to STDOUT 
in addition to SYSLOG")
 p.add_argument('-l', '--location', help="Location URL of the CGI server")
 p.add_argument('-s', '--secret-key', help="Secret key used to generate 
verification token")
 p.add_argument('-c', '--config-file', help="Path to config file (in INI 
format). Values from config file override command line options.")
 args = p.parse_args(namespace=TrapFactory)

-log = debug_init('CTRL2CGI', args.debug, args.output)
+log = debug_init('CTRL2CGI', args.debug)

 T = TrapFactory(Trap, log)

diff --git a/scripts/soap.py b/scripts/soap.py
index 267b4d8..0534000 100755
--- a/scripts/soap.py
+++ b/scripts/soap.py
@@ -136,11 +136,10 @@
 p.add_argument('-w', '--wsdl', required=True, help="WSDL URL for SOAP")
 p.add_argument('-n', '--num', type=int, default=5, help="Max number of 
concurrent HTTP requests to SOAP server")
 p.add_argument('-d', '--debug', action='store_true', help="Enable debug 
log") # keep in sync with debug_init call below
-p.add_argument('-o', '--output', action='store_true', help="Log to STDOUT 
in addition to SYSLOG")
 p.add_argument('-l', '--location', help="Override location found in WSDL 
file (don't use unless you know what you're doing)")
 args = p.parse_args()

-log = debug_init('CTRL2SOAP', args.debug, args.output)
+log = debug_init('CTRL2SOAP', args.debug)

 log.info("SOAP proxy %s starting with PID %d ..." % (__version__, 
os.getpid()))
 reactor.connectTCP(args.ctrl, args.port, TrapFactory(args.ctrl, args.port, 
Trap, defer.DeferredSemaphore(args.num), log, args.wsdl, args.location))

--
To view, visit https://gerrit.osmocom.org/12135
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifcad1877d45d43b3a2e617775a1c9b256e190591
Gerrit-Change-Number: 12135
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in osmo-pcu[master]: vty: add commands to show TBF of a certain kind

2018-12-05 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/6239 )

Change subject: vty: add commands to show TBF of a certain kind
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/6239
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I80f8df4fe663a0346f4289a4220b761e39726312
Gerrit-Change-Number: 6239
Gerrit-PatchSet: 4
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Comment-Date: Wed, 05 Dec 2018 10:00:42 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in osmo-trx[master]: Add CTRL log category

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12120 )

Change subject: Add CTRL log category
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/12120/1/CommonLibs/debug.h
File CommonLibs/debug.h:

https://gerrit.osmocom.org/#/c/12120/1/CommonLibs/debug.h@8
PS1, Line 8:DCTRL,
I think it's too easy to confuse with DLCTRL from libosmocore. Maybe call it 
DCTRLIF or alike?



--
To view, visit https://gerrit.osmocom.org/12120
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I98ec5e416272783ad3fbadf70478a4e48ae64983
Gerrit-Change-Number: 12120
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Max 
Gerrit-Comment-Date: Tue, 04 Dec 2018 15:51:09 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS, TS 29.205: add GCR routines

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11827 )

Change subject: LCLS, TS 29.205: add GCR routines
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11827
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Gerrit-Change-Number: 11827
Gerrit-PatchSet: 19
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 13:37:19 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS, TS 48.008: add GCR IE encoding/decoding

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12020 )

Change subject: LCLS, TS 48.008: add GCR IE encoding/decoding
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/12020
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
Gerrit-Change-Number: 12020
Gerrit-PatchSet: 13
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 13:37:16 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: add gsm0808_create_ass2()

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11826 )

Change subject: LCLS: add gsm0808_create_ass2()
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11826
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Gerrit-Change-Number: 11826
Gerrit-PatchSet: 24
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Tue, 04 Dec 2018 13:37:13 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: Log: add stdout target

2018-12-04 Thread Max
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/12093

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

Change subject: Log: add stdout target
..

Log: add stdout target

This is useful for code testing internal library functions which allows
to automatically fail tests due to output mismatch.

As a side-effect this also simplifies #if-#else logic due to both
_stdout() and _stderr() now being simple wrappers around static
function.

No user-visible changes are introduced because stdout is ignored in vty
for now.

Change-Id: Ia786361f5f687e43b27d87a45b4630bca58bcfe8
---
M include/osmocom/core/logging.h
M src/logging.c
M src/vty/logging_vty.c
3 files changed, 37 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/12093/2
--
To view, visit https://gerrit.osmocom.org/12093
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia786361f5f687e43b27d87a45b4630bca58bcfe8
Gerrit-Change-Number: 12093
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Pau Espin Pedrol 


Change in libosmocore[master]: Allow log_init() with NULL log_info

2018-12-04 Thread Max
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/12092

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

Change subject: Allow log_init() with NULL log_info
..

Allow log_init() with NULL log_info

Since we have library-internal categories we don't have to force
application to supply its own categories. This is especially useful for
testing code inside libosmocore which only use internal categories
anyway.

Change-Id: I42159780b57684bff225789f036f28a4b25fc7b8
---
M src/logging.c
1 file changed, 15 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/92/12092/2
--
To view, visit https://gerrit.osmocom.org/12092
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I42159780b57684bff225789f036f28a4b25fc7b8
Gerrit-Change-Number: 12092
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Pau Espin Pedrol 


Change in libosmocore[master]: Logging: don't print hex category by default

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12095 )

Change subject: Logging: don't print hex category by default
..


Patch Set 2:

That's only the default behavior for library code. What applications used as a 
default setting is defined by the application code.


--
To view, visit https://gerrit.osmocom.org/12095
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I6dc3898958cf60147ad73c52cf0b3990bd26359e
Gerrit-Change-Number: 12095
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 12:36:15 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: Add osmo_init_logging_std*()

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12094 )

Change subject: Add osmo_init_logging_std*()
..


Patch Set 1:

> Yes, but it would fail to if you used osmo_init_logging_stdout here.

Sure, right now those are mutually exclusive.

> So that means you cannot configure stderr and stdout at the same time

That's correct.

> Please provide me with information if I'm not understanding it.

It's intended for tests which do not use vty and do not need to log to stderr 
and stdout at the same time - see commit message of this and previous patch.


--
To view, visit https://gerrit.osmocom.org/12094
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I0fe8dc4a41aba4e4509540266e229700e8ec083c
Gerrit-Change-Number: 12094
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 12:34:44 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: Log: add stdout target

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12093 )

Change subject: Log: add stdout target
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/12093/1/src/vty/logging_vty.c
File src/vty/logging_vty.c:

https://gerrit.osmocom.org/#/c/12093/1/src/vty/logging_vty.c@881
PS1, Line 881:  /* we don't support vty logging to stdout to avoid 
messing up vty prompt and user input */
> how are you supposed to run telnet on the same terminal if the terminal is 
> being used by the process […]
Send it to background with &.



--
To view, visit https://gerrit.osmocom.org/12093
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia786361f5f687e43b27d87a45b4630bca58bcfe8
Gerrit-Change-Number: 12093
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 12:30:26 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: Log: add stdout target

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12093 )

Change subject: Log: add stdout target
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/12093/1/src/vty/logging_vty.c
File src/vty/logging_vty.c:

https://gerrit.osmocom.org/#/c/12093/1/src/vty/logging_vty.c@881
PS1, Line 881:  /* we don't support vty logging to stdout to avoid 
messing up vty prompt and user input */
> I don't get that. Isn't VTY printing to a TCP soket? the one used by telnet.
Right, it'll only mess up if you run telnet in the same console where you've 
started the app. I'll update comment.



--
To view, visit https://gerrit.osmocom.org/12093
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia786361f5f687e43b27d87a45b4630bca58bcfe8
Gerrit-Change-Number: 12093
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 12:24:51 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: Logging: don't print hex category by default

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12095 )

Change subject: Logging: don't print hex category by default
..


Patch Set 2:

(1 comment)

I'd rather avoid changing several defaults in one patch.

https://gerrit.osmocom.org/#/c/12095/2/src/application.c
File src/application.c:

https://gerrit.osmocom.org/#/c/12095/2/src/application.c@141
PS2, Line 141:  log_set_print_category_hex(std, 0);
> Should we then add log_set_print_category(std, 1) here?
Why?



--
To view, visit https://gerrit.osmocom.org/12095
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I6dc3898958cf60147ad73c52cf0b3990bd26359e
Gerrit-Change-Number: 12095
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 12:09:49 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: Add osmo_init_logging_std*()

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12094 )

Change subject: Add osmo_init_logging_std*()
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/12094/1/tests/logging/logging_vty_test.c
File tests/logging/logging_vty_test.c:

https://gerrit.osmocom.org/#/c/12094/1/tests/logging/logging_vty_test.c@245
PS1, Line 245:  if (osmo_init_logging_stderr(root_ctx, &log_info) == 0) {
> AFAIU from application. […]
That's exactly what we test in here: we fail this test if 
osmo_init_logging_stderr() is not failing as it should.



--
To view, visit https://gerrit.osmocom.org/12094
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I0fe8dc4a41aba4e4509540266e229700e8ec083c
Gerrit-Change-Number: 12094
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 12:07:51 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: Log: add stdout target

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12093 )

Change subject: Log: add stdout target
..


Patch Set 1:

(2 comments)

As for rename - I can change it in the next revision.

https://gerrit.osmocom.org/#/c/12093/1/src/logging.c
File src/logging.c:

https://gerrit.osmocom.org/#/c/12093/1/src/logging.c@926
PS1, Line 926:  if (target->tgt_file.out != stdout)
> This looks wrong or at least really messy.
Could you elaborate? How else should it look like? And why you think it's wrong?


https://gerrit.osmocom.org/#/c/12093/1/src/vty/logging_vty.c
File src/vty/logging_vty.c:

https://gerrit.osmocom.org/#/c/12093/1/src/vty/logging_vty.c@881
PS1, Line 881:  /* we don't support vty logging to stdout to avoid 
messing up vty prompt and user input */
> I don't get what's the issue here.
Vty code prints to stdout. If we log to stdout as well, than user will see vty 
prompts interspersed with log output which looks really messy. That's why I'm 
reluctant to add stdout target to vty.



--
To view, visit https://gerrit.osmocom.org/12093
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia786361f5f687e43b27d87a45b4630bca58bcfe8
Gerrit-Change-Number: 12093
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 04 Dec 2018 12:06:05 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: msgb: add test helpers

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12017 )

Change subject: msgb: add test helpers
..


Patch Set 5:

(1 comment)

> I usually end up tailoring the debug output to the specific test.

You can continue doing that. I use those helpers in tests in 2 different 
patches in this series and it seem to work quite fine. I don't intend to 
accommodate to every imaginable use-case.

> when an error occurs, I sometimes needed the position of the difference 
> indicated (usually only during development cycles)

That was main motivation for me as well.

> Could add hex string API (in a later patch?)

I'm not really sure how this should look like so I think it's better to be 
expanded by the person who'd use it that way. It's simply more efficient than 
me trying to guess someone else's use-case and devise API for it.

> and could add difference position indicator (in a later patch?).

It's already there - the position is indicated by !! sign when printing msgb 
and data arrays side-by-side.

> Might be interesting to take a look through other msgb/buffer printing 
> routines flying around in various tests today? Maybe figure out a smaller set 
> of API satisfying all cases?

I'd rather not spend too much time on this. This patch emerged as a simple way 
to aid in testing LCLS-related encoders/decoders where I've got to compare 
rather long arrays and wanted to be able to easily see where they differ.

It would be nice to digg through msgb API but I'm afraid there're more pressing 
tasks ATM.

https://gerrit.osmocom.org/#/c/12017/5/src/msgb.c
File src/msgb.c:

https://gerrit.osmocom.org/#/c/12017/5/src/msgb.c@198
PS5, Line 198: printf
> one slight problem with LOGP could be that in regression tests, we often only 
> check stdout.
That should be fixed by additional patches before this one in latest revision.



--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
Gerrit-Change-Number: 12017
Gerrit-PatchSet: 5
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Comment-Date: Tue, 04 Dec 2018 12:01:28 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: msgb: add test helpers

2018-12-04 Thread Max
Hello Vadim Yanitskiy, Pau Espin Pedrol, Neels Hofmeyr, Harald Welte, Jenkins 
Builder,

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

https://gerrit.osmocom.org/12017

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

Change subject: msgb: add test helpers
..

msgb: add test helpers

It's often handy to compare certain msgb layer to a given array and
print the position where they differ. Add simple pretty-printer and
corresponding L* wrappers.

Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
---
M include/osmocom/core/msgb.h
M src/msgb.c
2 files changed, 231 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/17/12017/9
--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
Gerrit-Change-Number: 12017
Gerrit-PatchSet: 9
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 


Change in libosmocore[master]: Log: add stdout target

2018-12-04 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12093


Change subject: Log: add stdout target
..

Log: add stdout target

This is useful for code testing internal library functions which allows
to automatically fail tests due to output mismatch.

As a side-effect this also simplifies #if-#else logic due to both
_stdout() and _stderr() now being simple wrappers around static
function.

No user-visible changes are introduced because stdout is ignored by vty
code to avoid messing up vty output.

Change-Id: Ia786361f5f687e43b27d87a45b4630bca58bcfe8
---
M include/osmocom/core/logging.h
M src/logging.c
M src/vty/logging_vty.c
3 files changed, 37 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/12093/1

diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index 295e5a8..4a835ff 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -218,6 +218,7 @@
LOG_TGT_TYPE_SYSLOG,/*!< syslog based logging */
LOG_TGT_TYPE_FILE,  /*!< text file logging */
LOG_TGT_TYPE_STDERR,/*!< stderr logging */
+   LOG_TGT_TYPE_STDOUT,/*!< stdout logging */
LOG_TGT_TYPE_STRRB, /*!< osmo_strrb-backed logging */
LOG_TGT_TYPE_GSMTAP,/*!< GSMTAP network logging */
 };
@@ -361,6 +362,7 @@
 struct log_target *log_target_create(void);
 void log_target_destroy(struct log_target *target);
 struct log_target *log_target_create_stderr(void);
+struct log_target *log_target_create_stdout(void);
 struct log_target *log_target_create_file(const char *fname);
 struct log_target *log_target_create_syslog(const char *ident, int option,
int facility);
diff --git a/src/logging.c b/src/logging.c
index 908ba54..31345d1 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -810,24 +810,45 @@
return target;
 }

-/*! Create the STDERR log target
- *  \returns dynamically-allocated \ref log_target for STDERR */
-struct log_target *log_target_create_stderr(void)
+static struct log_target *_log_target_create_std(FILE *out, enum 
log_target_type lt)
 {
-/* since C89/C99 says stderr is a macro, we can safely do this! */
-#if !EMBEDDED && defined(stderr)
+#if !EMBEDDED
struct log_target *target;

target = log_target_create();
if (!target)
return NULL;

-   target->type = LOG_TGT_TYPE_STDERR;
-   target->tgt_file.out = stderr;
+   target->type = lt;
+   target->tgt_file.out = out;
target->output = _file_output;
return target;
 #else
return NULL;
+#endif
+}
+
+/*! Create the STDOUT log target
+ *  \returns dynamically-allocated \ref log_target for STDOUT */
+struct log_target *log_target_create_stdout(void)
+{
+/* since C89/C99 says stdout is a macro, we can safely do this! */
+#if defined(stdout)
+   return _log_target_create_std(stdout, LOG_TGT_TYPE_STDOUT);
+#else
+   return NULL;
+#endif /* stdout */
+}
+
+/*! Create the STDERR log target
+ *  \returns dynamically-allocated \ref log_target for STDERR */
+struct log_target *log_target_create_stderr(void)
+{
+/* since C89/C99 says stderr is a macro, we can safely do this! */
+#if defined(stderr)
+   return _log_target_create_std(stderr, LOG_TGT_TYPE_STDERR);
+#else
+   return NULL;
 #endif /* stderr */
 }

@@ -900,6 +921,10 @@
/* don't close stderr */
if (target->tgt_file.out != stderr)
 #endif
+#ifdef stdout
+   /* don't close stdout */
+   if (target->tgt_file.out != stdout)
+#endif
{
fclose(target->tgt_file.out);
target->tgt_file.out = NULL;
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index f3e1419..e2d2b57 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -877,6 +877,9 @@
case LOG_TGT_TYPE_STDERR:
vty_out(vty, "log stderr%s", VTY_NEWLINE);
break;
+   case LOG_TGT_TYPE_STDOUT:
+   /* we don't support vty logging to stdout to avoid messing up 
vty prompt and user input */
+   break;
case LOG_TGT_TYPE_SYSLOG:
 #ifdef HAVE_SYSLOG_H
vty_out(vty, "log syslog %s%s",

--
To view, visit https://gerrit.osmocom.org/12093
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia786361f5f687e43b27d87a45b4630bca58bcfe8
Gerrit-Change-Number: 12093
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in libosmocore[master]: LCLS, TS 48.008: add GCR IE encoding/decoding

2018-12-04 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/12020

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

Change subject: LCLS, TS 48.008: add GCR IE encoding/decoding
..

LCLS, TS 48.008: add GCR IE encoding/decoding

* add functions to encode Global Call. Ref. from TS 29.205 as 3GPP TS
  48.008 §3.2.2.115 information element
* add corresponding tests

Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
5 files changed, 107 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/12020/11
--
To view, visit https://gerrit.osmocom.org/12020
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
Gerrit-Change-Number: 12020
Gerrit-PatchSet: 11
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: Logging: don't print hex category by default

2018-12-04 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12095


Change subject: Logging: don't print hex category by default
..

Logging: don't print hex category by default

This information is of little use and unnecessarily confuse users. We
also unset it while testing internally. Let's not set this option by
default and let applications enable it explicitly if necessary.

Change-Id: I6dc3898958cf60147ad73c52cf0b3990bd26359e
---
M src/application.c
M tests/logging/logging_vty_test.c
2 files changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/95/12095/1

diff --git a/src/application.c b/src/application.c
index 19e089b..01fda6f 100644
--- a/src/application.c
+++ b/src/application.c
@@ -138,6 +138,7 @@

log_add_target(std);
log_set_all_filter(std, 1);
+   log_set_print_category_hex(std, 0);

return std;
 }
diff --git a/tests/logging/logging_vty_test.c b/tests/logging/logging_vty_test.c
index 0bdb11d..b177e31 100644
--- a/tests/logging/logging_vty_test.c
+++ b/tests/logging/logging_vty_test.c
@@ -255,7 +255,6 @@
osmo_talloc_vty_add_cmds();

log_set_print_category(osmo_stderr_target, 1);
-   log_set_print_category_hex(osmo_stderr_target, 0);
log_set_print_level(osmo_stderr_target, 1);
log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);


--
To view, visit https://gerrit.osmocom.org/12095
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6dc3898958cf60147ad73c52cf0b3990bd26359e
Gerrit-Change-Number: 12095
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in libosmocore[master]: LCLS: add gsm0808_create_ass2()

2018-12-04 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/11826

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

Change subject: LCLS: add gsm0808_create_ass2()
..

LCLS: add gsm0808_create_ass2()

It allows setting additional assignment parameters explicitly.

Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Related: OS#2487
---
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
5 files changed, 135 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/11826/22
--
To view, visit https://gerrit.osmocom.org/11826
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Gerrit-Change-Number: 11826
Gerrit-PatchSet: 22
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-CC: Vadim Yanitskiy 


Change in libosmocore[master]: msgb: add test helpers

2018-12-04 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12017 )

Change subject: msgb: add test helpers
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
Gerrit-Change-Number: 12017
Gerrit-PatchSet: 8
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Comment-Date: Tue, 04 Dec 2018 11:46:30 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: Add osmo_init_logging_std*()

2018-12-04 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12094


Change subject: Add osmo_init_logging_std*()
..

Add osmo_init_logging_std*()

The osmo_init_logging_stdout() function is similar to
osmo_init_logging2() but uses stdout as a default log target instead of
stderr. It's expected to used by applications without vty (test code for
example).

The osmo_init_logging_stderr() is equivalent of osmo_init_logging2()
implemented on top of the same primitives as osmo_init_logging_stdout().

Logging test expanded to make sure that we only initialize logging once.

Change-Id: I0fe8dc4a41aba4e4509540266e229700e8ec083c
---
M include/osmocom/core/application.h
M src/application.c
M tests/logging/logging_vty_test.c
3 files changed, 51 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/94/12094/1

diff --git a/include/osmocom/core/application.h 
b/include/osmocom/core/application.h
index edf59ed..c1e5b09 100644
--- a/include/osmocom/core/application.h
+++ b/include/osmocom/core/application.h
@@ -13,12 +13,15 @@
 /*! one instance of a logging target (file, stderr, ...) */
 struct log_target;

-/*! the default logging target, logging to stderr */
+/*! the default logging targets, logging to stderr or stdout */
 extern struct log_target *osmo_stderr_target;
+extern struct log_target *osmo_stdout_target;

 void osmo_init_ignore_signals(void);
 int osmo_init_logging(const struct log_info *)
OSMO_DEPRECATED("use osmo_init_logging2() instead to avoid a NULL 
talloc ctx");
 int osmo_init_logging2(void *ctx, const struct log_info *log_info);
+int osmo_init_logging_stdout(void *ctx, const struct log_info *log_info);
+int osmo_init_logging_stderr(void *ctx, const struct log_info *log_info);

 int osmo_daemonize(void);
diff --git a/src/application.c b/src/application.c
index d912eb7..19e089b 100644
--- a/src/application.c
+++ b/src/application.c
@@ -83,6 +83,7 @@
 #include 

 struct log_target *osmo_stderr_target;
+struct log_target *osmo_stdout_target;

 static void sighup_hdlr(int signal)
 {
@@ -117,7 +118,7 @@
return osmo_init_logging2(NULL, log_info);
 }

-int osmo_init_logging2(void *ctx, const struct log_info *log_info)
+static int _init_logging_std(void *ctx, const struct log_info *log_info)
 {
static int logging_initialized = 0;

@@ -126,15 +127,52 @@

logging_initialized = 1;
log_init(log_info, ctx);
-   osmo_stderr_target = log_target_create_stderr();
+
+   return 0;
+}
+
+static struct log_target *_add_logging_std(struct log_target *std)
+{
+   if (!std)
+   return NULL;
+
+   log_add_target(std);
+   log_set_all_filter(std, 1);
+
+   return std;
+}
+
+int osmo_init_logging_stdout(void *ctx, const struct log_info *log_info)
+{
+   int rc = _init_logging_std(ctx, log_info);
+   if (rc < 0)
+   return rc;
+
+   osmo_stdout_target = _add_logging_std(log_target_create_stdout());
+   if (!osmo_stdout_target)
+   return -1;
+
+   return 0;
+}
+
+int osmo_init_logging_stderr(void *ctx, const struct log_info *log_info)
+{
+   int rc = _init_logging_std(ctx, log_info);
+   if (rc < 0)
+   return rc;
+
+   osmo_stderr_target = _add_logging_std(log_target_create_stderr());
if (!osmo_stderr_target)
return -1;

-   log_add_target(osmo_stderr_target);
-   log_set_all_filter(osmo_stderr_target, 1);
return 0;
 }

+int osmo_init_logging2(void *ctx, const struct log_info *log_info)
+{
+   return osmo_init_logging_stderr(ctx, log_info);
+}
+
 /*! Turn the current process into a background daemon
  *
  * This function will fork the process, exit the parent and set umask,
diff --git a/tests/logging/logging_vty_test.c b/tests/logging/logging_vty_test.c
index 806a460..0bdb11d 100644
--- a/tests/logging/logging_vty_test.c
+++ b/tests/logging/logging_vty_test.c
@@ -242,6 +242,11 @@

osmo_init_logging2(root_ctx, &log_info);

+   if (osmo_init_logging_stderr(root_ctx, &log_info) == 0) {
+   LOGP(DLGLOBAL, LOGL_FATAL, "Subsequent logging init has not 
failed!\n");
+   return 3;
+   }
+
vty_commands_init();

handle_options(argc, argv);

--
To view, visit https://gerrit.osmocom.org/12094
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0fe8dc4a41aba4e4509540266e229700e8ec083c
Gerrit-Change-Number: 12094
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in libosmocore[master]: Allow log_init() with NULL log_info

2018-12-04 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12092


Change subject: Allow log_init() with NULL log_info
..

Allow log_init() with NULL log_info

Since we have library-internal categories we don't have to force
application to supply its own categories. This is especially useful for
testing code inside libosmocore which only use internal categories
anyway.

Change-Id: I42159780b57684bff225789f036f28a4b25fc7b8
---
M src/logging.c
1 file changed, 13 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/92/12092/1

diff --git a/src/logging.c b/src/logging.c
index e7cc472..908ba54 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -964,10 +964,14 @@
if (!osmo_log_info)
return -ENOMEM;

-   osmo_log_info->filter_fn = inf->filter_fn;
-   osmo_log_info->num_cat_user = inf->num_cat;
-   /* total number = number of user cat + library cat */
-   osmo_log_info->num_cat = inf->num_cat + ARRAY_SIZE(internal_cat);
+   osmo_log_info->num_cat = ARRAY_SIZE(internal_cat);
+
+   if (inf) {
+   osmo_log_info->filter_fn = inf->filter_fn;
+   osmo_log_info->num_cat_user = inf->num_cat;
+   /* total number = number of user cat + library cat */
+   osmo_log_info->num_cat += inf->num_cat;
+   }

osmo_log_info->cat = talloc_zero_array(osmo_log_info,
struct log_info_cat,
@@ -978,12 +982,11 @@
return -ENOMEM;
}

-   /* copy over the user part */
-   for (i = 0; i < inf->num_cat; i++) {
-   memcpy((struct log_info_cat *) &osmo_log_info->cat[i],
-   &inf->cat[i],
-   sizeof(struct log_info_cat));
-   }
+   if (inf) /* copy over the user part */
+   for (i = 0; i < inf->num_cat; i++) {
+   memcpy((struct log_info_cat *) &osmo_log_info->cat[i],
+  &inf->cat[i], sizeof(struct log_info_cat));
+   }

/* copy over the library part */
for (i = 0; i < ARRAY_SIZE(internal_cat); i++) {

--
To view, visit https://gerrit.osmocom.org/12092
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I42159780b57684bff225789f036f28a4b25fc7b8
Gerrit-Change-Number: 12092
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in libosmocore[master]: LCLS, TS 29.205: add GCR routines

2018-12-04 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/11827

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

Change subject: LCLS, TS 29.205: add GCR routines
..

LCLS, TS 29.205: add GCR routines

Add functions to encode and decode Global Call Reference as per
3GPP TS 29.205 Table B 2.1.9.1 add corresponding tests.

Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Related: OS#2487
---
M include/Makefile.am
A include/osmocom/gsm/gsm29205.h
M src/gsm/Makefile.am
A src/gsm/gsm29205.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/gsm29205/gsm29205_test.c
A tests/gsm29205/gsm29205_test.ok
M tests/testsuite.at
9 files changed, 250 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/27/11827/17
--
To view, visit https://gerrit.osmocom.org/11827
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Gerrit-Change-Number: 11827
Gerrit-PatchSet: 17
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: Add msgb_tl_put() helper

2018-12-04 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/12080 )

Change subject: Add msgb_tl_put() helper
..

Add msgb_tl_put() helper

When adding complex TLV structures where length of V is not known in
advance it's handy to be able to simply add Tag and save the pointer to
the Length field so it can be updated once entire Value is added and its
length is known.

Change-Id: I8dc1e4880352833a0a49c1dd0d7cb4148ac43aff
---
M include/osmocom/gsm/tlv.h
1 file changed, 12 insertions(+), 0 deletions(-)

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



diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index 1ab964a..51bedd6 100644
--- a/include/osmocom/gsm/tlv.h
+++ b/include/osmocom/gsm/tlv.h
@@ -324,6 +324,18 @@
return v_put(buf, val);
 }

+/*! put (append) a TL fields to a \ref msgb
+ *  \returns pointer to the length field so it can be updated after adding new 
information under specified tag */
+static inline uint8_t *msgb_tl_put(struct msgb *msg, uint8_t tag)
+{
+   uint8_t *len = msgb_v_put(msg, tag);
+
+   /* reserve space for length, len points to this reserved space already 
*/
+   msgb_v_put(msg, 0);
+
+   return len;
+}
+
 /*! put (append) a TV16 field to a \ref msgb
  *  \returns pointer to first byte after newly-put information */
 static inline uint8_t *msgb_tv16_put(struct msgb *msg, uint8_t tag, uint16_t 
val)

--
To view, visit https://gerrit.osmocom.org/12080
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8dc1e4880352833a0a49c1dd0d7cb4148ac43aff
Gerrit-Change-Number: 12080
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 


Change in libosmocore[master]: LCLS: update osmo_lcls struct

2018-12-04 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/12019 )

Change subject: LCLS: update osmo_lcls struct
..

LCLS: update osmo_lcls struct

* use pointer to proper struct type for GCR
* update comments to be useful for doxygen

Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
---
M include/osmocom/gsm/gsm0808_utils.h
1 file changed, 4 insertions(+), 4 deletions(-)

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



diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index c5bf280..097bd76 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -60,10 +60,10 @@

 /*! LCLS-related parameters from 3GPP TS 48.008 */
 struct osmo_lcls {
-   enum gsm0808_lcls_config config;   /* §3.2.2.116 Configuration */
-   enum gsm0808_lcls_control control; /* §3.2.2.117 Connection Status 
Control */
-   struct gsm0808_gcr *gcr;   /* §3.2.2.115 Global Call Reference 
*/
-   bool corr_needed;  /* §3.2.2.118 Correlation-Not-Needed 
*/
+   enum gsm0808_lcls_config config;   /**< §3.2.2.116 Configuration */
+   enum gsm0808_lcls_control control; /**< §3.2.2.117 Connection Status 
Control */
+   struct gsm29205_gcr *gcr;  /**< §3.2.2.115 Global Call 
Reference */
+   bool corr_needed;  /**< §3.2.2.118 
Correlation-Not-Needed */
 };

 extern const struct value_string gsm0808_cell_id_discr_names[];

--
To view, visit https://gerrit.osmocom.org/12019
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
Gerrit-Change-Number: 12019
Gerrit-PatchSet: 8
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: LCLS, TS 29.205: add GCR routines

2018-12-04 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/11827

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

Change subject: LCLS, TS 29.205: add GCR routines
..

LCLS, TS 29.205: add GCR routines

Add functions to encode and decode Global Call Reference as per
3GPP TS 29.205 Table B 2.1.9.1 add corresponding tests.

Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Related: OS#2487
---
M include/Makefile.am
A include/osmocom/gsm/gsm29205.h
M src/gsm/Makefile.am
A src/gsm/gsm29205.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/gsm29205/gsm29205_test.c
A tests/gsm29205/gsm29205_test.ok
M tests/testsuite.at
9 files changed, 248 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/27/11827/16
--
To view, visit https://gerrit.osmocom.org/11827
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Gerrit-Change-Number: 11827
Gerrit-PatchSet: 16
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: LCLS: add gsm0808_create_ass2()

2018-12-04 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/11826

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

Change subject: LCLS: add gsm0808_create_ass2()
..

LCLS: add gsm0808_create_ass2()

It allows setting additional assignment parameters explicitly.

Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Related: OS#2487
---
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
5 files changed, 133 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/11826/21
--
To view, visit https://gerrit.osmocom.org/11826
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Gerrit-Change-Number: 11826
Gerrit-PatchSet: 21
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-CC: Vadim Yanitskiy 


Change in libosmocore[master]: LCLS, TS 48.008: add GCR IE encoding/decoding

2018-12-04 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/12020

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

Change subject: LCLS, TS 48.008: add GCR IE encoding/decoding
..

LCLS, TS 48.008: add GCR IE encoding/decoding

* add functions to encode Global Call. Ref. from TS 29.205 as 3GPP TS
  48.008 §3.2.2.115 information element
* add corresponding tests

Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
5 files changed, 105 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/12020/10
--
To view, visit https://gerrit.osmocom.org/12020
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
Gerrit-Change-Number: 12020
Gerrit-PatchSet: 10
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: ctrl: use #define for TRAP id

2018-12-03 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11926 )

Change subject: ctrl: use #define for TRAP id
..

ctrl: use #define for TRAP id

We always use id = 0 when sending TRAP messages. Let's make this more
obvious by introducing appropriate define.

Change-Id: I33d7d4c6a1885a75a85d6f2f017430e0860b4126
---
M include/osmocom/ctrl/control_cmd.h
M src/ctrl/control_if.c
2 files changed, 2 insertions(+), 1 deletion(-)

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



diff --git a/include/osmocom/ctrl/control_cmd.h 
b/include/osmocom/ctrl/control_cmd.h
index 93055c7..276a7de 100644
--- a/include/osmocom/ctrl/control_cmd.h
+++ b/include/osmocom/ctrl/control_cmd.h
@@ -12,6 +12,7 @@
 #define CTRL_CMD_ERROR -1
 #define CTRL_CMD_HANDLED   0
 #define CTRL_CMD_REPLY 1
+#define CTRL_CMD_TRAP_ID   "0"

 struct ctrl_handle;
 
diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 1121d07..0209f3b 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -156,7 +156,7 @@
if (!cmd)
return -ENOMEM;

-   cmd->id = "0"; /* It's a TRAP! */
+   cmd->id = CTRL_CMD_TRAP_ID; /* It's a TRAP! */
cmd->variable = (char *) name;
cmd->reply = value;
r = ctrl_cmd_send_to_all(ctrl, cmd);

--
To view, visit https://gerrit.osmocom.org/11926
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I33d7d4c6a1885a75a85d6f2f017430e0860b4126
Gerrit-Change-Number: 11926
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: daniel 
Gerrit-CC: Pau Espin Pedrol 


Change in libosmocore[master]: msgb: add test helpers

2018-12-03 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12017 )

Change subject: msgb: add test helpers
..


Patch Set 5:

> I think we should avoid using printf() in libosmocore

In general I'd agree but those are "test helpers" (see commit description) 
which are intended to be used in tests/ code where printf() usage is common. 
For use outside of tests/ there're variants which don't print anything 
implemented via #define wrappers.


--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
Gerrit-Change-Number: 12017
Gerrit-PatchSet: 5
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Comment-Date: Mon, 03 Dec 2018 14:52:47 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: add gsm0808_create_ass2()

2018-12-03 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11826 )

Change subject: LCLS: add gsm0808_create_ass2()
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11826
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Gerrit-Change-Number: 11826
Gerrit-PatchSet: 19
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Mon, 03 Dec 2018 14:42:09 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS, TS 48.008: add GCR IE encoding/decoding

2018-12-03 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12020 )

Change subject: LCLS, TS 48.008: add GCR IE encoding/decoding
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/12020
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
Gerrit-Change-Number: 12020
Gerrit-PatchSet: 8
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Mon, 03 Dec 2018 14:42:06 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: Add msgb_tl_put() helper

2018-12-03 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12080


Change subject: Add msgb_tl_put() helper
..

Add msgb_tl_put() helper

When adding complex TLV structures where length of V is not known in
advance it's handy to be able to simply add Tag and save the pointer to
the Length field so it can be updated once entire Value is added and its
length is known.

Change-Id: I8dc1e4880352833a0a49c1dd0d7cb4148ac43aff
---
M include/osmocom/gsm/tlv.h
1 file changed, 12 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/80/12080/1

diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h
index 1ab964a..51bedd6 100644
--- a/include/osmocom/gsm/tlv.h
+++ b/include/osmocom/gsm/tlv.h
@@ -324,6 +324,18 @@
return v_put(buf, val);
 }

+/*! put (append) a TL fields to a \ref msgb
+ *  \returns pointer to the length field so it can be updated after adding new 
information under specified tag */
+static inline uint8_t *msgb_tl_put(struct msgb *msg, uint8_t tag)
+{
+   uint8_t *len = msgb_v_put(msg, tag);
+
+   /* reserve space for length, len points to this reserved space already 
*/
+   msgb_v_put(msg, 0);
+
+   return len;
+}
+
 /*! put (append) a TV16 field to a \ref msgb
  *  \returns pointer to first byte after newly-put information */
 static inline uint8_t *msgb_tv16_put(struct msgb *msg, uint8_t tag, uint16_t 
val)

--
To view, visit https://gerrit.osmocom.org/12080
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8dc1e4880352833a0a49c1dd0d7cb4148ac43aff
Gerrit-Change-Number: 12080
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in libosmocore[master]: LCLS: update osmo_lcls struct

2018-12-03 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12019 )

Change subject: LCLS: update osmo_lcls struct
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/12019
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
Gerrit-Change-Number: 12019
Gerrit-PatchSet: 6
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Mon, 03 Dec 2018 14:22:20 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS, TS 29.205: add GCR routines

2018-12-03 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11827 )

Change subject: LCLS, TS 29.205: add GCR routines
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11827
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Gerrit-Change-Number: 11827
Gerrit-PatchSet: 14
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Mon, 03 Dec 2018 14:21:02 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: msgb: add test helpers

2018-12-03 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12017 )

Change subject: msgb: add test helpers
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
Gerrit-Change-Number: 12017
Gerrit-PatchSet: 5
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Mon, 03 Dec 2018 14:13:53 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: Update msgb Lx helpers

2018-12-03 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12079


Change subject: Update msgb Lx helpers
..

Update msgb Lx helpers

* add missing L1 and L4 hexdump
* add msgb_l4() for consistency and convert msgb_sms() into simple alias

Those will be used in follow-up patches for msgb debug/test helpers.

Change-Id: I8d6dd1b1ff3aa98a452711c692ca7dee0449203b
---
M include/osmocom/core/msgb.h
1 file changed, 17 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/79/12079/1

diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 2449151..1bb5fe5 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -130,8 +130,10 @@
 #define msgb_l2(m) ((void *)(m->l2h))
 /*! obtain L3 header of msgb */
 #define msgb_l3(m) ((void *)(m->l3h))
+/*! obtain L4 header of msgb */
+#define msgb_l4(m) ((void *)(m->l4h))
 /*! obtain SMS header of msgb */
-#define msgb_sms(m)((void *)(m->l4h))
+#define msgb_sms(m)msgb_l4(m)

 /*! determine length of L1 message
  *  \param[in] msgb message buffer
@@ -566,6 +568,13 @@
 void msgb_set_talloc_ctx(void *ctx) OSMO_DEPRECATED("Use 
msgb_talloc_ctx_init() instead");
 int msgb_printf(struct msgb *msgb, const char *format, ...);

+static inline const char *msgb_hexdump_l1(const struct msgb *msg)
+{
+   if (!msgb_l1(msg) || !(msgb_l1len(msg)))
+   return "[]";
+   return osmo_hexdump((const unsigned char *) msgb_l1(msg), 
msgb_l1len(msg));
+}
+
 static inline const char *msgb_hexdump_l2(const struct msgb *msg)
 {
if (!msgb_l2(msg) || !(msgb_l2len(msg)))
@@ -580,4 +589,11 @@
return osmo_hexdump((const unsigned char*) msgb_l3(msg), 
msgb_l3len(msg));
 }

+static inline const char *msgb_hexdump_l4(const struct msgb *msg)
+{
+   if (!msgb_l4(msg) || !(msgb_l4len(msg)))
+   return "[]";
+   return osmo_hexdump((const unsigned char*) msgb_l4(msg), 
msgb_l4len(msg));
+}
+
 /*! @} */

--
To view, visit https://gerrit.osmocom.org/12079
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d6dd1b1ff3aa98a452711c692ca7dee0449203b
Gerrit-Change-Number: 12079
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in libosmocore[master]: Move BSSMAP_MSG_* defines to header file

2018-11-30 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/12018 )

Change subject: Move BSSMAP_MSG_* defines to header file
..

Move BSSMAP_MSG_* defines to header file

This will be reused be several tests related to TS 48.008 and TS 29.205
in follow-up commits.

Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
---
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
2 files changed, 3 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 9b19d69..298b3e4 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -29,6 +29,9 @@
 #include 
 #include 

+#define BSSMAP_MSG_SIZE 512
+#define BSSMAP_MSG_HEADROOM 128
+
 struct sockaddr_storage;

 struct msgb;
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index fe7bc2c..2566ad5 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -34,9 +34,6 @@
  *  message generation/encoding.
  */

-#define BSSMAP_MSG_SIZE 512
-#define BSSMAP_MSG_HEADROOM 128
-
 /*! Create "Complete L3 Info" for AoIP, legacy implementation.
  * Instead use gsm0808_create_layer3_aoip2(), which is capable of three-digit 
MNC with leading zeros.
  *  \param[in] msg_l3 msgb containing Layer 3 Message

--
To view, visit https://gerrit.osmocom.org/12018
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
Gerrit-Change-Number: 12018
Gerrit-PatchSet: 4
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: LCLS: fix GCR parameter type

2018-11-30 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/12019

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

Change subject: LCLS: fix GCR parameter type
..

LCLS: fix GCR parameter type

* use proper struct pointer
* update comments to be useful for doxygen

Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
---
M include/osmocom/gsm/gsm0808_utils.h
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/19/12019/4
--
To view, visit https://gerrit.osmocom.org/12019
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
Gerrit-Change-Number: 12019
Gerrit-PatchSet: 4
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: LCLS, TS 29.205: add GCR routines

2018-11-30 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/11827

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

Change subject: LCLS, TS 29.205: add GCR routines
..

LCLS, TS 29.205: add GCR routines

Add functions to encode and decode Global Call Reference as per
3GPP TS 29.205 Table B 2.1.9.1 add corresponding tests.

Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Related: OS#2487
---
M include/Makefile.am
A include/osmocom/gsm/gsm29_205.h
M src/gsm/Makefile.am
A src/gsm/gsm29_205.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/gsm29205/gsm29205_test.c
A tests/gsm29205/gsm29205_test.ok
M tests/testsuite.at
9 files changed, 243 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/27/11827/12
--
To view, visit https://gerrit.osmocom.org/11827
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Gerrit-Change-Number: 11827
Gerrit-PatchSet: 12
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: LCLS: fix GCR parameter name

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12019 )

Change subject: LCLS: fix GCR parameter name
..


Patch Set 3:

(1 comment)

It's kinda confusing when you complain about presence and absence of "https://gerrit.osmocom.org/#/c/12019/3/include/osmocom/gsm/gsm0808_utils.h
File include/osmocom/gsm/gsm0808_utils.h:

https://gerrit.osmocom.org/#/c/12019/3/include/osmocom/gsm/gsm0808_utils.h@63
PS3, Line 63:   enum gsm0808_lcls_config config;   /*< doc  §3.2.2.116 
Configuration */
> what's "doc" about?
That was requested by you to make the comments visible to doxygen.



--
To view, visit https://gerrit.osmocom.org/12019
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
Gerrit-Change-Number: 12019
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Fri, 30 Nov 2018 15:34:52 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: gsm0808: add encoder for cause codes and use it

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12044 )

Change subject: gsm0808: add encoder for cause codes and use it
..


Patch Set 1:

(3 comments)

I think the test should be added as well. It's rather easy and the user of this 
function are outside of the library so it wouldn't be immediately obvious that 
smth is broken if we don't test for it.

https://gerrit.osmocom.org/#/c/12044/1/src/gsm/gsm0808_utils.c
File src/gsm/gsm0808_utils.c:

https://gerrit.osmocom.org/#/c/12044/1/src/gsm/gsm0808_utils.c@51
PS1, Line 51: /*! Encode TS 08.08 AoIP Cause IE
I think it's better to reference the same spec as in body of this function.


https://gerrit.osmocom.org/#/c/12044/1/src/gsm/gsm0808_utils.c@67
PS1, Line 67:   buf[1] = (uint8_t) (cause & 0xff);
I think it's better to use osmo_store16*() - that way it's immediately obvious 
which endian is used. Plus it's easier to read.


https://gerrit.osmocom.org/#/c/12044/1/src/gsm/gsm0808_utils.c@74
PS1, Line 74:   return (uint8_t) (msg->tail - old_tail);
You know for sure how many bytes are added - just return explicit number from 
corresponding if clause, there's no need to bother with pointer arithmetic.



--
To view, visit https://gerrit.osmocom.org/12044
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I71d58fad89502a43532f60717ca022c15c73f8bb
Gerrit-Change-Number: 12044
Gerrit-PatchSet: 1
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Fri, 30 Nov 2018 15:32:19 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: add gsm0808_create_ass_ext()

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11826 )

Change subject: LCLS: add gsm0808_create_ass_ext()
..


Patch Set 10:

(1 comment)

I've tried to address other comments in extended patch series. Let me know if 
I've missed something.

https://gerrit.osmocom.org/#/c/11826/10/include/osmocom/gsm/gsm0808.h
File include/osmocom/gsm/gsm0808.h:

https://gerrit.osmocom.org/#/c/11826/10/include/osmocom/gsm/gsm0808.h@67
PS10, Line 67: struct msgb *gsm0808_create_ass_ext(const struct 
gsm0808_channel_type *ct,
> please call it gsm0808_create_ass2() instead
Why? So far both ...2() and ..._ext() are widely used throughout the code. Did 
I miss some discussion in ML about it?



--
To view, visit https://gerrit.osmocom.org/11826
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Gerrit-Change-Number: 11826
Gerrit-PatchSet: 10
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Fri, 30 Nov 2018 15:08:56 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: msgb: add test helpers

2018-11-30 Thread Max
Hello Pau Espin Pedrol, Jenkins Builder,

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

https://gerrit.osmocom.org/12017

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

Change subject: msgb: add test helpers
..

msgb: add test helpers

It's often handy to compare certain msgb layer to a given array and
print the position where they differ. Add simple pretty-printer and
corresponding L* wrappers. Add missing L* helpers for per-layer data
access and printing.

Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
---
M include/osmocom/core/msgb.h
M src/msgb.c
2 files changed, 249 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/17/12017/3
--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
Gerrit-Change-Number: 12017
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: LCLS, TS 48.008: add GCR IE encoding/decoding

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12020 )

Change subject: LCLS, TS 48.008: add GCR IE encoding/decoding
..


Patch Set 2:

(1 comment)

The rest should be addressed in next revision.

https://gerrit.osmocom.org/#/c/12020/2/tests/gsm0808/gsm0808_test.c
File tests/gsm0808/gsm0808_test.c:

https://gerrit.osmocom.org/#/c/12020/2/tests/gsm0808/gsm0808_test.c@605
PS2, Line 605:  printf("parsing failed: %s [%s]\n", strerror(-rc), 
msgb_hexdump(msg));
> Exit or at last return in all failed cases.
Same comment as in one of the previous commits - why?



--
To view, visit https://gerrit.osmocom.org/12020
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
Gerrit-Change-Number: 12020
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Fri, 30 Nov 2018 14:59:20 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: fix GCR parameter name

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12019 )

Change subject: LCLS: fix GCR parameter name
..


Patch Set 1:

(1 comment)

Or did I misunderstood your question?

https://gerrit.osmocom.org/#/c/12019/1/include/osmocom/gsm/gsm0808_utils.h
File include/osmocom/gsm/gsm0808_utils.h:

https://gerrit.osmocom.org/#/c/12019/1/include/osmocom/gsm/gsm0808_utils.h@65
PS1, Line 65:   struct gsm29205_gcr *gcr;  /*< doc  §3.2.2.115 Global 
Call Reference */
> In the previous commit, "struct gsm29205_gcr" is added. […]
That's what this patch does.



--
To view, visit https://gerrit.osmocom.org/12019
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
Gerrit-Change-Number: 12019
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Fri, 30 Nov 2018 14:58:33 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS, TS 29.205: add GCR routines

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11827 )

Change subject: LCLS, TS 29.205: add GCR routines
..


Patch Set 9:

(3 comments)

The rest should be addressed in next revision.

https://gerrit.osmocom.org/#/c/11827/9/src/gsm/gsm29_205.c
File src/gsm/gsm29_205.c:

https://gerrit.osmocom.org/#/c/11827/9/src/gsm/gsm29_205.c@82
PS9, Line 82:   parsed += (2 + 1);
> parenthesis can be dropped here.
I think it would reduce readability so I'd rather keep them.


https://gerrit.osmocom.org/#/c/11827/9/src/gsm/libosmogsm.map
File src/gsm/libosmogsm.map:

https://gerrit.osmocom.org/#/c/11827/9/src/gsm/libosmogsm.map@147
PS9, Line 147: gsm29205_enc_gcr;
> I know not everything is perfectly sorted, but let's try to keep it as sorted 
> as possible, so move t […]
Curious, why it should be sorted at all? I thought this file is loaded 
completely by linker and entries order does not matter.


https://gerrit.osmocom.org/#/c/11827/9/tests/gsm29205/gsm29205_test.c
File tests/gsm29205/gsm29205_test.c:

https://gerrit.osmocom.org/#/c/11827/9/tests/gsm29205/gsm29205_test.c@64
PS9, Line 64:   printf("decoding failed: %s [%s]\n", strerror(-rc), 
msgb_hexdump(msg));
> All these should exit, or at least return.
Why? Printing unexpected text on the screen will cause test failure just like 
unexpected exit. At the same time running till the end of the test allows us to 
see multiple errors at once.



--
To view, visit https://gerrit.osmocom.org/11827
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Gerrit-Change-Number: 11827
Gerrit-PatchSet: 9
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Fri, 30 Nov 2018 14:57:39 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: msgb: add test helpers

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12017 )

Change subject: msgb: add test helpers
..


Patch Set 2:

> what about having it return an int like memcmp?

What for?

> after all we are using memcmp, so we can return an in

That would be pretty useless - I've yet to see the use-case where it would be 
necessary. It will also make API cumbersome and counter-intuitive because we 
not only use memcmp() but also compare lengths and check data availability. In 
fact, memcmp() might not be called at all.

The rest should be addressed in next revision.


--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
Gerrit-Change-Number: 12017
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Fri, 30 Nov 2018 14:54:09 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS, TS 29.205: add GCR routines

2018-11-30 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/11827

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

Change subject: LCLS, TS 29.205: add GCR routines
..

LCLS, TS 29.205: add GCR routines

Add functions to encode and decode Global Call Reference as per
3GPP TS 29.205 Table B 2.1.9.1 add corresponding tests.

Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Related: OS#2487
---
M include/Makefile.am
A include/osmocom/gsm/gsm29_205.h
M src/gsm/Makefile.am
A src/gsm/gsm29_205.c
M src/gsm/libosmogsm.map
M tests/Makefile.am
A tests/gsm29205/gsm29205_test.c
A tests/gsm29205/gsm29205_test.ok
M tests/testsuite.at
9 files changed, 243 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/27/11827/10
--
To view, visit https://gerrit.osmocom.org/11827
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Gerrit-Change-Number: 11827
Gerrit-PatchSet: 10
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: LCLS, TS 48.008: add GCR IE encoding/decoding

2018-11-30 Thread Max
Hello Pau Espin Pedrol, Jenkins Builder,

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

https://gerrit.osmocom.org/12020

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

Change subject: LCLS, TS 48.008: add GCR IE encoding/decoding
..

LCLS, TS 48.008: add GCR IE encoding/decoding

* add functions to encode Global Call. Ref. from TS 29.205 as 3GPP TS
  48.008 §3.2.2.115 information element
* add corresponding tests

Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
5 files changed, 104 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/12020/3
--
To view, visit https://gerrit.osmocom.org/12020
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
Gerrit-Change-Number: 12020
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: LCLS: add gsm0808_create_ass_ext()

2018-11-30 Thread Max
Hello Pau Espin Pedrol, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/11826

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

Change subject: LCLS: add gsm0808_create_ass_ext()
..

LCLS: add gsm0808_create_ass_ext()

It allows setting additional assignment  parameters explicitly.

Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Related: OS#2487
---
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
5 files changed, 132 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/26/11826/14
--
To view, visit https://gerrit.osmocom.org/11826
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Gerrit-Change-Number: 11826
Gerrit-PatchSet: 14
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-CC: Vadim Yanitskiy 


Change in libosmocore[master]: msgb: add test helpers

2018-11-30 Thread Max
Hello Pau Espin Pedrol, Jenkins Builder,

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

https://gerrit.osmocom.org/12017

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

Change subject: msgb: add test helpers
..

msgb: add test helpers

It's often handy to compare certain msgb layer to a given array and
print the position where they differ. Add simple pretty-printer and
corresponding L* wrappers. Add missing L* helpers for per-layer data
access and printing.

Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
---
M include/osmocom/core/msgb.h
M src/msgb.c
2 files changed, 243 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/17/12017/2
--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
Gerrit-Change-Number: 12017
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: Move BSSMAP_MSG_* defines to header file

2018-11-30 Thread Max
Hello Pau Espin Pedrol, Jenkins Builder,

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

https://gerrit.osmocom.org/12018

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

Change subject: Move BSSMAP_MSG_* defines to header file
..

Move BSSMAP_MSG_* defines to header file

This will be reused be several tests related to TS 48.008 and TS 29.205
in follow-up commits.

Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
---
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
2 files changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/12018/2
--
To view, visit https://gerrit.osmocom.org/12018
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
Gerrit-Change-Number: 12018
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11728 )

Change subject: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED
..


Patch Set 4:

(1 comment)

https://gerrit.osmocom.org/#/c/11728/4/src/gsm/gsm0808.c
File src/gsm/gsm0808.c:

https://gerrit.osmocom.org/#/c/11728/4/src/gsm/gsm0808.c@913
PS4, Line 913:  msgb_tlv_put(msg, GSM0808_IE_CAUSE, params->cause & 0x80 ? 2 : 
1, (const uint8_t *)¶ms->cause);
> I see, we should add a helper function that adds a cause. […]
It's already implemented - see gsm0808_create_cipher_reject_ext()



--
To view, visit https://gerrit.osmocom.org/11728
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I825106858bd89afc9837811b8fed2e8accc82441
Gerrit-Change-Number: 11728
Gerrit-PatchSet: 4
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Fri, 30 Nov 2018 10:36:13 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11728 )

Change subject: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED
..


Patch Set 6:

(2 comments)

https://gerrit.osmocom.org/#/c/11728/6/include/osmocom/gsm/gsm0808.h
File include/osmocom/gsm/gsm0808.h:

https://gerrit.osmocom.org/#/c/11728/6/include/osmocom/gsm/gsm0808.h@188
PS6, Line 188:  bool lcls_bss_status_present;
You can use GSM0808_LCLS_STS_NA - no need in separate bool variable.


https://gerrit.osmocom.org/#/c/11728/6/src/gsm/gsm0808.c
File src/gsm/gsm0808.c:

https://gerrit.osmocom.org/#/c/11728/6/src/gsm/gsm0808.c@935
PS6, Line 935:  if (params->lcls_bss_status_present)
Same here - check for GSM0808_LCLS_STS_NA and add if it differs.



--
To view, visit https://gerrit.osmocom.org/11728
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I825106858bd89afc9837811b8fed2e8accc82441
Gerrit-Change-Number: 11728
Gerrit-PatchSet: 6
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Fri, 30 Nov 2018 10:22:25 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS, TS 48.008: add GCR IE encoding/decoding

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12020 )

Change subject: LCLS, TS 48.008: add GCR IE encoding/decoding
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/12020
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
Gerrit-Change-Number: 12020
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Fri, 30 Nov 2018 09:53:10 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: add gsm0808_create_ass_ext()

2018-11-30 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11826 )

Change subject: LCLS: add gsm0808_create_ass_ext()
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11826
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Gerrit-Change-Number: 11826
Gerrit-PatchSet: 13
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Fri, 30 Nov 2018 09:53:13 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS, TS 29.205: add GCR routines

2018-11-29 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11827 )

Change subject: LCLS, TS 29.205: add GCR routines
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11827
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Gerrit-Change-Number: 11827
Gerrit-PatchSet: 9
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Thu, 29 Nov 2018 22:48:06 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: add gsm0808_create_ass_ext()

2018-11-29 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11826 )

Change subject: LCLS: add gsm0808_create_ass_ext()
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11826
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id89765df3f8c12f55f73f1d7a9d90c8883eb3bba
Gerrit-Change-Number: 11826
Gerrit-PatchSet: 12
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-CC: Vadim Yanitskiy 
Gerrit-Comment-Date: Thu, 29 Nov 2018 22:48:14 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: LCLS: fix GCR parameter name

2018-11-29 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12019


Change subject: LCLS: fix GCR parameter name
..

LCLS: fix GCR parameter name

* use proper struct pointer
* update comments to be useful for doxygen

Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
---
M include/osmocom/gsm/gsm0808_utils.h
1 file changed, 4 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/19/12019/1

diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index c5bf280..57aa6ea 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -60,10 +60,10 @@

 /*! LCLS-related parameters from 3GPP TS 48.008 */
 struct osmo_lcls {
-   enum gsm0808_lcls_config config;   /* §3.2.2.116 Configuration */
-   enum gsm0808_lcls_control control; /* §3.2.2.117 Connection Status 
Control */
-   struct gsm0808_gcr *gcr;   /* §3.2.2.115 Global Call Reference 
*/
-   bool corr_needed;  /* §3.2.2.118 Correlation-Not-Needed 
*/
+   enum gsm0808_lcls_config config;   /*< doc  §3.2.2.116 Configuration */
+   enum gsm0808_lcls_control control; /*< doc  §3.2.2.117 Connection 
Status Control */
+   struct gsm29205_gcr *gcr;  /*< doc  §3.2.2.115 Global Call 
Reference */
+   bool corr_needed;  /*< doc  §3.2.2.118 
Correlation-Not-Needed */
 };

 extern const struct value_string gsm0808_cell_id_discr_names[];

--
To view, visit https://gerrit.osmocom.org/12019
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ccfbd0c146e462e599e5305520cc89602364ec3
Gerrit-Change-Number: 12019
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in libosmocore[master]: LCLS, TS 48.008: add GCR IE encoding/decoding

2018-11-29 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12020


Change subject: LCLS, TS 48.008: add GCR IE encoding/decoding
..

LCLS, TS 48.008: add GCR IE encoding/decoding

* add functions to encode Global Call. Ref. from TS 29.205 as 3GPP TS
  48.008 §3.2.2.115 information element
* add corresponding tests

Change-Id: I82ce0207dc8de50689a8806c6471ad7fbae6219d
---
M include/osmocom/gsm/gsm0808_utils.h
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
M tests/gsm0808/gsm0808_test.ok
5 files changed, 103 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/12020/1

diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 57aa6ea..5de0d9d 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -81,6 +81,10 @@
const struct sockaddr_storage *ss);
 int gsm0808_dec_aoip_trasp_addr(struct sockaddr_storage *ss,
const uint8_t *elem, uint8_t len);
+
+uint8_t gsm0808_enc_gcr(struct msgb *msg,  const struct gsm29205_gcr *g);
+int gsm0808_dec_gcr(struct gsm29205_gcr *g, struct tlv_parsed *tp);
+
 uint8_t gsm0808_enc_speech_codec(struct msgb *msg,
 const struct gsm0808_speech_codec *sc);
 int gsm0808_dec_speech_codec(struct gsm0808_speech_codec *sc,
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index c58d828..9f7ec7e 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -482,6 +482,42 @@
return (int)(elem - old_elem);
 }

+/*! Create BSSMAP Global Call Reference, 3GPP TS 48.008 §3.2.2.115
+ *  \param[out] msg Message Buffer for appending IE
+ *  \param[in] g Global Call Reference, 3GPP TS 29.205 Table B 2.1.9.1
+ *  \returns number of bytes added to \a msg or 0 on error */
+uint8_t gsm0808_enc_gcr(struct msgb *msg, const struct gsm29205_gcr *g)
+{
+   uint8_t enc, *len;
+
+   len = msgb_v_put(msg, GSM0808_IE_GLOBAL_CALL_REF);
+
+   /* reserve space for length */
+   msgb_v_put(msg, 0); /* len points to this reserved space already */
+
+   enc = gsm29205_enc_gcr(msg, g);
+   if (enc) {
+   len[0] = enc;
+   return enc + 2; /* type (1 byte) + length (1 byte) */
+   }
+
+   return 0;
+}
+
+/*! Decode BSSMAP Global Call Reference, 3GPP TS 29.205 Table B 2.1.9.1
+ *  \param[out] gcr Caller-provided memory to store Global Call Reference
+ *  \param[in] elem IE value to be decoded
+ *  \param[in] len Length of \a elem in bytes
+ *  \returns number of bytes parsed; negative on error */
+int gsm0808_dec_gcr(struct gsm29205_gcr *gcr, struct tlv_parsed *tp)
+{
+   const uint8_t *buf = TLVP_VAL_MINLEN(tp, GSM0808_IE_GLOBAL_CALL_REF, 
OSMO_GCR_MIN_LEN);
+   if (!buf)
+   return -EINVAL;
+
+   return 2 + gsm29205_dec_gcr(gcr, buf, TLVP_LEN(tp, 
GSM0808_IE_GLOBAL_CALL_REF));
+}
+
 /*! Encode TS 08.08 Encryption Information IE
  *  \param[out] msg Message Buffer to which IE is to be appended
  *  \param[in] ei Encryption Information to be encoded
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index e1012b2..390b546 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -146,6 +146,8 @@

 gsm29205_enc_gcr;
 gsm29205_dec_gcr;
+gsm0808_enc_gcr;
+gsm0808_dec_gcr;

 gsm0808_att_tlvdef;
 gsm0808_bssap_name;
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 197ec06..e428970 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -569,6 +569,61 @@
msgb_free(in_msg);
 }

+static void test_enc_dec_gcr()
+{
+   static const uint8_t res[] = {
+   GSM0808_IE_GLOBAL_CALL_REF,
+   0x0d, /* GCR length */
+   0x03, /* .net_len */
+   0x4f, 0x4f, 0x4f, /* .net */
+   0x02, /* .node length */
+   0xde, 0xad, /* .node */
+   0x05, /* length of Call. Ref. */
+   0x4e, 0x4e, 0x4e, 0x4e, 0x4e /* .cr - Call. Ref. */
+   };
+   uint8_t len;
+   struct msgb *msg;
+   struct gsm29205_gcr g = { .net_len = 3, .node = 0xDEAD }, p = { 0 };
+   int rc;
+   struct tlv_parsed tp;
+   msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "global 
call reference");
+   if (!msg)
+   return;
+
+   memset(g.cr, 'N', sizeof(g.cr));
+   memset(g.net, 'O', g.net_len);
+
+   len = gsm0808_enc_gcr(msg, &g);
+   printf("Testing Global Call Reference IE encoder...\n\t%d bytes added: 
%s\n",
+  len, len == ARRAY_SIZE(res) ? "OK" : "FAIL");
+
+   if (!msgb_cmpr(__func__, __LINE__, msg, res, ARRAY_SIZE(res), true))
+   abort();
+
+   rc = osmo_bssap_tlv_parse(&tp, msgb_data

Change in libosmocore[master]: msgb: add test helper

2018-11-29 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12017


Change subject: msgb: add test helper
..

msgb: add test helper

It's often handy to compare msgb to a given array and print the position
where they differ.

Change-Id: I3bc95f2f5ab6e3f4b502647fb3e0aaaf1f7c4cf5
---
M include/osmocom/core/msgb.h
M src/msgb.c
2 files changed, 83 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/17/12017/1

diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 2449151..6e344f1 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -565,6 +565,8 @@
 void *msgb_talloc_ctx_init(void *root_ctx, unsigned int pool_size);
 void msgb_set_talloc_ctx(void *ctx) OSMO_DEPRECATED("Use 
msgb_talloc_ctx_init() instead");
 int msgb_printf(struct msgb *msgb, const char *format, ...);
+bool msgb_cmpr_l3(const char *f, size_t l, const struct msgb *msg, const 
uint8_t *data, size_t len, bool print);
+bool msgb_cmpr(const char *f, size_t l, const struct msgb *msg, const uint8_t 
*data, size_t len, bool print);

 static inline const char *msgb_hexdump_l2(const struct msgb *msg)
 {
diff --git a/src/msgb.c b/src/msgb.c
index 844cfc6..ebecc3e 100644
--- a/src/msgb.c
+++ b/src/msgb.c
@@ -173,6 +173,87 @@
return msg->data;
 }

+static inline bool compare_n_print(const char *f, size_t l, uint8_t level,
+  const uint8_t *m, const uint8_t *d, size_t 
len, bool print)
+{
+   size_t i;
+   if (memcmp(m, d, len) == 0)
+   return true;
+
+   if (!print)
+   return false;
+
+   printf("%s:%zu L%u data mismatch:\nexpected %s\n ",
+  f, l, level, osmo_hexdump(d, len));
+
+   for(i = 0; i < len; i++)
+   if (d[i] != m[i]) {
+   printf("!!\n");
+   break;
+   } else
+   printf(".. ");
+
+   /* N. B: that's intended to be used bymsgb_cmpr*() so length check is 
already passed,
+  so we can use len for both m and d */
+   printf("msgb %s\n", osmo_hexdump(m, len));
+
+   return false;
+}
+
+/*! Compare and print: check L3 data in msgb against given data and print 
erros if any
+ *  \param[in] f text prefix, usually __func__, ignored if print == false
+ *  \param[in] l numeric prefix, usually __LINE__, ignored if print == false
+ *  \param[in] msg message buffer
+ *  \param[in] data expected L3 data
+ *  \param[in] len length of data
+ *  \param[in] print boolean indicating whether we should print anything to 
stdout
+ *  \returns boolean indicating whether msgb L3 content is equal to a given 
data
+ */
+bool msgb_cmpr_l3(const char *f, size_t l, const struct msgb *msg, const 
uint8_t *data, size_t len, bool print)
+{
+   if (!msg) {
+   if (print)
+   printf("%s:%zu NULL msg comparison\n", f, l);
+   return false;
+   }
+
+   if (msgb_l3len(msg) != len) {
+   if (print)
+   printf("%s:%zu Length mismatch: %d != %zu, %s\n",
+  f, l, msgb_l3len(msg), len, 
msgb_hexdump_l3(msg));
+   return false;
+   }
+
+   return compare_n_print(f, l, 3, msgb_l3(msg), data, len, print);
+}
+
+/*! Compare and print: check data in msgb against given data and print erros 
if any
+ *  \param[in] f text prefix, usually __func__, ignored if print == false
+ *  \param[in] l numeric prefix, usually __LINE__, ignored if print == false
+ *  \param[in] msg message buffer
+ *  \param[in] data expected data
+ *  \param[in] len length of data
+ *  \param[in] print boolean indicating whether we should print anything to 
stdout
+ *  \returns boolean indicating whether msgb content is equal to a given data
+ */
+bool msgb_cmpr(const char *f, size_t l, const struct msgb *msg, const uint8_t 
*data, size_t len, bool print)
+{
+   if (!msg) {
+   if (print)
+   printf("%s:%zu NULL msg comparison\n", f, l);
+   return false;
+   }
+
+   if (msgb_length(msg) != len) {
+   if (print)
+   printf("%s:%zu Length mismatch: %d != %zu, %s\n",
+  f, l, msgb_length(msg), len, msgb_hexdump(msg));
+   return false;
+   }
+
+   return compare_n_print(f, l, 0, msgb_data(msg), data, len, print);
+}
+
 /*! get length of message buffer
  *  \param[in] msg message buffer
  *  \returns length of data section in message buffer

--
To view, visit https://gerrit.osmocom.org/12017
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-

Change in libosmocore[master]: Move BSSMAP_MSG_* defines to header file

2018-11-29 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12018


Change subject: Move BSSMAP_MSG_* defines to header file
..

Move BSSMAP_MSG_* defines to header file

Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
---
M include/osmocom/gsm/gsm0808.h
M src/gsm/gsm0808.c
2 files changed, 3 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/12018/1

diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 9b19d69..298b3e4 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -29,6 +29,9 @@
 #include 
 #include 

+#define BSSMAP_MSG_SIZE 512
+#define BSSMAP_MSG_HEADROOM 128
+
 struct sockaddr_storage;

 struct msgb;
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index fe7bc2c..2566ad5 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -34,9 +34,6 @@
  *  message generation/encoding.
  */

-#define BSSMAP_MSG_SIZE 512
-#define BSSMAP_MSG_HEADROOM 128
-
 /*! Create "Complete L3 Info" for AoIP, legacy implementation.
  * Instead use gsm0808_create_layer3_aoip2(), which is capable of three-digit 
MNC with leading zeros.
  *  \param[in] msg_l3 msgb containing Layer 3 Message

--
To view, visit https://gerrit.osmocom.org/12018
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4d8cc05b8df8e70c1f6257e53ae3acec7901681f
Gerrit-Change-Number: 12018
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


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

2018-11-29 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/3991 )

Change subject: EDGE: fix wrong encoding of LH bits
..


Patch Set 3:

Note to self: re-test after https://osmocom.org/issues/3014 is resolved.


--
To view, visit https://gerrit.osmocom.org/3991
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I75dd5bebc74eea85edf9582607c774d0bba0d2a6
Gerrit-Change-Number: 3991
Gerrit-PatchSet: 3
Gerrit-Owner: Minh-Quang Nguyen 
Gerrit-Assignee: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Minh-Quang Nguyen 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Comment-Date: Thu, 29 Nov 2018 12:43:52 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: ctrl2cgi: fix deferred callbacks

2018-11-28 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11953 )

Change subject: ctrl2cgi: fix deferred callbacks
..


Patch Set 4:

> I'd like to stop seeing code being moved somewhere and then moved back

I'd like to stop fixing other people's messed up async code.

Neither are likely to happen because people make mistakes. Also, I don't think 
that philosophical discussions belong to patch review comments.


--
To view, visit https://gerrit.osmocom.org/11953
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Gerrit-Change-Number: 11953
Gerrit-PatchSet: 4
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 
Gerrit-Comment-Date: Wed, 28 Nov 2018 13:03:33 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: Improve code style

2018-11-28 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11975 )

Change subject: Improve code style
..

Improve code style

* reorder imports to make pylint3 happy
* drop unused imports
* use proper spacing for list constants
* don't use reserved names for internal variables

The check was run as follows:
pylint3 -d C0103,C0301,C0410,C0326,R0913,R0901 ...
to disable useless warnings.

Change-Id: I5b90ee790f73dc509081401776911f25e43f1801
---
M osmopy/trap_helper.py
M scripts/ctrl2cgi.py
M scripts/soap.py
3 files changed, 21 insertions(+), 23 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index d07ebd3..d4a3b75 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -25,8 +25,6 @@
 import sys, os, datetime, signal, logging, logging.handlers
 from functools import partial
 from osmopy.osmo_ipa import Ctrl
-from osmopy.twisted_ipa import CTRL
-from twisted.internet import defer

 # keys from OpenBSC openbsc/src/libbsc/bsc_rf_ctrl.c, values SOAP-specific
 oper = { 'inoperational' : 0, 'operational' : 1 }
diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 6818b2a..1d6813d 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -24,17 +24,17 @@

 __version__ = "0.0.4" # bump this on every non-trivial change

-from twisted.internet import defer, reactor
-from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
-from osmopy.osmo_ipa import Ctrl
-from treq import post, collect
-from functools import partial
-from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params, comm_proc
-from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
-import argparse, datetime, signal, sys, os, logging, logging.handlers
+import argparse, os, logging, logging.handlers
 import hashlib
 import json
 import configparser
+from functools import partial
+from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
+from twisted.internet import defer, reactor
+from treq import post, collect
+from osmopy.trap_helper import debug_init, get_type, get_r, p_h, make_params, 
comm_proc
+from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
+from osmopy.osmo_ipa import Ctrl

 # we don't support older versions of TwistedIPA module
 assert V(twisted_ipa_version) > V('0.4')
@@ -48,14 +48,14 @@
 comm_proc(decoded.get('commands'), f, log)

 def gen_hash(params, skey):
-input = ''
-for key in 
['time_stamp','position_validity','admin_status','policy_status']:
-input += str(params.get(key))
-input += skey
-for key in ['bsc_id','lat','lon','position_validity']:
-input += str(params.get(key))
+inp = ''
+for key in ['time_stamp', 'position_validity', 'admin_status', 
'policy_status']:
+inp += str(params.get(key))
+inp += skey
+for key in ['bsc_id', 'lat', 'lon', 'position_validity']:
+inp += str(params.get(key))
 m = hashlib.md5()
-m.update(input.encode('utf-8'))
+m.update(inp.encode('utf-8'))
 res = m.hexdigest()
 #print('HASH: \nparams="%r"\ninput="%s" \nres="%s"' %(params, input, res))
 return res
diff --git a/scripts/soap.py b/scripts/soap.py
index 6bf786c..267b4d8 100755
--- a/scripts/soap.py
+++ b/scripts/soap.py
@@ -24,15 +24,15 @@

 __version__ = "0.7.2" # bump this on every non-trivial change

+import argparse, os, logging
+from functools import partial
+from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
 from twisted.internet import defer, reactor
+from suds.client import Client
+from treq import post, collect
+from osmopy.trap_helper import debug_init, get_type, get_r, p_h, make_params, 
comm_proc
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
 from osmopy.osmo_ipa import Ctrl
-from treq import post, collect
-from suds.client import Client
-from functools import partial
-from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params, comm_proc
-from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
-import argparse, datetime, signal, sys, os, logging, logging.handlers

 # we don't support older versions of TwistedIPA module
 assert V(twisted_ipa_version) > V('0.4')

--
To view, visit https://gerrit.osmocom.org/11975
To unsubscribe, or for help 

Change in python/osmo-python-tests[master]: Move command processing into shared function

2018-11-28 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11974 )

Change subject: Move command processing into shared function
..

Move command processing into shared function

Change-Id: I4e40607a9aa5e03a7b3f5b68e4261828209a5813
---
M osmopy/trap_helper.py
M scripts/ctrl2cgi.py
M scripts/soap.py
3 files changed, 19 insertions(+), 15 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index 6f4b95d..d07ebd3 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -24,6 +24,7 @@

 import sys, os, datetime, signal, logging, logging.handlers
 from functools import partial
+from osmopy.osmo_ipa import Ctrl
 from osmopy.twisted_ipa import CTRL
 from twisted.internet import defer

@@ -56,6 +57,17 @@
 loc = split_type(v)
 return loc[-1]

+def comm_proc(comm, f, log):
+"""
+Command processor: takes function f to run for each command
+"""
+bsc_id = comm[0].split()[0].split('.')[3] # we expect 1st command to have 
net.0.bsc.666.bts.2.trx.1 location prefix format
+log.debug("BSC %s commands: %r" % (bsc_id, comm))
+for t in comm:
+(_, m) = Ctrl().cmd(*t.split())
+f(m)
+return bsc_id
+
 def make_params(bsc, data):
 """
 Make parameters for request
diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index c566a7c..6818b2a 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -22,14 +22,14 @@
  */
 """

-__version__ = "0.0.3" # bump this on every non-trivial change
+__version__ = "0.0.4" # bump this on every non-trivial change
 
 from twisted.internet import defer, reactor
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
 from osmopy.osmo_ipa import Ctrl
 from treq import post, collect
 from functools import partial
-from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params
+from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params, comm_proc
 from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
 import argparse, datetime, signal, sys, os, logging, logging.handlers
 import hashlib
@@ -45,11 +45,7 @@
 Reply handler: process raw CGI server response, function f to run for each 
command
 """
 decoded = json.loads(resp.decode('utf-8'))
-bsc_id = decoded.get('commands')[0].split()[0].split('.')[3] # we expect 
1st command to have net.0.bsc.666.bts.2.trx.1 location prefix format
-log.debug("BSC %s commands: %r" % (bsc_id, decoded.get('commands')))
-for t in decoded.get('commands'): # Process commands format
-(_, m) = Ctrl().cmd(*t.split())
-f(m)
+comm_proc(decoded.get('commands'), f, log)

 def gen_hash(params, skey):
 input = ''
diff --git a/scripts/soap.py b/scripts/soap.py
index 75acd89..6bf786c 100755
--- a/scripts/soap.py
+++ b/scripts/soap.py
@@ -22,7 +22,7 @@
  */
 """

-__version__ = "0.7.1" # bump this on every non-trivial change
+__version__ = "0.7.2" # bump this on every non-trivial change

 from twisted.internet import defer, reactor
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
@@ -30,7 +30,7 @@
 from treq import post, collect
 from suds.client import Client
 from functools import partial
-from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params
+from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params, comm_proc
 from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
 import argparse, datetime, signal, sys, os, logging, logging.handlers

@@ -40,15 +40,11 @@

 def handle_reply(p, f, log, r):
 """
-Reply handler: takes function p to process raw SOAP server reply r, 
function f to run for each command and verbosity flag v
+Reply handler: takes function p to process raw SOAP server reply r, 
function f to run for each command
 """
 repl = p(r) # result is expected to have both commands[] array and error 
string (could be None)
-bsc_id = repl.commands[0].split()[0].split('.')[3] # we expect 1st command 
to have net.0.bsc.666.bts.2.trx.1 location prefix format
+bsc_id = comm_proc(repl.commands, f, log)
 log.info("Received SOAP response for BSC %s with %d commands, error 
status: %s" % (bsc_id, len(repl.commands), repl.error))
-log.debug("BSC %s commands: %s" % (bsc_id, repl.commands))
-for t in repl.commands: # Process OpenBscCommands format from .wsdl
-(_, 

Change in python/osmo-python-tests[master]: Drop unused Trap() class

2018-11-28 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11973 )

Change subject: Drop unused Trap() class
..

Drop unused Trap() class

Change-Id: Ic2066a66f99a059fc65cf3092170e248288c04d4
---
M osmopy/trap_helper.py
1 file changed, 0 insertions(+), 59 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index f7a64c8..6f4b95d 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -71,65 +71,6 @@
 loc = split_type(v)
 return partial(lambda a, i: a[i] if len(a) > i else None, loc)

-class Trap(CTRL):
-"""
-TRAP handler (agnostic to factory's client object)
-"""
-def ctrl_TRAP(self, data, op_id, v):
-"""
-Parse CTRL TRAP and dispatch to appropriate handler after normalization
-"""
-self.factory.log.debug('TRAP %s' % v)
-(l, r) = v.split()
-loc = l.split('.')
-t_type = loc[-1]
-p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse 
helper
-method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: 
"Unhandled %s trap" % t_type)
-method(p(1), p(3), p(5), p(7), r) # we expect 
net.0.bsc.666.bts.2.trx.1 format for trap prefix
-
-def ctrl_SET_REPLY(self, data, _, v):
-"""
-Debug log for replies to our commands
-"""
-self.factory.log.debug('SET REPLY %s' % v)
-
-def ctrl_ERROR(self, data, op_id, v):
-"""
-We want to know if smth went wrong
-"""
-self.factory.log.debug('CTRL ERROR [%s] %s' % (op_id, v))
-
-def connectionMade(self):
-"""
-Logging wrapper, calling super() is necessary not to break 
reconnection logic
-"""
-self.factory.log.info("Connected to CTRL@%s:%d" % (self.factory.host, 
self.factory.port))
-super(CTRL, self).connectionMade()
-
-@defer.inlineCallbacks
-def handle_locationstate(self, net, bsc, bts, trx, data):
-"""
-Handle location-state TRAP: parse trap content, prepare parameters and 
use treq's routines to post it while setting up async handlers
-"""
-(ts, fx, lat, lon, height, opr, adm, pol, mcc, mnc) = data.split(',')
-tstamp = datetime.datetime.fromtimestamp(float(ts)).isoformat()
-self.factory.log.debug('location-state@%s.%s.%s.%s (%s) [%s/%s] => %s' 
% (net, bsc, bts, trx, tstamp, mcc, mnc, data))
-
-d = self.factory.prepare_params(bsc, lon, lat, fix.get(fx, 0), tstamp, 
oper.get(opr, 2), admin.get(adm, 2), policy.get(pol, 3))
-
-d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error 
%s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), 
bsc) # handle HTTP errors
-# Ensure that we run only limited number of requests in parallel:
-yield self.factory.semaphore.acquire()
-yield d # we end up here only if semaphore is available which means 
it's ok to fire the request without exceeding the limit
-self.factory.semaphore.release()
-
-def handle_notificationrejectionv1(self, net, bsc, bts, trx, data):
-"""
-Handle notification-rejection-v1 TRAP: just an example to show how 
more message types can be handled
-"""
-self.factory.log.debug('notification-rejection-v1@bsc-id %s => %s' % 
(bsc, data))
-
-
 def reloader(path, script, log, dbg1, dbg2, signum, _):
 """
 Signal handler: we have to use execl() because twisted's reactor is not 
restartable due to some bug in twisted implementation

--
To view, visit https://gerrit.osmocom.org/11973
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic2066a66f99a059fc65cf3092170e248288c04d4
Gerrit-Change-Number: 11973
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in python/osmo-python-tests[master]: ctrl2cgi: fix deferred callbacks

2018-11-28 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11953 )

Change subject: ctrl2cgi: fix deferred callbacks
..

ctrl2cgi: fix deferred callbacks

Previously handle_reply() was marked as deferred callback unlike soap.py
where it's synchronous function. This seems to be causing issues where
some of the callbacks are not yield properly. Let's move to the
known-to-work semantics of soap.py where async functions are limited to
Trap() class.

Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Related: SYS#4399
---
M scripts/ctrl2cgi.py
1 file changed, 7 insertions(+), 18 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 843aeb9..c566a7c 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -22,7 +22,7 @@
  */
 """

-__version__ = "0.0.2" # bump this on every non-trivial change
+__version__ = "0.0.3" # bump this on every non-trivial change

 from twisted.internet import defer, reactor
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
@@ -40,25 +40,14 @@
 assert V(twisted_ipa_version) > V('0.4')


-@defer.inlineCallbacks
 def handle_reply(f, log, resp):
 """
 Reply handler: process raw CGI server response, function f to run for each 
command
 """
-#log.debug('HANDLE_REPLY: code=%r' % (resp.code))
-#for key,val in resp.headers.getAllRawHeaders():
-#log.debug('HANDLE_REPLY: key=%r val=%r' % (key, val))
-if resp.code != 200:
-resp_body = yield resp.text()
-log.critical('Received HTTP response %d: %s' % (resp.code, resp_body))
-return
-
-parsed = yield resp.json()
-#log.debug("RESPONSE: %r" % (parsed))
-bsc_id = parsed.get('commands')[0].split()[0].split('.')[3] # we expect 
1st command to have net.0.bsc.666.bts.2.trx.1 location prefix format
-log.info("Received CGI response for BSC %s with %d commands, error status: 
%s" % (bsc_id, len(parsed.get('commands')), parsed.get('error')))
-log.debug("BSC %s commands: %r" % (bsc_id, parsed.get('commands')))
-for t in parsed.get('commands'): # Process commands format
+decoded = json.loads(resp.decode('utf-8'))
+bsc_id = decoded.get('commands')[0].split()[0].split('.')[3] # we expect 
1st command to have net.0.bsc.666.bts.2.trx.1 location prefix format
+log.debug("BSC %s commands: %r" % (bsc_id, decoded.get('commands')))
+for t in decoded.get('commands'): # Process commands format
 (_, m) = Ctrl().cmd(*t.split())
 f(m)

@@ -116,8 +105,8 @@
 params = make_params(bsc, data)
 self.factory.log.debug('location-state@%s.%s.%s.%s (%s) => %s' % (net, 
bsc, bts, trx, params['time_stamp'], data))
 params['h'] = gen_hash(params, self.factory.secret_key)
-d = post(self.factory.location, None, params=params)
-d.addCallback(partial(handle_reply, self.transport.write, 
self.factory.log)) # treq's collect helper is handy to get all reply content at 
once using closure on ctx
+d = post(self.factory.location, params)
+d.addCallback(collect, partial(handle_reply, self.transport.write, 
self.factory.log)) # treq's collect helper is handy to get all reply content at 
once
 d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error 
%s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), 
bsc) # handle HTTP errors
 # Ensure that we run only limited number of requests in parallel:
 yield self.factory.semaphore.acquire()

--
To view, visit https://gerrit.osmocom.org/11953
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Gerrit-Change-Number: 11953
Gerrit-PatchSet: 4
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in libosmocore[master]: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED

2018-11-28 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11728 )

Change subject: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED
..


Patch Set 4:

I mean gsm0808_create_handover_performed() of course.


-- 
To view, visit https://gerrit.osmocom.org/11728
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I825106858bd89afc9837811b8fed2e8accc82441
Gerrit-Change-Number: 11728
Gerrit-PatchSet: 4
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Wed, 28 Nov 2018 12:51:11 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in libosmocore[master]: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED

2018-11-28 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11728 )

Change subject: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED
..


Patch Set 4:

Actually, could we add "const struct osmo_lcls *lcls" parameter to the 
function? That way we don't have to change its signature later on.


--
To view, visit https://gerrit.osmocom.org/11728
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I825106858bd89afc9837811b8fed2e8accc82441
Gerrit-Change-Number: 11728
Gerrit-PatchSet: 4
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Wed, 28 Nov 2018 12:50:37 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: ctrl2cgi: fix deferred callbacks

2018-11-28 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11953 )

Change subject: ctrl2cgi: fix deferred callbacks
..


Patch Set 3:

(1 comment)

The very point of this commit is to get rid of "yield" calls in this function 
which fixes all the issues I've seen before while testing locally. So if we 
actually need this error code than I can try to come up with a way of checking 
it. But it'll be separate commit or patch series. Which should be carefully 
tested not to break async semantics again.

https://gerrit.osmocom.org/#/c/11953/3/scripts/ctrl2cgi.py
File scripts/ctrl2cgi.py:

https://gerrit.osmocom.org/#/c/11953/3/scripts/ctrl2cgi.py@a51
PS3, Line 51:
> This resp.code stuff can still be used after changes in this commit

No, it can not. The resp is a simple byte sequence which have neither .code nor 
.body - please have a look at code change.



--
To view, visit https://gerrit.osmocom.org/11953
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Gerrit-Change-Number: 11953
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 
Gerrit-Comment-Date: Wed, 28 Nov 2018 12:31:21 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: osmo_ctrl.py: properly ignore out-of-order traps

2018-11-28 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11909 )

Change subject: osmo_ctrl.py: properly ignore out-of-order traps
..

osmo_ctrl.py: properly ignore out-of-order traps

Sometimes when we set variable we might receive arbitrary number of TRAP
messages before we get SET_REPLY. Those could be either separate
messages or combined together with SET_REPLY depending on tcp buffering
at server side. Let's handle this gracefully by skipping over all TRAP
messages.

An example command which often triggers this behavior:
./osmo_ctrl.py -s -d 127.0.0.1 -p 4249 bts.0.location (date +%s)",fix2d,1,2,3"

Change-Id: Ia6de02c2f13a56f0381c97a9ab02c6c7a31cc32f
Related: SYS#4399
---
M scripts/osmo_ctrl.py
1 file changed, 7 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved
  Neels Hofmeyr: Looks good to me, but someone else must approve



diff --git a/scripts/osmo_ctrl.py b/scripts/osmo_ctrl.py
index 2fb1765..8a67fd8 100755
--- a/scripts/osmo_ctrl.py
+++ b/scripts/osmo_ctrl.py
@@ -41,7 +41,13 @@
 _leftovers(sck, socket.MSG_DONTWAIT)
 (r, c) = Ctrl().cmd(var, value)
 sck.send(c)
-ret = sck.recv(4096)
+while True:
+ret = sck.recv(4096)
+# handle multiple messages, ignore TRAPs
+ret = Ctrl().skip_traps(ret)
+if ret != None:
+(i, k, v) = Ctrl().parse(ret)
+break;
 return (Ctrl().rem_header(ret),) + Ctrl().verify(ret, r, var, value)

 def set_var(sck, var, val):

--
To view, visit https://gerrit.osmocom.org/11909
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia6de02c2f13a56f0381c97a9ab02c6c7a31cc32f
Gerrit-Change-Number: 11909
Gerrit-PatchSet: 5
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in python/osmo-python-tests[master]: ctrl: add function to skip TRAP messages

2018-11-28 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11929 )

Change subject: ctrl: add function to skip TRAP messages
..

ctrl: add function to skip TRAP messages

This allows to easy skip TRAP messages when we do not want to process
them (for example when waiting for REPLY to a single command). Update
documentation and version accordingly.

Change-Id: I51ce207c19a1ca96c3e2af7d5efd64f79b02fbb4
---
M osmopy/osmo_ipa.py
1 file changed, 17 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/osmopy/osmo_ipa.py b/osmopy/osmo_ipa.py
index c371023..f957f41 100755
--- a/osmopy/osmo_ipa.py
+++ b/osmopy/osmo_ipa.py
@@ -2,7 +2,7 @@
 # -*- mode: python-mode; py-indent-tabs-mode: nil -*-
 """
 /*
- * Copyright (C) 2016 sysmocom s.f.m.c. GmbH
+ * Copyright (C) 2016-2018 sysmocom s.f.m.c. GmbH
  *
  * All Rights Reserved
  *
@@ -28,7 +28,7 @@
 """
 Stateless IPA protocol multiplexer: add/remove/parse (extended) header
 """
-version = "0.0.6"
+version = "0.0.7"
 TCP_PORT_OML = 3002
 TCP_PORT_RSL = 3003
 # OpenBSC extensions: OSMO, MGCP_OLD
@@ -114,6 +114,21 @@
 return struct.unpack('>HBB', data[:4]) + (data[4:], ) # length, 
protocol, extension, data
 return dlen, proto, None, data[3:] # length, protocol, _, data

+def skip_traps(self, data):
+"""
+Take one or more ctrl messages and data and return first non-TRAP 
message or None
+"""
+if data == None or len(data) == 0:
+return None
+
+(head, tail) = self.split_combined(data)
+(length, _, _, payload) = self.del_header(head)
+# skip over broken messages as well as TRAPs
+if length == 0 or payload[:(length + 
3)].decode('utf-8').startswith(self.CTRL_TRAP):
+return self.skip_traps(tail)
+
+return head
+
 def split_combined(self, data):
 """
 Split the data which contains multiple concatenated IPA messages into 
tuple (first, rest) where 'rest' contains

--
To view, visit https://gerrit.osmocom.org/11929
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I51ce207c19a1ca96c3e2af7d5efd64f79b02fbb4
Gerrit-Change-Number: 11929
Gerrit-PatchSet: 4
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in python/osmo-python-tests[master]: ctrl: cosmetic cleanup

2018-11-28 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11930 )

Change subject: ctrl: cosmetic cleanup
..

ctrl: cosmetic cleanup

* remove unused function
* move internal function call outside of main

Change-Id: I3c1bf59775f08f6252d731de653ee9cc212b31da
---
M scripts/osmo_ctrl.py
1 file changed, 1 insertion(+), 6 deletions(-)

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



diff --git a/scripts/osmo_ctrl.py b/scripts/osmo_ctrl.py
index ac20050..2fb1765 100755
--- a/scripts/osmo_ctrl.py
+++ b/scripts/osmo_ctrl.py
@@ -38,6 +38,7 @@
 return sck

 def do_set_get(sck, var, value = None):
+_leftovers(sck, socket.MSG_DONTWAIT)
 (r, c) = Ctrl().cmd(var, value)
 sck.send(c)
 ret = sck.recv(4096)
@@ -47,10 +48,6 @@
 (a, _, _) = do_set_get(sck, var, val)
 return a

-def get_var(sck, var):
-(_, _, v) = do_set_get(sck, var)
-return v
-
 def _leftovers(sck, fl):
 """
 Read outstanding data if any according to flags
@@ -102,13 +99,11 @@
 if options.cmd_set:
 if len(args) < 2:
 parser.error("Set requires var and value arguments")
-_leftovers(sock, socket.MSG_DONTWAIT)
 print("Got message:", set_var(sock, args[0], ' 
'.join(args[1:])))

 if options.cmd_get:
 if len(args) != 1:
 parser.error("Get requires the var argument")
-_leftovers(sock, socket.MSG_DONTWAIT)
 (a, _, _) = do_set_get(sock, args[0])
 print("Got message:", a)


--
To view, visit https://gerrit.osmocom.org/11930
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c1bf59775f08f6252d731de653ee9cc212b31da
Gerrit-Change-Number: 11930
Gerrit-PatchSet: 4
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in python/osmo-python-tests[master]: ctrl: add function to skip TRAP messages

2018-11-28 Thread Max
Hello Pau Espin Pedrol, daniel, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/11929

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

Change subject: ctrl: add function to skip TRAP messages
..

ctrl: add function to skip TRAP messages

This allows to easy skip TRAP messages when we do not want to process
them (for example when waiting for REPLY to a single command). Update
documentation and version accordingly.

Change-Id: I51ce207c19a1ca96c3e2af7d5efd64f79b02fbb4
---
M osmopy/osmo_ipa.py
1 file changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/29/11929/4
--
To view, visit https://gerrit.osmocom.org/11929
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I51ce207c19a1ca96c3e2af7d5efd64f79b02fbb4
Gerrit-Change-Number: 11929
Gerrit-PatchSet: 4
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in python/osmo-python-tests[master]: ctrl2cgi: fix deferred callbacks

2018-11-28 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11953 )

Change subject: ctrl2cgi: fix deferred callbacks
..


Patch Set 2:

(1 comment)

Logging should be fixed in follow-up patches.

https://gerrit.osmocom.org/#/c/11953/2/scripts/ctrl2cgi.py
File scripts/ctrl2cgi.py:

https://gerrit.osmocom.org/#/c/11953/2/scripts/ctrl2cgi.py@a51
PS2, Line 51:
> I think we wanted to handle resp codes for some specific feature, but I don't 
> remember anymore. […]
Nothing found so far. We can always add this later on if necessary once the 
current issues are resolved.



--
To view, visit https://gerrit.osmocom.org/11953
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Gerrit-Change-Number: 11953
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 
Gerrit-Comment-Date: Wed, 28 Nov 2018 11:26:12 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: Move command processing into shared function

2018-11-28 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/11974


Change subject: Move command processing into shared function
..

Move command processing into shared function

Change-Id: I4e40607a9aa5e03a7b3f5b68e4261828209a5813
---
M osmopy/trap_helper.py
M scripts/ctrl2cgi.py
M scripts/soap.py
3 files changed, 19 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/74/11974/1

diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index 6f4b95d..d07ebd3 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -24,6 +24,7 @@

 import sys, os, datetime, signal, logging, logging.handlers
 from functools import partial
+from osmopy.osmo_ipa import Ctrl
 from osmopy.twisted_ipa import CTRL
 from twisted.internet import defer

@@ -56,6 +57,17 @@
 loc = split_type(v)
 return loc[-1]

+def comm_proc(comm, f, log):
+"""
+Command processor: takes function f to run for each command
+"""
+bsc_id = comm[0].split()[0].split('.')[3] # we expect 1st command to have 
net.0.bsc.666.bts.2.trx.1 location prefix format
+log.debug("BSC %s commands: %r" % (bsc_id, comm))
+for t in comm:
+(_, m) = Ctrl().cmd(*t.split())
+f(m)
+return bsc_id
+
 def make_params(bsc, data):
 """
 Make parameters for request
diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index c566a7c..6818b2a 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -22,14 +22,14 @@
  */
 """

-__version__ = "0.0.3" # bump this on every non-trivial change
+__version__ = "0.0.4" # bump this on every non-trivial change
 
 from twisted.internet import defer, reactor
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
 from osmopy.osmo_ipa import Ctrl
 from treq import post, collect
 from functools import partial
-from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params
+from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params, comm_proc
 from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
 import argparse, datetime, signal, sys, os, logging, logging.handlers
 import hashlib
@@ -45,11 +45,7 @@
 Reply handler: process raw CGI server response, function f to run for each 
command
 """
 decoded = json.loads(resp.decode('utf-8'))
-bsc_id = decoded.get('commands')[0].split()[0].split('.')[3] # we expect 
1st command to have net.0.bsc.666.bts.2.trx.1 location prefix format
-log.debug("BSC %s commands: %r" % (bsc_id, decoded.get('commands')))
-for t in decoded.get('commands'): # Process commands format
-(_, m) = Ctrl().cmd(*t.split())
-f(m)
+comm_proc(decoded.get('commands'), f, log)

 def gen_hash(params, skey):
 input = ''
diff --git a/scripts/soap.py b/scripts/soap.py
index 75acd89..6bf786c 100755
--- a/scripts/soap.py
+++ b/scripts/soap.py
@@ -22,7 +22,7 @@
  */
 """

-__version__ = "0.7.1" # bump this on every non-trivial change
+__version__ = "0.7.2" # bump this on every non-trivial change

 from twisted.internet import defer, reactor
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
@@ -30,7 +30,7 @@
 from treq import post, collect
 from suds.client import Client
 from functools import partial
-from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params
+from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params, comm_proc
 from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
 import argparse, datetime, signal, sys, os, logging, logging.handlers

@@ -40,15 +40,11 @@

 def handle_reply(p, f, log, r):
 """
-Reply handler: takes function p to process raw SOAP server reply r, 
function f to run for each command and verbosity flag v
+Reply handler: takes function p to process raw SOAP server reply r, 
function f to run for each command
 """
 repl = p(r) # result is expected to have both commands[] array and error 
string (could be None)
-bsc_id = repl.commands[0].split()[0].split('.')[3] # we expect 1st command 
to have net.0.bsc.666.bts.2.trx.1 location prefix format
+bsc_id = comm_proc(repl.commands, f, log)
 log.info("Received SOAP response for BSC %s with %d commands, error 
status: %s" % (bsc_id, len(repl.commands), repl.error))
-log.debug("BSC %s commands: %s" % (bsc_id, repl.commands))
-for t in repl.commands: # Process OpenBscCommands format from .wsdl
-(_, 

Change in python/osmo-python-tests[master]: Improve code style

2018-11-28 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/11975


Change subject: Improve code style
..

Improve code style

* reorder imports to make pylint3 happy
* drop unused imports
* use proper spacing for list constants
* don't use reserved names for internal variables

The check was run as follows:
pylint3 -d C0103,C0301,C0410,C0326,R0913,R0901 ...
to disable useless warnings.

Change-Id: I5b90ee790f73dc509081401776911f25e43f1801
---
M osmopy/trap_helper.py
M scripts/ctrl2cgi.py
M scripts/soap.py
3 files changed, 21 insertions(+), 23 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/75/11975/1

diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index d07ebd3..d4a3b75 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -25,8 +25,6 @@
 import sys, os, datetime, signal, logging, logging.handlers
 from functools import partial
 from osmopy.osmo_ipa import Ctrl
-from osmopy.twisted_ipa import CTRL
-from twisted.internet import defer

 # keys from OpenBSC openbsc/src/libbsc/bsc_rf_ctrl.c, values SOAP-specific
 oper = { 'inoperational' : 0, 'operational' : 1 }
diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 6818b2a..1d6813d 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -24,17 +24,17 @@

 __version__ = "0.0.4" # bump this on every non-trivial change

-from twisted.internet import defer, reactor
-from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
-from osmopy.osmo_ipa import Ctrl
-from treq import post, collect
-from functools import partial
-from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params, comm_proc
-from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
-import argparse, datetime, signal, sys, os, logging, logging.handlers
+import argparse, os, logging, logging.handlers
 import hashlib
 import json
 import configparser
+from functools import partial
+from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
+from twisted.internet import defer, reactor
+from treq import post, collect
+from osmopy.trap_helper import debug_init, get_type, get_r, p_h, make_params, 
comm_proc
+from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
+from osmopy.osmo_ipa import Ctrl

 # we don't support older versions of TwistedIPA module
 assert V(twisted_ipa_version) > V('0.4')
@@ -48,14 +48,14 @@
 comm_proc(decoded.get('commands'), f, log)

 def gen_hash(params, skey):
-input = ''
-for key in 
['time_stamp','position_validity','admin_status','policy_status']:
-input += str(params.get(key))
-input += skey
-for key in ['bsc_id','lat','lon','position_validity']:
-input += str(params.get(key))
+inp = ''
+for key in ['time_stamp', 'position_validity', 'admin_status', 
'policy_status']:
+inp += str(params.get(key))
+inp += skey
+for key in ['bsc_id', 'lat', 'lon', 'position_validity']:
+inp += str(params.get(key))
 m = hashlib.md5()
-m.update(input.encode('utf-8'))
+m.update(inp.encode('utf-8'))
 res = m.hexdigest()
 #print('HASH: \nparams="%r"\ninput="%s" \nres="%s"' %(params, input, res))
 return res
diff --git a/scripts/soap.py b/scripts/soap.py
index 6bf786c..267b4d8 100755
--- a/scripts/soap.py
+++ b/scripts/soap.py
@@ -24,15 +24,15 @@

 __version__ = "0.7.2" # bump this on every non-trivial change

+import argparse, os, logging
+from functools import partial
+from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
 from twisted.internet import defer, reactor
+from suds.client import Client
+from treq import post, collect
+from osmopy.trap_helper import debug_init, get_type, get_r, p_h, make_params, 
comm_proc
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
 from osmopy.osmo_ipa import Ctrl
-from treq import post, collect
-from suds.client import Client
-from functools import partial
-from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params, comm_proc
-from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
-import argparse, datetime, signal, sys, os, logging, logging.handlers

 # we don't support older versions of TwistedIPA module
 assert V(twisted_ipa_version) > V('0.4')

--
To view, visit https://gerrit.osmocom.org/11975
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b90ee790f73dc509081401776911f25e43f1801
Gerrit-Change-Number: 11975
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in python/osmo-python-tests[master]: Drop unused Trap() class

2018-11-28 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/11973


Change subject: Drop unused Trap() class
..

Drop unused Trap() class

Change-Id: Ic2066a66f99a059fc65cf3092170e248288c04d4
---
M osmopy/trap_helper.py
1 file changed, 0 insertions(+), 59 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/73/11973/1

diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index f7a64c8..6f4b95d 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -71,65 +71,6 @@
 loc = split_type(v)
 return partial(lambda a, i: a[i] if len(a) > i else None, loc)

-class Trap(CTRL):
-"""
-TRAP handler (agnostic to factory's client object)
-"""
-def ctrl_TRAP(self, data, op_id, v):
-"""
-Parse CTRL TRAP and dispatch to appropriate handler after normalization
-"""
-self.factory.log.debug('TRAP %s' % v)
-(l, r) = v.split()
-loc = l.split('.')
-t_type = loc[-1]
-p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse 
helper
-method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: 
"Unhandled %s trap" % t_type)
-method(p(1), p(3), p(5), p(7), r) # we expect 
net.0.bsc.666.bts.2.trx.1 format for trap prefix
-
-def ctrl_SET_REPLY(self, data, _, v):
-"""
-Debug log for replies to our commands
-"""
-self.factory.log.debug('SET REPLY %s' % v)
-
-def ctrl_ERROR(self, data, op_id, v):
-"""
-We want to know if smth went wrong
-"""
-self.factory.log.debug('CTRL ERROR [%s] %s' % (op_id, v))
-
-def connectionMade(self):
-"""
-Logging wrapper, calling super() is necessary not to break 
reconnection logic
-"""
-self.factory.log.info("Connected to CTRL@%s:%d" % (self.factory.host, 
self.factory.port))
-super(CTRL, self).connectionMade()
-
-@defer.inlineCallbacks
-def handle_locationstate(self, net, bsc, bts, trx, data):
-"""
-Handle location-state TRAP: parse trap content, prepare parameters and 
use treq's routines to post it while setting up async handlers
-"""
-(ts, fx, lat, lon, height, opr, adm, pol, mcc, mnc) = data.split(',')
-tstamp = datetime.datetime.fromtimestamp(float(ts)).isoformat()
-self.factory.log.debug('location-state@%s.%s.%s.%s (%s) [%s/%s] => %s' 
% (net, bsc, bts, trx, tstamp, mcc, mnc, data))
-
-d = self.factory.prepare_params(bsc, lon, lat, fix.get(fx, 0), tstamp, 
oper.get(opr, 2), admin.get(adm, 2), policy.get(pol, 3))
-
-d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error 
%s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), 
bsc) # handle HTTP errors
-# Ensure that we run only limited number of requests in parallel:
-yield self.factory.semaphore.acquire()
-yield d # we end up here only if semaphore is available which means 
it's ok to fire the request without exceeding the limit
-self.factory.semaphore.release()
-
-def handle_notificationrejectionv1(self, net, bsc, bts, trx, data):
-"""
-Handle notification-rejection-v1 TRAP: just an example to show how 
more message types can be handled
-"""
-self.factory.log.debug('notification-rejection-v1@bsc-id %s => %s' % 
(bsc, data))
-
-
 def reloader(path, script, log, dbg1, dbg2, signum, _):
 """
 Signal handler: we have to use execl() because twisted's reactor is not 
restartable due to some bug in twisted implementation

--
To view, visit https://gerrit.osmocom.org/11973
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2066a66f99a059fc65cf3092170e248288c04d4
Gerrit-Change-Number: 11973
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in python/osmo-python-tests[master]: ctrl2cgi: fix deferred callbacks

2018-11-28 Thread Max
Hello Pau Espin Pedrol, daniel, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/11953

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

Change subject: ctrl2cgi: fix deferred callbacks
..

ctrl2cgi: fix deferred callbacks

Previously handle_reply() was marked as deferred callback unlike soap.py
where it's synchronous function. This seems to be causing issues where
some of the callbacks are not yield properly. Let's move to the
known-to-work semantics of soap.py where async functions are limited to
Trap() class.

Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Related: SYS#4399
---
M scripts/ctrl2cgi.py
1 file changed, 7 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/53/11953/3
--
To view, visit https://gerrit.osmocom.org/11953
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Gerrit-Change-Number: 11953
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in python/osmo-python-tests[master]: Update trap helper

2018-11-27 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11951 )

Change subject: Update trap helper
..

Update trap helper

* add missing import
* update docs
* add helper functions

Change-Id: Ie6dc8808efc76ad96b400913e5caa405bce7d970
Related: SYS#4399
---
M osmopy/trap_helper.py
1 file changed, 40 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index 4704564..f7a64c8 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -22,7 +22,7 @@
  */
 """

-import sys, os, signal, logging, logging.handlers
+import sys, os, datetime, signal, logging, logging.handlers
 from functools import partial
 from osmopy.twisted_ipa import CTRL
 from twisted.internet import defer
@@ -35,6 +35,42 @@
 # keys from OpenBSC openbsc/src/libbsc/bsc_vty.c
 fix = { 'invalid' : 0, 'fix2d' : 1, 'fix3d' : 1 } # SOAP server treats it as 
boolean but expects int

+def split_type(v):
+"""
+Split TRAP type into list
+"""
+(l, _) = v.split()
+return l.split('.')
+
+def get_r(v):
+"""
+Split TRAP record
+"""
+(_, r) = v.split()
+return r
+
+def get_type(v):
+"""
+Get TRAP type
+"""
+loc = split_type(v)
+return loc[-1]
+
+def make_params(bsc, data):
+"""
+Make parameters for request
+"""
+(ts, fx, lat, lon, _, opr, adm, pol, _, _) = data.split(',')
+tstamp = datetime.datetime.fromtimestamp(float(ts)).isoformat()
+return {'bsc_id': bsc, 'lon': lon, 'lat': lat, 'position_validity': 
fix.get(fx, 0), 'time_stamp': tstamp, 'oper_status': oper.get(opr, 2), 
'admin_status': admin.get(adm, 2), 'policy_status': policy.get(pol, 3) }
+
+def p_h(v):
+"""
+Parse helper for method dispatch: expected format is 
net.0.bsc.666.bts.2.trx.1
+"""
+loc = split_type(v)
+return partial(lambda a, i: a[i] if len(a) > i else None, loc)
+
 class Trap(CTRL):
 """
 TRAP handler (agnostic to factory's client object)
@@ -109,6 +145,9 @@
 os.execl(path, script, *sys.argv[1:])

 def debug_init(name, is_debug, output):
+"""
+Initialize signal handlers and logging
+"""
 log = logging.getLogger(name)
 if is_debug:
 log.setLevel(logging.DEBUG)

--
To view, visit https://gerrit.osmocom.org/11951
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie6dc8808efc76ad96b400913e5caa405bce7d970
Gerrit-Change-Number: 11951
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in python/osmo-python-tests[master]: Move Trap class back to separate files

2018-11-27 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11952 )

Change subject: Move Trap class back to separate files
..

Move Trap class back to separate files

After further testing it turns out that Trap() have too many
implementation details which makes it cumbersome to be shared. Instead,
it's easier to make it into wrapper over shared functions.

Change-Id: I8a3c62bcdf4286f8127c5b6d8dee6d740aca23b9
---
M scripts/ctrl2cgi.py
M scripts/soap.py
2 files changed, 114 insertions(+), 15 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 18cfdbe..843aeb9 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -22,14 +22,14 @@
  */
 """

-__version__ = "0.0.1" # bump this on every non-trivial change
+__version__ = "0.0.2" # bump this on every non-trivial change

 from twisted.internet import defer, reactor
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
 from osmopy.osmo_ipa import Ctrl
 from treq import post, collect
 from functools import partial
-from osmopy.trap_helper import Trap, reloader, debug_init
+from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params
 from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
 import argparse, datetime, signal, sys, os, logging, logging.handlers
 import hashlib
@@ -75,6 +75,61 @@
 #print('HASH: \nparams="%r"\ninput="%s" \nres="%s"' %(params, input, res))
 return res

+class Trap(CTRL):
+"""
+TRAP handler (agnostic to factory's client object)
+"""
+def ctrl_TRAP(self, data, op_id, v):
+"""
+Parse CTRL TRAP and dispatch to appropriate handler after normalization
+"""
+self.factory.log.debug('TRAP %s' % v)
+t_type = get_type(v)
+p = p_h(v)
+method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: 
"Unhandled %s trap" % t_type)
+method(p(1), p(3), p(5), p(7), get_r(v))
+
+def ctrl_SET_REPLY(self, data, _, v):
+"""
+Debug log for replies to our commands
+"""
+self.factory.log.debug('SET REPLY %s' % v)
+
+def ctrl_ERROR(self, data, op_id, v):
+"""
+We want to know if smth went wrong
+"""
+self.factory.log.debug('CTRL ERROR [%s] %s' % (op_id, v))
+
+def connectionMade(self):
+"""
+Logging wrapper, calling super() is necessary not to break 
reconnection logic
+"""
+self.factory.log.info("Connected to CTRL@%s:%d" % (self.factory.host, 
self.factory.port))
+super(CTRL, self).connectionMade()
+
+@defer.inlineCallbacks
+def handle_locationstate(self, net, bsc, bts, trx, data):
+"""
+Handle location-state TRAP: parse trap content, build CGI Request and 
use treq's routines to post it while setting up async handlers
+"""
+params = make_params(bsc, data)
+self.factory.log.debug('location-state@%s.%s.%s.%s (%s) => %s' % (net, 
bsc, bts, trx, params['time_stamp'], data))
+params['h'] = gen_hash(params, self.factory.secret_key)
+d = post(self.factory.location, None, params=params)
+d.addCallback(partial(handle_reply, self.transport.write, 
self.factory.log)) # treq's collect helper is handy to get all reply content at 
once using closure on ctx
+d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error 
%s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), 
bsc) # handle HTTP errors
+# Ensure that we run only limited number of requests in parallel:
+yield self.factory.semaphore.acquire()
+yield d # we end up here only if semaphore is available which means 
it's ok to fire the request without exceeding the limit
+self.factory.semaphore.release()
+
+def handle_notificationrejectionv1(self, net, bsc, bts, trx, data):
+"""
+Handle notification-rejection-v1 TRAP: just an example to show how 
more message types can be handled
+"""
+self.factory.log.debug('notification-rejection-v1@bsc-id %s => %s' % 
(bsc, data))
+

 class TrapFactory(IPAFactory):
 """
@@ -100,12 +155,6 @@
 self.log.setLevel(level)
 self.log.debug("Using IPA %s, CGI server: %s" % (Ctrl.version, 
self.loca

Change in python/osmo-python-tests[master]: ctrl2cgi: fix deferred callbacks

2018-11-27 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11953 )

Change subject: ctrl2cgi: fix deferred callbacks
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11953
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Gerrit-Change-Number: 11953
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 
Gerrit-Comment-Date: Tue, 27 Nov 2018 17:27:59 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: Move Trap class back to separate files

2018-11-27 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11952 )

Change subject: Move Trap class back to separate files
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11952
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8a3c62bcdf4286f8127c5b6d8dee6d740aca23b9
Gerrit-Change-Number: 11952
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Tue, 27 Nov 2018 17:27:20 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: Update trap helper

2018-11-27 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11951 )

Change subject: Update trap helper
..


Set Ready For Review


--
To view, visit https://gerrit.osmocom.org/11951
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie6dc8808efc76ad96b400913e5caa405bce7d970
Gerrit-Change-Number: 11951
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Tue, 27 Nov 2018 17:26:04 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: ctrl2cgi: fix deferred callbacks

2018-11-27 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/11953


Change subject: ctrl2cgi: fix deferred callbacks
..

ctrl2cgi: fix deferred callbacks

Previously handle_reply() was marked as deferred callback unlike soap.py
where it's synchronous function. This seems to be causing issues where
some of the callbacks are not yield properly. Let's move to the
known-to-work semantics of soap.py where async functions are limited to
Trap() class.

Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Related: SYS#4399
---
M scripts/ctrl2cgi.py
1 file changed, 5 insertions(+), 18 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/53/11953/1

diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 9c47c92..5a2c8c7 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -22,7 +22,7 @@
  */
 """

-__version__ = "0.0.2" # bump this on every non-trivial change
+__version__ = "0.0.3" # bump this on every non-trivial change

 from twisted.internet import defer, reactor
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
@@ -40,25 +40,12 @@
 assert V(twisted_ipa_version) > V('0.4')


-@defer.inlineCallbacks
 def handle_reply(f, log, resp):
 """
 Reply handler: process raw CGI server response, function f to run for each 
command
 """
-#log.debug('HANDLE_REPLY: code=%r' % (resp.code))
-#for key,val in resp.headers.getAllRawHeaders():
-#log.debug('HANDLE_REPLY: key=%r val=%r' % (key, val))
-if resp.code != 200:
-resp_body = yield resp.text()
-log.critical('Received HTTP response %d: %s' % (resp.code, resp_body))
-return
-
-parsed = yield resp.json()
-#log.debug("RESPONSE: %r" % (parsed))
-bsc_id = parsed.get('commands')[0].split()[0].split('.')[3] # we expect 
1st command to have net.0.bsc.666.bts.2.trx.1 location prefix format
-log.info("Received CGI response for BSC %s with %d commands, error status: 
%s" % (bsc_id, len(parsed.get('commands')), parsed.get('error')))
-log.debug("BSC %s commands: %r" % (bsc_id, parsed.get('commands')))
-for t in parsed.get('commands'): # Process commands format
+decoded = json.loads(resp.decode('utf-8'))
+for t in decoded.get('commands'): # Process commands format
 (_, m) = Ctrl().cmd(*t.split())
 f(m)

@@ -116,8 +103,8 @@
 params = make_params(bsc, data)
 self.factory.log.debug('location-state@%s.%s.%s.%s (%s) => %s' % (net, 
bsc, bts, trx, params['tstamp'], data))
 params['h'] = gen_hash(params, self.factory.secret_key)
-d = post(self.factory.location, None, params=params)
-d.addCallback(partial(handle_reply, self.transport.write, 
self.factory.log)) # treq's collect helper is handy to get all reply content at 
once using closure on ctx
+d = post(self.factory.location, params)
+d.addCallback(collect, partial(handle_reply, self.transport.write, 
self.factory.log))
 d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error 
%s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), 
bsc) # handle HTTP errors
 # Ensure that we run only limited number of requests in parallel:
 yield self.factory.semaphore.acquire()

--
To view, visit https://gerrit.osmocom.org/11953
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib2c28dd7f79cbd28d475de93750703659ddd18f1
Gerrit-Change-Number: 11953
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in python/osmo-python-tests[master]: Update trap helper

2018-11-27 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/11951


Change subject: Update trap helper
..

Update trap helper

* add missing import
* update docs
* add helper functions

Change-Id: Ie6dc8808efc76ad96b400913e5caa405bce7d970
Related: SYS#4399
---
M osmopy/trap_helper.py
1 file changed, 40 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/51/11951/1

diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index 4704564..f7a64c8 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -22,7 +22,7 @@
  */
 """

-import sys, os, signal, logging, logging.handlers
+import sys, os, datetime, signal, logging, logging.handlers
 from functools import partial
 from osmopy.twisted_ipa import CTRL
 from twisted.internet import defer
@@ -35,6 +35,42 @@
 # keys from OpenBSC openbsc/src/libbsc/bsc_vty.c
 fix = { 'invalid' : 0, 'fix2d' : 1, 'fix3d' : 1 } # SOAP server treats it as 
boolean but expects int

+def split_type(v):
+"""
+Split TRAP type into list
+"""
+(l, _) = v.split()
+return l.split('.')
+
+def get_r(v):
+"""
+Split TRAP record
+"""
+(_, r) = v.split()
+return r
+
+def get_type(v):
+"""
+Get TRAP type
+"""
+loc = split_type(v)
+return loc[-1]
+
+def make_params(bsc, data):
+"""
+Make parameters for request
+"""
+(ts, fx, lat, lon, _, opr, adm, pol, _, _) = data.split(',')
+tstamp = datetime.datetime.fromtimestamp(float(ts)).isoformat()
+return {'bsc_id': bsc, 'lon': lon, 'lat': lat, 'position_validity': 
fix.get(fx, 0), 'time_stamp': tstamp, 'oper_status': oper.get(opr, 2), 
'admin_status': admin.get(adm, 2), 'policy_status': policy.get(pol, 3) }
+
+def p_h(v):
+"""
+Parse helper for method dispatch: expected format is 
net.0.bsc.666.bts.2.trx.1
+"""
+loc = split_type(v)
+return partial(lambda a, i: a[i] if len(a) > i else None, loc)
+
 class Trap(CTRL):
 """
 TRAP handler (agnostic to factory's client object)
@@ -109,6 +145,9 @@
 os.execl(path, script, *sys.argv[1:])

 def debug_init(name, is_debug, output):
+"""
+Initialize signal handlers and logging
+"""
 log = logging.getLogger(name)
 if is_debug:
 log.setLevel(logging.DEBUG)

--
To view, visit https://gerrit.osmocom.org/11951
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6dc8808efc76ad96b400913e5caa405bce7d970
Gerrit-Change-Number: 11951
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in python/osmo-python-tests[master]: Move Trap class back to separate files

2018-11-27 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/11952


Change subject: Move Trap class back to separate files
..

Move Trap class back to separate files

After further testing it turns out that Trap() have too many
implementation details which makes it cumbersome to be shared. Instead,
it's easier to make it into wrapper over shared functions.

Change-Id: I8a3c62bcdf4286f8127c5b6d8dee6d740aca23b9
---
M scripts/ctrl2cgi.py
M scripts/soap.py
2 files changed, 114 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/52/11952/1

diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 18cfdbe..9c47c92 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -22,14 +22,14 @@
  */
 """

-__version__ = "0.0.1" # bump this on every non-trivial change
+__version__ = "0.0.2" # bump this on every non-trivial change

 from twisted.internet import defer, reactor
 from osmopy.twisted_ipa import CTRL, IPAFactory, __version__ as 
twisted_ipa_version
 from osmopy.osmo_ipa import Ctrl
 from treq import post, collect
 from functools import partial
-from osmopy.trap_helper import Trap, reloader, debug_init
+from osmopy.trap_helper import reloader, debug_init, get_type, get_r, p_h, 
make_params
 from distutils.version import StrictVersion as V # FIXME: use 
NormalizedVersion from PEP-386 when available
 import argparse, datetime, signal, sys, os, logging, logging.handlers
 import hashlib
@@ -75,6 +75,61 @@
 #print('HASH: \nparams="%r"\ninput="%s" \nres="%s"' %(params, input, res))
 return res

+class Trap(CTRL):
+"""
+TRAP handler (agnostic to factory's client object)
+"""
+def ctrl_TRAP(self, data, op_id, v):
+"""
+Parse CTRL TRAP and dispatch to appropriate handler after normalization
+"""
+self.factory.log.debug('TRAP %s' % v)
+t_type = get_type(v)
+p = p_h(v)
+method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: 
"Unhandled %s trap" % t_type)
+method(p(1), p(3), p(5), p(7), get_r(v))
+
+def ctrl_SET_REPLY(self, data, _, v):
+"""
+Debug log for replies to our commands
+"""
+self.factory.log.debug('SET REPLY %s' % v)
+
+def ctrl_ERROR(self, data, op_id, v):
+"""
+We want to know if smth went wrong
+"""
+self.factory.log.debug('CTRL ERROR [%s] %s' % (op_id, v))
+
+def connectionMade(self):
+"""
+Logging wrapper, calling super() is necessary not to break 
reconnection logic
+"""
+self.factory.log.info("Connected to CTRL@%s:%d" % (self.factory.host, 
self.factory.port))
+super(CTRL, self).connectionMade()
+
+@defer.inlineCallbacks
+def handle_locationstate(self, net, bsc, bts, trx, data):
+"""
+Handle location-state TRAP: parse trap content, build CGI Request and 
use treq's routines to post it while setting up async handlers
+"""
+params = make_params(bsc, data)
+self.factory.log.debug('location-state@%s.%s.%s.%s (%s) => %s' % (net, 
bsc, bts, trx, params['tstamp'], data))
+params['h'] = gen_hash(params, self.factory.secret_key)
+d = post(self.factory.location, None, params=params)
+d.addCallback(partial(handle_reply, self.transport.write, 
self.factory.log)) # treq's collect helper is handy to get all reply content at 
once using closure on ctx
+d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error 
%s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), 
bsc) # handle HTTP errors
+# Ensure that we run only limited number of requests in parallel:
+yield self.factory.semaphore.acquire()
+yield d # we end up here only if semaphore is available which means 
it's ok to fire the request without exceeding the limit
+self.factory.semaphore.release()
+
+def handle_notificationrejectionv1(self, net, bsc, bts, trx, data):
+"""
+Handle notification-rejection-v1 TRAP: just an example to show how 
more message types can be handled
+"""
+self.factory.log.debug('notification-rejection-v1@bsc-id %s => %s' % 
(bsc, data))
+

 class TrapFactory(IPAFactory):
 """
@@ -100,12 +155,6 @@
 self.log.setLevel(level)
 self.log.debug("Using IPA %s, CGI server: %s" % (Ctrl.version, 
self.location))

-def pre

Change in osmo-sysmon[master]: fix file descriptor leak in osysmon_file_read

2018-11-27 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11943 )

Change subject: fix file descriptor leak in osysmon_file_read
..


Patch Set 2: Code-Review+1

(2 comments)

Just a minor thing though - can be merged either way.

https://gerrit.osmocom.org/#/c/11943/2/osysmon_file.c
File osysmon_file.c:

https://gerrit.osmocom.org/#/c/11943/2/osysmon_file.c@80
PS2, Line 80:   char *s, *nl;
Seems like you don't need new variable.


https://gerrit.osmocom.org/#/c/11943/2/osysmon_file.c@93
PS2, Line 93:   }
s is not used after here and nl is not used before.



--
To view, visit https://gerrit.osmocom.org/11943
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sysmon
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie1b5734748438c6d785cd96dfa9af6303cd102da
Gerrit-Change-Number: 11943
Gerrit-PatchSet: 2
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-Comment-Date: Tue, 27 Nov 2018 15:05:44 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: Yes


Change in python/osmo-python-tests[master]: Re-apply changes to trap_helper.py

2018-11-27 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11948 )

Change subject: Re-apply changes to trap_helper.py
..

Re-apply changes to trap_helper.py

Due to changes getting out of sync, changes from
I44035323b70f04eb8f5dc12123cb708f53eba188 and
I21ff593be420a374a00073953c9254a013c43164 were overwritten by
I7b59f2dbded9074d15f2d2f40bf5a92ed02601e2 moving code to different
file. Fix this by re-applying those changes in new location.

Change-Id: I811f307ded63e7e1544243921ee07dceae81e295
---
M osmopy/trap_helper.py
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index a3ffbff..4704564 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -43,11 +43,12 @@
 """
 Parse CTRL TRAP and dispatch to appropriate handler after normalization
 """
+self.factory.log.debug('TRAP %s' % v)
 (l, r) = v.split()
 loc = l.split('.')
 t_type = loc[-1]
 p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse 
helper
-method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda: 
"Unhandled %s trap" % t_type)
+method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: 
"Unhandled %s trap" % t_type)
 method(p(1), p(3), p(5), p(7), r) # we expect 
net.0.bsc.666.bts.2.trx.1 format for trap prefix

 def ctrl_SET_REPLY(self, data, _, v):

--
To view, visit https://gerrit.osmocom.org/11948
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I811f307ded63e7e1544243921ee07dceae81e295
Gerrit-Change-Number: 11948
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 


Change in python/osmo-python-tests[master]: Re-apply changes to trap_helper.py

2018-11-27 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/11948


Change subject: Re-apply changes to trap_helper.py
..

Re-apply changes to trap_helper.py

Due to changes getting out of sync, changes from
I44035323b70f04eb8f5dc12123cb708f53eba188 and
I21ff593be420a374a00073953c9254a013c43164 were overwritten by
I7b59f2dbded9074d15f2d2f40bf5a92ed02601e2 moving code to different
file. Fix this by re-applying those changes in new location.

Change-Id: I811f307ded63e7e1544243921ee07dceae81e295
---
M osmopy/trap_helper.py
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/48/11948/1

diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index a3ffbff..4704564 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -43,11 +43,12 @@
 """
 Parse CTRL TRAP and dispatch to appropriate handler after normalization
 """
+self.factory.log.debug('TRAP %s' % v)
 (l, r) = v.split()
 loc = l.split('.')
 t_type = loc[-1]
 p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse 
helper
-method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda: 
"Unhandled %s trap" % t_type)
+method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: 
"Unhandled %s trap" % t_type)
 method(p(1), p(3), p(5), p(7), r) # we expect 
net.0.bsc.666.bts.2.trx.1 format for trap prefix

 def ctrl_SET_REPLY(self, data, _, v):

--
To view, visit https://gerrit.osmocom.org/11948
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I811f307ded63e7e1544243921ee07dceae81e295
Gerrit-Change-Number: 11948
Gerrit-PatchSet: 1
Gerrit-Owner: Max 


Change in libosmocore[master]: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED

2018-11-27 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11728 )

Change subject: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED
..


Patch Set 4:

(1 comment)

https://gerrit.osmocom.org/#/c/11728/4/src/gsm/gsm0808.c
File src/gsm/gsm0808.c:

https://gerrit.osmocom.org/#/c/11728/4/src/gsm/gsm0808.c@913
PS4, Line 913:  msgb_tlv_put(msg, GSM0808_IE_CAUSE, params->cause & 0x80 ? 2 : 
1, (const uint8_t *)¶ms->cause);
> It's about extended cause, I saw Max adding some code to handle that 
> recently. […]
Yes, it does - at least it's the same IE. See gsm0808_cause_ext() in libosmocore



--
To view, visit https://gerrit.osmocom.org/11728
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I825106858bd89afc9837811b8fed2e8accc82441
Gerrit-Change-Number: 11728
Gerrit-PatchSet: 4
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 27 Nov 2018 12:00:48 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED

2018-11-27 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11728 )

Change subject: gsm0808: add message generator for BSSMAP HANDOVER PERFORMED
..


Patch Set 4:

On another note - most likely I'll need to add LCLS-related stuff to this 
message later on.


--
To view, visit https://gerrit.osmocom.org/11728
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I825106858bd89afc9837811b8fed2e8accc82441
Gerrit-Change-Number: 11728
Gerrit-PatchSet: 4
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: dexter 
Gerrit-CC: Pau Espin Pedrol 
Gerrit-Comment-Date: Tue, 27 Nov 2018 12:01:51 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: ctrl: add function to skip TRAP messages

2018-11-27 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/11929 )

Change subject: ctrl: add function to skip TRAP messages
..


Patch Set 3:

> if you'd receive an IPA message with len(payload) == 0 followed by an IPA 
> message containing a CTRL message

Could you provide an example - how this can be generated?


--
To view, visit https://gerrit.osmocom.org/11929
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I51ce207c19a1ca96c3e2af7d5efd64f79b02fbb4
Gerrit-Change-Number: 11929
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: daniel 
Gerrit-Comment-Date: Tue, 27 Nov 2018 11:52:50 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in python/osmo-python-tests[master]: Move common Trap-related code into separate file

2018-11-27 Thread Max
Max has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11936 )

Change subject: Move common Trap-related code into separate file
..

Move common Trap-related code into separate file

The ctrl2cgi.py is heavily based upon soap.py - let's move all the
shared code into separate file to make further modifications easier.

Change-Id: I7b59f2dbded9074d15f2d2f40bf5a92ed02601e2
Related: SYS#4399
---
M README
M osmopy/__init__.py
A osmopy/trap_helper.py
M scripts/ctrl2cgi.py
M scripts/soap.py
5 files changed, 147 insertions(+), 194 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/README b/README
index 37cd847..76defb6 100644
--- a/README
+++ b/README
@@ -33,6 +33,7 @@
 Libraries:
 osmopy/osmoutil.py - code that's shared between the scripts
 osmopy/osmo_ipa.py - generic implementation of IPA and Ctrl protocols in python
+osmopy/trap_helper.py - generic Trap class and related helpers used by soap.py 
and ctrl2cgi.py
 osmopy/osmo_interact/{vty,ctrl}.py - general interactions with VTY and CTRL 
ports
 osmopy/obscvty.py - connect to a vty, superseded by osmo_interact/vty

diff --git a/osmopy/__init__.py b/osmopy/__init__.py
index 2195498..ce78caf 100644
--- a/osmopy/__init__.py
+++ b/osmopy/__init__.py
@@ -1,4 +1,4 @@
 #!/usr/bin/env python
-__version__ = '0.0.9'
+__version__ = '0.1.0'

-__all__ = ['obscvty', 'osmoutil', 'osmo_ipa', 'osmo_interact', 'twisted_ipa']
+__all__ = ['obscvty', 'osmoutil', 'osmo_ipa', 'osmo_interact', 'trap_helper', 
'twisted_ipa']
diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
new file mode 100644
index 000..a3ffbff
--- /dev/null
+++ b/osmopy/trap_helper.py
@@ -0,0 +1,126 @@
+#!/usr/bin/python3
+# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
+"""
+/*
+ * Copyright (C) 2018 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 sys, os, signal, logging, logging.handlers
+from functools import partial
+from osmopy.twisted_ipa import CTRL
+from twisted.internet import defer
+
+# keys from OpenBSC openbsc/src/libbsc/bsc_rf_ctrl.c, values SOAP-specific
+oper = { 'inoperational' : 0, 'operational' : 1 }
+admin = { 'locked' : 0, 'unlocked' : 1 }
+policy = { 'off' : 0, 'on' : 1, 'grace' : 2, 'unknown' : 3 }
+
+# keys from OpenBSC openbsc/src/libbsc/bsc_vty.c
+fix = { 'invalid' : 0, 'fix2d' : 1, 'fix3d' : 1 } # SOAP server treats it as 
boolean but expects int
+
+class Trap(CTRL):
+"""
+TRAP handler (agnostic to factory's client object)
+"""
+def ctrl_TRAP(self, data, op_id, v):
+"""
+Parse CTRL TRAP and dispatch to appropriate handler after normalization
+"""
+(l, r) = v.split()
+loc = l.split('.')
+t_type = loc[-1]
+p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse 
helper
+method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda: 
"Unhandled %s trap" % t_type)
+method(p(1), p(3), p(5), p(7), r) # we expect 
net.0.bsc.666.bts.2.trx.1 format for trap prefix
+
+def ctrl_SET_REPLY(self, data, _, v):
+"""
+Debug log for replies to our commands
+"""
+self.factory.log.debug('SET REPLY %s' % v)
+
+def ctrl_ERROR(self, data, op_id, v):
+"""
+We want to know if smth went wrong
+"""
+self.factory.log.debug('CTRL ERROR [%s] %s' % (op_id, v))
+
+def connectionMade(self):
+"""
+Logging wrapper, calling super() is necessary not to break 
reconnection logic
+"""
+self.factory.log.info("Connected to CTRL@%s:%d" % (self.factory.host, 
self.factory.port))
+super(CTRL

<    7   8   9   10   11   12   13   14   15   16   >