aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-01-17 03:42:16 +0600
committerHarald Welte <laforge@gnumonks.org>2018-01-17 10:45:40 +0000
commitf07c58cb363f5cd30a6186408dad2b77f66770a9 (patch)
tree3da0712867db3097b981ee13c9649983e23acda9 /src
parentfd744ceeae98113841c2323e17eb30aea93bacdc (diff)
gsm0480: refactor gsm0480_decode_ss_request
Diffstat (limited to 'src')
-rw-r--r--src/gsm/gsm0480.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 25f97a21..ca009998 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -255,17 +255,24 @@ int gsm0480_decode_ussd_request(const struct gsm48_hdr *hdr, uint16_t len,
int gsm0480_decode_ss_request(const struct gsm48_hdr *hdr, uint16_t len,
struct ss_request *req)
{
- int rc = 0;
+ uint8_t pdisc;
- if (gsm48_hdr_pdisc(hdr) == GSM48_PDISC_NC_SS) {
- req->transaction_id = hdr->proto_discr & 0x70;
- rc = parse_ss(hdr, len - sizeof(*hdr), req);
+ /**
+ * Check Protocol Discriminator
+ * see TS GSM 04.07 and GSM 04.80
+ */
+ pdisc = gsm48_hdr_pdisc(hdr);
+ if (pdisc != GSM48_PDISC_NC_SS) {
+ LOGP(0, LOGL_ERROR, "Dropping message with "
+ "unsupported pdisc=%02x\n", pdisc);
+ return 0;
}
- if (!rc)
- LOGP(0, LOGL_DEBUG, "Error occurred while parsing received SS!\n");
+ /* GSM 04.80 3.3 Transaction Identifier */
+ req->transaction_id = hdr->proto_discr & 0x70;
- return rc;
+ /* Parse SS request */
+ return parse_ss(hdr, len - sizeof(*hdr), req);
}
static int parse_ss(const struct gsm48_hdr *hdr, uint16_t len, struct ss_request *req)