Commit Graph

77 Commits

Author SHA1 Message Date
Pau Espin db936b9b55 osmo-trx: Add osmo_signal to stop whole transceiver chain correctly on error
Transceiver::stop() can only be called from either CTRL iface thread or
from main thread (running osmocom loop). That's because stop attempts to
cancel and then join all the other threads, which would then lock if
attempting to stop from some of them.
As a result, the best option is to indicate to the user of the
transceiver option (osmo-trx.cpp) to stop it in a correct fashion by
destroying the object from the main thread.

Change-Id: Iac1d2dbe2328e735db2d4b933cb67b1af1babca1
2018-09-04 16:35:23 +02:00
Pau Espin 86be40b4eb Logger: Disable pthread cancel point inside Logger destructor
pthread_cancel is implemented in c++ using exception handlers. In
destructor of Log object, the log function is called which will
eventually call fputs() to write to a file. Since that function is
considered a cancelation point, if pthread_cancel has been called the
exception handler will start unstacking frames and calling destructors
in the process. At some point this will cause a runtime exception in c++
which will call std::terminate() to abort the process.

The solution is thus to avoid starting the cancellation process inside the
destructor.

This behavior was spotted while calling the destructor of Transceiver
object in forthcoming patches.

See a more detailed example here:
https://skaark.wordpress.com/2010/08/26/pthread_cancel-considered-harmful/

Change-Id: I71ca90f3fbc73df58b878a03361f7b7831d838b4
2018-09-03 15:22:53 +02:00
Pau Espin aae403f0c9 vty: Fix typo in gpsdo clock reference type
Change-Id: I3f553c2cec9689524728cacb15b7daaff8166925
2018-08-27 16:50:19 +02:00
Harald Welte 5cc8858d8f logging: Introduce new "DDEV" category for device-specific code
The DMAIN category got too overloaded.  Let's have the code in
Transceive52M/device/* use the new DDEV category.

Also, in some cases the log levels have been adjusted to ensure
that enabling INFO level should not result in a complete overflow
of messages during normal operation.

Change-Id: I844fe4a75bf277cd3cc5bd8fa06e06ad97b2ea95
2018-08-17 19:57:40 +02:00
Harald Welte 03b3c30533 Fix config file saving of {tx,rx}-path VTY config strings
We were missing one indent level when writing the rx-path and tx-path

Change-Id: I5d5b02c71d39220cabc2a23d059908ef3c6350e0
Closes: OS#3435
2018-07-31 15:48:18 +02:00
Pau Espin c7a0bf1ffc lms: Several improvements and compilation/runtime fixes
Continuation of initial work done on LimeSuite support from Harald.

Change-Id: Ib2fca81b76d027b08e2891056fa076d071597783
2018-06-13 21:45:32 +00:00
Vadim Yanitskiy 01eea0aa42 trx_vty.c: fix: use CONFIG_NODE as parent by default
There are some configuration nodes, which are handled by extenral
libraries, such as libosmoctrl. So, when switching back to the
parent node, this should be kept in mind.

Instead of aborting, let's got to the CONFIG_NODE by default.

Fixes: OS#3250
Change-Id: Ia0600a46d19825806e5aed9257b6c57c3907808b
2018-05-09 15:19:56 +07:00
Pau Espin 478f82f47e build: Fix make distcheck
Change-Id: I1fa5e34b44331cd56408ea7ad4483dcf6443b259
2018-04-27 11:34:11 +02:00
Pau Espin 3b78cbfdc1 Logger: Print correct source file and line number
Before this commit, always Logger.cpp:53 was being printed.

Change-Id: Ie5c64b4961c7c41d23484784a93eda5e08331f08
2018-04-25 16:45:34 +02:00
Pau Espin a3ab8c263d vty: Implement VTY cfg parsing for current parameters
At this stage, osmo-trx still uses the cmdline parameters top run the
device, but it is already able to parse all the same parameters from a
cfg file through the VTY and filling a trx_ctx structure which will be
later used to drive the device. Device config can be printed in the VTY
with "show trx".

Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
2018-03-05 19:55:02 +01:00
Pau Espin efac20b6bb Move enums required by VTY to a separate header
This patch is a preparation for next patches, which add full VTY cfg
support.

Change-Id: I3d5b0576aa96869756f1629a40306c0043b6304b
2018-03-05 17:16:05 +01:00
Pau Espin 3da1f8352e Logger: Use libosmocore logging system
We still need an intermediate class Logger due to osmo-trx being
multi-threaded and requiring to have a lock to use libosmocore, which is
not thread safe.

Change-Id: I30baac89f53e927f8699d0586b43cccf88ecd493
2018-02-27 07:11:11 +00:00
Pau Espin 5ea1817dc2 Add initial support for logging, vty, ctrl
Up to this point, the logging system, vty and ctrl are initialized and
can be used fine, though they don't have a lot of use yet.

Depends on libosmocore Change-Id Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9

Related: OS#2184

Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
2018-02-27 07:10:50 +00:00
Pau Espin 61837c0420 Logger: Remove gLogToConsole flag
No code is using it and we always lock to console anyways.

Change-Id: I5fde99c6af5a845e635b5d27abab855682071f14
2018-02-20 20:32:27 +01:00
Pau Espin f83e11fefd Logger: Remove unused includes
Change-Id: I4d26c0b4f36ee3c66ed1a9e2e9fa2fa8272da16d
2018-02-20 20:32:27 +01:00
Pau Espin 01aff88ce9 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
2018-02-20 20:32:27 +01:00
Pau Espin 11d50d950c 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
2018-02-20 20:32:21 +01:00
Pau Espin 8bd111c942 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
2018-02-20 18:26:45 +01:00
Pau Espin 3808e479aa Logger: Remove unused logging macros
Change-Id: I1133e181183bec8dabe2fa77d0385f783458503f
2018-02-20 18:14:20 +01:00
Pau Espin bd45a979f8 Logger: Drop unused gLogEarly
Change-Id: I2c8f24fbf453e0a94d7a95c3df7cc75f0e4bd456
2018-02-20 18:14:20 +01:00
Pau Espin 89be118a3b Remove unneeded libdl dependency
Closes: OS#1929

Change-Id: I0caea2a2a8e6bd07432fd73bae72b42b1ce022cd
2018-01-23 18:15:24 +00:00
Pau Espin 8639fee504 Remove UDDSocket class
This class is not used anymore in osmo-trx, so we can safely remove it.

Change-Id: I67f90aa3d6a2a5e92292436d10928e0705c8f8ff
2018-01-11 20:17:43 +01:00
Pau Espin 2edbe4d366 Sockets.cpp: Fix initialization of UDD socket
Without this line, destination address for a UDD socket is left with
incorrect value AF_UNSPEC. Later on when calling DatagramSocket:write(),
sendto() fails with EINVAL.

This commit fixes test SocketsTest.cpp.

Change-Id: I6e1b7e743a781abdcf69aa9842b30be893633433
2018-01-10 11:29:16 +01:00
Pau Espin 2ac788b2c3 Set up GNU Autotest infrastructure
Test files are moved from CommonLibs/ to tests/CommonLibs/.
Some tests are disabled in autotest because they generate timedate
related output which cannot exactly match against expected output.

Change-Id: I3d6ba625968be09297642d18090c496490e9b8fc
2018-01-10 11:17:32 +01:00
Pau Espin caf2abc58f Remove Configuration module and libsqlite dependency
Change-Id: I823aea91367d586507bbf352f1b6f25bdd635baa
2018-01-09 15:26:50 +01:00
Pau Espin de1685f6d7 Drop use of ConfigurationTable gConfig
After latest changes, it is not being used anymore.

Change-Id: I43a49aee94e3239194ad9742fb6374324acac0de
2018-01-09 15:26:50 +01:00
Pau Espin f3837d26f9 Logger: Stop using Log.File and Log.Level from config
This is a required step towards getting rid of ConfigurationTable class
and libsqlite dependency.

As a side effect, support for different log levels for different files
is dropped, but it's not something really being used and we will end up
dropping current logging system in favour of osmocom's one in the future
anyway.

Change-Id: I51cb12d1ab7e103e78190ac71a70fb5bb1d9ff51
2018-01-09 15:26:49 +01:00
Pau Espin ddf4743306 Logger: Stop using Log.Alarms.Max from config
This is a first step towards removing ConfigurationTable class and
sqlite3 dependency.

Change-Id: Idcd789afe668a5c0271352f1d20d2efda826213a
2018-01-09 15:26:49 +01:00
Pau Espin 82f83ced73 cosmetic: Remove trailing whitespace
Change-Id: I64c8dbad3fc42bcb8dd4ac9b16bbd9c59a0cf5d5
2018-01-09 15:26:49 +01:00
Max d09843c692 Remove unused headers
Change-Id: Idadb17aeb85b011d114ffc1d81c920544bac1989
2018-01-04 14:31:54 +01:00
Harald Welte 1468a5c3dc SocketsTest: Fix printing of non-nul-terminated string
Change-Id: I33d0ddf851d84b81ab5252e3755422170cee54ee
Fixes: Coverity CID#149363
2017-11-07 20:32:09 +00:00
Pau Espin 8c80095017 Add -j option to bind to specific address
Before this patch, the binding of the listening sockets was hardcoded to
a local IP.

Change-Id: I9ba184a1251c823e413a9230943ed263e52142ec
2017-08-16 17:06:54 +02:00
Tom Tsou 87d158cc2d common: Declare explicit Vector move constructor
Vector class already has a semantically odd non-const copy
constructor that serves the same function as a C++11 move
constructor. Make the move constructor semantics explicit
and address Coverity at the same time.

Change-Id: I22e0099abe601b0c59beee808f7560837c6977dd
Fixes: Coverity CID 170738
2017-06-19 17:02:41 +00:00
Alexander Chemeris 082bbbf8fe PRBS: a Pseudo-random binary sequence (PRBS) generator class.
Implemeted with a Galois LFSR for speed and flexibility compared to Fibonacci version.

Aliases for three popular PRBS' are added for convenience - PRBS9, PRBS15 and PRBS64.

Note that we can't test PRBS64 completely, because the sequence is too long to
be generated.

Change-Id: Ib5331ba5d0b5819929541686fdd87905e2177b74
2017-06-08 18:33:47 +00:00
Alexander Chemeris 15f9d95f5f BitVector: Remove Generator class.
It is not used in osmo-trx, because we're not doing FEC or CRC checks.

Change-Id: I1509e785c1187ebdafe5b2518bd298fbbd1cd036
2017-05-30 20:12:58 +00:00
Alexander Chemeris 73dbccda78 Configuration: Variables allocated with 'new' must be freed with 'delete'.
Thank you Valgrind.

Change-Id: I8477e4e37282947f9841cee9002565631ca0c0b6
2017-05-30 19:19:19 +00:00
Tom Tsou 15da7e1f7e Configuration: Fix const and signedness compile warnings
Change-Id: I701559814b2aee6f84f10e612f128da40f6a51c1
2017-04-03 18:55:02 -07:00
Alexander Chemeris f0189c47be vector: Introduce shrink() function to shrink vector size without loosing data.
Change-Id: I9c0ac2715aea1a90c9e6ebcd982522b80a547099
2017-03-24 01:25:06 +00:00
Alexander Chemeris c708816be1 vector: Introduce segmentMove() method to move data inside of a vector.
Change-Id: I2f3f4267b4137a0bc031f27e0f896fba9b9f3433
2017-03-24 01:24:23 +00:00
Alexander Chemeris 38b69871ae BitVector: Convert SoftVector from 0..1 to -1..+1 soft bits.
This makes code simpler and will allow us send -127..127 soft bits towards
osmo-bts instead of 0..255 bits.

Change-Id: I16ecc3d4c829dcf0f619ad995bc9d4a4ed8af0a4
2017-03-22 18:31:22 +00:00
Alexander Chemeris 7db522b6d9 BitVector: Remove convolutional codec - we don't use it in osmo-trx.
Now we have more fexibility in how we represent SoftVector, since we
no longer depend on the particular convolutional codec implementation.

Change-Id: I3006b6a26c5eff59dbe9c034f689961802f1d0d0
2017-03-22 18:31:17 +00:00
Alexander Chemeris ae09b04e26 CommonLibs: Print soft bits with less confidence to console when printing a soft vector.
We use other symbols to show that these bits has less confidence:
o and . for 0 with less confidence
| and ' for 1 with less confidence

Change-Id: I747a17568ee48f1f3163e8dfab2e450af85e6435
2017-03-22 18:31:12 +00:00
Alexander Chemeris 4793f4679b CommonLibs: Remove unused files.
Change-Id: I2bfb45a1c7d01785bdb30204dba38c683a4288a9
2017-03-20 17:32:04 +00:00
Max 2dee3e996e Fix building against sqlite3
* Explicitly check for sqlite3 at configure stage, remove old include
  dir, fix header inclusion.
* Use configure results for linking instead of hardcoded linker option
  for sqlite.
* Add dependency on -dev package for .deb

Change-Id: I6d7f697d67651f02ceb77fc4da4317b64fa47f9e
Fixes: OS#1928
2017-01-26 17:06:06 +01:00
Tom Tsou 2c650a6895 common: Add mandatory length field to UDP receive calls
Current UDP receive reads up to MAX_UDP_LENGTH bytes into the
passed in buffer, which may lead to buffer overflow if the
write buffer is of insufficient size.

Add mandatory length argument to UDP socket receive calls.

Reported-by: Simone Margaritelli <simone@zimperium.com>
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-05-02 17:37:05 -07:00
Tom Tsou d4555f267e common: Restrict UDP binding to localhost only
Reported security vulnerability where control and data UDP
packets can be injected into the transceiver externally due
to socket binding to all interfaces using INADDR_ANY.

Existing socket interface does not allow specifying local
address; only the local port and remote address/port are
arguments.

Restrict socket bind to localhost with INADDR_LOOPBACK. If
external interfaces do need to be used, the API should be
modified to allow specifying the local socket address.

Reported-by: Simone Margaritelli <simone@zimperium.com>
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-05-02 17:35:01 -07:00
Alexander Chemeris a8cf208616 Common: Make sure gLogEarly() log to the same facilities as the normal log. 2016-04-20 12:33:41 -07:00
Alexander Chemeris f84232d30a Common: Get rid of a compilation warning.
debugLogEarly was replaced to an empty space and arguments of the function
became operators, grouped together by ():
Configuration.cpp: In member function 'bool ConfigurationTable::defines(const string&)':
Configuration.cpp:272:28: warning: left operand of comma operator has no effect [-Wunused-value]
   debugLogEarly(LOG_ALERT, "configuration parameter %s not found", key.c_str());
                            ^

This fix removes debugLogEarly together with its arguments.
2016-04-20 12:26:57 -07:00
Alexander Chemeris cc6f79b1c0 Logger: Output ERR log messages to stderr as well.
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2015-07-30 14:24:20 -07:00
Alexander Chemeris 909ffbfd23 Common: Use a scoped lock in the Logger to avoid deadlock on thread cancel.
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2015-07-30 14:14:23 -07:00