diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-12-12 16:54:08 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-01-09 21:57:13 +0100 |
commit | 5a03e129a633637d0a6b57b3b5aa6d6596b938fe (patch) | |
tree | e88873ee3a56ba950eab5bb64e2d6ba71a822627 /src | |
parent | b7ebf545e6cc5eee17df254815c7838fbea61db7 (diff) |
msg: Generalize the message structure test
This was taken out of LaF0rge's OML router branch and is now
used by the extended calibration feature.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/msg_utils.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c index f3cba090..22a3012a 100644 --- a/src/common/msg_utils.c +++ b/src/common/msg_utils.c @@ -103,13 +103,6 @@ int msg_verify_ipa_structure(struct msgb *msg) hh = (struct ipaccess_head *) msg->l1h; - if (hh->proto != IPAC_PROTO_OML) { - LOGP(DL1C, LOGL_ERROR, - "Incorrect ipa header protocol 0x%x 0x%x\n", - hh->proto, IPAC_PROTO_OML); - return -1; - } - if (ntohs(hh->len) != msgb_l1len(msg) - sizeof(struct ipaccess_head)) { LOGP(DL1C, LOGL_ERROR, "Incorrect ipa header msg size %d %d\n", @@ -117,7 +110,16 @@ int msg_verify_ipa_structure(struct msgb *msg) return -1; } - msg->l2h = hh->data; + if (hh->proto == IPAC_PROTO_OSMO) { + struct ipaccess_head_ext *hh_ext = (struct ipaccess_head_ext *) hh->data; + if (ntohs(hh->len) < sizeof(*hh_ext)) { + LOGP(DL1C, LOGL_ERROR, "IPA length shorter than OSMO header\n"); + return -1; + } + msg->l2h = hh_ext->data; + } else + msg->l2h = hh->data; + return 0; } |