Commit Graph

1268 Commits

Author SHA1 Message Date
Harald Welte d54c2ee8c5 initial checkin of 'libosmosim' 2014-10-26 19:09:22 +01:00
Harald Welte cac3cd6fcd msgb: make msgb_get() finally work as expected 2014-10-26 19:08:43 +01:00
Holger Hans Peter Freyther 42645d7d78 misc: Ignore the new test file as well 2014-10-25 12:20:24 +02:00
Holger Hans Peter Freyther e0a1a8021f bssgp: Include sys/socket.h for AF_INET on FreeBSD 2014-10-25 12:19:56 +02:00
Jacob Erlbeck b43baf20c5 gprs: Don't discard SUSPEND/RESUME in bssgp_rcvmsg
Currently sending SUSPEND/RESUME messages to this function (like it
is done in the osmo-sgsn) results in STATUS messages complaining
about an unknown BVCI. The reason is, that these messages rely on a
TLLI/RAI pair to identify the context and do not contain an explicit

This patch modifies bssgp_rcvmsg() to only complain about and unknown
BVCI if one is given but a matching context is not found (except for
RESET messages). The ctx argument is removed from the functions
handling SUSPEND and RESUME since it will always be NULL then.

Sponsored-by: On-Waves ehf
2014-10-23 18:53:02 +02:00
Jacob Erlbeck cdebf7484a gprs/test: Add BSSGP tests
This patch adds a test suite for the BSSGP protocol.
The first (and only) test checks the handling of BSSGP

Sponsored-by: On-Waves ehf
2014-10-23 18:52:56 +02:00
Max 862ba65bd6 Move common socket routine into separate function
Signed-off-by: Max <>
2014-10-13 21:29:42 +02:00
Holger Hans Peter Freyther 10dd73cf6a bssgp: Free msgb in case of error when calling into gprs_ns_sendmsg
In the OsmoSGSN we have a crash with a DEAD/BLOCKED GPRS-NS and
segmented SN-UNITDATA. For the caller it is not easy to know if
the passed msg buffer has been freed or not. The most easy solution
is to always take the ownership and either pass it on or free it
in case of an error.

Adjust indirect and direct callers of gprs_ns_sendmsg. I found
the following call-chains with an external msgb parameter.

  <- _bssgp_tx_dl_ud
     <- bssgp_fc_in
        <- bssgp_tx_dl_ud

Update the test to allocate a real msgb because for the test with
'1000' we will msgb_free it right away.

Sponsored-by: On-Waves ehf
2014-10-10 17:55:13 +02:00
Jacob Erlbeck dade018f2f gprs-ns/test: Check the nsvc state explicitely
This patch extends test_sgsn_reset_invalid_state by assertions to check
that nscv->state and nsvc->remote_state have been set as expected.

Sponsored-by: On-Waves ehf
2014-10-09 16:08:44 +02:00
Holger Hans Peter Freyther 84bcce6b4f gprs-ns/test: Re-add return value check for gprs_nsvc_reset
The return value check has been removed in the commit 'Use
gprs_nsvc_reset instead of gprs_ns_tx_reset', because gprs_nsvc_reset
had no return value then. Since a compatible return value has been
added by 'Let gprs_nsvc_reset return a value', the former patch is
partly reverted by this commit.

The printf is now an OSMO_ASSERT. The commit message was taken
from Jacob.

Sponsored-by: On-Waves ehf
2014-10-09 16:08:20 +02:00
Jacob Erlbeck 6ac70a41ee gprs-ns: Fix reset state handling
Currently the NS-VC's state is updated from within gprs_ns_tx_reset,
which can lead to an inconsistent state when the RESET_ACK is lost.
In this state, the NSE_S_RESET bit is set but the Tns-reset timer is
not started.

This patch moves the state update into gprs_nsvc_reset. This way, the
state flags are consistent with the timer.

  SGSN -> BSS       NS_ALIVE
  SGSN -> BSS       NS_STATUS, Cause: NS-VC blocked, NS VCI: 0x65
  and there is no BSS->SGSN NS_ALIVE

Ticket: OW#1213
Sponsored-by: On-Waves ehf
2014-10-09 07:52:43 +02:00
Jacob Erlbeck 0540d839ac gprs-ns: Let gprs_nsvc_reset return a value
Currently gprs_nsvc_reset does not return any value.

This patch changes the function to return an integer, where a value
less than zero indicates an error. The value is taken from the
gprs_ns_tx_reset function. In case of failure, an error message is logged.

Sponsored-by: On-Waves ehf
2014-10-09 07:47:20 +02:00
Jacob Erlbeck cdb85f58c5 gprs-ns/test: Add test_sgsn_reset_invalid_state
This tests the behaviour for a certain combination of messages and
packet losses that can put the NS-VC object into an undefined state.

In that state, the peer's ALIVE messages are properly answered, but
the local test procedure has stopped, incoming unitdata PDUs are
answered by STATUS(NS-VC blocked) and the unblocking procedure is not

Ticket: OW#1312
Sponsored-by: On-Waves ehf
2014-10-09 07:46:22 +02:00
Jacob Erlbeck f1bcbb0f8a gprs-ns/test: Add expire_nsvc_timer
This function forces the expiration of the timer within struct
gprs_nsvc. It is meant to be used for controlled (and faster) timer
expiration in unit tests. The timer_mode of the expired timer is
returned (or -1 if the timer wasn't active).

Sponsored-by: On-Waves ehf
2014-10-09 07:44:47 +02:00
Jacob Erlbeck 2381fded68 gprs-ns/test: Save the last PDU type sent
This records the PDU type of the last message sent to the remote peer
in the global variable sent_pdu_type, which can then be used in

Note that sent_pdu_type will remain unchanged if no message has been
sent via sendto.

Sponsored-by: On-Waves ehf
2014-10-09 07:43:54 +02:00
Jacob Erlbeck f357c87724 gprs-ns/test: Use gprs_nsvc_reset instead of gprs_ns_tx_reset
Currently gprs_ns_tx_reset is used to let the NS stack generate
NS_RESET message. This is not adjusting the nsvc state properly.

This patch uses gprs_nsvc_reset instead which starts the full reset

Sponsored-by: On-Waves ehf
2014-10-09 07:41:14 +02:00
Jan Engelhardt 1a632552e0 build: resolve compiler warning about implicit delcaration
CC       msgfile_test.o
msgfile/msgfile_test.c: In function "main":
msgfile/msgfile_test.c:48:2: warning: implicit declaration of
function "talloc_free" [-Wimplicit-function-declaration]
2014-10-04 11:49:23 +02:00
Jan Engelhardt c60de4f35f build: fix linker error with kasumi_test
When the osmocore package is configured with --disable-static,
building of kasumi_test fails. This seems quite legit, given
the function _kasumi_kgcore is not exported.
Don't try to workaround the build system. Include the code.

  CCLD     kasumi/kasumi_test
kasumi_test.o: In function `test_expansion':
~tests/kasumi/kasumi_test.c:25: undefined reference to `_kasumi_key_expand'
kasumi_test.o: In function `main':
~tests/kasumi/kasumi_test.c:56: undefined reference to `_kasumi'
~tests/kasumi/kasumi_test.c💯 undefined reference to `_kasumi_key_expand'
~tests/kasumi/kasumi_test.c:112: undefined reference to `_kasumi_kgcore'
2014-10-03 08:48:31 +02:00
Jan Engelhardt 9ffeb9756a build: remove unused all_includes and use AM_CPPFLAGS
Preprocessor flags are best placed in AM_CPPFLAGS. Remove use of the
unused all_includes variable, which is never set.
2014-10-03 08:48:31 +02:00
Jan Engelhardt a6d83932ba utils: resolve compiler warnings on implicit declarations
CC       osmo-auc-gen.o
	osmo-auc-gen.c: In function 'main':
	osmo-auc-gen.c:216:3: warning: implicit declaration of function
	'time' [-Wimplicit-function-declaration]
2014-10-03 08:46:47 +02:00
Holger Hans Peter Freyther 96af78650d misc: Look into the build directory for generated files
the bits/crc files are not inside the sourcedirectory but will end
in the build directory. Go and look there as well. This somehow
doesn't fail with make distcheck but when building for Yocto Dizzy.
2014-09-25 18:18:49 +02:00
Jacob Erlbeck a39e2deff8 gprs: Set bssgph field in bssgp_msgb_alloc()
Currently the bssgph field is not set when using the bssgp_tx_*
functions. This hinders unit testing of generated messages.

This patch initializes the bssgph field directly after allocation a
new bssgp msgb in bssgp_msgb_alloc() so that it is set by default.

Sponsored-by: On-Waves ehf
2014-09-23 16:30:49 +02:00
Jacob Erlbeck b83b838bd1 gprs: Fix bssgp_rcvmsg to handle signalling msgs with BVCI IE
Currently BSSGP messages with an NS BVCI of 0 (signalling) are
discarded if they aren't RESET messages. Thus valid signalling
messages (e.g. BLOCK) are not handled properly, because the BVCI IE
is ignored if it present. Instead a STATUS message referring to BVCI
0 (instead of the BVCI used in the BLOCK message) is returned.

This patch changes the implementation to use the BVCI contained in
the BVCI IE if that is present in a signalling message.

It fixes BSSGP BLOCK/UNBLOCK for the osmo-sgsn.

Note that signalling messages without an BVCI IE (e.g.
SUSPEND/RESUME) are still rejected.

Ticket: OW#1205
Sponsored-by: On-Waves ehf
2014-09-23 16:29:34 +02:00
Jacob Erlbeck a7165778c6 gprs: Fix and check BVCI in BSSGP STATUS messages
Currently the BVCI is not set in all invocations to bssgp_tx_status()
when the cause is UNKNOWN_BVCI.

This patch adds the argument where it is missing.

It also adds a check for compliance (GSM 08.18, to
bssgp_tx_status() to emit errors when the following requirement is
not fulfilled: The BVCI must be included if (and only if) the cause
is either "BVCI blocked" or "BVCI unknown".

Sponsored-by: On-Waves ehf
2014-09-23 16:27:44 +02:00
Harald Welte de883e7f6c Fix copyright header in gan.c
When I wrote the gan.c, I used the wrong copyright/license header
(AGPLv3+ intead of GPLv2+).  This was a mistake and is fixed hereby.
2014-09-11 13:20:33 +08:00
Harald Welte 468b64331a add missing copyright statements to source code files
Some source code files didn't have the usual copyright and licence
statement at their top.  I'm adding them baesed on information in the
2014-09-11 13:18:08 +08:00
Holger Hans Peter Freyther 804590e6d2 debian: Depend on the right version of libosmogsm as well 2014-09-08 07:44:20 +02:00
Holger Hans Peter Freyther 575a5395a6 debian: Depend on libosmocore5 for the legacy package 2014-09-08 07:27:52 +02:00
Ciaby 2cbfb5967c debian: fix build errors with libosmogsm and libosmoctrl
libosmogsm: the transition from 5 to 6 wasn't done properly. Fixed version number.
libosmoctrl: missing definition in debian/control and also missing libosmoctrl0.install.
2014-09-08 07:18:12 +02:00
Holger Hans Peter Freyther 3ec8de0072 logging: Document the ABI breakage in the release todo
In commit fb84f325b8 the ABI
was broken, let's add the required entry.
2014-09-02 18:19:03 +02:00
Holger Hans Peter Freyther 8d950eac9e msgfile: Fix memleak in the test and release the list 2014-08-29 14:21:14 +02:00
Harald Welte fb84f325b8 logging: Add ability to save/print current log filters
This enables the persistent configuration of let's say
'log filter imsi 012345678' for a given log file in the config
2014-08-25 10:09:42 +02:00
Harald Welte 276ca4b172 gsm48.h: define the reserved TMSI in libosmocore, not openbsc 2014-08-24 17:35:19 +02:00
Harald Welte f39aed6942 add port number 4238 for BTS control interface 2014-08-24 16:52:54 +02:00
Harald Welte 39c9e7b471 libctrl: Add support for 'deferred control commands'
Sometimes a control interface command cannot be processed
and responded immediately, but we need to process it asynchronously.

In order to support this, we introduce the 'ctrl_cmd_def', which
represents such a deferred command.  It is created by the service
implementing the command using ctrl_cmd_def_make(), and a response is
later sent using ctrl_cmd_def_send().

ctrl_cmd_def_is_zombie() must be called to handle the case where
the control connection has disconnected/died between receiving the
command and sending the response.
2014-08-24 16:52:54 +02:00
Holger Hans Peter Freyther 5e21131c8d ctrl: Attempt fix the build on FreeBSD and add include file
IPPROTO_TCP is defined in netinet/in.h. Include it and hope the
build is fixed for FreeBSD.
2014-08-21 16:33:32 +02:00
Harald Welte 336915aa0a prepare for 0.7.0 release 2014-08-21 15:53:20 +02:00
Harald Welte 5ddd435919 Convert recently-introduced header files to #pragma once 2014-08-21 15:42:44 +02:00
Harald Welte c7947ed1f6 New <osmocom/ctrl/ports.h> file listing tcp ports for CTRL interface 2014-08-21 15:34:19 +02:00
Harald Welte ae2fcb22cf rename controlif_setup() to ctrl_interface_setup()
which means that all control interface related functions now have
the common ctrl_ prefix.
2014-08-21 15:34:19 +02:00
Harald Welte bfdc259824 libctrl: Make two internal helper functions static 2014-08-21 15:34:18 +02:00
Harald Welte 528134b01c libctrl: Move bulk of control node lookup inti libosmoctrl
The control interface user now only has to register a very short
node lookup function callback.  This function is optional, and only
required if hierarchical command lookup should be supported.
2014-08-21 15:34:18 +02:00
Harald Welte c78e74e3d0 libctrl: remove 'struct gsm_network' references
libctrl doesn't need any knowledge about the type of the user-private
data that it gets passed upon setup time and includes on callbacks.
2014-08-21 15:34:18 +02:00
Harald Welte d8db92c578 libctrl: remove bsc-specific declaration
this was moved by accident when importing the code from openbsc.
2014-08-21 15:34:18 +02:00
Harald Welte acbb4c91b6 libctrl: adopt to recent ipaccess/ipa naming change 2014-08-21 15:34:18 +02:00
Harald Welte 3ff81b1a6b libctrl: autotools build system integration
Now we actually build the recently-imported libctrl
2014-08-21 15:34:18 +02:00
Harald Welte 7fd0c830d9 libctrl: Add DLCTRL as logging context for the control interface
... and make libctrl code use it
2014-08-21 15:34:18 +02:00
Harald Welte f3c7e85d05 libctrl: remove reference to bsc_replace_string()
... and rather introduce a general osmo_talloc_replace_string() to
2014-08-21 15:34:17 +02:00
Harald Welte c9df37d84a libctrl: Avoid using external tall_bsc_ctx
Instead of using one flat talloc context (and one that is specific to
openbsc), we should attach the objects to whatever parent context they
are being used in.
2014-08-21 15:34:17 +02:00
Harald Welte 1238cc64d7 libctrl: remove openbsc headers, convert from make_sock to libosmocore 2014-08-21 15:34:17 +02:00