aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
AgeCommit message (Collapse)AuthorFilesLines
2014-10-09gbproxy: Send STATUS(BVCI unknown) to BSS on unknown PTP BVCIJacob Erlbeck1-4/+11
Currently BSSGP PTP messages are silently dropped when the BVCI is not known and patching is enabled. The nanoBTS will not recognize this and continue to send messages on the BVCI. If it receives a STATUS(BVCI unknown) instead, it will start a BVC reset procedure instead. This patch modifies gbprox_rx_ptp_from_bss() to return a STATUS(BVCI unknown) to the BSS instead of dropping the message. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Replace ';;' by ';'Jacob Erlbeck2-5/+5
This patch removes some superfluous ';' from the code. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Fix parser to accept GSM 24.008 Attach Req messagesJacob Erlbeck1-1/+1
Currently the parse expects a 'MS network capability' IE with 2 <= length <= 3 which is compliant to GSM 04.08, 9.4.1 but not to GSM 24.008, 9.4.1 which specifies 3 <= length <= 9. Thus the parser rejects messages with a length >= 4 (including length field). This patch relaxes the length check to accept either range by requiring 2 <= length <= 9. Ticket: OW#1258 Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Use a separate regexp for routingJacob Erlbeck4-7/+10
Currently one regexp ('patching') is used for all matching. This patch adds a second category 'routing' which is exclusively used for SGSN selection. It also adds a corresponding VTY command: - match-imsi patching RE : MS related patching (currently APN) - match-imsi routing RE : Select secondary SGSN on match only - no match-imsi : Clear all filter expressions Ticket: OW#1258 Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Extend the match-imsi VTY command to support categoriesJacob Erlbeck1-7/+20
This patch modifies the match-imsi command to allow for different match categories (currently only 'patching' is provided). - match-imsi patching RE : Filter APN patching and routing - no match-imsi : Clear all filter expressions Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Cleanup match config after testsJacob Erlbeck2-28/+35
Currently, patch filter configurations are leaking between tests. This adds a call to gbproxy_clear_patch_filter() to the end of each test that calls gbproxy_set_patch_filter(). Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Refactor IMSI matchingJacob Erlbeck6-97/+133
The current implementation makes it difficult to add further match expressions. This patch adds a new struct gbproxy_match that contains the fields needed for each match expression. The matches (config) and the results (link_info) are stored in arrays. All related functions are updated to use them. The old fields in the config structure are removed. Sponsored-by: On-Waves ehf
2014-10-09gbproxy/test: Add expect_msg checks to test_gbproxy_ra_patchingJacob Erlbeck1-0/+59
This patch adds assertions to check the LLC/GMM message received from the gbproxy by the test framework within the function test_gbproxy_ra_patching. Sponsored-by: On-Waves ehf
2014-10-09gbproxy/test: Save and check received messagesJacob Erlbeck1-0/+155
Currently the only way to check, whether the right message have been generated is to look into the generated text output. This is error-prone if there are many messages. This patch adds a way to optionally store all received messages into a FIFO. They can then be checked by calling expect_msg() which removes the first message from the FIFO and returns a pointer to it or NULL if there is none. The pointer is only valid until the next call to this function. A few convenience functions are added to check for common message types: - expect_gmm_msg checks for certain GSM 04.08 messages in LLC/GMM - expect_llc_msg checks for arbitrary LLC messages in BSSGP/UD - expect_bssgp_msg checks for arbitrary BSSG messages Each of their arguments can be set by MATCH_ANY to ignore it while matching. On success, they return a pointer to a statically allocated struct containing the pointer to the msg and the full parse context. Recording is enabled by setting the global variable received_messages to a pointer to a struct llist_head. It can be disabled again by setting it to NULL. Sponsored-by: On-Waves ehf
2014-10-09gprs: Fix gprs_msgb_copy pointer computationJacob Erlbeck1-7/+15
Currently the pointers are computed by adding an offset to the new message's _data pointer even when the original pointer is NULL. This leads to invalid pointers in the copied msgb. This patch adds a NULL check to each computation such that NULL pointers are not adjusted. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Refactor local message generationJacob Erlbeck4-25/+33
This patch adds und uses the function gbproxy_gsm48_to_peer() which takes a GSM 04.08 message, encapsulates it in BSSGP and LLC, and sends it to the BSS peer. This function increments vu_gen_tx_bss which is now used instead of imsi_acq_retries to set the N(U) of the outgoing message. Since imsi_acq_retries isn't currently incremented before a Detach Accept is generated, this patch also fixes the N(U) of such messages. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Reset IMSI acquisition within gbproxy_unregister_link_infoJacob Erlbeck4-1/+10
Currently then link_info is not cleaned up completely, when gbproxy_unregister_link_info is called. This patch adds a function gbproxy_reset_link that must be defined externally. This is done in gb_proxy.c, where it resets the IMSI acquisition. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Parse Attach Reject messagesJacob Erlbeck3-1/+23
That message is currently ignored but should invalidate the TLLI and de-register the logical link instead. This patch extends the parser to recognize such messages and to set the invalidate_tlli flag. Sponsored-by: On-Waves ehf
2014-10-09gbproxy/test: Add invalidation tests to test_gbproxy_keep_info()Jacob Erlbeck2-17/+295
The TLLI should also be invalidated: - when an Attach Reject info is received from the SGSN - when an Attach Req is immediately followed by a Detach Req - when an Attach Req is immediately followed by an MT detach procedure To verify that, this patch adds corresponding message sequences to the test. Sponsored-by: On-Waves ehf
2014-10-09gbproxy/test: Fix IMSI length check (Coverity)Jacob Erlbeck1-1/+1
This fixes the IMSI length assertion, which currently uses a greater-or-equal than zero comparison which always yields true. It is replaced by a greater than zero check. Fixes: Coverity CID 1239442 Sponsored-by: On-Waves ehf
2014-10-09gbproxy/test: Fix time calculation in test_gbproxy_tlli_expire()Jacob Erlbeck1-1/+1
A single test case still uses time() to obtain the reference time. This commit fixes this by using the 'now' variable instead, that contains a fixed time value and does therefore not depend on when the test is executed. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Use monotonic system time instead of time-of-dayJacob Erlbeck2-4/+19
Currently time() is used for age calculations. This time source may jump either forwards or backwards in time (NTP update, leap seconds). This patch replaces the use of time() by using clock_gettime(CLOCK_MONOTONIC) instead. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Only search by valid identifiersJacob Erlbeck1-0/+12
Don't return a link_info if TLLI is 0 resp. P-TMSI is 0xffff. These values are used for uninitialised or cleared fields and can possibly match several entries. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Replace 'tlli' by 'link' in VTY commandsJacob Erlbeck1-47/+47
Since the (former) TLLI list has developed into a logical link list, related commands are renamed accordingly. - tlli-list * -> link-list * - delete-gbproxy-tlli * -> delete-gbproxy-link * - show gbproxy tllis -> show gbproxy links Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Rename the field 'enabled_tllis' to 'logical_links'Jacob Erlbeck5-50/+50
This field in struct gbproxy_patch_state has involved and holds a list of all tracked logical links now. Thus the name is modified accordingly. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Use the term 'link' instead of 'tlli'Jacob Erlbeck7-764/+764
Currently in many places where 'tlli' (Temporary Logical Link Identifier) within identifiers is used, the logical link itself is meant instead. For instance, the tlli_info contain information about an LLC logical link including up to four individual TLLI. To avoid confusion between these concepts, this patch replaces all 'tlli_info' by 'link_info' and a few 'tlli' by 'link'. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Rename functions related to tlli_infoJacob Erlbeck6-149/+148
This patch replaces 'tlli' by 'tlli_info' within the following function identifiers: - gbproxy_delete_tlli - gbproxy_delete_tllis - gbproxy_remove_stale_tllis - gbproxy_touch_tlli - gbproxy_unregister_tlli - gbproxy_remove_matching_tllis - gbproxy_find_tlli -> gbproxy_tlli_info_by_tlli - gbproxy_find_tlli_by_* -> gbproxy_tlli_info_by_* These functions refer to the whole logical link info rather than to a certain TLLI. So they are renamed to be named consistently with gbproxy_attach_tlli_info and others. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Remove sgsn_nsei parameterJacob Erlbeck1-7/+5
The function gbproxy_imsi_acquisition() has a parameter sgsn_nsei that is alyways equal to tlli_info->sgsn_nsei (if tlli_info is not NULL). This patch removes this parameter from gbproxy_imsi_acquisition() and gbproxy_flush_stored_messages() and accesses tlli_info->sgsn_nsei instead within these functions. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Rename identifiers related to IMSI matchingJacob Erlbeck5-16/+16
This patch renames gbproxy_check_tlli() to gbproxy_imsi_matches() and struct tlli_info's enable_patching to imsi_matches. It's meant to be more obvious and consistent this way. Sponsored-by: On-Waves ehf
2014-10-09gbproxy/sgsn: Enforce termination when creating a P-TMSI/TLLIJacob Erlbeck2-3/+20
Currently the number of iterations when creating a P-TMSI/TLLI is not limited. It is nevertheless very unlikely that the loop will not terminate. On the other hand, the number of iterations of every loop should have an upper bound (loop variant) which wouldn't be the case here if an arbitrary random generator was used. This patch limits the number of iterations to 23 and logs an error if the creation of the indentifier was aborted due to this limit. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Restart IMSI acquisition on RA UDP REQJacob Erlbeck2-3/+8
Currently the IMSI acquisition is not restarted when a RA Update Request is received. This leads to repeated N(U) in the generated Ident Request message, which in turn causes the MS to drop the second of these message. This is bad, when the first Ident Response has been lost between MS and gbproxy. This patch changes gbproxy_imsi_acquisition() to handle RA Update Request messages like Attach Requests. Sponsored-by: On-Waves ehf
2014-10-09gbproxy/test: Test IMSI acquisition for RA UDP REQJacob Erlbeck2-18/+218
When a MS is state GMM_REGISTERED enters a new RA, it sends a RA Update Request which is then handled by a gbproxy that possibly doesn't have a matching tlli_info. In this case, depending on the configuration an identification procedure to acquire the IMSI must be started. This adds tests to test_gbproxy_imsi_acquisition(): - IMSI acquisition triggered by a RA Update Request message - Reaction to repeated RA Update Request messages, like it could be caused by packet loss between PCU and gbproxy. Sponsored-by: On-Waves ehf
2014-10-09sgsn: Free MM context after receiving a Detach RequestJacob Erlbeck2-3/+5
On a Detach/Re-attach cycle the Address Sanitizer detected a use-after-free kind of problem. That is because we tried to destroy the LLME twice. The first time it is destroyed as part of the Detach handling ans the second time it is destroyed as part of destroying the old MM context. In case the GPRS GMM detach message is lost the SGSN needs to reply besides not having a MM entry. The alternative would have been to add NULL checks for all usages of ctx->llme which would not have helped with the readability. Sponsored-by: On-Waves ehf
2014-10-09sgsn: Add test that exposes a dangling pointer to the LLMEHolger Hans Peter Freyther2-0/+61
On detach the LLME get's unassigned (and hence destroyed) but the GMM context will still point to that dead structure.
2014-10-09sgsn: Create testcase that verifies that llmes get deletedHolger Hans Peter Freyther5-11/+182
On an "unassignment" this code verifies that the LLME will vanish from the list of LLMEs. We assume that this doesn't create a memory leak.
2014-10-09sgsn: Add boilerplate code for a SGSN testHolger Hans Peter Freyther8-0/+52
2014-10-09mgcp: Count the incoming data instead of the modified oneHolger Hans Peter Freyther2-38/+38
For jitter, transit and packet loss we should count the data that arrived and not the data we send towards the remote. This is changing the jitter timings to what they were before the re-factoring. For forced timing we might willingly add jumps in the sequence number but for jitter and packet loss we are more interested in the data that traveled through the wire/air.
2014-10-09mgcp: Do not detect the initial package as a wrap aroundHolger Hans Peter Freyther4-20/+67
The Annex A code has a probation period but we don't have it. When starting with seq_no==0 do not assume that the sequence numbers have wrapped. Do it by moving the entire checking code into the else.
2014-10-09mgcp: Move Annex A counting out of patch/count methodHolger Hans Peter Freyther4-86/+113
mgcp_patch_and_count has grown due supporting linearizing timestamps, ssrc and other things for equipment like the ip.access nanoBTS. Fight back and move the Annex A code into a dedicated method. The result is updated as we now count after all the patching and for the Annex A code no change in SSRC can be detected.
2014-10-09mgcp: We only look at the RTP header use that in the commentHolger Hans Peter Freyther1-2/+2
2014-10-03nitb: Add subscriber delete commandRuben Pollan2-2/+42
2014-10-02bsc: Let the VTY verify that the timeout is a numberHolger Hans Peter Freyther1-2/+2
Before the old code allowed to specify "timeout-ping bla" which would be parsed as '0' which would trigger a flood of pings. Use the VTY code to parse it as a number.
2014-09-25gprs: Move log message about mm context after NULL checkDaniel Willmann1-3/+3
Fixes: CID#1240205
2014-09-22gprs: Improve loglevels and log messages for SGSNDaniel Willmann4-64/+63
Many log levels were DEBUG without any good reason. Also where possible the details of the MM or PDP context are now logged with LOGMM/PDPCTXP.
2014-09-22gprs_sgsn.h: Add two macros to log details of MM/PDP contextsDaniel Willmann1-0/+5
2014-09-19sgsn: Reset local LLC parameters when sending XID resetJacob Erlbeck1-1/+8
Currently when gprs_llgmm_reset() is invoked an XID reset is sent but the local LLC parameters (e.g. V(U)) are not cleared (see GSM 04.64, 8.5.3.1). This can lead to discarded messages on the SGSN side. This patch modifies gprs_llgmm_reset to clear vu_send, vu_recv, oc_ui_send, oc_ui_recv. Sponsored-by: On-Waves ehf
2014-09-19gbproxy: Separate SGSN numeric namespacesJacob Erlbeck7-138/+240
Currently the SGSN side message's TLLI are searched without checking the originating SGSN. This leads to collisions if both SGSN use the same P-TMSI for different MS. With this patch, the SGSN NSEI is stored within the tlli_info and is used in comparisons to separate the namespaces. Note that this type of collision cannot happen with BSS numbers, since the tlli_info are already separated and stored per (BSS) peer. Sponsored-by: On-Waves ehf
2014-09-19gbproxy/test: Add a test with a P-TMSI collision between two SGSNsJacob Erlbeck2-38/+337
This patch extends test_gbproxy_secondary_sgsn() by the establishment of a third MS connection using a P-TMSI that has been assigned by the other SGSN already. It is expected that the entries do not interfere and are properly retrieved. Note that these collisions are not handled properly yet. Sponsored-by: On-Waves ehf
2014-09-19gbproxy/test: Fix Identification ResponseJacob Erlbeck2-4/+4
At one place, the reply to the second Ident Req contains the wrong IMSI. That is fixed by this patch. Sponsored-by: On-Waves ehf
2014-09-19gbproxy: Check other tlli_infos for matching TLLI/P-TMSIJacob Erlbeck3-11/+46
Currently it is possible to create serveral entries referring to the same P-TMSI/TLLI by using P-TMSI assigment via Attach Accept or RA Update Accept messages. This can lead to the use of the wrong tlli_info. This patch adds gbproxy_remove_matching_tllis() that removes all conflicting entries. This function is called after the P-TMSIs and the resulting TLLIs has been set up. Sponsored-by: On-Waves ehf
2014-09-19gbproxy/test: Add test case for P-TMSI assigmentJacob Erlbeck2-0/+554
This tests P-TMSI assignment when P-TMSI patching is disabled. A test with colliding P-TMSI in Attach Accept messages is included. Note that P-TMSI collisions are not handled properly yet. Sponsored-by: On-Waves ehf
2014-09-19gbproxy: Parse RA_UPD_REJ and invalidate TLLIJacob Erlbeck3-5/+39
Since this message puts the MS into DEREGISTERED state (like a detach procedure), this message is parsed and the invalidate_tlli field is set accordingly. Sponsored-by: On-Waves ehf
2014-09-19gbproxy: Delete and show detached entries via VTYJacob Erlbeck1-34/+65
This commit adds/modifies the following VTY commands: - delete-gbproxy-tlli <NSEI> de-registered : Delete all de-registered entries - show gbproxy tllis : Display 'DE-REGISTERED' when appropriate In addition, the implementation of the delete-gbproxy-tlli command has been split into two functions (with and without TLLI/IMSI value). Sponsored-by: On-Waves ehf
2014-09-19gbproxy: Replace LOGP by LOGPC for continued linesJacob Erlbeck1-11/+11
gprs_gb_log_parse_context() uses a sequence of LOGP calls to compose a single message line. This leads to cluttered log output. This patch replaces all but the first LOGP applications in this function by applications of LOGPC. Sponsored-by: On-Waves ehf
2014-09-19gbproxy: Avoid multiple tlli_info entries with the same IMSIJacob Erlbeck3-38/+49
Currently it is possible to create several tlli_info entries with the same IMSI. This patch disables this by adding a check before the imsi field is updated. Sponsored-by: On-Waves ehf