aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/gprs_subscriber.c
AgeCommit message (Collapse)AuthorFilesLines
2015-05-24gsup: Copy the hlr-Number and use it during purgeHolger Hans Peter Freyther1-0/+18
Copy the hlr-Number into the sgsn_data and use it during the purgeMS. There is no unit test that looks at the data we send so I manually verified this by looking at the output. Below is the output of the test that purges the subscriber. <000f> gprs_subscriber.c:170 SUBSCR(123456789012345) Sending GSUP, will send: 0c 01 08 21 43 65 87 09 21 43 f5 09 07 91 83 61 26 31 23 f3
2015-05-05sgsn: Store subscribed QoS and attempt to use itHolger Hans Peter Freyther1-0/+9
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-05-05sgsn: Copy the msisdn to the sgsn_data and use it in PDP activationHolger Hans Peter Freyther1-0/+14
The MSISDN should be present for "security" reasons in the first activation of a PDP context. Take the encoded MSISDN, store it for future use and then put it into the PDP activation request. The MM Context contains a field for a decoded MSISDN already. As we need to forward the data to the GGSN I want to avoid having to store TON and NPI in another place. Simply store the data in the encoded form.
2015-04-23misc: Fix warnings about size of size_t in printfHolger Hans Peter Freyther1-5/+5
Fixes warnings like: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat]
2015-04-07gprs: Fix GSUP cancel_type handling (Coverity)Jacob Erlbeck1-1/+2
When handling an incoming GSUP cancellation request, the cancel_type if effectively ignored, such that is always handled as GPRS_GSUP_CANCEL_TYPE_UPDATE and never as WITHDRAW. This commit fixes the expression used to set the variable is_update_procedure. Fixes: Coverity CID 1267739 Sponsored-by: On-Waves ehf
2015-02-06Revert "gprs: Block other GSUP procedures during PURGE_MS"Jacob Erlbeck1-50/+1
This reverts commit f81cacc6814dde73f203d125b0065d1451a98317. Since the PURGE MS retry mechanism had been removed, this feature is not used anymore. It just makes the code more complex. Conflicts: openbsc/include/openbsc/gprs_sgsn.h openbsc/src/gprs/gprs_subscriber.c openbsc/tests/sgsn/sgsn_test.c
2015-02-06sgsn: Add PDP info to subscriber dataJacob Erlbeck1-8/+77
Currently the PDP info that is transmitted via GSUP is just parsed and then discarded. This commit adds a new data structure sgsn_subscriber_pdp_data and maintains a list of those in sgsn_subscriber_data. The PDP data is copied from an incoming GSUP UpdateLocationResult message. If that message contains the PDPInfoComplete flag, the list is cleared before new entries are added. The 'show subscriber cache' output now also shows the PDP data entries. Note that the InsertSubscriberData message is still not supported. [hfreyther: Added talloc_free in gprs_subscr_pdp_data_clear] Sponsored-by: On-Waves ehf
2015-01-30gprs: Use 'Network failure' as default causeJacob Erlbeck1-0/+3
This commit adds a check after a GSUP message has been decoded whether it is an error message and does not contain a cause value. If his is the case, the cause value is set to 'Network failure', so that this cause if effectively the default value for error messages. Sponsored-by: On-Waves ehf
2015-01-30gprs: Send GSUP error reply for requests without IMSIJacob Erlbeck1-1/+7
Currently gprs_subscr_rx_gsup_message returns immediately after it detects that an IMSI has not been given in the received GSUP message. While this is ok for responses (result or error), a request should always be answered. This commit adds code to reply with a corresponding error message ("Invalid mandatory information") when it receives a request without an IMSI. Note that the generated error message will not contain an IMSI either. Sponsored-by: On-Waves ehf
2015-01-30gprs: Support cancellation typeJacob Erlbeck1-2/+13
The cancellation type that is part of the UpdateCancellation message is currently ignored. This patch adds the missing glue between the existing GSUP and GMM support. If the type is not present or has the value updateProcedure the subcriber and MM context are siliently removed. Otherwise, a message with cause 'implicitly detached' is sent to the MS. Since the real cause is not known (the specification neither added a cause IE nor defined a static cause value), the MS may get the real cause in the following AttachRej. Added VTY commands: - update-subscriber imsi IMSI cancel update-procedure - update-subscriber imsi IMSI cancel subscription-withdraw the old form without the cause is no longer supported. Sponsored-by: On-Waves ehf
2015-01-28gprs: Handle PURGE MS ERR/RES without subscrJacob Erlbeck1-2/+29
Currently the subscr entry is no longer present, when PURGE MS ERROR/RESULT arrives. In this case, an unspecific notice is logged ('unknown IMSI'). This clutters up the logfile with notices even in perfectly normal operation. This commit changes the code path that is used when a subscr cannot be found for an incoming GSUP message. A check for PURGE MS RESULT and ERROR is added and gprs_subscr_handle_gsup_purge_no_subscr is called for these messages instead of gprs_subscr_handle_unknown_imsi. Sponsored-by: On-Waves ehf
2015-01-28gprs: Don't use subscr->keep_in_ram in normal operationJacob Erlbeck1-2/+0
Currently the keep_in_ram flag is explicitely reset in gprs_subscr_cleanup to cover the case, that the VTY 'create' sub-command has been used to create the subscriber entry. This commit completely removes keep_in_ram handling from gprs_subscriber.c and adds a VTY 'destroy' sub-command to reset the flag and remove the entry. So 'create' and 'destroy' can be used to manager sticky entries that are kept even when a location cancellation is done. Added VTY command: - update-subscriber imsi IMSI destroy Sponsored-by: On-Waves ehf
2015-01-28sgsn: Don't allow mmctx == NULL in sgsn_update_subscriber_dataJacob Erlbeck1-2/+4
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-27gprs: Rename gprs_subscr_delete to gprs_subscr_cleanupJacob Erlbeck1-2/+2
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-4/+3
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 the "permanent" subscriber cacheHolger Hans Peter Freyther1-79/+5
The subscriber cache would help in case: * GPRS DETACH, GPRS ATTACH. In that case we might still have some cached authentication tuples we avoid another sendAuthenticationInfo request. * After a detach the cache expiry would make sure to eventually send a purgeMS to the HLR (which might be ignored). At the same time to make the cache work we will need to make sure to start and stop timers. In case we don't start we might accumulate subscribers. I am afraid that the above two benefits do not outweight the complexity of this implementation.
2015-01-20sgsn: Add SGSN_ERROR_CAUSE_NONE and use it instead of 0Jacob Erlbeck1-4/+6
Currently an error_cause of 0 is being used to indicate normal operation. Albeit this is not a defined GMM cause, the value is not explicitly reserved. This commit adds the macro SGSN_ERROR_CAUSE_NONE and uses it for initialisation (instead of relying on talloc_zero) and comparisons. The value is set to -1 to be on the safe side. The VTY code is updated to set the error_cause when using the 'update-subscriber imsi IMSI update-location-result CAUSE' command. Sponsored-by: On-Waves ehf
2015-01-20gprs: Support the full cancellation procedureJacob Erlbeck1-5/+18
Currently no GSUP LocationCancellationResult message is sent back to the peer (HLR), if the procedure succeeded at the SGSN's side. This patch adds the missing message and put the whole request handling of this procedure into a separate function. Ticket: OW#1338 Sponsored-by: On-Waves ehf
2015-01-20gprs: Don't create a subscr entry on InsertSubscriberDataJacob Erlbeck1-4/+1
Currently gprs_subscr_rx_gsup_message creates a subscriber entry if such an entry doesn't exist for the IMSI within an InsertSubscriberData GSUP message. This behaviour is not compliant to GSM 09.02, 20.3.3.2 (Subscriber data management/SGSN) where it is defined, that an error ("Unidentified subscriber") shall be returned. This patch removes the case distinction, so that an existing subscriber entry is required for all incoming GSUP messages. Sponsored-by: On-Waves ehf
2015-01-20gprs: Add replies for all GSUP requestsJacob Erlbeck1-8/+51
Currently, an incoming GSUP request message isn't answered at all if it is not handled due to an error or missing implementation. This patch adds GSUP error replies for these requests (and only for requests). It also adds tests for these cases. Note that several of these tests check for GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL, which will have to be changed, when the features are implemented. Sponsored-by: On-Waves ehf
2015-01-20gprs: Block other GSUP procedures during PURGE_MSJacob Erlbeck1-1/+55
GSM 09.02, 19.4.1.4 mandates that no other MAP procedures shall be started until the PURGE_MS procedure has been completed. This patch implements this by adding corresponding state and checks to gprs_subscr_purge, gprs_subscr_location_update, and gprs_subscr_update_auth_info. If an Update Location or a Send Auth Info Req procedure is not started because of blocking, the retry mechanism is aborted to shorten the blocking time. The outstanding Purge MS procedure itself is not aborted. Sponsored-by: On-Waves ehf
2015-01-18gprs: Retry PURGE_MS procedure after timeoutJacob Erlbeck1-1/+13
Currently, when the PURGE_MS_REQ to the HLR gets lost (e.g. by a connection or peer failure), the expired subscriber entry will not get deleted. This commit adds a retry mechanism then restarts the procedure after a timeout (currently 10s). The maximum number of retries is limited (currently to 3 PURGE_MS messages). If none of these procedures is completed (either with success or error), the subscriber data is deleted. Sponsored-by: On-Waves ehf
2015-01-18gprs: Use PURGE MS messagesJacob Erlbeck1-0/+82
When a subscriber entry is going to be deleted by SGSN and when the subscriber info has been obtained from a remote peer via GSUP, the peer should be informed before the entry is really deleted. For this purpose, MAP defines the PURGE MS procedure (see GSM 09.02, 19.1.4). This patch adds support for the PURGE_MS_REQ/_ERR/_RES messages and invokes the procedure when the subscriber entry is going to be removed. This only applies if GSUP is being used, the Update Location procedure has been completed successfully, and the subscriber has not been cancelled. The removal of the entry is delayed until a PURGE_MS_RES or PURGE_MS_ERR message is received. Note that GSM 09.02, 19.1.4.4 implies that the subscriber data is not to be removed when the procedure fails which is not the way the feature has been implemented. Note that handling 'P-TMSI freezing' is not implemented. Ticket: OW#1338 Sponsored-by: On-Waves ehf
2015-01-18gprs: Add expiry timeout for subscriber entriesJacob Erlbeck1-2/+45
Set the expiry delay after the subscriber has been deleted (e.g. by freeing the MM context). If cancelled, the subscriber will be deleted immediately and no timeout will be set. If the expiry time is set to SGSN_TIMEOUT_NEVER, no timer will be started and the subscriber entry will be kept until it is cancelled. The following VTY command is added to the sgsn node: - subscriber-expiry-time <0-999999> set expiry time in seconds - no subscriber-expiry-time set to SGSN_TIMEOUT_NEVER The default is an expiry time of 0 seconds, which means that the subscriber entries are wiped out immediately after an MM context is destroyed. Note that unused MM contexts are not expired yet. Therefore the subscriber will only be expired after a successful MM detach. Sponsored-by: On-Waves ehf
2015-01-18gprs: Pass GMM causes related to the MSC connectionJacob Erlbeck1-3/+9
Currently the error causes MSC_TEMP_NOTREACH, NET_FAIL, and CONGESTION are silently dropped to force the MS to continue. On the other hand, GSM 04.08/24.008, 4.7.3.1.4 in combination with 4.7.3.1.5, require the MS to retry the attachment procedure for cause codes above 15 instead of disabling GPRS. All of the mentioned GMM causes have codes above 15, so using a REJECT message including the cause code is a better choice. This way, the retry algorithm based on T3311 (15s, 5 times) and T3302 (default 12min) could be used. This patch modifies gprs_subscr_handle_gsup_auth_err and gprs_subscr_handle_gsup_upd_loc_err to proceed like when the access has beed denied, except that the corresponding subscriber's information fields are not cleared. This has been successfully tested which an iphone which enters a retry loop as it is being described in the specification. Sponsored-by: On-Waves ehf
2015-01-18gprs: Use LOGGSUBSCRP and LOGMMCTX for logging in gprs_susbcriber.cJacob Erlbeck1-58/+58
To unify the layout of the logging messages in gprs_subscriber.c, this patch replaces each LOGP by LOGGSUBSCRP, unless a non-NULL pointer to a subscr is not available. In those cases, it uses LOGMMCTXP if a pointer to an MM context is available or LOGP otherwise. Sponsored-by: On-Waves ehf
2015-01-18gprs: Let GSUP parser functions return GMM causes on errorsJacob Erlbeck1-5/+6
Currently the GSUP message handling function in gprs_subscriber.c and the functions in gprs_gsup_messages.c are not consistent with respect to the return codes if an error happens. Albeit all error return codes are negative, the semantics of the absolute value are not clearly defined. In addition, some return codes are not passed to the calling function. This path changes these functions to always return a negated GMM cause value in case of errors. Return values of called parser functions are not longer ignored. Sponsored-by: On-Waves ehf
2015-01-18gprs: Use the cause value in GSUP error messagesJacob Erlbeck1-16/+94
Currently always a cause with the meaning of 'access denied' is assumed. gprs_subscr_handle_gsup_auth_err just clears the auth triplets and the authorized flag before calling the update function. gprs_subscr_handle_gsup_upd_loc_err only clears the authorized flag and calls the update function. This means, that an MS will not retry to attach even on temporary network errors. This patch changes these functions to use the GSUP error cause value to decide, whether to clear the corresponding subscriber fields, to just continue with the corresponding update function, or to log, ignore and not pass the cause to the MS in case the error is directly related to the GSUP protocol. The subscriber's error_cause field is updated, if the update function is going to be called. The error_cause fielt is reset on non-error GSUP messages. Sponsored-by: On-Waves ehf
2015-01-18gprs: Handle incoming IPA CCM message in gsup_client_read_cbJacob Erlbeck1-0/+1
Currently the IPA CCM messages are not handled by the GSUP client. This means, that the client doesn't answer to PING and ID_GET and logs notices when receiving PONG or ID_ACK. At least the PING functionality (remotely originated PING) shall be supported. This patch extends gsup_client_read_cb by a call to ipaccess_bts_handle_ccm. Only when the return code is 0, the message is processed further and checked for an OSMO/GSUP message. ID_GET messages are answered by a dummy description, where only the unit_name is set to 'SGSN'. Sponsored-by: On-Waves ehf
2015-01-18sgsn: Integrate the GSUP client into the SGSNJacob Erlbeck1-5/+47
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-10gprs: Add subscriber functions to create/handle GSUP messagesJacob Erlbeck1-6/+205
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]
2014-12-24sgsn: Add a subscriber based authentication phaseJacob Erlbeck1-29/+62
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 Erlbeck1-0/+4
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-09sgsn: Put SGSN related subscriber data into separate structJacob Erlbeck1-8/+20
There will be an increasing number of SGSN related fields per subscriber. Instead of extending gsm_subscriber accordingly, a single struct sgsn_subscriber_data object is assigned to it. The talloc context used to allocated that object is the subscr object itself. Therefore it will be freed automatically along with the subscr object. Sponsored-by: On-Waves ehf
2014-12-09sgsn: Add gprs_subscriber.cJacob Erlbeck1-0/+144
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