aboutsummaryrefslogtreecommitdiffstats
path: root/src/libvlr/vlr_lu_fsm.c
AgeCommit message (Collapse)AuthorFilesLines
2018-12-19Remove redundancy in LAC processingMax1-1/+1
Always use LAC which is part of Cell Global ID otherwise we might end up in a situation where separately stored LAC differs. Both are described in 3GPP TS 23.008 $2.4 as temporary subscriber data to be stored in VLR. Both are defined in 3GPP TS 23.003. The LAC is part of LAI which is part of CGI so there should be no case when those values differ for a given subscriber. Change-Id: I993ebc3e14f25e83124b6d3f8461a4b18f971f8e
2018-12-17vlr_lu_fsm: drop unused out_state INIT -> WAIT_IMEINeels Hofmeyr1-2/+1
There is no state transition from INIT to WAIT_IMEI, only to WAIT_SUB_PRES. If there were code to skip WAIT_SUB_PRES, the allowed state transitions would have to be the same as for WAIT_SUB_PRES, i.e. also WAIT_IMEI_TMSI and WAIT_TMSI_CNF. For now just opt for the status quo. Change-Id: I18ef9e8c96b52401d98f49dc410f13681231b533
2018-12-17tweak comment to indicate sub_pres_vlr fsm as dead codeNeels Hofmeyr1-1/+3
sub_pres_vlr_fsm_start() only ever has an effect if ms_not_reachable_flag == true. But there simply is no code that sets this flag. So sub_pres_vlr_fsm_start() is currently dead code. Also, examining the FSM, if it should ever be set to true, this would halt the LU/CM Service/Paging response, since the FSM would merely change its state without dispatching asynchronous messages. No chance of finishing. Short of dropping the code entirely, first just mark it. The point being that this models some FSM definition from 3GPP specs, and we have a couple other "if (0)" branches in the VLR... Change-Id: I198d442e9ed288f37c7d4e5ec87b82dc53114e99
2018-12-11LU: do not always invoke sub_pres_vlr_fsm_start()Neels Hofmeyr1-1/+6
sub_pres_vlr_fsm_start() starts the FSM, invokes the START event, and then this FSM invariably always directly terminates when vsub->ms_not_reachable_flag == false. So if it is false, there is not much use in instantiating a whole FSM instance that just terminates again, we might as well directly issue the parent-term-event and save some logging space. The same condition is already in place in the vlr_proc_acc_fsm.c in _proc_arq_vlr_node2_post_vlr() for CM Service Request and Paging Response. Now also skip this for LU. Change-Id: Id2303a795dfd381f76e94ff8ff2f495926ca8ba0
2018-11-16vlr: drop unused is_ps parameter in vlr_subscr_req_lu()Philipp Maier1-1/+1
the function vlr_subscr_req_lu() has a parameter is_ps, which is set to vsub->vlr->cfg.is_ps by the only caller in vlr_lu_fsm.c. Inside the function one can see that vsub->vlr->cfg.is_ps is used directly to decide between PS or CS LU, we could also use is_ps there. Presumably the parameter is_ps had been abandonned in an early development stage and was not removed, so lets drop the parameter. Change-Id: Id239721773b90099d122b232dae1ba457be9d255
2018-10-30lu_fsm: result cb: use proper cause type (warning/coverity)Neels Hofmeyr1-2/+2
enum gsm48_gmm_cause is the wrong enum to pass to lu_fsm_failure(). Use enum gsm48_reject_value instead. Change-Id: If661f72056decb28c0ee82ad2449630a24d4f31c
2018-05-23implement periodic Location Update expiry in the VLRStefan Sperling1-1/+1
Remove subscribers which fail to send periodic Location Updates from the list of subscribers known to the VLR. This complements the IMSI detach procedure: periodic LU expiry triggers an implicit IMSI detach. Expired subscribers are purged from a periodic timer which iterates over all subscribers once per minute. Subscribers with an active connection do not expire. This is controlled by the subscriber conn FSM which sets a subscriber's the LU expiry timeout value to GSM_SUBSCRIBER_NO_EXPIRATION while a connection is active. Add support for fake time with osmo_clock_gettime() to msc_vlr tests. This functionality existed in OpenBSC but was lost during the nitb split. This code took some inspiration from the OpenBSC implementation. Related: OS#1976 Change-Id: Iebdee8b12d22acfcfb265ee41e71cfc8d9eb3ba9
2018-04-12refactor VLR FSM result handlingNeels Hofmeyr1-42/+22
Instead of keeping separate enums for FSM results and translating between those and the actual 04.08 reject causes that will ultimately reach the MS, just pass enum gsm48_reject_value cause codes around everywhere. Collapse some VLR *_timeout() and *_cancel() api to just *_cancel() with a gsm48 cause arg. (Hopefully) improve a few reject causes, but otherwise just aim for more transparent decisions on which cause value is used, for future fixes of returned causes. Depends: I6661f139e68a498fb1bef10c266c2f064b72774a (libosmocore) Change-Id: I27bf8d68737ff1f8dc6d11fb1eac3d391aab0cb1
2018-03-13restore sending of optional MM info messagesStefan Sperling1-0/+4
Since commit 2483f1b050496eda7f8707327204251c57212906 the function gsm48_tx_mm_info() was not called anymore. No MM info messages were transmitted to phones even if MM info messages were enabled via VTY. With this commit, we call gsm48_tx_mm_info() after successfully processing an IMSI ATTACH location update. Change-Id: Ice5963d84253eb8c803cd2dfa8b25a4db5382827 Related: OS#2850
2018-03-13vlr_ciph_result: fix use after free of imeisvNeels Hofmeyr1-1/+1
Define the struct vlr_ciph_result member .imeisv not as a char* but a char[] of appropriate length, to avoid the need to point to external memory. Thus fix a use-after-free in msc_cipher_mode_compl(), which defined the imeisv[] buffer in a sub-scope within that function, so that the .imeisv pointer was already invalid when fed to vlr_subscr_rx_ciph_res(). Did you notice that the commit summary rhymes? Closes: OS#3053 Change-Id: I90cfb952a7dec6d104200872164ebadb25d0260d
2018-03-10vlr: fix GSM AKA in a UMTS AKA capable environmentNeels Hofmeyr1-1/+15
Switch by vsub->sec_ctx to use the proper Kc for ciphering. Even on an R99 capable MS with a UMTS AKA capable USIM, the MS may still choose to only perform GSM AKA, as long as the bearer is GERAN. The VLR already stores whether the MS replied with a GSM AKA SRES or a UMTS AKA RES in vsub->sec_ctx. So far, though, we were always using the UMTS AKA Kc just because the USIM and core net are capable of it, ignoring the choice the MS might have made in the Authentication Response. In msc_vlr_test_gsm_ciph, fix the test expectations to the correct GSM AKA Kc keys, showing that all of LU, CM Service Request and Paging Response now support MS choosing GSM AKA in a UMTS capable environment. Related: OS#2793 Change-Id: I42ce51ae979f42d173a45ae69273071c426bf97c
2018-03-02vlr_lu_fsm: guard against using the wrong fiNeels Hofmeyr1-34/+68
Various functions in vlr_lu_fsm.c belong to one of the four FSMs defined in that file. After the recent error was uncovered where the lu_fsm called lu_compl_fsm()'s termination function, I want to make sure it's correct. Introduce distinct inline functions to dereference the respective fi->priv pointers, each asserting that the fi indeed belongs to the proper FSM. Use those *everywhere* to dereference fi->priv. From this patch on, we are sure beyond doubt that we are not inadvertently passing an fi pointer to the wrong FSM's handling functions, though we will only catch this at runtime -- but then will immediately know the reason. vlr_lu_fsm.c is the only file defining more than one FSM, so the other FSM definitions are already reasonably safe. Change-Id: I7419a780ff2d8b02efc4195bb1702818e4df181c
2018-03-02vlr: fix post-auth LU failure handlingNeels Hofmeyr1-2/+2
From the vlr_loc_update() FSM, don't call the vlr_lu_compl_fsm_failure() function. These are two distinct FSMs with distinct priv pointers, but they are defined in the same .c file. In vlr_loc_upd_post_auth(), change two erratic calls of vlr_lu_compl_fsm_failure() to lu_fsm_failure(), so that the proper fi and priv struct are used. Fixes: OS#2947 Change-Id: I7fd2c6fa23254fffd0d526e53541f4068153929f
2018-02-28implement support for 3-digit MNC with leading zerosNeels Hofmeyr1-9/+1
Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore) Change-Id: I82f0016d9512ee8722a3489a3cb4b6c704a271fc
2018-02-08GSUP: check osmo_gsup_encode() resultMax1-1/+4
Check and handle gracefully any error which might appear in osmo_gsup_encode() - mark corresponding functions with warn_unused_result attribute to make sure this failure is always checked against. Change-Id: I4551212011fb0bd898c020a183756ed7a9afb9e5 Related: OS#2864
2018-01-28Shift ciphering algorithm selection from VLR to MSCHarald Welte1-5/+4
The VLR code seems to have the assumption that there is one particular algorithm to be used, as opposed to one of a set of algorithms. What's missing is basically to decide when/where to pick the best algorithm within the capabilities of the phone (classmark) and the network configuration (net->a5_encryption_mask). So far, libvlr has no notion of classmark. Rather, libmsc has. Why does the VLR care about the particular algorithm at all? The VLR should probably simply decide if it should use encryption or not, and if so, the MSC will figure which algorithm to use. Change-Id: I5ed80ca2086560a5975a758ec568a034a9a8ab89
2017-12-18cosmetic prep: tell vlr_ops.set_ciph_mode() whether UMTS AKA is usedNeels Hofmeyr1-0/+7
In case of UMTS AKA, the Kc for ciphering must be derived from the 3G auth tokens. tuple->vec.kc was calculated from the GSM algorithm and is not necessarily a match for the UMTS AKA tokens. To decide (in an upcoming patch) whether to use UMTS AKA derived Kc or the Kc from the auth vector, the set_ciph_mode() from vlr_ops needs to know whether UMTS AKA is being used. This could possibly derived from the msc_conn_ref, but all flags are already available in the vlr_lu_fsm and vlr_access_req_fsm. Hence add a umts_aka flag to the set_ciph_mode() callback invocation. The VLR FSMs thus decide whether UMTS AKA or GSM AKA is to be used during Ciphering Mode Command, which makes more sense than re-implementing the same decision process in the MSC. I considered placing the Kc derivation in vlr_set_ciph_mode() and only tell the MSC's set_ciph_mode() implementation the precise keys it should use, but the RAN particulars, and whether a Kc is used at all, rather belong with the MSC. Related: OS#2745 Prepares: If04e405426c55a81341747a9b450a69188525d5c Change-Id: I983c48347faf4ee1b405d8174b4e006c904157cf
2017-11-20sub_pres_vlr_fsm_start: fix heap use after freeNeels Hofmeyr1-9/+15
When sub_pres_vlr_fsm_start() is called, it dispatches an event which may in some cases already cause tear down and free of the parent FSM instance, after which storing the returned instance pointer in that parent's metadata will use freed memory. Instead, pass the target pointer to remember the instance at to sub_pres_vlr_fsm_start() and assign the pointer *before* firing the event. Explain so in a new comment. I haven't checked whether that pointer is actually used at all -- this is the easiest way to fix the use-after-free without getting sucked into semantic questions. Change-Id: Ibdc0b64cd12ba3e2b9737e3517d8484e67abcf04
2017-10-04cosmetic: vlr: declare a struct in .h; drop unused headerNeels Hofmeyr1-1/+0
In vlr_core.h, "pre-declare" a struct used in function declaration. In vlr_lu_fsm.c, gsup.h is not used, drop the #include. Change-Id: I61d793c3001abbe6d381be1ae0bb350b07403e88
2017-09-15Remove rest_octets.hMax1-0/+1
The MSC should not fiddle with low-level SI details like rest octets anyway. Unfortunately simply removing the header is impossible as it causes massive fallout due to missing includes. Fixed it as well. The only other parameter which required removal is cell_ro_sel_par which is not referenced anywhere in the code anyway. Change-Id: Ibff77330de056fad4288cd4c48d016aad8105354
2017-09-06rename include/openbsc to include/osmocom/mscNeels Hofmeyr1-2/+2
Change-Id: I1f96a1285bbd1b4607614856bca935d5c26e2da9
2017-08-08Implement IuCS (large refactoring and addition)Neels Hofmeyr1-0/+12
osmo-nitb becomes osmo-msc add DIUCS debug log constant add iucs.[hc] add msc vty, remove nitb vty add libiudummy, to avoid linking Iu deps in tests Use new msc_tx_dtap() instead of gsm0808_submit_dtap() libmgcp: add mgcpgw client API bridge calls via mgcpgw Enable MSC specific CTRL commands, bsc_base_ctrl_cmds_install() still needs to be split up. Change-Id: I5b5b6a9678b458affa86800afb1ec726e66eed88
2017-08-07vlr: LU FSM: enable Retrieve_IMEISV_If_RequiredNeels Hofmeyr1-40/+50
Change-Id: I121b95ad6d5ecb7603815eece2b43008de487a8a
2017-08-07vlr: place comments on if (0) casesNeels Hofmeyr1-1/+4
Change-Id: I56c1e61dedeac01a4e24452feee6616782783d8f
2017-07-21Add libvlr implementationHarald Welte1-0/+1424
Original libvlr code is by Harald Welte <laforge@gnumonks.org>, polished and tweaked by Neels Hofmeyr <nhofmeyr@sysmocom.de>. This is a long series of trial-and-error development collapsed in one patch. This may be split in smaller commits if reviewers prefer that. If we can keep it as one, we have saved ourselves the additional separation work. Related: OS#1592 Change-Id: Ie303c98f8c18e40c87c1b68474b35de332033622