path: root/openbsc/tests
AgeCommit message (Collapse)AuthorFilesLines
2015-01-18sgsn: Pass subscriber error causes to the GMM layerJacob Erlbeck1-1/+1
This patch extends gsm0408_gprs_access_denied and gsm0408_gprs_access_cancelled to accept GMM cause codes. These are then passed to the MS, unless gsm0408_gprs_access_cancelled is called with cause 0 (no error -> updateProcedure). Since gsm0408_gprs_access_denied uses GMM_CAUSE_GPRS_NOTALLOWED if the cause is not set, and the subscriber's error_cause is never set (and thus always 0), the SGSN's behaviour does not change with this patch. Sponsored-by: On-Waves ehf Conflicts: openbsc/include/openbsc/gprs_sgsn.h [hfreyther: Conflict due the removal of the unused authenticate flag]
2015-01-18gprs: Move protocol value_strings to gsm_04_08_gprs.cJacob Erlbeck1-0/+1
Currently the mapping between GSM 04.08 (GPRS) protocol specific numbers and their textual description was put into gprs_gmm.c and not exported. This commit moves the mappings to a new file gsm_04_08_gprs.c, renames some of them, and exports them via gsm_04_08_gprs.h. The following identifiers are renamed to match the corresponding type names: - gmm_cause_names -> gsm48_gmm_cause_names - gsm_cause_names -> gsm48_gsm_cause_names Sponsored-by: On-Waves ehf
2015-01-18sgsn/test: Extend tests to simulate lost GSUP requestsJacob Erlbeck2-12/+44
This patch extends test_gmm_attach to optionally resend Attach Requests until the SGSN responds to it instead of calling OSMO_ASSERT at a few places. The test_gmm_attach_subscr_gsup_auth test optionally uses this feature. It is called once in either mode. Sponsored-by: On-Waves ehf
2015-01-18sgsn/test: Add GMM test for a GSUP based attach procedureJacob Erlbeck2-0/+73
This test calls test_gmm_attach() where the mocked subscriber functions insert GSUP messages instead of manipulating the subscriber structure directly. Sponsored-by: On-Waves ehf
2015-01-18sgsn/test: Add wrapper for gprs_subscr_rx_gsup_messageJacob Erlbeck1-27/+21
Currently, several lines of boiler plate are needed around a call to gprs_subscr_rx_gsup_message. This patch puts all of this (including the call to gprs_subscr_rx_gsup_message) into a separate function. Sponsored-by: On-Waves ehf
2015-01-18sgsn: Add global require_update_location flagJacob Erlbeck1-0/+2
This flag is used to determine, whether the Update Location procedure shall be invoked. This is currently only set, when the 'remote' authorization policy is set. When the flag is set, sgsn_auth_update will not never be called directly by sgsn_auth_request, if an Attach Request procedure is pending, even if the remote connection fails for some reason. Sponsored-by: On-Waves ehf
2015-01-18sgsn: Replace subscr.authenticate by global require_authentication flagJacob Erlbeck1-2/+2
Currently the flag 'authenticate' is managed per subscriber. This patch replaces that flag by a global cfg.require_authentication flag that enables/disables the use of the Auth & Ciph procedure for every subscriber. The flag is set by the VTY, if and only if the authorization policy is 'remote'. The VTY command - update-subscriber imsi IMSI insert authenticate <0-1> is removed. Sponsored-by: On-Waves ehf
2015-01-18sgsn: Integrate the GSUP client into the SGSNJacob Erlbeck1-0/+2
This commit adds GSUP client configuration (via VTY), connection set up, and real message sending. The following configuration commands are added: - gsup remote-ip A.B.C.D set server IP address - gsup remote-port PORT set server TCP port Ticket: OW#1338 Sponsored-by: On-Waves ehf
2015-01-18gprs/test: Add tests for invalid GSUP messagesJacob Erlbeck1-0/+92
Currently, the tests only use valid GSUP messages. This does not check the robustness of the parser. This commit adds a test for truncated messages and another for modified messages. Thanks to Holger for the basic truncation test. Sponsored-by: On-Waves ehf
2015-01-18sgsn/test: Fix msgb freeing in mocked bssgp_tx_dl_udJacob Erlbeck1-2/+2
Currently the mocked bssgp_tx_dl_ud function used for testing in sgsn_test.c does not free the msg as it is done by the original function. This leads to a msgb leak in the test. This patch fixes the test code accordingly and uncomments the assertion that checks for left-over msgbs. Sponsored-by: On-Waves ehf
2015-01-18sgsn/test: Add checks and reports to detect msgb leakageJacob Erlbeck1-0/+4
This commit adds talloc reports to log remaining chunks after the testing has been finished. It also adds a (currently disabled) check, that no msgbs are allocated after running the tests. Sponsored-by: On-Waves ehf
2015-01-10gprs: Add subscriber functions to create/handle GSUP messagesJacob Erlbeck3-0/+168
This patch extends gprs_subscr_query_auth_info and gprs_subscr_location_update to create GSUP messages with the help of a static gprs_subscr_tx_gsup_message function. A corresponding gprs_subscr_rx_gsup_message is added which takes a messages, gets the subscr, and updates it accordingly. Sponsored-by: On-Waves ehf [hfreyther: Added a msgb_free gprs_subscr_tx_gsup_message]
2015-01-10gprs: Add encoder/decoder for the Subscriber Update ProtocolJacob Erlbeck3-2/+151
This patch adds functions to encode and decode GSUP messages. This does not include the layer 1 framing (IPA). The messages so far supported are: send_auth_info_*, update_location_*, location_cancellation_*. Sponsored-by: On-Waves ehf
2015-01-02Partial revert "Fix most compiler warnings with gcc-4.9.2"Holger Hans Peter Freyther2-16/+16
Most of the "fixes" have nothing to do with gcc-4.9.2 but are a question of ABI/Architecture (e.g. x86 vs. AMD64). Revert these for now. This partially reverts commit 7b1d25a11e44bbc1cb0d2acd9f1a3d4a16ec7c90. abis_test.c: In function ‘test_simple_sw_config’: abis_test.c:68:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[0].start - simple_config, descr[0].len); ^ abis_test.c: In function ‘test_dual_sw_config’: abis_test.c:111:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[0].start - dual_config, descr[0].len); ^ abis_test.c:115:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[1].start - dual_config, descr[1].len); ^ abis_test.c: In function ‘test_sw_selection’: abis_test.c:132:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[0].start - load_config, descr[0].len); ^ abis_test.c:136:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=] printf("Start: %ld len: %zu\n", descr[1].start - load_config, descr[1].len);
2015-01-01Fix most compiler warnings with gcc-4.9.2Harald Welte2-16/+16
2014-12-25db: Extend the test to mark a SMS as delivered and verify itHolger Hans Peter Freyther1-0/+7
Mark the SMS as delivered, then free it and try to get an undelivered SMS to that subscriber again and make sure it is failing.
2014-12-24sgsn: Add a subscriber based authentication phaseJacob Erlbeck3-37/+99
This implements the MAP way of subscriber validation when the MS tries to perform an Attach Request: 1. perform authentication (optionally invoke the sendAuthInfo procedure), starts the Auth & Ciph procedure 2. perform update location 3. insert subscriber data 4. finish the update location 5. Attach Accept / Attach Reject The authentication triplets are used and eventually updated if all of them have been used. This is currently accessible via the VTY interface by the following commands: - update-subscriber imsi IMSI update-auth-info - update-subscriber imsi IMSI update-location-result (ok|ERR-CAUSE) Sponsored-by: On-Waves ehf
2014-12-24sgsn: Add support for authentication tripletsJacob Erlbeck2-0/+66
This commit add data structures, functions, initialization, and VTY commands for per subscriber authentication triplets. The following VTY command is added: - update-subscriber imsi IMSI \ insert auth-triplet <1-5> sres SRES rand RAND kc KC Note that the triplets are not really used by the SGSN yet. Sponsored-by: On-Waves ehf
2014-12-23gprs: Add gprs_shift_tlv functionJacob Erlbeck1-5/+18
This function is similar to gprs_match_tlv with the exception, that the tag is not compared but returned in *tag instead. Sponsored-by: On-Waves ehf
2014-12-23gprs: Move TLV parser functions to gprs_utils.c and rename themJacob Erlbeck4-237/+229
Currently the parser functions for single information elements are defined within gprs_gb_parse.c and not exported explicitely. In addition they are named like libosmocore's TLV parser functions and do not have a proper name prefix. Since it is planned to use them for other protocols, they need to be globally accessible. This patch moves them to gprs_utils.c and renames them. The new names are: lv_shift -> gprs_shift_lv v_fixed_shift -> gprs_shift_v_fixed lv_shift -> gprs_shift_lv v_fixed_shift -> gprs_shift_v_fixed In the long term, these functions should be moved to libosmocore (and renamed again). Sponsored-by: On-Waves ehf
2014-12-10sgsn: Support subscriber based authenticationJacob Erlbeck2-0/+56
This commit mainly extends sgsn_auth.c to use and support the auth_state SGSN_AUTH_AUTHENTICATE. It will be activated when IMSI and IMEI are available, authentication is required (subscr->sgsn_data->authenticate is set), but the MM context is not marked as authenticated. If the state has been set to SGSN_AUTH_AUTHENTICATE and sgsn_auth_update() is called, the GMM layer will be informed by invoking gsm0408_gprs_authenticate(). Sponsored-by: On-Waves ehf
2014-12-09nat: Fix copy and paste in the test codeHolger Hans Peter Freyther1-2/+2
The test didn't test that the access-list has been properly removed. Fix the test to only remove the list once and verify that it is gone.
2014-12-09sgsn: Add VTY commands to manage subscriber cacheJacob Erlbeck1-0/+16
This adds the following commands to the ENABLE node: - show subscriber cache - update-subscriber imsi IMSI insert authorized (0|1) - update-subscriber imsi IMSI cancel - update-subscriber imsi IMSI commit These commands are mainly testing tools and maintenance helpers. The update commands work asynchronously and can be used to complete a pending update request or to terminate an existing connection. The 'insert' command just update the subscriber records but does not notify the GMM layer. Invoke the 'commit' command to continue with pending procedures. Note that the subscriber cache is not stored persistently and will always be empty after an SGSN restart. Sponsored-by: On-Waves ehf
2014-12-09sgsn: Add gsm0408_gprs_access_cancelledJacob Erlbeck2-0/+118
This function is called to delete an established MM context silently without invoking a detach procedure. It is called when a subscriber is cancelled by the HLR. This generally happens, when an MS has moved to another routing area and has to use another SGSN. Sponsored-by: On-Waves ehf
2014-12-09sgsn: Integrate subscriber handling into the SGSNJacob Erlbeck4-5/+61
This commit adds a new authorization policy 'remote' and uses the subscriber cache for authorization when this policy is being used. Note that there is no remote backend implemented yet. After the IMSI/IMEI have been acquired, a request would be sent to the remote peer. The attach/auth-ciph procedure continues when authorization info has been received from the peer. This means, that gprs_subscr_update() must be called then to tell the GMM layer that it can proceed. A later commit will add VTY commands to do this manually. Sponsored-by: On-Waves ehf
2014-12-09sgsn: Add gprs_subscriber.cJacob Erlbeck3-1/+103
This patch adds GPRS specific functions for gsm_subscriber objects (allocation, retrieval, deletion) and subscriber data requests/updates. The sgsn_update_subscriber_data callback is used to notify the sgsn about updates and is extended by a parameter that passes a reference to a gsm_subscriber. Sponsored-by: On-Waves ehf
2014-12-09msc: Add per subscriber keep_in_ram flagJacob Erlbeck1-0/+16
Currently the keep_subscr flag in gsm_subscriber_group refers to a whole group of subscribers which makes it difficult to really delete single entries if the flag is set. This patch adds a keep_in_ram field to gsm_subscriber which allows for keeping subscriber objects in RAM while deleting others. Note that really deleting an entry requires that both flags (subscr_group->keep_subscr and subscr->keep_in_ram) are set to 0. So only the latter should be used if a specification requires the deletion of a subscriber entry. Sponsored-by: On-Waves ehf
2014-12-09sgsn: Remove warningsJacob Erlbeck1-3/+0
Remove warnings related to the SGSN specific code. Sponsored-by: On-Waves ehf
2014-12-05bsc/test: Add tests for gsm_subscriber baseJacob Erlbeck5-1/+132
This commit adds test for the generic part of gsm_subscriber like reference counting and flag usage. Sponsored-by: On-Waves ehf
2014-12-05msc: Add and use gsm_subscriber_groupJacob Erlbeck2-4/+11
Currently every subcriber object directly refers to the gsm_network which contains a flag shared by every related subscriber (keep_subscr). This adds a dependency on gsm_network even if only the function defined in gsm_subscriber_base.c are used. This patch adds a new struct gsm_subscriber_group which contains the keep_subscr flag and a back reference to the network object. The latter is not dereferenced in gsm_subscriber_base.c, so it can safely be set to NULL when only that part of the gsm_subscriber API is being used. It also changes that API to use gsm_subscriber_group instead of gsm_network parameters. Since there are some places where a pointer to the gsm_network is needed but where only a gsm_subscriber is available, a 'net' back pointer is added to the group struct, too. Nevertheless subscr group and network could be separated completely, but this is not the topic of this commit. Sponsored-by: On-Waves ehf
2014-12-05ctrl: Allow to query if the OML link is connected or notHolger Hans Peter Freyther1-0/+11
Related: SYS#798
2014-12-05ctrl: Add command to get the current load of a BTSHolger Hans Peter Freyther1-0/+10
Add a command and test to see the current channel load and available channels per BTS. Related: SYS#798
2014-12-02sgsn/test: Add test case for unexpected Detach AcceptsJacob Erlbeck2-0/+36
The commit "sgsn: Don't send XID reset after Detach Accept" fixed the SGSN to not respond to a Detach Accept message when there is no MM context. This patch adds a test case to verify, that there is really no message sent in that case. The test fails when the commit mentioned aboved is reverted. Sponsored-by: On-Waves ehf
2014-12-02sgsn/test: Don't rely on the actual PRNG sequenceJacob Erlbeck1-1/+9
Currently the expected P-TMSI generated by the SGSN is hard-coded into the test. This adds a dependency on the implementation of rand() and thus the libc used. This breaks the test e.g. on FreeBSD. This patch modifies test_gmm_attach() to srand(1) first, generate the P-TMSI, and finally srand(1) again before starting the test. Sponsored-by: On-Waves ehf
2014-12-02gbproxy: Reset TLLIs when the link_info is found by IMSI/P-TMSIJacob Erlbeck2-14/+6
Currently when the MS does a re-attach without doing a proper detach first, the gbproxy uses the old local TLLI if patching and the keep mode are enabled. This leads to a failing attachment procedure when TLLI patching is also enabled. This patch changes gbproxy_update_link_state_ul to reset all TLLIs within the link_info if the message contains an unknown TLLI and an MI. This is generally the case with Attach Request messages. The gbproxy_get_link_info_ul gets an additional tlli_is_valid output parameter that is set, when a TLLI was present and found. This flag is then used instead of checking tlli.current == 0 to set TLLI/P-TMSI e.g. Attach Requests when a link_info was already present for the P-TMSI/IMSI used in such a request. Ticket: OW#1324 Sponsored-by: On-Waves ehf
2014-11-21bsc: Add ctrl command to set the TRX ARFCNHolger Hans Peter Freyther1-0/+20
2014-11-21bsc: Allow to generate new system information onlineHolger Hans Peter Freyther1-0/+10
Increase the bcch_change_mark and generate a new copy of the system information. Make the method public, add a small test case. Manually verified using the FakeBTS. I don't know if the MS will re-read these SIs. Related: SYS#739
2014-11-21bsc: Allow to set the call-identityHolger Hans Peter Freyther1-0/+20
Allow to set the cell-identity through the control interface and add a small test for it. Related: SYS#739
2014-11-21bsc: Allow to apply configuration for an individual BTSHolger Hans Peter Freyther1-0/+9
This will drop a specific IP based BTS. It will lead to a re-connect of the BTS and the new settings will be applied then. Fixes: SYS#737
2014-11-20mgcp/sdp: Session name must not be empty pick an empty oneHolger Hans Peter Freyther1-0/+7
The session name must be present in a SDP file. The RFC proposes to use a space for it but the other equipment is using the dash so I have picked that as well. RFC 4566: The "s=" field is the textual session name. There MUST be one and only one "s=" field per session description. The "s=" field MUST NOT be empty and SHOULD contain ISO 10646 characters (but see also the "a=charset" attribute). If a session has no meaningful name, the alue "s= " SHOULD be used (i.e., a single space as the session name). Fixes: RT#2196
2014-11-19mgcp: Allow to omit sending the audio name at allHolger Hans Peter Freyther3-0/+67
Equipment like AudioCode appears to get upset when we use a builtin type and then assign a name to it. Allow to completely omit the name.
2014-11-14sgsn: Remove explicit sgsn_instance parametersJacob Erlbeck1-1/+1
Currently the function in sgsn_auth.c either have an sgsn_config or an sgsn_instance parameter. Since then global sgsn variable is already being used in that file and since other parts of the SGSN related code also rely on a global sgsn singleton, these parameters pretend to provide a flexibility that is not really supported. Therefore this patch removes these parameters except for the ACL related functions, which do not call code that uses the sgsn variable. Sponsored-by: On-Waves ehf
2014-11-14sgsn: Don't assign a new P-TMSI if one is pendingJacob Erlbeck2-0/+196
Currently every time an RA Update Req or an Attach Req is processed, a new P-TMSI is allocated. When an MS issues another of these messages before it has completed the first procedure, old_ptmsi is replaced by ptmsi (and thus lost) and ptmsi is replaced by the newly allocated P-TMSI. This can confuse the gbproxy, which can loose track of the logical link then. At least a Blackberry emits a double set of RA Upd Req messages from time to time which may be just 20ms apart. This patch adds a check whether mm->ptmsi or mm->old_ptmsi are set. If both are set, the P-TMSI is not re-allocated. This is only the case, when the Complete message has not been received yet, since that message will reset old_ptmsi. Sponsored-by: On-Waves ehf
2014-11-14sgsn: Cleanup after RA Update Reject / Attach RejectJacob Erlbeck2-0/+149
Currently, the LLME is not cleaned up after sending an RA Update Reject. This happens after entering a routing area from outside, since in that case the SGSN sends an RA Update Reject (implicitly detached) which causes the MS to restart the attach procedure. The LLME is also not updated if an Attach Request with message errors (encoding, invalid MI type) is received or if an MM context cannot be allocated. This patch changes gsm48_rx_gmm_ra_upd_req and gsm48_rx_gmm_att_req to unassign the LLME or free the MM context (if available) after a Reject message has been sent. Ticket: OW#1324 Sponsored-by: On-Waves ehf
2014-11-14sgsn: Add 'acl-only' authentication policyJacob Erlbeck2-1/+17
Currently the VTY 'auth-policy' command results in setting or clearing the acl_enabled flag. This also enables the matching of the MCC/MNC prefix of the IMSI. This patch adds an additional policy 'acl-only' which disables the MCC/MNC matching and relies on the ACL only. Sponsored-by: On-Waves ehf
2014-11-14sgsn/test: Add VTY tests for the SGSNJacob Erlbeck1-0/+53
This patch adds some basic SGSN tests to - check for config tree nodes - check specific show commands Sponsored-by: On-Waves ehf
2014-11-14sgsn: Move IMSI authorization to gsm48_gmm_authorizeJacob Erlbeck1-3/+4
Currently the IMSI is only checked immediately when an Attach Request is received that contains an IMSI IE. If it contains a P-TMSI instead, access is always granted. This commit moves the IMSI check to gsm48_gmm_authorize where it is applied when IMSI and IMEI have been acquired. This fixes the authorization when the Attach Accept doesn't contain an IMSI. Sponsored-by: On-Waves ehf
2014-11-14sgsn: Cleanup GMM state transitionsJacob Erlbeck1-5/+1
Currently the GMM state is set to GMM-REGISTERED when an Attach Accept or a RA Update Accept message is sent, even if a new P-TMSI is included. In this case 04.08 requires (see and, that the state is set to GMM-COMMON-PROCEDURE-INITIATED when the Accept is sent. When the Complete is received, the SGSN shall set the state to GMM-REGISTERED. This patch modifies the state updates accordingly. Sponsored-by: On-Waves ehf
2014-11-11bsc: Move gsm_network_init function to libbscJacob Erlbeck1-3/+5
Currently libcommon depends on libbsc, because gsm_network_init (libcommon/gsm_data.c) directly calls gsm_net_update_ctype (libbsc/gsm_04_08_utils.c). This patch moves gsm_network_init to a new file libbsc/net_init.c. Sponsored-by: On-Waves ehf
2014-11-11sgsn/test: Add test_gmm_attachJacob Erlbeck2-1/+123
This test checks the attach procedure until the Attach Complete is received. Note that authorization and GMM state updates are not working properly yet. Sponsored-by: On-Waves ehf