aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp <pmaier@sysmocom.de>2016-10-06 15:58:58 +0200
committerHarald Welte <laforge@gnumonks.org>2016-10-12 09:57:18 +0000
commitb8b939faa963973d5e34021dfe6cae357669a9a6 (patch)
tree22f78af650f1717d188b14aa7de01cbd9520d210
parent4ca5be766cb139eccb9798a0237cc32ae59617d9 (diff)
octphy: prevent mismatch between dsp-firmware and octphy headers
in its current statue l1_oml.c does not check if the version number in the header files (octvc1_main_version.h) matches up the version that is reported from the DSP during startip. This patch ads a check to make sure that the currently loaded firmware and the headers used during compile time match. If a mismatch is detected, osmo-bts exits immediately. Change-Id: Icba5756517d632d53b129c5ce1a1dab4936dab91
-rw-r--r--src/osmo-bts-octphy/l1_oml.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/osmo-bts-octphy/l1_oml.c b/src/osmo-bts-octphy/l1_oml.c
index 1b74fd40..74853bf7 100644
--- a/src/osmo-bts-octphy/l1_oml.c
+++ b/src/osmo-bts-octphy/l1_oml.c
@@ -50,6 +50,7 @@
#include <octphy/octvc1/gsm/octvc1_gsm_default.h>
#include <octphy/octvc1/gsm/octvc1_gsm_id.h>
#include <octphy/octvc1/main/octvc1_main_default.h>
+#include <octphy/octvc1/main/octvc1_main_version.h>
/* Map OSMOCOM logical channel type to OctPHY Logical channel type */
static tOCTVC1_GSM_LOGICAL_CHANNEL_COMBINATION_ENUM pchan_to_logChComb[_GSM_PCHAN_MAX] =
@@ -1207,29 +1208,42 @@ int l1if_check_app_sys_version(struct gsm_bts_trx *trx)
return l1if_req_compl(fl1h, msg, app_info_sys_compl_cb, 0);
}
-static int app_info_compl_cb(struct octphy_hdl *fl1h, struct msgb *resp, void *data)
+static int app_info_compl_cb(struct octphy_hdl *fl1h, struct msgb *resp,
+ void *data)
{
+ char ver_hdr[32];
+
tOCTVC1_MAIN_MSG_APPLICATION_INFO_RSP *air =
(tOCTVC1_MAIN_MSG_APPLICATION_INFO_RSP *) resp->l2h;
- /* in a completion call-back, we take msgb ownership and must
- * release it before returning */
+ sprintf(ver_hdr, "%02i.%02i.%02i-B%i", cOCTVC1_MAIN_VERSION_MAJOR,
+ cOCTVC1_MAIN_VERSION_MINOR, cOCTVC1_MAIN_VERSION_MAINTENANCE,
+ cOCTVC1_MAIN_VERSION_BUILD);
mOCTVC1_MAIN_MSG_APPLICATION_INFO_RSP_SWAP(air);
- LOGP(DL1C, LOGL_INFO, "Rx APP-INFO.resp (name='%s', desc='%s', ver='%s')\n",
- air->szName, air->szDescription, air->szVersion);
+ LOGP(DL1C, LOGL_INFO,
+ "Rx APP-INFO.resp (name='%s', desc='%s', ver='%s', ver_hdr='%s')\n",
+ air->szName, air->szDescription, air->szVersion, ver_hdr);
+
+ /* Bail if dsp firmware does not match up the header version info */
+ if (strcmp(air->szVersion, ver_hdr) != 0) {
+ LOGP(DL1C, LOGL_ERROR,
+ "Invalid header-file / dsp-firmware combination, exiting...\n");
+ exit(1);
+ }
talloc_replace(fl1h->info.app.name, fl1h, air->szName);
talloc_replace(fl1h->info.app.description, fl1h, air->szDescription);
talloc_replace(fl1h->info.app.version, fl1h, air->szVersion);
+ /* in a completion call-back, we take msgb ownership and must
+ * release it before returning */
msgb_free(resp);
return 0;
}
-
int l1if_check_app_version(struct gsm_bts_trx *trx)
{
struct phy_instance *pinst = trx_phy_instance(trx);