aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2015-01-20gprs: Don't create a subscr entry on InsertSubscriberDataJacob Erlbeck2-6/+2
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 Erlbeck4-10/+103
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 Erlbeck4-1/+160
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 Erlbeck2-1/+14
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 Erlbeck4-7/+96
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: Implement PURGE_MS GSUP messagesJacob Erlbeck4-0/+35
This commit implements the encoding and decoding of the messages - Purge MS Request - Purge MS Error - Purge MS Result and adds corresponding tests. Sponsored-by: On-Waves ehf
2015-01-18sgsn/doc: Add message definitions for PURGE_MS responsesJacob Erlbeck1-2/+10
Currently the definitions of the message PURGE_MS_RES and PURGE_MS_ERR are missing in the specification. This patch adds those definitions. Sponsored-by: On-Waves ehf
2015-01-18sgsn/test: Add checks and reports to detect subscr leakageJacob Erlbeck1-4/+26
This commit adds talloc reports to log remaining NULL chunks after the terminates. It also adds explicit checks for empty subscriber lists. Sponsored-by: On-Waves ehf
2015-01-18sgsn/test: Add test that intercepts gprs_gsup_client_sendJacob Erlbeck3-3/+101
This test replaces gprs_gsup_client_send by a custom function, that emulates a GSUP remote peer by calling gprs_subscr_rx_gsup_message with responses for all requests. It then executes a full Attach/Detach cycle. Sponsored-by: On-Waves ehf
2015-01-18gprs: Add expiry timeout for subscriber entriesJacob Erlbeck5-3/+119
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-18sgsn/test: Refactor subscriber testJacob Erlbeck1-21/+24
The code sequence that checks, whether a subscriber is still reachable for a given IMSI, is repeated several times. This patch puts this code sequence into a single function and adds a check for the IMSI after the entry has been found. In addition, some comments are extended. Sponsored-by: On-Waves ehf
2015-01-18sgsn/test: Fix subscriber cleanupJacob Erlbeck1-1/+4
Currently the subscribers are not really deleted by cleanup_subscr_by_imsi, but kept in RAM instead. This patch fixes this and adds a test to verify, that the subscriber is really deleted afterwards. Sponsored-by: On-Waves ehf
2015-01-18gprs/test: Move subscr cleanup code into a separate functionJacob Erlbeck1-9/+12
Refactor several occurences of the same subscriber cleanup code into a seperate cleanup_subscr_by_imsi function. 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: Add LOGGSUBSCRP macro to log subscriber infoJacob Erlbeck1-0/+4
This patch adds a new logging macro, that logs to DGPRS and provides a uniform prefix containing the IMSI without using the mm reference. This is an improvement over using LOGMMCTXP, since the new macro also provides an IMSI if no MM context is attached. Sponsored-by: On-Waves ehf
2015-01-18gprs: Let GSUP parser functions return GMM causes on errorsJacob Erlbeck3-9/+11
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-18sgsn: Pass subscriber error causes to the GMM layerJacob Erlbeck5-39/+40
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 Erlbeck5-112/+163
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: Show GSUP client info on 'show sgsn'Jacob Erlbeck1-0/+11
This commit adds a line to the output of 'show sgsn' if the GSUP client has been initialized: - Remote authorization: [not] connected to HOST:PORT via GSUP Sponsored-by: On-Waves ehf
2015-01-18gprs: Send PING and eventually reconnectJacob Erlbeck2-3/+61
Currently, the reconnect mechanism relies on gsup_client_updown_cb which in turn gets called based on the OS' view of connection state. This patch adds a timer based PING mechanism that regularly sends PING messages and forces a reconnect if a PONG message won't be received until the next PING message is scheduled. The current ping interval is 20s. Sponsored-by: On-Waves ehf Conflicts: openbsc/src/gprs/gprs_gsup_client.c [hfreyther: Conflicts due the potential memleak fix by me. Removed another TODO from the code as we stop the ping/pong timer]
2015-01-18gprs: Handle incoming IPA CCM message in gsup_client_read_cbJacob Erlbeck2-0/+26
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-18gprs: Handle return code of ipa_client_conn_open correctlyJacob Erlbeck1-3/+6
The ipa_client_conn_open function does not distinguish between a connection being already established or waiting for establishment. In either case, the application gets informed about the connection state via the updown_cb. The 'up' parameter is only set, if poll/select consider the socket as writable. This patch handles both cases equally and fully relies on the updown_cb to adjust the gsupc obejct state. Sponsored-by: On-Waves ehf
2015-01-18gprs: Avoid sending stale GSUP requests after reconnectJacob Erlbeck1-0/+8
Currently, messages are added to the tx queue even if the connection is down for some reason and all of these messages are eventually sent after a re-connect. The MS has probably sent several Attach Requests while the connection was down and will continue doing so. Therefore these stored messages could be dropped. This patch clears the queue before re-connecting and also extends gprs_gsup_client_send to return immediately, when the connection is not established instead of calling ipa_client_conn_send. Sponsored-by: On-Waves ehf [hfreyther: Replaced while (!llist_empty(&gsupc->link->tx_queue)) llist_del(gsupc->link->tx_queue.next); with new libosmo-abis API]
2015-01-18gprs: Add automatic re-connect if the GSUP connection is downJacob Erlbeck2-7/+76
Currently the GSUP connection to a server is not restarted if the connection cannot be established or is terminated during operation. This commit adds a timer based connection mechanism, basically consisting of a timer callback that calls gsup_client_connect. The timer is eventually triggered (up == 0) or cleared (up != 0) by gsup_client_updown_cb. It adds calls to osmo_timer_del() to gsup_client_connect and gprs_gsup_client_destroy. The latter is now called instead of talloc_free in gprs_gsup_client_create on error to be on the safe side. 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 Erlbeck4-4/+11
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-18gprs: Remove now unused authenticate flagHolger Hans Peter Freyther1-1/+0
This has been obsoleted by the previous commit. Remove it.
2015-01-18sgsn: Replace subscr.authenticate by global require_authentication flagJacob Erlbeck4-11/+10
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 Erlbeck6-6/+94
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: Add GSUP clientJacob Erlbeck4-2/+179
This commit adds the client code to get subscriber information from a remote server. It provides an IPA over TCP connection to transmit and receive GSUP messages. Sponsored-by: On-Waves ehf
2015-01-18gprs: Clear GSUP message structures before decodingJacob Erlbeck1-5/+5
Currently the message structure is not cleared before the message is parsed which can cause information leaking between messages if the same gprs_gsup_message object is used. Especially list elements (auth tuples and pdp info) are not replaced by an IE, but the IE is appended. This patch uses the assignment operator to clear gprs_gsup_message, gsm_auth_tuple, and gprs_gsup_pdp_info before using them. This also replaces the use of memcpy of the latter. Sponsored-by: On-Waves ehf
2015-01-18gprs: Always reset auth tuples/pdp infos in gprs_gsup_decodeJacob Erlbeck1-0/+3
Currently auth tuples are always appended to the lists when gprs_gsup_decode is called with a gsup_msg structure. This makes a test case fail, where the same gsup_msg is used again and again without clearing it after each use. Sponsored-by: On-Waves ehf
2015-01-18gprs: Handle empty GSUP messages correctlyJacob Erlbeck1-1/+4
Currently, the gprs_gsup_decode function doesn't check the return value of gprs_shift_v_fixed before using the value pointer. The function fails, if the GSUP message length (not including IPA headers) is 0. In this case, a segfault can happen, depending on the value of the uninitialized 'value' pointer. The test case doesn't trigger a segfault, but valgrind complains about reading uninitialized data. This patch adds a check for the return value that would return with an error code if the shift function failed. 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 Erlbeck5-6/+374
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 Erlbeck7-4/+662
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-10sgsn/doc: Add IPA default parametersJacob Erlbeck1-0/+6
This commit adds the default protocol identifiers that should be used for GSUP by the IPA protocol. Sponsored-by: On-Waves ehf
2015-01-10sgsn/doc: Add protocol specification for remote subscriber updateJacob Erlbeck1-0/+385
This is the first version of the specification for the GPRS Subscriber Update Protocol. Sponsored-by: On-Waves ehf
2015-01-10sgsn: Fix VTY command error handling (Coverity)Jacob Erlbeck1-3/+3
Currently the result of the osmo_hexparse function in update_subscr_insert_auth_triplet is not handled correctly. There is a misplaced leading exclamation mark in a few conditional expressions. This effectively disables the error checks, as it is noticed by Coverity ("Missing parentheses" followed by "Logically dead code"). This patch removes the exclamation marks. Fixes: Coverity CID 1260435 and CID 1260434 Sponsored-by: On-Waves ehf
2015-01-10meas: Unbreak the build once moreHolger Hans Peter Freyther2-6/+13
The code assumes that sqlite3.h is in the standard include path. Maybe sqlite3 wasn't installed or resides in a non standard (/usr/local) location? Fix the build as it has been broken since 1st of January.
2015-01-05Revert "debug.c: use new libosmocore features to print and save log filter"Harald Welte1-46/+0
This reverts commit c598e6e0a6d00827c2c974010d582815d66d0f14. It introduced a dependency from libcommon to libosmovty, which we don't want
2015-01-05meas_pcap2db.c: Fix build without CDKHarald Welte1-2/+0
Spotted by Jacob Erlbeck.
2015-01-05debug.c: use new libosmocore features to print and save log filterHarald Welte1-0/+46
2015-01-05RSL: Change "... is back in operation" to an INFO level messageHarald Welte1-1/+1