aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-12-12 16:54:08 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-06 19:06:51 +0100
commitd81b78b524c823122d569fc09f4a764b7a2e13f2 (patch)
tree8813bc0dc73ab5f354f2b70e051bb874bed29107
parent8fc2630dd4884ffeb4c5fc93457c8c06e6dbf918 (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.
-rw-r--r--src/common/msg_utils.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c
index f3cba09..22a3012 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;
}