aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/gprs_sgsn.c
AgeCommit message (Collapse)AuthorFilesLines
2017-10-26remove sgsn, gbproxy and gtphub from openbsc.gitHarald Welte1-923/+0
The GPRS related programs osmo-sgsn, osmo-gtphub and osmo-gbproxy have been split off into the separate osmo-sgsn repository, which can be found at git://git.osmocom.org/osmo-sgsn.git http://git.osmocom.org/osmo-sgsn/ This is technically unrelated but conceptually part of the larger NITB-split activities. I did a brief log of all changes in src/gprs and couldn't find any commits that we might have applied here but which are missing from osmo-sgsn.git. Change-Id: If60e28b23f5cfb2c4eb354951363a2bb63f3e0de
2017-08-14Migrate from gprs_apn_to_str() to libosmocore osmo_apn_to_str()Harald Welte1-1/+2
In 2015, Jacob moved/copied related functions to libosmocore, but for some reason didn't remove the copies here. Let's follow-up on that and remove duplicated code. The libosmocore commit introducing osmo_apn_to_str() was 8114294bf29ac6e44822c0ae43d4b0819f11b022 Change-Id: I7315ffcbed8a54cca2056f313bb7783ad82d0ee9
2017-07-12check for missing result of rate_ctr_group_alloc()Harald Welte1-0/+16
In case the counter group allocation fails, we must handle this gracefully and fail the allocation of the parent object, too. RelateD: OS#2361 Change-Id: I7dad4a4d52fe05f6b990359841b4408df5990e21
2017-07-10sgsn: Fill the cch_pdp with a value coming from the tlv structureHolger Hans Peter Freyther1-5/+16
For some GGSNs we need to insert the PDP Charging Characteristics that were returned. We receive these values from GSUP and will fill them into the tlv structure when finding the ggsn context. Change-Id: I1725bfd2403d29ce3550bfcd6fcc1498426ef906
2017-05-10src: use osmo_timer_setup()Pablo Neira Ayuso1-3/+1
Use new function available in libosmocore to set up timers. Compile tested only. Change-Id: Ibcfd915688e97d370a888888a83a7c95cbe16819
2017-03-14gprs_sgsn.c: initialize ptmsi with 0xdeadbeefAlexander Couzens1-1/+1
Fix uninitialized memory access warning. "Conditional jump or move depends on uninitialised value" Found by valgrind. Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a
2017-02-25add struct gprs_subscr, separating gprs from gsm_subscriberNeels Hofmeyr1-3/+3
Prepare for replacing gsm_subscriber with vlr_subscriber. vlr_subscriber will not make sense to be used in gprs, so have a dedicated GPRS subscriber struct. (Could change if the gprs code were to use libvlr; is currently independent). Related: OS#1592 Change-Id: Ia8b391ee009c8545763cba04505be3947835120e
2017-02-07gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLEAlexander Couzens1-0/+1
Previous the state was only set in Iu mode. Change-Id: I99a6aec1090cad9b9d38d134cc9b34ef292062df
2017-02-07gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb()Alexander Couzens1-2/+2
Postfix the ran type to clarify the purpose. Because of the new support of the Iu ran type, there are 2 functions to allocate a mm ctx. For Iu it's sgsn_mm_ctx_alloc_iu(). For gb it should be named in the same way. Change-Id: Ic49009e8c20c12308855e1409c09004698c79b95
2017-02-07gprs/sgsn: rename gprs->mm_state -> gmm_stateAlexander Couzens1-3/+3
GMM is the right term. MM state is already occupied. Change-Id: I9cfdcf921e4ebd14a5e7ce7489ec4ce5d1f5515f
2016-12-21Improve GPRS loggingMax1-0/+2
* log xid type as string instead of int * log packet encryption status, algorithm and IOV-UI in debug mode * print encryption parameters when dumping llme via vty * log key propagation from MM to LLC Related: OS#1794 Change-Id: I30c38fdeb0b88bb39bdb9928851300bc79e6aec6
2016-12-13Revert "Support Deactivate PDP Context Request from network"Neels Hofmeyr1-38/+0
This reverts commit 1611df5226199da2bf2fba3d22d93cc1a6c6c777. This is due to a segfault introduced to the asan build only. See: http://lists.osmocom.org/pipermail/openbsc/2016-December/009966.html Subject: new sanitizer breakage: SIGSEGV in sgsn_create_pdp_ctx() Date: Tue Dec 13 12:08:32 UTC 2016 Change-Id: Ic926c0e6778947b516994822e3a21d4fde25bb02
2016-12-12Support Deactivate PDP Context Request from networkPravin Kumarvel1-0/+38
Enable Deactivate PDP context based on the IMSI of the subscriber. When there are PDP contexts present for a MM context, PDP context will be deactivated along with GMM Detach(MM context deletion). If there are no PDP present, MM context will be deleted to avoid further PDP context request from the MS. Test cases is added to check this functionality. Change-Id: Ia0a41aa2218ec2fda4ea17a37c8cc55cba63dd13
2016-09-02IuPS: sgsn_mm_ctx: add enum gprs_pmm_state field, track PMM stateDaniel Willmann1-0/+1
Iu needs to page to transfer data in PMM-IDLE state. Change-Id: Id37778cb9a0328a21c8e8246998ecdb43dd687d8
2016-09-02IuPS: send Security Mode Command, track the new_key flag.Daniel Willmann1-0/+1
Change-Id: I0b2593c2df13b79eb36975b0d302e31cfdf8bb09
2016-09-01IuPS: osmo-sgsn: add core IuPS impl, call iu_init()Daniel Willmann1-0/+41
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-08-27cosmetic: gprs_sgsn.c: move pdp.h include to topNeels Hofmeyr1-1/+2
Change-Id: I9a9b34d714235462ba72cdb65b7c8c9824dfa9c6
2016-08-27sgsn: add statistics counter for LLC packetsAlexander Couzens1-0/+4
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-07-25sgsn: add statistics counter for GPRS and PDP packetsAlexander Couzens1-0/+34
Changing the test to allow still allocated block from the rate counters. Change-Id: Ie30e4c3084ee3a138d6b39bb5000234ac814e65f
2016-07-16SGSN: add preliminary support for GPRS encryptionMax1-5/+1
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-16SGSN: split GEA key management from TLLIMax1-1/+1
Move GEA key from TLLI assignment into separate function. Change-Id: I8a0bc907072dc19cd9535a28b5252dc0f05357cc Related: OS#1582
2016-07-04SGSN: move TLLI unassignment into separate functionMax1-1/+1
Change-Id: Ia4df145ab03ebcaad70a13601cff60c488a5de54 Related: OS#1582
2016-06-02gprs: more conditionals for Gb specific actionsDaniel Willmann1-2/+4
Change-Id: I213d21b9ddbf19e56269defcc6aa65aca4947140
2016-06-02sgsn_mm_ctx_cleanup_free(): clean up LLME iff present (Gb, not Iu)Daniel Willmann1-3/+10
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-01prepare sgsn_mm_ctx for Gb and Iu mode (UMTS)Harald Welte1-6/+7
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-04-29move gsm_04_08_gprs.h to libosmocoreHarald Welte1-1/+1
This requres the corresponding commit in libosmocore.
2016-02-22sgsn: Re-add searching for MM ctx based on TLLI / P-TMSI matchesJacob Erlbeck1-0/+25
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-22sgsn: Only look at TLLIs in sgsn_mm_ctx_by_tlliJacob Erlbeck1-30/+1
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-22sgsn: Make ra_id_equals available as gprs_ra_id_equalsJacob Erlbeck1-9/+2
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
2015-11-02stats: Set class_id in rate_ctr group descriptionsJacob Erlbeck1-0/+3
This commit adds the class_id initialiser to all rate_ctr_group_desc definitions. Sponsored-by: On-Waves ehf
2015-10-13gprs: Use RAND_bytes for p-tmsiDaniel Willmann1-1/+5
[hfreyther: Link to libcrypto, include header, add uint8_t* cast]
2015-10-12Revert "gprs: Use RAND_bytes for p-tmsi"Holger Hans Peter Freyther1-5/+1
The commit not compiling/linking should have been a strong indicator that it has not been tested either. This reverts commit 6cf0249dacc4ae46eb0857c007906c9a3f128a3e.
2015-10-12gprs: Use RAND_bytes for p-tmsiDaniel Willmann1-1/+5
[hfreyther: Link to libcrypto, include header, add uint8_t* cast]
2015-06-02sgsn: seleted_apn_str might be NULL do not strcpyHolger Hans Peter Freyther1-1/+4
The subscriber might simply not be allowed to use the APN that was specified. So selected_apn_str might very well be NULL. Fixes: Coverity CID#1302853
2015-05-25sgsn: Allow to resolve the IPv4 address of a GGSN through DNSHolger Hans Peter Freyther1-1/+17
For real networks we need to check if the requested APN string is allowed and then resolve the GGSN address through DNS. There are countries with two or three digit MNCs and one could either try to keep a list of countries that have two/three digits or just try both of them. I have opted for the later for the ease of the implementation. C-Ares doesn't allow to cancel a request so we will need to have the MMCTX and the Lookup have different lifetimes. We simply set ->mmctx to NULL in case the MMCTX dies more early. The selected and verified apn_str will be copied into the out parameter. In case no static APN/GGSN config is present and the dynamic mode is enabled a request will be made.
2015-05-25sgsn: Deal with no static ggsn being configured at allHolger Hans Peter Freyther1-0/+7
In case no static ggsn is configured the code would crash with the assumption that there is always such a GGSN.
2015-05-25sgsn: If there is a subscr don't allow an empty listHolger Hans Peter Freyther1-2/+1
This is a left-over from the initial system where no PDP was provided by the system. For now if there is a subscr attached and no PDP context provisioned. He is not allowed to have a data connection. Update the testcase to create the pdp list entry more early with a wildcard and then change it to a specific match.
2015-05-06sgsn: Add various signals consumed by CDR or other client codeHolger Hans Peter Freyther1-0/+19
2015-05-06sgsn: Make the free function internalHolger Hans Peter Freyther1-1/+1
All calls should and do go through the sgsn_mm_ctx_cleanup_free function.
2015-05-05sgsn: Store subscribed QoS and attempt to use itHolger Hans Peter Freyther1-0/+15
sgsn_create_pdp_ctx should use the subscribed QoS. When selecting the PDP context we inject the QoS to be used into the TLV structure and use it during the request. Assume a "qos-Subscribed" structure only with three bytes and prepend the Allocation/Retention policy to the request.
2015-02-06sgsn: Select GGSN based on APNJacob Erlbeck1-0/+110
Currently the APN IE in the Activate PDP Contex Request and the PDP data that is stored with the subscriber is ignored completely. This commit adds the sgsn_mm_ctx_find_ggsn_ctx that checks the APN IE against the subscriber's PDP data entries if both are present. If there is no match, the request is rejected. If an APN IE has not been included but PDP data entries are present, the function checks all of these entries against the static 'apn' configuration to find a suitable entry. If an APN has not been determined so far and any APN is allowed, the configuration is checked with an empty APN string, to allow for default configurations based on the IMSI prefix only. If nothing of this succeeded but the request wasn't rejected either, and there is no 'apn' configuration at all or if any APN is allowed but a default configuration ist not present, the GGSN with id 0 is used (if present). Otherwise the request is rejected ('missing APN'). Ticket: OW#1334 Sponsored-by: On-Waves ehf
2015-02-06sgsn: Add sgsn_ggsn_ctx_free functionJacob Erlbeck1-0/+6
This function will be needed for testing, since the leak check would fail if the GGSN context are not cleaned up after use. Sponsored-by: On-Waves ehf
2015-02-06sgsn: Add functions to handle APN contextsJacob Erlbeck1-9/+68
This commit adds the exported functions apn_ctx_find_alloc, apn_ctx_free, apn_ctx_by_name, and apn_ctx_match to manage and retrieve APN to GGSN mappings. The following VTY commands are added to 'config-sgsn': - apn APN ggsn <0-255> - apn APN imsi-prefix PREFIX ggsn <0-255> which maps an APN gateway string to an SGSN id. The SGSN must be configured in advance. When matching an APN string, entries with a leading '*' are used for suffix matching, otherwise an exact match is done. When a prefix is given, it is matched against the IMSI. If several entries match, a longer matching IMSI prefix has precedence. If there are several matching entries with the same PREFIX, the entry with longest matching APN is returned. Ticket: OW#1334 Sponsored-by: On-Waves ehf
2015-01-28sgsn: Add sgsn_mm_ctx_cleanup_free for safe shutdownJacob Erlbeck1-9/+30
Currently the MM context cleanup code is distributed over several functions. sgsn_mm_ctx_free not only frees data structure but also eventually stops the timer and does the subscriber clean-up. mm_ctx_cleanup_free (gprs_gmm.c) cleans up the PDP contexts and unassign the TLLI. This commit moves the cleanup code from both functions into a new unifying function sgsn_mm_ctx_cleanup_free that cares about the clean-up of all related sub-systems. Sponsored-by: On-Waves ehf
2015-01-28sgsn: Don't allow mmctx == NULL in sgsn_update_subscriber_dataJacob Erlbeck1-19/+2
Currently, sgsn_update_subscriber_data can be called with mmctx == NULL and will find and associate the right context (if present) based on the subscriber's IMSI. This will not happen in regular use any more, since sgsn_update_subscriber_data will only be called when subscribers are used (auth mode 'remote') and in this case gprs_subscr_get_or_create_by_mmctx will already be called by sgsn_auth_request. Therefore, MM context and subscriber are always associated except for some test cases and experimental VTY usage. The current implementation of sgsn_update_subscriber_data also causes additional complexity for the deletion on MM contexts to avoid a ipossible double-free MM contexts. This commit removes the MM context <-> subscriber association code from sgsn_update_subscriber_data. That function must always be called with mmctx != NULL, now. To avoid problems with VTY and test usage, the calling subscriber function now only call sgsn_update_subscriber_data when mmctx != NULL, since the purpose of that function is to update that state of an existing MM context after subscriber data has been changed. Sponsored-by: On-Waves ehf
2015-01-27sgsn: Don't reset mm->subscr manually in sgsn_mm_ctx_freeJacob Erlbeck1-3/+1
Currently the sgsn_mm_ctx_free contains code to reset the mm->subscr field that is also present in gprs_subscr_cleanup, which is called directly afterwards. This commit modifies the code path, so that the cleanup is done by the gprs_subscr_cleanup function. The additional reference counter increment is needed, since mm->subscr->mm->subscr (which is the same like mm->subscr) will be reset (and unref'd) within gprs_subscr_cleanup. Because the local variable subscr in sgsn_mm_ctx_free is an additional pointer to the subscriber object, it is consequent to adjust the reference counter when the assignment is done. Sponsored-by: On-Waves ehf
2015-01-27gprs: Rename gprs_subscr_delete to gprs_subscr_cleanupJacob Erlbeck1-1/+1
The old name is somewhat misleading. The function is rather preparing the subscriber for a subsequent subscr_free, that is possibly invoked by a subscr_put. It detaches the subscriber from the MM context and optionally invokes a PURGE_MS procedure. Therefore the _cleanup suffix is chosen (see mm_ctx_cleanup_free). Sponsored-by: On-Waves ehf
2015-01-26gprs: Do not put the subscr in gprs_subscr_deleteJacob Erlbeck1-0/+1
Currently gprs_subscr_delete implicitely calls subscr_put, which makes the code more complex than necessary (additional subscr_get) in a few places. It also makes it more difficult to see, whether get/put are balanced within a function. In addition, the functions are not named consistently (gprs_subscr_delete vs. gprs_subscr_put_and_cancel). This commit changes the semantics of gprs_subscr_delete and indirectly of gprs_subscr_put_and_cancel to not call subscr_put on their argument, but to leave that for the caller to do it explicitely. It renames gprs_subscr_put_and_cancel to gprs_subscr_cancel to reflect that change in the name, too. Sponsored-by: On-Waves ehf
2015-01-26sgsn: Remove MM from the list before gprs_subscr_delete is calledHolger Hans Peter Freyther1-3/+3
Modify sgsn_mm_ctx_free to remove the entry from the list as otherwise we might double free the context from within gprs_subscriber_delete.
2015-01-26sgsn: Remove inactive LLME/MM after inactivity timeoutJacob Erlbeck1-0/+63
Currently old LLMEs and MM contexts that haven't been explicitly detached or cancelled are not removed until another request with the same IMSI is made. These stale entries may accumulate over time and severely compromise the operation of the SGSN. This patch implements age based LLME expiry, when the maximum age has been reached, the corresponding MM context is cancelled. If such an MM context doesn't exist, the LLME is unassigned directly. The implementation works as follows. - llme->age_timestamp is reset on each received PTP LLC message - sgsn_llme_check_cb is invoked periodically (each 30s) - sgsn_llme_check_cb sets the age_timestamp to the current time if it has been reset - sgsn_llme_check_cb computes the age and expires the LLME if it exceeds gprs_max_time_to_idle() Ticket: OW#1364 Sponsored-by: On-Waves ehf [hfreyther: Fix typo in comment LMME -> LLME]