Build failure of network:osmocom:nightly/libsmpp34 in xUbuntu_17.04/i586

2018-02-28 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/libsmpp34/xUbuntu_17.04/i586

Package network:osmocom:nightly/libsmpp34 failed to build in xUbuntu_17.04/i586

Check out the package for editing:
  osc checkout network:osmocom:nightly libsmpp34

Last lines of build log:
[   42s] update-alternatives: using /usr/bin/info to provide 
/usr/bin/infobrowser (infobrowser) in auto mode
[   42s] Processing triggers for mime-support (3.60ubuntu1) ...
[   42s] [158/218] installing libgdbm3-1.8.3-14
[   42s] Processing triggers for libc-bin (2.24-9ubuntu2) ...
[   42s] [159/218] installing g++-4:6.3.0-2ubuntu1
[   42s] update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) 
in auto mode
[   42s] [160/218] installing grep-2.27-2
[   42s] Processing triggers for install-info (6.3.0.dfsg.1-1) ...
[   42s] [161/218] installing libcgmanager0-0.41-2
[   42s] Processing triggers for libc-bin (2.24-9ubuntu2) ...
[   42s] [162/218] installing libtool-2.4.6-2
[   42s] [163/218] installing libgssapi3-heimdal-7.1.0+dfsg-9ubuntu1
[   42s] Processing triggers for libc-bin (2.24-9ubuntu2) ...
[   42s] [164/218] installing tzdata-2017b-1
[   43s] Current default time zone: 'Etc/UTC'
[   43s] Local time is now:  Wed Feb 28 19:54:06 UTC 2018.
[   43s] Universal Time is now:  Wed Feb 28 19:54:06 UTC 2018.
[   43s] Run 'dpkg-reconfigure tzdata' if you wish to change it.
[   43s] [165/218] installing libssl1.0.0-1.0.2g-1ubuntu11
[   43s] Processing triggers for libc-bin (2.24-9ubuntu2) ...
[   44s] [166/218] installing locales-2.24-9ubuntu2
[28849s] qemu-system-x86_64: terminating on signal 15 from pid 10684 ()
[28849s] qemu-system-x86_64: Failed to unlink socket 
/var/cache/obs/worker/root_11/root.monitor: Permission denied
[28849s] ### VM INTERACTION END ###
[28849s] No buildstatus set, either the base system is broken 
(kernel/initrd/udev/glibc/bash/perl)
[28849s] or the build host has a kernel or hardware problem...


Job seems to be stuck here, killed. (after 28800 seconds of inactivity)

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


[PATCH] libosmocore[master]: timer: Introduce osmo_clock_gettime to override clock_gettime

2018-02-28 Thread Pau Espin Pedrol
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6961

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

timer: Introduce osmo_clock_gettime to override clock_gettime

Change-Id: I5bebc6e01fc9d238065bc2517058f0ba85620349
---
M include/osmocom/core/timer.h
M src/Makefile.am
A src/timer_clockgettime.c
M src/timer_gettimeofday.c
M tests/Makefile.am
M tests/testsuite.at
A tests/timer/clk_override_test.c
A tests/timer/clk_override_test.ok
8 files changed, 255 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/61/6961/2

diff --git a/include/osmocom/core/timer.h b/include/osmocom/core/timer.h
index 4958efb..caf4c67 100644
--- a/include/osmocom/core/timer.h
+++ b/include/osmocom/core/timer.h
@@ -40,6 +40,7 @@
 #pragma once
 
 #include 
+#include 
 #include 
 
 #include 
@@ -87,6 +88,7 @@
 int osmo_timers_check(void);
 
 int osmo_gettimeofday(struct timeval *tv, struct timezone *tz);
+int osmo_clock_gettime(clockid_t clk_id, struct timespec *tp);
 
 /*
  * timer override
@@ -96,4 +98,8 @@
 extern struct timeval osmo_gettimeofday_override_time;
 void osmo_gettimeofday_override_add(time_t secs, suseconds_t usecs);
 
+void osmo_clock_override_enable(clockid_t clk_id, bool enable);
+void osmo_clock_override_add(clockid_t clk_id, time_t secs, long nsecs);
+struct timespec *osmo_clock_override_gettimespec(clockid_t clk_id);
+
 /*! @} */
diff --git a/src/Makefile.am b/src/Makefile.am
index 3d6e6f7..2641a97 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,7 +13,8 @@
 lib_LTLIBRARIES = libosmocore.la
 
 libosmocore_la_LIBADD = $(BACKTRACE_LIB) $(TALLOC_LIBS)
-libosmocore_la_SOURCES = timer.c timer_gettimeofday.c select.c signal.c msgb.c 
bits.c \
+libosmocore_la_SOURCES = timer.c timer_gettimeofday.c timer_clockgettime.c \
+select.c signal.c msgb.c bits.c \
 bitvec.c bitcomp.c counter.c fsm.c \
 write_queue.c utils.c socket.c \
 logging.c logging_syslog.c logging_gsmtap.c rate_ctr.c 
\
diff --git a/src/timer_clockgettime.c b/src/timer_clockgettime.c
new file mode 100644
index 000..8d9760c
--- /dev/null
+++ b/src/timer_clockgettime.c
@@ -0,0 +1,138 @@
+/*
+ * (C) 2016 by sysmocom s.f.m.c. GmbH 
+ * All Rights Reserved
+ *
+ * Authors: Pau Espin Pedrol 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+/*! \addtogroup timer
+ *  @{
+ * \file timer_clockgettime.c
+ * Overriding Time: osmo_clock_gettime()
+ *  - Useful to write and reproduce tests that depend on specific time
+ *factors. This API allows to fake the timespec provided by 
`clock_gettime()`
+ *by using a small shim osmo_clock_gettime().
+ *  - Choose the clock you want to override, for instance CLOCK_MONOTONIC.
+ *  - If the clock override is disabled (default) for a given clock,
+ *osmo_clock_gettime() will do the same as regular `clock_gettime()`.
+ *  - If you want osmo_clock_gettime() to provide a specific time, you must
+ *enable time override with osmo_clock_override_enable(),
+ *then set a pointer to the timespec storing the fake time for that
+ *specific clock (`struct timespec *ts =
+ *osmo_clock_override_gettimespec()`) and set it as
+ *desired. Next time osmo_clock_gettime() is called, it will return the
+ *values previously set through the ts pointer.
+ *  - A helper osmo_clock_override_add() is provided to increment a given
+ *overriden clock with a specific amount of time.
+ */
+
+/*! \file timer_clockgettime.c
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/*! An internal structure to handle overriden time for each clock type. */
+struct fakeclock {
+   bool override;
+   struct timespec time;
+};
+
+static struct fakeclock realtime;
+static struct fakeclock realtime_coarse;
+static struct fakeclock mono;
+static struct fakeclock mono_coarse;
+static struct fakeclock mono_raw;
+static struct fakeclock boottime;
+static struct fakeclock boottime;
+static struct fakeclock proc_cputime_id;
+static struct fakeclock th_cputime_id;
+
+static struct fakeclock* clkid_to_fakeclock(clockid_t clk_id)
+{

[PATCH] libosmocore[master]: timer: Document osmo_gettimeofday API

2018-02-28 Thread Pau Espin Pedrol

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

timer: Document osmo_gettimeofday API

Change-Id: I1f9e13645033c61ffaed97e457deb5e78a6bec58
---
M src/timer_gettimeofday.c
1 file changed, 17 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/15/7015/1

diff --git a/src/timer_gettimeofday.c b/src/timer_gettimeofday.c
index 5273a3b..3494946 100644
--- a/src/timer_gettimeofday.c
+++ b/src/timer_gettimeofday.c
@@ -23,7 +23,23 @@
 
 /*! \addtogroup timer
  *  @{
- * \file timer_gettimeofday.c */
+ * \file timer_gettimeofday.c
+ * Overriding Time: osmo_gettimeofday()
+ *  - Useful to write and reproduce tests that depend on specific time
+ *factors. This API allows to fake the timeval provided by 
`gettimeofday()`
+ *by using a small shim osmo_gettimeofday().
+ *  - If the clock override is disabled (default) for a given clock,
+ *osmo_gettimeofday() will do the same as regular `gettimeofday()`.
+ *  - If you want osmo_gettimeofday() to provide a specific time, you must
+ *enable time override by setting the global variable
+ *osmo_gettimeofday_override (`osmo_gettimeofday_override = true`), 
then
+ *set the global struct timeval osmo_gettimeofday_override_time wih the
+ *desired value. Next time osmo_gettimeofday() is called, it will 
return
+ *the values previously set.
+ *  - A helper osmo_gettimeofday_override_add() is provided to easily
+ *increment osmo_gettimeofday_override_time with a specific amount of
+ *time.
+ */
 
 #include 
 #include 

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

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


osmo-sgsn[master]: implement support for 3-digit MNC with leading zeros

2018-02-28 Thread Harald Welte

Patch Set 2: Code-Review-1

just to make sure we have tested this somehow, particularly the gbproxy changes 
(see my last comment)

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

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


[MERGED] libosmocore[master]: gsm0408_test: test new gsm48_{decode, generate}_lai2() functions

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

Change subject: gsm0408_test: test new gsm48_{decode,generate}_lai2() functions
..


gsm0408_test: test new gsm48_{decode,generate}_lai2() functions

Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 50 insertions(+), 0 deletions(-)

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



diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 9e552ab..479b371 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -187,6 +187,39 @@
printf("  FAIL\n");
 }
 
+static inline void dump_lai(const struct osmo_location_area_id *lai)
+{
+   printf("%s%s\n", osmo_lai_name(lai), lai->plmn.mnc_3_digits ? " 
(3-digit MNC)" : "");
+}
+
+static inline void check_lai2(const struct gprs_ra_id *raid)
+{
+   struct gsm48_loc_area_id lai = {};
+   struct osmo_location_area_id decoded = {};
+   struct osmo_location_area_id laid = {
+   .plmn = {
+   .mcc = raid->mcc,
+   .mnc = raid->mnc,
+   .mnc_3_digits = raid->mnc_3_digits,
+   },
+   .lac = raid->lac,
+   };
+
+   printf("- gsm48_generate_lai2() from "); dump_lai();
+
+   gsm48_generate_lai2(, );
+   printf("  Encoded %s\n", osmo_hexdump((unsigned char*), 
sizeof(lai)));
+   gsm48_decode_lai2(, );
+   printf("  gsm48_decode_lai2() gives  "); dump_lai();
+   if (decoded.plmn.mcc == laid.plmn.mcc
+   && decoded.plmn.mnc == laid.plmn.mnc
+   && decoded.lac == laid.lac
+   && decoded.plmn.mnc_3_digits == (laid.plmn.mnc_3_digits || 
laid.plmn.mnc > 99))
+   printf("  passed\n");
+   else
+   printf("  FAIL\n");
+}
+
 static struct gprs_ra_id test_ra_cap_items[] = {
{
.mcc = 77,
@@ -228,6 +261,7 @@
 
for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++) {
check_lai(_ra_cap_items[i]);
+   check_lai2(_ra_cap_items[i]);
}
 }
 
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index cc56763..a0e2c23 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -26,15 +26,31 @@
   Encoded 70 17 21 02 9a 
   gsm48_decode_lai() gives  077-121-666-0
   passed
+- gsm48_generate_lai2() from 077-121-666
+  Encoded 70 17 21 02 9a 
+  gsm48_decode_lai2() gives  077-121-666 (3-digit MNC)
+  passed
 - gsm48_generate_lai() from 084-98-11-0
   Encoded 80 f4 89 00 0b 
   gsm48_decode_lai() gives  084-98-11-0
+  passed
+- gsm48_generate_lai2() from 084-98-11
+  Encoded 80 f4 89 00 0b 
+  gsm48_decode_lai2() gives  084-98-11
   passed
 - gsm48_generate_lai() from 000-00-0-0
   Encoded 00 f0 00 00 00 
   gsm48_decode_lai() gives  000-00-0-0
   passed
+- gsm48_generate_lai2() from 000-00-0
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai2() gives  000-00-0
+  passed
 - gsm48_generate_lai() from 999-999-65535-0
   Encoded 99 99 99 ff ff 
   gsm48_decode_lai() gives  999-999-65535-0
   passed
+- gsm48_generate_lai2() from 999-999-65535
+  Encoded 99 99 99 ff ff 
+  gsm48_decode_lai2() gives  999-999-65535 (3-digit MNC)
+  passed

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[MERGED] libosmocore[master]: gsm0408_test: check for new mnc_3_digits flag

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

Change subject: gsm0408_test: check for new mnc_3_digits flag
..


gsm0408_test: check for new mnc_3_digits flag

Note that on the input side, the 3-digits flag may be left false when the MNC
is >99 anyway. On the decoded side, the flag is set accurately.

Change-Id: I89765613d8c5bd939a6957f7443ac88475f1b93c
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 5 insertions(+), 4 deletions(-)

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



diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index a0e740a..9e552ab 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -132,7 +132,7 @@
 
 static inline void dump_ra(const struct gprs_ra_id *raid)
 {
-   printf("%03u-%02u-%u-%u\n", raid->mcc, raid->mnc, raid->lac, raid->rac);
+   printf("%s%s\n", osmo_rai_name(raid), raid->mnc_3_digits ? " (3-digit 
MNC)" : "");
 }
 
 static inline void check_ra(const struct gprs_ra_id *raid)
@@ -153,7 +153,8 @@
printf("MCC+MNC in BCD: %s\n", osmo_hexdump(ra.digits, 
sizeof(ra.digits)));
dump_ra();
printf("RA test...");
-   if (raid->mnc != raid0.mnc || raid->mcc != raid0.mcc || raid->lac != 
raid0.lac || raid->rac != raid0.rac)
+   if (raid->mnc != raid0.mnc || raid->mcc != raid0.mcc || raid->lac != 
raid0.lac || raid->rac != raid0.rac
+   || (raid->mnc_3_digits || raid->mnc > 99) != raid0.mnc_3_digits)
printf("FAIL\n");
else
printf("passed\n");
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 7612c12..cc56763 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -5,7 +5,7 @@
 Constructed RA:
 077-121-666-5
 MCC+MNC in BCD: 70 17 21 
-077-121-666-5
+077-121-666-5 (3-digit MNC)
 RA test...passed
 Constructed RA:
 084-98-11-89
@@ -20,7 +20,7 @@
 Constructed RA:
 999-999-65535-255
 MCC+MNC in BCD: 99 99 99 
-999-999-65535-255
+999-999-65535-255 (3-digit MNC)
 RA test...passed
 - gsm48_generate_lai() from 077-121-666-0
   Encoded 70 17 21 02 9a 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I89765613d8c5bd939a6957f7443ac88475f1b93c
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] libosmocore[master]: gsm0408_test: add test cases for MNC with leading zeros

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

Change subject: gsm0408_test: add test cases for MNC with leading zeros
..


gsm0408_test: add test cases for MNC with leading zeros

Change-Id: I9b387e09293a6bbef84b9620ccf21ee2f9ec751c
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 149 insertions(+), 0 deletions(-)

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



diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 479b371..2a0e661 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -238,6 +238,16 @@
.mnc = 0,
.lac = 0,
.rac = 0,
+   .mnc_3_digits = false,
+   /* expecting 000-00, BCD = 00 f0 00 */
+   },
+   {
+   .mcc = 0,
+   .mnc = 0,
+   .lac = 0,
+   .rac = 0,
+   .mnc_3_digits = true,
+   /* expecting 000-000, BCD = 00 00 00 */
},
{
.mcc = 999,
@@ -245,6 +255,54 @@
.lac = 65535,
.rac = 255,
},
+   {
+   .mcc = 1,
+   .mnc = 2,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = false,
+   /* expecting 001-02, BCD = 00 f1 20 */
+   },
+   {
+   .mcc = 1,
+   .mnc = 2,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = true,
+   /* expecting 001-002, BCD = 00 21 00 */
+   },
+   {
+   .mcc = 12,
+   .mnc = 34,
+   .lac = 56,
+   .rac = 78,
+   .mnc_3_digits = false,
+   /* expecting 012-34, BCD = 10 f2 43 */
+   },
+   {
+   .mcc = 12,
+   .mnc = 34,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = true,
+   /* expecting 012-034, BCD = 10 42 30 */
+   },
+   {
+   .mcc = 123,
+   .mnc = 456,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = false,
+   /* expecting 123-456, BCD = 21 63 54 (false flag has no effect) 
*/
+   },
+   {
+   .mcc = 123,
+   .mnc = 456,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = true,
+   /* expecting 123-456, BCD = 21 63 54 (same) */
+   },
 };
 
 static void test_ra_cap(void)
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index a0e2c23..c1d6a70 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -18,9 +18,44 @@
 000-00-0-0
 RA test...passed
 Constructed RA:
+000-000-0-0 (3-digit MNC)
+MCC+MNC in BCD: 00 00 00 
+000-000-0-0 (3-digit MNC)
+RA test...passed
+Constructed RA:
 999-999-65535-255
 MCC+MNC in BCD: 99 99 99 
 999-999-65535-255 (3-digit MNC)
+RA test...passed
+Constructed RA:
+001-02-23-42
+MCC+MNC in BCD: 00 f1 20 
+001-02-23-42
+RA test...passed
+Constructed RA:
+001-002-23-42 (3-digit MNC)
+MCC+MNC in BCD: 00 21 00 
+001-002-23-42 (3-digit MNC)
+RA test...passed
+Constructed RA:
+012-34-56-78
+MCC+MNC in BCD: 10 f2 43 
+012-34-56-78
+RA test...passed
+Constructed RA:
+012-034-23-42 (3-digit MNC)
+MCC+MNC in BCD: 10 42 30 
+012-034-23-42 (3-digit MNC)
+RA test...passed
+Constructed RA:
+123-456-23-42
+MCC+MNC in BCD: 21 63 54 
+123-456-23-42 (3-digit MNC)
+RA test...passed
+Constructed RA:
+123-456-23-42 (3-digit MNC)
+MCC+MNC in BCD: 21 63 54 
+123-456-23-42 (3-digit MNC)
 RA test...passed
 - gsm48_generate_lai() from 077-121-666-0
   Encoded 70 17 21 02 9a 
@@ -46,6 +81,14 @@
   Encoded 00 f0 00 00 00 
   gsm48_decode_lai2() gives  000-00-0
   passed
+- gsm48_generate_lai() from 000-000-0-0 (3-digit MNC)
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai() gives  000-00-0-0
+  passed
+- gsm48_generate_lai2() from 000-000-0 (3-digit MNC)
+  Encoded 00 00 00 00 00 
+  gsm48_decode_lai2() gives  000-000-0 (3-digit MNC)
+  passed
 - gsm48_generate_lai() from 999-999-65535-0
   Encoded 99 99 99 ff ff 
   gsm48_decode_lai() gives  999-999-65535-0
@@ -54,3 +97,51 @@
   Encoded 99 99 99 ff ff 
   gsm48_decode_lai2() gives  999-999-65535 (3-digit MNC)
   passed
+- gsm48_generate_lai() from 001-02-23-0
+  Encoded 00 f1 20 00 17 
+  gsm48_decode_lai() gives  001-02-23-0
+  passed
+- gsm48_generate_lai2() from 001-02-23
+  Encoded 00 f1 20 00 17 
+  gsm48_decode_lai2() gives  001-02-23
+  passed
+- gsm48_generate_lai() from 001-002-23-0 (3-digit MNC)
+  Encoded 00 f1 20 00 17 
+  gsm48_decode_lai() gives  001-02-23-0
+  passed
+- gsm48_generate_lai2() from 001-002-23 (3-digit MNC)
+  Encoded 00 21 00 00 17 
+  gsm48_decode_lai2() gives  001-002-23 (3-digit MNC)
+  passed
+- gsm48_generate_lai() from 012-34-56-0
+  Encoded 

[MERGED] libosmocore[master]: implement support for 3-digit MNC with leading zeros

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

Change subject: implement support for 3-digit MNC with leading zeros
..


implement support for 3-digit MNC with leading zeros

Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of structs
gprs_ra_id, osmo_plmn_id, osmo_cell_global_id, ... by adding an mnc_3_digits
flag.

Change ordering in gprs_ra_id because the canonical oder is {Mobile Country
Code, Mobile Network Code}, so have the mcc member first.

ABI compatibility cannot be maintained for struct gprs_ra_id, since it is a
direct member of structs bssgp_bvc_ctx and bssgp_paging_info, and even just
adding a flag to the end would cause ABI changes of those structs. Similarly,
osmo_plmn_id is a direct member of osmo_location_area_id, and so forth.

Add new API to set and read this additional flag to preserve leading zeros:
- osmo_plmn_to_bcd(), osmo_plmn_from_bcd() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm48_decode_lai2(), gsm48_generate_lai2() after
  gsm48_decode_lai(), gsm48_generate_lai().
- gsm0808_create_layer3_2() after gsm0808_create_layer3() and 
gsm0808_create_layer3_aoip().
- various osmo_*_name() functions in gsm23003.h (osmo_rai_name() still in
  gsm48.h close to struct gprs_ra_id definition). The amount and duplication of
  these may seem a bit overboard, but IMO they do make sense in this way.
  Though most code will soon see patches unifying the data structures used, in
  some cases (vty, ctrl) they are required singled out. Without these
  functions, the formatting ("%0*u", mnc_3_digits ?  3 : 2, mnc) would be
  duplicated all over our diverse repositories.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would immediately break all builds of dependent
  projects: it would require immediate merging of numerous patches in other
  repositories, and it would make compiling older code against a newer
  libosmocore unneccessarily hard.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
---
M debian/control
R debian/libosmogb6.install
R debian/libosmogsm9.install
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/gsm48.h
M src/gb/Makefile.am
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gsm/Makefile.am
M src/gsm/gsm0808.c
M src/gsm/gsm23003.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
15 files changed, 277 insertions(+), 75 deletions(-)

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



diff --git a/debian/control b/debian/control
index 596c3f1..d911f32 100644
--- a/debian/control
+++ b/debian/control
@@ -28,8 +28,8 @@
 Depends: libosmocodec0 (= ${binary:Version}),
  libosmocoding0 (= ${binary:Version}),
  libosmocore9 (= ${binary:Version}),
- libosmogb5 (= ${binary:Version}),
- libosmogsm8 (= ${binary:Version}),
+ libosmogb6 (= ${binary:Version}),
+ libosmogsm9 (= ${binary:Version}),
  libosmovty4 (= ${binary:Version}),
  libosmoctrl1 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
@@ -146,7 +146,7 @@
  .
  This package contains the documentation for the libosmocore library.
 
-Package: libosmogb5
+Package: libosmogb6
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -167,7 +167,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogb5,
+ libosmogb6,
  libjs-jquery
 Description: Documentation for the Osmo GPRS Gb library
  This is part of the libosmocore "meta"-library. The libosmocore library
@@ -178,7 +178,7 @@
  .
  This package contains the documentation for the libosmogb library.
 
-Package: libosmogsm8
+Package: libosmogsm9
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -202,7 +202,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogsm8,
+ libosmogsm9,
  libjs-jquery
 Description: Documentation for the Osmo GSM utility library
  This is part of the libosmocore "meta"-library. The libosmocore library
diff --git a/debian/libosmogb5.install b/debian/libosmogb6.install
similarity index 100%
rename from debian/libosmogb5.install
rename to 

[MERGED] libosmocore[master]: gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp(...

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

Change subject: gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() 
for 3-digit MNC
..


gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNC

osmo_mnc_from_str() preserves leading zeros in the string and is useful for
VTY config parsing (osmo-bsc, osmo-msc, osmo-sgsn, osmo-pcu).

osmo_{plmn,mnc}_cmp() takes care of the slight intricacy of ignoring the 
3-digit flag
if the MNC is anyway >99. Will be used by osmo-sgsn.git and osmo-bsc.git.  (All
current users just care about identical MNC, but a proper cmp doesn't hurt.)

Change-Id: Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6
---
M include/osmocom/gsm/gsm23003.h
M src/gsm/gsm23003.c
M src/gsm/libosmogsm.map
M tests/gsm23003/gsm23003_test.c
M tests/gsm23003/gsm23003_test.ok
5 files changed, 157 insertions(+), 0 deletions(-)

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



diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index 51e5ef8..660186e 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -95,3 +95,8 @@
 
 void osmo_plmn_to_bcd(uint8_t *bcd_dst, const struct osmo_plmn_id *plmn);
 void osmo_plmn_from_bcd(const uint8_t *bcd_src, struct osmo_plmn_id *plmn);
+
+int osmo_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits);
+
+int osmo_mnc_cmp(uint16_t a_mnc, bool a_mnc_3_digits, uint16_t b_mnc, bool 
b_mnc_3_digits);
+int osmo_plmn_cmp(const struct osmo_plmn_id *a, const struct osmo_plmn_id *b);
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c
index 63de2b8..1f6bf7d 100644
--- a/src/gsm/gsm23003.c
+++ b/src/gsm/gsm23003.c
@@ -25,6 +25,9 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -195,3 +198,77 @@
plmn->mnc_3_digits = true;
}
 }
+
+/* Convert string to MNC, detecting 3-digit MNC with leading zeros.
+ * Return mnc_3_digits as false if the MNC's most significant digit is encoded 
as 0xF, true
+ * otherwise; i.e. true if MNC > 99 or if it is represented with leading zeros 
instead of 0xF.
+ * \param mnc_str[in]  String representation of an MNC, with or without 
leading zeros.
+ * \param mnc[out] MNC result buffer, or NULL.
+ * \param[out] mnc_3_digitsResult buffer for 3-digit flag, or NULL.
+ * \returns zero on success, -EINVAL in case of surplus characters, negative 
errno in case of conversion
+ *  errors.
+ */
+int osmo_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits)
+{
+   long int _mnc = 0;
+   bool _mnc_3_digits = false;
+   char *endptr;
+   int rc = 0;
+
+   if (!mnc_str || !isdigit(mnc_str[0]) || strlen(mnc_str) > 3) {
+   /* return invalid, but give strtol a shot anyway, for callers 
that don't want to be
+* strict */
+   rc = -EINVAL;
+   }
+   errno = 0;
+   _mnc = strtol(mnc_str, , 10);
+   if (errno)
+   rc = -errno;
+   else if (*endptr)
+   rc = -EINVAL;
+   if (_mnc < 0 || _mnc > 999)
+   rc = -EINVAL;
+   _mnc_3_digits = strlen(mnc_str) > 2;
+
+   if (mnc)
+   *mnc = (uint16_t)_mnc;
+   if (mnc_3_digits)
+   *mnc_3_digits = _mnc_3_digits;
+   return rc;
+}
+
+/* Compare two MNC with three-digit flag.
+ * The mnc_3_digits flags passed in only have an effect if the MNC are < 100, 
i.e. if they would amount
+ * to a change in leading zeros in a BCD representation. An MNC >= 100 implies 
three digits, and the flag
+ * is actually ignored.
+ * \param a_mnc[in]"Left" side MNC.
+ * \param a_mnc_3_digits[in]   "Left" side three-digits flag.
+ * \param b_mnc[in]"Right" side MNC.
+ * \param b_mnc_3_digits[in]   "Right" side three-digits flag.
+ * \returns 0 if the MNC are equal, -1 if a < b or a shorter, 1 if a > b or a 
longer. */
+int osmo_mnc_cmp(uint16_t a_mnc, bool a_mnc_3_digits, uint16_t b_mnc, bool 
b_mnc_3_digits)
+{
+   if (a_mnc < b_mnc)
+   return -1;
+   if (a_mnc > b_mnc)
+   return 1;
+   /* a_mnc == b_mnc, but same amount of leading zeros? */
+   if (a_mnc < 100 && a_mnc_3_digits != b_mnc_3_digits)
+   return a_mnc_3_digits ? 1 : -1;
+   return 0;
+}
+
+/* Compare two PLMN.
+ * \param a[in]  "Left" side PLMN.
+ * \param b[in]  "Right" side PLMN.
+ * \returns 0 if the PLMN are equal, -1 if a < b or a shorter, 1 if a > b or a 
longer. */
+int osmo_plmn_cmp(const struct osmo_plmn_id *a, const struct osmo_plmn_id *b)
+{
+   if (a == b)
+   return 0;
+   if (a->mcc < b->mcc)
+   return -1;
+   if (a->mcc > b->mcc)
+   return 1;
+   return osmo_mnc_cmp(a->mnc, a->mnc_3_digits, b->mnc, b->mnc_3_digits);
+}
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 

[MERGED] osmo-msc[master]: cosmetic: gsm_network_init(): imply default 001-01 PLMN

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

Change subject: cosmetic: gsm_network_init(): imply default 001-01 PLMN
..


cosmetic: gsm_network_init(): imply default 001-01 PLMN

All callers pass mcc=1, mnc=1, so just have it as default.
(Prepare for net->country_code etc to be replaced by net->plmn)

Change-Id: Ibcd1cc38f170895305ae176a5574384c74a33939
---
M include/osmocom/msc/common_cs.h
M src/libcommon-cs/common_cs.c
M src/osmo-msc/msc_main.c
M tests/msc_vlr/msc_vlr_tests.c
4 files changed, 6 insertions(+), 12 deletions(-)

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



diff --git a/include/osmocom/msc/common_cs.h b/include/osmocom/msc/common_cs.h
index 6dc956f..273a8fe 100644
--- a/include/osmocom/msc/common_cs.h
+++ b/include/osmocom/msc/common_cs.h
@@ -17,10 +17,7 @@
uint8_t key[MAX_A5_KEY_LEN];
 };
 
-struct gsm_network *gsm_network_init(void *ctx,
-uint16_t country_code,
-uint16_t network_code,
-mncc_recv_cb_t mncc_recv);
+struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv);
 
 int common_cs_vty_init(struct gsm_network *network,
  int (* config_write_net )(struct vty *));
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index a2f5cb3..c64719b 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -37,10 +37,7 @@
  * The long term aim should be to have entirely separate structs for libbsc and
  * libmsc with some common general items.
  */
-struct gsm_network *gsm_network_init(void *ctx,
-uint16_t country_code,
-uint16_t network_code,
-mncc_recv_cb_t mncc_recv)
+struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv)
 {
struct gsm_network *net;
 
@@ -48,8 +45,8 @@
if (!net)
return NULL;
 
-   net->country_code = country_code;
-   net->network_code = network_code;
+   net->country_code = 1;
+   net->network_code = 1;
/* Permit a compile-time default of A5/3 and A5/1 */
net->a5_encryption_mask = (1 << 3) | (1 << 1);
 
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index da28083..f49c480 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -202,7 +202,7 @@
 struct gsm_network *msc_network_alloc(void *ctx,
  mncc_recv_cb_t mncc_recv)
 {
-   struct gsm_network *net = gsm_network_init(ctx, 1, 1, mncc_recv);
+   struct gsm_network *net = gsm_network_init(ctx, mncc_recv);
if (!net)
return NULL;
 
diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index f514286..362f32d 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -845,7 +845,7 @@
 
 struct gsm_network *test_net(void *ctx)
 {
-   struct gsm_network *net = gsm_network_init(ctx, 1, 1, mncc_recv);
+   struct gsm_network *net = gsm_network_init(ctx, mncc_recv);
 
net->gsup_server_addr_str = talloc_strdup(net, "no_gsup_server");
net->gsup_server_port = 0;

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

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


[ABANDON] osmocom-bb[fixeria/trx]: remove gsm48_encode_classmark1() which is now in libosmocore

2018-02-28 Thread Harald Welte
Harald Welte has abandoned this change.

Change subject: remove gsm48_encode_classmark1() which is now in libosmocore
..


Abandoned

libosmocore has this reverted now

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

Gerrit-MessageType: abandon
Gerrit-Change-Id: I3f7c83ad0624839ce42864c70396a4397b21f514
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


osmo-ttcn3-hacks[master]: bts: Update towards most recent "laforge/trx" branch

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I6d0122202e5d23308421e76b75e608d206aab56e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-ttcn3-hacks[master]: bts: Update towards most recent "laforge/trx" branch

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

Change subject: bts: Update towards most recent "laforge/trx" branch
..


bts: Update towards most recent "laforge/trx" branch

The existing BTS testing code was based on a ~1 week old version
of trxcon+fake_trx from osmocom-bb.git fixeria/trx branch, which
has meanwhile evolved:

* port number change for TRX protocol
* FAKE_TIMING -> FAKE_TOA
* we can now expect responses to our UDP control commands

Let's adapt the testsuite to those changes

Change-Id: I6d0122202e5d23308421e76b75e608d206aab56e
---
M bts/BTS_Tests.ttcn
M library/TRXC_CodecPort.ttcn
M library/TRXC_Types.ttcn
3 files changed, 42 insertions(+), 13 deletions(-)

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



diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index be9b4cc..af28396 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -45,7 +45,7 @@
charstring mp_rsl_ip := "127.0.0.2";
integer mp_rsl_port := 3003;
integer mp_trx0_arfcn := 871;
-   integer mp_bb_trxc_port := 5704;
+   integer mp_bb_trxc_port := 6701;
charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
 }
 
@@ -266,7 +266,7 @@
 
/* start with a default moderate timing offset equalling TA=2 */
f_main_trxc_connect();
-   BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, 
ts_TRXC_FAKE_TIMING(2*256)));
+   f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, 
valueof(ts_TRXC_FAKE_TIMING(2*256)));
 }
 
 /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
@@ -323,11 +323,11 @@
 }
 
 private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
-   BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi))); 
+   f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, 
valueof(ts_TRXC_FAKE_RSSI(rssi)));
 }
 
 private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
-   BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, 
ts_TRXC_FAKE_TIMING(toffs256))); 
+   f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, 
valueof(ts_TRXC_FAKE_TIMING(toffs256)));
 }
 
 /* first function started in ConnHdlr component */
@@ -632,7 +632,7 @@
 
 private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on 
test_CT {
/* tell fake_trx to use a given timing offset for all bursts */
-   BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, 
ts_TRXC_FAKE_TIMING(toffs256)));
+   f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, 
valueof(ts_TRXC_FAKE_TIMING(toffs256)));
f_sleep(0.5);
 
/* Transmit RACH request + wait for confirmation */
diff --git a/library/TRXC_CodecPort.ttcn b/library/TRXC_CodecPort.ttcn
index 6acead0..774b674 100644
--- a/library/TRXC_CodecPort.ttcn
+++ b/library/TRXC_CodecPort.ttcn
@@ -13,8 +13,8 @@
TrxcMessage msg
 }
 
-template TRXC_RecvFrom tr_TRXC_RecvFrom(template TrxcMessage msg) := {
-   connId := ?,
+template TRXC_RecvFrom tr_TRXC_RecvFrom(template ConnectionId cid, template 
TrxcMessage msg) := {
+   connId := cid,
remName := ?,
remPort := ?,
locName := ?,
@@ -59,4 +59,31 @@
msg := msg
 }
 
+function f_TRXC_transceive(TRXC_CODEC_PT pt, ConnectionId conn_id, TrxcMessage 
tx,
+  template TrxcMessage tr := ?) return TrxcMessage {
+   var TRXC_RecvFrom rf;
+   timer T := 3.0;
+   /* build better default template */
+   if (istemplatekind(tr, "?")) {
+   tr := {
+   rsp := {
+   verb := tx.cmd.verb,
+   status := ?,
+   params := *
+   }
+   };
+   }
+   pt.send(ts_TRXC_Send(conn_id, tx));
+   T.start;
+   alt {
+   [] pt.receive(tr_TRXC_RecvFrom(conn_id, tr)) -> value rf {
+   return rf.msg;
+   }
+   [] T.timeout {
+   setverdict(fail, "Timeout waiting for ", tr, " on ", pt);
+   }
+   }
+   return rf.msg;
+}
+
 }
diff --git a/library/TRXC_Types.ttcn b/library/TRXC_Types.ttcn
index c12e5d2..1a37a8c 100644
--- a/library/TRXC_Types.ttcn
+++ b/library/TRXC_Types.ttcn
@@ -9,15 +9,17 @@
 type charstring TrxcVerb ("POWERON", "POWEROFF", "CLOCK",
  "RXTUNE", "TXTUNE", "SETSLOT", "SETTSC", "SETBSIC", 
"SETPOWER",
  "SETMAXDLY", "SETMAXDLYNB", "SETSLOT", "HANDOVER", 
"NOHANDOVER",
- "MEASURE", "FAKE_RSSI", "FAKE_TIMING" ) with {
+ "MEASURE", "FAKE_RSSI", "FAKE_TOA" ) with {
variant "TEXT_CODING(,convert=upper_case,
-   
'((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TIMING))'
+   

[PATCH] osmocom-bb[fixeria/trx]: fake_trx: Increase TOA256 value ranges

2018-02-28 Thread Harald Welte

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

fake_trx: Increase TOA256 value ranges

In theory, the maximum TA value is 63 symbols, i.e. 63*256 in this
context.  However, our test cases want to test the BTS behavior is
correct if ever a larger timing offset is reported from TRX to the BTS,
to ensure it is rejected in the BTS.  Let's hence increaes the values
to rather large min/max limits.  We could also remove them completely.

Change-Id: I691d081256e8c6d18ef2836299ed8f7d502da3ee
---
M src/target/fake_trx/data_msg.py
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/14/7014/1

diff --git a/src/target/fake_trx/data_msg.py b/src/target/fake_trx/data_msg.py
index 5f93187..a48eff7 100644
--- a/src/target/fake_trx/data_msg.py
+++ b/src/target/fake_trx/data_msg.py
@@ -304,8 +304,8 @@
RSSI_MAX = -50
 
# TODO: verify this range
-   TOA256_MIN = -256 * 10
-   TOA256_MAX = 256 * 10
+   TOA256_MIN = -256 * 200
+   TOA256_MAX = 256 * 200
 
# Specific message fields
rssi = None

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I691d081256e8c6d18ef2836299ed8f7d502da3ee
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 


[PATCH] osmo-ttcn3-hacks[master]: bts: Update towards most recent "laforge/trx" branch

2018-02-28 Thread Harald Welte

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

bts: Update towards most recent "laforge/trx" branch

The existing BTS testing code was based on a ~1 week old version
of trxcon+fake_trx from osmocom-bb.git fixeria/trx branch, which
has meanwhile evolved:

* port number change for TRX protocol
* FAKE_TIMING -> FAKE_TOA
* we can now expect responses to our UDP control commands

Let's adapt the testsuite to those changes

Change-Id: I6d0122202e5d23308421e76b75e608d206aab56e
---
M bts/BTS_Tests.ttcn
M library/TRXC_CodecPort.ttcn
M library/TRXC_Types.ttcn
3 files changed, 42 insertions(+), 13 deletions(-)


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

diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index be9b4cc..af28396 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -45,7 +45,7 @@
charstring mp_rsl_ip := "127.0.0.2";
integer mp_rsl_port := 3003;
integer mp_trx0_arfcn := 871;
-   integer mp_bb_trxc_port := 5704;
+   integer mp_bb_trxc_port := 6701;
charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
 }
 
@@ -266,7 +266,7 @@
 
/* start with a default moderate timing offset equalling TA=2 */
f_main_trxc_connect();
-   BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, 
ts_TRXC_FAKE_TIMING(2*256)));
+   f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, 
valueof(ts_TRXC_FAKE_TIMING(2*256)));
 }
 
 /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */
@@ -323,11 +323,11 @@
 }
 
 private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr {
-   BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi))); 
+   f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, 
valueof(ts_TRXC_FAKE_RSSI(rssi)));
 }
 
 private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr {
-   BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, 
ts_TRXC_FAKE_TIMING(toffs256))); 
+   f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, 
valueof(ts_TRXC_FAKE_TIMING(toffs256)));
 }
 
 /* first function started in ConnHdlr component */
@@ -632,7 +632,7 @@
 
 private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on 
test_CT {
/* tell fake_trx to use a given timing offset for all bursts */
-   BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, 
ts_TRXC_FAKE_TIMING(toffs256)));
+   f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, 
valueof(ts_TRXC_FAKE_TIMING(toffs256)));
f_sleep(0.5);
 
/* Transmit RACH request + wait for confirmation */
diff --git a/library/TRXC_CodecPort.ttcn b/library/TRXC_CodecPort.ttcn
index 6acead0..774b674 100644
--- a/library/TRXC_CodecPort.ttcn
+++ b/library/TRXC_CodecPort.ttcn
@@ -13,8 +13,8 @@
TrxcMessage msg
 }
 
-template TRXC_RecvFrom tr_TRXC_RecvFrom(template TrxcMessage msg) := {
-   connId := ?,
+template TRXC_RecvFrom tr_TRXC_RecvFrom(template ConnectionId cid, template 
TrxcMessage msg) := {
+   connId := cid,
remName := ?,
remPort := ?,
locName := ?,
@@ -59,4 +59,31 @@
msg := msg
 }
 
+function f_TRXC_transceive(TRXC_CODEC_PT pt, ConnectionId conn_id, TrxcMessage 
tx,
+  template TrxcMessage tr := ?) return TrxcMessage {
+   var TRXC_RecvFrom rf;
+   timer T := 3.0;
+   /* build better default template */
+   if (istemplatekind(tr, "?")) {
+   tr := {
+   rsp := {
+   verb := tx.cmd.verb,
+   status := ?,
+   params := *
+   }
+   };
+   }
+   pt.send(ts_TRXC_Send(conn_id, tx));
+   T.start;
+   alt {
+   [] pt.receive(tr_TRXC_RecvFrom(conn_id, tr)) -> value rf {
+   return rf.msg;
+   }
+   [] T.timeout {
+   setverdict(fail, "Timeout waiting for ", tr, " on ", pt);
+   }
+   }
+   return rf.msg;
+}
+
 }
diff --git a/library/TRXC_Types.ttcn b/library/TRXC_Types.ttcn
index c12e5d2..1a37a8c 100644
--- a/library/TRXC_Types.ttcn
+++ b/library/TRXC_Types.ttcn
@@ -9,15 +9,17 @@
 type charstring TrxcVerb ("POWERON", "POWEROFF", "CLOCK",
  "RXTUNE", "TXTUNE", "SETSLOT", "SETTSC", "SETBSIC", 
"SETPOWER",
  "SETMAXDLY", "SETMAXDLYNB", "SETSLOT", "HANDOVER", 
"NOHANDOVER",
- "MEASURE", "FAKE_RSSI", "FAKE_TIMING" ) with {
+ "MEASURE", "FAKE_RSSI", "FAKE_TOA" ) with {
variant "TEXT_CODING(,convert=upper_case,
-   
'((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TIMING))'
+   
'((POWERON)|(POWEROFF)|(CLOCK)|(RXTUNE)|(TXTUNE)|(SETSLOT)|(SETTSC)|(SETBSIC)|(SETPOWER)|(SETMAXDLY)|(SETMAXDLYNB)|(HANDOVER)|(NOHANDOVER)|(MEASURE)|(FAKE_RSSI)|(FAKE_TOA))'

[MERGED] osmo-bts[master]: pcu_sock: LOG + drop PCU DATA.req for inactive lchan

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

Change subject: pcu_sock: LOG + drop PCU DATA.req for inactive lchan
..


pcu_sock: LOG + drop PCU DATA.req for inactive lchan

Change-Id: I11c622967885d594ef7e1c24b9bafd0fb8fd400c
---
M src/common/pcu_sock.c
1 file changed, 6 insertions(+), 0 deletions(-)

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



diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index cd8e0b2..e98769d 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -534,6 +534,12 @@
rc = -EINVAL;
break;
}
+   if (ts->lchan[0].state != LCHAN_S_ACTIVE) {
+   LOGP(DPCU, LOGL_ERROR, "%s: Received PCU DATA request 
for inactive lchan\n",
+   gsm_ts_name(ts));
+   rc = -EINVAL;
+   break;
+   }
is_ptcch = (data_req->sapi == PCU_IF_SAPI_PTCCH);
rc = l1sap_pdch_req(ts, is_ptcch, data_req->fn, data_req->arfcn,
data_req->block_nr, data_req->data, data_req->len);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I11c622967885d594ef7e1c24b9bafd0fb8fd400c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmocom-bb[fixeria/trx]: fake_trx: Always send control responses to where commands ar...

2018-02-28 Thread Harald Welte

fake_trx: Always send control responses to where commands are from

fake_trx is using locally bound and not connected UDP sockets for
control commands.

When we receive a control command, we should not simply send the
response to the default destination, but send it back to the exact
ip+prt from which the command originated.  This ensures correct routing
of responses even in case multiple programs are interfacing concurrently
with a control socket.

Change-Id: I24a0bba6eed059b101af95dac7d059f34dd715fc
---
M src/target/fake_trx/ctrl_if.py
M src/target/fake_trx/fake_trx.py
M src/target/fake_trx/udp_link.py
3 files changed, 13 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/11/7011/3

diff --git a/src/target/fake_trx/ctrl_if.py b/src/target/fake_trx/ctrl_if.py
index e84c1c8..394c959 100644
--- a/src/target/fake_trx/ctrl_if.py
+++ b/src/target/fake_trx/ctrl_if.py
@@ -25,16 +25,16 @@
 from udp_link import UDPLink
 
 class CTRLInterface(UDPLink):
-   def handle_rx(self, data):
+   def handle_rx(self, data, remote):
# print(data)
if self.verify_req(data):
request = self.prepare_req(data)
rc = self.parse_cmd(request)
 
if type(rc) is tuple:
-   self.send_response(request, rc[0], rc[1])
+   self.send_response(request, remote, rc[0], 
rc[1])
else:
-   self.send_response(request, rc)
+   self.send_response(request, remote, rc)
else:
print("[!] Wrong data on CTRL interface")
 
@@ -66,7 +66,7 @@
 
return True
 
-   def send_response(self, request, response_code, params = None):
+   def send_response(self, request, remote, response_code, params = None):
# Include status code, for example ["TXTUNE", "0", "941600"]
request.insert(1, str(response_code))
 
@@ -77,7 +77,7 @@
# Add the response signature, and join back to string
response = "RSP " + " ".join(request) + "\0"
# Now we have something like "RSP TXTUNE 0 941600"
-   self.send(response)
+   self.sendto(response, remote)
 
def parse_cmd(self, request):
raise NotImplementedError
diff --git a/src/target/fake_trx/fake_trx.py b/src/target/fake_trx/fake_trx.py
index c9e427c..a0534fd 100755
--- a/src/target/fake_trx/fake_trx.py
+++ b/src/target/fake_trx/fake_trx.py
@@ -124,12 +124,12 @@
# CTRL commands from BTS
if self.bts_ctrl.sock in r_event:
data, addr = self.bts_ctrl.sock.recvfrom(128)
-   self.bts_ctrl.handle_rx(data.decode())
+   self.bts_ctrl.handle_rx(data.decode(), addr)
 
# CTRL commands from BB
if self.bb_ctrl.sock in r_event:
data, addr = self.bb_ctrl.sock.recvfrom(128)
-   self.bb_ctrl.handle_rx(data.decode())
+   self.bb_ctrl.handle_rx(data.decode(), addr)
 
def shutdown(self):
print("[i] Shutting down...")
diff --git a/src/target/fake_trx/udp_link.py b/src/target/fake_trx/udp_link.py
index c464802..dda901c 100644
--- a/src/target/fake_trx/udp_link.py
+++ b/src/target/fake_trx/udp_link.py
@@ -43,3 +43,9 @@
data = data.encode()
 
self.sock.sendto(data, (self.remote_addr, self.remote_port))
+
+   def sendto(self, data, remote):
+   if type(data) not in [bytearray, bytes]:
+   data = data.encode()
+
+   self.sock.sendto(data, remote)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I24a0bba6eed059b101af95dac7d059f34dd715fc
Gerrit-PatchSet: 3
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 


[MERGED] osmo-bts[master]: pcu_sock: LOG + drop DATA.req from PCU for non-PDCH timeslot

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

Change subject: pcu_sock: LOG + drop DATA.req from PCU for non-PDCH timeslot
..


pcu_sock: LOG + drop DATA.req from PCU for non-PDCH timeslot

Change-Id: I3ae496eca96bc0823dfeca16ce36c200ce000895
---
M src/common/pcu_sock.c
1 file changed, 6 insertions(+), 0 deletions(-)

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



diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 0d1f07a..cd8e0b2 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -528,6 +528,12 @@
break;
}
ts = >ts[data_req->ts_nr];
+   if (!ts_should_be_pdch(ts)) {
+   LOGP(DPCU, LOGL_ERROR, "%s: Received PCU DATA request 
for non-PDCH TS\n",
+   gsm_ts_name(ts));
+   rc = -EINVAL;
+   break;
+   }
is_ptcch = (data_req->sapi == PCU_IF_SAPI_PTCCH);
rc = l1sap_pdch_req(ts, is_ptcch, data_req->fn, data_req->arfcn,
data_req->block_nr, data_req->data, data_req->len);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3ae496eca96bc0823dfeca16ce36c200ce000895
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmocom-bb[fixeria/trx]: fake_trx: Send positive response to FAKE_TOA commands

2018-02-28 Thread Harald Welte

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

fake_trx: Send positive response to FAKE_TOA commands

Now that ctrl_if.py is capable of sending back the response to where
the command originated from, we can just as well send a positive
response back after executing the related commands.

Change-Id: Icba138835149a7264f4db3a6b05f54ca501c4d54
---
M src/target/fake_trx/ctrl_if_bb.py
M src/target/fake_trx/ctrl_if_bts.py
2 files changed, 4 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/12/7012/1

diff --git a/src/target/fake_trx/ctrl_if_bb.py 
b/src/target/fake_trx/ctrl_if_bb.py
index 11533d8..15a7eb0 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -138,8 +138,7 @@
self.burst_fwd.toa256_ul_base = int(request[1])
self.burst_fwd.toa256_ul_threshold = int(request[2])
 
-   # TODO: avoid sending response
-   return -1
+   return 0
 
# Timing of Arrival simulation for Uplink
# Relative form: CMD FAKE_TOA <+-BASE_DELTA>
@@ -149,8 +148,7 @@
# Parse and apply delta
self.burst_fwd.toa256_ul_base += int(request[1])
 
-   # TODO: avoid sending response
-   return -1
+   return 0
 
# Wrong / unknown command
else:
diff --git a/src/target/fake_trx/ctrl_if_bts.py 
b/src/target/fake_trx/ctrl_if_bts.py
index 8c1d8e5..53b9acb 100644
--- a/src/target/fake_trx/ctrl_if_bts.py
+++ b/src/target/fake_trx/ctrl_if_bts.py
@@ -106,8 +106,7 @@
self.burst_fwd.toa256_dl_base = int(request[1])
self.burst_fwd.toa256_dl_threshold = int(request[2])
 
-   # TODO: avoid sending response
-   return -1
+   return 0
 
# Timing of Arrival simulation for Downlink
# Relative form: CMD FAKE_TOA <+-BASE_DELTA>
@@ -117,8 +116,7 @@
# Parse and apply delta
self.burst_fwd.toa256_dl_base += int(request[1])
 
-   # TODO: avoid sending response
-   return -1
+   return 0
 
# Wrong / unknown command
else:

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icba138835149a7264f4db3a6b05f54ca501c4d54
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[fixeria/trx]: trxcon: Define event names for osmo_fsm's

2018-02-28 Thread Harald Welte

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

trxcon: Define event names for osmo_fsm's

Change-Id: Id3279e99966a0ab236923c497ac0abbc9ed2c93c
---
M src/host/trxcon/l1ctl_link.c
M src/host/trxcon/trx_if.c
M src/host/trxcon/trxcon.c
3 files changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/09/7009/1

diff --git a/src/host/trxcon/l1ctl_link.c b/src/host/trxcon/l1ctl_link.c
index 3905654..596a9d1 100644
--- a/src/host/trxcon/l1ctl_link.c
+++ b/src/host/trxcon/l1ctl_link.c
@@ -45,6 +45,10 @@
 #include "l1ctl_link.h"
 #include "l1ctl.h"
 
+static struct value_string l1ctl_evt_names[] = {
+   { 0, NULL } /* no events? */
+};
+
 static struct osmo_fsm_state l1ctl_fsm_states[] = {
[L1CTL_STATE_IDLE] = {
.out_state_mask = GEN_MASK(L1CTL_STATE_CONNECTED),
@@ -61,6 +65,7 @@
.states = l1ctl_fsm_states,
.num_states = ARRAY_SIZE(l1ctl_fsm_states),
.log_subsys = DL1C,
+   .event_names = l1ctl_evt_names,
 };
 
 static int l1ctl_link_read_cb(struct osmo_fd *bfd)
diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c
index 6ee75d3..98e3cdd 100644
--- a/src/host/trxcon/trx_if.c
+++ b/src/host/trxcon/trx_if.c
@@ -45,6 +45,10 @@
 #include "logging.h"
 #include "scheduler.h"
 
+static struct value_string trx_evt_names[] = {
+   { 0, NULL } /* no events? */
+};
+
 static struct osmo_fsm_state trx_fsm_states[] = {
[TRX_STATE_OFFLINE] = {
.out_state_mask = (
@@ -76,6 +80,7 @@
.states = trx_fsm_states,
.num_states = ARRAY_SIZE(trx_fsm_states),
.log_subsys = DTRX,
+   .event_names = trx_evt_names,
 };
 
 static int trx_udp_open(void *priv, struct osmo_fd *ofd, const char *host,
diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c
index 0250b72..60db887 100644
--- a/src/host/trxcon/trxcon.c
+++ b/src/host/trxcon/trxcon.c
@@ -125,11 +125,20 @@
},
 };
 
+static const struct value_string app_evt_names[] = {
+   OSMO_VALUE_STRING(L1CTL_EVENT_CONNECT),
+   OSMO_VALUE_STRING(L1CTL_EVENT_DISCONNECT),
+   OSMO_VALUE_STRING(TRX_EVENT_OFFLINE),
+   OSMO_VALUE_STRING(TRX_EVENT_RSP_ERROR),
+   { 0, NULL }
+};
+
 static struct osmo_fsm trxcon_fsm_def = {
.name = "trxcon_app_fsm",
.states = trxcon_fsm_states,
.num_states = ARRAY_SIZE(trxcon_fsm_states),
.log_subsys = DAPP,
+   .event_names = app_evt_names,
 };
 
 static void print_usage(const char *app)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id3279e99966a0ab236923c497ac0abbc9ed2c93c
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[fixeria/trx]: fake_trx: Always send control responses to where commands ar...

2018-02-28 Thread Harald Welte

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

fake_trx: Always send control responses to where commands are from

fake_trx is using locally bound and not connected UDP sockets for
control commands.

When we receive a control command, we should not simply send the
response to the default destination, but send it back to the exact
ip+prt from which the command originated.  This ensures correct routing
of responses even in case multiple programs are interfacing concurrently
with a control socket.

Change-Id: I24a0bba6eed059b101af95dac7d059f34dd715fc
---
M src/target/fake_trx/ctrl_if.py
M src/target/fake_trx/fake_trx.py
M src/target/fake_trx/udp_link.py
3 files changed, 13 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/11/7011/1

diff --git a/src/target/fake_trx/ctrl_if.py b/src/target/fake_trx/ctrl_if.py
index e84c1c8..394c959 100644
--- a/src/target/fake_trx/ctrl_if.py
+++ b/src/target/fake_trx/ctrl_if.py
@@ -25,16 +25,16 @@
 from udp_link import UDPLink
 
 class CTRLInterface(UDPLink):
-   def handle_rx(self, data):
+   def handle_rx(self, data, remote):
# print(data)
if self.verify_req(data):
request = self.prepare_req(data)
rc = self.parse_cmd(request)
 
if type(rc) is tuple:
-   self.send_response(request, rc[0], rc[1])
+   self.send_response(request, remote, rc[0], 
rc[1])
else:
-   self.send_response(request, rc)
+   self.send_response(request, remote, rc)
else:
print("[!] Wrong data on CTRL interface")
 
@@ -66,7 +66,7 @@
 
return True
 
-   def send_response(self, request, response_code, params = None):
+   def send_response(self, request, remote, response_code, params = None):
# Include status code, for example ["TXTUNE", "0", "941600"]
request.insert(1, str(response_code))
 
@@ -77,7 +77,7 @@
# Add the response signature, and join back to string
response = "RSP " + " ".join(request) + "\0"
# Now we have something like "RSP TXTUNE 0 941600"
-   self.send(response)
+   self.sendto(response, remote)
 
def parse_cmd(self, request):
raise NotImplementedError
diff --git a/src/target/fake_trx/fake_trx.py b/src/target/fake_trx/fake_trx.py
index c9e427c..a0534fd 100755
--- a/src/target/fake_trx/fake_trx.py
+++ b/src/target/fake_trx/fake_trx.py
@@ -124,12 +124,12 @@
# CTRL commands from BTS
if self.bts_ctrl.sock in r_event:
data, addr = self.bts_ctrl.sock.recvfrom(128)
-   self.bts_ctrl.handle_rx(data.decode())
+   self.bts_ctrl.handle_rx(data.decode(), addr)
 
# CTRL commands from BB
if self.bb_ctrl.sock in r_event:
data, addr = self.bb_ctrl.sock.recvfrom(128)
-   self.bb_ctrl.handle_rx(data.decode())
+   self.bb_ctrl.handle_rx(data.decode(), addr)
 
def shutdown(self):
print("[i] Shutting down...")
diff --git a/src/target/fake_trx/udp_link.py b/src/target/fake_trx/udp_link.py
index c464802..c9640b1 100644
--- a/src/target/fake_trx/udp_link.py
+++ b/src/target/fake_trx/udp_link.py
@@ -43,3 +43,9 @@
data = data.encode()
 
self.sock.sendto(data, (self.remote_addr, self.remote_port))
+
+   def sendto(self, data, remote):
+   if type(data) not in [bytearray, bytes]:
+   data = data.encode()
+print("sending %s to %s" % (data, remote));
+   self.sock.sendto(data, remote)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24a0bba6eed059b101af95dac7d059f34dd715fc
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[fixeria/trx]: fake_trx: Log IP/Port information at start-up

2018-02-28 Thread Harald Welte

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

fake_trx: Log IP/Port information at start-up

Change-Id: I4ebeed7271d91ab2e45199e0fb59776c00ad833c
---
M src/target/fake_trx/ctrl_if_bb.py
M src/target/fake_trx/ctrl_if_bts.py
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/10/7010/1

diff --git a/src/target/fake_trx/ctrl_if_bb.py 
b/src/target/fake_trx/ctrl_if_bb.py
index c4d879c..11533d8 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -33,7 +33,7 @@
pm = None
 
def __init__(self, remote_addr, remote_port, bind_port):
-   print("[i] Init CTRL interface for BB")
+   print("[i] Init CTRL interface for BB (L:%u <-> R:%s:%u)" % 
(bind_port, remote_addr, remote_port))
CTRLInterface.__init__(self, remote_addr, remote_port, 
bind_port)
 
def parse_cmd(self, request):
diff --git a/src/target/fake_trx/ctrl_if_bts.py 
b/src/target/fake_trx/ctrl_if_bts.py
index f27b87d..8c1d8e5 100644
--- a/src/target/fake_trx/ctrl_if_bts.py
+++ b/src/target/fake_trx/ctrl_if_bts.py
@@ -34,7 +34,7 @@
pm = None
 
def __init__(self, remote_addr, remote_port, bind_port):
-   print("[i] Init CTRL interface for BTS")
+   print("[i] Init CTRL interface for BTSB (L:%u <-> R:%s:%u)" % 
(bind_port, remote_addr, remote_port))
CTRLInterface.__init__(self, remote_addr, remote_port, 
bind_port)
 
def parse_cmd(self, request):

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ebeed7271d91ab2e45199e0fb59776c00ad833c
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 


[PATCH] osmo-gsm-tester[master]: ms: Add a first test to use all parts of the system

2018-02-28 Thread Holger Freyther
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6918

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

ms: Add a first test to use all parts of the system

This is an interim solution but is bringing all parts together.
We will need to:

 * Abstract this into a base class
 * Be able to mix different tests without interfering with each
   other (e.g. 10k LU tests, 2k SMS sending)
 * The event loop will need to handle multiple timers/timeouts
 * Stats printing should print more information and test pass/fail
 * The test should quit early if everything has already passed

Change-Id: Id3277ed0f0f9ee734569bedd4752564eb68c9cfd
---
A src/osmo_ms_driver/location_update_test.py
1 file changed, 207 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/18/6918/5

diff --git a/src/osmo_ms_driver/location_update_test.py 
b/src/osmo_ms_driver/location_update_test.py
new file mode 100644
index 000..f7371a6
--- /dev/null
+++ b/src/osmo_ms_driver/location_update_test.py
@@ -0,0 +1,207 @@
+# osmo_ms_driver: Starter for processes
+# Help to start processes over time.
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# 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, see .
+
+
+from osmo_gsm_tester import log
+from .starter import OsmoVirtPhy, OsmoMobile
+
+from datetime import timedelta
+
+import time
+
+def imsi_ki_gen():
+"""
+Generate IMSIs and KIs to be used by test.
+"""
+n = 10100
+while True:
+yield ("%.15d" % n, "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")
+n += 1
+
+class Results(log.Origin):
+
+def __init__(self, name):
+super().__init__(log.C_RUN, name)
+self._time_of_registration = None
+self._time_of_launch = None
+self._time_of_lu = None
+
+def set_start_time(self, time):
+assert self._time_of_registration is None
+self._time_of_registration = time
+
+def set_launch_time(self, time):
+assert self._time_of_launch is None
+self._time_of_launch = time
+
+def set_lu_time(self, time):
+assert self._time_of_lu is None
+self._time_of_lu = time
+
+def start_time(self):
+return self._time_of_registration or 0
+
+def launch_time(self):
+return self._time_of_launch or 0
+
+def lu_time(self):
+return self._time_of_lu or 0
+
+def lu_delay(self):
+return self.lu_time() - self.start_time()
+
+class MassUpdateLocationTest(log.Origin):
+"""
+A test to launch a configurable amount of MS and make them
+execute a Location Updating Procedure.
+
+Configure the number of MS to be tested and a function that
+decides how quickly to start them and a timeout.
+"""
+
+TEMPLATE_LUA = "osmo-mobile-lu.lua"
+TEMPLATE_CFG = "osmo-mobile.cfg"
+TEST_TIME = timedelta(seconds=120)
+
+def __init__(self, name, number_of_ms, cdf_function, event_server, 
tmp_dir):
+super().__init__(log.C_RUN, name)
+self._number_of_ms = number_of_ms
+self._cdf = cdf_function
+self._cdf.set_target(number_of_ms)
+self._unstarted = []
+self._phys = []
+self._results = {}
+imsi_gen = imsi_ki_gen()
+
+for i in range(0, number_of_ms):
+ms_name = "%.5d" % i
+
+phy = OsmoVirtPhy(ms_name, tmp_dir)
+self._phys.append(phy)
+
+launcher = OsmoMobile(ms_name, tmp_dir, self.TEMPLATE_LUA,
+self.TEMPLATE_CFG, imsi_gen,
+phy.phy_filename(),
+event_server.server_path())
+self._results[ms_name] = Results(ms_name)
+self._unstarted.append(launcher)
+self._event_server = event_server
+self._event_server.register(self.handle_msg)
+
+def pre_launch(self, loop):
+"""
+We need the virtphy's be ready when the lua script in the
+mobile comes and kicks-off the test. In lua we don't seem to
+be able to just stat/check if a file/socket exists so we need
+to do this from here.
+"""
+self.log("Pre-launching all virtphy's")
+for ms in self._phys:
+ms.start_virtphy(loop)
+
+self.log("Checking if sockets are in the filesystem")
+for 

[PATCH] osmo-gsm-tester[master]: ms: Lua part of location update testing

2018-02-28 Thread Holger Freyther
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6232

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

ms: Lua part of location update testing

The lua part to start the MS and then signal the first
successful Location Update.

Change-Id: Ica5aa0c2f86d0e5d8a2bc4dc0652de18762dd156
---
A src/osmo_gsm_tester/templates/osmo-mobile-lu.lua.tmpl
1 file changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/32/6232/6

diff --git a/src/osmo_gsm_tester/templates/osmo-mobile-lu.lua.tmpl 
b/src/osmo_gsm_tester/templates/osmo-mobile-lu.lua.tmpl
new file mode 100644
index 000..c25d799
--- /dev/null
+++ b/src/osmo_gsm_tester/templates/osmo-mobile-lu.lua.tmpl
@@ -0,0 +1,18 @@
+package.path = '${test.lua_support}/?.lua;' .. package.path
+event = require('ms_support')
+send = 1
+
+function mm_cb(new_state, new_substate, old_substate)
+if new_state == 19 and new_substate == 1 and send == 1 then
+send = 0
+event.send({lu_done=1})
+end
+end
+
+local cbs = {
+Mm=mm_cb
+}
+osmo.ms():register(cbs)
+osmo.ms().start()
+
+event.register(osmo.ms():number(), "${test.event_path}")

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ica5aa0c2f86d0e5d8a2bc4dc0652de18762dd156
Gerrit-PatchSet: 6
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


[PATCH] osmo-gsm-tester[master]: ms: Create a starter for virtphy and mobile application

2018-02-28 Thread Holger Freyther
Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6917

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

ms: Create a starter for virtphy and mobile application

In the long run we might not want to start the virtphy but
for now virtphy+mobile belong together. Start virtphy first
as mobile will not handle a missing socket gracefully.

Change-Id: I5c6d742842d7f3e0a1858436ef3f8634d8c0582d
---
A src/osmo_ms_driver/starter.py
1 file changed, 120 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/17/6917/5

diff --git a/src/osmo_ms_driver/starter.py b/src/osmo_ms_driver/starter.py
new file mode 100644
index 000..dc67f90
--- /dev/null
+++ b/src/osmo_ms_driver/starter.py
@@ -0,0 +1,120 @@
+# osmo_ms_driver: Starter for processes
+# Help to start processes over time.
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# 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, see .
+
+from osmo_gsm_tester import log, template
+
+import os
+import os.path
+import subprocess
+
+_devnull = open(os.devnull, 'w')
+#_devnull = open('/dev/stdout', 'w')
+
+class Launcher(log.Origin):
+def __init__(self, base_name, name_number, tmp_dir):
+super().__init__(log.C_RUN, "{}/{}".format(base_name, name_number))
+self._name_number = name_number
+self._tmp_dir = tmp_dir
+
+def name_number(self):
+return self._name_number
+
+class OsmoVirtPhy(Launcher):
+def __init__(self, name_number, tmp_dir):
+super().__init__("osmo-ms-virt-phy", name_number, tmp_dir)
+self._phy_filename = os.path.join(self._tmp_dir, "osmocom_l2_" + 
self._name_number)
+
+def phy_filename(self):
+return self._phy_filename
+
+def start_virtphy(self, loop):
+if len(self._phy_filename.encode()) > 107:
+raise log.Error('Path for unix socket is longer than max allowed 
len for unix socket path (107):', self._phy_filename)
+
+self.log("Starting virtphy process")
+args = ["virtphy", "--l1ctl-sock=" + self._phy_filename]
+self.log(' '.join(args))
+self._vphy_proc = subprocess.Popen(args, stderr=_devnull, 
stdout=_devnull)
+
+def verify_phy_ready(self):
+while True:
+if os.path.exists(self._phy_filename):
+return
+import time
+time.sleep(0.2)
+
+def kill(self):
+"""Clean up things."""
+if self._vphy_proc:
+self._vphy_proc.kill()
+
+class OsmoMobile(Launcher):
+def __init__(self, name_number, tmp_dir, lua_tmpl, cfg_tmpl, 
imsi_ki_generator, phy_filename, ev_server_path):
+super().__init__("osmo-ms-mob", name_number, tmp_dir)
+self._lua_template = lua_tmpl
+self._cfg_template = cfg_tmpl
+self._imsi_ki_generator = imsi_ki_generator
+self._phy_filename = phy_filename
+self._ev_server_path = ev_server_path
+
+def write_lua_cfg(self):
+lua_support = os.path.join(os.path.dirname(__file__), 'lua')
+cfg = {
+'test': {
+'event_path': self._ev_server_path,
+'lua_support': lua_support,
+}
+}
+lua_cfg_file = os.path.join(self._tmp_dir, "lua_" + self._name_number 
+ ".lua")
+lua_script = template.render(self._lua_template, cfg)
+with open(lua_cfg_file, 'w') as w:
+w.write(lua_script)
+return lua_cfg_file
+
+
+def write_mob_cfg(self, lua_filename, phy_filename):
+(imsi, ki) = next(self._imsi_ki_generator)
+cfg = {
+'test': {
+'script': lua_filename,
+'virt_phy': phy_filename,
+'imsi': imsi,
+'ki_comp128': ki,
+'ms_number': self._name_number,
+}
+}
+mob_cfg_file = os.path.join(self._tmp_dir, "mob_" + self._name_number 
+ ".cfg")
+mob_vty = template.render(self._cfg_template, cfg)
+with open(mob_cfg_file, 'w') as w:
+w.write(mob_vty)
+return mob_cfg_file
+
+def start_mobile(self, loop):
+lua_filename = self.write_lua_cfg()
+mob_filename = self.write_mob_cfg(lua_filename, self._phy_filename)
+
+self.log("Starting process")
+# Let the kernel pick an unused port for the VTY.
+  

[PATCH] osmo-gsm-tester[master]: ms: Create template for the osmocom-bb mobile application

2018-02-28 Thread Holger Freyther
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6916

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

ms: Create template for the osmocom-bb mobile application

Change-Id: I9296f42edfab57762f8dd317d63231298cda5430
---
A src/osmo_gsm_tester/templates/osmo-mobile.cfg.tmpl
1 file changed, 49 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/16/6916/5

diff --git a/src/osmo_gsm_tester/templates/osmo-mobile.cfg.tmpl 
b/src/osmo_gsm_tester/templates/osmo-mobile.cfg.tmpl
new file mode 100644
index 000..96ec0d9
--- /dev/null
+++ b/src/osmo_gsm_tester/templates/osmo-mobile.cfg.tmpl
@@ -0,0 +1,49 @@
+no gps enable
+no hide-default
+ms ${test.ms_number}
+ layer2-socket ${test.virt_phy}
+ sim test
+ network-selection-mode auto
+ imei 000 0
+ imei-fixed
+ no emergency-imsi
+ no sms-service-center
+ no call-waiting
+ no auto-answer
+ no force-rekey
+ no clip
+ no clir
+ tx-power auto
+ no simulated-delay
+ no stick
+ location-updating
+ neighbour-measurement
+ codec full-speed prefer
+ codec half-speed
+ no abbrev
+ support
+  sms
+  a5/1
+  a5/2
+  p-gsm
+  e-gsm
+  r-gsm
+  no gsm-850
+  dcs
+  no pcs
+  class-900 4
+  class-850 4
+  class-dcs 1
+  class-pcs 1
+  channel-capability sdcch+tchf+tchh
+  full-speech-v1
+  full-speech-v2
+  half-speech-v1
+  min-rxlev -106
+  dsc-max 90
+  no skip-max-per-band
+ test-sim
+  imsi ${test.imsi}
+  ki comp128 ${test.ki_comp128}
+  no barred-access
+ lua-script ${test.script}

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9296f42edfab57762f8dd317d63231298cda5430
Gerrit-PatchSet: 5
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 


[PATCH] osmo-gsm-tester[master]: ms: Create a simple epoll (or kqueue) based event loop

2018-02-28 Thread Holger Freyther
Hello Pau Espin Pedrol, Jenkins Builder,

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

https://gerrit.osmocom.org/6913

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

ms: Create a simple epoll (or kqueue) based event loop

Create a C-like single process event loop. It could be powered by
select/epoll or kqueue. It should scale to many open fds but we
will not have that many.

Change-Id: Iea06f33870cab9f21e9a1a1feb9758467343dd29
---
A src/osmo_ms_driver/simple_loop.py
1 file changed, 63 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/13/6913/4

diff --git a/src/osmo_ms_driver/simple_loop.py 
b/src/osmo_ms_driver/simple_loop.py
new file mode 100644
index 000..f4b3e05
--- /dev/null
+++ b/src/osmo_ms_driver/simple_loop.py
@@ -0,0 +1,63 @@
+# osmo_ms_driver: Event loop because asyncio is not up to the job
+#
+# Copyright (C) 2018 by Holger Hans Peter Freyther
+#
+# 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, see .
+
+from osmo_gsm_tester import log
+from functools import partial
+
+import os
+import selectors
+import socket
+
+
+class SimpleLoop(log.Origin):
+def __init__(self):
+super().__init__(log.C_RUN, "SimpleLoop")
+self._loop = selectors.DefaultSelector()
+self._timeout = None
+
+def register_fd(self, fd, event, callback):
+self._loop.register(fd, event, callback)
+
+def schedule_timeout(self, timeout):
+assert self._timeout == None
+self._timeout = timeout
+
+def create_unix_server(self, cb, path):
+sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
+
+if len(path.encode()) > 107:
+raise log.Error('Path for unix socket is longer than max allowed 
len for unix socket path (107):', path)
+
+# If not a special Linux namespace...
+if path[0] != '\0':
+try:
+os.unlink(path)
+except FileNotFoundError:
+pass
+
+# Now bind+listen+NONBLOCK
+sock.bind(path)
+sock.setblocking(False)
+
+self.register_fd(sock.fileno(), selectors.EVENT_READ, cb)
+return sock
+
+def select(self):
+events = self._loop.select(timeout=self._timeout)
+self._timeout = None
+for key, mask in events:
+key.data(key.fileobj, mask)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iea06f33870cab9f21e9a1a1feb9758467343dd29
Gerrit-PatchSet: 4
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: neels 


[PATCH] osmo-bts[master]: pcu_sock: LOG + drop PCU DATA.req for inactive lchan

2018-02-28 Thread Harald Welte

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

pcu_sock: LOG + drop PCU DATA.req for inactive lchan

Change-Id: I11c622967885d594ef7e1c24b9bafd0fb8fd400c
---
M src/common/pcu_sock.c
1 file changed, 6 insertions(+), 0 deletions(-)


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

diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index cd8e0b2..e98769d 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -534,6 +534,12 @@
rc = -EINVAL;
break;
}
+   if (ts->lchan[0].state != LCHAN_S_ACTIVE) {
+   LOGP(DPCU, LOGL_ERROR, "%s: Received PCU DATA request 
for inactive lchan\n",
+   gsm_ts_name(ts));
+   rc = -EINVAL;
+   break;
+   }
is_ptcch = (data_req->sapi == PCU_IF_SAPI_PTCCH);
rc = l1sap_pdch_req(ts, is_ptcch, data_req->fn, data_req->arfcn,
data_req->block_nr, data_req->data, data_req->len);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I11c622967885d594ef7e1c24b9bafd0fb8fd400c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


osmo-bts[master]: pcu_sock: LOG + drop PCU DATA.req for inactive lchan

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I11c622967885d594ef7e1c24b9bafd0fb8fd400c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


osmo-bts[master]: pcu_sock: LOG + drop DATA.req from PCU for non-PDCH timeslot

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I3ae496eca96bc0823dfeca16ce36c200ce000895
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: pcu_sock: LOG + drop DATA.req from PCU for non-PDCH timeslot

2018-02-28 Thread Harald Welte

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

pcu_sock: LOG + drop DATA.req from PCU for non-PDCH timeslot

Change-Id: I3ae496eca96bc0823dfeca16ce36c200ce000895
---
M src/common/pcu_sock.c
1 file changed, 6 insertions(+), 0 deletions(-)


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

diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 0d1f07a..cd8e0b2 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -528,6 +528,12 @@
break;
}
ts = >ts[data_req->ts_nr];
+   if (!ts_should_be_pdch(ts)) {
+   LOGP(DPCU, LOGL_ERROR, "%s: Received PCU DATA request 
for non-PDCH TS\n",
+   gsm_ts_name(ts));
+   rc = -EINVAL;
+   break;
+   }
is_ptcch = (data_req->sapi == PCU_IF_SAPI_PTCCH);
rc = l1sap_pdch_req(ts, is_ptcch, data_req->fn, data_req->arfcn,
data_req->block_nr, data_req->data, data_req->len);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ae496eca96bc0823dfeca16ce36c200ce000895
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[MERGED] osmo-ttcn3-hacks[master]: bts: Fix bugs in RACH Tests (timer not started, wrong CS/PS ...

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

Change subject: bts: Fix bugs in RACH Tests (timer not started, wrong CS/PS 
function)
..


bts: Fix bugs in RACH Tests (timer not started, wrong CS/PS function)

Change-Id: I619264654bfeafe4b76c8702ede5876a82c32f13
---
M bts/BTS_Tests.ttcn
1 file changed, 3 insertions(+), 3 deletions(-)

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



diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index e68a20d..48ca1fd 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -488,9 +488,7 @@
 
 /* like L1SAP_IS_PACKET_RACH */
 private function ra_is_ps(OCT1 ra) return boolean {
-   if (ra and4b 'F0'O == '70'O) {
-   return true;
-   } else if (ra and4b '0F'O == '0F'O) {
+   if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
return true;
}
return false;
@@ -522,6 +520,7 @@
fn_last := fn;
 
timer T := 5.0;
+   T.start;
alt {
[] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
T.stop;
@@ -558,6 +557,7 @@
}
var integer rsl_chrqd := 0;
timer T := 3.0;
+   T.start;
alt {
[] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
rsl_chrqd := rsl_chrqd + 1;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I619264654bfeafe4b76c8702ede5876a82c32f13
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-ttcn3-hacks[master]: bts: Add PCU Interface testcases

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

Change subject: bts: Add PCU Interface testcases
..


bts: Add PCU Interface testcases

Change-Id: I671b8e2c61705485f46602f648eb5fdc01db12f7
---
M bts/BTS_Tests.default
M bts/BTS_Tests.ttcn
M bts/gen_links.sh
A library/PCUIF_CodecPort.ttcn
A library/PCUIF_Types.ttcn
5 files changed, 947 insertions(+), 0 deletions(-)

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



diff --git a/bts/BTS_Tests.default b/bts/BTS_Tests.default
index 562088b..fa8d0b0 100644
--- a/bts/BTS_Tests.default
+++ b/bts/BTS_Tests.default
@@ -13,6 +13,7 @@
 *.BTSVTY.CTRL_READMODE := "buffered"
 *.BTSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
 *.BTSVTY.PROMPT1 := "OsmoBTS> "
+*.PCU.socket_type := "SEQPACKET"
 
 [MODULE_PARAMETERS]
 Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoBTS";
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 48ca1fd..be9b4cc 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -22,6 +22,9 @@
 import from TRXC_CodecPort all;
 import from TRXC_CodecPort_CtrlFunct all;
 
+import from PCUIF_Types all;
+import from PCUIF_CodecPort all;
+
 import from MobileL3_CommonIE_Types all;
 import from MobileL3_RRM_Types all;
 import from MobileL3_Types all;
@@ -43,6 +46,7 @@
integer mp_rsl_port := 3003;
integer mp_trx0_arfcn := 871;
integer mp_bb_trxc_port := 5704;
+   charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
 }
 
 type component test_CT extends CTRL_Adapter_CT {
@@ -61,6 +65,12 @@
var integer g_bb_trxc_conn_id;
 
port TELNETasp_PT BTSVTY;
+
+   /* PCU Interface of BTS */
+   port PCUIF_CODEC_PT PCU;
+   var integer g_pcu_conn_id;
+   /* Last PCU INFO IND we received */
+   var PCUIF_Message g_pcu_last_info;
 
/* SI configuration */
var SystemInformationConfig si_cfg := {
@@ -212,6 +222,33 @@
f_vty_transceive(BTSVTY, "enable");
 }
 
+/* PCU socket may at any time receive a new INFO.ind */
+private altstep as_pcu_info_ind() runs on test_CT {
+   var PCUIF_send_data sd;
+   [] PCU.receive(t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_INFO_IND)) -> 
value sd {
+   g_pcu_last_info := sd.data;
+   repeat;
+   }
+}
+
+private function f_init_pcu(charstring id) runs on test_CT {
+   timer T := 2.0;
+   var PCUIF_send_data sd;
+   map(self:PCU, system:PCU);
+   g_pcu_conn_id := f_pcuif_connect(PCU, mp_pcu_socket);
+
+   T.start;
+   alt {
+   [] PCU.receive(t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_INFO_IND)) -> 
value sd {
+   g_pcu_last_info := sd.data;
+   }
+   [] T.timeout {
+   setverdict(fail, "Timeout waiting for PCU INFO_IND");
+   self.stop;
+   }
+   }
+}
+
 /* global init function */
 function f_init(charstring id := "BTS-Test") runs on test_CT {
f_init_rsl(id);
@@ -224,6 +261,8 @@
/* SI2 + SI4 are required for SI testing as they are mandatory defaults 
*/
f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
+
+   f_init_pcu(id);
 
/* start with a default moderate timing offset equalling TA=2 */
f_main_trxc_connect();
@@ -500,6 +539,15 @@
do {
ra := f_rnd_octstring(1);
} while (ra_is_ps(ra));
+   return ra;
+}
+
+/* generate a random RACH for packet-switched */
+private function f_rnd_ra_ps() return OCT1 {
+   var OCT1 ra;
+   do {
+   ra := f_rnd_octstring(1);
+   } while (not ra_is_ps(ra));
return ra;
 }
 
@@ -1790,6 +1838,353 @@
 }
 
 
+/***
+ * PCU Socket related tests
+ ***/
+
+private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t 
ts_nr, boolean exp_success)
+runs on test_CT {
+   timer T := 3.0;
+
+   /* we don't expect any RTS.req before PDCH are active */
+   T.start;
+   alt {
+   [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
+   setverdict(fail, "PCU RTS.req before PDCH active?");
+   self.stop;
+   }
+   [] PCU.receive { repeat; }
+   [] T.timeout { }
+   }
+
+   /* Send PDCH activate request for known PDCH timeslot */
+   PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, 
ts_nr)));
+
+   /* we now expect RTS.req for this timeslot (only) */
+   T.start;
+   alt {
+   [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, 
tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
+   setverdict(pass);
+   }
+   [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
+tr_PCUIF_RTS_REQ(bts_nr, 
trx_nr, 

osmo-ttcn3-hacks[master]: bts: Add PCU Interface testcases

2018-02-28 Thread Harald Welte

Patch Set 3: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I671b8e2c61705485f46602f648eb5fdc01db12f7
Gerrit-PatchSet: 3
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-bts[master]: pcu_sock: Log an error message and discard PCU primitives fo...

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

Change subject: pcu_sock: Log an error message and discard PCU primitives for 
BTS != 0
..


pcu_sock: Log an error message and discard PCU primitives for BTS != 0

In OsmoBTS, we (so far?) only have a single BTS inside each process,
let's make sure we log an error message if the PCU should ever want to
transmit primitives to a non-zero BTS number.

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

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



diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index c8308a9..0d1f07a 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -621,6 +621,10 @@
struct gsm_bts *bts;
 
/* FIXME: allow multiple BTS */
+   if (pcu_prim->bts_nr != 0) {
+   LOGP(DPCU, LOGL_ERROR, "Received PCU Prim for non-existent BTS 
%u\n", pcu_prim->bts_nr);
+   return -EINVAL;
+   }
bts = llist_entry(net->bts_list.next, struct gsm_bts, list);
 
switch (msg_type) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I158f935fed12941737c806c0677a8192ea3418a0
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 


osmo-ttcn3-hacks[master]: bts: Fix bugs in RACH Tests (timer not started, wrong CS/PS ...

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I619264654bfeafe4b76c8702ede5876a82c32f13
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-ttcn3-hacks[master]: bts: Add PCU Interface testcases

2018-02-28 Thread Harald Welte
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/7005

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

bts: Add PCU Interface testcases

Change-Id: I671b8e2c61705485f46602f648eb5fdc01db12f7
---
M bts/BTS_Tests.default
M bts/BTS_Tests.ttcn
M bts/gen_links.sh
A library/PCUIF_CodecPort.ttcn
A library/PCUIF_Types.ttcn
5 files changed, 947 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/05/7005/3

diff --git a/bts/BTS_Tests.default b/bts/BTS_Tests.default
index 562088b..fa8d0b0 100644
--- a/bts/BTS_Tests.default
+++ b/bts/BTS_Tests.default
@@ -13,6 +13,7 @@
 *.BTSVTY.CTRL_READMODE := "buffered"
 *.BTSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
 *.BTSVTY.PROMPT1 := "OsmoBTS> "
+*.PCU.socket_type := "SEQPACKET"
 
 [MODULE_PARAMETERS]
 Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoBTS";
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 48ca1fd..be9b4cc 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -22,6 +22,9 @@
 import from TRXC_CodecPort all;
 import from TRXC_CodecPort_CtrlFunct all;
 
+import from PCUIF_Types all;
+import from PCUIF_CodecPort all;
+
 import from MobileL3_CommonIE_Types all;
 import from MobileL3_RRM_Types all;
 import from MobileL3_Types all;
@@ -43,6 +46,7 @@
integer mp_rsl_port := 3003;
integer mp_trx0_arfcn := 871;
integer mp_bb_trxc_port := 5704;
+   charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
 }
 
 type component test_CT extends CTRL_Adapter_CT {
@@ -61,6 +65,12 @@
var integer g_bb_trxc_conn_id;
 
port TELNETasp_PT BTSVTY;
+
+   /* PCU Interface of BTS */
+   port PCUIF_CODEC_PT PCU;
+   var integer g_pcu_conn_id;
+   /* Last PCU INFO IND we received */
+   var PCUIF_Message g_pcu_last_info;
 
/* SI configuration */
var SystemInformationConfig si_cfg := {
@@ -212,6 +222,33 @@
f_vty_transceive(BTSVTY, "enable");
 }
 
+/* PCU socket may at any time receive a new INFO.ind */
+private altstep as_pcu_info_ind() runs on test_CT {
+   var PCUIF_send_data sd;
+   [] PCU.receive(t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_INFO_IND)) -> 
value sd {
+   g_pcu_last_info := sd.data;
+   repeat;
+   }
+}
+
+private function f_init_pcu(charstring id) runs on test_CT {
+   timer T := 2.0;
+   var PCUIF_send_data sd;
+   map(self:PCU, system:PCU);
+   g_pcu_conn_id := f_pcuif_connect(PCU, mp_pcu_socket);
+
+   T.start;
+   alt {
+   [] PCU.receive(t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_INFO_IND)) -> 
value sd {
+   g_pcu_last_info := sd.data;
+   }
+   [] T.timeout {
+   setverdict(fail, "Timeout waiting for PCU INFO_IND");
+   self.stop;
+   }
+   }
+}
+
 /* global init function */
 function f_init(charstring id := "BTS-Test") runs on test_CT {
f_init_rsl(id);
@@ -224,6 +261,8 @@
/* SI2 + SI4 are required for SI testing as they are mandatory defaults 
*/
f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
+
+   f_init_pcu(id);
 
/* start with a default moderate timing offset equalling TA=2 */
f_main_trxc_connect();
@@ -500,6 +539,15 @@
do {
ra := f_rnd_octstring(1);
} while (ra_is_ps(ra));
+   return ra;
+}
+
+/* generate a random RACH for packet-switched */
+private function f_rnd_ra_ps() return OCT1 {
+   var OCT1 ra;
+   do {
+   ra := f_rnd_octstring(1);
+   } while (not ra_is_ps(ra));
return ra;
 }
 
@@ -1790,6 +1838,353 @@
 }
 
 
+/***
+ * PCU Socket related tests
+ ***/
+
+private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t 
ts_nr, boolean exp_success)
+runs on test_CT {
+   timer T := 3.0;
+
+   /* we don't expect any RTS.req before PDCH are active */
+   T.start;
+   alt {
+   [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
+   setverdict(fail, "PCU RTS.req before PDCH active?");
+   self.stop;
+   }
+   [] PCU.receive { repeat; }
+   [] T.timeout { }
+   }
+
+   /* Send PDCH activate request for known PDCH timeslot */
+   PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, 
ts_nr)));
+
+   /* we now expect RTS.req for this timeslot (only) */
+   T.start;
+   alt {
+   [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, 
tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
+   setverdict(pass);
+   }
+   [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
+tr_PCUIF_RTS_REQ(bts_nr, 
trx_nr, ts_nr))) {
+   

osmo-bts[master]: pcu_sock: Log an error message and discard PCU primitives fo...

2018-02-28 Thread Harald Welte

Patch Set 3: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I158f935fed12941737c806c0677a8192ea3418a0
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


[PATCH] osmo-ttcn3-hacks[master]: bts: Fix bugs in RACH Tests (timer not started, wrong CS/PS ...

2018-02-28 Thread Harald Welte

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

bts: Fix bugs in RACH Tests (timer not started, wrong CS/PS function)

Change-Id: I619264654bfeafe4b76c8702ede5876a82c32f13
---
M bts/BTS_Tests.ttcn
1 file changed, 3 insertions(+), 3 deletions(-)


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

diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index e68a20d..48ca1fd 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -488,9 +488,7 @@
 
 /* like L1SAP_IS_PACKET_RACH */
 private function ra_is_ps(OCT1 ra) return boolean {
-   if (ra and4b 'F0'O == '70'O) {
-   return true;
-   } else if (ra and4b '0F'O == '0F'O) {
+   if ((ra and4b 'F0'O == '70'O) and (ra and4b '0F'O != '0F'O)) {
return true;
}
return false;
@@ -522,6 +520,7 @@
fn_last := fn;
 
timer T := 5.0;
+   T.start;
alt {
[] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) {
T.stop;
@@ -558,6 +557,7 @@
}
var integer rsl_chrqd := 0;
timer T := 3.0;
+   T.start;
alt {
[] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) {
rsl_chrqd := rsl_chrqd + 1;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I619264654bfeafe4b76c8702ede5876a82c32f13
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-bts[master]: pcu_sock: Log an error message and discard PCU primitives fo...

2018-02-28 Thread Harald Welte
Hello Stefan Sperling, Jenkins Builder,

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

https://gerrit.osmocom.org/6997

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

pcu_sock: Log an error message and discard PCU primitives for BTS != 0

In OsmoBTS, we (so far?) only have a single BTS inside each process,
let's make sure we log an error message if the PCU should ever want to
transmit primitives to a non-zero BTS number.

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/97/6997/3

diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index c8308a9..0d1f07a 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -621,6 +621,10 @@
struct gsm_bts *bts;
 
/* FIXME: allow multiple BTS */
+   if (pcu_prim->bts_nr != 0) {
+   LOGP(DPCU, LOGL_ERROR, "Received PCU Prim for non-existent BTS 
%u\n", pcu_prim->bts_nr);
+   return -EINVAL;
+   }
bts = llist_entry(net->bts_list.next, struct gsm_bts, list);
 
switch (msg_type) {

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I158f935fed12941737c806c0677a8192ea3418a0
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 


osmo-ttcn3-hacks[master]: bts: Add PCU Interface testcases

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I671b8e2c61705485f46602f648eb5fdc01db12f7
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-ttcn3-hacks[master]: bts: Add PCU Interface testcases

2018-02-28 Thread Harald Welte

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

bts: Add PCU Interface testcases

Change-Id: I671b8e2c61705485f46602f648eb5fdc01db12f7
---
M bts/BTS_Tests.default
M bts/BTS_Tests.ttcn
M bts/gen_links.sh
A library/PCUIF_CodecPort.ttcn
A library/PCUIF_Types.ttcn
5 files changed, 815 insertions(+), 0 deletions(-)


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

diff --git a/bts/BTS_Tests.default b/bts/BTS_Tests.default
index 562088b..fa8d0b0 100644
--- a/bts/BTS_Tests.default
+++ b/bts/BTS_Tests.default
@@ -13,6 +13,7 @@
 *.BTSVTY.CTRL_READMODE := "buffered"
 *.BTSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"
 *.BTSVTY.PROMPT1 := "OsmoBTS> "
+*.PCU.socket_type := "SEQPACKET"
 
 [MODULE_PARAMETERS]
 Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoBTS";
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index e68a20d..0d1aaba 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -22,6 +22,9 @@
 import from TRXC_CodecPort all;
 import from TRXC_CodecPort_CtrlFunct all;
 
+import from PCUIF_Types all;
+import from PCUIF_CodecPort all;
+
 import from MobileL3_CommonIE_Types all;
 import from MobileL3_RRM_Types all;
 import from MobileL3_Types all;
@@ -43,6 +46,7 @@
integer mp_rsl_port := 3003;
integer mp_trx0_arfcn := 871;
integer mp_bb_trxc_port := 5704;
+   charstring mp_pcu_socket := PCU_SOCK_DEFAULT;
 }
 
 type component test_CT extends CTRL_Adapter_CT {
@@ -61,6 +65,12 @@
var integer g_bb_trxc_conn_id;
 
port TELNETasp_PT BTSVTY;
+
+   /* PCU Interface of BTS */
+   port PCUIF_CODEC_PT PCU;
+   var integer g_pcu_conn_id;
+   /* Last PCU INFO IND we received */
+   var PCUIF_Message g_pcu_last_info;
 
/* SI configuration */
var SystemInformationConfig si_cfg := {
@@ -212,6 +222,33 @@
f_vty_transceive(BTSVTY, "enable");
 }
 
+/* PCU socket may at any time receive a new INFO.ind */
+private altstep as_pcu_info_ind() runs on test_CT {
+   var PCUIF_send_data sd;
+   [] PCU.receive(t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_INFO_IND)) -> 
value sd {
+   g_pcu_last_info := sd.data;
+   repeat;
+   }
+}
+
+private function f_init_pcu(charstring id) runs on test_CT {
+   timer T := 2.0;
+   var PCUIF_send_data sd;
+   map(self:PCU, system:PCU);
+   g_pcu_conn_id := f_pcuif_connect(PCU, mp_pcu_socket);
+
+   T.start;
+   alt {
+   [] PCU.receive(t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_INFO_IND)) -> 
value sd {
+   g_pcu_last_info := sd.data;
+   }
+   [] T.timeout {
+   setverdict(fail, "Timeout waiting for PCU INFO_IND");
+   self.stop;
+   }
+   }
+}
+
 /* global init function */
 function f_init(charstring id := "BTS-Test") runs on test_CT {
f_init_rsl(id);
@@ -224,6 +261,8 @@
/* SI2 + SI4 are required for SI testing as they are mandatory defaults 
*/
f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default);
f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default);
+
+   f_init_pcu(id);
 
/* start with a default moderate timing offset equalling TA=2 */
f_main_trxc_connect();
@@ -1790,6 +1829,273 @@
 }
 
 
+/***
+ * PCU Socket related tests
+ ***/
+
+private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t 
ts_nr, boolean exp_success)
+runs on test_CT {
+   timer T := 3.0;
+
+   /* we don't expect any RTS.req before PDCH are active */
+   T.start;
+   alt {
+   [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) {
+   setverdict(fail, "PCU RTS.req before PDCH active?");
+   self.stop;
+   }
+   [] PCU.receive { repeat; }
+   [] T.timeout { }
+   }
+
+   /* Send PDCH activate request for known PDCH timeslot */
+   PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, 
ts_nr)));
+
+   /* we now expect RTS.req for this timeslot (only) */
+   T.start;
+   alt {
+   [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, 
tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) {
+   setverdict(pass);
+   }
+   [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
+tr_PCUIF_RTS_REQ(bts_nr, 
trx_nr, ts_nr))) {
+   setverdict(fail, "Unexpected RTS.req for supposedly failing 
activation");
+   self.stop;
+   }
+   [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) {
+   setverdict(fail, "RTS.req for wrong TRX/TS");
+   self.stop;
+   }
+   [] PCU.receive { repeat; }
+   [exp_success] T.timeout {
+   setverdict(fail, "Timeout waiting for PCU RTS.req");
+   }
+   [not 

libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-28 Thread Harald Welte

Patch Set 7: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


osmo-msc[master]: cosmetic: gsm_network_init(): imply default 001-01 PLMN

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


[MERGED] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: FIX: apply TA value correctly

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

Change subject: fake_trx/burst_fwd.py: FIX: apply TA value correctly
..


fake_trx/burst_fwd.py: FIX: apply TA value correctly

If field randomization is disabled, Timing Advance value
indicated by MS would be ignored. Let's fix this by
separating the TA calculation code.

Change-Id: If43d5823fc33efc2f1649ea941ab6f619bb6f5e7
---
M src/target/fake_trx/burst_fwd.py
1 file changed, 6 insertions(+), 4 deletions(-)

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



diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index d059e13..9f0f84f 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -70,6 +70,11 @@
self.bts_link = bts_link
self.bb_link = bb_link
 
+   # Converts TA value from symbols to
+   # units of 1/256 of GSM symbol periods
+   def calc_ta256(self):
+   return self.ta * 256
+
# Calculates a random ToA value for Downlink bursts
def calc_dl_toa256(self):
# Check if randomization is required
@@ -97,10 +102,6 @@
 
# Generate a random ToA value
toa256 = random.randint(toa256_min, toa256_max)
-
-   # Apply TA value indicated by MS
-   ta256 = self.ta * 256
-   toa256 -= ta256
 
return toa256
 
@@ -149,6 +150,7 @@
msg_trx2l1.rssi = self.calc_dl_rssi()
else:
msg_trx2l1.toa256 = self.calc_ul_toa256()
+   msg_trx2l1.toa256 -= self.calc_ta256()
msg_trx2l1.rssi = self.calc_ul_rssi()
 
return msg_trx2l1

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If43d5823fc33efc2f1649ea941ab6f619bb6f5e7
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-bts[master]: pcu_sock: Don't overflow the timeslot array

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

Change subject: pcu_sock: Don't overflow the timeslot array
..


pcu_sock: Don't overflow the timeslot array

Don't blindly trust that the ts_nr received on the PCU socket will be
small enough to not overflow our timeslot array!

Change-Id: Ie9964c8dc0ca7b049da7dfec0ac0a0d3f1aedd45
---
M src/common/pcu_sock.c
1 file changed, 6 insertions(+), 0 deletions(-)

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



diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index b810174..c8308a9 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -521,6 +521,12 @@
rc = -EINVAL;
break;
}
+   if (data_req->ts_nr >= ARRAY_SIZE(trx->ts)) {
+   LOGP(DPCU, LOGL_ERROR, "Received PCU data request with "
+   "not existing TS %u\n", data_req->ts_nr);
+   rc = -EINVAL;
+   break;
+   }
ts = >ts[data_req->ts_nr];
is_ptcch = (data_req->sapi == PCU_IF_SAPI_PTCCH);
rc = l1sap_pdch_req(ts, is_ptcch, data_req->fn, data_req->arfcn,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie9964c8dc0ca7b049da7dfec0ac0a0d3f1aedd45
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 


[PATCH] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: FIX: apply TA value correctly

2018-02-28 Thread Vadim Yanitskiy

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

fake_trx/burst_fwd.py: FIX: apply TA value correctly

If field randomization is disabled, Timing Advance value
indicated by MS would be ignored. Let's fix this by
separating the TA calculation code.

Change-Id: If43d5823fc33efc2f1649ea941ab6f619bb6f5e7
---
M src/target/fake_trx/burst_fwd.py
1 file changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/04/7004/1

diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index d059e13..9f0f84f 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -70,6 +70,11 @@
self.bts_link = bts_link
self.bb_link = bb_link
 
+   # Converts TA value from symbols to
+   # units of 1/256 of GSM symbol periods
+   def calc_ta256(self):
+   return self.ta * 256
+
# Calculates a random ToA value for Downlink bursts
def calc_dl_toa256(self):
# Check if randomization is required
@@ -97,10 +102,6 @@
 
# Generate a random ToA value
toa256 = random.randint(toa256_min, toa256_max)
-
-   # Apply TA value indicated by MS
-   ta256 = self.ta * 256
-   toa256 -= ta256
 
return toa256
 
@@ -149,6 +150,7 @@
msg_trx2l1.rssi = self.calc_dl_rssi()
else:
msg_trx2l1.toa256 = self.calc_ul_toa256()
+   msg_trx2l1.toa256 -= self.calc_ta256()
msg_trx2l1.rssi = self.calc_ul_rssi()
 
return msg_trx2l1

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If43d5823fc33efc2f1649ea941ab6f619bb6f5e7
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 


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

2018-02-28 Thread Neels Hofmeyr

Patch Set 11: Code-Review-1

(2 comments)

https://gerrit.osmocom.org/#/c/6509/11/include/osmocom/gsm/gsm0808.h
File include/osmocom/gsm/gsm0808.h:

Line 74: /* deprecated */
OSMO_DEPRECATED()?


https://gerrit.osmocom.org/#/c/6509/11/tests/gsm0808/gsm0808_test.c
File tests/gsm0808/gsm0808_test.c:

Line 817:   enc_cil.id_discr = CELL_IDENT_BSS;
mention this fix in the commit log?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb
Gerrit-PatchSet: 11
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: Yes


libosmocore[master]: gsm0408_test: test new gsm48_{decode, generate}_lai2() functions

2018-02-28 Thread Neels Hofmeyr

Patch Set 7: Code-Review+2

only trivial function renames from prev patch set

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[PATCH] osmo-msc[master]: cosmetic: gsm_network_init(): imply default 001-01 PLMN

2018-02-28 Thread Neels Hofmeyr

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

cosmetic: gsm_network_init(): imply default 001-01 PLMN

All callers pass mcc=1, mnc=1, so just have it as default.
(Prepare for net->country_code etc to be replaced by net->plmn)

Change-Id: Ibcd1cc38f170895305ae176a5574384c74a33939
---
M include/osmocom/msc/common_cs.h
M src/libcommon-cs/common_cs.c
M src/osmo-msc/msc_main.c
M tests/msc_vlr/msc_vlr_tests.c
4 files changed, 6 insertions(+), 12 deletions(-)


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

diff --git a/include/osmocom/msc/common_cs.h b/include/osmocom/msc/common_cs.h
index 6dc956f..273a8fe 100644
--- a/include/osmocom/msc/common_cs.h
+++ b/include/osmocom/msc/common_cs.h
@@ -17,10 +17,7 @@
uint8_t key[MAX_A5_KEY_LEN];
 };
 
-struct gsm_network *gsm_network_init(void *ctx,
-uint16_t country_code,
-uint16_t network_code,
-mncc_recv_cb_t mncc_recv);
+struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv);
 
 int common_cs_vty_init(struct gsm_network *network,
  int (* config_write_net )(struct vty *));
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index a2f5cb3..c64719b 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -37,10 +37,7 @@
  * The long term aim should be to have entirely separate structs for libbsc and
  * libmsc with some common general items.
  */
-struct gsm_network *gsm_network_init(void *ctx,
-uint16_t country_code,
-uint16_t network_code,
-mncc_recv_cb_t mncc_recv)
+struct gsm_network *gsm_network_init(void *ctx, mncc_recv_cb_t mncc_recv)
 {
struct gsm_network *net;
 
@@ -48,8 +45,8 @@
if (!net)
return NULL;
 
-   net->country_code = country_code;
-   net->network_code = network_code;
+   net->country_code = 1;
+   net->network_code = 1;
/* Permit a compile-time default of A5/3 and A5/1 */
net->a5_encryption_mask = (1 << 3) | (1 << 1);
 
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index da28083..f49c480 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -202,7 +202,7 @@
 struct gsm_network *msc_network_alloc(void *ctx,
  mncc_recv_cb_t mncc_recv)
 {
-   struct gsm_network *net = gsm_network_init(ctx, 1, 1, mncc_recv);
+   struct gsm_network *net = gsm_network_init(ctx, mncc_recv);
if (!net)
return NULL;
 
diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index f514286..362f32d 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -845,7 +845,7 @@
 
 struct gsm_network *test_net(void *ctx)
 {
-   struct gsm_network *net = gsm_network_init(ctx, 1, 1, mncc_recv);
+   struct gsm_network *net = gsm_network_init(ctx, mncc_recv);
 
net->gsup_server_addr_str = talloc_strdup(net, "no_gsup_server");
net->gsup_server_port = 0;

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

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


[PATCH] osmo-msc[master]: implement support for 3-digit MNC with leading zeros

2018-02-28 Thread Neels Hofmeyr
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6671

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

implement support for 3-digit MNC with leading zeros

Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore),
 Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore)
Change-Id: I82f0016d9512ee8722a3489a3cb4b6c704a271fc
---
M include/osmocom/msc/gsm_data.h
M src/libcommon-cs/common_cs.c
M src/libcommon-cs/common_cs_vty.c
M src/libmsc/a_iface_bssap.c
M src/libmsc/gsm_04_08.c
M src/libmsc/msc_vty.c
M src/libvlr/vlr_lu_fsm.c
M src/osmo-msc/msc_main.c
8 files changed, 33 insertions(+), 41 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/71/6671/3

diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index 67b657a..2d1d20c 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -223,11 +223,11 @@
 * these have in common, like country and network code, put in yet
 * separate structs and placed as members in osmo_bsc and osmo_msc. */
 
-   /* global parameters */
-   uint16_t country_code;
-   uint16_t network_code;
+   struct osmo_plmn_id plmn;
+
char *name_long;
char *name_short;
+
/* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */
uint8_t a5_encryption_mask;
bool authentication_required;
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index c64719b..a1d2298 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -45,8 +45,8 @@
if (!net)
return NULL;
 
-   net->country_code = 1;
-   net->network_code = 1;
+   net->plmn = (struct osmo_plmn_id){ .mcc=1, .mnc=1 };
+
/* Permit a compile-time default of A5/3 and A5/1 */
net->a5_encryption_mask = (1 << 3) | (1 << 1);
 
diff --git a/src/libcommon-cs/common_cs_vty.c b/src/libcommon-cs/common_cs_vty.c
index 01c6b35..d59f31c 100644
--- a/src/libcommon-cs/common_cs_vty.c
+++ b/src/libcommon-cs/common_cs_vty.c
@@ -61,7 +61,7 @@
 {
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
 
-   gsmnet->country_code = atoi(argv[0]);
+   gsmnet->plmn.mcc = atoi(argv[0]);
 
return CMD_SUCCESS;
 }
@@ -75,8 +75,16 @@
   "Mobile Network Code to use\n")
 {
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+   uint16_t mnc;
+   bool mnc_3_digits;
 
-   gsmnet->network_code = atoi(argv[0]);
+   if (osmo_mnc_from_str(argv[0], , _3_digits)) {
+   vty_out(vty, "%% Error decoding MNC: %s%s", argv[0], 
VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   gsmnet->plmn.mnc = mnc;
+   gsmnet->plmn.mnc_3_digits = mnc_3_digits;
 
return CMD_SUCCESS;
 }
diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c
index 224c5c9..7b86764 100644
--- a/src/libmsc/a_iface_bssap.c
+++ b/src/libmsc/a_iface_bssap.c
@@ -263,9 +263,7 @@
struct gsm48_loc_area_id lai;
uint16_t ci;
} __attribute__ ((packed)) lai_ci;
-   uint16_t mcc;
-   uint16_t mnc;
-   uint16_t lac;
+   struct osmo_location_area_id lai;
uint8_t data_length;
const uint8_t *data;
int rc;
@@ -301,18 +299,15 @@
 "Unable to parse element CELL IDENTIFIER (wrong cell 
identification discriminator) -- discarding message!\n");
return -EINVAL;
}
-   if (gsm48_decode_lai(_ci.lai, , , ) != 0) {
-   LOGP(DBSSAP, LOGL_ERROR,
-"Unable to parse element CELL IDENTIFIER (lai decoding 
failed) -- discarding message!\n");
-   return -EINVAL;
-   }
+   gsm48_decode_lai2(_ci.lai, );
+   /* FIXME: Actually compare the MCC-MNC to the local network config?? */
 
/* Parse Layer 3 Information element */
msg->l3h = (uint8_t*)TLVP_VAL(tp, GSM0808_IE_LAYER_3_INFORMATION);
msgb_l3trim(msg, TLVP_LEN(tp, GSM0808_IE_LAYER_3_INFORMATION));
 
/* Create new subscriber context */
-   conn = subscr_conn_allocate_a(a_conn_info, network, lac, scu, 
a_conn_info->conn_id);
+   conn = subscr_conn_allocate_a(a_conn_info, network, lai.lac, scu, 
a_conn_info->conn_id);
 
/* Handover location update to the MSC code */
rc = msc_compl_l3(conn, msg, 0);
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index b928171..18f8412 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -222,15 +222,17 @@
struct gsm48_hdr *gh;
struct gsm48_loc_area_id *lai;
uint8_t *mid;
+   struct osmo_location_area_id laid = {
+   .plmn = conn->network->plmn,
+   .lac = conn->lac,
+   };
 

[PATCH] libosmocore[master]: gsm0408_test: add test cases for MNC with leading zeros

2018-02-28 Thread Neels Hofmeyr
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6662

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

gsm0408_test: add test cases for MNC with leading zeros

Change-Id: I9b387e09293a6bbef84b9620ccf21ee2f9ec751c
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 149 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/62/6662/7

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 479b371..2a0e661 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -238,6 +238,16 @@
.mnc = 0,
.lac = 0,
.rac = 0,
+   .mnc_3_digits = false,
+   /* expecting 000-00, BCD = 00 f0 00 */
+   },
+   {
+   .mcc = 0,
+   .mnc = 0,
+   .lac = 0,
+   .rac = 0,
+   .mnc_3_digits = true,
+   /* expecting 000-000, BCD = 00 00 00 */
},
{
.mcc = 999,
@@ -245,6 +255,54 @@
.lac = 65535,
.rac = 255,
},
+   {
+   .mcc = 1,
+   .mnc = 2,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = false,
+   /* expecting 001-02, BCD = 00 f1 20 */
+   },
+   {
+   .mcc = 1,
+   .mnc = 2,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = true,
+   /* expecting 001-002, BCD = 00 21 00 */
+   },
+   {
+   .mcc = 12,
+   .mnc = 34,
+   .lac = 56,
+   .rac = 78,
+   .mnc_3_digits = false,
+   /* expecting 012-34, BCD = 10 f2 43 */
+   },
+   {
+   .mcc = 12,
+   .mnc = 34,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = true,
+   /* expecting 012-034, BCD = 10 42 30 */
+   },
+   {
+   .mcc = 123,
+   .mnc = 456,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = false,
+   /* expecting 123-456, BCD = 21 63 54 (false flag has no effect) 
*/
+   },
+   {
+   .mcc = 123,
+   .mnc = 456,
+   .lac = 23,
+   .rac = 42,
+   .mnc_3_digits = true,
+   /* expecting 123-456, BCD = 21 63 54 (same) */
+   },
 };
 
 static void test_ra_cap(void)
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index a0e2c23..c1d6a70 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -18,9 +18,44 @@
 000-00-0-0
 RA test...passed
 Constructed RA:
+000-000-0-0 (3-digit MNC)
+MCC+MNC in BCD: 00 00 00 
+000-000-0-0 (3-digit MNC)
+RA test...passed
+Constructed RA:
 999-999-65535-255
 MCC+MNC in BCD: 99 99 99 
 999-999-65535-255 (3-digit MNC)
+RA test...passed
+Constructed RA:
+001-02-23-42
+MCC+MNC in BCD: 00 f1 20 
+001-02-23-42
+RA test...passed
+Constructed RA:
+001-002-23-42 (3-digit MNC)
+MCC+MNC in BCD: 00 21 00 
+001-002-23-42 (3-digit MNC)
+RA test...passed
+Constructed RA:
+012-34-56-78
+MCC+MNC in BCD: 10 f2 43 
+012-34-56-78
+RA test...passed
+Constructed RA:
+012-034-23-42 (3-digit MNC)
+MCC+MNC in BCD: 10 42 30 
+012-034-23-42 (3-digit MNC)
+RA test...passed
+Constructed RA:
+123-456-23-42
+MCC+MNC in BCD: 21 63 54 
+123-456-23-42 (3-digit MNC)
+RA test...passed
+Constructed RA:
+123-456-23-42 (3-digit MNC)
+MCC+MNC in BCD: 21 63 54 
+123-456-23-42 (3-digit MNC)
 RA test...passed
 - gsm48_generate_lai() from 077-121-666-0
   Encoded 70 17 21 02 9a 
@@ -46,6 +81,14 @@
   Encoded 00 f0 00 00 00 
   gsm48_decode_lai2() gives  000-00-0
   passed
+- gsm48_generate_lai() from 000-000-0-0 (3-digit MNC)
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai() gives  000-00-0-0
+  passed
+- gsm48_generate_lai2() from 000-000-0 (3-digit MNC)
+  Encoded 00 00 00 00 00 
+  gsm48_decode_lai2() gives  000-000-0 (3-digit MNC)
+  passed
 - gsm48_generate_lai() from 999-999-65535-0
   Encoded 99 99 99 ff ff 
   gsm48_decode_lai() gives  999-999-65535-0
@@ -54,3 +97,51 @@
   Encoded 99 99 99 ff ff 
   gsm48_decode_lai2() gives  999-999-65535 (3-digit MNC)
   passed
+- gsm48_generate_lai() from 001-02-23-0
+  Encoded 00 f1 20 00 17 
+  gsm48_decode_lai() gives  001-02-23-0
+  passed
+- gsm48_generate_lai2() from 001-02-23
+  Encoded 00 f1 20 00 17 
+  gsm48_decode_lai2() gives  001-02-23
+  passed
+- gsm48_generate_lai() from 001-002-23-0 (3-digit MNC)
+  Encoded 00 f1 20 00 17 
+  gsm48_decode_lai() gives  001-02-23-0
+  passed
+- gsm48_generate_lai2() from 001-002-23 (3-digit MNC)
+  Encoded 00 21 00 00 17 
+  gsm48_decode_lai2() gives  001-002-23 (3-digit MNC)
+  passed
+- gsm48_generate_lai() from 012-34-56-0
+  Encoded 10 f2 43 00 38 
+  gsm48_decode_lai() gives  

[PATCH] libosmocore[master]: implement support for 3-digit MNC with leading zeros

2018-02-28 Thread Neels Hofmeyr
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6659

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

implement support for 3-digit MNC with leading zeros

Enable representing three-digit MNC with leading zeros. The MNCs 23 and 023 are
actually different; so far we treated both as 23. Re-encode an incoming BCD or
string of 023 as it were, i.e. not dropping the leading zero as 23.

Break ABI compatibility by changing the size and ordering of structs
gprs_ra_id, osmo_plmn_id, osmo_cell_global_id, ... by adding an mnc_3_digits
flag.

Change ordering in gprs_ra_id because the canonical oder is {Mobile Country
Code, Mobile Network Code}, so have the mcc member first.

ABI compatibility cannot be maintained for struct gprs_ra_id, since it is a
direct member of structs bssgp_bvc_ctx and bssgp_paging_info, and even just
adding a flag to the end would cause ABI changes of those structs. Similarly,
osmo_plmn_id is a direct member of osmo_location_area_id, and so forth.

Add new API to set and read this additional flag to preserve leading zeros:
- osmo_plmn_to_bcd(), osmo_plmn_from_bcd() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm48_decode_lai2(), gsm48_generate_lai2() after
  gsm48_decode_lai(), gsm48_generate_lai().
- gsm0808_create_layer3_2() after gsm0808_create_layer3() and 
gsm0808_create_layer3_aoip().
- various osmo_*_name() functions in gsm23003.h (osmo_rai_name() still in
  gsm48.h close to struct gprs_ra_id definition). The amount and duplication of
  these may seem a bit overboard, but IMO they do make sense in this way.
  Though most code will soon see patches unifying the data structures used, in
  some cases (vty, ctrl) they are required singled out. Without these
  functions, the formatting ("%0*u", mnc_3_digits ?  3 : 2, mnc) would be
  duplicated all over our diverse repositories.

In various log output, include the leading MNC zeros.

Mark one TODO in card_fs_sim.c, I am not sure how to communicate a leading zero
to/from a SIM card FS. The focus here is on the core network / BSS.

To indicate ABI incompatibility, bump libosmogsm and libosmogb LIBVERSIONs;
adjust debian files accordingly.

Implementation choices:

- The default behavior upon zero-initialization will be the mnc_3_digits flag
  set to false, which yields exactly the previous behavior.

- I decided against packing the mnc with the mnc_3_digits field into a
  sub-struct because it would immediately break all builds of dependent
  projects: it would require immediate merging of numerous patches in other
  repositories, and it would make compiling older code against a newer
  libosmocore unneccessarily hard.

Change-Id: Id2240f7f518494c9df6c8bda52c0d5092f90f221
---
M debian/control
R debian/libosmogb6.install
R debian/libosmogsm9.install
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/gsm48.h
M src/gb/Makefile.am
M src/gb/gprs_bssgp.c
M src/gb/gprs_bssgp_vty.c
M src/gsm/Makefile.am
M src/gsm/gsm0808.c
M src/gsm/gsm23003.c
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
15 files changed, 277 insertions(+), 75 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/6659/7

diff --git a/debian/control b/debian/control
index 596c3f1..d911f32 100644
--- a/debian/control
+++ b/debian/control
@@ -28,8 +28,8 @@
 Depends: libosmocodec0 (= ${binary:Version}),
  libosmocoding0 (= ${binary:Version}),
  libosmocore9 (= ${binary:Version}),
- libosmogb5 (= ${binary:Version}),
- libosmogsm8 (= ${binary:Version}),
+ libosmogb6 (= ${binary:Version}),
+ libosmogsm9 (= ${binary:Version}),
  libosmovty4 (= ${binary:Version}),
  libosmoctrl1 (= ${binary:Version}),
  libosmosim0 (= ${binary:Version}),
@@ -146,7 +146,7 @@
  .
  This package contains the documentation for the libosmocore library.
 
-Package: libosmogb5
+Package: libosmogb6
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -167,7 +167,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogb5,
+ libosmogb6,
  libjs-jquery
 Description: Documentation for the Osmo GPRS Gb library
  This is part of the libosmocore "meta"-library. The libosmocore library
@@ -178,7 +178,7 @@
  .
  This package contains the documentation for the libosmogb library.
 
-Package: libosmogsm8
+Package: libosmogsm9
 Section: libs
 Architecture: any
 Multi-Arch: same
@@ -202,7 +202,7 @@
 Architecture: all
 Section: doc
 Depends: ${misc:Depends},
- libosmogsm8,
+ libosmogsm9,
  libjs-jquery
 Description: Documentation for the Osmo GSM utility library
  This is part of the libosmocore "meta"-library. The libosmocore library
diff --git a/debian/libosmogb5.install b/debian/libosmogb6.install
similarity index 100%
rename from debian/libosmogb5.install
rename to debian/libosmogb6.install
diff --git 

[PATCH] libosmocore[master]: gsm0408_test: test new gsm48_{decode, generate}_lai2() functions

2018-02-28 Thread Neels Hofmeyr
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6661

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

gsm0408_test: test new gsm48_{decode,generate}_lai2() functions

Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 50 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/61/6661/7

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 9e552ab..479b371 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -187,6 +187,39 @@
printf("  FAIL\n");
 }
 
+static inline void dump_lai(const struct osmo_location_area_id *lai)
+{
+   printf("%s%s\n", osmo_lai_name(lai), lai->plmn.mnc_3_digits ? " 
(3-digit MNC)" : "");
+}
+
+static inline void check_lai2(const struct gprs_ra_id *raid)
+{
+   struct gsm48_loc_area_id lai = {};
+   struct osmo_location_area_id decoded = {};
+   struct osmo_location_area_id laid = {
+   .plmn = {
+   .mcc = raid->mcc,
+   .mnc = raid->mnc,
+   .mnc_3_digits = raid->mnc_3_digits,
+   },
+   .lac = raid->lac,
+   };
+
+   printf("- gsm48_generate_lai2() from "); dump_lai();
+
+   gsm48_generate_lai2(, );
+   printf("  Encoded %s\n", osmo_hexdump((unsigned char*), 
sizeof(lai)));
+   gsm48_decode_lai2(, );
+   printf("  gsm48_decode_lai2() gives  "); dump_lai();
+   if (decoded.plmn.mcc == laid.plmn.mcc
+   && decoded.plmn.mnc == laid.plmn.mnc
+   && decoded.lac == laid.lac
+   && decoded.plmn.mnc_3_digits == (laid.plmn.mnc_3_digits || 
laid.plmn.mnc > 99))
+   printf("  passed\n");
+   else
+   printf("  FAIL\n");
+}
+
 static struct gprs_ra_id test_ra_cap_items[] = {
{
.mcc = 77,
@@ -228,6 +261,7 @@
 
for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++) {
check_lai(_ra_cap_items[i]);
+   check_lai2(_ra_cap_items[i]);
}
 }
 
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index cc56763..a0e2c23 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -26,15 +26,31 @@
   Encoded 70 17 21 02 9a 
   gsm48_decode_lai() gives  077-121-666-0
   passed
+- gsm48_generate_lai2() from 077-121-666
+  Encoded 70 17 21 02 9a 
+  gsm48_decode_lai2() gives  077-121-666 (3-digit MNC)
+  passed
 - gsm48_generate_lai() from 084-98-11-0
   Encoded 80 f4 89 00 0b 
   gsm48_decode_lai() gives  084-98-11-0
+  passed
+- gsm48_generate_lai2() from 084-98-11
+  Encoded 80 f4 89 00 0b 
+  gsm48_decode_lai2() gives  084-98-11
   passed
 - gsm48_generate_lai() from 000-00-0-0
   Encoded 00 f0 00 00 00 
   gsm48_decode_lai() gives  000-00-0-0
   passed
+- gsm48_generate_lai2() from 000-00-0
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai2() gives  000-00-0
+  passed
 - gsm48_generate_lai() from 999-999-65535-0
   Encoded 99 99 99 ff ff 
   gsm48_decode_lai() gives  999-999-65535-0
   passed
+- gsm48_generate_lai2() from 999-999-65535
+  Encoded 99 99 99 ff ff 
+  gsm48_decode_lai2() gives  999-999-65535 (3-digit MNC)
+  passed

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-bts[master]: pcu_sock: Discard messages that are too short

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

Change subject: pcu_sock: Discard messages that are too short
..


pcu_sock: Discard messages that are too short

The downstream code of pcu_sock.c doesn't contain any length checks,
so let's discard any messages that are shorter than the primitive
length.

Change-Id: I35ac84d4db6d21ea61afbd1864c810bbf601d69b
---
M src/common/pcu_sock.c
1 file changed, 6 insertions(+), 0 deletions(-)

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



diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index fa13f24..b810174 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -749,6 +749,12 @@
goto close;
}
 
+   if (rc < sizeof(*pcu_prim)) {
+   LOGP(DPCU, LOGL_ERROR, "Received %d bytes on PCU Socket, but 
primitive size "
+   "is %lu, discarding\n", rc, sizeof(*pcu_prim));
+   return 0;
+   }
+
rc = pcu_rx(state->net, pcu_prim->msg_type, pcu_prim);
 
/* as we always synchronously process the message in pcu_rx() and

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I35ac84d4db6d21ea61afbd1864c810bbf601d69b
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 


osmo-bts[master]: pcu_sock: Log an error message and discard PCU primitives fo...

2018-02-28 Thread Stefan Sperling

Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/6997/2/src/common/pcu_sock.c
File src/common/pcu_sock.c:

Line 625:   LOGP(DPCU, LOGL_ERROR, "Received PCU Prim for 
non-existant BTS %u\n", pcu_prim->bts_nr);
spelling: 'non-existent'


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I158f935fed12941737c806c0677a8192ea3418a0
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: Yes


osmo-bts[master]: pcu_sock: Log an error message and discard PCU primitives fo...

2018-02-28 Thread Stefan Sperling

Patch Set 2: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I158f935fed12941737c806c0677a8192ea3418a0
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


osmo-bts[master]: pcu_sock: Don't overflow the timeslot array

2018-02-28 Thread Stefan Sperling

Patch Set 2: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie9964c8dc0ca7b049da7dfec0ac0a0d3f1aedd45
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


osmo-bts[master]: pcu_sock: Discard messages that are too short

2018-02-28 Thread Stefan Sperling

Patch Set 2: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I35ac84d4db6d21ea61afbd1864c810bbf601d69b
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


osmocom-bb[fixeria/trx]: fake_trx: handle SETTA (Timing Advance) indicated by MS

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie5833a9f221587bbcac10f0b223ead9c1cbda72b
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-bts[master]: pcu_sock: Don't overflow the timeslot array

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie9964c8dc0ca7b049da7dfec0ac0a0d3f1aedd45
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-bts[master]: pcu_sock: Log an error message and discard PCU primitives fo...

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I158f935fed12941737c806c0677a8192ea3418a0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: drop useless set_slot() method

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

Change subject: fake_trx/burst_fwd.py: drop useless set_slot() method
..


fake_trx/burst_fwd.py: drop useless set_slot() method

Change-Id: I721c87758f04a1962427341eb1b2d47cfdd3f780
---
M src/target/fake_trx/burst_fwd.py
1 file changed, 0 insertions(+), 6 deletions(-)

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



diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 663f499..db0b05b 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -57,12 +57,6 @@
self.toa_min = self.TOA_RAND_BASE - self.TOA_RAND_TRESHOLD
self.toa_max = self.TOA_RAND_BASE + self.TOA_RAND_TRESHOLD
 
-   def set_slot(self, ts):
-   if ts > 0 and ts < 8:
-   self.ts_pass = ts
-   else:
-   raise ValueError("Incorrect index for timeslot filter")
-
# Converts a L12TRX message to TRX2L1 message
def transform_msg(self, msg_raw):
# Attempt to parse a message

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I721c87758f04a1962427341eb1b2d47cfdd3f780
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: calculate both RSSI and ToA separately

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

Change subject: fake_trx/burst_fwd.py: calculate both RSSI and ToA separately
..


fake_trx/burst_fwd.py: calculate both RSSI and ToA separately

In order to be able to simulate and randomize both RSSI and ToA
values for Uplink and Downlink separately, let's calculate them
in separate methods of the BurstForwarder.

Change-Id: Ia2031f22f2b549c799c782d0c8c8d0691fb6f18c
---
M src/target/fake_trx/burst_fwd.py
1 file changed, 62 insertions(+), 30 deletions(-)

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



diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index bcf2257..503d035 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -39,42 +39,75 @@
# one GSM symbol advance.
ta = 0
 
-   # Constants
-   # TODO: add options to change this
-   RSSI_RAND_TRESHOLD = 10
-   RSSI_RAND_MIN = -90
-   RSSI_RAND_MAX = -60
+   # Timing of Arrival values indicated by transceiver
+   # in units of 1/256 of GSM symbol periods. A pair of
+   # base and threshold values defines a range of ToA value
+   # randomization: from (base - threshold) to (base + threshold).
+   toa256_dl_base = 0
+   toa256_ul_base = 0
 
-   # TODO: add options to change this
-   TOA256_RAND_TRESHOLD = 128
-   TOA256_RAND_BASE = 0
+   toa256_dl_threshold = 128
+   toa256_ul_threshold = 128
+
+   # RSSI values indicated by transceiver in dBm.
+   # A pair of base and threshold values defines a range of RSSI
+   # randomization: from (base - threshold) to (base + threshold).
+   rssi_dl_base = -60
+   rssi_ul_base = -70
+
+   rssi_dl_threshold = 10
+   rssi_ul_threshold = 5
 
def __init__(self, bts_link, bb_link):
self.bts_link = bts_link
self.bb_link = bb_link
 
-   # Generate a random RSSI range
-   rssi = random.randint(self.RSSI_RAND_MIN, self.RSSI_RAND_MAX)
-   self.rssi_min = rssi - self.RSSI_RAND_TRESHOLD
-   self.rssi_max = rssi + self.RSSI_RAND_TRESHOLD
+   # Calculates a random ToA value for Downlink bursts
+   def calc_dl_toa256(self):
+   # Calculate a range for randomization
+   toa256_min = self.toa256_dl_base - self.toa256_dl_threshold
+   toa256_max = self.toa256_dl_base + self.toa256_dl_threshold
 
-   # Generate a random ToA range
-   self.toa256_min = self.TOA256_RAND_BASE - 
self.TOA256_RAND_TRESHOLD
-   self.toa256_max = self.TOA256_RAND_BASE + 
self.TOA256_RAND_TRESHOLD
-
-   # Calculates ToA value for Uplink bursts (coming to a BTS)
-   def calc_toa_ul(self):
# Generate a random ToA value
-   toa256 = random.randint(self.toa256_min, self.toa256_max)
+   toa256 = random.randint(toa256_min, toa256_max)
 
-   # Apply TA value
+   return toa256
+
+   # Calculates a random ToA value for Uplink bursts
+   def calc_ul_toa256(self):
+   # Calculate a range for randomization
+   toa256_min = self.toa256_ul_base - self.toa256_ul_threshold
+   toa256_max = self.toa256_ul_base + self.toa256_ul_threshold
+
+   # Generate a random ToA value
+   toa256 = random.randint(toa256_min, toa256_max)
+
+   # Apply TA value indicated by MS
ta256 = self.ta * 256
toa256 -= ta256
 
return toa256
 
+   # Calculates a random RSSI value for Downlink bursts
+   def calc_dl_rssi(self):
+   # Calculate a range for randomization
+   rssi_min = self.rssi_dl_base - self.rssi_dl_threshold
+   rssi_max = self.rssi_dl_base + self.rssi_dl_threshold
+
+   # Generate a random RSSI value
+   return random.randint(rssi_min, rssi_max)
+
+   # Calculates a random RSSI value for Uplink bursts
+   def calc_ul_rssi(self):
+   # Calculate a range for randomization
+   rssi_min = self.rssi_ul_base - self.rssi_ul_threshold
+   rssi_max = self.rssi_ul_base + self.rssi_ul_threshold
+
+   # Generate a random RSSI value
+   return random.randint(rssi_min, rssi_max)
+
# Converts a L12TRX message to TRX2L1 message
-   def transform_msg(self, msg_raw):
+   def transform_msg(self, msg_raw, dl = True):
# Attempt to parse a message
try:
msg_l12trx = DATAMSG_L12TRX()
@@ -87,10 +120,12 @@
msg_trx2l1 = msg_l12trx.gen_trx2l1()
 
# Randomize both RSSI and ToA values
-   msg_trx2l1.rssi = msg_trx2l1.rand_rssi(
-   min = self.rssi_min, max 

osmo-bts[master]: pcu_sock: Discard messages that are too short

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I35ac84d4db6d21ea61afbd1864c810bbf601d69b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[fixeria/trx]: fake_trx: handle SETTA (Timing Advance) indicated by MS

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

Change subject: fake_trx: handle SETTA (Timing Advance) indicated by MS
..


fake_trx: handle SETTA (Timing Advance) indicated by MS

Timing Advance value is a timing correction value, indicated by
the network to MS, which is used to compensate UL signal delay.
In other words, the network instructs a phone to transmit bursts
N=TA symbol periods earlier than expected.

Since we are in virtual environment, let's use TA value to
calculate the ToA (Timing of Arrival) value for BTS.

Change-Id: Ie5833a9f221587bbcac10f0b223ead9c1cbda72b
---
M src/target/fake_trx/burst_fwd.py
M src/target/fake_trx/ctrl_if_bb.py
2 files changed, 33 insertions(+), 0 deletions(-)

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



diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 4a0e9bb..bcf2257 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -34,6 +34,11 @@
bts_freq = None
bb_freq = None
 
+   # Timing Advance value indicated by MS (0 by default)
+   # Valid range: 0..63, where each unit means
+   # one GSM symbol advance.
+   ta = 0
+
# Constants
# TODO: add options to change this
RSSI_RAND_TRESHOLD = 10
@@ -56,6 +61,17 @@
# Generate a random ToA range
self.toa256_min = self.TOA256_RAND_BASE - 
self.TOA256_RAND_TRESHOLD
self.toa256_max = self.TOA256_RAND_BASE + 
self.TOA256_RAND_TRESHOLD
+
+   # Calculates ToA value for Uplink bursts (coming to a BTS)
+   def calc_toa_ul(self):
+   # Generate a random ToA value
+   toa256 = random.randint(self.toa256_min, self.toa256_max)
+
+   # Apply TA value
+   ta256 = self.ta * 256
+   toa256 -= ta256
+
+   return toa256
 
# Converts a L12TRX message to TRX2L1 message
def transform_msg(self, msg_raw):
@@ -128,6 +144,9 @@
if msg is None:
return None
 
+   # Emulate ToA value for BTS
+   msg.toa256 = self.calc_toa_ul()
+
# Validate and generate the payload
payload = msg.gen_msg()
 
diff --git a/src/target/fake_trx/ctrl_if_bb.py 
b/src/target/fake_trx/ctrl_if_bb.py
index 47c7048..74fb242 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -115,6 +115,20 @@
 
return 0
 
+   # Timing Advance
+   elif self.verify_cmd(request, "SETTA", 1):
+   print("[i] Recv SETTA cmd")
+
+   # Parse and check TA value
+   ta = int(request[1])
+   if ta < 0 or ta > 63:
+   print("[!] TA value should be in range: 0..63")
+   return -1
+
+   # Save to the BurstForwarder instance
+   self.burst_fwd.ta = ta
+   return 0
+
# Wrong / unknown command
else:
# We don't care about other commands,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie5833a9f221587bbcac10f0b223ead9c1cbda72b
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmocom-bb[fixeria/trx]: fake_trx/data_msg.py: use integer math for ToA

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

Change subject: fake_trx/data_msg.py: use integer math for ToA
..


fake_trx/data_msg.py: use integer math for ToA

In order to avoid both float arithmetic as well as loosing any
precision, let's use integer math fot ToA (Timing of Arrival),
i.e. let's express ToA values in units of 1/256 symbol periods.

Change-Id: I56b88740f4d782ac7591fc096d1969514784a4e1
---
M src/target/fake_trx/burst_fwd.py
M src/target/fake_trx/burst_gen.py
M src/target/fake_trx/burst_send.py
M src/target/fake_trx/data_dump.py
M src/target/fake_trx/data_msg.py
5 files changed, 47 insertions(+), 45 deletions(-)

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



diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index db0b05b..4a0e9bb 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -41,8 +41,8 @@
RSSI_RAND_MAX = -60
 
# TODO: add options to change this
-   TOA_RAND_TRESHOLD = 0.3
-   TOA_RAND_BASE = 0.00
+   TOA256_RAND_TRESHOLD = 128
+   TOA256_RAND_BASE = 0
 
def __init__(self, bts_link, bb_link):
self.bts_link = bts_link
@@ -54,8 +54,8 @@
self.rssi_max = rssi + self.RSSI_RAND_TRESHOLD
 
# Generate a random ToA range
-   self.toa_min = self.TOA_RAND_BASE - self.TOA_RAND_TRESHOLD
-   self.toa_max = self.TOA_RAND_BASE + self.TOA_RAND_TRESHOLD
+   self.toa256_min = self.TOA256_RAND_BASE - 
self.TOA256_RAND_TRESHOLD
+   self.toa256_max = self.TOA256_RAND_BASE + 
self.TOA256_RAND_TRESHOLD
 
# Converts a L12TRX message to TRX2L1 message
def transform_msg(self, msg_raw):
@@ -73,8 +73,8 @@
# Randomize both RSSI and ToA values
msg_trx2l1.rssi = msg_trx2l1.rand_rssi(
min = self.rssi_min, max = self.rssi_max)
-   msg_trx2l1.toa = msg_trx2l1.rand_toa(
-   min = self.toa_min, max = self.toa_max)
+   msg_trx2l1.toa256 = msg_trx2l1.rand_toa256(
+   min = self.toa256_min, max = self.toa256_max)
 
return msg_trx2l1
 
diff --git a/src/target/fake_trx/burst_gen.py b/src/target/fake_trx/burst_gen.py
index c2e1ad2..179dbcd 100755
--- a/src/target/fake_trx/burst_gen.py
+++ b/src/target/fake_trx/burst_gen.py
@@ -54,8 +54,8 @@
tn = None
 
# Message specific header fields
+   toa256 = None
rssi = None
-   toa = None
pwr = None
 
def __init__(self):
@@ -108,8 +108,8 @@
msg.pwr = self.pwr
 
# Set time of arrival
-   if self.toa is not None:
-   msg.toa = self.toa
+   if self.toa256 is not None:
+   msg.toa256 = self.toa256
 
# Set RSSI
if self.rssi is not None:
@@ -164,7 +164,8 @@
 "  -t --timeslot   Set timeslot index (default 
random)\n"   \
 " --pwrSet power level (default 
random)\n"  \
 " --rssi   Set RSSI (default random)\n"
 \
-" --toaSet TOA (default random)\n\n"
+" --toaSet ToA in symbols (default 
random)\n"   \
+" --toa256 Set ToA in 1/256 symbol 
periods\n"
 
print(s % (self.remote_addr, self.base_port))
 
@@ -187,6 +188,7 @@
"timeslot=",
"rssi=",
"toa=",
+   "toa256=",
"pwr=",
])
except getopt.GetoptError as err:
@@ -221,8 +223,10 @@
self.pwr = int(v)
elif o == "--rssi":
self.rssi = int(v)
+   elif o == "--toa256":
+   self.toa256 = int(v)
elif o == "--toa":
-   self.toa = float(v)
+   self.toa256 = int(float(v) * 256.0 + 0.5)
 
def check_argv(self):
# Check connection mode
diff --git a/src/target/fake_trx/burst_send.py 
b/src/target/fake_trx/burst_send.py
index 61a526f..d6c5c0c 100755
--- a/src/target/fake_trx/burst_send.py
+++ b/src/target/fake_trx/burst_send.py
@@ -91,8 +91,8 @@
continue
 
# HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed 0.00 value for now...
-

[MERGED] osmocom-bb[fixeria/trx]: fake_trx/data_msg.py: implement ToA parsing support

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

Change subject: fake_trx/data_msg.py: implement ToA parsing support
..


fake_trx/data_msg.py: implement ToA parsing support

This change implements ToA (Timing of Arrival) parsing, which
was missing in the DATAMSG_TRX2L1. Since we use integer math,
a ToA value is represented in units of 1/256 symbol periods.

Change-Id: Ib11482c06b977c4cf01b0644f5845a2e49d059fb
---
M src/target/fake_trx/burst_send.py
M src/target/fake_trx/data_dump.py
M src/target/fake_trx/data_msg.py
3 files changed, 3 insertions(+), 31 deletions(-)

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



diff --git a/src/target/fake_trx/burst_send.py 
b/src/target/fake_trx/burst_send.py
index d6c5c0c..882fcd6 100755
--- a/src/target/fake_trx/burst_send.py
+++ b/src/target/fake_trx/burst_send.py
@@ -90,10 +90,6 @@
if not self.msg_pass_filter(l12trx, msg):
continue
 
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   msg.toa256 = 0
-
print("[i] Sending a burst %s to %s..."
% (msg.desc_hdr(), self.conn_mode))
 
diff --git a/src/target/fake_trx/data_dump.py b/src/target/fake_trx/data_dump.py
index 5e16da8..1d7805e 100644
--- a/src/target/fake_trx/data_dump.py
+++ b/src/target/fake_trx/data_dump.py
@@ -257,11 +257,6 @@
# Randomize the header
msg.rand_hdr()
 
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   if isinstance(msg, DATAMSG_TRX2L1):
-   msg.toa256 = 0
-
# Append
messages_ref.append(msg)
 
@@ -293,10 +288,6 @@
assert(messages_check[i].fn == messages_ref[i].fn)
assert(messages_check[i].tn == messages_ref[i].tn)
 
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   messages_check[i].toa256 = 0
-
# Validate a message
assert(messages_check[i].validate())
 
@@ -318,10 +309,6 @@
assert(messages_check[i].burst == messages_ref[i].burst)
assert(messages_check[i].fn == messages_ref[i].fn)
assert(messages_check[i].tn == messages_ref[i].tn)
-
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   messages_check[i].toa256 = 0
 
# Validate a message
assert(messages_check[i].validate())
@@ -345,11 +332,6 @@
assert(msg10.fn == messages_ref[10].fn)
assert(msg10.tn == messages_ref[10].tn)
 
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   msg0.toa256 = 0
-   msg10.toa256 = 0
-
# Validate both messages
assert(msg0.validate())
assert(msg10.validate())
@@ -371,10 +353,6 @@
assert(messages_check[i].burst == messages_ref[i + 10].burst)
assert(messages_check[i].fn == messages_ref[i + 10].fn)
assert(messages_check[i].tn == messages_ref[i + 10].tn)
-
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   messages_check[i].toa256 = 0
 
# Validate a message
assert(messages_check[i].validate())
diff --git a/src/target/fake_trx/data_msg.py b/src/target/fake_trx/data_msg.py
index 5dbebcf..5f93187 100644
--- a/src/target/fake_trx/data_msg.py
+++ b/src/target/fake_trx/data_msg.py
@@ -23,6 +23,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 import random
+import struct
 
 from gsm_shared import *
 
@@ -391,8 +392,7 @@
self.rssi = -(hdr[5])
 
# Parse ToA (Time of Arrival)
-   # FIXME: parsing unsupported
-   self.toa256 = None
+   self.toa256 = struct.unpack(">h", hdr[6:8])[0]
 
# Generates message specific burst
def gen_burst(self):
@@ -494,9 +494,7 @@
# Compare message specific parts
assert(msg_trx2l1_dec.rssi == msg_trx2l1_ref.rssi)
assert(msg_l12trx_dec.pwr == msg_l12trx_ref.pwr)
-
-   # FIXME: ToA check disabled until the parsing is implemented
-   # assert(msg_trx2l1_dec.toa256 == msg_trx2l1_ref.toa256)
+   assert(msg_trx2l1_dec.toa256 == msg_trx2l1_ref.toa256)
 
print("[?] Compare message specific data: OK")
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: 

[MERGED] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: disable field randomization by default

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

Change subject: fake_trx/burst_fwd.py: disable field randomization by default
..


fake_trx/burst_fwd.py: disable field randomization by default

Both RSSI and ToA fields randomization is only required in some
specific test / use cases, so let's disable it by default.

Change-Id: I94835a840b6239f2c05197292825cb26977d0216
---
M src/target/fake_trx/burst_fwd.py
1 file changed, 24 insertions(+), 0 deletions(-)

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

Objections:
  Vadim Yanitskiy: I would prefer this is not merged as is



diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 503d035..d059e13 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -34,6 +34,14 @@
bts_freq = None
bb_freq = None
 
+   # Randomization of RSSI
+   randomize_dl_rssi = False
+   randomize_ul_rssi = False
+
+   # Randomization of ToA
+   randomize_dl_toa256 = False
+   randomize_ul_toa256 = False
+
# Timing Advance value indicated by MS (0 by default)
# Valid range: 0..63, where each unit means
# one GSM symbol advance.
@@ -64,6 +72,10 @@
 
# Calculates a random ToA value for Downlink bursts
def calc_dl_toa256(self):
+   # Check if randomization is required
+   if not self.randomize_dl_toa256:
+   return self.toa256_dl_base
+
# Calculate a range for randomization
toa256_min = self.toa256_dl_base - self.toa256_dl_threshold
toa256_max = self.toa256_dl_base + self.toa256_dl_threshold
@@ -75,6 +87,10 @@
 
# Calculates a random ToA value for Uplink bursts
def calc_ul_toa256(self):
+   # Check if randomization is required
+   if not self.randomize_ul_toa256:
+   return self.toa256_ul_base
+
# Calculate a range for randomization
toa256_min = self.toa256_ul_base - self.toa256_ul_threshold
toa256_max = self.toa256_ul_base + self.toa256_ul_threshold
@@ -90,6 +106,10 @@
 
# Calculates a random RSSI value for Downlink bursts
def calc_dl_rssi(self):
+   # Check if randomization is required
+   if not self.randomize_dl_rssi:
+   return self.rssi_dl_base
+
# Calculate a range for randomization
rssi_min = self.rssi_dl_base - self.rssi_dl_threshold
rssi_max = self.rssi_dl_base + self.rssi_dl_threshold
@@ -99,6 +119,10 @@
 
# Calculates a random RSSI value for Uplink bursts
def calc_ul_rssi(self):
+   # Check if randomization is required
+   if not self.randomize_ul_rssi:
+   return self.rssi_ul_base
+
# Calculate a range for randomization
rssi_min = self.rssi_ul_base - self.rssi_ul_threshold
rssi_max = self.rssi_ul_base + self.rssi_ul_threshold

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I94835a840b6239f2c05197292825cb26977d0216
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


[MERGED] osmocom-bb[fixeria/trx]: fake_trx/fake_trx.py: add options to enable field randomization

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

Change subject: fake_trx/fake_trx.py: add options to enable field randomization
..


fake_trx/fake_trx.py: add options to enable field randomization

By default, both RSSI and ToA fields randomization is disabled.
Let's add command line options, which allow one to enable it.

Change-Id: Ieac63cc3aadef397906479a6179ba54a53a5311a
---
M src/target/fake_trx/fake_trx.py
1 file changed, 37 insertions(+), 4 deletions(-)

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



diff --git a/src/target/fake_trx/fake_trx.py b/src/target/fake_trx/fake_trx.py
index bdc4c61..c9e427c 100755
--- a/src/target/fake_trx/fake_trx.py
+++ b/src/target/fake_trx/fake_trx.py
@@ -49,6 +49,12 @@
bts_base_port = 5700
bb_base_port = 6700
 
+   # BurstForwarder field randomization
+   randomize_dl_toa256 = False
+   randomize_ul_toa256 = False
+   randomize_dl_rssi = False
+   randomize_ul_rssi = False
+
def __init__(self):
self.print_copyright()
self.parse_argv()
@@ -74,12 +80,18 @@
self.bts_ctrl.pm = self.pm
self.bb_ctrl.pm = self.pm
 
-   # BTS <-> BB burst forwarding
+   # Init DATA links
self.bts_data = UDPLink(self.bts_addr,
self.bts_base_port + 102, self.bts_base_port + 2)
self.bb_data = UDPLink(self.bb_addr,
self.bb_base_port + 102, self.bb_base_port + 2)
+
+   # BTS <-> BB burst forwarding
self.burst_fwd = BurstForwarder(self.bts_data, self.bb_data)
+   self.burst_fwd.randomize_dl_toa256 = self.randomize_dl_toa256
+   self.burst_fwd.randomize_ul_toa256 = self.randomize_ul_toa256
+   self.burst_fwd.randomize_dl_rssi = self.randomize_dl_rssi
+   self.burst_fwd.randomize_ul_rssi = self.randomize_ul_rssi
 
# Share a BurstForwarder instance between BTS and BB
self.bts_ctrl.burst_fwd = self.burst_fwd
@@ -137,7 +149,13 @@
 "  -R --bts-addr   Set BTS remote address (default 
%s)\n"   \
 "  -r --bb-addrSet BB remote address (default 
%s)\n"\
 "  -P --bts-base-port  Set BTS base port number 
(default %d)\n" \
-"  -p --bb-base-port   Set BB base port number 
(default %d)\n"
+"  -p --bb-base-port   Set BB base port number 
(default %d)\n\n"
+
+   s += " Simulation\n" \
+"  --rand-dl-rssi  Enable DL RSSI randomization\n" 
  \
+"  --rand-ul-rssi  Enable UL RSSI randomization\n" 
  \
+"  --rand-dl-toa   Enable DL ToA randomization\n"  
  \
+"  --rand-ul-toa   Enable UL ToA randomization\n"
 
print(s % (self.bts_addr, self.bb_addr,
self.bts_base_port, self.bb_base_port))
@@ -149,8 +167,13 @@
try:
opts, args = getopt.getopt(sys.argv[1:],
"R:r:P:p:h",
-   ["help", "bts-addr=", "bb-addr=",
-   "bts-base-port=", "bb-base-port="])
+   [
+   "help",
+   "bts-addr=", "bb-addr=",
+   "bts-base-port=", "bb-base-port=",
+   "rand-dl-rssi", "rand-ul-rssi",
+   "rand-dl-toa", "rand-ul-toa",
+   ])
except getopt.GetoptError as err:
self.print_help("[!] " + str(err))
sys.exit(2)
@@ -170,6 +193,16 @@
elif o in ("-p", "--bb-base-port"):
self.bb_base_port = int(v)
 
+   # Message field randomization
+   elif o == "rand-dl-rssi":
+   self.randomize_dl_rssi = True
+   elif o == "rand-ul-rssi":
+   self.randomize_ul_rssi = True
+   elif o == "rand-dl-toa":
+   self.randomize_dl_toa256 = True
+   elif o == "rand-ul-toa":
+   self.randomize_ul_toa256 = True
+
# Ensure there is no overlap between ports
if self.bts_base_port == self.bb_base_port:
self.print_help("[!] BTS and BB base ports should be 
different")

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

Gerrit-MessageType: merged

[MERGED] osmocom-bb[fixeria/trx]: fake_trx/ctrl_if_(bb|bts).py: add FAKE_TOA command

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

Change subject: fake_trx/ctrl_if_(bb|bts).py: add FAKE_TOA command
..


fake_trx/ctrl_if_(bb|bts).py: add FAKE_TOA command

FAKE_TOA is an auxilary CTRL command, which may be used to update
the ToA (Timing of Arrival) value of forwarded bursts at runtime.
This is useful for testing the measurement processing
code in OsmoBTS.

The command is implemented for both BTS and BB CTRL interfaces
in two absolute and relative forms:

  CMD FAKE_TOA  
  CMD FAKE_TOA <+-BASE_DELTA>

The first form overwrites both ToA value and its treshold.
The second one is relative, and applies a delta
to the current ToA value.

The command affects Downlink bursts if sent on BTS CTRL
interface, and Uplink bursts if sent on the BB CTRL.

Change-Id: Ia23becec4104d47e7b22350db67b8834d6f1ad1b
---
M src/target/fake_trx/ctrl_if_bb.py
M src/target/fake_trx/ctrl_if_bts.py
2 files changed, 46 insertions(+), 0 deletions(-)

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



diff --git a/src/target/fake_trx/ctrl_if_bb.py 
b/src/target/fake_trx/ctrl_if_bb.py
index 74fb242..c4d879c 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -129,6 +129,29 @@
self.burst_fwd.ta = ta
return 0
 
+   # Timing of Arrival simulation for Uplink
+   # Absolute form: CMD FAKE_TOA  
+   elif self.verify_cmd(request, "FAKE_TOA", 2):
+   print("[i] Recv FAKE_TOA cmd")
+
+   # Parse and apply both base and threshold
+   self.burst_fwd.toa256_ul_base = int(request[1])
+   self.burst_fwd.toa256_ul_threshold = int(request[2])
+
+   # TODO: avoid sending response
+   return -1
+
+   # Timing of Arrival simulation for Uplink
+   # Relative form: CMD FAKE_TOA <+-BASE_DELTA>
+   elif self.verify_cmd(request, "FAKE_TOA", 1):
+   print("[i] Recv FAKE_TOA cmd")
+
+   # Parse and apply delta
+   self.burst_fwd.toa256_ul_base += int(request[1])
+
+   # TODO: avoid sending response
+   return -1
+
# Wrong / unknown command
else:
# We don't care about other commands,
diff --git a/src/target/fake_trx/ctrl_if_bts.py 
b/src/target/fake_trx/ctrl_if_bts.py
index 92a4abb..f27b87d 100644
--- a/src/target/fake_trx/ctrl_if_bts.py
+++ b/src/target/fake_trx/ctrl_if_bts.py
@@ -97,6 +97,29 @@
self.burst_fwd.bts_freq = self.tx_freq
return 0
 
+   # Timing of Arrival simulation for Downlink
+   # Absolute form: CMD FAKE_TOA  
+   elif self.verify_cmd(request, "FAKE_TOA", 2):
+   print("[i] Recv FAKE_TOA cmd")
+
+   # Parse and apply both base and threshold
+   self.burst_fwd.toa256_dl_base = int(request[1])
+   self.burst_fwd.toa256_dl_threshold = int(request[2])
+
+   # TODO: avoid sending response
+   return -1
+
+   # Timing of Arrival simulation for Downlink
+   # Relative form: CMD FAKE_TOA <+-BASE_DELTA>
+   elif self.verify_cmd(request, "FAKE_TOA", 1):
+   print("[i] Recv FAKE_TOA cmd")
+
+   # Parse and apply delta
+   self.burst_fwd.toa256_dl_base += int(request[1])
+
+   # TODO: avoid sending response
+   return -1
+
# Wrong / unknown command
else:
# We don't care about other commands,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia23becec4104d47e7b22350db67b8834d6f1ad1b
Gerrit-PatchSet: 4
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


osmocom-bb[fixeria/trx]: fake_trx/ctrl_if_(bb|bts).py: add FAKE_TOA command

2018-02-28 Thread Harald Welte

Patch Set 4: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia23becec4104d47e7b22350db67b8834d6f1ad1b
Gerrit-PatchSet: 4
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: disable field randomization by default

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94835a840b6239f2c05197292825cb26977d0216
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmocom-bb[fixeria/trx]: fake_trx/fake_trx.py: add options to enable field randomization

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ieac63cc3aadef397906479a6179ba54a53a5311a
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: calculate both RSSI and ToA separately

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia2031f22f2b549c799c782d0c8c8d0691fb6f18c
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[fixeria/trx]: fake_trx/data_msg.py: implement ToA parsing support

2018-02-28 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib11482c06b977c4cf01b0644f5845a2e49d059fb
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[fixeria/trx]: fake_trx/data_msg.py: use integer math for ToA

2018-02-28 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I56b88740f4d782ac7591fc096d1969514784a4e1
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: drop useless set_slot() method

2018-02-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I721c87758f04a1962427341eb1b2d47cfdd3f780
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: disable field randomization by default

2018-02-28 Thread Vadim Yanitskiy

Patch Set 1: Code-Review-1

Introduced a bug here, fix is WIP...

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94835a840b6239f2c05197292825cb26977d0216
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: drop useless set_slot() method

2018-02-28 Thread Vadim Yanitskiy

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

fake_trx/burst_fwd.py: drop useless set_slot() method

Change-Id: I721c87758f04a1962427341eb1b2d47cfdd3f780
---
M src/target/fake_trx/burst_fwd.py
1 file changed, 0 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/98/6998/1

diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 663f499..db0b05b 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -57,12 +57,6 @@
self.toa_min = self.TOA_RAND_BASE - self.TOA_RAND_TRESHOLD
self.toa_max = self.TOA_RAND_BASE + self.TOA_RAND_TRESHOLD
 
-   def set_slot(self, ts):
-   if ts > 0 and ts < 8:
-   self.ts_pass = ts
-   else:
-   raise ValueError("Incorrect index for timeslot filter")
-
# Converts a L12TRX message to TRX2L1 message
def transform_msg(self, msg_raw):
# Attempt to parse a message

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I721c87758f04a1962427341eb1b2d47cfdd3f780
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] osmo-bsc[master]: Generate the S_L_INP_TEI_UP signal earlier.

2018-02-28 Thread Stefan Sperling
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6387

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

Generate the S_L_INP_TEI_UP signal earlier.

The S_L_INP_TEI_UP signal was generated when the first message from a BTS
arrives on the OML/RSL link, rather than when the OML/RSL link comes up.
Instead, generate this signal when the link is brought up, so we
intitialize state regardless of how a particular BTS behaves.

Tested with osmo-bts-virtual and virtphy/mobile programs,
and with a sysmobts.

Change-Id: I3b76ae6b00043e706dddc78209311e00ace85bb7
Related: OS#2719
---
M src/libbsc/bts_ipaccess_nanobts.c
1 file changed, 12 insertions(+), 13 deletions(-)


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

diff --git a/src/libbsc/bts_ipaccess_nanobts.c 
b/src/libbsc/bts_ipaccess_nanobts.c
index cf85961..99e178d 100644
--- a/src/libbsc/bts_ipaccess_nanobts.c
+++ b/src/libbsc/bts_ipaccess_nanobts.c
@@ -438,6 +438,11 @@
bts->oml_tei, 0);
rc = clock_gettime(CLOCK_MONOTONIC, );
bts->uptime = (rc < 0) ? 0 : tp.tv_sec; /* we don't need 
sub-second precision for uptime */
+   if (!(sign_link->trx->bts->ip_access.flags & OML_UP)) {
+   e1inp_event(sign_link->ts, S_L_INP_TEI_UP,
+   sign_link->tei, sign_link->sapi);
+   sign_link->trx->bts->ip_access.flags |= OML_UP;
+   }
break;
case E1INP_SIGN_RSL: {
struct e1inp_ts *ts;
@@ -458,6 +463,13 @@
e1inp_sign_link_create(ts, E1INP_SIGN_RSL,
   trx, trx->rsl_tei, 0);
trx->rsl_link->ts->sign.delay = 0;
+   if (!(sign_link->trx->bts->ip_access.flags &
+   (RSL_UP << sign_link->trx->nr))) {
+   e1inp_event(sign_link->ts, S_L_INP_TEI_UP,
+   sign_link->tei, sign_link->sapi);
+   sign_link->trx->bts->ip_access.flags |=
+   (RSL_UP << sign_link->trx->nr);
+   }
break;
}
default:
@@ -490,25 +502,12 @@
 {
int ret = 0;
struct e1inp_sign_link *link = msg->dst;
-   struct e1inp_ts *e1i_ts = link->ts;
 
switch (link->type) {
case E1INP_SIGN_RSL:
-   if (!(link->trx->bts->ip_access.flags &
-   (RSL_UP << link->trx->nr))) {
-   e1inp_event(e1i_ts, S_L_INP_TEI_UP,
-   link->tei, link->sapi);
-   link->trx->bts->ip_access.flags |=
-   (RSL_UP << link->trx->nr);
-   }
ret = abis_rsl_rcvmsg(msg);
break;
case E1INP_SIGN_OML:
-   if (!(link->trx->bts->ip_access.flags & OML_UP)) {
-   e1inp_event(e1i_ts, S_L_INP_TEI_UP,
-   link->tei, link->sapi);
-   link->trx->bts->ip_access.flags |= OML_UP;
-   }
ret = abis_nm_rcvmsg(msg);
break;
default:

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3b76ae6b00043e706dddc78209311e00ace85bb7
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 


[PATCH] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: disable field randomization by default

2018-02-28 Thread Vadim Yanitskiy

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

fake_trx/burst_fwd.py: disable field randomization by default

Both RSSI and ToA fields randomization is only required in some
specific test / use cases, so let's disable it by default.

Change-Id: I94835a840b6239f2c05197292825cb26977d0216
---
M src/target/fake_trx/burst_fwd.py
1 file changed, 24 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/01/7001/1

diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 503d035..d059e13 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -34,6 +34,14 @@
bts_freq = None
bb_freq = None
 
+   # Randomization of RSSI
+   randomize_dl_rssi = False
+   randomize_ul_rssi = False
+
+   # Randomization of ToA
+   randomize_dl_toa256 = False
+   randomize_ul_toa256 = False
+
# Timing Advance value indicated by MS (0 by default)
# Valid range: 0..63, where each unit means
# one GSM symbol advance.
@@ -64,6 +72,10 @@
 
# Calculates a random ToA value for Downlink bursts
def calc_dl_toa256(self):
+   # Check if randomization is required
+   if not self.randomize_dl_toa256:
+   return self.toa256_dl_base
+
# Calculate a range for randomization
toa256_min = self.toa256_dl_base - self.toa256_dl_threshold
toa256_max = self.toa256_dl_base + self.toa256_dl_threshold
@@ -75,6 +87,10 @@
 
# Calculates a random ToA value for Uplink bursts
def calc_ul_toa256(self):
+   # Check if randomization is required
+   if not self.randomize_ul_toa256:
+   return self.toa256_ul_base
+
# Calculate a range for randomization
toa256_min = self.toa256_ul_base - self.toa256_ul_threshold
toa256_max = self.toa256_ul_base + self.toa256_ul_threshold
@@ -90,6 +106,10 @@
 
# Calculates a random RSSI value for Downlink bursts
def calc_dl_rssi(self):
+   # Check if randomization is required
+   if not self.randomize_dl_rssi:
+   return self.rssi_dl_base
+
# Calculate a range for randomization
rssi_min = self.rssi_dl_base - self.rssi_dl_threshold
rssi_max = self.rssi_dl_base + self.rssi_dl_threshold
@@ -99,6 +119,10 @@
 
# Calculates a random RSSI value for Uplink bursts
def calc_ul_rssi(self):
+   # Check if randomization is required
+   if not self.randomize_ul_rssi:
+   return self.rssi_ul_base
+
# Calculate a range for randomization
rssi_min = self.rssi_ul_base - self.rssi_ul_threshold
rssi_max = self.rssi_ul_base + self.rssi_ul_threshold

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I94835a840b6239f2c05197292825cb26977d0216
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] osmocom-bb[fixeria/trx]: fake_trx: handle SETTA (Timing Advance) indicated by MS

2018-02-28 Thread Vadim Yanitskiy

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

fake_trx: handle SETTA (Timing Advance) indicated by MS

Timing Advance value is a timing correction value, indicated by
the network to MS, which is used to compensate UL signal delay.
In other words, the network instructs a phone to transmit bursts
N=TA symbol periods earlier than expected.

Since we are in virtual environment, let's use TA value to
calculate the ToA (Timing of Arrival) value for BTS.

Change-Id: Ie5833a9f221587bbcac10f0b223ead9c1cbda72b
---
M src/target/fake_trx/burst_fwd.py
M src/target/fake_trx/ctrl_if_bb.py
2 files changed, 33 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/99/6999/1

diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index 4a0e9bb..bcf2257 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -34,6 +34,11 @@
bts_freq = None
bb_freq = None
 
+   # Timing Advance value indicated by MS (0 by default)
+   # Valid range: 0..63, where each unit means
+   # one GSM symbol advance.
+   ta = 0
+
# Constants
# TODO: add options to change this
RSSI_RAND_TRESHOLD = 10
@@ -56,6 +61,17 @@
# Generate a random ToA range
self.toa256_min = self.TOA256_RAND_BASE - 
self.TOA256_RAND_TRESHOLD
self.toa256_max = self.TOA256_RAND_BASE + 
self.TOA256_RAND_TRESHOLD
+
+   # Calculates ToA value for Uplink bursts (coming to a BTS)
+   def calc_toa_ul(self):
+   # Generate a random ToA value
+   toa256 = random.randint(self.toa256_min, self.toa256_max)
+
+   # Apply TA value
+   ta256 = self.ta * 256
+   toa256 -= ta256
+
+   return toa256
 
# Converts a L12TRX message to TRX2L1 message
def transform_msg(self, msg_raw):
@@ -128,6 +144,9 @@
if msg is None:
return None
 
+   # Emulate ToA value for BTS
+   msg.toa256 = self.calc_toa_ul()
+
# Validate and generate the payload
payload = msg.gen_msg()
 
diff --git a/src/target/fake_trx/ctrl_if_bb.py 
b/src/target/fake_trx/ctrl_if_bb.py
index 47c7048..74fb242 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -115,6 +115,20 @@
 
return 0
 
+   # Timing Advance
+   elif self.verify_cmd(request, "SETTA", 1):
+   print("[i] Recv SETTA cmd")
+
+   # Parse and check TA value
+   ta = int(request[1])
+   if ta < 0 or ta > 63:
+   print("[!] TA value should be in range: 0..63")
+   return -1
+
+   # Save to the BurstForwarder instance
+   self.burst_fwd.ta = ta
+   return 0
+
# Wrong / unknown command
else:
# We don't care about other commands,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5833a9f221587bbcac10f0b223ead9c1cbda72b
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] osmocom-bb[fixeria/trx]: fake_trx/burst_fwd.py: calculate both RSSI and ToA separately

2018-02-28 Thread Vadim Yanitskiy

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

fake_trx/burst_fwd.py: calculate both RSSI and ToA separately

In order to be able to simulate and randomize both RSSI and ToA
values for Uplink and Downlink separately, let's calculate them
in separate methods of the BurstForwarder.

Change-Id: Ia2031f22f2b549c799c782d0c8c8d0691fb6f18c
---
M src/target/fake_trx/burst_fwd.py
1 file changed, 62 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/00/7000/1

diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index bcf2257..503d035 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -39,42 +39,75 @@
# one GSM symbol advance.
ta = 0
 
-   # Constants
-   # TODO: add options to change this
-   RSSI_RAND_TRESHOLD = 10
-   RSSI_RAND_MIN = -90
-   RSSI_RAND_MAX = -60
+   # Timing of Arrival values indicated by transceiver
+   # in units of 1/256 of GSM symbol periods. A pair of
+   # base and threshold values defines a range of ToA value
+   # randomization: from (base - threshold) to (base + threshold).
+   toa256_dl_base = 0
+   toa256_ul_base = 0
 
-   # TODO: add options to change this
-   TOA256_RAND_TRESHOLD = 128
-   TOA256_RAND_BASE = 0
+   toa256_dl_threshold = 128
+   toa256_ul_threshold = 128
+
+   # RSSI values indicated by transceiver in dBm.
+   # A pair of base and threshold values defines a range of RSSI
+   # randomization: from (base - threshold) to (base + threshold).
+   rssi_dl_base = -60
+   rssi_ul_base = -70
+
+   rssi_dl_threshold = 10
+   rssi_ul_threshold = 5
 
def __init__(self, bts_link, bb_link):
self.bts_link = bts_link
self.bb_link = bb_link
 
-   # Generate a random RSSI range
-   rssi = random.randint(self.RSSI_RAND_MIN, self.RSSI_RAND_MAX)
-   self.rssi_min = rssi - self.RSSI_RAND_TRESHOLD
-   self.rssi_max = rssi + self.RSSI_RAND_TRESHOLD
+   # Calculates a random ToA value for Downlink bursts
+   def calc_dl_toa256(self):
+   # Calculate a range for randomization
+   toa256_min = self.toa256_dl_base - self.toa256_dl_threshold
+   toa256_max = self.toa256_dl_base + self.toa256_dl_threshold
 
-   # Generate a random ToA range
-   self.toa256_min = self.TOA256_RAND_BASE - 
self.TOA256_RAND_TRESHOLD
-   self.toa256_max = self.TOA256_RAND_BASE + 
self.TOA256_RAND_TRESHOLD
-
-   # Calculates ToA value for Uplink bursts (coming to a BTS)
-   def calc_toa_ul(self):
# Generate a random ToA value
-   toa256 = random.randint(self.toa256_min, self.toa256_max)
+   toa256 = random.randint(toa256_min, toa256_max)
 
-   # Apply TA value
+   return toa256
+
+   # Calculates a random ToA value for Uplink bursts
+   def calc_ul_toa256(self):
+   # Calculate a range for randomization
+   toa256_min = self.toa256_ul_base - self.toa256_ul_threshold
+   toa256_max = self.toa256_ul_base + self.toa256_ul_threshold
+
+   # Generate a random ToA value
+   toa256 = random.randint(toa256_min, toa256_max)
+
+   # Apply TA value indicated by MS
ta256 = self.ta * 256
toa256 -= ta256
 
return toa256
 
+   # Calculates a random RSSI value for Downlink bursts
+   def calc_dl_rssi(self):
+   # Calculate a range for randomization
+   rssi_min = self.rssi_dl_base - self.rssi_dl_threshold
+   rssi_max = self.rssi_dl_base + self.rssi_dl_threshold
+
+   # Generate a random RSSI value
+   return random.randint(rssi_min, rssi_max)
+
+   # Calculates a random RSSI value for Uplink bursts
+   def calc_ul_rssi(self):
+   # Calculate a range for randomization
+   rssi_min = self.rssi_ul_base - self.rssi_ul_threshold
+   rssi_max = self.rssi_ul_base + self.rssi_ul_threshold
+
+   # Generate a random RSSI value
+   return random.randint(rssi_min, rssi_max)
+
# Converts a L12TRX message to TRX2L1 message
-   def transform_msg(self, msg_raw):
+   def transform_msg(self, msg_raw, dl = True):
# Attempt to parse a message
try:
msg_l12trx = DATAMSG_L12TRX()
@@ -87,10 +120,12 @@
msg_trx2l1 = msg_l12trx.gen_trx2l1()
 
# Randomize both RSSI and ToA values
-   msg_trx2l1.rssi = msg_trx2l1.rand_rssi(
-   min = self.rssi_min, max = self.rssi_max)
-   msg_trx2l1.toa256 = msg_trx2l1.rand_toa256(
-   min = self.toa256_min, max = self.toa256_max)
+   if dl:
+  

[PATCH] osmocom-bb[fixeria/trx]: fake_trx/fake_trx.py: add options to enable field randomization

2018-02-28 Thread Vadim Yanitskiy

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

fake_trx/fake_trx.py: add options to enable field randomization

By default, both RSSI and ToA fields randomization is disabled.
Let's add command line options, which allow one to enable it.

Change-Id: Ieac63cc3aadef397906479a6179ba54a53a5311a
---
M src/target/fake_trx/fake_trx.py
1 file changed, 37 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/02/7002/1

diff --git a/src/target/fake_trx/fake_trx.py b/src/target/fake_trx/fake_trx.py
index bdc4c61..c9e427c 100755
--- a/src/target/fake_trx/fake_trx.py
+++ b/src/target/fake_trx/fake_trx.py
@@ -49,6 +49,12 @@
bts_base_port = 5700
bb_base_port = 6700
 
+   # BurstForwarder field randomization
+   randomize_dl_toa256 = False
+   randomize_ul_toa256 = False
+   randomize_dl_rssi = False
+   randomize_ul_rssi = False
+
def __init__(self):
self.print_copyright()
self.parse_argv()
@@ -74,12 +80,18 @@
self.bts_ctrl.pm = self.pm
self.bb_ctrl.pm = self.pm
 
-   # BTS <-> BB burst forwarding
+   # Init DATA links
self.bts_data = UDPLink(self.bts_addr,
self.bts_base_port + 102, self.bts_base_port + 2)
self.bb_data = UDPLink(self.bb_addr,
self.bb_base_port + 102, self.bb_base_port + 2)
+
+   # BTS <-> BB burst forwarding
self.burst_fwd = BurstForwarder(self.bts_data, self.bb_data)
+   self.burst_fwd.randomize_dl_toa256 = self.randomize_dl_toa256
+   self.burst_fwd.randomize_ul_toa256 = self.randomize_ul_toa256
+   self.burst_fwd.randomize_dl_rssi = self.randomize_dl_rssi
+   self.burst_fwd.randomize_ul_rssi = self.randomize_ul_rssi
 
# Share a BurstForwarder instance between BTS and BB
self.bts_ctrl.burst_fwd = self.burst_fwd
@@ -137,7 +149,13 @@
 "  -R --bts-addr   Set BTS remote address (default 
%s)\n"   \
 "  -r --bb-addrSet BB remote address (default 
%s)\n"\
 "  -P --bts-base-port  Set BTS base port number 
(default %d)\n" \
-"  -p --bb-base-port   Set BB base port number 
(default %d)\n"
+"  -p --bb-base-port   Set BB base port number 
(default %d)\n\n"
+
+   s += " Simulation\n" \
+"  --rand-dl-rssi  Enable DL RSSI randomization\n" 
  \
+"  --rand-ul-rssi  Enable UL RSSI randomization\n" 
  \
+"  --rand-dl-toa   Enable DL ToA randomization\n"  
  \
+"  --rand-ul-toa   Enable UL ToA randomization\n"
 
print(s % (self.bts_addr, self.bb_addr,
self.bts_base_port, self.bb_base_port))
@@ -149,8 +167,13 @@
try:
opts, args = getopt.getopt(sys.argv[1:],
"R:r:P:p:h",
-   ["help", "bts-addr=", "bb-addr=",
-   "bts-base-port=", "bb-base-port="])
+   [
+   "help",
+   "bts-addr=", "bb-addr=",
+   "bts-base-port=", "bb-base-port=",
+   "rand-dl-rssi", "rand-ul-rssi",
+   "rand-dl-toa", "rand-ul-toa",
+   ])
except getopt.GetoptError as err:
self.print_help("[!] " + str(err))
sys.exit(2)
@@ -170,6 +193,16 @@
elif o in ("-p", "--bb-base-port"):
self.bb_base_port = int(v)
 
+   # Message field randomization
+   elif o == "rand-dl-rssi":
+   self.randomize_dl_rssi = True
+   elif o == "rand-ul-rssi":
+   self.randomize_ul_rssi = True
+   elif o == "rand-dl-toa":
+   self.randomize_dl_toa256 = True
+   elif o == "rand-ul-toa":
+   self.randomize_ul_toa256 = True
+
# Ensure there is no overlap between ports
if self.bts_base_port == self.bb_base_port:
self.print_help("[!] BTS and BB base ports should be 
different")

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieac63cc3aadef397906479a6179ba54a53a5311a
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 

[PATCH] osmocom-bb[fixeria/trx]: fake_trx/data_msg.py: implement ToA parsing support

2018-02-28 Thread Vadim Yanitskiy
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6991

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

fake_trx/data_msg.py: implement ToA parsing support

This change implements ToA (Timing of Arrival) parsing, which
was missing in the DATAMSG_TRX2L1. Since we use integer math,
a ToA value is represented in units of 1/256 symbol periods.

Change-Id: Ib11482c06b977c4cf01b0644f5845a2e49d059fb
---
M src/target/fake_trx/burst_send.py
M src/target/fake_trx/data_dump.py
M src/target/fake_trx/data_msg.py
3 files changed, 3 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/91/6991/2

diff --git a/src/target/fake_trx/burst_send.py 
b/src/target/fake_trx/burst_send.py
index d6c5c0c..882fcd6 100755
--- a/src/target/fake_trx/burst_send.py
+++ b/src/target/fake_trx/burst_send.py
@@ -90,10 +90,6 @@
if not self.msg_pass_filter(l12trx, msg):
continue
 
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   msg.toa256 = 0
-
print("[i] Sending a burst %s to %s..."
% (msg.desc_hdr(), self.conn_mode))
 
diff --git a/src/target/fake_trx/data_dump.py b/src/target/fake_trx/data_dump.py
index 5e16da8..1d7805e 100644
--- a/src/target/fake_trx/data_dump.py
+++ b/src/target/fake_trx/data_dump.py
@@ -257,11 +257,6 @@
# Randomize the header
msg.rand_hdr()
 
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   if isinstance(msg, DATAMSG_TRX2L1):
-   msg.toa256 = 0
-
# Append
messages_ref.append(msg)
 
@@ -293,10 +288,6 @@
assert(messages_check[i].fn == messages_ref[i].fn)
assert(messages_check[i].tn == messages_ref[i].tn)
 
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   messages_check[i].toa256 = 0
-
# Validate a message
assert(messages_check[i].validate())
 
@@ -318,10 +309,6 @@
assert(messages_check[i].burst == messages_ref[i].burst)
assert(messages_check[i].fn == messages_ref[i].fn)
assert(messages_check[i].tn == messages_ref[i].tn)
-
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   messages_check[i].toa256 = 0
 
# Validate a message
assert(messages_check[i].validate())
@@ -345,11 +332,6 @@
assert(msg10.fn == messages_ref[10].fn)
assert(msg10.tn == messages_ref[10].tn)
 
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   msg0.toa256 = 0
-   msg10.toa256 = 0
-
# Validate both messages
assert(msg0.validate())
assert(msg10.validate())
@@ -371,10 +353,6 @@
assert(messages_check[i].burst == messages_ref[i + 10].burst)
assert(messages_check[i].fn == messages_ref[i + 10].fn)
assert(messages_check[i].tn == messages_ref[i + 10].tn)
-
-   # HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed value for now...
-   messages_check[i].toa256 = 0
 
# Validate a message
assert(messages_check[i].validate())
diff --git a/src/target/fake_trx/data_msg.py b/src/target/fake_trx/data_msg.py
index 5dbebcf..5f93187 100644
--- a/src/target/fake_trx/data_msg.py
+++ b/src/target/fake_trx/data_msg.py
@@ -23,6 +23,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 import random
+import struct
 
 from gsm_shared import *
 
@@ -391,8 +392,7 @@
self.rssi = -(hdr[5])
 
# Parse ToA (Time of Arrival)
-   # FIXME: parsing unsupported
-   self.toa256 = None
+   self.toa256 = struct.unpack(">h", hdr[6:8])[0]
 
# Generates message specific burst
def gen_burst(self):
@@ -494,9 +494,7 @@
# Compare message specific parts
assert(msg_trx2l1_dec.rssi == msg_trx2l1_ref.rssi)
assert(msg_l12trx_dec.pwr == msg_l12trx_ref.pwr)
-
-   # FIXME: ToA check disabled until the parsing is implemented
-   # assert(msg_trx2l1_dec.toa256 == msg_trx2l1_ref.toa256)
+   assert(msg_trx2l1_dec.toa256 == msg_trx2l1_ref.toa256)
 
print("[?] Compare message specific data: OK")
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib11482c06b977c4cf01b0644f5845a2e49d059fb
Gerrit-PatchSet: 2
Gerrit-Project: 

[PATCH] osmocom-bb[fixeria/trx]: fake_trx/data_msg.py: use integer math for ToA

2018-02-28 Thread Vadim Yanitskiy
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6990

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

fake_trx/data_msg.py: use integer math for ToA

In order to avoid both float arithmetic as well as loosing any
precision, let's use integer math fot ToA (Timing of Arrival),
i.e. let's express ToA values in units of 1/256 symbol periods.

Change-Id: I56b88740f4d782ac7591fc096d1969514784a4e1
---
M src/target/fake_trx/burst_fwd.py
M src/target/fake_trx/burst_gen.py
M src/target/fake_trx/burst_send.py
M src/target/fake_trx/data_dump.py
M src/target/fake_trx/data_msg.py
5 files changed, 47 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/90/6990/2

diff --git a/src/target/fake_trx/burst_fwd.py b/src/target/fake_trx/burst_fwd.py
index db0b05b..4a0e9bb 100644
--- a/src/target/fake_trx/burst_fwd.py
+++ b/src/target/fake_trx/burst_fwd.py
@@ -41,8 +41,8 @@
RSSI_RAND_MAX = -60
 
# TODO: add options to change this
-   TOA_RAND_TRESHOLD = 0.3
-   TOA_RAND_BASE = 0.00
+   TOA256_RAND_TRESHOLD = 128
+   TOA256_RAND_BASE = 0
 
def __init__(self, bts_link, bb_link):
self.bts_link = bts_link
@@ -54,8 +54,8 @@
self.rssi_max = rssi + self.RSSI_RAND_TRESHOLD
 
# Generate a random ToA range
-   self.toa_min = self.TOA_RAND_BASE - self.TOA_RAND_TRESHOLD
-   self.toa_max = self.TOA_RAND_BASE + self.TOA_RAND_TRESHOLD
+   self.toa256_min = self.TOA256_RAND_BASE - 
self.TOA256_RAND_TRESHOLD
+   self.toa256_max = self.TOA256_RAND_BASE + 
self.TOA256_RAND_TRESHOLD
 
# Converts a L12TRX message to TRX2L1 message
def transform_msg(self, msg_raw):
@@ -73,8 +73,8 @@
# Randomize both RSSI and ToA values
msg_trx2l1.rssi = msg_trx2l1.rand_rssi(
min = self.rssi_min, max = self.rssi_max)
-   msg_trx2l1.toa = msg_trx2l1.rand_toa(
-   min = self.toa_min, max = self.toa_max)
+   msg_trx2l1.toa256 = msg_trx2l1.rand_toa256(
+   min = self.toa256_min, max = self.toa256_max)
 
return msg_trx2l1
 
diff --git a/src/target/fake_trx/burst_gen.py b/src/target/fake_trx/burst_gen.py
index c2e1ad2..179dbcd 100755
--- a/src/target/fake_trx/burst_gen.py
+++ b/src/target/fake_trx/burst_gen.py
@@ -54,8 +54,8 @@
tn = None
 
# Message specific header fields
+   toa256 = None
rssi = None
-   toa = None
pwr = None
 
def __init__(self):
@@ -108,8 +108,8 @@
msg.pwr = self.pwr
 
# Set time of arrival
-   if self.toa is not None:
-   msg.toa = self.toa
+   if self.toa256 is not None:
+   msg.toa256 = self.toa256
 
# Set RSSI
if self.rssi is not None:
@@ -164,7 +164,8 @@
 "  -t --timeslot   Set timeslot index (default 
random)\n"   \
 " --pwrSet power level (default 
random)\n"  \
 " --rssi   Set RSSI (default random)\n"
 \
-" --toaSet TOA (default random)\n\n"
+" --toaSet ToA in symbols (default 
random)\n"   \
+" --toa256 Set ToA in 1/256 symbol 
periods\n"
 
print(s % (self.remote_addr, self.base_port))
 
@@ -187,6 +188,7 @@
"timeslot=",
"rssi=",
"toa=",
+   "toa256=",
"pwr=",
])
except getopt.GetoptError as err:
@@ -221,8 +223,10 @@
self.pwr = int(v)
elif o == "--rssi":
self.rssi = int(v)
+   elif o == "--toa256":
+   self.toa256 = int(v)
elif o == "--toa":
-   self.toa = float(v)
+   self.toa256 = int(float(v) * 256.0 + 0.5)
 
def check_argv(self):
# Check connection mode
diff --git a/src/target/fake_trx/burst_send.py 
b/src/target/fake_trx/burst_send.py
index 61a526f..d6c5c0c 100755
--- a/src/target/fake_trx/burst_send.py
+++ b/src/target/fake_trx/burst_send.py
@@ -91,8 +91,8 @@
continue
 
# HACK: as ToA parsing is not implemented yet,
-   # we have to use a fixed 0.00 value for now...
-   msg.toa = 0.00
+ 

[PATCH] osmocom-bb[fixeria/trx]: fake_trx/ctrl_if_(bb|bts).py: add FAKE_TOA command

2018-02-28 Thread Vadim Yanitskiy
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6846

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

fake_trx/ctrl_if_(bb|bts).py: add FAKE_TOA command

FAKE_TOA is an auxilary CTRL command, which may be used to update
the ToA (Timing of Arrival) value of forwarded bursts at runtime.
This is useful for testing the measurement processing
code in OsmoBTS.

The command is implemented for both BTS and BB CTRL interfaces
in two absolute and relative forms:

  CMD FAKE_TOA  
  CMD FAKE_TOA <+-BASE_DELTA>

The first form overwrites both ToA value and its treshold.
The second one is relative, and applies a delta
to the current ToA value.

The command affects Downlink bursts if sent on BTS CTRL
interface, and Uplink bursts if sent on the BB CTRL.

Change-Id: Ia23becec4104d47e7b22350db67b8834d6f1ad1b
---
M src/target/fake_trx/ctrl_if_bb.py
M src/target/fake_trx/ctrl_if_bts.py
2 files changed, 46 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/46/6846/4

diff --git a/src/target/fake_trx/ctrl_if_bb.py 
b/src/target/fake_trx/ctrl_if_bb.py
index 74fb242..c4d879c 100644
--- a/src/target/fake_trx/ctrl_if_bb.py
+++ b/src/target/fake_trx/ctrl_if_bb.py
@@ -129,6 +129,29 @@
self.burst_fwd.ta = ta
return 0
 
+   # Timing of Arrival simulation for Uplink
+   # Absolute form: CMD FAKE_TOA  
+   elif self.verify_cmd(request, "FAKE_TOA", 2):
+   print("[i] Recv FAKE_TOA cmd")
+
+   # Parse and apply both base and threshold
+   self.burst_fwd.toa256_ul_base = int(request[1])
+   self.burst_fwd.toa256_ul_threshold = int(request[2])
+
+   # TODO: avoid sending response
+   return -1
+
+   # Timing of Arrival simulation for Uplink
+   # Relative form: CMD FAKE_TOA <+-BASE_DELTA>
+   elif self.verify_cmd(request, "FAKE_TOA", 1):
+   print("[i] Recv FAKE_TOA cmd")
+
+   # Parse and apply delta
+   self.burst_fwd.toa256_ul_base += int(request[1])
+
+   # TODO: avoid sending response
+   return -1
+
# Wrong / unknown command
else:
# We don't care about other commands,
diff --git a/src/target/fake_trx/ctrl_if_bts.py 
b/src/target/fake_trx/ctrl_if_bts.py
index 92a4abb..f27b87d 100644
--- a/src/target/fake_trx/ctrl_if_bts.py
+++ b/src/target/fake_trx/ctrl_if_bts.py
@@ -97,6 +97,29 @@
self.burst_fwd.bts_freq = self.tx_freq
return 0
 
+   # Timing of Arrival simulation for Downlink
+   # Absolute form: CMD FAKE_TOA  
+   elif self.verify_cmd(request, "FAKE_TOA", 2):
+   print("[i] Recv FAKE_TOA cmd")
+
+   # Parse and apply both base and threshold
+   self.burst_fwd.toa256_dl_base = int(request[1])
+   self.burst_fwd.toa256_dl_threshold = int(request[2])
+
+   # TODO: avoid sending response
+   return -1
+
+   # Timing of Arrival simulation for Downlink
+   # Relative form: CMD FAKE_TOA <+-BASE_DELTA>
+   elif self.verify_cmd(request, "FAKE_TOA", 1):
+   print("[i] Recv FAKE_TOA cmd")
+
+   # Parse and apply delta
+   self.burst_fwd.toa256_dl_base += int(request[1])
+
+   # TODO: avoid sending response
+   return -1
+
# Wrong / unknown command
else:
# We don't care about other commands,

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia23becec4104d47e7b22350db67b8834d6f1ad1b
Gerrit-PatchSet: 4
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


osmo-bsc[master]: Generate the S_L_INP_TEI_UP signal earlier.

2018-02-28 Thread Stefan Sperling

Patch Set 1:

> > pleaes test with real BTS setup, update commitlog and then we can
 > > merge it.
 > 
 > Yes, as noted in https://osmocom.org/issues/2719#note-7 I plan to
 > get to doing this soon.

I have tested the patch with a sysmobts now and it looks good to me. Please see 
the pcap files I have attached to the issue. Do they look alright?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I3b76ae6b00043e706dddc78209311e00ace85bb7
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: pcu_sock: Discard messages that are too short

2018-02-28 Thread Harald Welte

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

pcu_sock: Discard messages that are too short

The downstream code of pcu_sock.c doesn't contain any length checks,
so let's discard any messages that are shorter than the primitive
length.

Change-Id: I35ac84d4db6d21ea61afbd1864c810bbf601d69b
---
M src/common/pcu_sock.c
1 file changed, 6 insertions(+), 0 deletions(-)


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

diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index fa13f24..b810174 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -749,6 +749,12 @@
goto close;
}
 
+   if (rc < sizeof(*pcu_prim)) {
+   LOGP(DPCU, LOGL_ERROR, "Received %d bytes on PCU Socket, but 
primitive size "
+   "is %lu, discarding\n", rc, sizeof(*pcu_prim));
+   return 0;
+   }
+
rc = pcu_rx(state->net, pcu_prim->msg_type, pcu_prim);
 
/* as we always synchronously process the message in pcu_rx() and

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35ac84d4db6d21ea61afbd1864c810bbf601d69b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-bts[master]: pcu_sock: Don't overflow the timeslot array

2018-02-28 Thread Harald Welte

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

pcu_sock: Don't overflow the timeslot array

Don't blindly trust that the ts_nr received on the PCU socket will be
small enough to not overflow our timeslot array!

Change-Id: Ie9964c8dc0ca7b049da7dfec0ac0a0d3f1aedd45
---
M src/common/pcu_sock.c
1 file changed, 6 insertions(+), 0 deletions(-)


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

diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index b810174..c8308a9 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -521,6 +521,12 @@
rc = -EINVAL;
break;
}
+   if (data_req->ts_nr >= ARRAY_SIZE(trx->ts)) {
+   LOGP(DPCU, LOGL_ERROR, "Received PCU data request with "
+   "not existing TS %u\n", data_req->ts_nr);
+   rc = -EINVAL;
+   break;
+   }
ts = >ts[data_req->ts_nr];
is_ptcch = (data_req->sapi == PCU_IF_SAPI_PTCCH);
rc = l1sap_pdch_req(ts, is_ptcch, data_req->fn, data_req->arfcn,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie9964c8dc0ca7b049da7dfec0ac0a0d3f1aedd45
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-bts[master]: pcu_sock: Log an error message and discard PCU primitives fo...

2018-02-28 Thread Harald Welte

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

pcu_sock: Log an error message and discard PCU primitives for BTS != 0

In OsmoBTS, we (so far?) only have a single BTS inside each process,
let's make sure we log an error message if the PCU should ever want to
transmit primitives to a non-zero BTS number.

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


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

diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index c8308a9..0818388 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -621,6 +621,10 @@
struct gsm_bts *bts;
 
/* FIXME: allow multiple BTS */
+   if (pcu_prim->bts_nr != 0) {
+   LOGP(DPCU, LOGL_ERROR, "Received PCU Prim for non-existant BTS 
%u\n", pcu_prim->bts_nr);
+   return -EINVAL;
+   }
bts = llist_entry(net->bts_list.next, struct gsm_bts, list);
 
switch (msg_type) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I158f935fed12941737c806c0677a8192ea3418a0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


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

2018-02-28 Thread Stefan Sperling
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/6509

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

support for more cell ID list types in libosmocore

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

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

The old API using struct gsm0808_cell_id_list is deprecated.
The previous definition was insufficient because it assumed that all
decoded cell ID types could be represented with a single uint16_t.
It was declared in a GSM protocol header (gsm/protocol/gsm_08_08.h)
despite being a host-side representation of data in an IE.
The only user I am aware of is in osmo-msc, where this struct is used
for one local variable. osmo-msc releases >= 1.1.0 make use of this API.

Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb
Related: OS#2847
---
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm0808_utils.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/protocol/gsm_08_08.h
M src/gsm/gsm0808.c
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
8 files changed, 353 insertions(+), 31 deletions(-)


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

diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 3deee70..62ff06e 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -28,6 +28,8 @@
 struct sockaddr_storage;
 
 struct msgb;
+struct gsm0808_cell_id_list;
+struct gsm0808_cell_id_list2;
 
 struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc,
   uint16_t cc, int lac, uint16_t _ci);
@@ -66,6 +68,10 @@
 *scl);
 struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t 
*rr_cause);
 struct msgb *gsm0808_create_clear_rqst(uint8_t cause);
+struct msgb *gsm0808_create_paging2(const char *imsi, const uint32_t *tmsi,
+  const struct gsm0808_cell_id_list2 *cil,
+  const uint8_t *chan_needed);
+/* deprecated */
 struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
   const struct gsm0808_cell_id_list *cil,
   const uint8_t *chan_needed);
diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 7432164..f0b27bd 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -26,6 +26,27 @@
 struct sockaddr_storage;
 
 #include 
+#include 
+
+ /*! (225-1)/2 is the maximum number of elements in a cell identifier list. */
+#define GSM0808_CELL_ID_LIST2_MAXLEN   127
+
+/*! Parsed representation of a cell identifier list IE. */
+struct gsm0808_cell_id_list2 {
+   enum CELL_IDENT id_discr;
+   union {
+   /*!
+* All elements of these arrays contain parsed representations 
of the
+* data in the corresponding IE, in host-byte order.
+*/
+   struct osmo_cell_global_id  id_list_global;
+   struct osmo_lac_and_ci_id   id_list_lac_and_ci;
+   uint16_tid_list_ci;
+   struct osmo_location_area_idid_list_lai_and_lac;
+   uint16_tid_list_lac;
+   } id_list[GSM0808_CELL_ID_LIST2_MAXLEN];
+   unsigned int id_list_len;
+};
 
 uint8_t gsm0808_enc_aoip_trasp_addr(struct msgb *msg,
const struct sockaddr_storage *ss);
@@ -48,8 +69,12 @@
 const struct gsm0808_encrypt_info *ei);
 int gsm0808_dec_encrypt_info(struct gsm0808_encrypt_info *ei,
 const uint8_t *elem, uint8_t len);
+uint8_t gsm0808_enc_cell_id_list2(struct msgb *msg, const struct 
gsm0808_cell_id_list2 *cil);
+/* deprecated */
 uint8_t gsm0808_enc_cell_id_list(struct msgb *msg,
 const struct gsm0808_cell_id_list *cil);
+int gsm0808_dec_cell_id_list2(struct gsm0808_cell_id_list2 *cil, const uint8_t 
*elem, uint8_t len);
+/* deprecated */
 int gsm0808_dec_cell_id_list(struct gsm0808_cell_id_list *cil,
 const uint8_t *elem, uint8_t len);
 int gsm0808_chan_type_to_speech_codec(uint8_t perm_spch);
diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index dd41bc5..9623a05 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -29,6 +29,13 @@
uint16_t cell_identity;
 };
 
+/* Actually defined in 3GPP TS 48.008 3.2.2.27 Cell Identifier List,
+ * but conceptually belongs with the 

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

2018-02-28 Thread Stefan Sperling
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/6509

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

support for more cell ID list types in libosmocore

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

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

The old API using struct gsm0808_cell_id_list is deprecated.
The previous definition was insufficient because it assumed that all
decoded cell ID types could be represented with a single uint16_t.
It was declared in a GSM protocol header (gsm/protocol/gsm_08_08.h)
despite being a host-side representation of data in an IE.
The only user I am aware of is in osmo-msc, where this struct is used
for one local variable. osmo-msc releases >= 1.1.0 make use of this API.

Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb
Related: OS#2847
---
M include/osmocom/gsm/gsm0808.h
M include/osmocom/gsm/gsm0808_utils.h
M include/osmocom/gsm/gsm23003.h
M include/osmocom/gsm/protocol/gsm_08_08.h
M src/gsm/gsm0808.c
M src/gsm/gsm0808_utils.c
M src/gsm/libosmogsm.map
M tests/gsm0808/gsm0808_test.c
8 files changed, 353 insertions(+), 31 deletions(-)


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

diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 3deee70..62ff06e 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -28,6 +28,8 @@
 struct sockaddr_storage;
 
 struct msgb;
+struct gsm0808_cell_id_list;
+struct gsm0808_cell_id_list2;
 
 struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc,
   uint16_t cc, int lac, uint16_t _ci);
@@ -66,6 +68,10 @@
 *scl);
 struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t 
*rr_cause);
 struct msgb *gsm0808_create_clear_rqst(uint8_t cause);
+struct msgb *gsm0808_create_paging2(const char *imsi, const uint32_t *tmsi,
+  const struct gsm0808_cell_id_list2 *cil,
+  const uint8_t *chan_needed);
+/* deprecated */
 struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
   const struct gsm0808_cell_id_list *cil,
   const uint8_t *chan_needed);
diff --git a/include/osmocom/gsm/gsm0808_utils.h 
b/include/osmocom/gsm/gsm0808_utils.h
index 7432164..f0b27bd 100644
--- a/include/osmocom/gsm/gsm0808_utils.h
+++ b/include/osmocom/gsm/gsm0808_utils.h
@@ -26,6 +26,27 @@
 struct sockaddr_storage;
 
 #include 
+#include 
+
+ /*! (225-1)/2 is the maximum number of elements in a cell identifier list. */
+#define GSM0808_CELL_ID_LIST2_MAXLEN   127
+
+/*! Parsed representation of a cell identifier list IE. */
+struct gsm0808_cell_id_list2 {
+   enum CELL_IDENT id_discr;
+   union {
+   /*!
+* All elements of these arrays contain parsed representations 
of the
+* data in the corresponding IE, in host-byte order.
+*/
+   struct osmo_cell_global_id  id_list_global;
+   struct osmo_lac_and_ci_id   id_list_lac_and_ci;
+   uint16_tid_list_ci;
+   struct osmo_location_area_idid_list_lai_and_lac;
+   uint16_tid_list_lac;
+   } id_list[GSM0808_CELL_ID_LIST2_MAXLEN];
+   unsigned int id_list_len;
+};
 
 uint8_t gsm0808_enc_aoip_trasp_addr(struct msgb *msg,
const struct sockaddr_storage *ss);
@@ -48,8 +69,12 @@
 const struct gsm0808_encrypt_info *ei);
 int gsm0808_dec_encrypt_info(struct gsm0808_encrypt_info *ei,
 const uint8_t *elem, uint8_t len);
+uint8_t gsm0808_enc_cell_id_list2(struct msgb *msg, const struct 
gsm0808_cell_id_list2 *cil);
+/* deprecated */
 uint8_t gsm0808_enc_cell_id_list(struct msgb *msg,
 const struct gsm0808_cell_id_list *cil);
+int gsm0808_dec_cell_id_list2(struct gsm0808_cell_id_list2 *cil, const uint8_t 
*elem, uint8_t len);
+/* deprecated */
 int gsm0808_dec_cell_id_list(struct gsm0808_cell_id_list *cil,
 const uint8_t *elem, uint8_t len);
 int gsm0808_chan_type_to_speech_codec(uint8_t perm_spch);
diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index dd41bc5..9623a05 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -29,6 +29,13 @@
uint16_t cell_identity;
 };
 
+/* Actually defined in 3GPP TS 48.008 3.2.2.27 Cell Identifier List,
+ * but conceptually belongs with the 

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

2018-02-28 Thread Stefan Sperling

Patch Set 9:

(11 comments)

https://gerrit.osmocom.org/#/c/6509/9/include/osmocom/gsm/gsm0808_utils.h
File include/osmocom/gsm/gsm0808_utils.h:

Line 32: #define GSM0808_CELL_ID_LIST2_MAXLEN   128
> from (255-1)/2 the theoretical max is 127, would be nice to explain that in
Yes, comment improved in next patch set.


Line 47:} id_list;
> why not just {...}id_list[MAXLEN] once? the size will be the same and it's 
Unfortunately, your ARRAY_SIZE() idea complicates the parse_cell_id_* functions 
in gsm0808_utils.c. At present these won't get to see the entire id_list, 
instead they see a type-specific pointer to a union member like 
_list.id_list_global[0]. So we'd have to either typedef the union in order 
to pass the entire union array to each such function, or pass a size...

I think I prefer either leaving it the way things are now, or using id_list[] 
as an array but leaving CELL_ID_LIST2_MAXLEN in place so these functions can 
use it. See next patch set.


Line 73: /* deprecated */
> we have an OSMO_DEPRECATED() macro to mark with a compiler warning. The onl
I'll leave this as it is for now.


https://gerrit.osmocom.org/#/c/6509/9/include/osmocom/gsm/protocol/gsm_08_08.h
File include/osmocom/gsm/protocol/gsm_08_08.h:

Line 505:  * DEPRECATED: This definition of the cell identifier list is
> maybe rather move this down to the struct, I think doxygen will otherwise a
I'll move the #define above the comment.


https://gerrit.osmocom.org/#/c/6509/9/src/gsm/gsm0808.c
File src/gsm/gsm0808.c:

Line 553:  * Create BSSMAP PAGING message
> make sure to put full-stops at the end of sentences for doxygen parsing. Of
Sure. Fixed in next patch set.


Line 565:   /* Mandatory emelents! */
> rofl squared, seriously? :D
I have to admit I left this one there on purpose cause I liked the typo so much 
<3


Line 571:   memset(, 0, sizeof(cil2));
> since holger pointed me at it, I like to use constructs like
Sure, I don't mind either way. Tweaked in next patch set.


Line 573:   memcpy(cil2.id_list.id_list_lac, cil->id_list_lac, 
cil->id_list_len * sizeof(cil2.id_list.id_list_lac[0]));
> why not just copy the whole array, used or not. Otherwise you have to valid
The length check on line 568 above is not sufficient?


https://gerrit.osmocom.org/#/c/6509/9/src/gsm/gsm0808_utils.c
File src/gsm/gsm0808_utils.c:

Line 600:   msgb_put_u16(msg, id->cell_identity);
> the parsing function puts each single parsing section in its separate funct
The encoding case is much simpler then decoding. It doesn't need paranoid input 
verification and requires less local variables. So I think additional functions 
are not warranted.


Line 632:   OSMO_ASSERT(false);
> will an incoming message with an unsupported list type be able to crash the
If this function is asked to encode something we don't actually support, we 
should assert and fix the bug in upper layers. This function is dealing with 
output, not input.


https://gerrit.osmocom.org/#/c/6509/9/tests/gsm0808/gsm0808_test.c
File tests/gsm0808/gsm0808_test.c:

Line 817:   enc_cil.id_discr = CELL_IDENT_BSS;
> ha! this a bugfix?
Yes.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb
Gerrit-PatchSet: 9
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Stefan Sperling 
Gerrit-HasComments: Yes


[PATCH] osmo-bsc[master]: bsc_vty: Merge more VTY documentation string #defines

2018-02-28 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6594

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

bsc_vty: Merge more VTY documentation string #defines

Change-Id: I3fcbcd319813e3b220daf8170cadd4ebb2aefa0f
---
M src/libbsc/bsc_vty.c
1 file changed, 14 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/94/6594/6

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index ae1dd93..3dac29e 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -69,10 +69,18 @@
 #define BTS_NR_STR "BTS Number\n"
 #define TRX_NR_STR "TRX Number\n"
 #define TS_NR_STR "Timeslot Number\n"
+#define SS_NR_STR "Sub-slot Number\n"
 #define LCHAN_NR_STR "Logical Channel Number\n"
 #define BTS_TRX_STR BTS_NR_STR TRX_NR_STR
 #define BTS_TRX_TS_STR BTS_TRX_STR TS_NR_STR
 #define BTS_TRX_TS_LCHAN_STR BTS_TRX_TS_STR LCHAN_NR_STR
+#define BTS_NR_TRX_TS_STR2 \
+   "BTS for manual command\n" BTS_NR_STR \
+   "TRX for manual command\n" TRX_NR_STR \
+   "Timeslot for manual command\n" TS_NR_STR
+#define BTS_NR_TRX_TS_SS_STR2 \
+   BTS_NR_TRX_TS_STR2 \
+   "Sub-slot for manual command\n" SS_NR_STR
 
 /* FIXME: this should go to some common file */
 static const struct value_string gprs_ns_timer_strs[] = {
@@ -1568,8 +1576,7 @@
 DEFUN(handover_subscr_conn,
   handover_subscr_conn_cmd,
   "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> handover <0-255>",
-  "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-  "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+  BTS_NR_TRX_TS_SS_STR2
   MANUAL_HANDOVER_STR
   "New " BTS_NR_STR)
 {
@@ -1579,8 +1586,7 @@
 DEFUN(assignment_subscr_conn,
   assignment_subscr_conn_cmd,
   "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> assignment",
-  "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-  "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+  BTS_NR_TRX_TS_SS_STR2
   MANUAL_ASSIGNMENT_STR)
 {
return ho_or_as(vty, argv, argc);
@@ -4289,8 +4295,8 @@
 
 DEFUN(pdch_act, pdch_act_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Packet Data Channel\n"
+   BTS_NR_TRX_TS_STR2
+   "Packet Data Channel\n"
"Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
"Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
 {
@@ -4375,8 +4381,7 @@
  * performance testing (FER/RBER/...) */
 DEFUN(lchan_act, lchan_act_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> 
(activate|deactivate) (hr|fr|efr|amr) [<0-7>]",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+   BTS_NR_TRX_TS_SS_STR2
"Manual Channel Activation (e.g. for BER test)\n"
"Manual Channel Deactivation (e.g. for BER test)\n"
"Half-Rate v1\n" "Full-Rate\n" "Enhanced Full Rate\n" "Adaptive 
Multi-Rate\n" "AMR Mode\n")
@@ -4443,8 +4448,7 @@
 
 DEFUN(lchan_mdcx, lchan_mdcx_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> mdcx A.B.C.D 
<0-65535>",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Sub-Slot\n" LCHAN_NR_STR
+   BTS_NR_TRX_TS_SS_STR2
"Modify RTP Connection\n" "MGW IP Address\n" "MGW UDP Port\n")
 {
struct gsm_bts_trx_ts *ts;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3fcbcd319813e3b220daf8170cadd4ebb2aefa0f
Gerrit-PatchSet: 6
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: bsc_vty: Merge more VTY documentation string #defines

2018-02-28 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6594

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

bsc_vty: Merge more VTY documentation string #defines

Change-Id: I3fcbcd319813e3b220daf8170cadd4ebb2aefa0f
---
M src/libbsc/bsc_vty.c
1 file changed, 14 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/94/6594/5

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index ae1dd93..5b24b23 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -69,10 +69,18 @@
 #define BTS_NR_STR "BTS Number\n"
 #define TRX_NR_STR "TRX Number\n"
 #define TS_NR_STR "Timeslot Number\n"
+#define SS_NR_STR "Sub-slot Number\n"
 #define LCHAN_NR_STR "Logical Channel Number\n"
 #define BTS_TRX_STR BTS_NR_STR TRX_NR_STR
 #define BTS_TRX_TS_STR BTS_TRX_STR TS_NR_STR
 #define BTS_TRX_TS_LCHAN_STR BTS_TRX_TS_STR LCHAN_NR_STR
+#define BTS_NR_TRX_TS_STR2 \
+   "BTS for manual command\n" BTS_NR_STR \
+   "TRX for manual command\n" TRX_NR_STR \
+   "Timeslot for manual command\n" TS_NR_STR
+#define BTS_NR_TRX_TS_SS_STR2 \
+   BTS_NR_TRX_TS_STR2 \
+   "Sub-slot for manual command\n" SS_NR_STR
 
 /* FIXME: this should go to some common file */
 static const struct value_string gprs_ns_timer_strs[] = {
@@ -1568,8 +1576,7 @@
 DEFUN(handover_subscr_conn,
   handover_subscr_conn_cmd,
   "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> handover <0-255>",
-  "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-  "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+  BTS_NR_TRX_TS_SS_STR2
   MANUAL_HANDOVER_STR
   "New " BTS_NR_STR)
 {
@@ -1579,8 +1586,7 @@
 DEFUN(assignment_subscr_conn,
   assignment_subscr_conn_cmd,
   "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> assignment",
-  "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-  "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+  BTS_NR_TRX_TS_SS_STR2
   MANUAL_ASSIGNMENT_STR)
 {
return ho_or_as(vty, argv, argc);
@@ -4289,8 +4295,8 @@
 
 DEFUN(pdch_act, pdch_act_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Packet Data Channel\n"
+   BTS_NR_TRX_TS_STR2
+   "PDCH activation for manual command\n"
"Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
"Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
 {
@@ -4375,8 +4381,7 @@
  * performance testing (FER/RBER/...) */
 DEFUN(lchan_act, lchan_act_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> 
(activate|deactivate) (hr|fr|efr|amr) [<0-7>]",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+   BTS_NR_TRX_TS_SS_STR2
"Manual Channel Activation (e.g. for BER test)\n"
"Manual Channel Deactivation (e.g. for BER test)\n"
"Half-Rate v1\n" "Full-Rate\n" "Enhanced Full Rate\n" "Adaptive 
Multi-Rate\n" "AMR Mode\n")
@@ -4443,8 +4448,7 @@
 
 DEFUN(lchan_mdcx, lchan_mdcx_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> mdcx A.B.C.D 
<0-65535>",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Sub-Slot\n" LCHAN_NR_STR
+   BTS_NR_TRX_TS_SS_STR2
"Modify RTP Connection\n" "MGW IP Address\n" "MGW UDP Port\n")
 {
struct gsm_bts_trx_ts *ts;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3fcbcd319813e3b220daf8170cadd4ebb2aefa0f
Gerrit-PatchSet: 5
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: bsc_vty: Merge more VTY documentation string #defines

2018-02-28 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6594

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

bsc_vty: Merge more VTY documentation string #defines

Change-Id: I3fcbcd319813e3b220daf8170cadd4ebb2aefa0f
---
M src/libbsc/bsc_vty.c
1 file changed, 14 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/94/6594/4

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index ae1dd93..b3f933f 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -69,10 +69,18 @@
 #define BTS_NR_STR "BTS Number\n"
 #define TRX_NR_STR "TRX Number\n"
 #define TS_NR_STR "Timeslot Number\n"
+#define SS_NR_STR "Sub-slot Number\n"
 #define LCHAN_NR_STR "Logical Channel Number\n"
 #define BTS_TRX_STR BTS_NR_STR TRX_NR_STR
 #define BTS_TRX_TS_STR BTS_TRX_STR TS_NR_STR
 #define BTS_TRX_TS_LCHAN_STR BTS_TRX_TS_STR LCHAN_NR_STR
+#define BTS_NR_TRX_TS_STR2 \
+   "BTS for manual command\n" BTS_NR_STR \
+   "TRX for manual command\n" TRX_NR_STR \
+   "Timeslot for manual command\n" TS_NR_STR
+#define BTS_NR_TRX_TS_SS_STR2 \
+   BTS_NR_TRX_TS_STR2 \
+   "Sub-slot for manual command\n" SS_NR_STR
 
 /* FIXME: this should go to some common file */
 static const struct value_string gprs_ns_timer_strs[] = {
@@ -1568,8 +1576,7 @@
 DEFUN(handover_subscr_conn,
   handover_subscr_conn_cmd,
   "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> handover <0-255>",
-  "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-  "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+  BTS_NR_TRX_TS_SS_STR2
   MANUAL_HANDOVER_STR
   "New " BTS_NR_STR)
 {
@@ -1579,8 +1586,7 @@
 DEFUN(assignment_subscr_conn,
   assignment_subscr_conn_cmd,
   "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> assignment",
-  "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-  "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+  BTS_NR_TRX_TS_SS_STR2
   MANUAL_ASSIGNMENT_STR)
 {
return ho_or_as(vty, argv, argc);
@@ -4289,8 +4295,8 @@
 
 DEFUN(pdch_act, pdch_act_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Packet Data Channel\n"
+   BTS_NR_TRX_TS_STR2
+   "PDCH activation for manual command\n"  
"Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
"Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
 {
@@ -4375,8 +4381,7 @@
  * performance testing (FER/RBER/...) */
 DEFUN(lchan_act, lchan_act_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> 
(activate|deactivate) (hr|fr|efr|amr) [<0-7>]",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+   BTS_NR_TRX_TS_SS_STR2
"Manual Channel Activation (e.g. for BER test)\n"
"Manual Channel Deactivation (e.g. for BER test)\n"
"Half-Rate v1\n" "Full-Rate\n" "Enhanced Full Rate\n" "Adaptive 
Multi-Rate\n" "AMR Mode\n")
@@ -4443,8 +4448,7 @@
 
 DEFUN(lchan_mdcx, lchan_mdcx_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> mdcx A.B.C.D 
<0-65535>",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Sub-Slot\n" LCHAN_NR_STR
+   BTS_NR_TRX_TS_SS_STR2
"Modify RTP Connection\n" "MGW IP Address\n" "MGW UDP Port\n")
 {
struct gsm_bts_trx_ts *ts;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3fcbcd319813e3b220daf8170cadd4ebb2aefa0f
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bsc[master]: bsc_vty: Merge more VTY documentation string #defines

2018-02-28 Thread dexter
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/6594

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

bsc_vty: Merge more VTY documentation string #defines

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


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

diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index ae1dd93..734e063 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -69,10 +69,18 @@
 #define BTS_NR_STR "BTS Number\n"
 #define TRX_NR_STR "TRX Number\n"
 #define TS_NR_STR "Timeslot Number\n"
+#define SS_NR_STR "Sub-slot Number\n"
 #define LCHAN_NR_STR "Logical Channel Number\n"
 #define BTS_TRX_STR BTS_NR_STR TRX_NR_STR
 #define BTS_TRX_TS_STR BTS_TRX_STR TS_NR_STR
 #define BTS_TRX_TS_LCHAN_STR BTS_TRX_TS_STR LCHAN_NR_STR
+#define BTS_NR_TRX_TS_STR2 \
+   "BTS for manual command\n" BTS_NR_STR \
+   "TRX for manual command\n" TRX_NR_STR \
+   "Timeslot for manual command\n" TS_NR_STR
+#define BTS_NR_TRX_TS_SS_STR2 \
+   BTS_NR_TRX_TS_STR2 \
+   "Sub-slot for manual command\n" SS_NR_STR
 
 /* FIXME: this should go to some common file */
 static const struct value_string gprs_ns_timer_strs[] = {
@@ -1568,8 +1576,7 @@
 DEFUN(handover_subscr_conn,
   handover_subscr_conn_cmd,
   "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> handover <0-255>",
-  "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-  "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+  BTS_NR_TRX_TS_SS_STR2
   MANUAL_HANDOVER_STR
   "New " BTS_NR_STR)
 {
@@ -1579,8 +1586,7 @@
 DEFUN(assignment_subscr_conn,
   assignment_subscr_conn_cmd,
   "bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> assignment",
-  "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-  "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+  BTS_NR_TRX_TS_SS_STR2
   MANUAL_ASSIGNMENT_STR)
 {
return ho_or_as(vty, argv, argc);
@@ -4289,8 +4295,7 @@
 
 DEFUN(pdch_act, pdch_act_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> pdch (activate|deactivate)",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Packet Data Channel\n"
+   BTS_NR_TRX_TS_STR2
"Activate Dynamic PDCH/TCH (-> PDCH mode)\n"
"Deactivate Dynamic PDCH/TCH (-> TCH mode)\n")
 {
@@ -4375,8 +4380,7 @@
  * performance testing (FER/RBER/...) */
 DEFUN(lchan_act, lchan_act_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> 
(activate|deactivate) (hr|fr|efr|amr) [<0-7>]",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Sub-Slot Number\n" LCHAN_NR_STR
+   BTS_NR_TRX_TS_SS_STR2
"Manual Channel Activation (e.g. for BER test)\n"
"Manual Channel Deactivation (e.g. for BER test)\n"
"Half-Rate v1\n" "Full-Rate\n" "Enhanced Full Rate\n" "Adaptive 
Multi-Rate\n" "AMR Mode\n")
@@ -4443,8 +4447,7 @@
 
 DEFUN(lchan_mdcx, lchan_mdcx_cmd,
"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> mdcx A.B.C.D 
<0-65535>",
-   "BTS related commands\n" BTS_NR_STR "Transceiver\n" TRX_NR_STR
-   "TRX Timeslot\n" TS_NR_STR "Sub-Slot\n" LCHAN_NR_STR
+   BTS_NR_TRX_TS_SS_STR2
"Modify RTP Connection\n" "MGW IP Address\n" "MGW UDP Port\n")
 {
struct gsm_bts_trx_ts *ts;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3fcbcd319813e3b220daf8170cadd4ebb2aefa0f
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmocom-bb[fixeria/trx]: fake_trx/data_msg.py: use a single unified constructor

2018-02-28 Thread Vadim Yanitskiy
Vadim Yanitskiy has submitted this change and it was merged.

Change subject: fake_trx/data_msg.py: use a single unified constructor
..


fake_trx/data_msg.py: use a single unified constructor

There are no message specific initialization parts, excepting
the header specific fields setting. Let's us a common constructor,
dropping custom fields from its arguments.

Change-Id: I13a3e4b2f6a1f443ebe7d809df62736e3c43f56f
---
M src/target/fake_trx/data_msg.py
1 file changed, 5 insertions(+), 18 deletions(-)

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



diff --git a/src/target/fake_trx/data_msg.py b/src/target/fake_trx/data_msg.py
index 5ee8ed5..045e281 100644
--- a/src/target/fake_trx/data_msg.py
+++ b/src/target/fake_trx/data_msg.py
@@ -32,9 +32,11 @@
fn = None
tn = None
 
-   # HACK: Abstract class definition
-   def __init__(self):
-   raise NotImplementedError
+   # Common constructor
+   def __init__(self, fn = None, tn = None, burst = None):
+   self.burst = burst
+   self.fn = fn
+   self.tn = tn
 
# Generates message specific header
def gen_hdr(self):
@@ -213,13 +215,6 @@
# Specific message fields
pwr = None
 
-   def __init__(self, fn = None, tn = None, pwr = None, burst = None):
-   # Init local variables
-   self.burst = burst
-   self.pwr = pwr
-   self.fn = fn
-   self.tn = tn
-
# Validates the message fields
def validate(self):
# Validate common fields
@@ -314,14 +309,6 @@
# Specific message fields
rssi = None
toa = None
-
-   def __init__(self, fn = None, tn = None, rssi = None, toa = None, burst 
= None):
-   # Init local variables
-   self.burst = burst
-   self.rssi = rssi
-   self.toa = toa
-   self.fn = fn
-   self.tn = tn
 
# Validates the message fields
def validate(self):

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I13a3e4b2f6a1f443ebe7d809df62736e3c43f56f
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


  1   2   >