aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc/gprs_gb_parse.h
AgeCommit message (Collapse)AuthorFilesLines
2014-10-27gbproxy: Patch BSSGP P-TMSI in PAGING PS messagesJacob Erlbeck1-1/+1
Currently the P-TMSI IE in PAGING_PS is not patched. This commit adds code to patch BSSGP P-TMSI IE in gbproxy_patch_bssgp independently from the P-TMSI patching at the LLC layer. It also extends gbproxy_update_link_state_dl to use the IMSI to find the link_info if the TLLI is not present in the message. Note that the spec (GSM 08.18, 7.2) requires to use of the P-TMSI instead of the IMSI to select the MS if that IE is available. Nevertheless as long as the IMSI is always present in downlink BSSGP messages and as long as the optional P-TMSI refers to the same MS (which is the case currently), this is not an issue. Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Pass the log level as argument to gprs_gb_log_parse_contextJacob Erlbeck1-1/+2
Currently, the log level is always LOGL_DEBUG. In case of errors it would be helpful to use a higher log level. This patch adds a log_level parameter to gprs_gb_log_parse_context to let the caller decide about the level. Ticket: OW#1307 Sponsored-by: On-Waves ehf
2014-10-09gbproxy: Add gprs_gb_message_name functionJacob Erlbeck1-0/+3
This function tries to get an accurate name for the message even if the parsing has been aborted due to message errors. The patch also moves the settings of the BSSGP related fields in parse_ctx from behind to the front of bssgp_tlv_parse, to get more information in the case of failure. This is now consistent with the handling of the llc and g48_hdr fields. Id addition, gprs_gb_log_parse_context now uses the new function to derive a more accurate message name. Ticket: OW#1307 Sponsored-by: On-Waves ehf
2014-09-19gbproxy: Separate SGSN numeric namespacesJacob Erlbeck1-0/+1
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: Keep tlli_info after detachJacob Erlbeck1-0/+1
Currently a tlli_info entry is deleted when the TLLI gets invalidated by a Detach message. This patch introduces the possibility to keep tlli_info entries in the list. Those entries then have cleared TLLI fields, are marked as de-registered, and can only be retrieved by a message containing an IMSI or a P-TMSI. The following VTY configuration commands are added to the gbproxy node: - tlli-list keep-mode never : Don't keep the entries (default) - tlli-list keep-mode re-attach : Only keep them, when a Detach message with re-attach required has been received - tlli-list keep-mode identified : Only keep entries which are associated with an IMSI - tlli-list keep-mode always : Keep all entries Note that at least one of max-length or max-age should be set when this feature is used to limit the number of entries. Sponsored-by: On-Waves ehf
2014-09-18gbproxy: Fixed RAI patching in Attach Request messagesJacob Erlbeck1-1/+1
Currently the RAI in the LLC part of the message is not updated if the message has been taken from the list of stored messages. The reason is, that old_raid_matches is update in gbprox_process_bssgp_ul() but not in gbproxy_flush_stored_messages(). This patch moves the check to gprs_gb_parse_bssgp() which is called at both places and where other fields like parse_ctx->tlli are set, too. In addition, old_raid_matches is replaced by old_raid_is_foreign since this is clearer in the case when there is no old RAI at all. Several RAI patch counter assertions are also added to test_gbproxy_ra_patching(). Sponsored-by: On-Waves ehf
2014-09-02gbproxy: Create STATUS message with original PDUJacob Erlbeck1-0/+1
Currently when patching is enabled and an error happens when receiving a message from the SGSN, the patched message is sent back with the PDU_IN_ERROR IE. This patch modifies gbprox_rx_sig_from_sgsn() to copy the message before it is patched, so that the original message can be used with the STATUS message. gbprox_rx_ptp_from_sgsn() does all checks before the message is patched, so copying is not necessary. Since gbprox_rx_sig_from_sgsn() is not called for BSSGP UNITDATA messages and the msgb is already been copied in the gbprox_relay2peer function, the relative performance impact is expected to be low. Note that the PDU IE of STATUS messages received from an MS and forwarded to the SGSN will not be patched. STATUS messages from the SGSN are only logged and not forwarded to the MS. Sponsored-by: On-Waves ehf
2014-09-02gbproxy: Remove nonnull attributesJacob Erlbeck1-4/+4
The compiler also uses this attribute for code elimination. If the nonnull attribute has been given erroneously for an parameter, that is later been checked against NULL, this check is removed silently by the gcc if optimization is enabled. This can lead to hard-to-find segmentation violation faults. To be on the safe side, this patch removes all uses of the nonnull attribute in openbsc. Compiler: - gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1): no warning, segfault - clang 3.4 (3.4-1ubuntu3): no warning, no segfault, asm ok Example: /* foo.c */ int f(int* p) __attribute((nonnull)); int f(int *p) { if (!p) return 0; return *p; } /* main.c */ int f(int* p) __attribute((nonnull)); int g () { return f(arg); } int main() { return g(NULL); } When these files are compiled into an executable, no warnungs are issued but it will fail with a segfault when -O2 is used (unless LTO is active). Compiler output (gcc -O2): int f(int *p) { 0: 8b 44 24 04 mov 0x4(%esp),%eax 4: 8b 00 mov (%eax),%eax 6: c3 ret } Sponsored-by: On-Waves ehf
2014-08-24gbproxy: Refactor gb_proxy.c into several filesJacob Erlbeck1-0/+52
This patch moves several functions and declarations out of gb_proxy.c to make them reusable by other components and to separate them by context and task. Counter enums (prefix is changed to gbproxy_): enum gbprox_global_ctr -> gprs/gb_proxy.h enum gbprox_peer_ctr -> gprs/gb_proxy.h Generic Gb parsing (prefix is changed to gprs_gb_): struct gbproxy_parse_context -> openbsc/gprs_gb_parse.h gbprox_parse_dtap() -> gprs/gprs_gb_parse.c gbprox_parse_llc() -> gprs/gprs_gb_parse.c gbprox_parse_bssgp() -> gprs/gprs_gb_parse.c gbprox_log_parse_context() -> gprs/gprs_gb_parse.c *_shift(), *_match() -> gprs/gprs_gb_parse.c (no prefix) gbprox_parse_gmm_* -> gprs/gprs_gb_parse.c (static) gbprox_parse_gsm_* -> gprs/gprs_gb_parse.c (static) MI testing/parsing (prefix gprs_ added): is_mi_tmsi() -> gprs/gprs_utils.c is_mi_imsi() -> gprs/gprs_utils.c parse_mi_tmsi() -> gprs/gprs_utils.c TLLI state handling (prefix is changed to gbproxy_): gbprox_*tlli* -> gprs/gb_proxy_tlli.c (except gbprox_patch_tlli, gbproxy_make_sgsn_tlli) Message patching (prefix is changed to gbproxy_): gbprox_*patch* -> gprs/gb_proxy_patch.c gbprox_check_imsi -> gprs/gb_proxy_patch.c Sponsored-by: On-Waves ehf