aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-10-09 12:04:56 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-10-09 18:15:31 +0200
commit9b07135b92dce6c6b78a9ff0f0a1c6d2df64f9d6 (patch)
tree4985e5be51d90400c38a8ea8a306804d738417ed /openbsc/src
parentcc8856f9d3671cc64adc611677f1d3f5feff7bbd (diff)
gbproxy: Add gprs_gb_message_name function
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
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/gprs/gprs_gb_parse.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/openbsc/src/gprs/gprs_gb_parse.c b/openbsc/src/gprs/gprs_gb_parse.c
index 1978bd4bf..17d4b9c19 100644
--- a/openbsc/src/gprs/gprs_gb_parse.c
+++ b/openbsc/src/gprs/gprs_gb_parse.c
@@ -564,15 +564,15 @@ int gprs_gb_parse_bssgp(uint8_t *bssgp, size_t bssgp_len,
data_len = bssgp_len - sizeof(*bgph);
}
- if (bssgp_tlv_parse(tp, data, data_len) < 0)
- return 0;
-
parse_ctx->pdu_type = pdu_type;
parse_ctx->bud_hdr = budh;
parse_ctx->bgp_hdr = bgph;
parse_ctx->bssgp_data = data;
parse_ctx->bssgp_data_len = data_len;
+ if (bssgp_tlv_parse(tp, data, data_len) < 0)
+ return 0;
+
if (budh)
parse_ctx->tlli_enc = (uint8_t *)&budh->tlli;
@@ -626,7 +626,7 @@ int gprs_gb_parse_bssgp(uint8_t *bssgp, size_t bssgp_len,
void gprs_gb_log_parse_context(struct gprs_gb_parse_context *parse_ctx,
const char *default_msg_name)
{
- const char *msg_name = default_msg_name;
+ const char *msg_name;
const char *sep = "";
if (!parse_ctx->tlli_enc &&
@@ -635,6 +635,8 @@ void gprs_gb_log_parse_context(struct gprs_gb_parse_context *parse_ctx,
!parse_ctx->imsi)
return;
+ msg_name = gprs_gb_message_name(parse_ctx, default_msg_name);
+
if (parse_ctx->llc_msg_name)
msg_name = parse_ctx->llc_msg_name;
@@ -713,3 +715,23 @@ void gprs_gb_log_parse_context(struct gprs_gb_parse_context *parse_ctx,
LOGPC(DGPRS, LOGL_DEBUG, "\n");
}
+const char *gprs_gb_message_name(const struct gprs_gb_parse_context *parse_ctx,
+ const char *default_msg_name)
+{
+ if (parse_ctx->llc_msg_name)
+ return parse_ctx->llc_msg_name;
+
+ if (parse_ctx->g48_hdr)
+ return "GMM";
+
+ if (parse_ctx->llc)
+ return "LLC";
+
+ if (parse_ctx->bud_hdr)
+ return "BSSGP-UNITDATA";
+
+ if (parse_ctx->bgp_hdr)
+ return "BSSGP";
+
+ return "unknown";
+}