aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs/gprs_gmm.c
AgeCommit message (Collapse)AuthorFilesLines
2018-10-30Update wrong references to bsc in sgsn codePau Espin Pedrol1-2/+2
Change-Id: I93f0dc721c2eff8a87fb9248882f24768f708713
2018-10-02gprs_gmm: Fix missing Security Command for 3G when attachingAlexander Couzens1-1/+1
Introduce a new FSM step in GMM Attach to send the Security Command to the RNC after completing the Authentication. Fixes: f7198d7dbb84 ("gprs_gmm: introduce a GMM Attach Request FSM") Change-Id: I1e12b0a32e58c6f78dba7b548f7d7016567229db
2018-09-28gprs_gmm: dont answer unknown IMSI/TMSI on Service Requests NET_FAILAlexander Couzens1-2/+2
NET_FAIL will result in asking again and again. Reject with IMPL_DETACHED to drop the MS completely. Change-Id: I195d533e330a4b577cad80c7e757d481f9c837df
2018-09-13gprs_gmm: introduce a GMM Attach Request FSMAlexander Couzens1-9/+38
The old GMM Attach Request handling used a recursive function which can not handle certain states and is quite complex and hard to extend. The new FSM handles such request in a FSM and can be called multiple times. Change-Id: I58b9c17be9776a03bb2a5b21e99135cfefc8c912
2018-08-15Drop gprs_msgb_copy with libosmocore replacementPau Espin Pedrol1-1/+1
gprs_msgb_copy was introduced in libosmocore 0.94 (f78ec5ce0d0f6038147d9b9e14d81094309ba5d5) as bssgp_msgb_copy. Let's use that one to avoid code duplication. Change-Id: I42a65fd8e4045fafadf5694f2d8d0c5e7ab350a0
2018-07-16sgsn: Fix T3395 firing foreverPau Espin Pedrol1-4/+13
field pdp->num_T_exp was being reset to 0 every time pdpctx_timer_start() was called from gsm48_tx_gsm_deact_pdp_req(). Take the chance to test max amount of retrans to 4 as detailed in specs. Change-Id: Iacce3c66f61578ebee37abaa287f7e183f985c1c
2018-07-16sgsn: Don't attempt to delete GTP pdp ctx if GGSN was restartedPau Espin Pedrol1-2/+9
Scenario and behaviour before this commit: - Received Echo Reply from GGSN has incremented RestartCounter - func sgsn_ggsn_ctx_drop_all_pdp() is called to dettach all pdp ctx from GGSN and request the MS to deact all related ctx. - DEACT ACCEPT is received from MS, and then it tries to send DEL PDP CTX to GGSN, expecting to receive a Confirmation and only then freeing the pdp ctx. The problem is that since the initial cause of triggering was a GGSN restart, the GGSN doesn't know anything about that pdp ctx anymore, so it's not useful sending it. We can instead dettach the GGSN and libgtp ref at drop_all_pdp() time and then when we receive DEACT ACCEPT from MS we can free the pdp ctx directly. Change-Id: I1c74098e181552c218e152bf4ac5035cea770428
2018-07-16Add optional TearDownInd IE in PDP DEACT REQ towards PCUPau Espin Pedrol1-4/+6
According to 3GPP TS 24.008 Section 6.1.3.4, the tear down indicator IE maybe included in the DEACTIVATE PDP CONTEXT REQUEST message in order to indicate whether only the PDP context associated with this specific TI or all active PDP contexts sharing the same PDP address and APN as the PDP context associated with this specific TI shall be deactivated. As we don't permit/support establishing multiple PDP contexts using the same APN and PDP address, it shouldn't really make any difference. Nevertheless, we want to clear everything, so let's include it. Change-Id: Ia9bc2d0e93362a8473eac5cf4c7e8ffa41c79e5b
2018-07-13Disarm T3395 when dettaching mmctx from pdpctxPau Espin Pedrol1-0/+10
In sgsn_pdp_ctx_terminate, a pdp ctx is terminated and the mm ctx is detached. However, T3395 may still be armed and then pdpctx_timer_cb will trigger, and attempt to use the pdp->mm ctx which was already detached (set to NULL) when calling gsm48_tx_gsm_deact_pdp_req()->mmctx2msgid(). Following list of log lines shows the scenario+crash, in which osmo-sgsn is trying to deactivate the ctx all the time but the PCU doesn't ACK it, and then at some point the PDP context is forced released. osmo-sgsn/src/gprs/gprs_gmm.c:2294 MM(901700000015254/d7e9ab95) <- DEACTIVATE PDP CONTEXT REQ osmo-sgsn/src/gprs/gprs_gmm.c:1464 MM(901700000015254/d7e9ab95) -> GMM DETACH REQUEST TLLI=0xd7e9ab95 type=GPRS detach Power-off osmo-sgsn/src/gprs/gprs_gmm.c:313 MM(901700000015254/d7e9ab95) Cleaning MM context due to GPRS DETACH REQUEST osmo-sgsn/src/gprs/gprs_sgsn.c:332 MM(901700000015254/d7e9ab95) Dropping PDP context for NSAPI=5 osmo-sgsn/src/gprs/gprs_sgsn.c:434 PDP(901700000015254/0) Forcing release of PDP context osmo-sgsn/src/gprs/gprs_sndcp.c:508 SNSM-DEACTIVATE.ind (lle=0x62100001bca0, TLLI=d7e9ab95, SAPI=3, NSAPI=5) osmo-sgsn/src/gprs/sgsn_libgtp.c:310 PDP(---/0) Delete PDP Context osmo-sgsn/src/gprs/gprs_gmm.c:2294 MM(---/ffffffff) <- DEACTIVATE PDP CONTEXT REQ osmo-sgsn/src/gprs/gprs_gmm.c:305:25: runtime error: member access within null pointer of type 'const struct sgsn_mm_ctx' Program received signal SIGSEGV, Segmentation fault. 0x0000555555698c1b in mmctx2msgid (msg=0x61d0000172e0, mm=0x0) at /home/pespin/dev/sysmocom/git/osmo-sgsn/src/gprs/gprs_gmm.c:305 305 msgb_tlli(msg) = mm->gb.tlli; (gdb) bt #0 0x0000555555698c1b in mmctx2msgid (msg=0x61d0000172e0, mm=0x0) at osmo-sgsn/src/gprs/gprs_gmm.c:305 #1 0x00005555556b170a in _gsm48_tx_gsm_deact_pdp_req (mm=0x0, tid=0 '\000', sm_cause=38 '&') at osmo-sgsn/src/gprs/gprs_gmm.c:2297 #2 0x00005555556b1a2e in gsm48_tx_gsm_deact_pdp_req (pdp=0x6140000008a0, sm_cause=38 '&') at osmo-sgsn/src/gprs/gprs_gmm.c:2311 #3 0x00005555556b876c in pdpctx_timer_cb (_pdp=0x6140000008a0) at osmo-sgsn/src/gprs/gprs_gmm.c:2717 #4 0x00007ffff355eb3e in osmo_timers_update () at libosmocore/src/timer.c:257 #5 0x00007ffff356255c in osmo_select_main (polling=0) at libosmocore/src/select.c:254 #6 0x00005555556f17cb in main (argc=3, argv=0x7fffffffe298) at osmo-sgsn/src/gprs/sgsn_main.c:531 Change-Id: I2120e53ade6cabad37f9bd99e6680a453411821b
2018-06-05gprs_gmm: Cancel Location: use detach type IMSIAlexander Couzens1-1/+1
The detach type network side is defined as - Reattach required - Reattach not required - IMSI detach (after VLR failure) IMSI detach seems to be more close. Howeever the standard isn't clear about this. Change-Id: I27da6dc5165819cccd1ae0a98b132b45a01f38bb
2018-05-23gprs_gmm: make extract_subscr_msisdn extract_subscr_hlr publicAlexander Couzens1-2/+2
Change-Id: I54168e1a58dd36b38c53c13bbb5cdb4311f34410
2018-05-23gprs_gmm: make functions relating to GMM Attach Request publicAlexander Couzens1-5/+5
GMM Attach Request will be handled in it's own file and will use those functions. Change-Id: Ic90d77f7b0bacd2a8e2e409e82d676772d352749
2018-05-02GMM: dont reply to GMM_DETACH_REQ with POWER OFF when MS is unknownAlexander Couzens1-0/+7
Change-Id: I1d1cf64500f1295ab58d157d4d4dab16fcddbbf3
2018-05-01GERAN: allow GSM SRES on UMTS AKA challengeNeels Hofmeyr1-20/+19
Store the established security context type (GSM or UMTS) instead of the boolean flag is_authenticated. Provide the previous boolean query with thin sgsn_mm_ctx_is_authenticated() function. Knowing which security context was established will be necessary for OS#3224, i.e. using the proper ciphering key, which is not yet tested properly, and probably not correct at this stage. This change will make new SGSN_Tests.TC_attach_umts_aka_gsm_sres pass. Related: OS#3193 OS#3224 Change-Id: I36807bad3bc55c0030d4f09cb2c369714f24bec7
2018-04-30log two RA Update Request failure causesNeels Hofmeyr1-0/+5
Change-Id: Ic9c8a492abf5a707b37d9c8888c59be6e51541b8
2018-04-30auth+ciph: log is_r99 and auth typesNeels Hofmeyr1-2/+4
Change-Id: I9679b7c174df186e05171a059a6b4d870a6f16e6
2018-03-16compiler warnings: use enum ranap_nsap_addr_enc, constify local varNeels Hofmeyr1-1/+1
Use the proper enum ranap_nsap_addr_enc instead of int, and properly exclude that member when we're building without Iu support: sgsn_vty.c:1323:31: error: passing argument 2 of ‘ranap_iu_vty_init’ from incompatible pointer type [-Werror=incompatible-pointer-types] ranap_iu_vty_init(SGSN_NODE, &g_cfg->iu.rab_assign_addr_enc); Add const to a local var to silence compiler warning retrieving TLVP_VAL: gprs_gmm.c:1657:18: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] uint8_t *mi = TLVP_VAL(&tp, GSM48_IE_GMM_ALLOC_PTMSI); ^~~~~~~~ Change-Id: I1168ce6425c31db3f6c3bf1f3682ae96b028c59b
2018-03-15implement support for 3-digit MNC with leading zerosNeels Hofmeyr1-5/+4
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). Note that in gbproxy_test.ok, 0-0 changes to 000-000 instead of 000-00, because the parsed ra buffer is 000000 which results in 000-000, while 00f000 would result in 000-00. IOW this is expected. Change-Id: I7437dfaa586689e2bef0d4be6537e5577a8f6c26
2018-01-19Use gsm48_encode_ra() for RAI encodingMax1-2/+2
It has stricter type signature which increase the chance of spotting misuse either via compiler warning or with automated scan. This also paves the way for gsm48_construct_ra() deprecation in libosmocore. Change-Id: I2c0f082dc7214ed57a40dad0788e34b838dfac97 Related: OS#1640
2018-01-08Fix RAI constructionMax1-2/+2
The gsm48_construct_ra() expect 6-byte buffer while ra_id.digits is 3-byte buffer. The function fills in LAC and RAC as well so we should pass entire struct, not just 'digits' part which only store MCC/MNC. Related: OS#1640 Change-Id: I3bfda930012c792452f9fd695ed7acf46365f1df Fixes: CID57877, CID57876
2018-01-07gprs_gmm: Convert warning message to pragma messagePau Espin Pedrol1-1/+1
This way we can enable -Werror in builds to disallow new compilation warnings being introduced. Change-Id: If2b9a618f4219df9e013095beff52c20aacbc79e
2018-01-07cosmetic: gprs_gmm: Remove trailing whitespacePau Espin Pedrol1-2/+2
Change-Id: Ie2466268fbc4699a366856d467660b17e3f7e307
2018-01-07gprs_gmm: Remove unused variablePau Espin Pedrol1-2/+2
Fixes following compilation warning: osmo-sgsn/src/gprs/gprs_gmm.c: In function ‘gsm48_rx_gmm_service_req’: osmo-sgsn/src/gprs/gprs_gmm.c:1786:10: warning: variable ‘ciph_seq_nr’ set but not used [-Wunused-but-set-variable] uint8_t ciph_seq_nr, service_type, mi_len, mi_type; ^~~~~~~~~~~ Change-Id: If0819026a99f45df96ee6de26a71c16128e79cb8
2017-12-27Migrate from OpenSSL to osmo_get_rand_id()Max1-10/+14
This avoids potential licensing incompatibility and makes integration of Debian packaging patches easier. The libosmocore version requirements are fine already but for jenkins tests to pass we have to have Ic77866ce65acf524b768882c751a4f9c0635740b merged into libosmocore master. Related: OS#1694 Change-Id: I2b687b7f07ef05bbd861b8479cad5a958a3dde92
2017-12-20Remove dead codeMax1-4/+0
Get rid of ifdefs around old unused code to improve readability. Change-Id: Ia80cf845b624d520d67143b61c9de3d49074cb8c
2017-12-20gsm48_rx_gmm_att_req: fix error handling: don't clean up NULL llmeNeels Hofmeyr1-1/+1
Change-Id: I78903d0846568d4e98b6e43e62bbe3c329b5bc68
2017-12-20gprs_gmm: segfault: gracefully handle failure to alloc contextNeels Hofmeyr1-0/+4
This counter allocation error I hit uncovers a segfault when allocating an MM context fails in the GSM_MI_TYPE_TMSI case: DRANAP <001a> ../../../src/osmo-iuh/src/iu_client.c:509 handle_co_initial(dir=1, proc=19) DRANAP <001a> ../../../src/osmo-iuh/src/iu_client.c:229 RNC 23: new LAC 24358 RAC 22 DMM <0002> ../../../../src/osmo-sgsn/src/gprs/gprs_gmm.c:1271 MM(---/ffffffff) -> GMM ATTACH REQUEST MI(3427325924) type="GPRS attach" DLGLOBAL <001d> ../../../src/libosmocore/src/rate_ctr.c:195 counter group 'sgsn:mmctx' already exists for index 0 DMM <0002> ../../../../src/osmo-sgsn/src/gprs/gprs_sgsn.c:272 MM(/00000000) Cannot allocate counter group Program received signal SIGSEGV, Segmentation fault. gsm48_rx_gmm_att_req (llme=0x0, msg=0x555555886950, ctx=0x0) at ../../../../src/osmo-sgsn/src/gprs/gprs_gmm.c:1375 1375 ctx->p_tmsi = tmsi; Fix it with a bit of code already present for the GSM_MI_TYPE_IMSI case just above the segfault. Change-Id: I49aa95b610f2faec52dede2e4816da47ca1dfb14
2017-10-27Log GTP-U endpoints updateMax1-0/+2
* make gtp_ntoa() public after renaming it to sgsn_gtp_ntoa() to avoid confusion with libgtp functions * use it to log GTP-U endpoints address updates Change-Id: I96d0f3a63cce338471cc39cc33fd44c39cd2aa73 Related: SYS#3610
2017-10-09Check for correct P-TMSI allocationMax1-2/+5
Do not assign new P-TMSI if allocation failed. Change-Id: Ifa71bbc8df726c74aceaf9ae3eb49e124a53910a
2017-10-09Move P-TMSI alloc/update into separate functionMax1-13/+16
Remove code duplication by allocating and assigning P-TMSI in a static function. Change-Id: Ie5466326a851867d55da389bf18b240acd3f0fc5
2017-09-06move include/openbsc to include/osmocom/sgsnNeels Hofmeyr1-9/+9
Change-Id: I281ef585fffc2644682c8282224fb1c2da5ca795
2017-08-30split off osmo-sgsn: remove files, apply build1.1.0Neels Hofmeyr1-6/+1
Change-Id: I5d27ff93e56cd13e0e70edd15e2080201e35e91f
2017-08-30move libiu to osmo-iuh/libosmo-ranapNeels Hofmeyr1-19/+28
Remove libiu here, use the functions from libosmo-ranap instead, by applying the ranap_ / RANAP_ prefix. Corresponding change-id in osmo-iuh.git is I6a3f7ad15be03fb94689b4af6ccfa828c25f45c0 To be able to run the msc_vlr tests for RAN_UTRAN_IU without Iu client headers available, add iu_dummy.h, containing mere function signatures that match iu_dummy.c and a mostly empty struct ranap_ue_conn_ctx. Make sure we can build with and without --enable-iu: include osmo-iuh headers only with --enable-iu. Change-Id: Ib8c4fcdb4766c5e575618b95ce16dce51063206b
2017-08-27Implement IuCS (large refactoring and addition)Neels Hofmeyr1-2/+8
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-27IuPS: explicitly check RAN type; move commentNeels Hofmeyr1-1/+3
Change-Id: I054d72590dfb2012f6f8506d3a5f8fd2953194e1
2017-08-27IuPS: don't require an MM context for Iu ReleaseNeels Hofmeyr1-5/+13
Change-Id: I8b4d08b3ee8add1f1d54efb13985eabe0c9d31f3
2017-08-27GPRS/IuPS: remove all 3G authentication dev hacksNeels Hofmeyr1-27/+0
UMTS auth works now with the external OsmoHLR. Change-Id: Ie42945bb687b077fd0ee430c2711d19782151610
2017-08-27move openbsc/* to repos rootNeels Hofmeyr1-0/+2939
This is the first step in creating this repository from the legacy openbsc.git. Like all other Osmocom repositories, keep the autoconf and automake files in the repository root. openbsc.git has been the sole exception, which ends now. Change-Id: I9c6f2a448d9cb1cc088cf1cf6918b69d7e69b4e7