mgmtops: Fail if read_version fails

If the mgmt_read_version command fails or indicates a too old version we
should just abort since mgmt will in this case be mostly non-functional.
This commit is contained in:
Johan Hedberg 2012-02-20 01:17:07 +02:00
parent b6490e9ee5
commit 56a7c39040

View File

@ -77,8 +77,9 @@ static void read_version_complete(int sk, void *buf, size_t len)
struct mgmt_rp_read_version *rp = buf;
if (len < sizeof(*rp)) {
error("Too small read version complete event");
return;
error("Too small read version complete event"
" (probably an old kernel)");
abort();
}
mgmt_revision = btohs(bt_get_unaligned(&rp->revision));
@ -86,6 +87,12 @@ static void read_version_complete(int sk, void *buf, size_t len)
DBG("version %u revision %u", mgmt_version, mgmt_revision);
if (mgmt_version < 1) {
error("Version 1 of mgmt needed (kernel has version %u)",
mgmt_version);
abort();
}
memset(&hdr, 0, sizeof(hdr));
hdr.opcode = htobs(MGMT_OP_READ_INDEX_LIST);
hdr.index = htobs(MGMT_INDEX_NONE);