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

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


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

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


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

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


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

2018-02-21 Thread Harald Welte

Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/6616/2//COMMIT_MSG
Commit Message:

Line 9: No code is using it and we always lock to console anyways.
log?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I5fde99c6af5a845e635b5d27abab855682071f14
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: Yes


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

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


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

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


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

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic0231adbd2171214de133d26b3fbf36130ee8aa0
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-trx[master]: Logger: Remove unused includes

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

Change subject: Logger: Remove unused includes
..


Logger: Remove unused includes

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

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



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

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4d26c0b4f36ee3c66ed1a9e2e9fa2fa8272da16d
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-ttcn3-hacks[master]: RSL_Emulation: Introduce notion of 'bts_role'

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0d0460cbb633b470f6117d07643f68aefb1530eb
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-trx[master]: Logger: Drop syslog support

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

Change subject: Logger: Drop syslog support
..


Logger: Drop syslog support

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

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

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



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

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

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

Change subject: Logger: Drop support to log into file
..


Logger: Drop support to log into file

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

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

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



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

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If2c77c776823f595130edac963be953026049423
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


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

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ica9cfae5a691e4d967d046b04e5bb16a71a89adf
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-trx[master]: Logger: Remove unused logging macros

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

Change subject: Logger: Remove unused logging macros
..


Logger: Remove unused logging macros

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

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



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


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

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


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

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

Change subject: Logger: get rid of alarm APIs
..


Logger: get rid of alarm APIs

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

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

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



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

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

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

Change subject: Logger: Remove gLogToConsole flag
..


Logger: Remove gLogToConsole flag

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

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

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



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

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5fde99c6af5a845e635b5d27abab855682071f14
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-ttcn3-hacks[master]: IPA_Emulation: Don't log IPAC_MSGT_ID_RESP as "Unknown/unsup...

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I6ea3855a1f3d1cba6ac173b0f9cf9052d5d028fc
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-trx[master]: Logger: Drop unused gLogEarly

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

Change subject: Logger: Drop unused gLogEarly
..


Logger: Drop unused gLogEarly

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

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



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

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

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


osmo-ttcn3-hacks[master]: RSL_Emulation: Pass ASP_IPA_EVENT_UP to RSL_CCHAN port

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iad2f6e4cb6a8f3b77e452f36a83ec11e7554e6c7
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


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

2018-02-21 Thread Harald Welte

Patch Set 4:

(4 comments)

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

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


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

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


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

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

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


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

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

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


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
Gerrit-PatchSet: 4
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


osmo-pcu[master]: TBF: make network counters internal

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


[MERGED] osmo-pcu[master]: TBF: make network counters internal

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

Change subject: TBF: make network counters internal
..


TBF: make network counters internal

* store N310* counters in shared array similar to corresponding timers
* add functions to increment/reset counters

This avoids direct access to TBF counters from PDCH.

Change-Id: I89c7186f74bde7e6ac5f6e98f0b3e4c35274
Related: OS#1539
---
M src/pdch.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
5 files changed, 88 insertions(+), 35 deletions(-)

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



diff --git a/src/pdch.cpp b/src/pdch.cpp
index ee9df31..22a1605 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -290,7 +290,7 @@
}
 
/* Reset N3101 counter: */
-   tbf->m_n3101 = 0;
+   tbf->n_reset(N3101);
 
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
 
@@ -310,7 +310,7 @@
if (tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_WAIT_ACK)) {
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] DOWNLINK ASSIGNED\n");
/* reset N3105 */
-   tbf->n3105 = 0;
+   tbf->n_reset(N3105);
TBF_SET_ASS_STATE_DL(tbf, GPRS_RLCMAC_DL_ASS_NONE);
 
new_tbf = tbf->ms() ? tbf->ms()->dl_tbf() : NULL;
@@ -342,7 +342,7 @@
if (tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_WAIT_ACK)) {
LOGPTBF(tbf, LOGL_DEBUG, "[DOWNLINK] UPLINK ASSIGNED\n");
/* reset N3105 */
-   tbf->n3105 = 0;
+   tbf->n_reset(N3105);
TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_NONE);
 
new_tbf = tbf->ms() ? tbf->ms()->ul_tbf() : NULL;
@@ -399,7 +399,7 @@
}
 
/* Reset N3101 counter: */
-   tbf->m_n3101 = 0;
+   tbf->n_reset(N3101);
 
if (tbf->handle_ack_nack())
LOGPTBF(tbf, LOGL_NOTICE, "Recovered downlink ack\n");
@@ -466,7 +466,7 @@
}
 
/* Reset N3101 counter: */
-   tbf->m_n3101 = 0;
+   tbf->n_reset(N3101);
 
if (tbf->handle_ack_nack())
LOGPTBF(tbf, LOGL_NOTICE, "Recovered EGPRS downlink ack\n");
@@ -638,7 +638,7 @@
"RX: [PCU <- BTS] FIXME: Packet resource request\n");
 
/* Reset N3101 counter: */
-   dl_tbf->m_n3101 = 0;
+   dl_tbf->n_reset(N3101);
} else {
struct gprs_rlcmac_ul_tbf *ul_tbf;
int8_t tfi = request->ID.u.Global_TFI.u.UPLINK_TFI;
@@ -651,7 +651,7 @@
"RX: [PCU <- BTS] FIXME: Packet resource request\n");
 
/* Reset N3101 counter: */
-   ul_tbf->m_n3101 = 0;
+   ul_tbf->n_reset(N3101);
}
 }
 
@@ -806,7 +806,7 @@
}
 
/* Reset N3101 counter: */
-   tbf->m_n3101 = 0;
+   tbf->n_reset(N3101);
 
return tbf->rcv_data_block_acknowledged(_dec, data, meas);
 }
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 72b39ec..7036ea1 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -80,6 +80,13 @@
{ 0, NULL }
 };
 
+static const struct value_string tbf_counters_names[] = {
+   OSMO_VALUE_STRING(N3101),
+   OSMO_VALUE_STRING(N3103),
+   OSMO_VALUE_STRING(N3105),
+   { 0, NULL }
+};
+
 static const struct value_string tbf_timers_names[] = {
OSMO_VALUE_STRING(T0),
OSMO_VALUE_STRING(T3169),
@@ -187,13 +194,11 @@
control_ts(0xff),
poll_fn(0),
poll_ts(0),
-   n3105(0),
fT(0),
num_fT_exp(0),
was_releasing(0),
upgrade_to_multislot(0),
bts(bts_),
-   m_n3101(0),
m_tfi(0),
m_created_ts(0),
m_ctrs(NULL),
@@ -213,6 +218,7 @@
 * Just set them to 0 like talloc_zero did */
memset(, 0, sizeof(pdch));
memset(, 0, sizeof(T));
+   memset(, 0, sizeof(N));
memset(_rlc, 0, sizeof(m_rlc));
memset(_timer, 0, sizeof(gsm_timer));
 
@@ -546,6 +552,55 @@
"RELEASING",
 };
 
+void gprs_rlcmac_tbf::n_reset(enum tbf_counters n)
+{
+   if (n >= N_MAX) {
+   LOGPTBF(this, LOGL_ERROR, "attempting to reset unknown counter 
%s\n",
+   get_value_string(tbf_counters_names, n));
+   return;
+   }
+
+   N[n] = 0;
+}
+
+/* Increment counter and check for MAX value (return true if we hit it) */
+bool gprs_rlcmac_tbf::n_inc(enum tbf_counters n)
+{
+   uint8_t chk;
+
+   if (n >= N_MAX) {
+   LOGPTBF(this, LOGL_ERROR, "attempting to increment unknown 
counter %s\n",
+   get_value_string(tbf_counters_names, n));
+   return true;
+   }
+
+   N[n]++;
+
+   switch(n) {
+   case N3101:
+   chk = bts->bts_data()->n3101;
+   break;
+   case N3103:
+   chk = bts->bts_data()->n3103;
+   break;
+   case N3105:
+   

[PATCH] osmo-ttcn3-hacks[master]: GSM_RR_Types: Add ts_IMM_ASS and ts_MEAS_REP

2018-02-21 Thread Harald Welte

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

GSM_RR_Types: Add ts_IMM_ASS and ts_MEAS_REP

which allows us to send RR IMMEDIATE ASSIGNMENT (DL/AGCH) and
RR MEASUREMENT REPORT (UL/SACCH) messages from tests.

Change-Id: Ic75041e84c15c77805ecafb823bf7108920675ca
---
M library/GSM_RR_Types.ttcn
1 file changed, 92 insertions(+), 2 deletions(-)


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

diff --git a/library/GSM_RR_Types.ttcn b/library/GSM_RR_Types.ttcn
index eed58df..2625a1f 100644
--- a/library/GSM_RR_Types.ttcn
+++ b/library/GSM_RR_Types.ttcn
@@ -139,6 +139,12 @@
RrMessageType   message_type
} with { variant "" };
 
+   template RrL3Header t_RrL3Header(RrMessageType msg_type) := {
+   skip_indicator := 0,
+   rr_protocol_discriminator := 6,
+   message_type := msg_type
+   }
+
type record MaioHsn {
} with { variant "" };
 
@@ -486,6 +492,31 @@
variant (hh) "PRESENCE(presence = '11'B)"
};
 
+   type record MeasurementResults {
+   BIT1ba_used,
+   BIT1dtx_used,
+   uint6_t rxlev_full_srv_cell,
+   BIT1threeg_ba_used,
+   BIT1meas_valid,
+   uint6_t rxlev_sub_srv_cell,
+   BIT1si23_ba_used,
+   uint3_t rxqual_full_srv_cell,
+   uint3_t rxqual_sub_srv_cell,
+   uint3_t no_ncell_m,
+   NcellReportsncell_reports optional
+   } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
+variant (no_ncell_m) "UNIT(elements)"
+variant "PADDING(yes)"
+variant "FIELDLENGTH(16)"
+   };
+
+   type record NcellReport {
+   uint6_t rxlev,
+   uint5_t bcch_freq,
+   uint6_t bsic
+   } with { variant ""};
+   type record of NcellReport NcellReports;
+
 
/* 9.1.18 */
type record ImmediateAssignment {
@@ -497,7 +528,7 @@
TimingAdvance   timing_advance,
MobileAllocationmobile_allocation,
/* TODO: starting time TLV */
-   IaRestOctetsrest_octets
+   IaRestOctetsrest_octets optional
} with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
 
@@ -511,6 +542,11 @@
FeatureIndicatorfeature_ind,
PageModepage_mode,
ReqRefWaitInd4  payload
+   } with { variant "" };
+
+   /* 9.1.21 */
+   type record MeasurementReport {
+   MeasurementResults  meas_res
} with { variant "" };
 
/* 9.1.22 */
@@ -607,6 +643,7 @@
 
type union RrL3Union {
PagingResponse  paging_response,
+   MeasurementReport meas_rep,
octetstring other
};
 
@@ -615,8 +652,61 @@
RrL3Union   payload
} with { variant (payload) "CROSSTAG(
paging_response, header.message_type = 
PAGING_RESPONSE;
-
+   meas_rep, header.message_type = 
MEASUREMENT_REPORT;
other, OTHERWISE;
)" }
 
+   external function enc_GsmRrL3Message(in GsmRrL3Message msg) return 
octetstring
+   with { extension "prototype(convert) encode(RAW)" };
+   external function dec_GsmRrL3Message(in octetstring stream) return 
GsmRrL3Message
+   with { extension "prototype(convert) decode(RAW)" };
+
+
+   template GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, 
TimingAdvance ta,
+   ChannelDescription ch_desc, 
MobileAllocation ma) := {
+   header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
+   payload := {
+   imm_ass := {
+   ded_or_tbf := {
+   spare := '0'B,
+   tma := false,
+   downlink := false,
+   tbf := false
+   },
+   page_mode := PAGE_MODE_NORMAL,
+   chan_desc := ch_desc,
+   pkt_chan_desc := omit,
+   req_ref := f_compute_ReqRef(ra, fn),
+   timing_advance := ta,
+   mobile_allocation := ma,
+   rest_octets := omit
+   }
+   }
+   };
+
+   template 

[PATCH] osmo-ttcn3-hacks[master]: L1CTL: Add optional link_id argument to t_L1CTL_DATA_IND()

2018-02-21 Thread Harald Welte

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

L1CTL: Add optional link_id argument to t_L1CTL_DATA_IND()

Change-Id: Ib4cf42825da1034966086d9232273c2328a94947
---
M library/L1CTL_Types.ttcn
1 file changed, 4 insertions(+), 3 deletions(-)


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

diff --git a/library/L1CTL_Types.ttcn b/library/L1CTL_Types.ttcn
index 00323b4..d49f37d 100644
--- a/library/L1CTL_Types.ttcn
+++ b/library/L1CTL_Types.ttcn
@@ -501,12 +501,13 @@
payload := ?
};
 
-   /* for matching against incoming RACH_CONF */
-   template L1ctlDlMessage t_L1CTL_DATA_IND(template RslChannelNr chan_nr) 
:= {
+   /* for matching against incoming DATA_IND */
+   template L1ctlDlMessage t_L1CTL_DATA_IND(template RslChannelNr chan_nr,
+template RslLinkId link_id := 
?) := {
header := t_L1ctlHeader(L1CTL_DATA_IND),
dl_info := {
chan_nr := chan_nr,
-   link_id := ?,
+   link_id := link_id,
arfcn := ?,
frame_nr := ?,
rx_level := ?,

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

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


osmo-bts[master]: RSL: Ensure we don't accept DCHAN messages for CCHAN

2018-02-21 Thread Vadim Yanitskiy

Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/6635/1/src/common/rsl.c
File src/common/rsl.c:

Line 139: static bool chan_nr_is_dchan(uint8_t chan_nr)
Why not to use a macros here?

#define CHAN_NR_IS_DCHAN(chan) \
(chan & 0x80)


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I43a78bec63aeb36dd67043d237b27fe880209349
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


[MERGED] osmo-ttcn3-hacks[master]: RSL_Emulation: Pass ASP_IPA_EVENT_UP to RSL_CCHAN port

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

Change subject: RSL_Emulation: Pass ASP_IPA_EVENT_UP to RSL_CCHAN port
..


RSL_Emulation: Pass ASP_IPA_EVENT_UP to RSL_CCHAN port

When emulating the BSC side of RSL, this can be used by a test case
to wait for the RSL connection to be established.

Change-Id: Iad2f6e4cb6a8f3b77e452f36a83ec11e7554e6c7
---
M library/RSL_Emulation.ttcn
1 file changed, 6 insertions(+), 2 deletions(-)

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



diff --git a/library/RSL_Emulation.ttcn b/library/RSL_Emulation.ttcn
index 5c7dc9c..bf6686a 100644
--- a/library/RSL_Emulation.ttcn
+++ b/library/RSL_Emulation.ttcn
@@ -53,7 +53,7 @@
 } with { extension "internal" };
 
 type port RSL_CCHAN_PT message {
-   inout ASP_RSL_Unitdata;
+   inout ASP_RSL_Unitdata, ASP_IPA_Event;
 } with { extension "internal" };
 
 
@@ -277,6 +277,7 @@
 
 
 function main(boolean bts_role := true) runs on RSL_Emulation_CT {
+   var ASP_IPA_Event evt;
var ASP_RSL_Unitdata rx_rsl;
var RSL_Message rx_rsl_msg;
var RSLDC_ChanRqd chan_rqd;
@@ -292,7 +293,10 @@
 
while (true) {
alt {
-   [] IPA_PT.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}) {
+   [bts_role] IPA_PT.receive(ASP_IPA_Event:{up_down := 
ASP_IPA_EVENT_UP}) {
+   }
+   [not bts_role] IPA_PT.receive(ASP_IPA_Event:{up_down := 
ASP_IPA_EVENT_UP}) -> value evt {
+   CCHAN_PT.send(evt);
}
[bts_role] IPA_PT.receive(ASP_IPA_Event:{up_down := 
ASP_IPA_EVENT_ID_ACK}) {

IPA_PT.send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23)));

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

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


[MERGED] libosmocore[master]: gsm0408_test: also test gsm48_generate_lai() and gsm48_decod...

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

Change subject: gsm0408_test: also test gsm48_generate_lai() and 
gsm48_decode_lai()
..


gsm0408_test: also test gsm48_generate_lai() and gsm48_decode_lai()

Change-Id: Idd6cee090464bc92b654332904a9a08edf16e5c9
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 53 insertions(+), 0 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 ad45507..a0e740a 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -159,6 +159,33 @@
printf("passed\n");
 }
 
+static inline void check_lai(const struct gprs_ra_id *raid)
+{
+   int rc;
+   struct gsm48_loc_area_id lai = {};
+   struct gprs_ra_id decoded = {};
+   struct gprs_ra_id _laid = *raid;
+   struct gprs_ra_id *laid = &_laid;
+   laid->rac = 0;
+
+   printf("- gsm48_generate_lai() from "); dump_ra(laid);
+
+   gsm48_generate_lai(, laid->mcc, laid->mnc, laid->lac);
+   printf("  Encoded %s\n", osmo_hexdump((unsigned char*), 
sizeof(lai)));
+   rc = gsm48_decode_lai(, , , );
+   if (rc) {
+   printf("  gsm48_decode_lai() returned %d --> FAIL\n", rc);
+   return;
+   }
+   printf("  gsm48_decode_lai() gives  "); dump_ra();
+   if (decoded.mcc == laid->mcc
+   && decoded.mnc == laid->mnc
+   && decoded.lac == laid->lac)
+   printf("  passed\n");
+   else
+   printf("  FAIL\n");
+}
+
 static struct gprs_ra_id test_ra_cap_items[] = {
{
.mcc = 77,
@@ -192,6 +219,15 @@
 
for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++)
check_ra(_ra_cap_items[i]);
+}
+
+static void test_lai_encode_decode(void)
+{
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++) {
+   check_lai(_ra_cap_items[i]);
+   }
 }
 
 static void test_mid_from_tmsi(void)
@@ -229,6 +265,7 @@
test_mid_from_tmsi();
test_mid_from_imsi();
test_ra_cap();
+   test_lai_encode_decode();
 
return EXIT_SUCCESS;
 }
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index dc19eea..7612c12 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -22,3 +22,19 @@
 MCC+MNC in BCD: 99 99 99 
 999-999-65535-255
 RA test...passed
+- gsm48_generate_lai() from 077-121-666-0
+  Encoded 70 17 21 02 9a 
+  gsm48_decode_lai() gives  077-121-666-0
+  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_lai() from 000-00-0-0
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai() gives  000-00-0-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

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

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


[MERGED] libosmocore[master]: gsm0408_test: cosmetically re-order MCC to come before MNC

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

Change subject: gsm0408_test: cosmetically re-order MCC to come before MNC
..


gsm0408_test: cosmetically re-order MCC to come before MNC

For consistency in human readability, MCC simply should come first, always.

Change-Id: Idb86a7088fac4d8a8c41190ab46f9801635f4eee
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 7 insertions(+), 7 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 8e6cf2f..87f8dde 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("RA: MNC=%u, MCC=%u, LAC=%u, RAC=%u\n", raid->mnc, raid->mcc, 
raid->lac, raid->rac);
+   printf("RA: MCC=%u, MNC=%u, LAC=%u, RAC=%u\n", raid->mcc, raid->mnc, 
raid->lac, raid->rac);
 }
 
 static inline void check_ra(const struct gprs_ra_id *raid)
@@ -160,14 +160,14 @@
 
 static struct gprs_ra_id test_ra_cap_items[] = {
{
-   .mnc = 121,
.mcc = 77,
+   .mnc = 121,
.lac = 666,
.rac = 5,
},
{
-   .mnc = 98,
.mcc = 84,
+   .mnc = 98,
.lac = 11,
.rac = 89,
},
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 76a7940..295d8ec 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -3,10 +3,10 @@
 Simple TMSI encoding testpassed
 Simple IMSI encoding testpassed: [10] 17 08 99 10 07 00 00 00 64 02 
 Constructed RA:
-RA: MNC=121, MCC=77, LAC=666, RAC=5
-RA: MNC=121, MCC=77, LAC=666, RAC=5
+RA: MCC=77, MNC=121, LAC=666, RAC=5
+RA: MCC=77, MNC=121, LAC=666, RAC=5
 RA test...passed
 Constructed RA:
-RA: MNC=98, MCC=84, LAC=11, RAC=89
-RA: MNC=98, MCC=84, LAC=11, RAC=89
+RA: MCC=84, MNC=98, LAC=11, RAC=89
+RA: MCC=84, MNC=98, LAC=11, RAC=89
 RA test...passed

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

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


[MERGED] osmo-bts[master]: RSL: Properly reject RSL CHAN_NR IE for incompatible PCHAN

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

Change subject: RSL: Properly reject RSL CHAN_NR IE for incompatible PCHAN
..


RSL: Properly reject RSL CHAN_NR IE for incompatible PCHAN

If we receive a message for a dedicated channel, whose channel number
structure doesn't match with the physical channel (timeslot) type,
we must properly reject this.  For RSL CHAN ACT it means sending a NACK,
and for all other cases it means sending an RSL ERROR REPORT.

Related: OS#2972, OS#2971
Change-Id: Iebd2571726d1284a7431b3f9b23ad3185e832ed1
---
M src/common/rsl.c
1 file changed, 78 insertions(+), 34 deletions(-)

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



diff --git a/src/common/rsl.c b/src/common/rsl.c
index 2eb0db1..877f5d8 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1,7 +1,7 @@
 /* GSM TS 08.58 RSL, BTS Side */
 
 /* (C) 2011 by Andreas Eversberg 
- * (C) 2011-2014 by Harald Welte 
+ * (C) 2011-2017 by Harald Welte 
  *
  * All Rights Reserved
  *
@@ -135,18 +135,6 @@
  * support
  */
 
-/**
- * Handle GSM 08.58 7 Error Handling for the given input. This method will
- * send either a CHANNEL ACTIVATION NACK, MODE MODIFY NACK or ERROR REPORT
- * depending on the input of the method.
- *
- * TODO: actually make the decision
- */
-static int report_error(struct gsm_bts_trx *trx)
-{
-   return rsl_tx_error_report(trx, RSL_ERR_IE_CONTENT);
-}
-
 static struct gsm_lchan *lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
  const char *log_name)
 {
@@ -159,9 +147,11 @@
return NULL;
}
 
-   if (rc < 0)
+   if (rc < 0) {
LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n",
 gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr);
+   return NULL;
+   }
return lchan;
 }
 
@@ -643,14 +633,16 @@
 }
 
 /* 8.4.3 sending CHANnel ACTIVation Negative ACK */
-static int rsl_tx_chan_act_nack(struct gsm_lchan *lchan, uint8_t cause)
+static int _rsl_tx_chan_act_nack(struct gsm_bts_trx *trx, uint8_t chan_nr, 
uint8_t cause,
+struct gsm_lchan *lchan)
 {
struct msgb *msg;
-   uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
 
-   LOGP(DRSL, LOGL_NOTICE,
-   "%s Sending Channel Activated NACK: cause = 0x%02x\n",
-   gsm_lchan_name(lchan), cause);
+   if (lchan)
+   LOGP(DRSL, LOGL_NOTICE, "%s: ", gsm_lchan_name(lchan));
+   else
+   LOGP(DRSL, LOGL_NOTICE, "0x%02x: ", chan_nr);
+   LOGPC(DRSL, LOGL_NOTICE, "Sending Channel Activated NACK: cause = 
0x%02x\n", cause);
 
msg = rsl_msgb_alloc(sizeof(struct abis_rsl_dchan_hdr));
if (!msg)
@@ -659,9 +651,12 @@
/* 9.3.26 Cause */
msgb_tlv_put(msg, RSL_IE_CAUSE, 1, );
rsl_dch_push_hdr(msg, RSL_MT_CHAN_ACTIV_NACK, chan_nr);
-   msg->trx = lchan->ts->trx;
+   msg->trx = trx;
 
return abis_bts_rsl_sendmsg(msg);
+}
+static int rsl_tx_chan_act_nack(struct gsm_lchan *lchan, uint8_t cause) {
+   return _rsl_tx_chan_act_nack(lchan->ts->trx, gsm_lchan2chan_nr(lchan), 
cause, lchan);
 }
 
 /* Send an RSL Channel Activation Ack if cause is zero, a Nack otherwise. */
@@ -1229,13 +1224,16 @@
 }
 
 /* 8.4.11 MODE MODIFY NEGATIVE ACKNOWLEDGE */
-static int rsl_tx_mode_modif_nack(struct gsm_lchan *lchan, uint8_t cause)
+static int _rsl_tx_mode_modif_nack(struct gsm_bts_trx *trx, uint8_t chan_nr, 
uint8_t cause,
+ struct gsm_lchan *lchan)
 {
struct msgb *msg;
-   uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
 
-   LOGP(DRSL, LOGL_NOTICE, "%s Tx MODE MODIFY NACK (cause = 0x%02x)\n",
-gsm_lchan_name(lchan), cause);
+   if (lchan)
+   LOGP(DRSL, LOGL_NOTICE, "%s: ", gsm_lchan_name(lchan));
+   else
+   LOGP(DRSL, LOGL_NOTICE, "0x%02x: ", chan_nr);
+   LOGPC(DRSL, LOGL_NOTICE, "Tx MODE MODIFY NACK (cause = 0x%02x)\n", 
cause);
 
msg = rsl_msgb_alloc(sizeof(struct abis_rsl_dchan_hdr));
if (!msg)
@@ -1247,11 +1245,15 @@
/* 9.3.26 Cause */
msgb_tlv_put(msg, RSL_IE_CAUSE, 1, );
rsl_dch_push_hdr(msg, RSL_MT_MODE_MODIFY_NACK, chan_nr);
-   msg->lchan = lchan;
-   msg->trx = lchan->ts->trx;
+   msg->trx = trx;
 
return abis_bts_rsl_sendmsg(msg);
 }
+static int rsl_tx_mode_modif_nack(struct gsm_lchan *lchan, uint8_t cause)
+{
+   return _rsl_tx_mode_modif_nack(lchan->ts->trx, 
gsm_lchan2chan_nr(lchan), cause, lchan);
+}
+
 
 /* 8.4.10 MODE MODIFY ACK */
 static int rsl_tx_mode_modif_ack(struct gsm_lchan *lchan)
@@ -2190,6 +2192,52 @@
 pdch_act? "ACT" : "DEACT", rc);
 }
 
+/* handle a message with an RSL CHAN_NR that is incompatible/unknown */
+static int 

[MERGED] libosmocore[master]: gsm0408_test: include BCD and leading zeros in test output

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

Change subject: gsm0408_test: include BCD and leading zeros in test output
..


gsm0408_test: include BCD and leading zeros in test output

(Preparation for adding 3-digit MNC)

Change-Id: I7f8ae05fa3e4a6fc004212757b05ca8a14c9ef45
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 8 insertions(+), 5 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 87f8dde..aa6a8be 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("RA: MCC=%u, MNC=%u, LAC=%u, RAC=%u\n", raid->mcc, raid->mnc, 
raid->lac, raid->rac);
+   printf("%03u-%02u-%u-%u\n", raid->mcc, raid->mnc, raid->lac, raid->rac);
 }
 
 static inline void check_ra(const struct gprs_ra_id *raid)
@@ -150,6 +150,7 @@
 
gsm48_parse_ra(, (const uint8_t *));
dump_ra(raid);
+   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)
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 295d8ec..a3d801d 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -3,10 +3,12 @@
 Simple TMSI encoding testpassed
 Simple IMSI encoding testpassed: [10] 17 08 99 10 07 00 00 00 64 02 
 Constructed RA:
-RA: MCC=77, MNC=121, LAC=666, RAC=5
-RA: MCC=77, MNC=121, LAC=666, RAC=5
+077-121-666-5
+MCC+MNC in BCD: 70 17 21 
+077-121-666-5
 RA test...passed
 Constructed RA:
-RA: MCC=84, MNC=98, LAC=11, RAC=89
-RA: MCC=84, MNC=98, LAC=11, RAC=89
+084-98-11-89
+MCC+MNC in BCD: 80 f4 89 
+084-98-11-89
 RA test...passed

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

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


[MERGED] libosmocore[master]: gsm0408_test: RA test: include min/max value cases

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

Change subject: gsm0408_test: RA test: include min/max value cases
..


gsm0408_test: RA test: include min/max value cases

(Preparation for adding 3-digit MNC)

Change-Id: Ifbc167de0cc039858112677b8d0cd14a2c8af086
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 22 insertions(+), 0 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 aa6a8be..ad45507 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -172,6 +172,18 @@
.lac = 11,
.rac = 89,
},
+   {
+   .mcc = 0,
+   .mnc = 0,
+   .lac = 0,
+   .rac = 0,
+   },
+   {
+   .mcc = 999,
+   .mnc = 999,
+   .lac = 65535,
+   .rac = 255,
+   },
 };
 
 static void test_ra_cap(void)
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index a3d801d..dc19eea 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -12,3 +12,13 @@
 MCC+MNC in BCD: 80 f4 89 
 084-98-11-89
 RA test...passed
+Constructed RA:
+000-00-0-0
+MCC+MNC in BCD: 00 f0 00 
+000-00-0-0
+RA test...passed
+Constructed RA:
+999-999-65535-255
+MCC+MNC in BCD: 99 99 99 
+999-999-65535-255
+RA test...passed

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

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


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

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


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

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2

-- 
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: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] libosmocore[master]: cosmetic: gsm0408_test: RA test cases as array-of-struct

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

Change subject: cosmetic: gsm0408_test: RA test cases as array-of-struct
..


cosmetic: gsm0408_test: RA test cases as array-of-struct

(Preparation for adding 3-digit MNC)

Change-Id: Ic6c645ebf82d5f8d9d51c4c4cc804a0172008156
---
M tests/gsm0408/gsm0408_test.c
1 file changed, 12 insertions(+), 8 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 ab2dee4..8e6cf2f 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -158,23 +158,27 @@
printf("passed\n");
 }
 
-static void test_ra_cap(void)
-{
-   struct gprs_ra_id raid1 = {
+static struct gprs_ra_id test_ra_cap_items[] = {
+   {
.mnc = 121,
.mcc = 77,
.lac = 666,
.rac = 5,
-   };
-   struct gprs_ra_id raid2 = {
+   },
+   {
.mnc = 98,
.mcc = 84,
.lac = 11,
.rac = 89,
-   };
+   },
+};
 
-   check_ra();
-   check_ra();
+static void test_ra_cap(void)
+{
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++)
+   check_ra(_ra_cap_items[i]);
 }
 
 static void test_mid_from_tmsi(void)

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

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


osmo-sgsn[master]: sgsn_test: guard against struct gprs_ra_id changing

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


[MERGED] osmo-sgsn[master]: sgsn_test: guard against struct gprs_ra_id changing

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

Change subject: sgsn_test: guard against struct gprs_ra_id changing
..


sgsn_test: guard against struct gprs_ra_id changing

sgsn_test initializes various struct gprs_ra_id without naming the actual
members, which is vulnerable to struct member re-ordering. Name the members
explicitly.

An upcoming ABI change in libosmocore would cause test failures here without
this patch.

Change-Id: I517ed9edf77fac37d9de7a39df24c419a8a65d96
---
M tests/sgsn/sgsn_test.c
1 file changed, 3 insertions(+), 3 deletions(-)

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



diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c
index 4237349..2fbd6e4 100644
--- a/tests/sgsn/sgsn_test.c
+++ b/tests/sgsn/sgsn_test.c
@@ -1644,7 +1644,7 @@
  */
 static void test_gmm_ptmsi_allocation(void)
 {
-   struct gprs_ra_id raid = {332, 112, 16464, 96};
+   struct gprs_ra_id raid = { .mnc=332, .mcc=112, .lac=16464, .rac=96};
struct sgsn_mm_ctx *ctx = NULL;
struct sgsn_mm_ctx *ictx;
uint32_t foreign_tlli;
@@ -1847,8 +1847,8 @@
  */
 static void test_gmm_routing_areas(void)
 {
-   struct gprs_ra_id raid1 = {332, 112, 16464, 96};
-   struct gprs_ra_id raid2 = {332, 112, 16464, 97};
+   struct gprs_ra_id raid1 = { .mnc=332, .mcc=112, .lac=16464, .rac=96};
+   struct gprs_ra_id raid2 = { .mnc=332, .mcc=112, .lac=16464, .rac=97};
struct sgsn_mm_ctx *ctx = NULL;
struct sgsn_mm_ctx *ictx;
uint32_t ptmsi1;

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

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


osmo-iuh[master]: ensure unique CellIDs in HNB-GW

2018-02-21 Thread Harald Welte

Patch Set 1:

Back rto all of heels' comments

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iffd441eb2b6b75dfbe001b49b01bea015ca6e11c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[MERGED] osmo-mgw[master]: mgcp_client: cosmetic: clean up SDP params parsing

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

Change subject: mgcp_client: cosmetic: clean up SDP params parsing
..


mgcp_client: cosmetic: clean up SDP params parsing

The mgcp_response_parse_params() is in a jumble. Straighten out these cosmetic
issues:

- Move assertion of r->body close to its first use.
- Instead of a talloc_zero and osmo_strlcpy dance, simply use talloc_strdup().
- Drop the first unused invocation of mgcp_find_section_end().
- Drop unused assignment of data_ptr = data.
- In the log, mention "SDP" to clarify.
- Add a comment clarifying how we skip the section marker.

Change-Id: Icf1df761270777a142bc8ace75f2a10918314f73
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 7 insertions(+), 6 deletions(-)

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



diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index c340303..de940c0 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -251,26 +251,27 @@
 {
char *line;
int rc;
-   OSMO_ASSERT(r->body);
-   char *data = mgcp_find_section_end(r->body);
+   char *data;
char *data_ptr;
 
/* Since this functions performs a destructive parsing, we create a
 * local copy of the body data */
-   data = talloc_zero_size(r, strlen(r->body)+1);
+   OSMO_ASSERT(r->body);
+   data = talloc_strdup(r, r->body);
OSMO_ASSERT(data);
-   data_ptr = data;
-   osmo_strlcpy(data, r->body, strlen(r->body));
 
/* Find beginning of the parameter (SDP) section */
data_ptr = mgcp_find_section_end(data);
if (!data) {
LOGP(DLMGCP, LOGL_ERROR,
-"MGCP response: cannot find start of parameters\n");
+"MGCP response: cannot find start of SDP parameters\n");
rc = -EINVAL;
goto exit;
}
 
+   /* data_ptr now points to the beginning of the section-end-marker; 
for_each_non_empty_line()
+* skips any \r and \n characters for free, so we don't need to skip 
the marker. */
+
for_each_non_empty_line(line, data_ptr) {
if (!mgcp_line_is_valid(line))
return -EINVAL;

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

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


[MERGED] osmo-mgw[master]: mgcp_client: detect SDP section-start parsing errors

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

Change subject: mgcp_client: detect SDP section-start parsing errors
..


mgcp_client: detect SDP section-start parsing errors

After call to mgcp_find_section_end(), actually check the proper variable to
evaluate its return value.

Show in mgcp_client_test output that the parsing errors are fixed, and enable
the assertion that no tests should fail.

Change-Id: I62a2453cd9e2e7d5408423161fa65ec9c9989f98
---
M src/libosmo-mgcp-client/mgcp_client.c
M tests/mgcp_client/mgcp_client_test.c
M tests/mgcp_client/mgcp_client_test.err
3 files changed, 9 insertions(+), 15 deletions(-)

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



diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index de940c0..e054593 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -262,7 +262,7 @@
 
/* Find beginning of the parameter (SDP) section */
data_ptr = mgcp_find_section_end(data);
-   if (!data) {
+   if (!data_ptr) {
LOGP(DLMGCP, LOGL_ERROR,
 "MGCP response: cannot find start of SDP parameters\n");
rc = -EINVAL;
diff --git a/tests/mgcp_client/mgcp_client_test.c 
b/tests/mgcp_client/mgcp_client_test.c
index 588b313..50e21b5 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -371,9 +371,7 @@
talloc_free(r);
}
 
-   /* Expecting failures due to known bugs, will be resolved in a 
subsequent commit.
OSMO_ASSERT(!failures);
-   */
 }
 
 static const struct log_info_cat log_categories[] = {
diff --git a/tests/mgcp_client/mgcp_client_test.err 
b/tests/mgcp_client/mgcp_client_test.err
index 9079c27..7309242 100644
--- a/tests/mgcp_client/mgcp_client_test.err
+++ b/tests/mgcp_client/mgcp_client_test.err
@@ -15,9 +15,8 @@
 
 test_sdp_section_start() test [0]:
 body: ""
-got rc=0
-FAIL: Expected rc=-22
-got audio_port=0
+DLMGCP MGCP response: cannot find start of SDP parameters
+got rc=-22
 
 test_sdp_section_start() test [1]:
 body: "\n\n"
@@ -51,19 +50,16 @@
 
 test_sdp_section_start() test [7]:
 body: "some mgcp header data\r\nand header params\n\r\nm=audio 23\r\n"
-got rc=0
-FAIL: Expected rc=-22
-got audio_port=0
+DLMGCP MGCP response: cannot find start of SDP parameters
+got rc=-22
 
 test_sdp_section_start() test [8]:
 body: "some mgcp header data\r\nand header params\r\n\rm=audio 23\r\n"
-got rc=0
-FAIL: Expected rc=-22
-got audio_port=0
+DLMGCP MGCP response: cannot find start of SDP parameters
+got rc=-22
 
 test_sdp_section_start() test [9]:
 body: "some mgcp header data\r\nand header params\n\r\rm=audio 23\r\n"
-got rc=0
-FAIL: Expected rc=-22
-got audio_port=0
+DLMGCP MGCP response: cannot find start of SDP parameters
+got rc=-22
 Done

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

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


[MERGED] osmo-mgw[master]: mgcp_client: show failure by MGCP SDP section parsing test

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

Change subject: mgcp_client: show failure by MGCP SDP section parsing test
..


mgcp_client: show failure by MGCP SDP section parsing test

To show how the current code fails, add test_sdp_section_start() to
mgcp_client_test.c, and temporarily accept failing output. This will be fixed
in change I62a2453cd9e2e7d5408423161fa65ec9c9989f98.

Change-Id: I5c6d3566b8f6dbf04c0cd8b127423f5295c19f8d
---
M tests/mgcp_client/mgcp_client_test.c
M tests/mgcp_client/mgcp_client_test.err
M tests/mgcp_client/mgcp_client_test.ok
3 files changed, 180 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved; Verified



diff --git a/tests/mgcp_client/mgcp_client_test.c 
b/tests/mgcp_client/mgcp_client_test.c
index ef2fca8..588b313 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -271,6 +271,111 @@
fprintf(stderr, "%s() done\n", __func__);
 }
 
+struct sdp_section_start_test {
+   const char *body;
+   int expect_rc;
+   struct mgcp_response expect_params;
+};
+
+static struct sdp_section_start_test sdp_section_start_tests[] = {
+   {
+   .body = "",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "\n\n",
+   },
+   {
+   .body = "\r\n\r\n",
+   },
+   {
+   .body = "\n\r\n\r",
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\n"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\r\n\r\n"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\n\r"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\n"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\r\n\r"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\r"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+};
+
+void test_sdp_section_start()
+{
+   int i;
+   int failures = 0;
+
+   for (i = 0; i < ARRAY_SIZE(sdp_section_start_tests); i++) {
+   int rc;
+   struct sdp_section_start_test *t = _section_start_tests[i];
+   struct mgcp_response *r = talloc_zero(ctx, struct 
mgcp_response);
+
+   r->body = talloc_strdup(r, t->body);
+
+   printf("\n%s() test [%d]:\n", __func__, i);
+   fprintf(stderr, "\n%s() test [%d]:\n", __func__, i);
+   fprintf(stderr, "body: \"%s\"\n", osmo_escape_str(r->body, -1));
+
+   rc = mgcp_response_parse_params(r);
+
+   fprintf(stderr, "got rc=%d\n", rc);
+   if (rc != t->expect_rc) {
+   fprintf(stderr, "FAIL: Expected rc=%d\n", t->expect_rc);
+   failures++;
+   }
+   if (rc) {
+   talloc_free(r);
+   continue;
+   }
+
+   fprintf(stderr, "got audio_port=%u\n", 
t->expect_params.audio_port);
+   if (r->audio_port != t->expect_params.audio_port) {
+   fprintf(stderr, "FAIL: Expected audio_port=%u\n", 
t->expect_params.audio_port);
+   failures++;
+   }
+   talloc_free(r);
+   }
+
+   /* Expecting failures due to known bugs, will be resolved in a 
subsequent commit.
+   OSMO_ASSERT(!failures);
+   */
+}
+
 static const struct log_info_cat log_categories[] = {
 };
 
@@ -297,6 +402,7 @@
test_crcx();
test_mgcp_msg();
test_mgcp_client_cancel();
+   test_sdp_section_start();
 
printf("Done\n");
fprintf(stderr, "Done\n");
diff --git a/tests/mgcp_client/mgcp_client_test.err 
b/tests/mgcp_client/mgcp_client_test.err
index 8e9f648..9079c27 100644
--- a/tests/mgcp_client/mgcp_client_test.err
+++ b/tests/mgcp_client/mgcp_client_test.err
@@ -12,4 +12,58 @@
 - canceling again does nothing
 DLMGCP Cannot cancel, no such transaction: 1
 test_mgcp_client_cancel() done

osmo-mgw[master]: mgcp_client: show failure by MGCP SDP section parsing test

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2 Verified+1

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

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


osmo-ttcn3-hacks[master]: L1CTL: Add optional link_id argument to t_L1CTL_DATA_IND()

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib4cf42825da1034966086d9232273c2328a94947
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


osmo-ttcn3-hacks[master]: GSM_RR_Types: Add ts_IMM_ASS and ts_MEAS_REP

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic75041e84c15c77805ecafb823bf7108920675ca
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]: L1CTL: Add optional link_id argument to t_L1CTL_DATA_IND()

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

Change subject: L1CTL: Add optional link_id argument to t_L1CTL_DATA_IND()
..


L1CTL: Add optional link_id argument to t_L1CTL_DATA_IND()

Change-Id: Ib4cf42825da1034966086d9232273c2328a94947
---
M library/L1CTL_Types.ttcn
1 file changed, 4 insertions(+), 3 deletions(-)

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



diff --git a/library/L1CTL_Types.ttcn b/library/L1CTL_Types.ttcn
index 00323b4..d49f37d 100644
--- a/library/L1CTL_Types.ttcn
+++ b/library/L1CTL_Types.ttcn
@@ -501,12 +501,13 @@
payload := ?
};
 
-   /* for matching against incoming RACH_CONF */
-   template L1ctlDlMessage t_L1CTL_DATA_IND(template RslChannelNr chan_nr) 
:= {
+   /* for matching against incoming DATA_IND */
+   template L1ctlDlMessage t_L1CTL_DATA_IND(template RslChannelNr chan_nr,
+template RslLinkId link_id := 
?) := {
header := t_L1ctlHeader(L1CTL_DATA_IND),
dl_info := {
chan_nr := chan_nr,
-   link_id := ?,
+   link_id := link_id,
arfcn := ?,
frame_nr := ?,
rx_level := ?,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4cf42825da1034966086d9232273c2328a94947
Gerrit-PatchSet: 1
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]: GSM_RR_Types: Add ts_IMM_ASS and ts_MEAS_REP

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

Change subject: GSM_RR_Types: Add ts_IMM_ASS and ts_MEAS_REP
..


GSM_RR_Types: Add ts_IMM_ASS and ts_MEAS_REP

which allows us to send RR IMMEDIATE ASSIGNMENT (DL/AGCH) and
RR MEASUREMENT REPORT (UL/SACCH) messages from tests.

Change-Id: Ic75041e84c15c77805ecafb823bf7108920675ca
---
M library/GSM_RR_Types.ttcn
1 file changed, 92 insertions(+), 2 deletions(-)

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



diff --git a/library/GSM_RR_Types.ttcn b/library/GSM_RR_Types.ttcn
index eed58df..2625a1f 100644
--- a/library/GSM_RR_Types.ttcn
+++ b/library/GSM_RR_Types.ttcn
@@ -139,6 +139,12 @@
RrMessageType   message_type
} with { variant "" };
 
+   template RrL3Header t_RrL3Header(RrMessageType msg_type) := {
+   skip_indicator := 0,
+   rr_protocol_discriminator := 6,
+   message_type := msg_type
+   }
+
type record MaioHsn {
} with { variant "" };
 
@@ -486,6 +492,31 @@
variant (hh) "PRESENCE(presence = '11'B)"
};
 
+   type record MeasurementResults {
+   BIT1ba_used,
+   BIT1dtx_used,
+   uint6_t rxlev_full_srv_cell,
+   BIT1threeg_ba_used,
+   BIT1meas_valid,
+   uint6_t rxlev_sub_srv_cell,
+   BIT1si23_ba_used,
+   uint3_t rxqual_full_srv_cell,
+   uint3_t rxqual_sub_srv_cell,
+   uint3_t no_ncell_m,
+   NcellReportsncell_reports optional
+   } with { variant (no_ncell_m) "LENGTHTO(ncell_reports)"
+variant (no_ncell_m) "UNIT(elements)"
+variant "PADDING(yes)"
+variant "FIELDLENGTH(16)"
+   };
+
+   type record NcellReport {
+   uint6_t rxlev,
+   uint5_t bcch_freq,
+   uint6_t bsic
+   } with { variant ""};
+   type record of NcellReport NcellReports;
+
 
/* 9.1.18 */
type record ImmediateAssignment {
@@ -497,7 +528,7 @@
TimingAdvance   timing_advance,
MobileAllocationmobile_allocation,
/* TODO: starting time TLV */
-   IaRestOctetsrest_octets
+   IaRestOctetsrest_octets optional
} with { variant (chan_desc) "PRESENCE(ded_or_tbf.tbf = false)"
 variant (pkt_chan_desc) "PRESENCE(ded_or_tbf.tbf = true)" };
 
@@ -511,6 +542,11 @@
FeatureIndicatorfeature_ind,
PageModepage_mode,
ReqRefWaitInd4  payload
+   } with { variant "" };
+
+   /* 9.1.21 */
+   type record MeasurementReport {
+   MeasurementResults  meas_res
} with { variant "" };
 
/* 9.1.22 */
@@ -607,6 +643,7 @@
 
type union RrL3Union {
PagingResponse  paging_response,
+   MeasurementReport meas_rep,
octetstring other
};
 
@@ -615,8 +652,61 @@
RrL3Union   payload
} with { variant (payload) "CROSSTAG(
paging_response, header.message_type = 
PAGING_RESPONSE;
-
+   meas_rep, header.message_type = 
MEASUREMENT_REPORT;
other, OTHERWISE;
)" }
 
+   external function enc_GsmRrL3Message(in GsmRrL3Message msg) return 
octetstring
+   with { extension "prototype(convert) encode(RAW)" };
+   external function dec_GsmRrL3Message(in octetstring stream) return 
GsmRrL3Message
+   with { extension "prototype(convert) decode(RAW)" };
+
+
+   template GsmRrMessage ts_IMM_ASS(uint8_t ra, GsmFrameNumber fn, 
TimingAdvance ta,
+   ChannelDescription ch_desc, 
MobileAllocation ma) := {
+   header := t_RrHeader(IMMEDIATE_ASSIGNMENT, 0),
+   payload := {
+   imm_ass := {
+   ded_or_tbf := {
+   spare := '0'B,
+   tma := false,
+   downlink := false,
+   tbf := false
+   },
+   page_mode := PAGE_MODE_NORMAL,
+   chan_desc := ch_desc,
+   pkt_chan_desc := omit,
+   req_ref := f_compute_ReqRef(ra, fn),
+   timing_advance := ta,
+   

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

2018-02-21 Thread Harald Welte

Patch Set 2: Code-Review+2

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

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


[MERGED] osmo-bts[master]: RSL: Ensure we don't accept DCHAN messages for CCHAN

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

Change subject: RSL: Ensure we don't accept DCHAN messages for CCHAN
..


RSL: Ensure we don't accept DCHAN messages for CCHAN

If the Channel Number IE points to a common channel, we cannot
accept such messages in code paths that only process dedicated
channels, such as RLL/DCHAN/IPA.

Related: OS#2972, OS#2971
Change-Id: I43a78bec63aeb36dd67043d237b27fe880209349
---
M src/common/rsl.c
1 file changed, 22 insertions(+), 0 deletions(-)

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



diff --git a/src/common/rsl.c b/src/common/rsl.c
index 877f5d8..001d7e0 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -135,6 +135,16 @@
  * support
  */
 
+/* Is this channel number for a dedicated channel (true) or not (false) */
+static bool chan_nr_is_dchan(uint8_t chan_nr)
+{
+   /* See TS 48.058 9.3.1 */
+   if (chan_nr & 0x80)
+   return false;
+   else
+   return true;
+}
+
 static struct gsm_lchan *lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
  const char *log_name)
 {
@@ -2254,6 +2264,9 @@
}
msg->l3h = (unsigned char *)rh + sizeof(*rh);
 
+   if (!chan_nr_is_dchan(rh->chan_nr))
+   return rsl_reject_unknown_lchan(msg);
+
lchan = lchan_lookup(trx, rh->chan_nr, "RSL rx RLL: ");
if (!lchan) {
LOGP(DRLL, LOGL_NOTICE, "Rx RLL %s for unknown lchan\n",
@@ -2445,6 +2458,9 @@
}
msg->l3h = (unsigned char *)cch + sizeof(*cch);
 
+   if (chan_nr_is_dchan(cch->chan_nr))
+   return rsl_reject_unknown_lchan(msg);
+
msg->lchan = lchan_lookup(trx, cch->chan_nr, "RSL rx CCHAN: ");
if (!msg->lchan) {
LOGP(DRSL, LOGL_ERROR, "Rx RSL %s for unknown lchan\n",
@@ -2497,6 +2513,9 @@
return -EIO;
}
msg->l3h = (unsigned char *)dch + sizeof(*dch);
+
+   if (!chan_nr_is_dchan(dch->chan_nr))
+   return rsl_reject_unknown_lchan(msg);
 
msg->lchan = lchan_lookup(trx, dch->chan_nr, "RSL rx DCHAN: ");
if (!msg->lchan) {
@@ -2596,6 +2615,9 @@
}
msg->l3h = (unsigned char *)dch + sizeof(*dch);
 
+   if (!chan_nr_is_dchan(dch->chan_nr))
+   return rsl_reject_unknown_lchan(msg);
+
msg->lchan = lchan_lookup(trx, dch->chan_nr, "RSL rx IPACC: ");
if (!msg->lchan) {
LOGP(DRSL, LOGL_ERROR, "Rx RSL %s for unknow lchan\n",

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

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


[MERGED] osmo-bts[master]: octphy: ensure all BTS models set features

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

Change subject: octphy: ensure all BTS models set features
..


octphy: ensure all BTS models set features

Most of the BTS models do not or do register not all of thier
features to the the feature list.

- Update/extend the feature lists for all BTS-Models

Change-Id: I26765a64153368016921c2ac115b1c4aec9bc5e4
---
M src/osmo-bts-litecell15/main.c
M src/osmo-bts-octphy/l1_if.c
M src/osmo-bts-sysmo/main.c
M src/osmo-bts-trx/main.c
M src/osmo-bts-virtual/main.c
5 files changed, 28 insertions(+), 0 deletions(-)

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



diff --git a/src/osmo-bts-litecell15/main.c b/src/osmo-bts-litecell15/main.c
index 97b5359..dcbd9f5 100644
--- a/src/osmo-bts-litecell15/main.c
+++ b/src/osmo-bts-litecell15/main.c
@@ -92,8 +92,14 @@
}
 
gsm_bts_set_feature(bts, BTS_FEAT_GPRS);
+   gsm_bts_set_feature(bts, BTS_FEAT_EGPRS);
gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
gsm_bts_set_feature(bts, BTS_FEAT_AGCH_PCH_PROP);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_EFR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR);
 
bts_model_vty_init(bts);
 
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index dde993d..e5fcd98 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -791,6 +791,11 @@
 
gsm_bts_set_feature(bts, BTS_FEAT_GPRS);
gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
+#if 
defined(cOCTVC1_GSM_LOGICAL_CHANNEL_COMBINATION_ENUM_FCCH_SCH_BCCH_CCCH_SDCCH4_CBCH_SACCHC4)
 && defined(cOCTVC1_GSM_LOGICAL_CHANNEL_COMBINATION_ENUM_SDCCH8_CBCH_SACCHC8)
+   gsm_bts_set_feature(bts, BTS_FEAT_CBCH);
+#endif
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
 
bts_model_vty_init(bts);
 
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index f52ecdd..6118b60 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -94,6 +94,11 @@
gsm_bts_set_feature(bts, BTS_FEAT_EGPRS);
gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
gsm_bts_set_feature(bts, BTS_FEAT_AGCH_PCH_PROP);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_EFR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR);
 
bts_model_vty_init(bts);
 
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 973a611..38bb881 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -120,6 +120,11 @@
 
gsm_bts_set_feature(bts, BTS_FEAT_GPRS);
gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_EFR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR);
 
bts_model_vty_init(bts);
 
diff --git a/src/osmo-bts-virtual/main.c b/src/osmo-bts-virtual/main.c
index 8459107..7815a34 100644
--- a/src/osmo-bts-virtual/main.c
+++ b/src/osmo-bts-virtual/main.c
@@ -61,6 +61,13 @@
btsb = bts_role_bts(bts);
btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3);
 
+   gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_EFR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR);
+
bts_model_vty_init(bts);
 
return 0;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I26765a64153368016921c2ac115b1c4aec9bc5e4
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


osmo-bts[master]: gsm_data_shared: extend bts feature list with speech codecs

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


osmo-mgw[master]: compiler warning: ignore deprecated in mgcp_client_test.c

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


[MERGED] osmo-bts[master]: gsm_data_shared: extend bts feature list with speech codecs

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

Change subject: gsm_data_shared: extend bts feature list with speech codecs
..


gsm_data_shared: extend bts feature list with speech codecs

The feature list does not cover any speech codec related information.

- Add speech codec related items to feature list.

Change-Id: If6d50c6f4e2348b23f31c3415b0f5577a3f5be50
---
M include/osmo-bts/gsm_data_shared.h
M src/common/gsm_data_shared.c
2 files changed, 12 insertions(+), 1 deletion(-)

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



diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index 6c1383f..1571929 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -525,7 +525,8 @@
 };
 
 /* N. B: always add new features to the end of the list (right before 
_NUM_BTS_FEAT) to avoid breaking compatibility
-   with BTS compiled against earlier version of this header */
+   with BTS compiled against earlier version of this header. Also make sure 
that the description strings
+   gsm_bts_features_descs[] in gsm_data_shared.c are also updated accordingly! 
*/
 enum gsm_bts_features {
BTS_FEAT_HSCSD,
BTS_FEAT_GPRS,
@@ -536,6 +537,11 @@
BTS_FEAT_OML_ALERTS,
BTS_FEAT_AGCH_PCH_PROP,
BTS_FEAT_CBCH,
+   BTS_FEAT_SPEECH_F_V1,
+   BTS_FEAT_SPEECH_H_V1,
+   BTS_FEAT_SPEECH_F_EFR,
+   BTS_FEAT_SPEECH_F_AMR,
+   BTS_FEAT_SPEECH_H_AMR,
_NUM_BTS_FEAT
 };
 
diff --git a/src/common/gsm_data_shared.c b/src/common/gsm_data_shared.c
index 1ef223c..e5a5ee6 100644
--- a/src/common/gsm_data_shared.c
+++ b/src/common/gsm_data_shared.c
@@ -117,6 +117,11 @@
{ BTS_FEAT_OML_ALERTS,  "OML Alerts" },
{ BTS_FEAT_AGCH_PCH_PROP,   "AGCH/PCH proportional allocation" },
{ BTS_FEAT_CBCH,"CBCH" },
+   { BTS_FEAT_SPEECH_F_V1, "Fullrate speech V1" },
+   { BTS_FEAT_SPEECH_H_V1, "Halfrate speech V1" },
+   { BTS_FEAT_SPEECH_F_EFR,"Fullrate speech EFR" },
+   { BTS_FEAT_SPEECH_F_AMR,"Fullrate speech AMR" },
+   { BTS_FEAT_SPEECH_H_AMR,"Halfrate speech AMR" },
{ 0, NULL }
 };
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If6d50c6f4e2348b23f31c3415b0f5577a3f5be50
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


[MERGED] osmo-mgw[master]: compiler warning: ignore deprecated in mgcp_client_test.c

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

Change subject: compiler warning: ignore deprecated in mgcp_client_test.c
..


compiler warning: ignore deprecated in mgcp_client_test.c

mgcp_msg_crcx() causes deprecation warning, but it's fine for a unit test
to use deprecated API.

Change-Id: Iba6d0c9c729367e00a9ab7fff7c89007d336e59d
---
M tests/mgcp_client/mgcp_client_test.c
1 file changed, 2 insertions(+), 0 deletions(-)

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



diff --git a/tests/mgcp_client/mgcp_client_test.c 
b/tests/mgcp_client/mgcp_client_test.c
index 50e21b5..19b55e2 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -18,6 +18,8 @@
  * along with this program.  If not, see .
  */
 
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 #include 
 
 #include 

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

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


osmo-bts[master]: bts: use feature list instead of speech codec table

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


libosmocore[master]: gsm0408_test: include BCD and leading zeros in test output

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


libosmocore[master]: gsm0408_test: cosmetically re-order MCC to come before MNC

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


libosmocore[master]: cosmetic: gsm0408_test: RA test cases as array-of-struct

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


libosmocore[master]: gsm0408_test: RA test: include min/max value cases

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


libosmocore[master]: gsm0408_test: also test gsm48_generate_lai() and gsm48_decod...

2018-02-21 Thread Harald Welte

Patch Set 1: Code-Review+2

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

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


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

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

Change subject: IPA_Emulation: Make dependencies to RSL/MGCP/SCCP/GSUP 
conditional
..


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

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

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

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

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



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

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

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

Change subject: RSL_Types: Add templates for "BSC side"
..


RSL_Types: Add templates for "BSC side"

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

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

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

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



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

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

2018-02-21 Thread Neels Hofmeyr

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

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_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
7 files changed, 27 insertions(+), 14 deletions(-)


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

diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index 67b657a..18f92af 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -226,6 +226,7 @@
/* global parameters */
uint16_t country_code;
uint16_t network_code;
+   bool network_code_3_digits;
char *name_long;
char *name_short;
/* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */
diff --git a/src/libcommon-cs/common_cs_vty.c b/src/libcommon-cs/common_cs_vty.c
index 01c6b35..0d39e9c 100644
--- a/src/libcommon-cs/common_cs_vty.c
+++ b/src/libcommon-cs/common_cs_vty.c
@@ -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 (gsm48_mnc_from_str(argv[0], , _3_digits)) {
+   vty_out(vty, "%% Error decoding MNC: %s%s", argv[0], 
VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   gsmnet->network_code = mnc;
+   gsmnet->network_code_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..37a4255 100644
--- a/src/libmsc/a_iface_bssap.c
+++ b/src/libmsc/a_iface_bssap.c
@@ -265,6 +265,7 @@
} __attribute__ ((packed)) lai_ci;
uint16_t mcc;
uint16_t mnc;
+   bool mnc_3_digits;
uint16_t lac;
uint8_t data_length;
const uint8_t *data;
@@ -301,11 +302,12 @@
 "Unable to parse element CELL IDENTIFIER (wrong cell 
identification discriminator) -- discarding message!\n");
return -EINVAL;
}
-   if (gsm48_decode_lai(_ci.lai, , , ) != 0) {
+   if (gsm48_decode_lai2(_ci.lai, , , _3_digits, ) != 
0) {
LOGP(DBSSAP, LOGL_ERROR,
 "Unable to parse element CELL IDENTIFIER (lai decoding 
failed) -- discarding message!\n");
return -EINVAL;
}
+   /* 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);
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index b928171..0a61c09 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -228,9 +228,9 @@
gh->msg_type = GSM48_MT_MM_LOC_UPD_ACCEPT;
 
lai = (struct gsm48_loc_area_id *) msgb_put(msg, sizeof(*lai));
-   gsm48_generate_lai(lai, conn->network->country_code,
-  conn->network->network_code,
-  conn->lac);
+   gsm48_generate_lai2(lai, conn->network->country_code,
+   conn->network->network_code, 
conn->network->network_code_3_digits,
+   conn->lac);
 
if (send_tmsi == GSM_RESERVED_TMSI) {
/* we did not allocate a TMSI to the MS, so we need to
@@ -381,10 +381,11 @@
break;
}
 
-   gsm48_decode_lai(>lai, _lai.plmn.mcc,
-_lai.plmn.mnc, _lai.lac);
+   gsm48_decode_lai2(>lai, _lai.plmn.mcc,
+ _lai.plmn.mnc, _lai.plmn.mnc_3_digits, 
_lai.lac);
new_lai.plmn.mcc = conn->network->country_code;
new_lai.plmn.mnc = conn->network->network_code;
+   new_lai.plmn.mnc_3_digits = conn->network->network_code_3_digits;
new_lai.lac = conn->lac;
DEBUGP(DMM, "LU/new-LAC: %u/%u\n", old_lai.lac, new_lai.lac);
 
@@ -703,6 +704,7 @@
 
lai.plmn.mcc = conn->network->country_code;
lai.plmn.mnc = conn->network->network_code;
+   lai.plmn.mnc_3_digits = conn->network->network_code_3_digits;
lai.lac = conn->lac;
 
DEBUGP(DMM, "<- CM SERVICE REQUEST ");
@@ -1154,6 +1156,7 @@
 
lai.plmn.mcc = conn->network->country_code;
lai.plmn.mnc = conn->network->network_code;
+   lai.plmn.mnc_3_digits = conn->network->network_code_3_digits;
lai.lac = conn->lac;
 
resp = (struct gsm48_pag_resp *) >data[0];
diff --git a/src/libmsc/msc_vty.c b/src/libmsc/msc_vty.c

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

2018-02-21 Thread Neels Hofmeyr

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

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).

Note that in gbproxy_test.ok, 0-0 changes to 000-000 instead of 000-00, because
the parsed ra buffer is 00 which results in 000-000, while 00f000 would
result in 000-00. IOW this is expected.

Change-Id: I7437dfaa586689e2bef0d4be6537e5577a8f6c26
---
M include/osmocom/sgsn/gb_proxy.h
M src/gprs/gb_proxy.c
M src/gprs/gb_proxy_patch.c
M src/gprs/gb_proxy_vty.c
M src/gprs/gprs_gb_parse.c
M src/gprs/gprs_gmm.c
M src/gprs/gprs_utils.c
M src/gprs/sgsn_auth.c
M src/gprs/sgsn_vty.c
M tests/gbproxy/gbproxy_test.c
M tests/gbproxy/gbproxy_test.ok
11 files changed, 70 insertions(+), 56 deletions(-)


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

diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h
index e10894f..f4d82a0 100644
--- a/include/osmocom/sgsn/gb_proxy.h
+++ b/include/osmocom/sgsn/gb_proxy.h
@@ -102,6 +102,7 @@
 
/* force mcc/mnc */
int core_mnc;
+   bool core_mnc_3_digits;
int core_mcc;
uint8_t* core_apn;
size_t core_apn_size;
@@ -121,6 +122,7 @@
 
 struct gbproxy_patch_state {
int local_mnc;
+   bool local_mnc_3_digits;
int local_mcc;
 
/* List of TLLIs for which patching is enabled */
diff --git a/src/gprs/gb_proxy.c b/src/gprs/gb_proxy.c
index 63c3a61..68d9b15 100644
--- a/src/gprs/gb_proxy.c
+++ b/src/gprs/gb_proxy.c
@@ -194,6 +194,7 @@
struct gbproxy_patch_state *state = >patch_state;
const int old_local_mcc = state->local_mcc;
const int old_local_mnc = state->local_mnc;
+   const bool old_local_mnc_3_digits = state->local_mnc_3_digits;
struct gprs_ra_id raid;
 
if (!raid_enc)
@@ -208,22 +209,28 @@
state->local_mcc = raid.mcc;
}
 
-   if (!peer->cfg->core_mnc || raid.mnc == peer->cfg->core_mnc) {
+   if (!peer->cfg->core_mnc
+   || !gsm48_mnc_cmp(raid.mnc, raid.mnc_3_digits,
+ peer->cfg->core_mnc, 
peer->cfg->core_mnc_3_digits)) {
state->local_mnc = 0;
+   state->local_mnc_3_digits = false;
} else {
state->local_mnc = raid.mnc;
+   state->local_mnc_3_digits = raid.mnc_3_digits;
}
 
-   if (old_local_mcc != state->local_mcc ||
-   old_local_mnc != state->local_mnc)
+   if (old_local_mcc != state->local_mcc
+   || gsm48_mnc_cmp(old_local_mnc, old_local_mnc_3_digits,
+state->local_mnc, state->local_mnc_3_digits))
LOGP(DGPRS, LOGL_NOTICE,
 "Patching RAID %sactivated, msg: %s, "
-"local: %d-%d, core: %d-%d\n",
+"local: %s, core: %s\n",
 state->local_mcc || state->local_mnc ?
 "" : "de",
 log_text,
-state->local_mcc, state->local_mnc,
-peer->cfg->core_mcc, peer->cfg->core_mnc);
+osmo_mcc_mnc_name(state->local_mcc, state->local_mnc, 
state->local_mnc_3_digits),
+osmo_mcc_mnc_name2(peer->cfg->core_mcc, 
peer->cfg->core_mnc,
+   peer->cfg->core_mnc_3_digits));
 }
 
 uint32_t gbproxy_make_bss_ptmsi(struct gbproxy_peer *peer,
@@ -994,9 +1001,8 @@
sizeof(from_peer->ra));
gsm48_parse_ra(, from_peer->ra);
LOGP(DGPRS, LOGL_INFO, "NSEI=%u BSSGP SUSPEND/RESUME "
-   "RAI snooping: RAI %u-%u-%u-%u behind BVCI=%u\n",
-   nsei, raid.mcc, raid.mnc, raid.lac,
-   raid.rac , from_peer->bvci);
+   "RAI snooping: RAI %s behind BVCI=%u\n",
+   nsei, osmo_rai_name(), from_peer->bvci);
/* FIXME: This only supports one BSS per RA */
break;
case BSSGP_PDUT_BVC_RESET:
@@ -1037,10 +1043,8 @@
TLVP_VAL(, BSSGP_IE_CELL_ID),
sizeof(from_peer->ra));
gsm48_parse_ra(, from_peer->ra);
-   LOGP(DGPRS, LOGL_INFO, "NSEI=%u/BVCI=%u "
-"Cell ID %u-%u-%u-%u\n", nsei,
-bvci, raid.mcc, raid.mnc, raid.lac,
-raid.rac);
+   LOGP(DGPRS, LOGL_INFO, "NSEI=%u/BVCI=%u Cell ID 
%s\n",
+nsei, bvci, osmo_rai_name());
}
if (cfg->route_to_sgsn2)
copy_to_sgsn2 = 1;
diff --git a/src/gprs/gb_proxy_patch.c 

[PATCH] osmo-iuh[master]: hnb-test: log accurate three-digit MNC with leading zeros

2018-02-21 Thread Neels Hofmeyr

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

hnb-test: log accurate three-digit MNC with leading zeros

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore)
Change-Id: Ie3dd206bca2f38a0ef7ee7f9d3b6bf2eacc899a4
---
M src/tests/hnb-test.c
1 file changed, 4 insertions(+), 3 deletions(-)


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

diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c
index 32f4ba8..4687d34 100644
--- a/src/tests/hnb-test.c
+++ b/src/tests/hnb-test.c
@@ -268,9 +268,10 @@
lai = (struct gsm48_loc_area_id *)>data[0];
 
uint16_t mcc, mnc, lac;
-   gsm48_decode_lai(lai, , , );
-   printf("LU: mcc %hd  mnc %hd  lac %hd\n",
-  mcc, mnc, lac);
+   bool mnc_3_digits;
+   gsm48_decode_lai2(lai, , , _3_digits, );
+   printf("LU: mcc %s  mnc %s  lac %hd\n",
+  osmo_mcc_name(mcc), osmo_mnc_name(mnc, mnc_3_digits), lac);
 
struct tlv_parsed tp;
int parse_res;

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

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


[PATCH] libosmocore[master]: introduce GSM_MCC_MNC_INVALID

2018-02-21 Thread Neels Hofmeyr

introduce GSM_MCC_MNC_INVALID

In some cases, we want to mark an unset MCC-MNC. Define uint16-max for this
purpose.

osmo-bsc code is already doing so with a -1 and using int data types, which
will become inconvenient with the new API that handles MCC and MNC as uint16_t.

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/64/6664/2

diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h
index 37c421d..7c32cfb 100644
--- a/include/osmocom/gsm/gsm48.h
+++ b/include/osmocom/gsm/gsm48.h
@@ -11,6 +11,10 @@
 /* reserved according to GSM 03.03 § 2.4 */
 #define GSM_RESERVED_TMSI   0x
 
+/* Valid MCC and MNC range from 0 to 999.
+ * To mark an invalid / unset MNC, this value shall be used. */
+#define GSM_MCC_MNC_INVALID 0x
+
 /* A parsed GPRS routing area */
 struct gprs_ra_id {
uint16_tmcc;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ieee7add0bd6d94cf84743a49794bbcd38561b72f
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


osmo-bsc[master]: use gsm48_ra_id instead of buf

2018-02-21 Thread Vadim Yanitskiy

Patch Set 1: Code-Review+1

Would be also great to have a minimalistic commit description,
i.e. where do we use gsm48_ra_id and why?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I0d3908fb8ca1e2e669d257b5d59b40675fa85d06
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[MERGED] osmo-ttcn3-hacks[master]: IPA_Emulation: Don't log IPAC_MSGT_ID_RESP as "Unknown/unsup...

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

Change subject: IPA_Emulation: Don't log IPAC_MSGT_ID_RESP as 
"Unknown/unsupported"
..


IPA_Emulation: Don't log IPAC_MSGT_ID_RESP as "Unknown/unsupported"

Change-Id: I6ea3855a1f3d1cba6ac173b0f9cf9052d5d028fc
---
M library/IPA_Emulation.ttcnpp
1 file changed, 3 insertions(+), 0 deletions(-)

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



diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp
index 3508091..c3cfe8d 100644
--- a/library/IPA_Emulation.ttcnpp
+++ b/library/IPA_Emulation.ttcnpp
@@ -342,6 +342,9 @@
case (IPAC_MSGT_ID_GET) {
f_ccm_tx(f_ccm_make_id_resp(ccm));
}
+   case (IPAC_MSGT_ID_RESP) {
+   log("IPA ID RESP: ", ccm.u.resp);
+   }
case else {
log("Unknown/unsupported IPA CCM message type", ccm);
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6ea3855a1f3d1cba6ac173b0f9cf9052d5d028fc
Gerrit-PatchSet: 1
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]: RSL_Emulation: Introduce notion of 'bts_role'

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

Change subject: RSL_Emulation: Introduce notion of 'bts_role'
..


RSL_Emulation: Introduce notion of 'bts_role'

So far we assumed we emulate the BTS side and talk to a BSC.

Let's make this configurable and disable the BTS-side spcific code
paths by means of a 'bts_role' boolean type.

Change-Id: I0d0460cbb633b470f6117d07643f68aefb1530eb
---
M library/RSL_Emulation.ttcn
1 file changed, 20 insertions(+), 8 deletions(-)

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



diff --git a/library/RSL_Emulation.ttcn b/library/RSL_Emulation.ttcn
index dab1785..5c7dc9c 100644
--- a/library/RSL_Emulation.ttcn
+++ b/library/RSL_Emulation.ttcn
@@ -52,6 +52,11 @@
inout RSLDC_ChanRqd, RSL_Message;
 } with { extension "internal" };
 
+type port RSL_CCHAN_PT message {
+   inout ASP_RSL_Unitdata;
+} with { extension "internal" };
+
+
 signature RSLEM_register(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr 
hdlr);
 signature RSLEM_unregister(uint8_t trx_nr, RslChannelNr chan_nr, RSL_DchanHdlr 
hdlr);
 signature RSLEM_suspend(boolean suspend);
@@ -242,6 +247,9 @@
port RSL_DCHAN_PT CLIENT_PT;
port RSLEM_PROC_PT RSL_PROC;
 
+   /* port for Common Channel / TRX Management */
+   port RSL_CCHAN_PT CCHAN_PT;
+
/* state of all concurrent connections / dedicated channels */
var ConnectionData ConnectionTable[64];
 }
@@ -268,7 +276,7 @@
 }
 
 
-function main() runs on RSL_Emulation_CT {
+function main(boolean bts_role := true) runs on RSL_Emulation_CT {
var ASP_RSL_Unitdata rx_rsl;
var RSL_Message rx_rsl_msg;
var RSLDC_ChanRqd chan_rqd;
@@ -286,10 +294,10 @@
alt {
[] IPA_PT.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}) {
}
-   [] IPA_PT.receive(ASP_IPA_Event:{up_down := 
ASP_IPA_EVENT_ID_ACK}) {
+   [bts_role] IPA_PT.receive(ASP_IPA_Event:{up_down := 
ASP_IPA_EVENT_ID_ACK}) {

IPA_PT.send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,ts_RSL_PAGING_LOAD_IND(23)));
}
-   [] IPA_PT.receive(tr_RSL(tr_RSL_IMM_ASSIGN)) -> value rx_rsl {
+   [bts_role] IPA_PT.receive(tr_RSL(tr_RSL_IMM_ASSIGN)) -> value 
rx_rsl {
var GsmRrMessage rr;
var OCT1 ra;
var GsmFrameNumber fn;
@@ -327,7 +335,7 @@
}
}
 
-   [] IPA_PT.receive(tr_RSL(tr_RSL_PAGING_CMD(?, ?))) -> value 
rx_rsl {
+   [bts_role] IPA_PT.receive(tr_RSL(tr_RSL_PAGING_CMD(?, ?))) -> 
value rx_rsl {
log("PAGING IDENTITY ", rx_rsl.rsl.ies[2].body.other);
/* broadcast to all clients? */
for (i := 0; i < sizeof(ConnectionTable); i := i + 1) {
@@ -337,16 +345,20 @@
}
}
 
+   /* Forward common channel management to the special port for it 
*/
[] IPA_PT.receive(tr_RSL(tr_RSL_MsgTypeT(?))) -> value rx_rsl {
-   log("Ingnoring TRX Mgmt ", rx_rsl.rsl);
+   log("Forwarding TRX Mgmt ", rx_rsl.rsl);
+   CCHAN_PT.send(rx_rsl);
}
 
+   /* Forward common channel management to the special port for it 
*/
[] IPA_PT.receive(tr_RSL(tr_RSL_MsgTypeC(?))) -> value rx_rsl {
-   log("Ignoring Common Channel Mgmt ", rx_rsl.rsl);
+   log("Forwarding Common Channel Mgmt ", rx_rsl.rsl);
+   CCHAN_PT.send(rx_rsl);
}
 
/* blindly acknowledge all channel activations */
-   [] IPA_PT.receive(tr_RSL(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) 
-> value rx_rsl {
+   [bts_role] 
IPA_PT.receive(tr_RSL(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) -> value rx_rsl {
chan_nr := rx_rsl.rsl.ies[0].body.chan_nr;
IPA_PT.send(ts_ASP_RSL_UD(rx_rsl.streamId, 
ts_RSL_CHAN_ACT_ACK(chan_nr, 23)));
}
@@ -367,7 +379,7 @@
self.stop;
}
 
-   [] CLIENT_PT.receive(RSLDC_ChanRqd:?) -> value chan_rqd sender 
vc_conn {
+   [bts_role] CLIENT_PT.receive(RSLDC_ChanRqd:?) -> value chan_rqd 
sender vc_conn {
/* Store the knowledge that this sender has requested a 
certain RQ+time */
f_cid_create(chan_rqd.ra, chan_rqd.fn, vc_conn);
IPA_PT.send(ts_ASP_RSL_UD(IPAC_PROTO_RSL_TRX0,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0d0460cbb633b470f6117d07643f68aefb1530eb
Gerrit-PatchSet: 1

[PATCH] libosmocore[master]: gsm0408_test: include BCD and leading zeros in test output

2018-02-21 Thread Neels Hofmeyr

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

gsm0408_test: include BCD and leading zeros in test output

(Preparation for adding 3-digit MNC)

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/56/6656/1

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 87f8dde..aa6a8be 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("RA: MCC=%u, MNC=%u, LAC=%u, RAC=%u\n", raid->mcc, raid->mnc, 
raid->lac, raid->rac);
+   printf("%03u-%02u-%u-%u\n", raid->mcc, raid->mnc, raid->lac, raid->rac);
 }
 
 static inline void check_ra(const struct gprs_ra_id *raid)
@@ -150,6 +150,7 @@
 
gsm48_parse_ra(, (const uint8_t *));
dump_ra(raid);
+   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)
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 295d8ec..a3d801d 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -3,10 +3,12 @@
 Simple TMSI encoding testpassed
 Simple IMSI encoding testpassed: [10] 17 08 99 10 07 00 00 00 64 02 
 Constructed RA:
-RA: MCC=77, MNC=121, LAC=666, RAC=5
-RA: MCC=77, MNC=121, LAC=666, RAC=5
+077-121-666-5
+MCC+MNC in BCD: 70 17 21 
+077-121-666-5
 RA test...passed
 Constructed RA:
-RA: MCC=84, MNC=98, LAC=11, RAC=89
-RA: MCC=84, MNC=98, LAC=11, RAC=89
+084-98-11-89
+MCC+MNC in BCD: 80 f4 89 
+084-98-11-89
 RA test...passed

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f8ae05fa3e4a6fc004212757b05ca8a14c9ef45
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Neels Hofmeyr

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

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 struct gprs_ra_id.
Ordering is changed because the canonical oder is {Mobile Country Code, Mobile
Network Code}, so have the mcc member first. Change size (and ordering) by
inserting a flag to indicate a three-digit MNC after the mnc member. ABI
compatibility cannot be maintained, since struct gprs_ra_id 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.

Add new API to set and read this additional flag to preserve leading zeros:
- gsm48_mcc_mnc_to_bcd2(), gsm48_mcc_mnc_from_bcd2() after
  gsm48_mcc_mnc_to_bcd() and gsm48_mcc_mnc_from_bcd().
- gsm0808_create_layer3_aoip2() after gsm0808_create_layer3_aoip().
- gsm48_decode_lai2(), gsm48_generate_lai2() after
  gsm48_decode_lai(), gsm48_generate_lai().
- The equivalent of gsm0808_create_layer3() for preserving leading zeros is
  gsm0808_create_layer3_aoip2() with the scl argument passed as NULL; instead
  of introducing a new shim function like gsm0808_create_layer3_2(), indicate
  such in the API docs, only.
- gsm48_mnc_from_str() to encode leading zeros from string, useful for VTY
  config parsing.
- gsm48_mnc_cmp() to compare MNC values including leading zeros.

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 enlarge this patch; plus, with a separate flag,
  current code can decide when to start heeding leading zeros.

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/gsm48.c
M src/gsm/libosmogsm.map
M src/sim/card_fs_sim.c
14 files changed, 234 insertions(+), 40 deletions(-)


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

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 a/debian/libosmogsm8.install b/debian/libosmogsm9.install
similarity index 100%
rename from debian/libosmogsm8.install
rename to debian/libosmogsm9.install
diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h
index 3deee70..f0f8a38 100644
--- a/include/osmocom/gsm/gsm0808.h
+++ b/include/osmocom/gsm/gsm0808.h
@@ -35,6 +35,10 @@
uint16_t cc, int lac, uint16_t _ci,
  

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

2018-02-21 Thread Neels Hofmeyr

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

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/1

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index c40c643..2591442 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -233,6 +233,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,
@@ -240,6 +250,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 be2a1de..59484c3 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-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-0 (3-digit MNC)
+  Encoded 00 00 00 00 00 
+  gsm48_decode_lai2() gives  000-000-0-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-0 (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-0
+  Encoded 00 f1 20 00 17 
+  gsm48_decode_lai2() gives  001-02-23-0
+  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-0 (3-digit MNC)
+  Encoded 00 21 00 00 17 
+  gsm48_decode_lai2() gives  001-002-23-0 (3-digit MNC)
+  passed
+- gsm48_generate_lai() from 012-34-56-0
+  Encoded 10 f2 43 00 38 
+  gsm48_decode_lai() gives  012-34-56-0
+  passed
+- gsm48_generate_lai2() from 012-34-56-0
+  Encoded 10 f2 43 00 38 
+  

[PATCH] libosmocore[master]: gsm: add gsm48_mnc_from_str() and gsm48_mnc_cmp(), for 3-dig...

2018-02-21 Thread Neels Hofmeyr

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

gsm: add gsm48_mnc_from_str() and gsm48_mnc_cmp(), for 3-digit MNC

gsm48_mnc_from_str() preserves leading zeros in the string and is useful for
VTY config parsing.

gsm48_mnc_cmp() will be used by osmo-sgsn.git

Change-Id: Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6
---
M include/osmocom/gsm/gsm48.h
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
3 files changed, 63 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/6663/1

diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h
index 9d312c2..37c421d 100644
--- a/include/osmocom/gsm/gsm48.h
+++ b/include/osmocom/gsm/gsm48.h
@@ -63,3 +63,7 @@
 void gsm48_mcc_mnc_to_bcd2(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc, bool 
mnc_3_digits);
 void gsm48_mcc_mnc_from_bcd(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc);
 void gsm48_mcc_mnc_from_bcd2(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc, 
bool *mnc_3_digits);
+
+int gsm48_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits);
+
+int gsm48_mnc_cmp(uint16_t a_mnc, bool a_mnc_3_digits, uint16_t b_mnc, bool 
b_mnc_3_digits);
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index 122f7ea..be2a976 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -530,6 +530,63 @@
}
 }
 
+/* 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 gsm48_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits)
+{
+   uint16_t _mnc = 0;
+   bool _mnc_3_digits = false;
+   char *endptr;
+   int rc = 0;
+
+   if (!mnc_str || !isdigit(mnc_str[0])) {
+   /* 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;
+   _mnc_3_digits = strlen(mnc_str) > 2;
+
+   if (mnc)
+   *mnc = _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 gsm48_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;
+}
+
 /*! Encode TS 04.08 Location Area Identifier, legacy implementation.
  * Instead use gsm48_generate_lai2(), which is capable of three-digit MNC with 
leading zeros.
  *  \param[out] caller-provided memory for output
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 917eab2..9e3de75 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -272,6 +272,8 @@
 osmo_mcc_mnc_name;
 osmo_mcc_mnc_name2;
 osmo_rai_name;
+gsm48_mnc_from_str;
+gsm48_mnc_cmp;
 gsm48_chan_mode_names;
 gsm_chan_t_names;
 gsm48_pdisc_names;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Neels Hofmeyr

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

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, 45 insertions(+), 0 deletions(-)


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

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 9e552ab..c40c643 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -187,6 +187,34 @@
printf("  FAIL\n");
 }
 
+static inline void check_lai2(const struct gprs_ra_id *raid)
+{
+   int rc;
+   struct gsm48_loc_area_id lai = {};
+   struct gprs_ra_id decoded = {};
+   struct gprs_ra_id _laid = *raid;
+   struct gprs_ra_id *laid = &_laid;
+   laid->rac = 0;
+
+   printf("- gsm48_generate_lai2() from "); dump_ra(laid);
+
+   gsm48_generate_lai2(, laid->mcc, laid->mnc, laid->mnc_3_digits, 
laid->lac);
+   printf("  Encoded %s\n", osmo_hexdump((unsigned char*), 
sizeof(lai)));
+   rc = gsm48_decode_lai2(, , , 
_3_digits, );
+   if (rc) {
+   printf("  gsm48_decode_lai2() returned %d --> FAIL\n", rc);
+   return;
+   }
+   printf("  gsm48_decode_lai2() gives  "); dump_ra();
+   if (decoded.mcc == laid->mcc
+   && decoded.mnc == laid->mnc
+   && decoded.lac == laid->lac
+   && decoded.mnc_3_digits == (laid->mnc_3_digits || laid->mnc > 99))
+   printf("  passed\n");
+   else
+   printf("  FAIL\n");
+}
+
 static struct gprs_ra_id test_ra_cap_items[] = {
{
.mcc = 77,
@@ -228,6 +256,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..be2a1de 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-0
+  Encoded 70 17 21 02 9a 
+  gsm48_decode_lai2() gives  077-121-666-0 (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-0
+  Encoded 80 f4 89 00 0b 
+  gsm48_decode_lai2() gives  084-98-11-0
   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-0
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai2() gives  000-00-0-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-0
+  Encoded 99 99 99 ff ff 
+  gsm48_decode_lai2() gives  999-999-65535-0 (3-digit MNC)
+  passed

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


[PATCH] libosmocore[master]: gsm0408_test: also test gsm48_generate_lai() and gsm48_decod...

2018-02-21 Thread Neels Hofmeyr

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

gsm0408_test: also test gsm48_generate_lai() and gsm48_decode_lai()

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/58/6658/1

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index ad45507..a0e740a 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -159,6 +159,33 @@
printf("passed\n");
 }
 
+static inline void check_lai(const struct gprs_ra_id *raid)
+{
+   int rc;
+   struct gsm48_loc_area_id lai = {};
+   struct gprs_ra_id decoded = {};
+   struct gprs_ra_id _laid = *raid;
+   struct gprs_ra_id *laid = &_laid;
+   laid->rac = 0;
+
+   printf("- gsm48_generate_lai() from "); dump_ra(laid);
+
+   gsm48_generate_lai(, laid->mcc, laid->mnc, laid->lac);
+   printf("  Encoded %s\n", osmo_hexdump((unsigned char*), 
sizeof(lai)));
+   rc = gsm48_decode_lai(, , , );
+   if (rc) {
+   printf("  gsm48_decode_lai() returned %d --> FAIL\n", rc);
+   return;
+   }
+   printf("  gsm48_decode_lai() gives  "); dump_ra();
+   if (decoded.mcc == laid->mcc
+   && decoded.mnc == laid->mnc
+   && decoded.lac == laid->lac)
+   printf("  passed\n");
+   else
+   printf("  FAIL\n");
+}
+
 static struct gprs_ra_id test_ra_cap_items[] = {
{
.mcc = 77,
@@ -192,6 +219,15 @@
 
for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++)
check_ra(_ra_cap_items[i]);
+}
+
+static void test_lai_encode_decode(void)
+{
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++) {
+   check_lai(_ra_cap_items[i]);
+   }
 }
 
 static void test_mid_from_tmsi(void)
@@ -229,6 +265,7 @@
test_mid_from_tmsi();
test_mid_from_imsi();
test_ra_cap();
+   test_lai_encode_decode();
 
return EXIT_SUCCESS;
 }
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index dc19eea..7612c12 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -22,3 +22,19 @@
 MCC+MNC in BCD: 99 99 99 
 999-999-65535-255
 RA test...passed
+- gsm48_generate_lai() from 077-121-666-0
+  Encoded 70 17 21 02 9a 
+  gsm48_decode_lai() gives  077-121-666-0
+  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_lai() from 000-00-0-0
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai() gives  000-00-0-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

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd6cee090464bc92b654332904a9a08edf16e5c9
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


[PATCH] libosmocore[master]: cosmetic: gsm0408_test: RA test cases as array-of-struct

2018-02-21 Thread Neels Hofmeyr

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

cosmetic: gsm0408_test: RA test cases as array-of-struct

(Preparation for adding 3-digit MNC)

Change-Id: Ic6c645ebf82d5f8d9d51c4c4cc804a0172008156
---
M tests/gsm0408/gsm0408_test.c
1 file changed, 12 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/6654/1

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index ab2dee4..8e6cf2f 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -158,23 +158,27 @@
printf("passed\n");
 }
 
-static void test_ra_cap(void)
-{
-   struct gprs_ra_id raid1 = {
+static struct gprs_ra_id test_ra_cap_items[] = {
+   {
.mnc = 121,
.mcc = 77,
.lac = 666,
.rac = 5,
-   };
-   struct gprs_ra_id raid2 = {
+   },
+   {
.mnc = 98,
.mcc = 84,
.lac = 11,
.rac = 89,
-   };
+   },
+};
 
-   check_ra();
-   check_ra();
+static void test_ra_cap(void)
+{
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++)
+   check_ra(_ra_cap_items[i]);
 }
 
 static void test_mid_from_tmsi(void)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6c645ebf82d5f8d9d51c4c4cc804a0172008156
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


[PATCH] libosmocore[master]: gsm0408_test: cosmetically re-order MCC to come before MNC

2018-02-21 Thread Neels Hofmeyr

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

gsm0408_test: cosmetically re-order MCC to come before MNC

For consistency in human readability, MCC simply should come first, always.

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/55/6655/1

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 8e6cf2f..87f8dde 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("RA: MNC=%u, MCC=%u, LAC=%u, RAC=%u\n", raid->mnc, raid->mcc, 
raid->lac, raid->rac);
+   printf("RA: MCC=%u, MNC=%u, LAC=%u, RAC=%u\n", raid->mcc, raid->mnc, 
raid->lac, raid->rac);
 }
 
 static inline void check_ra(const struct gprs_ra_id *raid)
@@ -160,14 +160,14 @@
 
 static struct gprs_ra_id test_ra_cap_items[] = {
{
-   .mnc = 121,
.mcc = 77,
+   .mnc = 121,
.lac = 666,
.rac = 5,
},
{
-   .mnc = 98,
.mcc = 84,
+   .mnc = 98,
.lac = 11,
.rac = 89,
},
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 76a7940..295d8ec 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -3,10 +3,10 @@
 Simple TMSI encoding testpassed
 Simple IMSI encoding testpassed: [10] 17 08 99 10 07 00 00 00 64 02 
 Constructed RA:
-RA: MNC=121, MCC=77, LAC=666, RAC=5
-RA: MNC=121, MCC=77, LAC=666, RAC=5
+RA: MCC=77, MNC=121, LAC=666, RAC=5
+RA: MCC=77, MNC=121, LAC=666, RAC=5
 RA test...passed
 Constructed RA:
-RA: MNC=98, MCC=84, LAC=11, RAC=89
-RA: MNC=98, MCC=84, LAC=11, RAC=89
+RA: MCC=84, MNC=98, LAC=11, RAC=89
+RA: MCC=84, MNC=98, LAC=11, RAC=89
 RA test...passed

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb86a7088fac4d8a8c41190ab46f9801635f4eee
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Neels Hofmeyr

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

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: I8e722103344186fde118b26d8353db95a4581daa
---
M include/osmocom/bsc/bsc_msc_data.h
M include/osmocom/bsc/gsm_data.h
M src/libbsc/bsc_ctrl_commands.c
M src/libbsc/bsc_init.c
M src/libbsc/bsc_vty.c
M src/libbsc/system_information.c
M src/osmo-bsc/osmo_bsc_api.c
M src/osmo-bsc/osmo_bsc_bssap.c
M src/osmo-bsc/osmo_bsc_ctrl.c
M src/osmo-bsc/osmo_bsc_filter.c
M src/osmo-bsc/osmo_bsc_msc.c
M src/osmo-bsc/osmo_bsc_vty.c
M tests/bssap/bssap_test.err
13 files changed, 124 insertions(+), 65 deletions(-)


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

diff --git a/include/osmocom/bsc/bsc_msc_data.h 
b/include/osmocom/bsc/bsc_msc_data.h
index a3e0106..cbda10d 100644
--- a/include/osmocom/bsc/bsc_msc_data.h
+++ b/include/osmocom/bsc/bsc_msc_data.h
@@ -78,8 +78,9 @@
struct osmo_timer_list pong_timer;
int advanced_ping;
struct bsc_msc_connection *msc_con;
-   int core_mnc;
-   int core_mcc;
+   uint16_t core_mcc;
+   uint16_t core_mnc;
+   bool core_mnc_3_digits;
int core_lac;
int core_ci;
int rtp_base;
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index a8d7a0b..8fc0901 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -1195,6 +1196,8 @@
/* global parameters */
uint16_t country_code;
uint16_t network_code;
+   bool network_code_3_digits;
+
/* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */
uint8_t a5_encryption_mask;
int neci;
@@ -1270,6 +1273,11 @@
} mgw;
 };
 
+static inline const char *gsmnet_mcc_mnc_name(struct gsm_network *net)
+{
+   return osmo_mcc_mnc_name2(net->country_code, net->network_code, 
net->network_code_3_digits);
+}
+
 extern void talloc_ctx_init(void *ctx_root);
 
 int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
diff --git a/src/libbsc/bsc_ctrl_commands.c b/src/libbsc/bsc_ctrl_commands.c
index 41d2361..cac3ba9 100644
--- a/src/libbsc/bsc_ctrl_commands.c
+++ b/src/libbsc/bsc_ctrl_commands.c
@@ -22,6 +22,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -75,6 +76,10 @@
 
if (!mcc || !mnc)
return 1;
+
+   if (gsm48_mnc_from_str(mnc, NULL, NULL))
+   return 1;
+
return 0;
 }
 
@@ -82,7 +87,8 @@
 {
struct gsm_network *net = cmd->node;
char *tmp, *saveptr, *mcc_str, *mnc_str;
-   int mcc, mnc;
+   uint16_t mcc, mnc;
+   bool mnc_3_digits;
 
tmp = talloc_strdup(cmd, cmd->value);
if (!tmp)
@@ -93,16 +99,22 @@
mnc_str = strtok_r(NULL, ",", );
 
mcc = atoi(mcc_str);
-   mnc = atoi(mnc_str);
+   if (gsm48_mnc_from_str(mnc_str, , _3_digits)) {
+   cmd->reply = "Error while decoding MNC";
+   return CTRL_CMD_ERROR;
+   }
 
talloc_free(tmp);
 
-   if (net->network_code == mnc && net->country_code == mcc) {
+   if (!gsm48_mnc_cmp(net->network_code, net->network_code_3_digits,
+  mnc, mnc_3_digits)
+   && net->country_code == mcc) {
cmd->reply = "Nothing changed";
return CTRL_CMD_REPLY;
}
 
net->network_code = mnc;
+   net->network_code_3_digits = mnc_3_digits;
net->country_code = mcc;
 
return set_net_apply_config(cmd, data);
diff --git a/src/libbsc/bsc_init.c b/src/libbsc/bsc_init.c
index 2b1d53b..04a8ef5 100644
--- a/src/libbsc/bsc_init.c
+++ b/src/libbsc/bsc_init.c
@@ -326,9 +326,10 @@
unsigned int i;
 
LOGP(DRSL, LOGL_NOTICE, "bootstrapping RSL for BTS/TRX (%u/%u) "
-   "on ARFCN %u using MCC=%u MNC=%u LAC=%u CID=%u BSIC=%u\n",
-   trx->bts->nr, trx->nr, trx->arfcn, bsc_gsmnet->country_code,
-   bsc_gsmnet->network_code, trx->bts->location_area_code,
+   "on ARFCN %u using MCC-MNC %s LAC=%u CID=%u BSIC=%u\n",
+   trx->bts->nr, trx->nr, trx->arfcn,
+   gsmnet_mcc_mnc_name(bsc_gsmnet),
+   trx->bts->location_area_code,
trx->bts->cell_identity, trx->bts->bsic);
 
if (trx->bts->type == GSM_BTS_TYPE_NOKIA_SITE) {
diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 36c849d..1f13606 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -194,9 +194,8 @@
struct pchan_load pl;
int i;
 
-   vty_out(vty, "BSC is on Country Code %u, Network Code %u 

[PATCH] osmo-bsc[master]: pcu_if: implement support for 3-digit MNC -- TODO

2018-02-21 Thread Neels Hofmeyr

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

pcu_if: implement support for 3-digit MNC -- TODO

I am actually unsure how this one relates to the pcuif of osmo-bts and
osmo-pcu, if at all. Pushing this for review to probe the community for the
proper counterpart of this.

Change-Id: I78f30aef7aa224b2e9db54c3a844d8f520b3aee0
---
M include/osmocom/bsc/pcuif_proto.h
M src/libbsc/pcu_sock.c
2 files changed, 5 insertions(+), 2 deletions(-)


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

diff --git a/include/osmocom/bsc/pcuif_proto.h 
b/include/osmocom/bsc/pcuif_proto.h
index eb28d66..2e3f782 100644
--- a/include/osmocom/bsc/pcuif_proto.h
+++ b/include/osmocom/bsc/pcuif_proto.h
@@ -1,7 +1,7 @@
 #ifndef _PCUIF_PROTO_H
 #define _PCUIF_PROTO_H
 
-#define PCU_IF_VERSION 0x08
+#define PCU_IF_VERSION 0x09
 
 /* msg_type */
 #define PCU_IF_MSG_DATA_REQ0x00/* send data to given channel */
@@ -106,7 +106,9 @@
struct gsm_pcu_if_info_trx trx[8];  /* TRX infos per BTS */
uint8_t bsic;
/* RAI */
-   uint16_tmcc, mnc, lac, rac;
+   uint16_tmcc, mnc;
+   uint8_t mnc_3_digits;
+   uint16_tlac, rac;
/* NSE */
uint16_tnsei;
uint8_t nse_timer[7];
diff --git a/src/libbsc/pcu_sock.c b/src/libbsc/pcu_sock.c
index 9f1c80c..0075a93 100644
--- a/src/libbsc/pcu_sock.c
+++ b/src/libbsc/pcu_sock.c
@@ -154,6 +154,7 @@
/* RAI */
info_ind->mcc = bts->network->country_code;
info_ind->mnc = bts->network->network_code;
+   info_ind->mnc_3_digits = bts->network->network_code_3_digits;
info_ind->lac = bts->location_area_code;
info_ind->rac = bts->gprs.rac;
 

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

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


[PATCH] osmo-bsc[master]: use gsm48_ra_id instead of buf

2018-02-21 Thread Neels Hofmeyr

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

use gsm48_ra_id instead of buf

Change-Id: I0d3908fb8ca1e2e669d257b5d59b40675fa85d06
---
M include/osmocom/bsc/abis_nm.h
M include/osmocom/bsc/gsm_data.h
M src/libbsc/abis_nm.c
M src/libbsc/bts_ipaccess_nanobts_omlattr.c
M src/libbsc/gsm_data.c
5 files changed, 9 insertions(+), 10 deletions(-)


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

diff --git a/include/osmocom/bsc/abis_nm.h b/include/osmocom/bsc/abis_nm.h
index 18f87cd..d6b7084 100644
--- a/include/osmocom/bsc/abis_nm.h
+++ b/include/osmocom/bsc/abis_nm.h
@@ -157,7 +157,7 @@
uint8_t *attr, uint8_t attr_len);
 int abis_nm_ipaccess_rsl_connect(struct gsm_bts_trx *trx, 
 uint32_t ip, uint16_t port, uint8_t stream);
-void abis_nm_ipaccess_cgi(uint8_t *buf, struct gsm_bts *bts);
+void abis_nm_ipaccess_cgi(struct gsm48_ra_id *buf, struct gsm_bts *bts);
 int ipac_parse_bcch_info(struct ipac_bcch_info *binf, uint8_t *buf);
 const char *ipacc_testres_name(uint8_t res);
 
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 07e5478..a8d7a0b 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -1348,7 +1348,7 @@
 const char *bts_gprs_mode_name(enum bts_gprs_mode mode);
 int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode);
 
-int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts);
+void gsm48_ra_id_by_bts(struct gsm48_ra_id *buf, struct gsm_bts *bts);
 void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
 
 int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum 
gsm_bts_features feat);
diff --git a/src/libbsc/abis_nm.c b/src/libbsc/abis_nm.c
index 671c874..393fb7a 100644
--- a/src/libbsc/abis_nm.c
+++ b/src/libbsc/abis_nm.c
@@ -2848,12 +2848,12 @@
 attr, attr_len);
 }
 
-void abis_nm_ipaccess_cgi(uint8_t *buf, struct gsm_bts *bts)
+void abis_nm_ipaccess_cgi(struct gsm48_ra_id *buf, struct gsm_bts *bts)
 {
-   /* we simply reuse the GSM48 function and overwrite the RAC
-* with the Cell ID */
+   /* we simply reuse the GSM48 function and write the Cell ID over the 
position where the RAC
+* starts */
gsm48_ra_id_by_bts(buf, bts);
-   *((uint16_t *)(buf + 5)) = htons(bts->cell_identity);
+   *((uint16_t*)>rac) = htons(bts->cell_identity);
 }
 
 void gsm_trx_lock_rf(struct gsm_bts_trx *trx, bool locked, const char *reason)
diff --git a/src/libbsc/bts_ipaccess_nanobts_omlattr.c 
b/src/libbsc/bts_ipaccess_nanobts_omlattr.c
index 926322c..4347132 100644
--- a/src/libbsc/bts_ipaccess_nanobts_omlattr.c
+++ b/src/libbsc/bts_ipaccess_nanobts_omlattr.c
@@ -101,7 +101,7 @@
 
msgb_tv_put(msgb, NM_ATT_BSIC, bts->bsic);
 
-   abis_nm_ipaccess_cgi(buf, bts);
+   abis_nm_ipaccess_cgi((struct gsm48_ra_id*)buf, bts);
msgb_tl16v_put(msgb, NM_ATT_IPACC_CGI, 7, buf);
 
return msgb;
diff --git a/src/libbsc/gsm_data.c b/src/libbsc/gsm_data.c
index a504252..e18c528 100644
--- a/src/libbsc/gsm_data.c
+++ b/src/libbsc/gsm_data.c
@@ -277,13 +277,12 @@
raid->rac = bts->gprs.rac;
 }
 
-int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts)
+void gsm48_ra_id_by_bts(struct gsm48_ra_id *buf, struct gsm_bts *bts)
 {
struct gprs_ra_id raid;
 
gprs_ra_id_by_bts(, bts);
-
-   return gsm48_construct_ra(buf, );
+   gsm48_encode_ra(buf, );
 }
 
 int gsm_parse_reg(void *ctx, regex_t *reg, char **str, int argc, const char 
**argv)

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

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


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

2018-02-21 Thread Neels Hofmeyr

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

implement support for 3-digit MNC with leading zeros

Receive the mnc_3_digits flag from the PCU interface. Bump the PCU interface
version from 7 to 9 to match osmo-bts (see
I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 there).

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),
 I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 (osmo-bts)

Change-Id: I787fed84a7b613158a5618dd5cffafe4e4927234
---
M include/osmocom/pcu/pcuif_proto.h
M src/gprs_bssgp_pcu.cpp
M src/gprs_bssgp_pcu.h
M src/pcu_l1_if.cpp
M src/pcu_main.cpp
M tests/alloc/AllocTest.cpp
M tests/alloc/MslotTest.cpp
M tests/edge/EdgeTest.cpp
M tests/emu/pcu_emu.cpp
M tests/fn/FnTest.cpp
M tests/llc/LlcTest.cpp
M tests/ms/MsTest.cpp
M tests/tbf/TbfTest.cpp
M tests/types/TypesTest.cpp
14 files changed, 40 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/66//1

diff --git a/include/osmocom/pcu/pcuif_proto.h 
b/include/osmocom/pcu/pcuif_proto.h
index 39103ee..2b4b15c 100644
--- a/include/osmocom/pcu/pcuif_proto.h
+++ b/include/osmocom/pcu/pcuif_proto.h
@@ -5,7 +5,7 @@
 
 #define PCU_SOCK_DEFAULT   "/tmp/pcu_bts"
 
-#define PCU_IF_VERSION 0x07
+#define PCU_IF_VERSION 0x09
 #define TXT_MAX_LEN128
 
 /* msg_type */
@@ -105,7 +105,9 @@
struct gsm_pcu_if_info_trx trx[8];  /* TRX infos per BTS */
uint8_t bsic;
/* RAI */
-   uint16_tmcc, mnc, lac, rac;
+   uint16_tmcc, mnc;
+   uint8_t mnc_3_digits;
+   uint16_tlac, rac;
/* NSE */
uint16_tnsei;
uint8_t nse_timer[7];
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 3cc86e2..6727735 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -44,6 +44,7 @@
 
 extern void *tall_pcu_ctx;
 extern uint16_t spoof_mcc, spoof_mnc;
+extern bool spoof_mnc_3_digits;
 
 static void bvc_timeout(void *_priv);
 
@@ -876,15 +877,11 @@
 struct gprs_bssgp_pcu *gprs_bssgp_create_and_connect(struct gprs_rlcmac_bts 
*bts,
uint16_t local_port, uint32_t sgsn_ip,
uint16_t sgsn_port, uint16_t nsei, uint16_t nsvci, uint16_t bvci,
-   uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac,
+   uint16_t mcc, uint16_t mnc, bool mnc_3_digits, uint16_t lac, uint16_t 
rac,
uint16_t cell_id)
 {
struct sockaddr_in dest;
int rc;
-
-   mcc = ((mcc & 0xf00) >> 8) * 100 + ((mcc & 0x0f0) >> 4) * 10 + (mcc & 
0x00f);
-   mnc = ((mnc & 0xf00) >> 8) * 100 + ((mnc & 0x0f0) >> 4) * 10 + (mnc & 
0x00f);
-   cell_id = ntohs(cell_id);
 
/* if already created... return the current address */
if (the_pcu.bctx)
@@ -930,7 +927,13 @@
return NULL;
}
the_pcu.bctx->ra_id.mcc = spoof_mcc ? : mcc;
-   the_pcu.bctx->ra_id.mnc = spoof_mnc ? : mnc;
+   if (spoof_mnc) {
+   the_pcu.bctx->ra_id.mnc = spoof_mnc;
+   the_pcu.bctx->ra_id.mnc_3_digits = spoof_mnc_3_digits;
+   } else {
+   the_pcu.bctx->ra_id.mnc = mnc;
+   the_pcu.bctx->ra_id.mnc_3_digits = mnc_3_digits;
+   }
the_pcu.bctx->ra_id.lac = lac;
the_pcu.bctx->ra_id.rac = rac;
the_pcu.bctx->cell_id = cell_id;
diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h
index 4eda57d..4127244 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -77,7 +77,7 @@
 struct gprs_bssgp_pcu *gprs_bssgp_create_and_connect(struct gprs_rlcmac_bts 
*bts,
uint16_t local_port,
uint32_t sgsn_ip, uint16_t sgsn_port, uint16_t nsei,
-   uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc,
+   uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc, bool 
mnc_3_digits,
uint16_t lac, uint16_t rac, uint16_t cell_id);
 
 void gprs_bssgp_destroy(void);
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 664a7b7..85dbfb9 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -408,6 +408,7 @@
int rc = 0;
unsigned int trx, ts;
int i;
+   uint16_t cell_id = ntohs(info_ind->cell_id);
 
if (info_ind->version != PCU_IF_VERSION) {
fprintf(stderr, "PCU interface version number of BTS (%d) is "
@@ -434,11 +435,11 @@
exit(0);
}
LOGP(DL1IF, LOGL_INFO, "BTS available\n");
-   LOGP(DL1IF, LOGL_DEBUG, " mcc=%x\n", info_ind->mcc);
-   LOGP(DL1IF, LOGL_DEBUG, " mnc=%x\n", info_ind->mnc);
+   LOGP(DL1IF, LOGL_DEBUG, " mcc=%03u\n", info_ind->mcc);
+   LOGP(DL1IF, LOGL_DEBUG, " mnc=%0*u\n", info_ind->mnc_3_digits, 
info_ind->mnc);
LOGP(DL1IF, LOGL_DEBUG, " 

[PATCH] libosmocore[master]: GSM_MNC_INVALID

2018-02-21 Thread Neels Hofmeyr

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

GSM_MNC_INVALID

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/64/6664/1

diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h
index 37c421d..7c32cfb 100644
--- a/include/osmocom/gsm/gsm48.h
+++ b/include/osmocom/gsm/gsm48.h
@@ -11,6 +11,10 @@
 /* reserved according to GSM 03.03 § 2.4 */
 #define GSM_RESERVED_TMSI   0x
 
+/* Valid MCC and MNC range from 0 to 999.
+ * To mark an invalid / unset MNC, this value shall be used. */
+#define GSM_MCC_MNC_INVALID 0x
+
 /* A parsed GPRS routing area */
 struct gprs_ra_id {
uint16_tmcc;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieee7add0bd6d94cf84743a49794bbcd38561b72f
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Neels Hofmeyr

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

implement support for 3-digit MNC with leading zeros

Record the mnc_3_digits flag from SI and pass on via the PCU interface.

Bump the PCU interface version from 7 to 9, since osmo-bsc.git had a pcuif of
version 8 already, and its addition of the mnc_3_digits flag bumped to 9. I am
actually not sure whether this needs to match.
See I78f30aef7aa224b2e9db54c3a844d8f520b3aee0

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore)
Change-Id: I49cd762c3c9d7ee6a82451bdf3ffa2a060767947
---
M include/osmo-bts/gsm_data.h
M include/osmo-bts/pcuif_proto.h
M src/common/pcu_sock.c
3 files changed, 7 insertions(+), 10 deletions(-)


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

diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 853b445..0f2f75a 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -30,6 +30,7 @@
struct llist_head bts_list;
unsigned int num_bts;
uint16_t mcc, mnc;
+   bool mnc_3_digits;
struct pcu_sock_state *pcu_state;
 };
 
diff --git a/include/osmo-bts/pcuif_proto.h b/include/osmo-bts/pcuif_proto.h
index 88dc09e..5eb5e20 100644
--- a/include/osmo-bts/pcuif_proto.h
+++ b/include/osmo-bts/pcuif_proto.h
@@ -3,7 +3,7 @@
 
 #include 
 
-#define PCU_IF_VERSION 0x07
+#define PCU_IF_VERSION 0x09
 #define TXT_MAX_LEN128
 
 /* msg_type */
@@ -103,7 +103,9 @@
struct gsm_pcu_if_info_trx trx[8];  /* TRX infos per BTS */
uint8_t bsic;
/* RAI */
-   uint16_tmcc, mnc, lac, rac;
+   uint16_tmcc, mnc;
+   uint8_t mnc_3_digits;
+   uint16_tlac, rac;
/* NSE */
uint16_tnsei;
uint8_t nse_timer[7];
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index fa13f24..9e84170 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -145,6 +145,7 @@
/* RAI */
info_ind->mcc = net->mcc;
info_ind->mnc = net->mnc;
+   info_ind->mnc_3_digits = net->mnc_3_digits;
info_ind->lac = bts->location_area_code;
info_ind->rac = bts->gprs.rac;
 
@@ -254,14 +255,7 @@
break;
si3 = (struct gsm48_system_information_type_3 *)
bts->si_buf[SYSINFO_TYPE_3];
-   net->mcc = ((si3->lai.digits[0] & 0x0f) << 8)
-   | (si3->lai.digits[0] & 0xf0)
-   | (si3->lai.digits[1] & 0x0f);
-   net->mnc = ((si3->lai.digits[2] & 0x0f) << 8)
-   | (si3->lai.digits[2] & 0xf0)
-   | ((si3->lai.digits[1] & 0xf0) >> 4);
-   if ((net->mnc & 0x00f) == 0x00f)
-   net->mnc >>= 4;
+   gsm48_mcc_mnc_from_bcd2(si3->lai.digits, >mcc, >mnc, 
>mnc_3_digits);
bts->location_area_code = ntohs(si3->lai.lac);
bts->cell_identity = si3->cell_identity;
avail_lai = 1;

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

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


[PATCH] libosmocore[master]: gsm0408_test: RA test: include min/max value cases

2018-02-21 Thread Neels Hofmeyr

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

gsm0408_test: RA test: include min/max value cases

(Preparation for adding 3-digit MNC)

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/57/6657/1

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index aa6a8be..ad45507 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -172,6 +172,18 @@
.lac = 11,
.rac = 89,
},
+   {
+   .mcc = 0,
+   .mnc = 0,
+   .lac = 0,
+   .rac = 0,
+   },
+   {
+   .mcc = 999,
+   .mnc = 999,
+   .lac = 65535,
+   .rac = 255,
+   },
 };
 
 static void test_ra_cap(void)
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index a3d801d..dc19eea 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -12,3 +12,13 @@
 MCC+MNC in BCD: 80 f4 89 
 084-98-11-89
 RA test...passed
+Constructed RA:
+000-00-0-0
+MCC+MNC in BCD: 00 f0 00 
+000-00-0-0
+RA test...passed
+Constructed RA:
+999-999-65535-255
+MCC+MNC in BCD: 99 99 99 
+999-999-65535-255
+RA test...passed

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifbc167de0cc039858112677b8d0cd14a2c8af086
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Neels Hofmeyr

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

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(-)


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

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: newchange
Gerrit-Change-Id: I89765613d8c5bd939a6957f7443ac88475f1b93c
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Neels Hofmeyr

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/2

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index c40c643..2591442 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -233,6 +233,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,
@@ -240,6 +250,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 be2a1de..59484c3 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-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-0 (3-digit MNC)
+  Encoded 00 00 00 00 00 
+  gsm48_decode_lai2() gives  000-000-0-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-0 (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-0
+  Encoded 00 f1 20 00 17 
+  gsm48_decode_lai2() gives  001-02-23-0
+  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-0 (3-digit MNC)
+  Encoded 00 21 00 00 17 
+  gsm48_decode_lai2() gives  001-002-23-0 (3-digit MNC)
+  passed
+- gsm48_generate_lai() from 012-34-56-0
+  Encoded 10 f2 43 00 38 
+  gsm48_decode_lai() gives  012-34-56-0
+  passed
+- gsm48_generate_lai2() from 012-34-56-0
+  Encoded 10 f2 43 00 38 
+  gsm48_decode_lai2() gives  012-34-56-0
+  passed
+- 

[PATCH] libosmocore[master]: gsm: add gsm48_mnc_from_str() and gsm48_mnc_cmp(), for 3-dig...

2018-02-21 Thread Neels Hofmeyr

gsm: add gsm48_mnc_from_str() and gsm48_mnc_cmp(), for 3-digit MNC

gsm48_mnc_from_str() preserves leading zeros in the string and is useful for
VTY config parsing.

gsm48_mnc_cmp() will be used by osmo-sgsn.git

Change-Id: Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6
---
M include/osmocom/gsm/gsm48.h
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
3 files changed, 63 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/6663/2

diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h
index 9d312c2..37c421d 100644
--- a/include/osmocom/gsm/gsm48.h
+++ b/include/osmocom/gsm/gsm48.h
@@ -63,3 +63,7 @@
 void gsm48_mcc_mnc_to_bcd2(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc, bool 
mnc_3_digits);
 void gsm48_mcc_mnc_from_bcd(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc);
 void gsm48_mcc_mnc_from_bcd2(uint8_t *bcd_src, uint16_t *mcc, uint16_t *mnc, 
bool *mnc_3_digits);
+
+int gsm48_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits);
+
+int gsm48_mnc_cmp(uint16_t a_mnc, bool a_mnc_3_digits, uint16_t b_mnc, bool 
b_mnc_3_digits);
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index 122f7ea..be2a976 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -530,6 +530,63 @@
}
 }
 
+/* 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 gsm48_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits)
+{
+   uint16_t _mnc = 0;
+   bool _mnc_3_digits = false;
+   char *endptr;
+   int rc = 0;
+
+   if (!mnc_str || !isdigit(mnc_str[0])) {
+   /* 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;
+   _mnc_3_digits = strlen(mnc_str) > 2;
+
+   if (mnc)
+   *mnc = _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 gsm48_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;
+}
+
 /*! Encode TS 04.08 Location Area Identifier, legacy implementation.
  * Instead use gsm48_generate_lai2(), which is capable of three-digit MNC with 
leading zeros.
  *  \param[out] caller-provided memory for output
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 917eab2..9e3de75 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -272,6 +272,8 @@
 osmo_mcc_mnc_name;
 osmo_mcc_mnc_name2;
 osmo_rai_name;
+gsm48_mnc_from_str;
+gsm48_mnc_cmp;
 gsm48_chan_mode_names;
 gsm_chan_t_names;
 gsm48_pdisc_names;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Neels Hofmeyr

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(-)


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

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: newpatchset
Gerrit-Change-Id: I89765613d8c5bd939a6957f7443ac88475f1b93c
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Neels Hofmeyr

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, 45 insertions(+), 0 deletions(-)


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

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 9e552ab..c40c643 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -187,6 +187,34 @@
printf("  FAIL\n");
 }
 
+static inline void check_lai2(const struct gprs_ra_id *raid)
+{
+   int rc;
+   struct gsm48_loc_area_id lai = {};
+   struct gprs_ra_id decoded = {};
+   struct gprs_ra_id _laid = *raid;
+   struct gprs_ra_id *laid = &_laid;
+   laid->rac = 0;
+
+   printf("- gsm48_generate_lai2() from "); dump_ra(laid);
+
+   gsm48_generate_lai2(, laid->mcc, laid->mnc, laid->mnc_3_digits, 
laid->lac);
+   printf("  Encoded %s\n", osmo_hexdump((unsigned char*), 
sizeof(lai)));
+   rc = gsm48_decode_lai2(, , , 
_3_digits, );
+   if (rc) {
+   printf("  gsm48_decode_lai2() returned %d --> FAIL\n", rc);
+   return;
+   }
+   printf("  gsm48_decode_lai2() gives  "); dump_ra();
+   if (decoded.mcc == laid->mcc
+   && decoded.mnc == laid->mnc
+   && decoded.lac == laid->lac
+   && decoded.mnc_3_digits == (laid->mnc_3_digits || laid->mnc > 99))
+   printf("  passed\n");
+   else
+   printf("  FAIL\n");
+}
+
 static struct gprs_ra_id test_ra_cap_items[] = {
{
.mcc = 77,
@@ -228,6 +256,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..be2a1de 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-0
+  Encoded 70 17 21 02 9a 
+  gsm48_decode_lai2() gives  077-121-666-0 (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-0
+  Encoded 80 f4 89 00 0b 
+  gsm48_decode_lai2() gives  084-98-11-0
   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-0
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai2() gives  000-00-0-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-0
+  Encoded 99 99 99 ff ff 
+  gsm48_decode_lai2() gives  999-999-65535-0 (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: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 


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

2018-02-21 Thread Pau Espin Pedrol

Patch Set 4:

(2 comments)

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

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


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

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


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
Gerrit-PatchSet: 4
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


[PATCH] osmo-mgw[master]: compiler warning: ignore deprecated in mgcp_client_test.c

2018-02-21 Thread Neels Hofmeyr

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

compiler warning: ignore deprecated in mgcp_client_test.c

mgcp_msg_crcx() causes deprecation warning, but it's fine for a unit test
to use deprecated API.

Change-Id: Iba6d0c9c729367e00a9ab7fff7c89007d336e59d
---
M tests/mgcp_client/mgcp_client_test.c
1 file changed, 2 insertions(+), 0 deletions(-)


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

diff --git a/tests/mgcp_client/mgcp_client_test.c 
b/tests/mgcp_client/mgcp_client_test.c
index ef2fca8..68b97ae 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -18,6 +18,8 @@
  * along with this program.  If not, see .
  */
 
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
 #include 
 
 #include 

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

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


[PATCH] osmo-mgw[master]: mgcp_client: show failure by MGCP SDP section parsing test

2018-02-21 Thread Neels Hofmeyr

mgcp_client: show failure by MGCP SDP section parsing test

To show how the current code fails, add test_sdp_section_start() to
mgcp_client_test.c, and temporarily accept failing output. This will be fixed
in change I62a2453cd9e2e7d5408423161fa65ec9c9989f98.

Change-Id: I5c6d3566b8f6dbf04c0cd8b127423f5295c19f8d
---
M tests/mgcp_client/mgcp_client_test.c
M tests/mgcp_client/mgcp_client_test.err
M tests/mgcp_client/mgcp_client_test.ok
3 files changed, 180 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/38/6638/2

diff --git a/tests/mgcp_client/mgcp_client_test.c 
b/tests/mgcp_client/mgcp_client_test.c
index ef2fca8..588b313 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -271,6 +271,111 @@
fprintf(stderr, "%s() done\n", __func__);
 }
 
+struct sdp_section_start_test {
+   const char *body;
+   int expect_rc;
+   struct mgcp_response expect_params;
+};
+
+static struct sdp_section_start_test sdp_section_start_tests[] = {
+   {
+   .body = "",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "\n\n",
+   },
+   {
+   .body = "\r\n\r\n",
+   },
+   {
+   .body = "\n\r\n\r",
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\n"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\r\n\r\n"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\n\r"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\n"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\r\n\r"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\r"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+};
+
+void test_sdp_section_start()
+{
+   int i;
+   int failures = 0;
+
+   for (i = 0; i < ARRAY_SIZE(sdp_section_start_tests); i++) {
+   int rc;
+   struct sdp_section_start_test *t = _section_start_tests[i];
+   struct mgcp_response *r = talloc_zero(ctx, struct 
mgcp_response);
+
+   r->body = talloc_strdup(r, t->body);
+
+   printf("\n%s() test [%d]:\n", __func__, i);
+   fprintf(stderr, "\n%s() test [%d]:\n", __func__, i);
+   fprintf(stderr, "body: \"%s\"\n", osmo_escape_str(r->body, -1));
+
+   rc = mgcp_response_parse_params(r);
+
+   fprintf(stderr, "got rc=%d\n", rc);
+   if (rc != t->expect_rc) {
+   fprintf(stderr, "FAIL: Expected rc=%d\n", t->expect_rc);
+   failures++;
+   }
+   if (rc) {
+   talloc_free(r);
+   continue;
+   }
+
+   fprintf(stderr, "got audio_port=%u\n", 
t->expect_params.audio_port);
+   if (r->audio_port != t->expect_params.audio_port) {
+   fprintf(stderr, "FAIL: Expected audio_port=%u\n", 
t->expect_params.audio_port);
+   failures++;
+   }
+   talloc_free(r);
+   }
+
+   /* Expecting failures due to known bugs, will be resolved in a 
subsequent commit.
+   OSMO_ASSERT(!failures);
+   */
+}
+
 static const struct log_info_cat log_categories[] = {
 };
 
@@ -297,6 +402,7 @@
test_crcx();
test_mgcp_msg();
test_mgcp_client_cancel();
+   test_sdp_section_start();
 
printf("Done\n");
fprintf(stderr, "Done\n");
diff --git a/tests/mgcp_client/mgcp_client_test.err 
b/tests/mgcp_client/mgcp_client_test.err
index 8e9f648..9079c27 100644
--- a/tests/mgcp_client/mgcp_client_test.err
+++ b/tests/mgcp_client/mgcp_client_test.err
@@ -12,4 +12,58 @@
 - canceling again does nothing
 DLMGCP Cannot cancel, no such transaction: 1
 test_mgcp_client_cancel() done
+
+test_sdp_section_start() test [0]:
+body: ""
+got rc=0
+FAIL: Expected rc=-22
+got audio_port=0
+
+test_sdp_section_start() test [1]:
+body: "\n\n"
+got rc=0
+got audio_port=0
+

[PATCH] osmo-mgw[master]: mgcp_client: show failure by MGCP SDP section parsing test

2018-02-21 Thread Neels Hofmeyr

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

mgcp_client: show failure by MGCP SDP section parsing test

To show how the current code fails, add test_sdp_section_start() to
mgcp_client_test.c, and temporarily accept failing output. This will be fixed
in change Ib0d5a9fc3020ff630eb3460209c1317f09254a92.

Change-Id: I5c6d3566b8f6dbf04c0cd8b127423f5295c19f8d
---
M tests/mgcp_client/mgcp_client_test.c
M tests/mgcp_client/mgcp_client_test.err
M tests/mgcp_client/mgcp_client_test.ok
3 files changed, 180 insertions(+), 0 deletions(-)


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

diff --git a/tests/mgcp_client/mgcp_client_test.c 
b/tests/mgcp_client/mgcp_client_test.c
index ef2fca8..588b313 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -271,6 +271,111 @@
fprintf(stderr, "%s() done\n", __func__);
 }
 
+struct sdp_section_start_test {
+   const char *body;
+   int expect_rc;
+   struct mgcp_response expect_params;
+};
+
+static struct sdp_section_start_test sdp_section_start_tests[] = {
+   {
+   .body = "",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "\n\n",
+   },
+   {
+   .body = "\r\n\r\n",
+   },
+   {
+   .body = "\n\r\n\r",
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\n"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\r\n\r\n"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\n\r"
+   "m=audio 23\r\n",
+   .expect_params = {
+   .audio_port = 23,
+   },
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\n"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\r\n\r"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+   {
+   .body = "some mgcp header data\r\nand header params"
+   "\n\r\r"
+   "m=audio 23\r\n",
+   .expect_rc = -EINVAL,
+   },
+};
+
+void test_sdp_section_start()
+{
+   int i;
+   int failures = 0;
+
+   for (i = 0; i < ARRAY_SIZE(sdp_section_start_tests); i++) {
+   int rc;
+   struct sdp_section_start_test *t = _section_start_tests[i];
+   struct mgcp_response *r = talloc_zero(ctx, struct 
mgcp_response);
+
+   r->body = talloc_strdup(r, t->body);
+
+   printf("\n%s() test [%d]:\n", __func__, i);
+   fprintf(stderr, "\n%s() test [%d]:\n", __func__, i);
+   fprintf(stderr, "body: \"%s\"\n", osmo_escape_str(r->body, -1));
+
+   rc = mgcp_response_parse_params(r);
+
+   fprintf(stderr, "got rc=%d\n", rc);
+   if (rc != t->expect_rc) {
+   fprintf(stderr, "FAIL: Expected rc=%d\n", t->expect_rc);
+   failures++;
+   }
+   if (rc) {
+   talloc_free(r);
+   continue;
+   }
+
+   fprintf(stderr, "got audio_port=%u\n", 
t->expect_params.audio_port);
+   if (r->audio_port != t->expect_params.audio_port) {
+   fprintf(stderr, "FAIL: Expected audio_port=%u\n", 
t->expect_params.audio_port);
+   failures++;
+   }
+   talloc_free(r);
+   }
+
+   /* Expecting failures due to known bugs, will be resolved in a 
subsequent commit.
+   OSMO_ASSERT(!failures);
+   */
+}
+
 static const struct log_info_cat log_categories[] = {
 };
 
@@ -297,6 +402,7 @@
test_crcx();
test_mgcp_msg();
test_mgcp_client_cancel();
+   test_sdp_section_start();
 
printf("Done\n");
fprintf(stderr, "Done\n");
diff --git a/tests/mgcp_client/mgcp_client_test.err 
b/tests/mgcp_client/mgcp_client_test.err
index 8e9f648..9079c27 100644
--- a/tests/mgcp_client/mgcp_client_test.err
+++ b/tests/mgcp_client/mgcp_client_test.err
@@ -12,4 +12,58 @@
 - canceling again does nothing
 DLMGCP Cannot cancel, no such transaction: 1
 test_mgcp_client_cancel() done
+
+test_sdp_section_start() test [0]:
+body: ""
+got rc=0
+FAIL: Expected rc=-22
+got audio_port=0
+
+test_sdp_section_start() test [1]:
+body: "\n\n"

[PATCH] osmo-mgw[master]: mgcp_client: detect SDP section-start parsing errors

2018-02-21 Thread Neels Hofmeyr

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

mgcp_client: detect SDP section-start parsing errors

After call to mgcp_find_section_end(), actually check the proper variable to
evaluate its return value.

Show in mgcp_client_test output that the parsing errors are fixed, and enable
the assertion that no tests should fail.

Change-Id: I62a2453cd9e2e7d5408423161fa65ec9c9989f98
---
M src/libosmo-mgcp-client/mgcp_client.c
M tests/mgcp_client/mgcp_client_test.c
M tests/mgcp_client/mgcp_client_test.err
3 files changed, 9 insertions(+), 15 deletions(-)


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

diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index de940c0..e054593 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -262,7 +262,7 @@
 
/* Find beginning of the parameter (SDP) section */
data_ptr = mgcp_find_section_end(data);
-   if (!data) {
+   if (!data_ptr) {
LOGP(DLMGCP, LOGL_ERROR,
 "MGCP response: cannot find start of SDP parameters\n");
rc = -EINVAL;
diff --git a/tests/mgcp_client/mgcp_client_test.c 
b/tests/mgcp_client/mgcp_client_test.c
index 588b313..50e21b5 100644
--- a/tests/mgcp_client/mgcp_client_test.c
+++ b/tests/mgcp_client/mgcp_client_test.c
@@ -371,9 +371,7 @@
talloc_free(r);
}
 
-   /* Expecting failures due to known bugs, will be resolved in a 
subsequent commit.
OSMO_ASSERT(!failures);
-   */
 }
 
 static const struct log_info_cat log_categories[] = {
diff --git a/tests/mgcp_client/mgcp_client_test.err 
b/tests/mgcp_client/mgcp_client_test.err
index 9079c27..7309242 100644
--- a/tests/mgcp_client/mgcp_client_test.err
+++ b/tests/mgcp_client/mgcp_client_test.err
@@ -15,9 +15,8 @@
 
 test_sdp_section_start() test [0]:
 body: ""
-got rc=0
-FAIL: Expected rc=-22
-got audio_port=0
+DLMGCP MGCP response: cannot find start of SDP parameters
+got rc=-22
 
 test_sdp_section_start() test [1]:
 body: "\n\n"
@@ -51,19 +50,16 @@
 
 test_sdp_section_start() test [7]:
 body: "some mgcp header data\r\nand header params\n\r\nm=audio 23\r\n"
-got rc=0
-FAIL: Expected rc=-22
-got audio_port=0
+DLMGCP MGCP response: cannot find start of SDP parameters
+got rc=-22
 
 test_sdp_section_start() test [8]:
 body: "some mgcp header data\r\nand header params\r\n\rm=audio 23\r\n"
-got rc=0
-FAIL: Expected rc=-22
-got audio_port=0
+DLMGCP MGCP response: cannot find start of SDP parameters
+got rc=-22
 
 test_sdp_section_start() test [9]:
 body: "some mgcp header data\r\nand header params\n\r\rm=audio 23\r\n"
-got rc=0
-FAIL: Expected rc=-22
-got audio_port=0
+DLMGCP MGCP response: cannot find start of SDP parameters
+got rc=-22
 Done

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

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


[PATCH] osmo-mgw[master]: mgcp_client: cosmetic: clean up SDP params parsing

2018-02-21 Thread Neels Hofmeyr

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

mgcp_client: cosmetic: clean up SDP params parsing

The mgcp_response_parse_params() is in a jumble. Straighten out these cosmetic
issues:

- Move assertion of r->body close to its first use.
- Instead of a talloc_zero and osmo_strlcpy dance, simply use talloc_strdup().
- Drop the first unused invocation of mgcp_find_section_end().
- Drop unused assignment of data_ptr = data.
- In the log, mention "SDP" to clarify.
- Add a comment clarifying how we skip the section marker.

Change-Id: Icf1df761270777a142bc8ace75f2a10918314f73
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 7 insertions(+), 6 deletions(-)


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

diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index c340303..de940c0 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -251,26 +251,27 @@
 {
char *line;
int rc;
-   OSMO_ASSERT(r->body);
-   char *data = mgcp_find_section_end(r->body);
+   char *data;
char *data_ptr;
 
/* Since this functions performs a destructive parsing, we create a
 * local copy of the body data */
-   data = talloc_zero_size(r, strlen(r->body)+1);
+   OSMO_ASSERT(r->body);
+   data = talloc_strdup(r, r->body);
OSMO_ASSERT(data);
-   data_ptr = data;
-   osmo_strlcpy(data, r->body, strlen(r->body));
 
/* Find beginning of the parameter (SDP) section */
data_ptr = mgcp_find_section_end(data);
if (!data) {
LOGP(DLMGCP, LOGL_ERROR,
-"MGCP response: cannot find start of parameters\n");
+"MGCP response: cannot find start of SDP parameters\n");
rc = -EINVAL;
goto exit;
}
 
+   /* data_ptr now points to the beginning of the section-end-marker; 
for_each_non_empty_line()
+* skips any \r and \n characters for free, so we don't need to skip 
the marker. */
+
for_each_non_empty_line(line, data_ptr) {
if (!mgcp_line_is_valid(line))
return -EINVAL;

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

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


[PATCH] osmo-mgw[master]: mgcp_client: cosmetic: clean up SDP params parsing

2018-02-21 Thread Neels Hofmeyr

mgcp_client: cosmetic: clean up SDP params parsing

The mgcp_response_parse_params() is in a jumble. Straighten out these cosmetic
issues:

- Move assertion of r->body close to its first use.
- Instead of a talloc_zero and osmo_strlcpy dance, simply use talloc_strdup().
- Drop the first unused invocation of mgcp_find_section_end().
- Drop unused assignment of data_ptr = data.
- In the log, mention "SDP" to clarify.
- Add a comment clarifying how we skip the section marker.

Change-Id: Icf1df761270777a142bc8ace75f2a10918314f73
---
M src/libosmo-mgcp-client/mgcp_client.c
1 file changed, 7 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/39/6639/2

diff --git a/src/libosmo-mgcp-client/mgcp_client.c 
b/src/libosmo-mgcp-client/mgcp_client.c
index c340303..de940c0 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -251,26 +251,27 @@
 {
char *line;
int rc;
-   OSMO_ASSERT(r->body);
-   char *data = mgcp_find_section_end(r->body);
+   char *data;
char *data_ptr;
 
/* Since this functions performs a destructive parsing, we create a
 * local copy of the body data */
-   data = talloc_zero_size(r, strlen(r->body)+1);
+   OSMO_ASSERT(r->body);
+   data = talloc_strdup(r, r->body);
OSMO_ASSERT(data);
-   data_ptr = data;
-   osmo_strlcpy(data, r->body, strlen(r->body));
 
/* Find beginning of the parameter (SDP) section */
data_ptr = mgcp_find_section_end(data);
if (!data) {
LOGP(DLMGCP, LOGL_ERROR,
-"MGCP response: cannot find start of parameters\n");
+"MGCP response: cannot find start of SDP parameters\n");
rc = -EINVAL;
goto exit;
}
 
+   /* data_ptr now points to the beginning of the section-end-marker; 
for_each_non_empty_line()
+* skips any \r and \n characters for free, so we don't need to skip 
the marker. */
+
for_each_non_empty_line(line, data_ptr) {
if (!mgcp_line_is_valid(line))
return -EINVAL;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Icf1df761270777a142bc8ace75f2a10918314f73
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-bts[master]: vty: display bts features in vty command show bts

2018-02-21 Thread dexter

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

vty: display bts features in vty command show bts

The VTY command show bts does not display the bts specific
features yet.

- Also display the feature list in snow-bts

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


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

diff --git a/src/common/vty.c b/src/common/vty.c
index 5abc90e..55c1e0f 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -736,6 +736,24 @@
return len;
 }
 
+static void bts_dump_vty_features(struct vty *vty, struct gsm_bts *bts)
+{
+   unsigned int i;
+   bool no_features = true;
+   vty_out(vty, "  Features:%s", VTY_NEWLINE);
+
+   for (i = 0; i < _NUM_BTS_FEAT; i++) {
+   if (gsm_bts_has_feature(bts, i)) {
+   vty_out(vty, "%03u ", i);
+   vty_out(vty, "%-40s%s", 
get_value_string(gsm_bts_features_descs, i), VTY_NEWLINE);
+   no_features = false;
+   }
+   }
+
+   if (no_features)
+   vty_out(vty, "(not available)%s", VTY_NEWLINE);
+}
+
 static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
 {
struct gsm_bts_role_bts *btsb = bts->role;
@@ -788,6 +806,8 @@
vty_out(vty, "%s", VTY_NEWLINE);
}
}
+
+   bts_dump_vty_features(vty, bts);
 }
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I509f2a7bbfa96c70bdfea4ff2488ee371e914620
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 


[PATCH] osmo-bts[master]: bts: use feature list instead of speech codec table

2018-02-21 Thread dexter

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

bts: use feature list instead of speech codec table

osmo-bts has a table of pchan/channel mode combinations for every
bts. This table models the codec capabilitys of the BTS hardware.
However, having the speech codec apabilities modeled inside the
BTS feature list would be much more comfortable and since the
feature list is communicated back to the BSC we would get the
codec capabilities inside the BSC domain as well.

- remove the pchan/channel mode tables
- set speech codec variants for each BTS type
- fix bts_supports_cm so that it queries the feature list

Change-Id: I977dc729ba856631245aedf76afd48eac92166f7
---
M include/osmo-bts/bts.h
M include/osmo-bts/gsm_data.h
M src/common/bts.c
M src/common/rsl.c
M src/osmo-bts-octphy/l1_if.c
M src/osmo-bts-sysmo/main.c
M src/osmo-bts-trx/main.c
M tests/misc/misc_test.c
8 files changed, 53 insertions(+), 79 deletions(-)


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

diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index 2f63e37..4d6e347 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -45,8 +45,8 @@
 
 int bts_main(int argc, char **argv);
 
-int bts_supports_cm(struct gsm_bts_role_bts *bts,
-   enum gsm_phys_chan_config pchan, enum gsm48_chan_mode cm);
+int bts_supports_cm(struct gsm_bts *bts, enum gsm_phys_chan_config pchan,
+   enum gsm48_chan_mode cm);
 
 #endif /* _BTS_H */
 
diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 853b445..4b834b5 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -33,11 +33,6 @@
struct pcu_sock_state *pcu_state;
 };
 
-struct bts_cm {
-   enum gsm_phys_chan_config pchan;
-   enum gsm48_chan_mode cm;
-};
-
 /* data structure for BTS related data specific to the BTS role */
 struct gsm_bts_role_bts {
struct {
@@ -94,7 +89,6 @@
bool rtp_jitter_adaptive;
struct {
uint8_t ciphers;/* flags A5/1==0x1, A5/2==0x2, 
A5/3==0x4 */
-   const struct bts_cm *cm; /* Table with supp. ch rate/mode 
combinations */
} support;
struct {
uint8_t tc4_ctr;
diff --git a/src/common/bts.c b/src/common/bts.c
index 31afba4..7849d61 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -676,32 +676,45 @@
return >gsm_time;
 }
 
-int bts_supports_cm(struct gsm_bts_role_bts *bts,
-   enum gsm_phys_chan_config pchan, enum gsm48_chan_mode cm)
+int bts_supports_cm(struct gsm_bts *bts, enum gsm_phys_chan_config pchan,
+   enum gsm48_chan_mode cm)
 {
-   const struct bts_cm *supported;
-   int i;
+   enum gsm_bts_features feature = _NUM_BTS_FEAT;
 
-   supported = bts->support.cm;
-
-   /* Check if we got a list with supported codec, if not, no list has
-* been configured yet for that BTS. In that case we will just skip
-* and accept any combination */
-   if (supported == NULL)
-   return 1;
-
-   for (i = 0;; i++) {
-   /* If we manage to find the given combination in the list,
-* we know that the pchan/cm combination is supported */
-   if (supported[i].pchan == pchan && supported[i].cm == cm)
-   return 1;
-
-   /* When we hit the terminator, we know that the given
-* pchan/cm combination is not supported because it
-* is not in the list. */
-   if (supported[i].pchan == _GSM_PCHAN_MAX)
+   /* Before the requested pchan/cm combination can be checked, we need to
+* convert it to a feature identifier we can check */
+   if (pchan == GSM_PCHAN_TCH_F) {
+   switch(cm) {
+   case GSM48_CMODE_SPEECH_V1:
+   feature = BTS_FEAT_SPEECH_F_V1;
+   break;
+   case GSM48_CMODE_SPEECH_EFR:
+   feature = BTS_FEAT_SPEECH_F_EFR;
+   break;
+   case GSM48_CMODE_SPEECH_AMR:
+   feature = BTS_FEAT_SPEECH_F_AMR;
+   break;
+   default:
+   /* Invalid speech codec type => Not supported! */
return 0;
+   }
+   } else if (pchan == GSM_PCHAN_TCH_H) {
+   switch(cm) {
+   case GSM48_CMODE_SPEECH_V1:
+   feature = BTS_FEAT_SPEECH_H_V1;
+   break;
+   case GSM48_CMODE_SPEECH_AMR:
+   feature = BTS_FEAT_SPEECH_H_AMR;
+   break;
+   default:
+   /* Invalid speech codec type => Not supported! */
+   return 0;
+   }
}
 
+   /* Check if the feature is supported by this BTS */
+   if (gsm_bts_has_feature(bts, feature))
+   return 1;
+
 

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

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

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

https://gerrit.osmocom.org/6623

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

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

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


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

diff --git a/include/osmocom/ctrl/ports.h b/include/osmocom/ctrl/ports.h
index 4e93190..d6b5394 100644
--- a/include/osmocom/ctrl/ports.h
+++ b/include/osmocom/ctrl/ports.h
@@ -8,6 +8,9 @@
 
 #pragma once
 
+
+#define OSMO_CTRL_PORT_TRX 4236
+/* 4237 used by VTY interface */
 #define OSMO_CTRL_PORT_BTS 4238
 #define OSMO_CTRL_PORT_NITB_BSC4249
 #define OSMO_CTRL_PORT_BSC_NAT 4250
diff --git a/include/osmocom/vty/ports.h b/include/osmocom/vty/ports.h
index 4819b87..5e7e655 100644
--- a/include/osmocom/vty/ports.h
+++ b/include/osmocom/vty/ports.h
@@ -8,6 +8,8 @@
 
 #pragma once
 
+/* 4236 used by control interface */
+#define OSMO_VTY_PORT_TRX  4237
 /* 4238 used by osmo-bts control interface */
 #define OSMO_VTY_PORT_STP  4239
 #define OSMO_VTY_PORT_PCU  4240/* also: osmo_pcap_client */

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

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


[PATCH] osmo-bts[master]: RSL: Properly reject RSL CHAN_NR IE for incompatible PCHAN

2018-02-21 Thread Harald Welte

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

RSL: Properly reject RSL CHAN_NR IE for incompatible PCHAN

If we receive a message for a dedicated channel, whose channel number
structure doesn't match with the physical channel (timeslot) type,
we must properly reject this.  For RSL CHAN ACT it means sending a NACK,
and for all other cases it means sending an RSL ERROR REPORT.

Related: OS#2972, OS#2971
Change-Id: Iebd2571726d1284a7431b3f9b23ad3185e832ed1
---
M src/common/rsl.c
1 file changed, 78 insertions(+), 34 deletions(-)


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

diff --git a/src/common/rsl.c b/src/common/rsl.c
index 2eb0db1..877f5d8 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1,7 +1,7 @@
 /* GSM TS 08.58 RSL, BTS Side */
 
 /* (C) 2011 by Andreas Eversberg 
- * (C) 2011-2014 by Harald Welte 
+ * (C) 2011-2017 by Harald Welte 
  *
  * All Rights Reserved
  *
@@ -135,18 +135,6 @@
  * support
  */
 
-/**
- * Handle GSM 08.58 7 Error Handling for the given input. This method will
- * send either a CHANNEL ACTIVATION NACK, MODE MODIFY NACK or ERROR REPORT
- * depending on the input of the method.
- *
- * TODO: actually make the decision
- */
-static int report_error(struct gsm_bts_trx *trx)
-{
-   return rsl_tx_error_report(trx, RSL_ERR_IE_CONTENT);
-}
-
 static struct gsm_lchan *lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
  const char *log_name)
 {
@@ -159,9 +147,11 @@
return NULL;
}
 
-   if (rc < 0)
+   if (rc < 0) {
LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n",
 gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr);
+   return NULL;
+   }
return lchan;
 }
 
@@ -643,14 +633,16 @@
 }
 
 /* 8.4.3 sending CHANnel ACTIVation Negative ACK */
-static int rsl_tx_chan_act_nack(struct gsm_lchan *lchan, uint8_t cause)
+static int _rsl_tx_chan_act_nack(struct gsm_bts_trx *trx, uint8_t chan_nr, 
uint8_t cause,
+struct gsm_lchan *lchan)
 {
struct msgb *msg;
-   uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
 
-   LOGP(DRSL, LOGL_NOTICE,
-   "%s Sending Channel Activated NACK: cause = 0x%02x\n",
-   gsm_lchan_name(lchan), cause);
+   if (lchan)
+   LOGP(DRSL, LOGL_NOTICE, "%s: ", gsm_lchan_name(lchan));
+   else
+   LOGP(DRSL, LOGL_NOTICE, "0x%02x: ", chan_nr);
+   LOGPC(DRSL, LOGL_NOTICE, "Sending Channel Activated NACK: cause = 
0x%02x\n", cause);
 
msg = rsl_msgb_alloc(sizeof(struct abis_rsl_dchan_hdr));
if (!msg)
@@ -659,9 +651,12 @@
/* 9.3.26 Cause */
msgb_tlv_put(msg, RSL_IE_CAUSE, 1, );
rsl_dch_push_hdr(msg, RSL_MT_CHAN_ACTIV_NACK, chan_nr);
-   msg->trx = lchan->ts->trx;
+   msg->trx = trx;
 
return abis_bts_rsl_sendmsg(msg);
+}
+static int rsl_tx_chan_act_nack(struct gsm_lchan *lchan, uint8_t cause) {
+   return _rsl_tx_chan_act_nack(lchan->ts->trx, gsm_lchan2chan_nr(lchan), 
cause, lchan);
 }
 
 /* Send an RSL Channel Activation Ack if cause is zero, a Nack otherwise. */
@@ -1229,13 +1224,16 @@
 }
 
 /* 8.4.11 MODE MODIFY NEGATIVE ACKNOWLEDGE */
-static int rsl_tx_mode_modif_nack(struct gsm_lchan *lchan, uint8_t cause)
+static int _rsl_tx_mode_modif_nack(struct gsm_bts_trx *trx, uint8_t chan_nr, 
uint8_t cause,
+ struct gsm_lchan *lchan)
 {
struct msgb *msg;
-   uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
 
-   LOGP(DRSL, LOGL_NOTICE, "%s Tx MODE MODIFY NACK (cause = 0x%02x)\n",
-gsm_lchan_name(lchan), cause);
+   if (lchan)
+   LOGP(DRSL, LOGL_NOTICE, "%s: ", gsm_lchan_name(lchan));
+   else
+   LOGP(DRSL, LOGL_NOTICE, "0x%02x: ", chan_nr);
+   LOGPC(DRSL, LOGL_NOTICE, "Tx MODE MODIFY NACK (cause = 0x%02x)\n", 
cause);
 
msg = rsl_msgb_alloc(sizeof(struct abis_rsl_dchan_hdr));
if (!msg)
@@ -1247,11 +1245,15 @@
/* 9.3.26 Cause */
msgb_tlv_put(msg, RSL_IE_CAUSE, 1, );
rsl_dch_push_hdr(msg, RSL_MT_MODE_MODIFY_NACK, chan_nr);
-   msg->lchan = lchan;
-   msg->trx = lchan->ts->trx;
+   msg->trx = trx;
 
return abis_bts_rsl_sendmsg(msg);
 }
+static int rsl_tx_mode_modif_nack(struct gsm_lchan *lchan, uint8_t cause)
+{
+   return _rsl_tx_mode_modif_nack(lchan->ts->trx, 
gsm_lchan2chan_nr(lchan), cause, lchan);
+}
+
 
 /* 8.4.10 MODE MODIFY ACK */
 static int rsl_tx_mode_modif_ack(struct gsm_lchan *lchan)
@@ -2190,6 +2192,52 @@
 pdch_act? "ACT" : "DEACT", rc);
 }
 
+/* handle a message with an RSL CHAN_NR that is incompatible/unknown */
+static int rsl_reject_unknown_lchan(struct msgb *msg)
+{
+   struct abis_rsl_common_hdr *rh = msgb_l2(msg);
+   struct abis_rsl_dchan_hdr *dch;
+   int rc;
+
+   /* 

[PATCH] osmo-bts[master]: RSL: Ensure we don't accept DCHAN messages for CCHAN

2018-02-21 Thread Harald Welte

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

RSL: Ensure we don't accept DCHAN messages for CCHAN

If the Channel Number IE points to a common channel, we cannot
accept such messages in code paths that only process dedicated
channels, such as RLL/DCHAN/IPA.

Related: OS#2972, OS#2971
Change-Id: I43a78bec63aeb36dd67043d237b27fe880209349
---
M src/common/rsl.c
1 file changed, 22 insertions(+), 0 deletions(-)


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

diff --git a/src/common/rsl.c b/src/common/rsl.c
index 877f5d8..001d7e0 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -135,6 +135,16 @@
  * support
  */
 
+/* Is this channel number for a dedicated channel (true) or not (false) */
+static bool chan_nr_is_dchan(uint8_t chan_nr)
+{
+   /* See TS 48.058 9.3.1 */
+   if (chan_nr & 0x80)
+   return false;
+   else
+   return true;
+}
+
 static struct gsm_lchan *lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
  const char *log_name)
 {
@@ -2254,6 +2264,9 @@
}
msg->l3h = (unsigned char *)rh + sizeof(*rh);
 
+   if (!chan_nr_is_dchan(rh->chan_nr))
+   return rsl_reject_unknown_lchan(msg);
+
lchan = lchan_lookup(trx, rh->chan_nr, "RSL rx RLL: ");
if (!lchan) {
LOGP(DRLL, LOGL_NOTICE, "Rx RLL %s for unknown lchan\n",
@@ -2445,6 +2458,9 @@
}
msg->l3h = (unsigned char *)cch + sizeof(*cch);
 
+   if (chan_nr_is_dchan(cch->chan_nr))
+   return rsl_reject_unknown_lchan(msg);
+
msg->lchan = lchan_lookup(trx, cch->chan_nr, "RSL rx CCHAN: ");
if (!msg->lchan) {
LOGP(DRSL, LOGL_ERROR, "Rx RSL %s for unknown lchan\n",
@@ -2497,6 +2513,9 @@
return -EIO;
}
msg->l3h = (unsigned char *)dch + sizeof(*dch);
+
+   if (!chan_nr_is_dchan(dch->chan_nr))
+   return rsl_reject_unknown_lchan(msg);
 
msg->lchan = lchan_lookup(trx, dch->chan_nr, "RSL rx DCHAN: ");
if (!msg->lchan) {
@@ -2596,6 +2615,9 @@
}
msg->l3h = (unsigned char *)dch + sizeof(*dch);
 
+   if (!chan_nr_is_dchan(dch->chan_nr))
+   return rsl_reject_unknown_lchan(msg);
+
msg->lchan = lchan_lookup(trx, dch->chan_nr, "RSL rx IPACC: ");
if (!msg->lchan) {
LOGP(DRSL, LOGL_ERROR, "Rx RSL %s for unknow lchan\n",

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

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


[PATCH] osmo-bts[master]: octphy: ensure all BTS models set features

2018-02-21 Thread dexter

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

octphy: ensure all BTS models set features

Most of the BTS models do not or do register not all of thier
features to the the feature list.

- Update/extend the feature lists for all BTS-Models

Change-Id: I26765a64153368016921c2ac115b1c4aec9bc5e4
---
M src/osmo-bts-litecell15/main.c
M src/osmo-bts-octphy/l1_if.c
M src/osmo-bts-sysmo/main.c
M src/osmo-bts-trx/main.c
M src/osmo-bts-virtual/main.c
5 files changed, 28 insertions(+), 0 deletions(-)


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

diff --git a/src/osmo-bts-litecell15/main.c b/src/osmo-bts-litecell15/main.c
index 97b5359..dcbd9f5 100644
--- a/src/osmo-bts-litecell15/main.c
+++ b/src/osmo-bts-litecell15/main.c
@@ -92,8 +92,14 @@
}
 
gsm_bts_set_feature(bts, BTS_FEAT_GPRS);
+   gsm_bts_set_feature(bts, BTS_FEAT_EGPRS);
gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
gsm_bts_set_feature(bts, BTS_FEAT_AGCH_PCH_PROP);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_EFR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR);
 
bts_model_vty_init(bts);
 
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index dde993d..e5fcd98 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -791,6 +791,11 @@
 
gsm_bts_set_feature(bts, BTS_FEAT_GPRS);
gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
+#if 
defined(cOCTVC1_GSM_LOGICAL_CHANNEL_COMBINATION_ENUM_FCCH_SCH_BCCH_CCCH_SDCCH4_CBCH_SACCHC4)
 && defined(cOCTVC1_GSM_LOGICAL_CHANNEL_COMBINATION_ENUM_SDCCH8_CBCH_SACCHC8)
+   gsm_bts_set_feature(bts, BTS_FEAT_CBCH);
+#endif
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
 
bts_model_vty_init(bts);
 
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index f52ecdd..6118b60 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -94,6 +94,11 @@
gsm_bts_set_feature(bts, BTS_FEAT_EGPRS);
gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
gsm_bts_set_feature(bts, BTS_FEAT_AGCH_PCH_PROP);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_EFR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR);
 
bts_model_vty_init(bts);
 
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 973a611..38bb881 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -120,6 +120,11 @@
 
gsm_bts_set_feature(bts, BTS_FEAT_GPRS);
gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_EFR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR);
 
bts_model_vty_init(bts);
 
diff --git a/src/osmo-bts-virtual/main.c b/src/osmo-bts-virtual/main.c
index 8459107..7815a34 100644
--- a/src/osmo-bts-virtual/main.c
+++ b/src/osmo-bts-virtual/main.c
@@ -61,6 +61,13 @@
btsb = bts_role_bts(bts);
btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3);
 
+   gsm_bts_set_feature(bts, BTS_FEAT_OML_ALERTS);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_V1);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_EFR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_F_AMR);
+   gsm_bts_set_feature(bts, BTS_FEAT_SPEECH_H_AMR);
+
bts_model_vty_init(bts);
 
return 0;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26765a64153368016921c2ac115b1c4aec9bc5e4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 


  1   2   >