Commit Graph

870 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther f9eda7489b tests: Use GNU autotest to execute our tests and compare textual output
The output of make check is looking like this now:

Regression tests.

  1: bits                                            ok
  2: msgfile                                         ok
  3: sms                                             ok
  4: smscb                                           ok
  5: timer                                           FAILED (testsuite.at:38)
  6: ussd                                            FAILED (testsuite.at:44)
2011-11-14 13:35:41 +01:00
Holger Hans Peter Freyther 36a9cdfcd6 git: Ignore vi files (.swp, .swo) 2011-11-14 13:34:45 +01:00
Sylvain Munaut 4cfbae8152 utils: Add declaration back for osmo_osmo_hexdump_nospc
As it turns out, if a project uses the old name but without a declaration,
it'll causes a segfault on 64 bits platform (because of the implicit
int return type which doesn't apply since here it's a pointer).

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-13 23:04:00 +01:00
Pablo Neira Ayuso a71b8eaca7 timer: Better fix to the timer re-scheduling situation
As it turns out, the previous fix didn't cover the case of a
timer X being re-scheduled inside a timer call back expiring at
the same time as the previous X instance.

Written-by: Pablo Neira Ayuso <pablo@gnumonks.org>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-13 10:11:31 +01:00
Sylvain Munaut cc90d494ce gsm/gsm0411_smc: Fix typo
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:52:40 +01:00
Sylvain Munaut 0d9b8ec9d3 include/gsm_04_11: Fix compatibility issue with GSM411_TMR_TC1A
We need to keep the old one for compatibility !

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:52:20 +01:00
Andreas Eversberg c1a91a896f gsm/sms: Rewrite of SMR process, extracted from OpenBSC
The SMR process is used to transfer SMS TPDUs. It is now extracted from
OpenBSC. It includes a real state machine now for easier debugging.

Also it implements the TR1M and TR2M timers. The memory notification
procedure is missing, but not required for network side.

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:37 +01:00
Andreas Eversberg bbf9034eaa gsm/sms: Rewrite of SMC process, extracted from OpenBSC
The SMC process is used to transfer RP frames. It is now extracted from
OpenBSC. It includes a real state machine now for easier debugging.

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:37 +01:00
Andreas.Eversberg d84f47abb3 gsm/sms: Moved utility functions of SMS processing to new gsm0411_utils.c
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:37 +01:00
Andreas Eversberg c626da9f87 gsm/sms: Added DLSMS debugging
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas.Eversberg 153903c8cf gsm/lapdm: Display SAPI in debug message for easier debug
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas.Eversberg 816e178e99 gsm/lapdm: Fix UI frames from BTS->MS have length (B4 format)
This is part of a set of commit to fix LAPDm to handle datalink
connection on ACCH (SAPI 3)

This is required to transfer SMS on SACCH of TCH/f or SDCCH/8 (4).

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas.Eversberg f1f80de007 gsm/lapdm: Fix TA and power level handling in the ACCH header
Timing advance and power level indicated by MS (measurement reports)
and BTS (SI 5/6) are now stored for use at ACCH data link connection.

This is part of a set of commit to fix LAPDm to handle datalink
connection on ACCH (SAPI 3)

This is required to transfer SMS on SACCH of TCH/f or SDCCH/8 (4).

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas.Eversberg cbed327965 gsm/lapdm: Set N201 depending on the frame type
This is part of a set of commit to fix LAPDm to handle datalink
connection on ACCH (SAPI 3)

This is required to transfer SMS on SACCH of TCH/f or SDCCH/8 (4).

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas.Eversberg 5ac44784b6 gsm/lapdm: Make T200 timer depends on the link type (SACCH is slower)
This is part of a set of commit to fix LAPDm to handle datalink
connection on ACCH (SAPI 3)

This is required to transfer SMS on SACCH of TCH/f or SDCCH/8 (4).

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas.Eversberg a42b699516 gsm/lapdm: Add missing msgb_free in rslms_rx_rll error cases
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas Eversberg 5ad4ac800c lapd: Fixed possible double free buf in lapd_core.c
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas.Eversberg f948dbc442 vty: Fixed vty_down_level to move down from config nodes
When using ^D at config nodes above the CONFIG_NODE, the
go_parent_cb function is used to go down by one node. This
is equivalent to "exit" command.

Written-by: Andreas.Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Andreas.Eversberg dc3be0a653 vty/telnet_interface: Add telnet_exit function
This frees socket and pending connections

Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:36 +01:00
Sylvain Munaut aeeb7070f8 core/timer: Allow an already scheduled timer to be re-scheduled at a new time
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:35 +01:00
Sylvain Munaut 54187ba442 core/rbtree: remove redundant if()-condition in rb_erase()
See kernel commit 4b324126e0c6c3a5080ca3ec0981e8766ed6f1ee

----
Furthermore, notice that the initial checks:

        if (!node->rb_left)
                child = node->rb_right;
        else if (!node->rb_right)
                child = node->rb_left;
        else
        {
                ...
        }
guarantee that old->rb_right is set in the final else branch, therefore
we can omit checking that again.

Signed-off-by: Wolfram Strepp <wstrepp@gmx.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
----

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:35 +01:00
Sylvain Munaut a83cbe12f8 core/rbtree: make clear distinction between two different cases in rb_erase()
See kernel commit 4c60117811171d867d4f27f17ea07d7419d45dae

----
There are two cases when a node, having 2 childs, is erased:
'normal case': the successor is not the right-hand-child of the node to be erased
'special case': the successor is the right-hand child of the node to be erased

Here some ascii-art, with following symbols (referring to the code):
O: node to be deleted
N: the successor of O
P: parent of N
C: child of N
L: some other node

normal case:

               O                         N
              / \                       / \
             /   \                     /   \
            L     \                   L     \
           / \     P      ---->      / \     P
                  / \                       / \
                 /                         /
                N                         C
                 \                       / \
                  \
                   C
                  / \

special case:
              O|P                        N
              / \                       / \
             /   \                     /   \
            L     \                   L     \
           / \     N      ---->      /       C
                    \                       / \
                     \
                      C
                     / \

Notice that for the special case we don't have to reconnect C to N.

Signed-off-by: Wolfram Strepp <wstrepp@gmx.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
----

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:35 +01:00
Sylvain Munaut b8c5bdefcd core/rbtree: reorganize code in rb_erase() for additional changes
See kernel commit 16c047add3ceaf0ab882e3e094d1ec904d02312d

----
First, move some code around in order to make the next change more
obvious.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Wolfram Strepp <wstrepp@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
----

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:35 +01:00
Sylvain Munaut 0395c6e7c4 core/rbtree: optimize rb_erase()
See kernel commit 55a63998b8967615a15e2211ba0ff3a84a565824

----
Tfour 4 redundant if-conditions in function __rb_erase_color() in
lib/rbtree.c are removed.

In pseudo-source-code, the structure of the code is as follows:

if ((!A || B) && (!C || D)) {
        .
        .
        .
} else {
        if (!C || D) {//if this is true, it implies: (A == true) && (B == false)
                if (A) {//hence this always evaluates to 'true'...
                        .
                }
                .
                //at this point, C always becomes true, because of:
                __rb_rotate_right/left();
                //and:
                other = parent->rb_right/left;
        }
        .
        .
        if (C) {//...and this too !
                .
        }
}

Signed-off-by: Wolfram Strepp <wstrepp@gmx.de>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrea Arcangeli <andrea@qumranet.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
----

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:35 +01:00
Sylvain Munaut 2179f402e0 core/rbtree: add const qualifier to some functions
See kernel commit f4b477c47332367d35686bd2b808c2156b96d7c7

----
The 'rb_first()', 'rb_last()', 'rb_next()' and 'rb_prev()' calls
take a pointer to an RB node or RB root. They do not change the
pointed objects, so add a 'const' qualifier in order to make life
of the users of these functions easier.

Indeed, if I have my own constant pointer &const struct my_type *p,
and I call 'rb_next(&p->rb)', I get a GCC warning:

warning: passing argument 1 of ?~@~Xrb_next?~@~Y discards qualifiers from pointer target type

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
----

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-12 23:23:35 +01:00
Sylvain Munaut e55ae3ae1c core/utils: Add a symbol alias for a previous typo for compatibility
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-11 23:06:55 +01:00
Sylvain Munaut ff23d24972 utils: Fix a bad double osmo_ prefix for osmo_hexdump_nospc
Hopefully no project where using them it seems

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-10 23:03:18 +01:00
Holger Hans Peter Freyther 3ec5047c6b freebsd: Provide a dummy backtrace implementation that does nothing 2011-11-09 12:18:55 +01:00
Holger Hans Peter Freyther 4772348b4f freebsd: Fixes for the compilation of libosmocore on FreeBSD
alloca.h is not available on FreeBSD, use the default autoconf
function to check for it, there is a complete list[1] of what to
do for using alloca but let us see how far we get with this test.

Include netinet/in.h for the IPv4 and IPv6 socket address. Check
for dlopen in libraries and use this instead of linking -dl.

[1] http://www.gnu.org/s/hello/manual/autoconf/Particular-Functions.html
2011-11-09 11:56:56 +01:00
Holger Hans Peter Freyther 887934e28d gb_proxy: Make sure each parameter has some sort of documentation 2011-11-06 21:41:51 +01:00
Sylvain Munaut 07f1103782 timer: Add compatibility header with timer helpers
Some of these are not always present, especially when cross compiling

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-21 21:55:29 +02:00
Sylvain Munaut dec48005cc core: Fix include path to use top_builddir as well for generated headers
With the new generated headers for the CRC code, we need to include
the builddir as well in case we're building out of tree.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-21 21:23:05 +02:00
Sylvain Munaut 0061dedaae timer: Simplify osmo_timers_nearest even more
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-18 20:11:03 +02:00
Sylvain Munaut 955fdb039e timer: Fix implementation of osmo_timers_nearest causing high CPU load
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-17 23:03:57 +02:00
Harald Welte 16df917131 Merge branch 'pablo_timer' 2011-10-17 13:30:56 +02:00
Harald Welte 4a0a163d81 bump major library version / breaking the ABI with the rb_tree timers 2011-10-17 13:26:52 +02:00
Pablo Neira Ayuso 9ebc5056b4 tests: add new torture test for timer infrastructure
This is a new test for the timer infrastructure. It basically consists
of adding 2^N timers per step (where N is the number of step) that
expire in (random() % 10) + 1 seconds. Moreover, we randomly delete
timers that fulfill (random() % 100) < 10 everytime one timer expires.

The default number of steps is 16, the test also allows to check for
timer imprecisions (currently, defaulting to 10ms as aceptable).

The list-based implementation crashes or it seems loop forever with
this test (I guess due to some memory corruption).

BTW, this patch contains one cosmetic clean up since we go back to
8-chars per indentations, which seems to be the policy in osmocom.
2011-10-17 13:25:29 +02:00
Pablo Neira Ayuso 066c912fd3 timer: add scalable RB-tree based timer infrastructure
This patch adds RB-tree based timers which scales better than the
previous list-based implementation.

It does not require any API changes. It breaks ABI because the
osmo_timer_list structure has changed though (to avoid this in
the future, we can put internal data in some private structure).

The following table summarizes the worst-case computational complexity
of this new implementation versus the previous one:

                                rb-tree         list-based
                                -------         ----------
calculate next timer to expire  O(1)            O(n)
insertion of new timer          O(log n)        O(n)
deletion of timer               O(log n)        O(1)
timer-fired scheduler           O(log n)        O(3n)

The most repeated cases are:

* the calculation of the next timer to expire, that happens in every
  loop of our select function.

* the timer-fired scheduler execution.

This new implementation only loses in the deletion of timer scenario,
this happens because we may need to rebalance the tree after the
removal.

So I think there is some real gain if we have some situation in which
we have to handle lots of timers.
2011-10-17 13:25:29 +02:00
Pablo Neira Ayuso f74db0b33d add rb-tree implementation to libosmocore
This patch adds red black trees implementation to libosmocore.
This data structure is very useful to search for elements in
ordered sets in O(log n) instead of O(n) that lists provide.

The first client of this code will be one follow up patch that
implements rbtree-based timer scheduler.
2011-10-17 13:25:29 +02:00
Jan Engelhardt e2bcaceee6 build: resolve link failure when --disable-talloc is used 2011-10-10 18:10:06 +02:00
Harald Welte 226ef1d143 add header file containing UMA/GAN protocol definitions 2011-10-10 09:21:27 +02:00
Harald Welte 27dc1b130b update .gitignore (crc*gen.[ch], some autotools stuff) 2011-10-10 09:20:19 +02:00
Harald Welte 17f56f385b update LIBVERSION to reflect new API additions 2011-10-10 08:46:40 +02:00
Andreas Eversberg 78122ab568 Added defines to use primitive/operation tuples in switch/case statements 2011-10-10 08:38:58 +02:00
Andreas Eversberg 742fc79d58 LAPD: Moved timer handling into seperate functions 2011-10-10 08:38:58 +02:00
root af48bed556 Split of LAPDm into a core part and a GSM specific part
Instead of mixing together the GSM layer 1 interface and RSL interface
with the implementation of LAPD, the core function of LAPD is now
extracted from LAPDm. The core implementation is now in lapd_core.c
and lapd_core.h respectively.

The lapd_core.c implements exactly one datalink instance for one SAP.
The surrounding implementation "lapdm.c" codes/decodes the layer 2
headers and handles multiplexing and datalink instances, as well as
translates primitives from/to RSL layer.

lapd_core.c can now be used for other LAPD implementations. (ISDN/ABIS)
2011-10-10 08:38:58 +02:00
root 8a996b4844 Changed logging of LAPD from DLLAPDM to DLLAPD 2011-10-10 08:38:58 +02:00
Sylvain Munaut f84571d0f4 gsmtap: Add type/subtypes for GMR-1 protocol
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-09 16:57:33 +02:00
Harald Welte ccd040f61e GSMTAP: Add comments to explain how to make GSMTAP changes 2011-10-08 14:40:14 +02:00
Harald Welte fae779ac54 GSMTAP: Import changes from Wireshark
There have been some changes in the wireshark source code that have
never been submitted to gsmtap.h

GSMTAP_CHANNEL_PACCH has been defined in an incompatible way in mainline
wirshark :(
2011-10-08 14:40:09 +02:00