Commit Graph

5123 Commits

Author SHA1 Message Date
Max 582e4f6276 Replace magic number with define
Value 4 used as magic number by both OpenBSC and OsmoBTS so it make
sense to add it to shared header. See
ebb483b69a5319e522ba5f713e9cb6f68a814a6a in osmo-bts for details.

Change-Id: I9c6ad68f4c6aa72d39ec7e5a6968b36ec20e79f4
2016-10-18 16:19:33 +02:00
Alexander Couzens fbd96f55fd fix mistypes, spaces and tabs
Change-Id: I651473f638365bbd333c4c80d223cdd023dd2c51
2016-10-14 12:20:25 +00:00
Neels Hofmeyr 39ae17fb69 msgb ctx: use new msgb_talloc_ctx_init(), don't access talloc_msgb_ctx
Drop extern definitions of talloc_msgb_ctx and use msgb_talloc_ctx_init()
instead.

In sgsn_test.c, use a local variable msgb_ctx to do the talloc report
from the return value of msgb_talloc_ctx_init().

Change-Id: I2f9ace855f0ecbdc9adf5d75bcb1a3d666570de4
2016-10-13 13:14:41 +00:00
Neels Hofmeyr 4c2d4ab5db msgb talloc ctx: initialize in all main() scopes
Add msgb_talloc_ctx_init() call to many main() functions still lacking a
msgb talloc context.

Change-Id: Ib0d6751260659cabf18a7ce80680ba2fb4228ea1
2016-10-13 13:14:41 +00:00
Neels Hofmeyr e072da9d2e gtphub_test.c: remove unused include of msgb.h
Change-Id: I7a8003a0e0bff803941d7981ffc07cf78c3ae9a9
2016-10-13 13:14:41 +00:00
Neels Hofmeyr 20436c8506 meas_pcap2db.c: remove unused include of msgb.h
Change-Id: I2197432c9482537bd5cf06a6c4fc912607ffab53
2016-10-13 13:14:41 +00:00
Neels Hofmeyr 30f7310a62 bs11_config: initialize bs11 tall ctx, use instead of bsc ctx
Actually initialize tall_bs11cfg_ctx as named const.

Change-Id: I3b42b29cd1a688cb4c9d1d4e44208509d936e4ef
2016-10-13 13:14:41 +00:00
Neels Hofmeyr 3edd0b03d5 ipaccess-config: initialize root talloc ctx with name
tall_ctx_config is defined but remains NULL. Instead initialize as named
const.

Change-Id: Iec708eda2e4f8eb88b9e5bc5f82f6342709760b1
2016-10-13 13:14:41 +00:00
Max b6591072d8 Log use of incompatible BS-AG-BLKS-RES value
There's "channel-descrption bs-ag-blks-res" vty command which sets
BS-AG-BLKS-RES which might be too high if CCCH is combined with
SDCCHs. Previously proper value was silently enforced. Log this
situation explicitly and add spec reference to the comment.

Change-Id: I53e2b881fc28472d6709f063fb265a4e6a0fffcd
2016-10-13 08:35:24 +00:00
Max 1e646f02f4 DTX DL: use FSM for AMR
- consolidate all DTX-specific things in a separate struct
- rename struct fields to better reflect meaning
- add pointer to DL FSM for AMR
- remove unused flag
- expand buffer to hold cached payload alongside with CMR/CMI

Change-Id: Idac8609faf9b5ced818fde899ccfc6ed0c42e8fd
2016-10-12 11:22:22 +00:00
Neels Hofmeyr 756fb30c8a gsm_trx_name(): don't break if trx is NULL
Just as a general precaution deemed to fit such a convenience function that
lives in libcommon, no actual failure observed.

Change-Id: I8e77fe1abc402469fd037e2fde2f46e2c8114f59
2016-10-10 03:26:36 +02:00
Neels Hofmeyr a6ba6a370b abis_rsl_rx_dchan(): guard against lchan_lookup() returning NULL
Found this by coincidence, no actual failure case was observed.

lchan_lookup() does have a return NULL code path, so we should not blindly use
its returned pointer.

Change-Id: I34ce126d36420b8194c88c0faa865294334a6658
2016-10-10 03:24:09 +02:00
Neels Hofmeyr 5275c152e5 Revert "bsc: count the usage of codec by setting the lchan active"
This reverts commit 38e9ea3f7f.

Introduced a reproducable segfault, because msg->trx is not actually set/used
in the openbsc code paths.

 Program received signal SIGSEGV, Segmentation fault.
 count_codecs (lchan=0x1, bts=<optimized out>) at ../../../src/libbsc/abis_rsl.c:104
 104                             rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CODEC_V1_FR]);
 (gdb) bt
 #0  count_codecs (lchan=0x1, bts=<optimized out>) at ../../../src/libbsc/abis_rsl.c:104
 #1  0x0000000000425661 in abis_rsl_rx_dchan (msg=<optimized out>) at ../../../src/libbsc/abis_rsl.c:1516
 #2  abis_rsl_rcvmsg (msg=0x8143f0) at ../../../src/libbsc/abis_rsl.c:2611
 #3  0x00007ffff71420d0 in handle_ts1_read (bfd=<optimized out>) at ../../src/input/ipaccess.c:271
 #4  ipaccess_fd_cb (bfd=0x815af8, what=1) at ../../src/input/ipaccess.c:386
 #5  0x00007ffff7779b62 in osmo_fd_disp_fds (_eset=0x7fffffffe590, _wset=0x7fffffffe510, _rset=0x7fffffffe490) at ../../src/select.c:149
 #6  osmo_select_main (polling=polling@entry=0) at ../../src/select.c:189
 #7  0x0000000000406fac in main (argc=<optimized out>, argv=0x7fffffffe738) at ../../../src/osmo-nitb/bsc_hack.c:385
2016-10-10 02:33:59 +02:00
Max 2d66bb2099 DTX: add flag for AMR HR P*
Add flag to explicitly track the state of DTX DL for AMR HR whe
SID_FIRST_P1 has been sent to L1 already but no next frame available
yet: this can be followed by SID_FIRST_P2 or SID_FIRST_INH depending on
arrival of voice frame within next 60 ms.

Change-Id: Id28b07b8e83cfe5e84de48a2f124084036580cd4
2016-10-05 05:48:16 +00:00
Max 63c18ca791 DTX: extend SID cache
In addition to RTP payload SID cache got to store CMR/CMI prefix. Extend
the buffer so it can fit in.

Change-Id: Ibd4a63604a82cad3ce65f0752bffefa4b083e1b3
Fixes: Coverity CID#149508
2016-10-05 05:48:11 +00:00
Alexander Couzens 3316397921 gprs/gprs_llc: count UI frames over SAPI in the statistics
Change-Id: I5f38d70e046ce9ca1342e6f862329dc3cded8995
2016-10-04 17:53:21 +02:00
Alexander Couzens 92f552f344 msc: add counters to track call attempts/active/success/failed
active_calls describe all calls in active state.
call.complete Call got terminated by disconnect requested either by MS or MSC.
call.incomplete Call got terminated by any other reason.
call.active Calls reached active state.
Change-Id: I49b93af2e6a0ba16c2fb00b7b83974e8a6a16df3
2016-10-04 01:08:12 +02:00
Alexander Couzens 38e9ea3f7f bsc: count the usage of codec by setting the lchan active
we count the codec when the channel was successful setted up

Change-Id: Ifc8a406a11dce16b9e7f3310841e470545550a2c
2016-10-04 00:55:05 +02:00
Neels Hofmeyr a8f91df851 configure: check for pkg-config presence
Change-Id: I1484fc8b870df6f0aeef0c13078c66d0cfa97e75
2016-10-01 01:01:53 +02:00
Neels Hofmeyr b81031292b build: be robust against install-sh files above the root dir
Explicitly set AC_CONFIG_AUX_DIR.

To reproduce the error avoided by this patch:

  rm install-sh        # in case it was already generated.
  touch ../install-sh  # yes, outside this source tree
  autoreconf -fi

This will produce an error like

  ...
  configure.ac:16: error: required file '../ltmain.sh' not found
  configure.ac:5: installing '../missing'
  src/Makefile.am: installing '../depcomp'
  autoreconf: automake failed with exit status: 1

See also automake (vim `which automake`) and look for 'sub locate_aux_dir'.

Change-Id: I3b6d9ad4e5af44c2bdf3844c7bf8e8517bd61d8e
2016-10-01 01:01:53 +02:00
Philipp Maier ea291e3004 SGSN: Fixing build config
Tests for V.42bis, slhc, llc-xid and sndcp-xid are built and
executed on all build configurations, but are only needed when
the sgsn (gprs) is built. This patch adds conditions check
if the tests mentioned abvove are needed or not.

Change-Id: I6921e6198ea7f99fe5276f91cbc522091853bc4e
2016-09-30 12:42:48 +00:00
Neels Hofmeyr 0867b72055 vty_test_runner.py: fix indents to use spaces, fix vim comment
Most of this file uses four spaces of indenting. Replace all tabs with spaces.

Remove the erratic 'set' from the recently added vim comment at the bottom.

Change-Id: I4273b3314defb1e5b31b509c2ac7d7c6cd6834cf
2016-09-30 12:42:20 +00:00
Neels Hofmeyr 0a45c1e77d vty_test_runner.py: make unittest print all output by default
Add option to TextTestRunner that shows print output on stdout.
It's better to see everything in our jenkins runs and not hide test output.

Change-Id: If4be1ad1c81c9ed4ab9b208b4c6d1e4b2cc8fdd5
2016-09-30 12:42:20 +00:00
Neels Hofmeyr aba82097b6 log CTRL bind only once
After libosmocore 38d232ee5d2ceb045d9ad6d3a23afcb4972523f7 which outputs
'CTRL at <ip> <port>' from ctrl_interface_setup_dynip(), there's no need to log
the CTRL bind here anymore.

Change-Id: I1a874efe365a1ecf8ec37b058215b95b9a635ec2
2016-09-30 03:12:46 +02:00
Neels Hofmeyr c6a44bbab9 fix: send SNDCP XID only on GERAN Gb contexts
Add a condition for GERAN Gb.

SNDCP and IuPS were developed on separate branches, and the merge results in
code trying to use an llme on a UTRAN Iu context where the llme is NULL,
leading to stack corruption upon PDP ctx act.

Change-Id: Ibb20d738c1b64d36630ce8eceb54c33ba4f1b003
2016-09-29 03:24:57 +02:00
Neels Hofmeyr caeb62d7ff vty_test_runner.py: fix nat_msc_test(): socket attach: reduce timeout, retry
In nat_msc_test(), upon socket timeout, retry up to six times. Reduce the
timeout between retries. This should get rid of sporadic test failures that
we've been seeing a lot on jenkins lately.

Raise an exception upon unexpected vty response.

Print more detail to stdout. Since we would actually want as much output as we
can get in a test suite, remove the 'if (verbose)' and just always print the
connection source. unittest is keeping all stdout silent by default anyway.

Change-Id: I2f83eef55592778e54164a90e1eabeb80fb918da
2016-09-28 23:53:24 +02:00
Harald Welte 7e5bb6283d COSMETIC: 'if' is not a function, so there is space before '('
Change-Id: Ic22623dffce998d70a3c67aa6e445de98f558ed7
2016-09-28 00:47:28 +00:00
Neels Hofmeyr 3ea9fece6d cosmetic: bs11: also use ts_is_tch()
Use the recently added ts_is_tch() function instead of an explicit switch to
determine TCH pchan types. This is a cosmetic change since the bs11 does not
support dynamic channels (which was the main motivator behind ts_is_tch()).

Change-Id: Idf8ce51c76a83210fe3d70e18c51bbaffebb8ad5
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 255dbfe655 dyn TS: fix: e1_config.c: switch(pchan) for dyn TS
Add ts_is_tch() in gsm_data_shared.h/.c and use it to replace a switch on the
pchan in e1_config.c.

This patch is not due to an actual observed failure. A general grep for switch
on pchan turned up this instance that doesn't handle dyn TS properly. Hence
this patch is not actually tested with real equipment.

Change-Id: Ide4f156034bab77140d2d9a8c462d68ae6f0d6a6
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 23c3aa37ac dyn TS: fix: abis_om2000: also handle dyn TS as TCH
Add ts2comb() to switch on dyn TS so that dyn TS in TCH mode are also treated
like normal TCH/H or TCH/F pchans. Use ts2comb() instead of pchan2comb().

Change-Id: Iddc51a4409488d91db59228ca66aaab73ce3f1df
2016-09-28 00:28:01 +00:00
Neels Hofmeyr c3f72f63af dyn TS: fix: ts_subslots() for TCH/F_PDCH in PDCH mode
In gsm_data_shared.c, add ts_pchan() to determine actual pchan type for dynamic
and non-dynamic TS.

Use in ts_subslots() to fix the value returned for TCH/F_PDCH in PDCH mode.
Adjust the assertion in channel_test.c accordingly.

Drop GSM_PCHAN_TCH_F_PDCH, which is now handled in ts_pchan().
Explicitly add GSM_PCHAN_PDCH as zero in subslots_per_pchan[] (cosmetic).
Adjust the comment in subslots_per_pchan[].

The fix for the number of subslots affects only one caller: bts_chan_load() in
chan_alloc.c. Before this, it would always include a TCH/F_PDCH in the
load_counter->total, now it is skipped when in PDCH mode. Whether this is the
way bts_chan_load() should handle dynamic TS is a separate discussion, so far
I'm only making sure that the two dyn TS kinds act in the same way:
TCH/F_TCH/H_PDCH is only counted when in TCH mode, and TCH/F_PDCH should match.

Change-Id: Icd6668667ad2be7ad20866ffd185bf3b8711ccd6
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 2afffd5cf6 Revert "bts: extend bts_chan_load to allow counting tch only"
This reverts commit 308cb0719d.

Problems in this commit:

openbsc/src/libbsc/chan_alloc.c:523:   case GSM_PCHAN_TCH_F_PDCH:
This is actually wrong, GSM_PCHAN_TCH_F_PDCH use ts->flags, not ts->dyn below
(due to historical reasons and could be unified).

560:   if (only_count_tch && !chan_is_tch(ts))
This has exactly one effect: it excludes GSM_PCHAN_TCH_F_PDCH when in PDCH
mode, because for all other PDCH (plain PDCH and TCH/F_TCH/H_PDCH in PDCH mode)
below ts_subslots() returns 0 and skips the for() loop. I consider this a bug
in TCH/F_PDCH, to be fixed in an upcoming commit.

I don't see why we need the only_count_tch argument, because this should
normally only count TCH, weren't it for the TCH/F_PDCH bug.

If dyn TS should be counted differently, we should do this in a different way.

Change-Id: I34dbbaf53a800115e3d03bd44028cad675f3b525
2016-09-28 00:28:01 +00:00
Neels Hofmeyr e289a2a86a channel_test: test nr of subslots for dyn pchan, with error
Add test_dyn_ts_subslots() and call from main(). Update channel_test.ok.

This includes erratic assert to show a bug for TCH/F_PDCH in PDCH mode: the nr
of subslots should be the same as for a normal PDCH, i.e. zero. This will be
adjusted along with the fix in an upcoming commit.

Change-Id: I09685be3fb3ed1ead4577b772a9fbc31967980d1
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 8d878e8a28 channel test: prepare to add another test function
Move the main() guts to test_request_chan(), so that I can add another test in
an upcoming commit.

Change-Id: I1349d0f416806416080d4667ad697f7db1ea252d
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 57e8a1fee0 cosmetic: comment typo on e1_config.c
Change-Id: I894adf562670abf26665a1eb09592682ab8b31b5
2016-09-27 09:59:39 +00:00
Philipp Maier 3163f336f2 SLHC: Improving slhc (RFC1144) testcase
- Adding Testcases for  UNCOMPRESSED_TCP and TYPE_IP
- Minor cosmetic changes

Change-Id: I555fa3c9b9f78424102f359ef1c27b290fa9c9e9
2016-09-27 05:52:20 +00:00
Neels Hofmeyr dab3e34d0b log VTY telnet bind only once
After libosmocore 55dc2edc89c1a85187ef8aafc09f7d922383231f which outputs
'telnet at <ip> <port>' from telnet_init_dynif(), there's no need to log the
telnet VTY bind here anymore.

Change-Id: I97a730b28759df1d549a5049f47a3da1c16a3447
2016-09-27 05:00:18 +00:00
Neels Hofmeyr 89d20b60ef vty_test_runner.py: raise exception when MSC socket connection fails
Instead of below error, raise an exception to describe what's happening.

Seen in a jenkins run on https://gerrit.osmocom.org/#/c/945/2:

ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 787, in testBSCreload
    msc = nat_msc_test(self, ip, port)
  File "./vty_test_runner.py", line 1251, in nat_msc_test
    return conn
UnboundLocalError: local variable 'conn' referenced before assignment

Change-Id: Iae26e7345267a21aed0b108b089453832889c9fa
2016-09-26 13:00:35 +02:00
Neels Hofmeyr 23d37c91af cosmetic: vty_test_runner.py: add comment for vim auto settings
Change-Id: I61a0476a0317b011432bb4f6f593cfdcaf1c072b
2016-09-26 13:00:35 +02:00
Neels Hofmeyr a9f2bb5ab8 mscsplit: directly access gsm_network backpointer from gsm_subscriber_connection
The previous commit added a network backpointer to gsm_subscriber_connection.
Use it wherever it makes sense, to skip the step through the bts structure.

In some places, remove local variables that become unused.

Change-Id: I34537025986713291e14c8212a81539b497befd4
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 5e0b0a658f mscsplit: add gsm_network backpointer to gsm_subscriber_connection
We want to be able to use a network backpointer without having to go through a
gsm_bts struct.

This commit adds the network pointer, the subsequent commit applies direct
access to the network structure from gsm_subscriber_connection.

Change-Id: If8870972f1b3e333c2a4cce97cdc95bdee0382a1
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 663debcb90 mscsplit: abis vty: decouple from global bsc_gsmnet variable
Publish gsmnet_from_vty() in openbsc/vty.h and use in the abis VTY functions.

Change-Id: Ib65a18db06b8bc4fc7d56bf56dd64a52cc1cd253
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 43d86bfc94 mscsplit: bsc_vty_init(): decouple from global bsc_gsmnet
Add an explicit gsm_network pointer instead of using the bsc_gsmnet global.
This allows passing a gsm_network struct from the main() scope, which helps to
decouple libmsc from libbsc.

Change-Id: I9e2c0d9c18d4cebb5efb71565ad84df2bc2e0251
2016-09-26 02:25:46 +02:00
Neels Hofmeyr c13e687742 mscsplit: talloc_ctx_init(): decouple from global tall_bsc_ctx
Decouple the talloc context allocations from global tall_bsc_ctx pointer.

It appears that talloc_ctx_init() was intended for general use, since it is
located in libcommon. It is currently used only by osmo-nitb; but the upcoming
osmo-cscn will use it as well.

Instead of defining in osmo-nitb main file, add definition in gsm_data.h.

Change-Id: I168106599b788f586be0ff0af4699b9746c1b103
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 77c8d5ffb5 mscsplit: gsm_network_init(): add explicit root talloc ctx
Decouple the root talloc context from libbsc's global talloc_bsc_ctx.

This allows to define the root talloc ctx from a main() scope, which in turn
helps decouple libmsc from libbsc.

Change-Id: I92f6b47b1eeea2e8f3fba66f25d7e708e5659f8a
2016-09-26 02:25:46 +02:00
Neels Hofmeyr d90fa42dc9 mscsplit: move subscriber conns list into struct gsm_network
Replace the global sub_connections llist with gsm_network.subscr_conns.
Initialize and apply where applicable.

Remove bsc_api_sub_connections(), callers now access gsm_network->subscr_conns
directly.

This allows using the subscr_conns from libmsc without having to link libbsc.

Change-Id: Ice2a7ca04910bcfaaff22539abe68a6349e8631c
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 0ce98c749a mscsplit: bsc_init: don't pass telnet dummy conn
We want to create the telnet for VTY only after reading the config file, and
the dummy_conn was a workaround to be able to do so, but is not needed:
gsmnet_from_vty() used to expect vty->priv to point to a gsm_network struct,
but that is not actually the case anymore. It is using a static pointer to
store the gsm_network struct instead.

Change-Id: I51e7224c5a4cd5baf564bee871cf2fa6e885cda7
2016-09-26 02:25:46 +02:00
Philipp Maier 73f83d533b SNDCP: add V.42bis data compression functionality
- Add compression control for V.42bis Add code to handle compression
   (gprs_sndcp_dcomp.c/h)
 - Add Adjustments in SNDCP
 - Add VTY commands

Change-Id: I6d36cbdf2f5c5f83ca9ba57c70452f02b8582e7e
2016-09-24 03:17:59 +00:00
Philipp Maier d8b45778de V.42bis: integration and unit test
- Edit previously committed V.42bis implementation to function
   outside IAXmodem.
 - Add unit test to verify the correct function of V.42bis

Change-Id: I689413f2541b6def0625ce6bd96f1f488f05f99d
2016-09-24 03:17:59 +00:00
Philipp Maier 0b11db7e9f V.42bis: add sourcecode from IAXmodem (SPANDSP)
V.42bis is a data compression method found in modems. It has also
been specified for GPRS as data compression algorithm.

The implementation has been taken from IAXmodem:

https://sourceforge.net/p/iaxmodem/code/HEAD/tree/
svn checkout svn://svn.code.sf.net/p/iaxmodem/code/ iaxmodem-code
Revision: r36

Change-Id: Iabedece9f97ca944a1e3f747bb073e532c4e9dca
2016-09-24 03:17:59 +00:00
Philipp Maier f1f34360fb SNDCP: add RFC1144 header compression functionality
- Add module to handle compression entities
- Add module to control header compression
- Introduce VTY commands for heade compression configuration
- Add changes in sndcp and llc to integrate header compression

Change-Id: Ia00260dc09978844c2865957b4d43000b78b5e43
2016-09-24 03:17:58 +00:00
Philipp Maier 2c7f83762a RFC1144: integration and unit-test
The previously pushed slhc implementation has been modified to compile
and function outside of the kernel. Also debug log messages were added
and datatypes ware matched. The implementation is now ready to be used

Change-Id: I7a638e88a43b3eb9d006751a03ef2570e36613f0
2016-09-24 03:17:58 +00:00
Philipp Maier b3e116c74d RFC1144: add slhc code from linux kernel
SLHC is an Implementation of RFC1144 TCP/IP header compression. We will need
RFC1144 compression to compress GPRS TCP/IP traffic. The implementation pushed
with this commit was taken from:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
commit 29b4817d4018df78086157ea3a55c1d9424a7cfc

Change-Id: Ied69c143678dc4a64cecc671f5c4dfebe19d8519
2016-09-24 03:17:58 +00:00
Philipp Maier 22611be3d9 SNDCP: add SNDCP-XID encoder/decoder and unit test
The SNDCP-XID (or layer-3 xid) is used to exchange layer-3 parameters
such as compression. The encoder encodes a bytestream that is then
sent as regular XID field from LLC.

We will need the SNDCP-XID to negotiate the parameters for our
upcomming GPRS data and header compression features

Change-Id: If2d63fe2550864cafef3156b1dc0629037c49c1e
2016-09-24 03:17:58 +00:00
Alexander Couzens 308cb0719d bts: extend bts_chan_load to allow counting tch only
Change-Id: I86f1d502649747b6b9aefcb39081b14110e8f494
2016-09-23 02:43:12 +00:00
Neels Hofmeyr 7c359eb4b4 cosmetic fixes in libcommon/talloc_ctx.c
Add copyright notice, remove obsolete include, remove unneeded line break.

Change-Id: I4d06a0323aee5a003b06edd179fc61e1936acae5
2016-09-22 21:11:42 +02:00
Neels Hofmeyr 8ce66fd19e cosmetic: transaction.h: 1 comment typo, 1 whitespace
Change-Id: Ia2629f9d9887b50b25c6996531b7ef518fb33335
2016-09-19 11:51:12 +00:00
Neels Hofmeyr 1e918c3d31 debug log for sms: fix/add
One logged the wrong function name. Add others.

Change-Id: Ied5d8e84d5d192c826bc131be8907eaa55190479
2016-09-18 23:40:06 +02:00
Neels Hofmeyr ffaed9eed2 Sanity fixes for gsm0408_dispatch(): rc, assertions
gsm0408_dispatch() is the main entry point for receiving data from the BSC/RNC
level, so make sure callers pass valid pointers before using them all the way
down the code path (related to CID#93769, a fix before this was refactored).

For unknown/unimplemented packet discriminators, make sure to return error
codes.

Change-Id: Ieec39c74a53ef4dfa971dd935c8c9aa60fef58c1
2016-09-18 23:40:06 +02:00
Neels Hofmeyr 378a492fd9 cosmetic: various comment, whitespace tweaks
Change-Id: I131939cfba4d67d7e2c935341deeb14d09523fee
2016-09-18 23:40:06 +02:00
Neels Hofmeyr 0b607297e6 utils/Makefile.am: remove unused LIBOSMOVTY_CFLAGS
Change-Id: Id1152b105bb7364a06d9720829d39f587242b707
2016-09-18 23:40:04 +02:00
Neels Hofmeyr d1fdefedf1 vty l3 help: fix typo 'comamnds'; fix english s/his//
Change-Id: I6be52bbb69de8aa0a6d57a3a320661ad85fc2cc4
2016-09-18 23:35:49 +02:00
Neels Hofmeyr 6d82c351b9 remove unused bsc_copyright from bsc_vty.c
Change-Id: I281791c0f57ca75ffe14431a3030811b2d224f0b
2016-09-18 23:35:49 +02:00
Neels Hofmeyr ab04fb2d50 properly #include <openbsc/gsm_data.h> from gsm_subscriber.h
Don't use quoted, local include, use <> style include.

Cosmetic: also move stdbool.h include to the top to keep osmocom and openbsc
includes grouped.

Change-Id: Iaa3dc36768f96f6b8c91010a2ba389fdc37f1503
2016-09-18 23:35:49 +02:00
Max 292ec58e67 Modify SI 13 field for control_ack_type
Add vty function to explicitly set use of 4xRACH type of ack message for
PACKET CONTROL ACKNOWLEDGMENT. Previous hardcoded value (use RLC/MAC
control block) is used as a default.

This is handy for debugging issues related to Timing Advance in context
of GPRS.

Change-Id: Ie869ac0a82055110f1e3b875e246750c4e113336
Related: OS#1526
2016-09-17 10:00:58 +00:00
Neels Hofmeyr 2867f883a1 log causing rx event for lchan_lookup errors
Add log_name to lchan_lookup() and pass such from the various RSL rx events
that call it to validate the RSL chan_nr.

Change-Id: Id81e7b8b9c27831923f050a78dfc7d650e687033
2016-09-17 09:58:54 +00:00
Neels Hofmeyr b3d8706bea log: abis_rsl: don't log 'error' when there is no error
The message 'RF Channel Release due error 0' keeps catching my eye because
it says 'error' even though the error code is zero, i.e. no error.
This shall end now.

Change-Id: Ie0b9d62e8ce85a096c963931e0ae5527b8dc490a
2016-09-17 09:58:53 +00:00
Alexander Couzens aa386d29fd sms: change rp err cause of smpp_try_deliver errors
smpp_try_deliver could fail with rc < 0. In such cases don't send the MS the rp
error sms rejected (cause 21). A rejected message should not be sent again. The
spec 04 11 recommends sending cause 41 Temporary failure in unknown cases.

Add also a log message and rate counter for such cases.

Tweaked-By: Neels Hofmeyr <nhofmeyr@sysmocom.de>
Change-Id: Ia03e50ce2bd9a7d1054cc5a6000fd73bd3497c03
2016-09-17 08:45:07 +00:00
Alexander Huemer c2f2ad8a5f Build fixes
Some fixes for build environments where dependencies are installed in
distinct directories.

Change-Id: I38808fd2911747b266ee6fde91187a88dd7ae355
2016-09-15 16:02:18 +02:00
Alexander Huemer 7b6673fa06 Consistenly format variables in */Makefile.am files
Change-Id: Ifa21513c007072314097b7bec188579972dc1694
2016-09-15 15:55:02 +02:00
Alexander Couzens 58f446ca08 gprs/gprs_llc: fix null pointer deref in gprs_llc_rcvmsg
Change-Id: I1f7e1d524042134c93a4f3de599c54d442447512
2016-09-05 13:36:01 +00:00
Alexander Couzens a173566b35 gprs/gsm0408_gprs_force_reattach_oldmsg: check llme before use
Change-Id: I9385655872c4dcf46aa1d18bcc47b84aba2f34f7
2016-09-05 13:36:01 +00:00
Daniel Willmann 21b269f814 IuPS: Change GTP-U endpoint to SGSN in PMM_IDLE and page UE when data arrives
Change-Id: I47b73a40cbdda6b7c31fb2767f74f9f93d84056b
2016-09-02 04:29:36 +02:00
Daniel Willmann c17cdb40b5 IuPS: Introduce function to change PMM state
This is where IuPS will redirect GTP-U endpoints in a subsequent commit.

Also add comprehensive logging of pmm_state transitions.

Change-Id: I7c2cd1abc1805659b01dffffff31c49fe5161086
2016-09-02 04:29:21 +02:00
Daniel Willmann fac9758820 IuPS: GMM Attach: reset MM ctx pending_req
Change-Id: I0df0f3d88085939eb617405e2013ad164eed477b
2016-09-02 04:29:15 +02:00
Daniel Willmann 5b2363ebb2 IuPS: sgsn_mm_ctx: add enum gprs_pmm_state field, track PMM state
Iu needs to page to transfer data in PMM-IDLE state.

Change-Id: Id37778cb9a0328a21c8e8246998ecdb43dd687d8
2016-09-02 04:29:01 +02:00
Daniel Willmann af241727a9 IuPS: RA UPD: make sure to authorize, for Iu Integrity Protection
Change-Id: I2ea2089895f8a8e125ef39d9bef70dafb2b1ce69
2016-09-02 04:28:49 +02:00
Daniel Willmann 1dee2b6e96 IuPS: add GMM Service Request rx and tx
Change-Id: Ib935de22d23a15f449927840d4d59497ce22abbd
2016-09-02 04:28:41 +02:00
Daniel Willmann 3ecfbbba6f IuPS: send Security Mode Command, track the new_key flag.
Change-Id: I0b2593c2df13b79eb36975b0d302e31cfdf8bb09
2016-09-02 04:28:31 +02:00
Daniel Willmann 770f3e32e0 IuPS: dev hack: init hardcoded Ki on ATT REQ
DEVELOPMENT HACK: Our current HLR does not support 3G authentication tokens.  A
new HLR/VLR implementation is being developed. Until it is ready and actual
milenage authentication is properly supported, we are hardcoding a fixed Ki and
use 2G auth.

Change-Id: Ieca45960fa941a3a706c6e479b04b9f2ef89d860
2016-09-02 04:28:16 +02:00
Daniel Willmann 7bc6986f6b IuPS: add Iu response to delete_pdp_conf()
Change-Id: I6d601586101c0a004b2243633fab48db82b44b7c
2016-09-01 23:44:45 +02:00
Daniel Willmann 6b7b319d54 IuPS: add Iu response to create_pdp_conf()
Change-Id: Iad65ca9b77c3166d4df9a58af527e6aef7e589ee
2016-09-01 23:44:45 +02:00
Daniel Willmann 61329d45b8 IuPS: redirect Iu in various places, link Iu in sgsn-test
In gsm48_gmm_sendmsg(), redirect to iu_tx() for both cases of MM context
present or not.

In gsm48_rx_gmm_att_req(), compose an MM context marked as Iu for messages
coming in from a ue_conn_ctx (passed in msg->dst). Also make sure cid is
initialized to avoid introducing a compiler warning.

In gsm48_rx_gmm_ra_upd_req(), look up an Iu MM context based on the presence of
the ue_conn_ctx in msg->dst.

In sgsn-test, add libiu and libasn1c, libosmo-sigtran, libosmo-ranap, which are
now needed for an --enable-iu build.

Change-Id: Ia47ffbfa6fa0f5a0cd76a379c57ef42faa0d80e3
2016-09-01 23:44:45 +02:00
Daniel Willmann 6292c8d44d IuPS: osmo-sgsn: add core IuPS impl, call iu_init()
Add main Iu entry points for IuPS:
* gsm0408_gprs_rcvmsg_iu()
* sgsn_ranap_iu_event()
* sgsn_ranap_rab_ass_resp()

Add main MM context management for IuPS:
* sgsn_mm_ctx_by_ue_ctx()
* sgsn_mm_ctx_alloc_iu()

Call iu_init() from sgsn_main.c.

Add asn_debug impl ("extern" from libasn1c).
Initialize asn_debug VTY command (iu_vty_init()).

osmo-sgsn build: add libiu and libasn1c, libosmo-sigtran, libosmo-ranap

Change-Id: I469ae6ca9ef254d04ee0d2d79bdd65aebcd027b5
2016-09-01 23:41:10 +02:00
Neels Hofmeyr 9bc42ec47b IuPS: add VTY config for asn_debug
Add file iu_vty.c in libiu, and iu_vty_init() to initialize the new VTY
command:

  log
   logging asn1-debug (1|0)

Change-Id: If4e7d0ab3fc2ed0cdf4fb0a3fa077a9e34890918
2016-08-31 11:11:07 +00:00
Harald Welte 7e82ad20fa osmo-nitb: generate backtrace on SIGABRT
As the NITB has an internal SIGABRT handler that prints a talloc report,
let's also print a stack backtrace at the same point.

Change-Id: Ia63aa5c39b26e27c3ee220d755c17d2c1ef636c5
2016-08-31 11:07:35 +00:00
Alexander Couzens 4b95b5401c bsc/netinit: correct mistyped rate counter
Introduced by b847a21fa4

Change-Id: I57c41f98e3826951a5071b005cb640c23d466477
2016-08-30 14:39:43 +02:00
Alexander Couzens b847a21fa4 libmsc/bsc: split rate counters into bsc and msc group
Tweaked-By: Neels Hofmeyr <nhofmeyr@sysmocom.de>
Change-Id: I7361033cd1eb919ec3c2ea2652f40ab8c75b2f99
2016-08-29 18:56:20 +02:00
Daniel Willmann d75864f6f5 IuPS: track msg->dst aka ue_conn_ctx, comment
For Iu connections, msg->dst will point to the ue_conn_ctx, and we need to make
sure to keep msg->dst intact when copying from/to msgb and from/to MM context.

Change-Id: I90c7ca6c3655d447aaca958e0086ae6ce6f6045a
2016-08-27 13:29:33 +02:00
Daniel Willmann 746c7896cb gprs_gmm: Fix bit mask when determining update/attach type
Bit 4 is reserved in 3GPP TS 04.08 so exclude it from the type.

In 3GPP TS 24.008 it indicates if a follow-on request is pending by the
MS, but only in Iu mode. According to the spec it is not required to
react to that request with a follow-on proceed so this field can be
ignored for now.

See 3GPP TS 24.008 Ch. 4.4:
"Unless it has specific permission from the network (follow-on proceed)
the mobile station side should await the release of the RR connection
used for a MM specific procedure before a new MM specific procedure or
MM connection establishment is started."

as well as Ch. 4.4.4.6:
"If the network wishes to prolong the RR connection to allow the mobile
station to initiate MM connection establishment (for example if the
mobile station has indicated in the LOCATION UPDATING REQUEST that it
has a follow-on request pending) the network shall send "follow on
proceed" in the LOCATION UPDATING ACCEPT and start timer T3255."

Change-Id: If1dff960c406060e257dafc54132687ffc42ad8f
2016-08-27 13:29:33 +02:00
Neels Hofmeyr f4daf16c8d cosmetic: gprs_sgsn.c: move pdp.h include to top
Change-Id: I9a9b34d714235462ba72cdb65b7c8c9824dfa9c6
2016-08-27 13:29:33 +02:00
Neels Hofmeyr bfa8878a07 add libiu
Co-Authored by dwillmann, laforge, nhofmeyr

Change-Id: Iffc26f9c73cb15463948f7435b72ac1747aabdb3
2016-08-27 13:29:30 +02:00
Philipp Maier 4ac3aee711 Adding LLC-XID related modifications in LLC
With this commit the already existing XID mechanism has been
modified to suit the needs for the upcomming SNDCP-XID patches.

This commit should not break anything since it does not alter
the current behaviour (incoming XID is still just echoed, on
GMM-Reset a basic XID message is still echoed)

Change-Id: I65b9d625e72d3d61c99abdc7041773701d694d52
2016-08-27 04:45:55 +00:00
Philipp Maier 3ec03d5048 Moving grs_sndcp.h header file to include
For some reason gprs_sndcp.h is located in src/gprs. This commit moves
gprs_sndcp.h to include/openbsc and fixes the include path in
gprs_sndcp.c and gprs_sndcp_vty.c

Change-Id: If4e4f1252c81d7907c1b4d738c982bb172b128c9
2016-08-27 04:45:55 +00:00
Philipp Maier a536fc644b Adding LLC-XID encoder / decoder and unit test
The lle-xid encoder/decoder is needed to encode and decode llc
xid parameter messages. We need this to exchange sndcp-parameters
(SNDCP-XID) and also simple parameters such as encryption IOVs

Change-Id: Ia06e4cb08bf9b48c2a4682606d1b1a91d19a9d37
2016-08-27 04:45:54 +00:00
Neels Hofmeyr d5d39ae2b6 log: rsl notice: tiny tweak for readability
Change-Id: I57c3b7d27d857c96e3fa3dacf7b766bc43100fc3
2016-08-27 02:23:47 +00:00
Neels Hofmeyr 423269f803 log: improve for rsl_lchan_mark_broken()
In rsl_lchan_mark_broken(), call rsl_lchan_set_state() so the state transition
gets logged in the debug log.

Remove logging for the broken channel at the callers, instead log the error
actually in rsl_lchan_mark_broken() itself, with the reason message passed by
the caller anyway. (Removes code dup and ensures it's always logged.)

Change-Id: I54ae9bbd3f193bae7b1bda1fef3e33e62b353bf5
2016-08-27 02:23:47 +00:00
Neels Hofmeyr baa6c5546e dyn TS: debug log: if still in use, also log lchan type and state
Change-Id: Ifbf31cde24b2d1022b7a472966c17959c96e6dda
2016-08-27 02:23:47 +00:00
Neels Hofmeyr a0a08d80b8 dyn TS: debug log 'switchover complete' only when there was a switchover
Change-Id: I7ddcb41edce1cd7b22fe91e33bdcaedb21856222
2016-08-27 02:23:47 +00:00
Neels Hofmeyr d35fc4408c dyn TS: fix OS#1798: on late RF CHAN REL ACK, activate PDCH
Tested by hacking a REL ACK delay of a couple of seconds into osmo-bts' rsl.c
for the first TCH_H lchan:

[[[
diff --git a/include/osmo-bts/rsl.h b/include/osmo-bts/rsl.h
index 093e9cb..b35c3bb 100644
--- a/include/osmo-bts/rsl.h
+++ b/include/osmo-bts/rsl.h
@@ -22,6 +22,7 @@ int rsl_tx_est_ind(struct gsm_lchan *lchan, uint8_t link_id, uint8_t *data, int
 int rsl_tx_chan_act_acknack(struct gsm_lchan *lchan, uint8_t cause);
 int rsl_tx_conn_fail(struct gsm_lchan *lchan, uint8_t cause);
 int rsl_tx_rf_rel_ack(struct gsm_lchan *lchan);
+int rsl_tx_rf_rel_ack_later(struct gsm_lchan *lchan);
 int rsl_tx_hando_det(struct gsm_lchan *lchan, uint8_t *ho_delay);

 /* call-back for LAPDm code, called when it wants to send msgs UP */
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 3802e25..1f92b0d 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -491,7 +491,16 @@ static int l1sap_info_rel_cnf(struct gsm_bts_trx *trx,

 	lchan = get_lchan_by_chan_nr(trx, info_act_cnf->chan_nr);

-	rsl_tx_rf_rel_ack(lchan);
+	static int yyy = 0;
+
+	DEBUGP(DRSL, "%s YYYYYYYYYYYYYYYYYYYYY %d %s\n",
+	       gsm_lchan_name(lchan), yyy, gsm_lchant_name(lchan->type));
+
+	if (lchan->type == GSM_LCHAN_TCH_H && !yyy) {
+		yyy ++;
+		rsl_tx_rf_rel_ack_later(lchan);
+	} else
+		rsl_tx_rf_rel_ack(lchan);

 	/* During PDCH DEACT, this marks the deactivation of the PDTCH as
 	 * requested by the PCU. Next up, we disconnect the TS completely and
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 3c97af9..7926f21 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -534,6 +534,22 @@ int rsl_tx_rf_rel_ack(struct gsm_lchan *lchan)
 	return abis_bts_rsl_sendmsg(msg);
 }

+struct osmo_timer_list yyy_timer;
+
+static void yyy_timer_cb(void *data)
+{
+	rsl_tx_rf_rel_ack(data);
+}
+
+int rsl_tx_rf_rel_ack_later(struct gsm_lchan *lchan)
+{
+	yyy_timer.cb = yyy_timer_cb;
+	yyy_timer.data = lchan;
+	osmo_timer_schedule(&yyy_timer, 10, 0);
+	return 0;
+}
+
+
 /* 8.4.2 sending CHANnel ACTIVation ACKnowledge */
 static int rsl_tx_chan_act_ack(struct gsm_lchan *lchan)
 {
]]]

Change-Id: I87e07e1d54882f8f3d667fa300c6e3679f5c920d
Fixes: OS#1798
2016-08-27 02:23:47 +00:00
Neels Hofmeyr a2ef7d6477 dyn TS: fix: properly run an lchan activation timeout
Actually schedule an activation timer for the activation part of a dyn TS
switchover. It needs to be restarted because the channel release procedure in
the first part of a switchover actually removes the activation timer.

Change-Id: Ibf50d13ba10298464a8b07e34716763161438990
2016-08-27 02:23:47 +00:00
Neels Hofmeyr b74a2c8e29 dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).

Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.

For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.

Adjust all callers to pass ts instead of lchan.

In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.

In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].

In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.

This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.

Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-27 02:23:47 +00:00
Neels Hofmeyr cd150a8f74 dyn TS: fix error recovery: switch to PDCH after lchan error state
Tested by hacking a CHAN ACT ACK delay of a couple of seconds into osmo-bts'
rsl.c for the first TCH_H lchan:

[[[
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 3c97af9..4bfd27a 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -559,6 +559,22 @@ static int rsl_tx_chan_act_ack(struct gsm_lchan *lchan)
 	return abis_bts_rsl_sendmsg(msg);
 }

+struct osmo_timer_list xxx_timer;
+
+static void xxx_timer_cb(void *data)
+{
+	rsl_tx_chan_act_ack(data);
+}
+
+static int rsl_tx_chan_act_ack_later(struct gsm_lchan *lchan)
+{
+	xxx_timer.cb = xxx_timer_cb;
+	xxx_timer.data = lchan;
+	osmo_timer_schedule(&xxx_timer, 10, 0);
+	return 0;
+}
+
+
 /* 8.4.7 sending HANDOver DETection */
 int rsl_tx_hando_det(struct gsm_lchan *lchan, uint8_t *ho_delay)
 {
@@ -614,6 +630,18 @@ int rsl_tx_chan_act_acknack(struct gsm_lchan *lchan, uint8_t cause)

 	if (cause)
 		return rsl_tx_chan_act_nack(lchan, cause);
+
+	static int xxx = 0;
+
+	DEBUGP(DRSL, "%s XXXXXXXXXXXXXXXXXXXXX %d %s\n",
+	      gsm_lchan_name(lchan), xxx, gsm_lchant_name(lchan->type));
+
+	if (lchan->type == GSM_LCHAN_TCH_H) {
+		if (!xxx) {
+			xxx ++;
+			return rsl_tx_chan_act_ack_later(lchan);
+		}
+	}
 	return rsl_tx_chan_act_ack(lchan);
 }

]]]

Change-Id: Ie82dec9c9fefc476fdf5b5afdad2246b9d6fe304
2016-08-27 02:23:47 +00:00
Neels Hofmeyr 2ae305de46 dyn TS: move check whether to switch to PDCH to separate function
Prepares for an upcoming commit using the same check in error_timeout_cb().

Change-Id: I8abfa964631040f798212cc3e360f67f9e09b7c5
2016-08-27 02:23:47 +00:00
Alexander Couzens 7130683ffe libmsc: add missing count of sms no receiver when using smpp_first
Change-Id: I20ecb3299d67dbaa7b016620685997db49970ffb
2016-08-27 01:58:19 +00:00
Alexander Couzens 20423ea6cf libbsc/libmsc: convert old osmo counter into rate_ctrgs
rate counters support the export to statsd and can have a delta value.

Change-Id: Ie749cebd53a0bb618d0e23d375885712078bf8dd
2016-08-27 01:58:19 +00:00
Alexander Couzens 4e699a9cbf sgsn: add statistics counter for LLC packets
new counters are:

llc.dl_bytes
llc.ul_bytes
llc.dl_packets
llc.ul_packets

The ip payload bytes are waiting for payload compression
because those data are known then.

Change-Id: I068376d35e84283cb98523cd3097a12c55cdb709
2016-08-27 01:27:43 +00:00
Neels Hofmeyr 76a0ad7fe9 move ts_sublots() to gsm_data_shared.c, it will be used by osmo-bts
Change-Id: I8ba06d7dd6e0ceab3d8d18bb565354d6ed461f7e
2016-08-27 01:23:49 +00:00
Neels Hofmeyr 5486025b18 chan_alloc.c: use ts_subslots() instead of subslots_per_pchan[]
The array will move to gsm_data_shared.c; to prepare, use the function
instead.

Change-Id: Icbea7dbd78abf6144e5291f531a97f96507d8cbf
2016-08-27 01:23:49 +00:00
Neels Hofmeyr 3673380cdb dyn TS: bts_chan_load: use correct nr of subslots for dyn ts
For TCH/F_TCH/H_PDCH dynamic timeslots, the ts->pchan does not lead to a
meaningful value from the subslots_per_pchan[] array. Use the ts_subslots()
function instead, which checks for dyn pchan.

Change-Id: I659acebca82dfb3e305433471be64e9d27439af8
2016-08-27 01:23:49 +00:00
Neels Hofmeyr 723f7c7db3 comment: gsm48_gmm_sendmsg(): add spec reference on encryptable
Change-Id: I54a3bc518bc38e38b78f6e9ea3705e4fbd5ffb98
2016-08-22 22:19:13 +00:00
Max 1f6a9ba7e5 Add web proxy for control interface
Add web application exposing Control Interface over web. All of SET, GET
and TRAP are fully supported.

Notice: TRAP is converted into 'Server-sent events' according to RFC
6202, see also https://www.w3.org/TR/eventsource/ - this requires
corresponding client.

Due to use of special prefix modified version of python
eventsource-client is necessary ATM.

Change-Id: I87d40c80061f8b3d02d656ab8cadabbfb871b461
Related: OS#1646
2016-08-11 06:05:39 +00:00
Max dbb6392368 Add python functions to get/set ctrl variables
Add get_var and set_var functions which handle requested variable while
checking for proper response and id. Split header handling into separate
function.

Change-Id: I08705963c277bd93a011193dd7451a626d606c21
Related: OS#1646
2016-08-11 06:05:39 +00:00
Max 2a63d01c1e Use random operation id
According to documentation for Control Interface Protocol <id> is "A
numeric identifier, uniquely identifying this particular operation",
hence it's best to be illustrated with random integer - use it as
default.

Fix override of id with previously used python-specific objects' id.

Change-Id: I32236c067360526f4e7ee4bbdba64c5137de696d
Related: OS#1646
2016-08-11 06:05:39 +00:00
Neels Hofmeyr b6f565c97d gsm_pchan2chan_nr(): fix uninitialized cbits
Commit ec1b5a0e9e introduced an unset cbits
value for the 'special hack for BCCH', where I break out of the switch
without setting cbits. Fix that.

Also remove the comment part that says 'return 0', because I don't return 0.

Change-Id: I54129d921807971eeafc23f80c57666c67b71377
2016-08-10 17:14:53 +02:00
Neels Hofmeyr 2f44693fad gsm_pchan2chan_nr: disable a chan_nr assert in BTS, to not break octphy
In https://gerrit.osmocom.org/589 , msuraev reports an assertion on octphy.
So disable this recently added assertion until we clarify the invocation in
question.

Change-Id: Ia0f7ae5b114e179ab56b98adbae9810e81b4b88f
2016-08-10 17:14:48 +02:00
Harald Welte beca090586 add example config for sysmobts
Many years ago, there was no difference between the libbsc support for
nanobts and sysmobts.  However, this is not the case for a long time
anymore, and there are some specifics in OsmoNITB when it comes to
sysmobts.  Let's have an example config file

Change-Id: I94ae57c9a3cb497ca39d56270fa15ed65d7f147e
2016-08-08 11:29:49 +00:00
Max 3ed214c7b0 Improve code re-use
Introduce explicit __main__ function to facilitate re-use of defined
python functions for ctrl interface.

Change-Id: I9bad8f0dd1d69bd28816bf047d85840e3411bb9c
Related: OS#1646
2016-07-29 18:23:21 +02:00
Neels Hofmeyr 5f0c71b7d5 dyn TS: OS#1778 workaround: disable TCH/F on dyn TS for nitb
To avoid two phones picking mismatching TCH pchans, never pick TCH/F on dynamic
TS in osmo-nitb.

Add gsm_network flag dyn_ts_allow_tch_f, set to true by default in
gsm_network_init().

Set this flag to false in osmo-nitb's main().

See http://osmocom.org/issues/1778

Reasoning about ways to solve this:

* a compile time switch doesn't work because libbsc is first compiled and then
  linked to both osmo-nitb and osmo-bsc.

* we could test net->bsc_api == msc_bsc_api(), but I have the so-called MSC
  split waiting on branch sysmocom/cscn, which will result in msc_bsc_api() not
  being linked in the osmo-bsc binary.

* have a function am_i_nitb() with different implementations in osmo-nitb and
  osmo-bsc, but then we'd need to add implementations to all tests and other
  binaries linking lchan_alloc().

* have a flag in struct bsc_api, but so far there are only function pointers
  there.

Having a "global" flag in gsm_network allows to add a VTY command in case we
decide to keep this feature (#1781), has no linking implications and is nicely
explicit.

Tested that osmo-bsc still picks TCH/F on dyn TS indirectly, since I have no
standalone MSC available: when compiling osmo-nitb with the line that sets
dyn_ts_allow_tch_f = false commented out, TCH/F is picked as described in
OS#1778; and by printf-verifying that dyn_ts_allow_tch_f == true in osmo-bsc
main(), only osmo-nitb should have TCH/F disabled.

Related: OS#1778, OS#1781
Change-Id: If7e4797a72815fc6e2bbef27756ea5df69f4bde7
2016-07-28 17:40:59 +02:00
Neels Hofmeyr c5e75f3e6a dyn TS: Rename bsc_dyn_pdch.c to bsc_dyn_ts.c
It's no longer just for IPAC style TCH/F_PDCH, but also contains code for
TCH/F_TCH/H_PDCH, so pick a more general name.

Change-Id: Ic19db81eca03fd72738839ee3686b6b4c8b6b437
2016-07-28 11:56:51 +02:00
Neels Hofmeyr d3b7fa837d dyn TS: split dyn_pdch_init() for new dyn type and rename
Init both TCH/F_PDCH and TCH/F_TCH/H_PDCH via dyn_ts_init(), which
refactors dyn_pdch_init().

Make dyn_ts_switchover_start from abis_rsl.c public in abis_rsl.h, so we can
start the initial switchover to PDCH from dyn_ts_init(); in abis_rsl.h include
gsm_utils.h for enum gsm_phys_chan_config.

Change-Id: I5c0b257ba8ff0e9c9a2268681a84b0681a778368
2016-07-28 11:56:51 +02:00
Neels Hofmeyr b91e6002a6 dyn TS: implement pchan switchover logic
In struct gsm_lchan, add dyn.rqd_ref and dyn.rqd_ta. These save the Channel
Requested details across the PDCH deactivation dance.

abis_rsl.c: add static functions:

* dyn_ts_switchover*() for the various stages of switchover between pchans.

* pchan_for_lchant() to derive the desired pchan from the lchan type that was
  set during lchan_alloc().

* rsl_chan_activate_lchan_as_pdch() to compose the simpler RSL CHAN ACT message
  without introducing numerous special cases to the normal RSL CHAN ACT code.

In rsl_chan_activate_lchan(), detect and initiate required pchan switchovers if
requested pchan on a dyn TS differs.

In rsl_rx_rf_chan_rel_ack(), initiate or continue pchan switchovers after a
channel was released.

In rsl_rx_chan_act_ack(), notice that a switchover is complete.

In chan_alloc.c, add ts_subslots(): abis_rsl.c will need to know the number of
subslots per pchan, to verify that all lchans are free before dyn TS
switchover. The subslots_per_pchan[] array is static to lchan_alloc.c, and
since we need a non-trivial check for dyn TS anyway, add public ts_subslots()
to lchan_alloc.c, which also checks the current dyn pchan type.

Change-Id: I5c6bce13092a10204113d84678c587c65e35e4fd
2016-07-28 11:56:51 +02:00
Neels Hofmeyr 7af652c0b2 dyn TS: chan act: set chan_nr according to dyn pchan type
Change-Id: Ica5ef2197b3e97d5e895f3e3221295d5d0ef8908
2016-07-28 11:56:51 +02:00
Neels Hofmeyr fdd9ad7c40 dyn TS: enhance channel allocator for dynamic TS
Change _lc_find_bts() to _lc_dyn_find_bts() with added dyn_as_pchan arg to
pass exactly as which pchan we'd like to allocate on a dynamic TS. Add
_lc_find_bts() as wrapper so non-dynamic-TS callers remain unchanged.

Also add dyn_as_pchan arg to _lc_find_trx() (not renaming to dyn and wrapping
because there is only one caller).

Implement dynamic allocator logic in _lc_find_trx() and lchan_alloc().

A returned dynamic channel still needs to be switched to the proper mode, which
will follow in another commit.

Replace a fixme comment with a normal comment in subslots_per_pchan[], because
handling of dynamic TS is now defined.

Change-Id: I18da7679300c43220d9baa6a304e8df74d366249
2016-07-28 11:56:51 +02:00
Neels Hofmeyr f58852d117 dyn TS: rsl_lchan_lookup(): add dyn PCHAN
Accept GSM_PCHAN_TCH_F_TCH_H_PDCH for TCH/F and TCH/H if in matching pchan mode
or switching to matching pchan.

Accept RSL_CHAN_OSMO_PDCH chan_nr cbits for GSM_PCHAN_TCH_F_TCH_H_PDCH pchan.

Change-Id: If8f7c118f69e5a9f370bfe25f82f3d5a8de75b51
2016-07-28 11:56:51 +02:00
Neels Hofmeyr 9518ffc299 dyn TS: verify_chan_comb(): handle new dyn TS NM_CHANC_*
Change-Id: I7ce754a48c7f492e921a4450745383bb8dd7225c
2016-07-28 11:56:51 +02:00
Neels Hofmeyr 4673b86f3d dyn TS: rsl *2chan_nr(): handle TCH/F_TCH/H_PDCH
In gsm_lchan2chan_nr() use the current pchan type.

In gsm_lchan_as_pchan2chan_nr(), add the special case of non-standard cbits for
activating PDCH on a TCH/F_TCH/H_PDCH dyn TS. This way, gsm_pchan2chan_nr()
conforms to the standard and does not need access to a ts struct.

Change-Id: If248b9073b9f397110a2003d8e1a04afdc1c0e20
2016-07-28 11:56:51 +02:00
Neels Hofmeyr d384110d3d dyn TS: gsm_lchan2chan_nr(): decouple from ts->pchan
For upcoming dynamic TS, the pchan choice for RSL De-/Activation is not
trivial. So in order to pass the desired pchan to generate the RSL chan_nr,
introduce gsm_lchan_as_pchan2chan_nr().

To avoid code dup, this requires decoupling the gsm_ts2chan_nr() pchan from the
actual ts struct, so refactor gsm_ts2chan_nr() to gsm_pchan2chan_nr() with
explicit pchan, ts_nr and lchan_nr arguments.

Change-Id: I1a40e8452fe8120d350a27973e56be0b8c8c517f
2016-07-28 11:56:49 +02:00
Neels Hofmeyr 6e999b75fa dyn TS: rename lchan->dyn_pdch to lchan->dyn
This will also be used by the new dynamic TS type, so make the name more
general.

Change-Id: I2451b10519dff3e5cdf503b430574c0984d19000
2016-07-28 11:55:03 +02:00
Neels Hofmeyr cf7933892a prepare dyn TS: act lchan: fetch the channel mode a bit later
Dyn TS will add a new type of chan activation, which does not need a Channel
Mode IE. Incidentally, the dyn PDCH also doesn't need this IE if it opts for
sending a PDCH ACT instead. So it makes sense to compose the Channel Mode IE
only after the dynamic decisions are done.

Change-Id: I66d88ad6a4ae7bee1e552960fd4e92aff953125c
2016-07-28 11:55:03 +02:00
Neels Hofmeyr e2eb5cb6a1 error log: rsl_chan_activate_lchan: log channel mode error
Change-Id: I0f403b13ff9897770c0b855bf57a9440717b46e8
2016-07-28 11:55:03 +02:00
Neels Hofmeyr 2e84b60652 cosmetic: dyn_pdch_init(): debug log: use new gsm_ts_and_pchan_name()
Change-Id: I396c2696bdbedb41a1f1fe2183f8eada57dc3413
2016-07-28 11:55:03 +02:00
Neels Hofmeyr ec1b5a0e9e gsm_ts2chan_nr(): add assertions for lchan_nr
Change-Id: Ibfdef347c85d4a145645a7325cd193ea1b475a54
2016-07-28 11:55:00 +02:00
bhargava 350533cc32 Modify SI 13 field to support 11 bit RACH
System Information 13 field EGPRS PACKET CHANNEL REQUEST is
modified to support 11 bit RACH. Further VTY configuration is added
to enable/disable 11 bit RACH support in EGPRS. By default 11 bit
RACH support is disabled.

Change-Id: I51357bec936c28a26ab9ff5d59e0e30ca3363297
2016-07-28 06:49:03 +00:00
Neels Hofmeyr e3dc498e01 debug log: fix line endings for abis_rsl_rx_rll logging
This function outputs a debug log without line ending, which should be
completed by a subsequent DEBUGPC(), so complete the started log line where
missing in three of the switch cases.

The three cases do print another log message, but since these don't start on a
new line when RLL is in debug level, the log output for these is hard(er) to
read without this patch.

Change-Id: I355647e77e1b2d8e75ae1a167fe87a507a38d82d
2016-07-28 06:31:35 +00:00
Max e443145d3e Fix default subscriber regexp
Incorrect regular expression used by default to authorize all
subscribers to implement authorization policy 'accept-all' prevented MS
from camping on the open network.

Change-Id: I20284b3d40ecf4ca1e67d8cd25afb8d5e4ae3025
2016-07-27 14:52:14 +02:00
Neels Hofmeyr d1c0e3755f log lchan_alloc() result
It is particularly interesting to see whether a given lchan type is allocated
on a dynamic timeslot.

Change-Id: I8a0bca6d9cd583a0988e5ee8f4e6f74f218f4185
2016-07-25 17:35:47 +02:00
Neels Hofmeyr bbbcfe5b73 error log: abis_rsl.c: log errors in channel_mode_from_lchan()
Change-Id: Ifa416eab76e6c26dc83e979d815ae778d0d7133b
2016-07-25 17:35:47 +02:00
Neels Hofmeyr 745857277c code dup: join [rsl_]lchan_lookup() from libbsc and osmo-bts
lchan_lookup in abis_rsl.c and rsl_lchan_lookup() from osmo-bts rsl.c are the
same code, except for the log context, which is only set in abis_rsl.c.
Factor out the common code to rsl_lchan_lookup() in gsm_data_shared.c.

Openbsc and osmo-bts each define their own DRSL log constant, so add an int *rc
return code argument and keep the logging part in abis_rsl.c's thin lchan_lookup()
wrapper. Incidentally, this also removes code dup for logging.

To avoid duplicate symbols, the rsl_lchan_lookup() implementation needs to be
removed from osmo-bts, so older osmo-bts git revisions will not build with
this.

Change-Id: Ie89bc5bb9110a0e539d37991dedac6f913211b48
2016-07-25 17:35:47 +02:00
Neels Hofmeyr 34b8b5b29b gsm_data_shared: add gsm_ts_and_pchan_name() for dyn ts logging
Change-Id: I9b6be77c9e5fb9dffa2021a2da72293af15a03a0
2016-07-25 17:35:47 +02:00
Neels Hofmeyr c165876223 dyn TS: add ts->dyn state
Add state fields osmo_bts_trx_ts->dyn.* to record dynamic timeslot state.
Initialize in gsm_bts_trx_alloc().

Change-Id: I0a4049df8500b4f7c864f1355c4e9238932d1b8f
2016-07-25 17:35:47 +02:00
Neels Hofmeyr f29dd5f15b cosmetic: rsl_rx_chan_act_ack(): use local lchan var in 14 instances
In preparation for an upcoming change.

Change-Id: I9ce71fd7dde42ad7d20f806ac70c150d11450efa
2016-07-25 15:21:24 +00:00
Neels Hofmeyr 8151648ceb cosmetic: act lchan type: use constant instead of 0x00
Change-Id: Idc8afc4e52e189f474077899eef896381ce238f7
2016-07-25 15:21:24 +00:00
Neels Hofmeyr 4007468014 cosmetic: rsl_rx_rf_chan_rel_ack(): use local ts var for brevity
In preparation for an upcoming change.

Change-Id: I11bd59492fa8d5b9392d9f2b511c8fa9585afe6c
2016-07-25 15:21:24 +00:00
Neels Hofmeyr c6926d064d comments: clarify some dynamic TS comments
A new type of dynamic channel will be introduced soon, so prepare some comments
to name the dynamic TS kind more specifically.

Change-Id: I51fa8c2ebba507299e55a5cb7e67e48a6c8471f7
2016-07-25 15:21:24 +00:00
Neels Hofmeyr 67933a19d6 fix: create_pdp_conf(): unset reject_cause after unknown ran_type
f9f4387686 introduced a check for ran_type,
which potentially leaves reject_cause unset. Fix that.

Change-Id: I0220841ff796f949d00a1415d46b54a3eacc9493
2016-07-25 15:19:50 +00:00
Harald Welte 7c989e7ced remove old copy of documentation that now is in osmo-gsm-manuals.git
We keep some random snippets of documentation here, but manuals are now
generally kept in osmo-gsm-manuals.git.  Particularly the GSUP, OAP and
control interface are documented more extensively there.

To avoid having two sets of (diverging) documentation, let's remove it
from the openbsc.git repository.

Change-Id: I4a4c918587e236a7aa00cf2bb6aa05b090f7229b
2016-07-25 09:58:34 +00:00
Alexander Couzens 14314bd808 sgsn: add statistics counter for GPRS and PDP packets
Changing the test to allow still allocated block from the rate
counters.

Change-Id: Ie30e4c3084ee3a138d6b39bb5000234ac814e65f
2016-07-25 00:15:53 +00:00
Alexander Couzens b1c227e5ab bs11_config: add brackets to fix warning in argument parsing
Change-Id: I2f02e09a21ca622b03fd966445f533263a499c8d
2016-07-25 00:14:44 +00:00
Neels Hofmeyr 17a6bab150 fix ctrl test: dyn TS: use new GSM_PCHAN_TCH_F_TCH_H_PDCH
Add GSM_PCHAN_TCH_F_TCH_H_PDCH in gsm_pchant_names and gsm_pchant_descs: the
VTY and CTRL can now handle the new pchan type.

Adjust the CTRL iface test to expect the new PCHAN type in the output.

Fixes make check with --enable-external-tests after libosmocore commit
fd80f5a04239c2ab7b561401476dd89f2861748b that adds GSM_PCHAN_TCH_F_TCH_H_PDCH.

Change-Id: I4ad9c972d7f76f7e20cf74d6fc3d1928b644a4f8
2016-07-24 13:35:04 +02:00
Vadim Yanitskiy d091b8de21 mncc_sock: use osmo_sock_unix_init() from libosmocore
Since the osmo_unixsock_listen() was moved to libosmocore
it would be better to use the library's implementation
instead of reinventing the wheel again.

Change-Id: Iacfc39b6214c24084438f8fe04d03952cdc9ebc2
2016-07-23 19:21:17 +00:00
Alexander Couzens 15fcd10fde gprs_gmm: remove duplicated start of T3395
The timer is already scheduled by gsm48_tx_gsm_deact_pdp_req().

Change-Id: I8203b939d2196f87b11c0f3b2b0ff481e572835c
2016-07-23 15:26:13 +00:00
Dieter Spaar b572d7c45e SGSN: fix FCS calculation for encrypted frames
Change-Id: I352bc9db0c17fff773788831c4389ec0a5a30af8
Related: OS#1582
2016-07-17 08:44:38 +00:00
Neels Hofmeyr 9ddd8e6267 dyn pdch: don't PDCH ACT if gprs mode is none
Skip PDCH activation if the GPRS mode is 'none' at:

* TCH/F_PDCH init after OML Enable (dyn_pdch_init())
* after TCH/F_PDCH is released, in TCH/F mode
* in the T3111 error timer callback after a TCH/F_PDCH was released in error
  state

Assert the GPRS mode in rsl_ipacc_pdch_activate() to make sure all callers
check the GPRS mode.

Closes: OS#1765

Change-Id: I970e5f9dbcb1c625209e914a4c7696294ed34e62
2016-07-17 07:46:38 +00:00
Neels Hofmeyr 9331df16cf cosmetic: dyn_pdch_init(): flatten if-logic, add comments
Prepare for upcoming addition of heeding gprs mode == none.

Change-Id: Id0fe6f762ac863c4d4053841c7732d011aa8c561
2016-07-17 07:46:38 +00:00
Max 1de159168c SGSN: move cipher application to separate function
Split out generation and application of GEA gamma into separate function
which can be used for both encryption and decryption.

Change-Id: I442f2ead57e40d9bcd24e7f1b261041371595360
Related: OS#1582
2016-07-17 07:15:20 +00:00
Max 82040101eb SGSN: encrypt/decrypt only necessary frames
According to 3GPP TS 24.008 § 4.7.1.2 some GMM frames are not supposed
to be ciphered. Propagate information about the necessity for
encryption between MM <-> LLC to ensure only proper frames are
encrypted/decrypted/dropped.

Change-Id: I0358905e60d1b182f75caec81bfcc72bbbbb2aa1
Related: OS#1582
2016-07-16 23:17:58 +00:00
Max b997f84443 SGSN: add preliminary support for GPRS encryption
It is already functional enough to allow testing with real
phones. However, note - there are several limitations in the current
implementation:

* only default value for IOV-UI is supported at the moment
* AUTN-based key material is not supported

Related: OS#1582
Change-Id: I8900b906693496e4e6b35be5a86937c58039ed9e
2016-07-16 21:11:10 +00:00
Max 5aa5196fbf SGSN: split GEA key management from TLLI
Move GEA key from TLLI assignment into separate function.

Change-Id: I8a0bc907072dc19cd9535a28b5252dc0f05357cc
Related: OS#1582
2016-07-16 21:04:01 +00:00
Max 4011e728d2 SGSN: use unique AUTH REQ reference
The A&C reference number specified in 3GPP TS 24.008 § 10.5.5.19
identifies particular request sent by network with the related response
sent by MS. The value transparently copied from request to response by
MS: the spec do not specify what exactly should be in there so we use
rand() to decrease chance for collisions.

Note: variable named 'rand' clashes with standard function rand() so it
was renamed.

Change-Id: I3638821a9b4a0532b28dbbb50faa30c4082579f6
Related: OS#1582
2016-07-16 21:03:30 +00:00
Daniel Willmann 5754206379 osmux: Add negotiation state so race conditions can't disable osmux
Without this commit it is possible that osmux is disabled again on links with
high jitter. This happens when an MGCP response without X-Osmux header is
received before the NAT receives an Osmux dummy frame from the other side.

Ticket: SYS#2628, SYS#2627
Sponsored-by: On-Waves ehf
Change-Id: Id624b0279aee5e2412059a10296ce7896e2d4628
2016-07-11 19:19:05 +00:00
Max 176b62a80c SGSN: prevent starting with inconsistent config
Previously it was possible to start osmo-sgsn with "auth-policy remote"
but without "gsup remote-*" which resulted in broken setup: no MS could
perform GPRS ATTACH. Add consistency check to vty code to fix this.

Related: OS#1582
Change-Id: Ie4296e7d99d7833f7d828b0196435ea81097cf6e
2016-07-11 19:18:17 +00:00
Max e6052c4cc7 Make random MSISDN assignment optional
Previously if subscriber was automatically created it got assigned
random MSISDN number. Make it optional (defaulting to previous behavior)
by adding following:

* new optional no-extension argument for subscriber-create-on-demand vty
  command
* db unit tests
* vty test

Note: using the db made with new code might result in subscribers with
empty extension. Such subscribers cannot be deleted using old
code. Make sure not to mix db versions or manually fix it by editing
sqlite with external program.

Fixes: OS#1658
Change-Id: Ibbc2e88e4722b08854ebc631485f19ed56443cbb
2016-07-09 19:52:54 +00:00
Alexander Couzens 9f8f9b8021 libbsc: skip channel state LCHAN_S_INACTIVE while handover
The state is directly overwritten by the next function. Because
there isn't any state transition, remove this state.

Change-Id: I7f287692dbd559268fb5e61d81ac19e5dd4827eb
2016-07-09 08:53:16 +00:00
Max 3955025c2a SGSN: move TLLI unassignment into separate function
Change-Id: Ia4df145ab03ebcaad70a13601cff60c488a5de54
Related: OS#1582
2016-07-04 08:42:37 +00:00
Max 93408ae727 SGSN: add vty config for choosing GPRS encryption
Change-Id: I07d65205be1c75d59744426629ed04cf3cd99f79
Related: OS#1582
2016-07-04 08:42:07 +00:00
Max 896c6f8e9e SGSN: force GSUP CN domain to PS
Always set CN domain in outgoing GSUP packets to PS to make it
compatible with osmo-auc.

Change-Id: Ia6ee2e55a41a8ea9e465d7df1b2b3559b553fca8
Related: OS#1582
2016-07-01 15:24:44 +02:00
Max 488902db2a Fix vty tests with subscriber deletion
Use correct vty command for subscriber deletion, adjust assertions
accordingly. The error was cause by inconsistent syntax of vty commands
for subscriber creation and deletion.

Change-Id: I9b9376b4ac0ec066000545167de312ca4460493b
2016-06-29 16:45:14 +00:00
Neels Hofmeyr dd49beebb1 err log: tweak dyn pdch ack error logging
Rather use gsm_lchan_name().

Change-Id: I0334484eaa6a2c0f25925042c9c3c1a4e3e78ca4
2016-06-24 09:31:54 +00:00
Neels Hofmeyr 3f2212235c dyn PDCH: cosmetic: clarify lchan rel with assertion and comment
Change-Id: If3cc40022e8283daa991fffe4b6baa734303d8a5
2016-06-24 09:31:17 +00:00
Neels Hofmeyr b0cc64274a debug log: log all lchan state transitions
Change-Id: Ic70aca65b3796c90ba1a88ea67ac7a2ad9190b69
2016-06-23 20:57:44 +00:00
Neels Hofmeyr efedf80526 vty: show lchan summary: also show lchan->state
Change-Id: If7ae92b8d501b51bbe8a165c223734e169a8bb97
2016-06-23 20:01:25 +00:00
Neels Hofmeyr 82c8f75f71 dyn PDCH: enable PDCH only after release due to error
In rsl_rx_rf_chan_rel_ack(), only activate PDCH when in NONE state.

For the case of REL_ERR state, do the PDCH activation in the error timeout
callback after T3111 is done.

Change-Id: I4c55479b252a12039bb3d8c30a9cbf0199ca410e
2016-06-21 21:33:28 +02:00
Neels Hofmeyr 241bda03b4 typo in sgsn_test
(committing just to test gerrit, if it goes through it's still a valid change)

Change-Id: I3291ea2da99cd7f0e2f340b0e6fd6022d088beb8
2016-06-20 18:26:15 +02:00
Neels Hofmeyr 29048b2a80 rm dup: use channel type names from libosmocore
In gsm_lchant_name(enum gsm_chan_t), use the gsm_chan_t_names value strings
from libosmocore instead of redefining the same strings. The list from
libosmocore is also more complete, including CCCH and PDTCH.

Add a todo comment to move to libosmocore.

In consequence, libosmogsm linkage needs to be added to osmo-bsc_mgcp,
mgcp_test, mgcp_transcoding_test and smpp_mirror, smpp_test.

Change-Id: If65ee7c0619cbc0acb0a15045bd5a969442c93cc
2016-06-18 11:34:21 +00:00
Neels Hofmeyr f8e02aa4e3 configure: require libgsm for --enable-mgcp-transcoding
Fail in configure if libgsm is not found.

Before this, the --enable-mgcp-transcoding would gladly accept that libgsm is
missing and the build would fail later because of missing linking and undefined
references.

Change-Id: Ic23157cc5b75694f400a176c31f97d71e861ea02
2016-06-17 15:33:22 +00:00
Neels Hofmeyr 349108801f bsc_version.c: update copyright date, add contributor
Change-Id: Ib3f6763448457915d7473ec5039ab406fd4bdb48
2016-06-17 04:52:30 +02:00
Neels Hofmeyr 832afa3f4b dyn PDCH: set lchan->state after PDCH DEACT / before PDCH ACT
Do the PDCH DE/ACT before we set the lchan->state to De-/Activation Requested.
It makes more sense semantically to change PDCH mode while the lchan is still
in NONE status. Thus slightly move some invocations:

PDCH ACT: Free the lchan before PDCH activation. Hence remove the lchan_free()
call from the rsl_rx_pdch_act_ack() code path; it used to do the PDCH
activation first and call lchan_free() in the callback.

PDCH DEACT: Set the (TCH) Activation Requested state only within
rsl_chan_activate_lchan(), after the PDCH deact is complete.

Channel allocator: don't pick channels that have a PDCH PENDING flag set, to
avoid using channels that are still in PDCH switchover (despite their state
being NONE).

The lchan_may_change_pdch() sanity checks are becoming a lot simpler.

Change-Id: I4206dd4808e21c3e59393ea7f5ab4f438afff066
2016-06-16 04:29:40 +02:00
Neels Hofmeyr 285df2ec62 dyn PDCH: add lchan sanity checks in PDCH DE/ACT ACK
Change-Id: I0456cfb88860823c37c14688673e9cbc8d0085d8
2016-06-16 04:29:40 +02:00
Neels Hofmeyr 3201988f7b dyn PDCH: track pending PDCH de-/activation
Set and clear pending flags on the TS according to PDCH de-/activation.

This will allow changing the time we set the channel state to after PDCH
DEACT and before PDCH ACT, in a subsequent commit.

Also add a sanity check on whether we're sending conflicting or superfluous
PDCH de-/activations on the same TS.

Change-Id: Ieae73271df749ded3d90585116aae01f3ad4ee74
2016-06-16 04:29:40 +02:00
Neels Hofmeyr c1fbdedcd3 dyn PDCH: fix: clear PDCH flags on TS reconnect (e.g. BTS re-connect)
Change-Id: I89a0ef1794f343fdd06a62237f5732e73f4d2704
2016-06-16 04:29:40 +02:00
Neels Hofmeyr 2ebacce4fa dyn PDCH: TS flags: rename one, add three, as enum
Rename TS_F_PDCH_MODE to TS_F_PDCH_ACTIVE, to more accurately reflect the truth
value's meaning.

Add TS_F_PDCH_ACT_PENDING and TS_F_PDCH_DEACT_PENDING for sysmoBTS (and
possibly other BTS implementations) to remember what to do when the PCU replies
with a channel de/activation. Also add TS_F_PDCH_PENDING_MASK to test for both.

Change from #define to an enum.

Note: These flags are also used in the upcoming osmo-bts-sysmo dyn PDCH
commits, so osmo-bts submission depends on this commit.

Change-Id: I391a103ab599648b0c5d4f3ad613a6d7c48834b3
2016-06-16 04:26:33 +02:00
Max 0fcd2e2fec Make random extension range configurable
Previously if subscriber was automatically created it got assigned
random MSISDN number between 20000 and 49999. Make it configurable with
new vty command "subscriber-create-on-demand random" and expand vty
tests to check it.

Change-Id: I040a1d227b0c7a1601dc7c33eccb0007941408a6
Related: OS#1658
2016-06-14 22:20:40 +00:00
Max e152ffe14d Fix SIGABRT on wrong AMR payload
Previously length check have not considered AMR format which requires
extra byte for in-band length leading to SIGABRT on incorrect payload
from BTS.

Change-Id: I800f756fc803accace8c7e0b4a42b3744fe78bb6
Fixes: OS#1731
2016-06-14 10:20:05 +00:00
Neels Hofmeyr b8afb5fda2 dyn PDCH: send PDCH ACT for each TCH/F_PDCH on TS Enable
Add dyn_pdch_init() in new file bsc_dyn_pdch.c (new file to avoid linking
issues; bsc_init.c would create undefined references, and putting in a new file
is the easiest solution).

Call dyn_pdch_init() from nm_statechg_event() whenever a TS is enabled.

Revert the |= TS_F_PDCH_MODE chunk from previous commit, since this flag will
now be set after dyn_pdch_init() sent out the PDCH ACT and when subsequently
the PDCH ACT ACK messages are received in rsl_rx_pdch_act_ack().

Change-Id: I0cad93dec59d546b3f3b19e332e0833496031575
2016-06-14 10:18:19 +00:00
Andreas Eversberg 9df268e217 dyn PDCH: Automatically deactivate/activate PDCH on TCH/F+PDCH channel
Handle shared TCH/F+PDCH channels as regular TCH/F channels. Prior to
activation, deactivate PDCH mode.

After deactivation, restore PDCH mode.

Change-Id: I59712b8769cc3959ef114a6e12e77801816fe8b6
2016-06-14 10:18:19 +00:00
Daniel Willmann 3adb23cfc5 add DSUA debug constant
Change-Id: I4a3a8189564345700ea4825983ab39a8411227f4
2016-06-13 09:18:51 +00:00
Neels Hofmeyr a66852525a dyn PDCH: allow allocating TCH/F on TCH/F_PDCH slots
Remove check for dyn PDCH in _lc_find_trx(), instead call _lc_find_trx() via
_lc_find_bts() several times, so that pure TCH/F is preferred to TCH/F_PDCH.
Add this logic next to the other channel match decisions in chan_alloc().

BTW, the removed check in _lc_find_trx() whether PDCH is active is not
necessary, as described in the added comment for lchan_alloc().

Original patch idea by jolly, but split in two and implemented differently by
nhofmeyr.

Change-Id: I0c728b922656be03588b775638b610a93f8187d5
2016-06-12 15:48:38 +00:00
Andreas Eversberg 0434efa077 dyn PDCH: Fix free slot search for chan_alloc_reverse == true
For chan_alloc_reverse, _lc_find_trx() should return the last free slot instead
of the first.

Original patch by jolly, but split in two by nhofmeyr.

Change-Id: Iff980242b9b5cb39345aaad0350ee368537677cd
2016-06-12 15:48:38 +00:00
Max ec744655b4 Add talkspurt indicator for gsm_lchan
Add bit which can be set on BTS side to indicate that next RTP frame
should be marked as a beginning of speech.

Change-Id: I355a5ae275a2743b29071924c916c4f68c3b3e80
Related: OS#1562
2016-06-12 15:43:50 +00:00
Max f5fe31d513 DTX: add data necessary for scheduling
DTXd: to schedule SID repetition we have to know when previous SID was
sent (fn) and if it was UPDATE or FIRST SID (is_update).
DTXu: to properly set Marker bit in outgoing RTP we have to know the
beginning of talkspurt. For codecs without explicit ONSET event we can
do it by setting the flag (ul_sid) upon receiving SID and unsetting it
on speech frames.

Change-Id: I79cbec3b6c6fed5de385f8e202ceaf0b13234778
Related: OS#22, OS#1701
2016-06-10 14:09:07 +02:00
Max ae3f0718f1 Add DTXd indicator to gsm_lchan
It is necessary for proper reporting of DTXd status during the
measurement period.

Change-Id: I4a033b03fcd0deb4db7a38273b5407511dbf1d6c
Related: OS#1701
2016-06-10 11:34:41 +00:00
Daniel Willmann 35a65edd10 add DRANAP debug constant
Change-Id: I6132198ea86979e0ed84df32f2b7117feba497f2
2016-06-10 10:46:48 +00:00
Neels Hofmeyr f5713a5c63 lchan_alloc(): on alloc failure, report original type
In lchan_alloc(), there are several decisions to fall back to another type of
channel, followed by setting the channel type to the fall back type. So far,
this was set regardless of allocation success or failure.

If such fall back type is not available, do not modify the local type variable
and thus report an S_CHALLOC_ALLOC_FAIL on the type originally requested
(report is at the end of lchan_alloc()).

Change-Id: Ie3d4cb74f91db0b8c4f5e595a963099de339ad1a
2016-06-07 11:10:40 +00:00
Max 6079528b48 Add warning for unsupported DTX configurations
libosmo-abis do not consider DTX bits while processing TRAU frames. As I
do not have equipment to test it, I'm not sure if/how non-IP BTS will
work in case of DTX - warn users about it.

Change-Id: I94ee69cd309fc343a428ddc66942cd57f2a34c05
Related: OS#22
2016-06-06 11:36:48 +02:00
Neels Hofmeyr 9329e6fb49 gprs_gmm.c: don't transmit NOTEXIST when mmctx is NULL
Add missing mmctx NULL check in gsm0408_rcv_gmm(). gsm48_tx_gmm_status() would
dereference mmctx without checking, so we can't call it if mmctx == NULL.

Follows up on recent e98ba82d2b07c835:
"gprs_gmm.c: Don't try to de-reference NULL mmctx".

Change-Id: If59efbde86c76ffe91a0b33be87273783a2a4a02
2016-06-05 23:36:28 +00:00
Daniel Willmann 3af9660e51 configure.ac: add --enable-iu with deps asn1c, ranap, sigtran
For upcoming 3G support.

Change-Id: I6209423d71f94d5cd0ca9daf065d0a9df521ef02
2016-06-05 23:13:01 +00:00
Neels Hofmeyr 9f5d231f00 debug log: cosmetic fixes
Drop erroneous C from a DEBUGPC, should be on a new line.

Drop underscores from IPAC_PDCH_[DE]ACT: all other log messages for IPAC PDCH
are without underscores -- git grep "P(.*IPAC.PDCH.*ACT"

Change-Id: I8fb7a1c1beabb1f4388517383fd0bdc082d557ca
2016-06-05 23:02:09 +00:00
Neels Hofmeyr 3e62d415ac comment tweak for bsc_handover_start()
Have a comment only in the .c file to remove dup, tweak wording, use doxygen
style.

Change-Id: If054dad877a1ca750cd72be9c9d90bcf087bf741
2016-06-05 23:01:25 +00:00
Max ddee01fa8f Add regexp authorization policy for IMSI
* extend "auth policy" vty command with new option "regexp"
* add vty command "authorized-regexp" for setting arbitrary POSIX
  regular expression
* add basic vty test
* add optional "regexp" argument to subscriber-create-on-demand vty
  command

With those in place we can now set the regexp against which MS's IMSI
will be matched.

If IMSI match the regexp than MS is allowed to access the network. If
subscriber is already marked as authorized in HLR than it'll be allowed
regardless of IMSI matching.

The same way we can decide whether to create subscribers on-demand
basesd on IMSI regexp match. Similar to authorization this restriction
can be overridden by manually creating subscriber via vty, ctrl
interface or directly in HLR.

Change-Id: I525f4b80676de47d1d422686da2ca012301b0129
Fixes: OS#1647
2016-06-05 09:36:37 +00:00
Max d7df7ae392 Store last used FN for TCH
It's necessary to properly compute timestamp compensation for RTP
packets in case of DTX (or heavy packet loss).

Related: OS#22
Change-Id: Ib42c6a8614a4b73333a83181488dd4069cac14d7
2016-06-03 13:03:52 +02:00
Daniel Willmann f9f4387686 gprs: more conditionals for Gb specific actions
Change-Id: I213d21b9ddbf19e56269defcc6aa65aca4947140
2016-06-02 03:01:06 +02:00
Daniel Willmann 7ec8ca422c sgsn_mm_ctx_cleanup_free(): clean up LLME iff present (Gb, not Iu)
Assert that llme is unused for non-Gb (Iu) connections, and clean up otherwise.
Make sure the cleanup is left below the sgsn_mm_ctx_free() call, as the comment
states.

Change-Id: I891ae21afc1f4f60580b822273b5435e0e17d46f
2016-06-02 03:01:04 +02:00
Harald Welte 2b2429eb59 gprs_gmm.c: Perform LLME operations only if we have one
In case the GMM message did not arrive over a Gb interface, there is no
LLME (and thus the associated pointer is NULL).  Don't try to perform
operations on a NULL LLME.

Change-Id: If7f24161cd2826f8ee238d4bc1090adf555cea4e
2016-06-02 03:01:02 +02:00
Harald Welte dbc72b37ee gprs_gmm.c: Make TLLI handling specific to Gb interface
Soem of the operations we perform in the GMM layer are specific to the
GPRS/EDGE radio access network and its Gb interface.  Let's make them
conditional to that in preparation of supporting an Iu interface.

Change-Id: I3efb7c5087afe8e2331ec17bd9fac5029f4bee6c
2016-06-02 03:00:59 +02:00
Neels Hofmeyr e98ba82d2b gprs_gmm.c: Don't try to de-reference NULL mmctx
There was a comment in the code that certain GMM messages require a
valid mmctx pointer.  However, nothing actually checked if that pointer
was in fact non-NULL.  We plainly crashed if a MS would send us the
wrong message in the wrong state.

Original patch by Harald Welte, but it broke message validity checking,
resulting in sgsn_test failure. This re-implements the NULL check in a
different way, as explained by in-code comment.

Change-Id: I7908de65bec91599f7042549b832cbbd7ae5a9a8
2016-06-02 03:00:55 +02:00
Harald Welte 49393e128e rename gsm0408_gprs_rcvmsg() to gsm0408_gprs_rcvmsg_gb()
This is the entry point for GMM from Gb.  We will create a new one
for Iu, so let's be explicit rather than implicit.

Change-Id: I93c074bf99db041117c0dc03dc8255879845a875
2016-06-02 03:00:53 +02:00
Daniel Willmann 62ff38447c create_pdp_conf(): factor out PDP context accept dispatch as send_act_pdp_cont_acc()
Change-Id: Ibf60e18707ff4aa2e60291e5595386ddda8d8190
2016-06-01 12:09:51 +00:00
Harald Welte f97ee04563 prepare sgsn_mm_ctx for Gb and Iu mode (UMTS)
Explicitly mark those sgsn_mm_ctx members that apply for Gb mode and (upcoming)
Iu mode, respectively.

Add some comments in sgsn_mm_ctx.

Change-Id: Ife9b02549f284e2547f16117cf43d7a36948fc4b
Tweaked-By: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2016-06-01 12:09:36 +00:00
Harald Welte e1197481e5 Merge "rename enum gprs_mm_state to gprs_gmm_state" 2016-06-01 10:46:41 +00:00
Alexander Couzens 85f8fdabc3 gprs: use new uint8_t * for kv in gprs_cipher_run()
libosmocore changed in bf990bb8 Update internal GPRS cipher API
from uint_64 to uint8_t*.
Fix a warning.

Change-Id: Ib5bfe1fb05c693347b11ff4faadd3fc2205ebd76
2016-05-31 17:47:52 +02:00
Daniel Willmann 0f46f9ca5a rename enum gprs_mm_state to gprs_gmm_state
Change-Id: Ibba054d15c55c7ac570e64ff66ea57964be095e3
2016-05-31 13:53:15 +02:00
Max 69e9c0dfc6 Make si2q scheduling optional
Previously si2quater SI messages were always scheduled. Check for
neighbor configuration and only schedule si2q when necessary. Add
corresponding unit test.

Change-Id: Ibe997803ffb894133fd4d838410fe735791d414f
Fixes: OS#1727
Reviewed-on: https://gerrit.osmocom.org/81
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-31 09:32:12 +00:00
Holger Hans Peter Freyther 82dd983dd8 bsc: Create minimal SI6 rest octets
In GSM R99 SI6 has mandatory SI6 rest octets and so far we did
not include them. Add minimal support to generate the right band
indicator.

Target a slightly older version of the SI6 rest octets as we neither
support MBMS nor Random bit stream but should include the band
indicator.

Change-Id: I417a40eb91f42a3416b4e07bb9fb4d7a01aaa36b
Fixes: OS#1698
Related: OS#1725
Reviewed-on: https://gerrit.osmocom.org/71
Tested-by: Jenkins Builder
Reviewed-by: Max <msuraev@sysmocom.de>
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-30 21:28:40 +00:00
Neels Hofmeyr 307e40648e tweak db debug log: log TMSI as hex
Change-Id: I4564c99c145a35fb592c228c1fa84c61ec425fd3
Reviewed-on: https://gerrit.osmocom.org/94
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-05-27 10:48:04 +00:00
Holger Hans Peter Freyther 5b692d0a5c filter/nat: Fix the context for the imsi assignment
In c09f8a3b7f as part of a cleanup
I accidently changed the talloc context from "con" to "bsc". The
issue occurred at an earlier commit when assigning req.ctx to the
"wrong" context. The allocation needs to be scoped by the struct
nat_sccp_connection and not the connection from BSC to NAT.

Before we have a nat_sccp_connection we scope the copied imsi to
the bsc_connection and then steal it, but for the identity resp
we will always have a nat_sccp_connection and can already use the
right context.

Change-Id: I53789aad2809e19338ad3b2deb72c4757e7bd524
Related: OS#1733
Reviewed-on: https://gerrit.osmocom.org/102
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Reviewed-by: daniel <dwillmann@sysmocom.de>
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-25 19:43:38 +00:00
Harald Welte ed04fcc179 rtp_proxy.c: Ensure msgb_alloc is large enough for largest AMR frame
In AMR 12.2 (mode 7), the actual RTP payload is 33 bytes.  Howeerver,
as we store the length of the (dynamically-sized) AMR payload in the
first byte, our buffer needs at least 33+1 byte in size.

Change-Id: If1ad5d2d68c85733306c75ea62f67fe8fbc143b3
Reviewed-on: https://gerrit.osmocom.org/91
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-25 12:33:47 +00:00
Neels Hofmeyr aea28ceb27 gsm04_08_clear_request(): release loc with arg release=0
In gsm04_08_clear_request(), in_release == 1 anyway and
msc_release_connection() would exit immediately without any effect. Don't
confuse the reader by passing release=1 arg.

Change-Id: I5bf9eb4889d32ad5e42ac7d096bf62fa3a493e20
Reviewed-on: https://gerrit.osmocom.org/93
Reviewed-by: Holger Freyther <holger@freyther.de>
Tested-by: Jenkins Builder
2016-05-23 20:20:37 +00:00
Max ea8e983514 Fix copy-paste error in SI6
Fix error which prevented enabling DTX for half-rate channels.

Change-Id: I7d41df0068783c8fb33ddeeab1d1dcf63c2c259f
Reviewed-on: https://gerrit.osmocom.org/101
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-23 16:24:40 +00:00
Harald Welte 7184bd088e subscr_name(): Handle case for subscr == NULL
subscr_name() was called from several places:
* either without a check for subscr being NULL, which for example
  was causing a segfault if we hand-over a channel before identifying the
  subscriber
* or with an explicit NULL check and the ternary operator (?).

We now simplify the code by checking for the NULL Subscriber in subscr_name()
itself.

Change-Id: Ide09f4a515222eb2ec6c25e7a6a8c5f6cc2ffd4b
Reviewed-on: https://gerrit.osmocom.org/92
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-22 11:51:18 +00:00
Neels Hofmeyr 8495e03588 drop unneccessary duplicate linking: tests/gsm0408
Change-Id: I8b6fb27d1db0157cb7d61f18b03f33c4f3168946
Reviewed-on: https://gerrit.osmocom.org/90
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-22 10:46:42 +00:00
Neels Hofmeyr 5493d87f95 drop unneccessary duplicate linking: osmo-nitb
Change-Id: I430adbb1e0c6382317da282bcf5ef73cf9496f80
Reviewed-on: https://gerrit.osmocom.org/89
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-21 15:54:36 +00:00
Neels Hofmeyr 2fa7d8464f drop unneccessary duplicate/unused linking: ipaccess
Drop unused linking of libmsc, and drop duplicate linking of libbsc.

Change-Id: If2d63adb832c72ff1a22c25a78e06b0c244628d2
Reviewed-on: https://gerrit.osmocom.org/88
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-21 15:20:47 +00:00
Neels Hofmeyr 63081fe34d drop unneccessary duplicate linking: osmo-bsc
Change-Id: Ia227abcaa7b1f808646aadb9f53ee2a669699c51
Reviewed-on: https://gerrit.osmocom.org/87
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-21 15:02:55 +00:00
Max e21cf38da4 Make extending subscriber creation easier
* rename variable controlling subscriber creation
* use enum for subscriber creation policy
* move check for subscriber creation policy into separate static
  function

Related: OS#1658, OS#1647
Change-Id: I3b10a9a764fd3a7bb96717a990e52caae16266da
Reviewed-on: https://gerrit.osmocom.org/42
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 16:32:37 +00:00
Max 8a4d2e756d Use proper measurement for handover
Previously *FULL measurements were always used for handover
decisions. Those are incorrect in case of DTX - check if it was enabled
and use *SUB instead.

Note: *SUB values have higher variance so there might be more "bad"
values compared to *FULL although real quality remains the same.

Change-Id: I95e8e544047a83a256e057a47458678f40a19a15
Related: OS#1701
Reviewed-on: https://gerrit.osmocom.org/66
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-20 16:26:33 +00:00
Max c08ee71bff Move DTX settings to BTS
* Add per-BTS DTX settings
* Configure Uplink and Downlink DTX separately
* Deprecate global DTX option (it was never tested/used anyway)
* Use libosmocore function for DTX indicator in System
  Information (previously it was incorrectly assigned for half-rate
  channels)

Related: OS#22
Change-Id: I3d55168475ad47044b6238b55846ea22bdd518a4
Reviewed-on: https://gerrit.osmocom.org/40
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-17 16:17:54 +00:00
Max 9a7e25b9c3 Cleanup db test
Move copy-pasted code into separate function to make writing more tests
easier.

Related: OS#1658
Change-Id: I9e39af85718514dd0f081d41c234c9dda77c4b27
Reviewed-on: https://gerrit.osmocom.org/43
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-17 16:14:06 +00:00
Vadim Yanitskiy a8d8e93086 db.c: implemented incremental migration
In the past, normal migration was possible only if the actual
schema version differed from the version used in DB by 1. For
example, if DB uses an old version 3 and you need to use it
with the code written for version 5, the check_db_revision()
will convert it to 4 and DB will still use incompatible schema
version during Osmo-NITB running time. After next run it will
be converted to version 5.

This patch replaces a set of 'else-if' checks by a 'switch'
without 'break' statements between 'case' labels (waterfall).
It makes you able to migrate from current version to the
latest despite any difference between them.

Change-Id: Ia9c2aa86f96b88ad8a710d0a23879ce219bc82dc
Reviewed-on: https://gerrit.osmocom.org/62
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-15 19:31:18 +00:00
Max 34e2b09278 Ignore extended test leftovers
Change-Id: If9e3522d934611f631cbfde6e6db52251babc37f
Reviewed-on: https://gerrit.osmocom.org/41
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Reviewed-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
Tested-by: Holger Freyther <holger@freyther.de>
Reviewed-on: https://gerrit.osmocom.org/56
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-12 12:24:23 +00:00
Harald Welte cd5e52605c sgsn_test: Adapt test case to now-existing InsertSubscriberData
We recently implementd InsertSubscriberData in the SGSN, adapt the test
to reflect that.
2016-05-06 13:49:20 +02:00
Harald Welte 7c55ede8b1 Add human-readable name of SGSN_AUTH_AUTHENTICATE
In commit 4adb136da6 we introduced
a new authentication state SGSN_AUTH_AUTHENTICATE, but we didn't
add that to auth_state_names[] resulting in log messages printing
it abut 'unknown 0x1' rather than something more useful.
2016-05-05 18:31:37 +02:00
Harald Welte 5f2524fe3d sgsn/GSUP: Support MAP-style nested LU/ISD
The existing GSUP code expected the subscriber data to be piggy-backed
onto the location update response, rather than a separate (and nested)
insert subscriber data request/response phase.

With this patch we should now support both the nested as well as the
piggy-backed version.
2016-05-05 18:25:12 +02:00
Harald Welte 5d547a4358 osmo_oap_decode(): Use common argument ordering
In general, if a function generates output data like a msgb (or in this
case filling an osmo_oap_message structure), the output argument
precedes the source.  This is what we use all over libosmo*, and it is
modelled after memcpy(), where dst is the first argument, before src.

Let's align osmo_oap_decode().  Intestingly, osmo_oap_encode was already
correct, so the encode/decode functions used different conventions
before.
2016-04-29 13:10:37 +02:00
Harald Welte d8aa412c46 OAP: Various coding style fixes
* we always declare stack variables at the top of the function / block
* 'switch' is not a function, so there's space ahead of the opening (
2016-04-29 13:10:37 +02:00
Harald Welte 564c06525b OAP: use osmo_oap_ prefix for OAP, rather than plain oap_
this is in preparation of moving related code to libosmocore.
2016-04-29 13:10:37 +02:00
Harald Welte 31760a1f60 oap_message.h: Remove dependency to openbsc include
This is a first step to moving oap_messages.h to libosmocore
2016-04-29 13:10:37 +02:00
Harald Welte 23d77d56ea Move osmo_gsup_messages.[ch] to libosmocore
This requires the corresponding commit in libosmocore.
2016-04-29 13:10:37 +02:00
Harald Welte 50f1c0af56 move utils.h functions to libosmocore
This needs the corresponding commit in libosmocore which imports
the related functions
2016-04-29 13:10:37 +02:00
Harald Welte eff215a8bb osmo_gsup_messge.[ch] documentation update (doxygen) 2016-04-29 13:10:37 +02:00
Harald Welte 7ca035deca gsup_messages: Add UMTS AKA related encoding/decoding support 2016-04-29 13:10:37 +02:00
Harald Welte 85234a32db move osmo_shift_* / osmo_match_shift_* to libosmogsm 2016-04-29 13:10:37 +02:00
Harald Welte 842674b8b3 rename gprs_shift_*() to osmo_shift_*()
This rename is the first step of moving the associated functions into
libosmocore.

Also, rename gprs_match_* to osmo_match_shift_* to indicate that it is
not just matching the TLV, but also shifting the data portion.
2016-04-29 13:10:37 +02:00
Harald Welte 28903a99ea Rename gprs_gsup_* to osmo_gsup_*
This is a preparation to move the related code to libosmocore, whilst
at the same time generalizing it from GPRS Subscriber Update Protocol
to the Osmocom Generic Subscriber Update Protoco.
2016-04-29 13:10:37 +02:00
Harald Welte d3fa84dbba use new libosmocore gsm_23_003.h for IMEI/IMSI length
... rather than our private definitions everwhere.  As an added benefit,
gprs_gsup_messages.h is now free of any header dependencies within
openbsc.
2016-04-29 13:10:37 +02:00
Harald Welte 53373bca8f move gsm_04_08_gprs.h to libosmocore
This requres the corresponding commit in libosmocore.
2016-04-29 13:10:37 +02:00
Harald Welte 121e9a4164 Start to use struct osmo_auth_vector from gsm_auth_tuple
Rather than having a 'private' structure for kc, sres and rand, we
now finally (with 4 years delay) use osmo_auth_vector from libosmogsm,
which encapsulates authentication vectors that can be either GSM
triplets or UMTS quintuples or a combination of both.

gsm_auth_tuple becomes a wrapper around osmo_auth_vector, adding
use_count and key_seq to it.

key_seq is no longer initialized inside gprs_gsup_messages.c, as there
is no CKSN / key_seq inside the message anyway.  If a usre of the code
needs key_seq, they need to manage it themselves.
2016-04-29 13:10:37 +02:00
Max 3ffce19cb4 Disconnect calls with incompatible channel types / modes
In case both TCH/H and TCH/F or different codecs are configured and
internal MNCC handler is used we might end up in a situation where call
legs with incompatible channel types or codecs would be connected
resulting in a broken audio.  Disconnect such calls with appropriate
error message.

Fixes: OS#1663
2016-04-29 13:10:00 +02:00
Max 35697b9a10 Adjust si2quater ranges
Change ranges of arguments for si2quater neighbor lists to proper values
according to 3GPP spec.
2016-04-29 12:57:53 +02:00
Max 299a999465 Fix comment typo 2016-04-29 12:57:53 +02:00
Max e01f5050ef Add missing include 2016-04-23 18:12:01 +02:00
Max 8db12e4263 Add extra debug output with channel mode and type
This provides helpful information for debugging internal MNCC handler.
2016-04-22 15:53:51 +02:00
Max aafff96c40 Add vty check for max si2quater size
Explicitly check if added (U|E)ARFCN will fit into available si2quater
message.
2016-04-22 14:56:06 +02:00
Max 26679e0475 Add basic UARFCN support
* add data structures, generation functions
* vty interface for neightbor UARFCNs specific to SI2quater
* vty test
* unit test

Fixes: OS#1666
2016-04-22 14:55:33 +02:00
Max 27c3e76aa7 Cleanup shared data structure
* remove unused variable.
* lower max number of (e|u)arfcns to more realistic value.
2016-04-22 14:54:39 +02:00
Max 0c1bc26b64 Fix earfcn deletion
* fix typo in arg index
* fix sign in error reporting
* add vty test
2016-04-22 14:50:42 +02:00
Max 36212f2850 Fix documentation for command parameters 2016-04-22 14:50:29 +02:00
Holger Hans Peter Freyther 3a434f8e8c nat/ussd: Add an example of the USSD gateway side-channel
This adds a very basic, use once example in python on how to connect
and deal with the app specific payload and messages. The code is not
complete as the invokeId should be patched according to the initial
invoke. This excercise is left to future readers of that code.
2016-04-16 15:56:13 -04:00
Holger Hans Peter Freyther e43f8e0400 nat/vty: Do not print token update statement
On start this would print one line per BSC and this doesn't add
a lot of value. Let's just remove this logging message.
2016-04-16 15:56:13 -04:00
Max 59a1bf3dae Add basic SI2quater support
* support for sending arbitrary static SI2quater.
* vty interface for neightbor EARFCNs specific to SI2quater.
* dynamic generation of SI2quater messages.
* unit test for SI2quater messages.

Fixes: OS#1630
2016-04-16 13:47:56 +02:00
Max 5fa7e36bbc Refactor SI-related code
Move define to header file.
Use inline functions where appropriate.
Change int variables which are used as boolean into actual bool to make
code easier to follow.
2016-04-16 13:47:56 +02:00
Max f3f3505f49 Add SI2quater support to SI3
Advertise SI2 quater presence and location (if available) using SI3
according to 3GPP TS 44.018 § 10.5.2.34
2016-04-16 13:47:52 +02:00
Neels Hofmeyr c9ac20ea43 gbproxy_test: assert msg allocation (CID #57873) 2016-04-16 13:33:22 +02:00
Neels Hofmeyr a6e81a0986 bsc_nat: forward_sccp_to_msc(): assert con presence (CID #57872) 2016-04-16 13:33:21 +02:00
Neels Hofmeyr 312bf6ce8b gtphub_unmap_header_tei(): don't dereference unmapped_tei arg if not present (CID #57687) 2016-04-16 13:33:14 +02:00
Holger Hans Peter Freyther 8bb6204d50 nat/vty: Fix construct not working with python 2.6
Use the simpler approach and just call encode('hex') on the str and
then convert it to lower case to keep the tests working.

reproduce:

Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> d = '\0\0'
>>> d
'\x00\x00'
>>> "".join("{:02x}".format(ord(c)) for c in d)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
ValueError: zero length field name in format

fixes:

======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 658, in testBSCreload
    b0 = nat_bsc_sock_test(0, "lol")
  File "./vty_test_runner.py", line 1150, in nat_bsc_sock_test
    ipa_handle_small(bsc, verbose)
  File "./vty_test_runner.py", line 1116, in ipa_handle_small
    s = data2str(x.recv(4))
  File "./vty_test_runner.py", line 1100, in data2str
    return "".join("{:02x}".format(ord(c)) for c in d)
  File "./vty_test_runner.py", line 1100, in <genexpr>
    return "".join("{:02x}".format(ord(c)) for c in d)
ValueError: zero length field name in format

----------------------------------------------------------------------
2016-04-14 21:40:04 -04:00
Holger Hans Peter Freyther 2abf2b072d nat/vty: Remove second assumption about lo and binding
If we want to separate the BSCs we should separate based on
the source port and not the source ip (at least in the current
test setup).

Fixes:
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 658, in testBSCreload
    b0 = nat_bsc_sock_test(0, "lol")
  File "./vty_test_runner.py", line 1145, in nat_bsc_sock_test
    bsc.bind(('127.0.0.1' + str(nr), 0))
  File "<string>", line 1, in bind
error: [Errno 99] Cannot assign requested address

----------------------------------------------------------------------
2016-04-14 21:13:51 -04:00
Holger Hans Peter Freyther e98c9c7136 nat/vty: And move to a different port.. 2016-04-14 10:58:58 -04:00
Holger Hans Peter Freyther 84ae27e731 nat/vty: Convert into str for the VTY command
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 656, in testBSCreload
    nat_msc_ip(self, ip, port)
  File "./vty_test_runner.py", line 1096, in nat_msc_ip
    x.vty.command("msc port " + port)
TypeError: cannot concatenate 'str' and 'int' objects

----------------------------------------------------------------------
2016-04-14 10:40:06 -04:00
Holger Hans Peter Freyther 44ed4979c9 nat/vty: Use different port for the mock MSC
Update the comment to reflect that the NAT itself will bind to port
5000 and then the mock MSC will fail to bind to it. Try to move the
mock MSC to another port.

Could fix:

======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 654, in testBSCreload
    msc = nat_msc_test(self, ip)
  File "./vty_test_runner.py", line 1101, in nat_msc_test
    msc.bind((ip, 5000))
  File "<string>", line 1, in bind
error: [Errno 98] Address already in use

----------------------------------------------------------------------
2016-04-14 10:05:13 -04:00
Holger Hans Peter Freyther f1a61bb99f nat/vty: Don't assume one can magically add IPv4 addresses to lo
Don't assume that one can just bind to a local address that has
not been configured. Remove the unspecific comment as I don't know
to which other tests it is referred to.

This should fix:
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 655, in testBSCreload
    msc = nat_msc_test(self, ip)
  File "./vty_test_runner.py", line 1102, in nat_msc_test
    msc.bind((ip, 5000))
  File "<string>", line 1, in bind
error: [Errno 99] Cannot assign requested address

----------------------------------------------------------------------
2016-04-14 08:51:57 -04:00
Max 4936448761 NAT: reload BSCs config dynamically
Add vty tests for BSC configuration reloading.
Load BSCs configuration on bscs-config-file command:
* remove all runtime configured BSC not in the config file
* close connections to all BSC with updated token value

Fixes: OS#1670
Sponsored-by: On-Waves ehf
2016-04-14 08:37:34 -04:00
Max 82f5ecde6a NAT: move BSC config into separate file
Introduce new configuration option bscs-config-file which includes BSC
configuration from the given file. Both absolute and relative (to the
main config file) paths are supported.
Add 'show bscs-config' command to display current BSC configuration.
Note: it is still possible to have BSC configuration in the main
file (provided proper index number is used) and in runtime but BSC
configuration is no longer saved automatically. The management of
included configuration file is left to external tools.
Update configuration examples.

Fixes: OS#1669
Sponsored-by: On-Waves ehf
2016-04-14 08:34:49 -04:00
Max 70cf7290da vty_test_runner: update ipa sending code
Factor out 2, add 3 functions. Those functions are simple wrappers
around hex strings specific to IPA protocol. Not all of them are
utilized at the moment but they were checked with wireshark while
working on the tests. It might come in handy if we'd like to further
expand related test harness in future. The same goes for optional
verbosity argument which is not used right now but will be handy for
future debugging.
2016-04-14 08:33:47 -04:00
Max 714b170f89 NAT: allow allocating BSC in arbitrary order
Check for existing BSC before allocating new one.
Track number of remaining BSCs on deallocation.
Explicitly use BSC number in allocation function.
2016-04-12 10:15:02 -04:00
Max 7a301d3576 Remove trivial wrapper function
Rename gsm48_tx_chan_mode_modify() to gsm48_lchan_modify() and remove
corresponding wrapper code.
2016-04-12 10:13:57 -04:00
Max f220b52df3 NAT: extend debug output for ipaccess errors 2016-04-12 10:13:07 -04:00
Max e5686f21d6 NAT: vty command to display number of BSCs
Add command 'show nat num-bscs-configured' to display number of configured BSCs.

Sponsored-by: On-Waves ehf
2016-04-12 10:12:36 -04:00
Max 687f048ab0 Fix segfault with broken config
Fixes OS#1691
2016-04-11 10:22:55 +02:00
Holger Hans Peter Freyther 9bcb1a56cb ctrl: Extend ctrl command to optionally handle alg+ki
Extend the existing ctrl command to be able to specify the
algorithm and Ki. In contrast to the VTY no size check is
done. Together with the VTY this code only supports a small
part of what is supported by libosmocore.

The algorithm and ki are considered optional but if a valid
algorithm other than "none" is passed, a KI must be passed as
well.

Extend the test coverage by passing the potential values. It
is not verified that the KI/algorithm is stored.
2016-04-07 09:27:07 +02:00
Holger Hans Peter Freyther adb86759da db: If creating a subscriber in the db fails, return NULL
We should not return a subscriber in case it was not written to
the database. Instead free the memory allocated and return NULL.
Callers in gsm_04_08.c are prepared to have the creation fail.

Related: OS Issue #1657
2016-04-06 21:21:24 +02:00
Holger Hans Peter Freyther 2826df56b2 subscr: Make db_create_subscriber fail on duplicates
The issue of db_create_subscriber updating an already existing subscr
is that the same subscriber will then have two entries in the active
subscribers list. In general this will break assumptions that a subscr
can be compared by comparing the pointer.

In the case of the VTY this was not an issue as the created subscr
was immediately destroyed again but it is better to avoid this problem.

Change the VTY command to find the subscriber and then call sync to
have the updated time set. The side-effect is we will now have two
queries for the subscriber. Once through subscr_get_by_imsi and once
through db_create_subscriber.

Change the db_create_subscriber to fail if a subscriber already exists,
and add a testcase for this behavior and do not updated the 'updated'
timestamp of an already existing subscriber.

Add a testcase for this behavior.

Related: OS Issue #1657
2016-04-06 21:19:53 +02:00
Holger Hans Peter Freyther de392254ff subscr: Add testcase creating an already created subscriber
Add testcase to issue the subscriber create twice. db_create_subscriber
in db.c will first try to find the subscriber and if it exists, it will
update the "updated" column in the database.

Related: OS Issue #1657
2016-04-06 21:18:36 +02:00
Max 7dd2eed6d3 Ignore vty test byproducts 2016-04-05 22:34:54 +02:00
Holger Hans Peter Freyther c6a65511f3 bsc: Add parameter to restart a bts
The ip.access nanoBTS seems to have severe issues with BSSGP when
changing the country code and/or network code. It is unlikely that
the proprietary code is getting fixed so we extend the parameter
for the apply-configuration command to carry the 'restart' param.
2016-04-01 19:34:42 +02:00
Holger Hans Peter Freyther 740e65fb7b bsc: Add code to send ip.access reboot command to nanoBTS
The nanoBTS continues to be buggy and seems to have broken BSSGP
when changing SIs across new OML connections. Add an easy command
to force the reboot of the system through OML.
2016-04-01 19:34:42 +02:00
Holger Hans Peter Freyther 3a38ee6c3d abis: Send the message without enforcing to wait for a response
The user might issue restarts while no BTS is connected and we
should not block the abis queue because of these messages.
2016-04-01 19:34:42 +02:00
Neels Hofmeyr cf1302e4cb Fix MM Auth: zero-initialize auth tuple before first use
Make sure a new auth tuple is initialized after
db_get_lastauthtuple_for_subscr() returns an error, i.e. if no tuple is present
for the subscriber yet.

Before this patch, the first key_seq depended on the typically uninitialized
value that was present in auth tuple's key_seq upon calling
auth_get_tuple_for_subscr().

The very first key_seq used for a new subscriber will now always be 0. Before,
it used to be mostly 1 ("(0 + 1) % 7"), but depended on whether the key_seq was
indeed initialized with 0, actually by random.
2016-03-31 11:56:49 +02:00
Neels Hofmeyr 0d929be826 Fix MM Auth: disallow key_seq mismatch
In auth_get_tuple_for_subscr(), add missing condition to match incoming
key_seq with stored key_seq, so that re-authentication is requested for
mismatching key_seqs.

Add test for this issue.
2016-03-31 11:56:48 +02:00
Neels Hofmeyr 4e875aec0f MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero
AUTH_NOT_AVAIL == 0, so this is no functional change.
2016-03-31 11:56:47 +02:00
Neels Hofmeyr f9b212fabd MM Auth: introduce AUTH_ERROR constant.
Instead of using hardcoded -1 for errors, include -1 in the enum auth_action
type; apply its use.

In the mm_auth test, the string output changes from '(internal error)' to
'AUTH_ERROR', since now the proper enum value is used in auth_action_names[].
2016-03-31 11:56:29 +02:00
Neels Hofmeyr d617c5d3ac MM Auth test: add test to re-use existing auth 2016-03-31 11:56:21 +02:00
Neels Hofmeyr 4554a62c4d MM Auth test: add two tests for AUTH_THEN_CIPH
Test two situations for AUTH_DO_AUTH_THEN_CIPH:
- when no auth tuple is available
- when the key sequence from LU is marked invalid

Add convenience auth tuple comparison function using stringification.
2016-03-31 11:56:14 +02:00
Neels Hofmeyr 37984bdb1b Add MM Auth test; add auth_action_str() function
Add basic MM Authentication test setup, with fake DB access and RAND_bytes().

So far implement simple tests for IO error during DB access and missing auth
entry.

To print the auth action during tests, add struct auth_action_names and
auth_action_str() inline function in auth.[hc].
2016-03-31 11:56:00 +02:00
Neels Hofmeyr 56ea30ff3f osmo-bsc: fix compiler warning: store struct in vty->index
Don't store an MSC index number in the vty->index void* value. Instead,
store the osmo_msc_data struct directly. Thus avoid warnings about
differences in int vs void* sizes, and save some index lookups.
2016-03-27 10:48:14 +02:00
Harald Welte 3ad0346f00 Revert "move to hex TMSI representation"
This reverts commit 044fbe6568.
2016-03-17 14:42:24 +01:00
Vadim Yanitskiy 044fbe6568 move to hex TMSI representation
In OpenBSC, we traditionally displayed a TMSI in its integer
representation, which is quite unusual in the telecom world.  A TMSI is
normally printed as a series of 8 hex digits.

This patch aligns OpenBSC with the telecom industry standard.

Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
2016-03-17 14:15:16 +01:00
Neels Hofmeyr d2fa7a509a fix confusing typo in constant (THAN -> THEN) 2016-03-17 14:15:16 +01:00
Holger Hans Peter Freyther f4afcf0b23 mgcp: Fix compiler warnings on size_t on AMD64
mgcp_transcode.c: In function 'decode_audio':
mgcp_transcode.c:332:4: warning: format '%d' expects argument of type 'int', but argument 7 has type 'size_t' [-Wformat=]
    LOGP(DMGCP, LOGL_ERROR,
    ^
mgcp_transcode.c:332:4: warning: format '%d' expects argument of type 'int', but argument 8 has type 'long unsigned int' [-Wformat=]
mgcp_transcode.c: In function 'encode_audio':
mgcp_transcode.c:390:4: warning: format '%d' expects argument of type 'int', but argument 7 has type 'size_t' [-Wformat=]
    LOGP(DMGCP, LOGL_INFO,
    ^
mgcp_transcode.c:390:4: warning: format '%d' expects argument of type 'int', but argument 8 has type 'size_t' [-Wformat=]
mgcp_transcode.c: In function 'mgcp_transcoding_process_rtp':
mgcp_transcode.c:542:5: warning: format '%d' expects argument of type 'int', but argument 9 has type 'size_t' [-Wformat=]
     LOGP(DMGCP, LOGL_NOTICE,
     ^
mgcp_transcode.c:571:4: warning: format '%d' expects argument of type 'int', but argument 7 has type 'size_t' [-Wformat=]
    LOGP(DMGCP, LOGL_NOTICE,
    ^
2016-03-16 11:16:06 +01:00
Neels Hofmeyr 10cd11345c bsc_scan_msc_msg: check protocol discriminator
The function assumed an MM protocol discriminator without verifying it.
2016-03-15 14:26:00 +01:00
Holger Hans Peter Freyther 8c515272c3 meas: Do not retry to close the database
There is no concurrency involved and if it failed the first time,
it will fail the second, third, ... time as well. Simply print that
we will leak the database instance.
2016-03-15 14:22:57 +01:00
Neels Hofmeyr 961bd0b121 04.08: apply new transaction id inline functions
libosmocore recently added inline functions to relieve callers from applying
bitmasks and bit shifts to access the transaction id of a GSM 04.08 header.
Apply these functions.
2016-03-15 14:18:52 +01:00
Neels Hofmeyr 531734a547 04.08: apply new bitmask functions, fix bitmask use
Replace hardcoded protocol discriminator and message type bitmasks with
function calls recently introduced in libosmocore.

Note that the release 98 bitmasks slightly differ from the release 99 bitmasks.
This patch uses the "default" gsm48_hdr_msg_type invocation, thus it depends on
libosmocore whether 98 or 99 bitmasks are used.

In some places, use of the bitmask was erratic. Fix these implicitly by
employing the bitmask functions:

 * silent_call.c: silent_call_reroute(): add missing bitmask for MM.
 * bsc_msg_filter.c: bsc_msg_filter_initial(): RR vs. MM messages.
 * osmo_bsc_filter.c: bsc_find_msc() and bsc_scan_bts_msg(): RR vs. MM
   messages.
 * bsc_nat_rewrite.c: bsc_nat_rewrite_msg(): SMS vs. CC messages.
 * bsc_ussd.c: no bitmask is applicable for the message types used here.
 * gb_proxy.c: gbproxy_imsi_acquisition(): missing bit mask for pdisc.

In gprs_gb_parse.c: gprs_gb_parse_dtap(), add a log notice for unexpected
message types.
2016-03-15 14:15:00 +01:00
Neels Hofmeyr 51273157fa channel_test: don't segfault if paging fails
Add due assertions of return value validity, otherwise leading to segfaults.
2016-03-03 16:12:04 +01:00
Neels Hofmeyr 6a1d172c95 db: evaluate return value of sqlite3_finalize(), tweak log output. 2016-03-01 13:05:27 +01:00
Neels Hofmeyr 45ee133d1d check return value of sqlite3_close(), retry up to three times. 2016-02-29 16:44:13 +01:00
Neels Hofmeyr 5b38312b92 use sqlite3_close() instead of sqlite3_close_v2()
This allows using sqlite3 v3.7.13, used by our current debian installation in
the test setup. _v2 was added in v3.7.14.
2016-02-29 16:42:00 +01:00
Neels Hofmeyr 49b83d8f67 minor comment 2016-02-29 10:31:07 +01:00
Neels Hofmeyr a7313dd886 osmo_bsc_filter.c: add fixme note 2016-02-29 10:31:07 +01:00
Neels Hofmeyr fea1df8587 bsc_test.c: fix tz.override val and note a FIXME 2016-02-27 23:38:28 +01:00
Neels Hofmeyr 1b0e5540db smpp: refactor initialization, add bind address
Make the SMPP bind address configurable (used to be harcoded as "0.0.0.0").

Add VTY command

    smpp
     local-tcp A.B.C.D <1-65535>

while keeping the old command 'local-tcp-port <1-65535>'. Both the old and the
new command immediately change the SMPP listening address and port.

Add a LOGL_NOTICE log when the SMPP listening address and/or port change.

However, to be useful, this patch has to go somewhat further: refactor the
initialization procedure, because it was impossible to run the VTY commands
without an already established connection.

The SMPP initialization procedure was weird. It would first open a connection
on the default port, and a subsequent VTY port reconfiguration while reading
the config file would try to re-establish a connection on a different port. If
that failed, smpp would switch back to the default port instead of failing the
program launch as the user would expect. If anything else ran on port 2775,
SMPP would thus refuse to launch despite the config file having a different
port: the first bind would always happen on 0.0.0.0:2775. Change that.

In the VTY commands, merely store address and port if no fd is established yet.

Introduce several SMPP initialization stages:

* allocate struct and initialize pointers,
* then read config file without immediately starting to listen,
* and once the main program is ready, start listening.

After that, the VTY command behaves as before: try to re-establish the old
connection if the newly supplied address and port don't work out. I'm not
actually sure why this switch-back behavior is needed, but fair enough.

In detail, replace the function
  smpp_smsc_init()
with the various steps
  smpp_smsc_alloc_init() -- prepare struct for VTY commands
  smpp_smsc_conf() -- set addr an port only, for reading the config file
  smpp_smsc_start() -- establish a first connection, for main()
  smpp_smsc_restart() -- switch running connection, for telnet VTY
  smpp_smsc_stop() -- tear down connection, used by _start() twice

And replace
  smpp_openbsc_init()
  smpp_openbsc_set_net()
with
  smpp_openbsc_alloc_init()
  smpp_openbsc_start()

I'd have picked function names like "_bind"/"_unbind", but in the SMPP protocol
there is also a bind/unbind process, so instead I chose the names "_start",
"_restart" and "_stop".

The smsc struct used to be talloc'd outside of smpp_smsc_init(). Since the smsc
code internally uses talloc anyway and employs the smsc struct as talloc
context, I decided to enforce talloc allocation within smpp_smsc_alloc_init().

Be stricter about osmo_signal_register_handler() return codes.
2016-02-25 12:18:04 +01:00
Neels Hofmeyr 73828152d9 enable ctrl bind config for various programs
Add ctrl_vty_init() calls and feed the ctrl_vty_get_bind_addr() return value to
ctrl_interface_setup() in the following programs:

  osmo-bsc
  osmo-bsc_nat
  osmo-nitb
  osmo-sgsn

For osmo-sgsn, move the control interface setup invocation below the config
parsing, so that the ctrl_vty_get_bind_addr() can return the configured
address.
2016-02-25 12:18:04 +01:00
Neels Hofmeyr fc7add20e1 osmo-nitb: be strict about cmdline args
Abort upon unknown options and missing option arguments. This came to my
attention while rewiring the -m and -M options: passing -M without argument
would launch nitb with wrong configuration. So, rather exit immediately.

If there are legacy options that should be ignored, they deserve an own 'case:'
in the option switch. There are none that I'm aware of though.
2016-02-25 12:18:04 +01:00
Neels Hofmeyr f4a3123145 osmo-nitb: cosmetic: rename to rf_ctrl_path, following mncc_sock_path
Strictly speaking, the unix domain socket location is not a name but a path.
The MNCC socket is called path, so it is confusing to call the ctrl socket
a 'name'.
2016-02-25 12:18:04 +01:00
Neels Hofmeyr 0ade63233b osmo-nitb: add -M to pass specific MNCC socket path
The old -m option without argument is still available and marked deprecated,
to not make users' lives more difficult than necessary.
2016-02-25 12:18:03 +01:00
Neels Hofmeyr fa0f71526c enable telnet VTY bind address config for various programs
Following the 'line vty'/'bind A.B.C.D' command added in libosmocore, use the
configured address to set the telnet bind for the VTY line. It is now possible
to publish the VTY on a specific local interface (including 0.0.0.0 aka "any").

Implement in all of:
  osmo-gbproxy
  osmo-gtphub
  osmo-sgsn
  osmo-bsc
  osmo-bsc_nat
  osmo-bsc_mgcp
  osmo-nitb

In some of these main programs, move the telnet initialization below the
configuration parsing.

Historically, this was not a good idea for programs using bsc_init.c (aka
bsc_bootstrap_network()), since they expected a gsm_network struct pointer in
((struct telnet_connection*)vty->priv)->priv, so that telnet had to be either
initialized or replaced by a dummy struct. In the meantime, the gsm_network
struct is not actually looked up in a priv pointer but in the static bsc_vty.c
scope (bsc_gsmnet), so this limitation is mere legacy (even though said legacy
is still there in an "#if 0" chunk).

In the other binaries I have briefly looked at the init sequence dependencies
and found no reason to initialize telnet above the config file parsing. In any
case, I have tested every single one of abovementioned binaries to verify that
they still parse the example config successfully and launch, allowing VTY
connections on the configured address(es). I hope this suffices.

In all of the above, log VTY address and port. LOGL_INFO is disabled by default
in some of the logging scopes, and since it is a single log message right at
program launch, I decided for the slightly more aggressive LOGL_NOTICE.
2016-02-25 12:18:03 +01:00
Neels Hofmeyr 58d5430dd5 gsm340_rx_tpdu: comment-out two unused vars
Kills two compiler warnings.
2016-02-25 12:18:03 +01:00
Neels Hofmeyr 127fc93a13 ipaccess_rcvmsg: fix returncode, add partial write warning
Kills a compiler warning.
2016-02-25 12:18:03 +01:00
Neels Hofmeyr 547f048c89 bsc_nat: fail if VTY telnet port cannot be bound, clarify comment 2016-02-25 12:17:07 +01:00
Neels Hofmeyr fd1187e2e9 minor fixes in bsc_vty.c and bsc_nat.c
Remove unused talloc.h from bsc_vty.c.

In bsc_nat.c, use OSMO_CTRL_PORT_BSC_NAT instead of hardcoding port number, and
include ctrl/ports.h for that.

Fix comment typo "COMAMND"
2016-02-24 00:43:41 +01:00
Neels Hofmeyr 1901b92f0c osmo-bsc: fix checking wrong pointer for ctrl setup success 2016-02-24 00:43:25 +01:00
Neels Hofmeyr 69da1d453c gtphub: tweak default logging level 2016-02-23 13:28:04 +01:00
Neels Hofmeyr 03933a49de gtphub: include ports.h instead of redefining OSMO_VTY_PORT_GTPHUB 2016-02-23 13:26:02 +01:00
Jacob Erlbeck 5ac4aadd1a sgsn: Re-add searching for MM ctx based on TLLI / P-TMSI matches
If an MM context cannot be found based on BBSGP info and a RA UPDATE
REQUEST is received, try to find an MM context with an P-TMSI from
which the TLLI could have been derived. This also checks, whether the
routing area matches.

This is similar to the old behaviour removed by the commits
"sgsn: Only look at TLLIs in sgsn_mm_ctx_by_tlli" and
"sgsn: Remove tlli_foreign2local", except that this will only
be done for RA UPDATE REQUESTs now.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck 1330478aa5 sgsn/test: Add test case test_gmm_routing_areas
This test add different cases of routing area changes.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck d35957a7d9 sgsn: Change handling of missing mmctx in gsm48_rx_gmm_ra_upd_req
Currently the MM context is just overwritten by a call to
sgsn_mm_ctx_by_tlli(msgb_tlli(msg), &old_ra_id) even if it
has already been found by using the BSSGP info. With the changes
made to sgsn_mm_ctx_by_tlli this will never find a MM context if
the routing area has changed. If the routing area has not changed,
the mmctx has already been found if it exists.

This commit splits searching for an MM context (if it hasn't been
found already) from checking, whether a found one can really be
used. The actual search is removed, so that the MS will be forced to
restart the attach procedure, which is less efficient but safe.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck d58c033305 sgsn: Only look at TLLIs in sgsn_mm_ctx_by_tlli
Currently the code also matches the TLLI against LOCAL and FOREIGN
mappings of the P-TMSI, thus eventually finding MM contexts not
consistent with the TLLI (both tlli and tlli_new differ). On
the other hand, tlli_new is not checked at all.

This commit changes the function to only look at mmctx->tlli,
mmctx->tlli_new, and the routing area.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck e7bcdc3bda sgsn: Make ra_id_equals available as gprs_ra_id_equals
The function is moved to gprs_utils.c, renamed, and made non-static
to be usable in other modules, too.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck 9158089fa8 sgsn/test: Add bssgp_raid parameter to send_0408_message
The BSSGP cell identifier is used to get the RA for the TLLI lookup.
The send_0408_message function used in the tests does not set this,
so the RA identifier is always 0-0-0-0.

This commit adds a parameters to pass the RAID and adds missing
dummy RAIDs.

Note that the CI can still not be set and thus is always 0.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck 3fbf0a3735 sgsn: Remove tlli_foreign2local
Currently foreign TLLI are sometimes mapped to local TLLI in the
hope that they will match. This seems to sometimes introduce
inconsisties, possibly leading to a failing assertion in
_bssgp_tx_dl_ud.

This mapping should probably reduce the allocation of additional
LLME during routing area changes.

This commit removes tlli_foreign2local.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Ruben Undheim 2259c7528e Patch to make openbsc find libsmpp34
This patch lets the build script for openbsc find the libsmpp34 installation
with the help of pkg-config instead of assuming the header files are in
/usr/include.
2016-02-18 19:39:32 +01:00
Harald Welte 28e9f60404 rename ipaccess-find into abisip-find
The tool is not used only to find ip.access devices, but used to find
any Abis/IP implementing devices, including those supported by OsmoBTS.
2016-02-18 11:15:16 +01:00
Harald Welte bafc1e4cfe add DOT graph showing NITB data structures and their references 2016-02-14 17:38:26 +01:00
Holger Hans Peter Freyther e9f420d487 msc: Remove oversimplified todo entry and add a comment
Add a comment of why we want to accept this connection anyway.
2016-02-10 10:42:20 +01:00
Holger Hans Peter Freyther 8239e063b9 gsm0408: Provide unique strings for the gsm 04.08 message
At Rhizomatica we see that some GSM 04.08 messages are leaked and
have no other indication if that is Call Control, SMS or something
else.
2016-01-30 09:57:49 +01:00
Neels Hofmeyr 1da0a7e229 openbsc/README: some fixes, add CSCN and Iu*
OsmoNITB stated to include BTS, should be BSC. Reword some outdated
statements. Add OsmoCSCN and mention IuCS and IuPS interfaces.
2016-01-28 13:36:07 +01:00
Neels Hofmeyr 6d575cbe57 Add README.vty-tests 2016-01-28 13:36:07 +01:00
Neels Hofmeyr 34cf923704 remove src/libgb/Makefile.am
libgb has been obsolete for years, but the Makefile.am is still there.
src/Makefile.am does not list it as a subdir, so it's just dangling legacy.
2016-01-28 11:51:21 +01:00
Neels Hofmeyr 9c4f1d6fd0 fix bsc_vty out: timeslot indented too deeply.
In 'show running-config', timeslot appears as a sub-element of rsl, but it is a
direct child of trx. Fix the timeslot section in vty_out by removing one space
of idention.

Adjust various config examples.

Rationale: it's not relevant for function, but confuses human operators. Fixing
it will save the next hacker some time.
2016-01-28 11:45:51 +01:00
Alexander Huemer 1bf8617610 gprs: use libgtp cflags 2016-01-26 11:05:14 +01:00
Holger Hans Peter Freyther de76661cf3 gtphub: Fix use after free on failure
Even if fclose fails the stream is inaccessible and the second fclose
might cause memory violation.

Linux manpage says:
Upon  successful  completion 0 is returned.  Otherwise, EOF is returned
and errno is set to indicate the error.  In either case any further
access (including another call to fclose()) to the stream results in
undefined behavior.

Fixes: CID#57958
2016-01-23 10:28:09 +01:00
Holger Hans Peter Freyther f9f44901a2 db: Avoid undefined behavior when copying cm2/cm3 from the db
memcpy has both the source and destination marked as non-null and
we were still passing NULL (with a zero size) to it. While this
makes sense it violates the constraints of the function. Add the
check to see if these values are NULL or not.

+db.c:583:2: runtime error: null pointer passed as argument 2, which is declared to never be null
+    #0 0x40d7f7 in get_equipment_by_subscr (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40d7f7)
+    #1 0x40f6d2 in db_get_subscriber (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40f6d2)
+    #2 0x40bfaa in sms_from_result_v3 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40bfaa)
+    #3 0x40c847 in update_db_revision_3 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40c847)
+    #4 0x40cbc3 in check_db_revision (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40cbc3)
+    #5 0x40cf85 in db_prepare (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40cf85)
+    #6 0x406f18 in main /home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test.c:179
+    #7 0x7fd625638a3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
+    #8 0x405598 in _start (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x405598)
+
+db.c:590:2: runtime error: null pointer passed as argument 2, which is declared to never be null
+    #0 0x40da23 in get_equipment_by_subscr (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40da23)
+    #1 0x40f6d2 in db_get_subscriber (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40f6d2)
+    #2 0x40bfaa in sms_from_result_v3 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40bfaa)
+    #3 0x40c847 in update_db_revision_3 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40c847)
+    #4 0x40cbc3 in check_db_revision (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40cbc3)
+    #5 0x40cf85 in db_prepare (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40cf85)
+    #6 0x406f18 in main /home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test.c:179
+    #7 0x7fd625638a3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
+    #8 0x405598 in _start (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x405598)
2016-01-23 09:21:04 +01:00
Holger Hans Peter Freyther fec29ab4e9 gtphub: Make the two setter static as well
Same as with the previous gtphub commit. Make these static to deal
with the new semantic of inline in gcc5.
2016-01-22 23:36:22 +01:00
Holger Hans Peter Freyther 7ba088bdf0 dahdi: The driver has moved to libosmo-abis
We can remove this check from openbsc as the handling is done
in libosmo-abis.
2016-01-22 23:35:21 +01:00
Holger Hans Peter Freyther 91e0e1b038 gtphub: Fix compilation using gcc5
The semantic of inline has changed and we need to make it static
to not end up with undefined references.
2016-01-22 23:32:36 +01:00
Alexander Huemer 22a7142129 tests/abis: fix format specifiers 2016-01-15 15:41:19 +01:00
Alexander Huemer 6cacc56d8e tests/oap: depend on libgtp
exclude logic copied from src/gprs/Makefile.am
2016-01-15 15:06:03 +01:00
Holger Hans Peter Freyther 5cb480a4c0 bsc/vty: Provide a hint of available input 2016-01-15 15:05:42 +01:00
Neels Hofmeyr cdc548cb0a gtphub VTY: add newlines to some VTY docs' final lines 2015-12-14 16:11:47 +01:00
Neels Hofmeyr 69a720f3be gtphub VTY: fix doc strings for show cmds 2015-12-14 15:52:01 +01:00