From 531734a547f16de08ce94ec64d58cf94c2230893 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 14 Mar 2016 16:13:24 +0100 Subject: 04.08: apply new bitmask functions, fix bitmask use Replace hardcoded protocol discriminator and message type bitmasks with function calls recently introduced in libosmocore. Note that the release 98 bitmasks slightly differ from the release 99 bitmasks. This patch uses the "default" gsm48_hdr_msg_type invocation, thus it depends on libosmocore whether 98 or 99 bitmasks are used. In some places, use of the bitmask was erratic. Fix these implicitly by employing the bitmask functions: * silent_call.c: silent_call_reroute(): add missing bitmask for MM. * bsc_msg_filter.c: bsc_msg_filter_initial(): RR vs. MM messages. * osmo_bsc_filter.c: bsc_find_msc() and bsc_scan_bts_msg(): RR vs. MM messages. * bsc_nat_rewrite.c: bsc_nat_rewrite_msg(): SMS vs. CC messages. * bsc_ussd.c: no bitmask is applicable for the message types used here. * gb_proxy.c: gbproxy_imsi_acquisition(): missing bit mask for pdisc. In gprs_gb_parse.c: gprs_gb_parse_dtap(), add a log notice for unexpected message types. --- openbsc/src/gprs/gb_proxy.c | 4 ++-- openbsc/src/gprs/gprs_gb_parse.c | 13 ++++++++++--- openbsc/src/gprs/gprs_gmm.c | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'openbsc/src/gprs') diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c index 955133562..6e6b03b86 100644 --- a/openbsc/src/gprs/gb_proxy.c +++ b/openbsc/src/gprs/gb_proxy.c @@ -462,8 +462,8 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, if (link_info->imsi_acq_pending && link_info->imsi_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; + gsm48_hdr_pdisc(parse_ctx->g48_hdr) == GSM48_PDISC_MM_GPRS && + gsm48_hdr_msg_type(parse_ctx->g48_hdr) == GSM48_MT_GMM_ID_RESP; /* The IMSI is now available */ gbproxy_flush_stored_messages(peer, msg, now, link_info, diff --git a/openbsc/src/gprs/gprs_gb_parse.c b/openbsc/src/gprs/gprs_gb_parse.c index 609685407..63ac9028d 100644 --- a/openbsc/src/gprs/gprs_gb_parse.c +++ b/openbsc/src/gprs/gprs_gb_parse.c @@ -329,17 +329,20 @@ int gprs_gb_parse_dtap(uint8_t *data, size_t data_len, struct gprs_gb_parse_context *parse_ctx) { struct gsm48_hdr *g48h; + uint8_t pdisc; + uint8_t msg_type; if (gprs_shift_v_fixed(&data, &data_len, sizeof(*g48h), (uint8_t **)&g48h) <= 0) return 0; parse_ctx->g48_hdr = g48h; - if ((g48h->proto_discr & 0x0f) != GSM48_PDISC_MM_GPRS && - (g48h->proto_discr & 0x0f) != GSM48_PDISC_SM_GPRS) + pdisc = gsm48_hdr_pdisc(g48h); + if (pdisc != GSM48_PDISC_MM_GPRS && pdisc != GSM48_PDISC_SM_GPRS) return 1; - switch (g48h->msg_type) { + msg_type = gsm48_hdr_msg_type(g48h); + switch (msg_type) { case GSM48_MT_GMM_ATTACH_REQ: return gprs_gb_parse_gmm_attach_req(data, data_len, parse_ctx); @@ -376,6 +379,10 @@ int gprs_gb_parse_dtap(uint8_t *data, size_t data_len, break; default: + LOGP(DLLC, LOGL_NOTICE, + "Unknown GSM 04.08 message type 0x%02hhx for protocol" + " discriminator 0x%02hhx.\n", + msg_type, pdisc); break; }; diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index d93ba3f77..9d94c24fe 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -2089,7 +2089,7 @@ int gsm0408_gprs_force_reattach(struct sgsn_mm_ctx *mmctx) int gsm0408_gprs_rcvmsg(struct msgb *msg, struct gprs_llc_llme *llme) { struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg); - uint8_t pdisc = gh->proto_discr & 0x0f; + uint8_t pdisc = gsm48_hdr_pdisc(gh); struct sgsn_mm_ctx *mmctx; struct gprs_ra_id ra_id; int rc = -EINVAL; -- cgit v1.2.3