summaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/gb_proxy.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-11 11:35:17 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-18 11:21:57 +0200
commit6bafa4ce0ddb9e4c97497452f521df5a8cdf703c (patch)
tree5309f2069845ba826437d421b7624d0f17174ba0 /openbsc/src/gprs/gb_proxy.c
parent0b243a106a45c1b47a1e389eda98e025b6950214 (diff)
gbproxy: Rework gbproxy_imsi_acquisition
This commit changes gbproxy_imsi_acquisition as follows: tlli_info->mi_data_len is used instead of parse_ctx->imsi to check, whether the IMSI is known already. Since the function is always called after gbproxy_update_tlli_ul(), the two values are already synchronized. Messages are always flushed when the IMSI gets known, if the current message is IDENT RESP discard it, otherwise continue processing as usual. The 'if' clauses are simplified for better readability. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/src/gprs/gb_proxy.c')
-rw-r--r--openbsc/src/gprs/gb_proxy.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 514898a..dfaa380 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -357,9 +357,14 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer,
struct gbproxy_tlli_info* tlli_info,
struct gprs_gb_parse_context *parse_ctx)
{
+ struct msgb *stored_msg;
+
if (!tlli_info)
return 1;
+ if (!tlli_info->imsi_acq_pending && tlli_info->mi_data_len > 0)
+ return 1;
+
if (parse_ctx->g48_hdr &&
parse_ctx->g48_hdr->msg_type == GSM48_MT_GMM_ATTACH_REQ)
{
@@ -371,58 +376,53 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer,
}
}
- if (tlli_info->imsi_acq_pending && parse_ctx->g48_hdr &&
- parse_ctx->g48_hdr->proto_discr == GSM48_PDISC_MM_GPRS &&
- parse_ctx->g48_hdr->msg_type == GSM48_MT_GMM_ID_RESP &&
- parse_ctx->imsi_len > 0) {
+ if (tlli_info->imsi_acq_pending && tlli_info->mi_data_len > 0) {
+ int is_ident_resp =
+ parse_ctx->g48_hdr &&
+ parse_ctx->g48_hdr->proto_discr == GSM48_PDISC_MM_GPRS &&
+ parse_ctx->g48_hdr->msg_type == GSM48_MT_GMM_ID_RESP;
+
/* The IMSI is now available */
gbproxy_flush_stored_messages(peer, msg, sgsn_nsei, now,
tlli_info, parse_ctx);
gbproxy_reset_imsi_acquisition(tlli_info);
- return 0;
- }
-
- if (tlli_info->imsi_acq_pending) {
- struct msgb *stored_msg;
- LOGP(DLLC, LOGL_DEBUG,
- "NSEI=%d(BSS) IMSI acquisition in progess, "
- "storing message (%s)\n",
- msgb_nsei(msg),
- parse_ctx->llc_msg_name ? parse_ctx->llc_msg_name : "BSSGP");
+ /* This message is most probably the response to the ident
+ * request sent by gbproxy_acquire_imsi(). Don't forward it to
+ * the SGSN. */
+ return !is_ident_resp;
+ }
- /* Enqueue unpatched messages */
- stored_msg = gprs_msgb_copy(msg, "process_bssgp_ul");
- msgb_enqueue(&tlli_info->stored_msgs, stored_msg);
+ /* The message cannot be processed since the IMSI is still missing */
- return 0;
- }
+ /* Enqueue unpatched messages */
+ LOGP(DLLC, LOGL_INFO,
+ "NSEI=%d(BSS) IMSI acquisition in progress, "
+ "storing message (%s)\n",
+ msgb_nsei(msg),
+ parse_ctx->llc_msg_name ? parse_ctx->llc_msg_name : "BSSGP");
- if (tlli_info->mi_data_len == 0) {
- struct msgb *stored_msg = gprs_msgb_copy(msg, "process_bssgp_ul");
+ stored_msg = gprs_msgb_copy(msg, "process_bssgp_ul");
+ msgb_enqueue(&tlli_info->stored_msgs, stored_msg);
- LOGP(DLLC, LOGL_DEBUG,
+ if (!tlli_info->imsi_acq_pending) {
+ LOGP(DLLC, LOGL_INFO,
"NSEI=%d(BSS) IMSI is required but not available, "
- "storing message (%s)\n",
+ "initiating identification procedure (%s)\n",
msgb_nsei(msg),
parse_ctx->llc_msg_name ? parse_ctx->llc_msg_name : "BSSGP");
- /* Enqueue message */
- msgb_enqueue(&tlli_info->stored_msgs, stored_msg);
-
gbproxy_acquire_imsi(peer, tlli_info, msgb_bvci(msg));
- tlli_info->imsi_acq_pending = 1;
-
/* There is no explicit retransmission handling, the
* implementation relies on the MS doing proper retransmissions
* of the triggering message instead */
- return 0;
+ tlli_info->imsi_acq_pending = 1;
}
- return 1;
+ return 0;
}
struct gbproxy_peer *gbproxy_find_peer(struct gbproxy_config *cfg,