Ensure setFieldData return value for all protocols

Some protocol fields were not setting 'isOk' before returning it
This commit is contained in:
Srivats P 2021-12-11 12:56:23 +05:30
parent fb91a094fc
commit 58d4ceb9c7
5 changed files with 14 additions and 6 deletions

View File

@ -671,6 +671,7 @@ bool GmpProtocol::setFieldData(int index, const QVariant &value,
ba.append(QByteArray(4 - (ba.size() % 4), char(0))); ba.append(QByteArray(4 - (ba.size() % 4), char(0)));
rec->set_aux_data(std::string(ba.constData(), ba.size())); rec->set_aux_data(std::string(ba.constData(), ba.size()));
} }
isOk = true;
break; break;
} }

View File

@ -306,6 +306,7 @@ bool IgmpProtocol::setFieldData(int index, const QVariant &value,
quint32 ip = QHostAddress(str).toIPv4Address(); quint32 ip = QHostAddress(str).toIPv4Address();
data.add_sources()->set_v4(ip); data.add_sources()->set_v4(ip);
} }
isOk = true;
break; break;
} }
@ -332,6 +333,7 @@ bool IgmpProtocol::setFieldData(int index, const QVariant &value,
QHostAddress(src).toIPv4Address()); QHostAddress(src).toIPv4Address());
} }
} }
isOk = true;
break; break;
} }

View File

@ -634,6 +634,7 @@ bool Ip6Protocol::setFieldData(int index, const QVariant &value,
| (quint64(addr[14]) << 8) | (quint64(addr[14]) << 8)
| (quint64(addr[15]) << 0); | (quint64(addr[15]) << 0);
data.set_src_addr_lo(x); data.set_src_addr_lo(x);
isOk = true;
break; break;
} }
case ip6_dstAddress: case ip6_dstAddress:
@ -668,6 +669,7 @@ bool Ip6Protocol::setFieldData(int index, const QVariant &value,
| (quint64(addr[14]) << 8) | (quint64(addr[14]) << 8)
| (quint64(addr[15]) << 0); | (quint64(addr[15]) << 0);
data.set_dst_addr_lo(x); data.set_dst_addr_lo(x);
isOk = true;
break; break;
} }

View File

@ -270,7 +270,6 @@ QVariant MacProtocol::fieldData(int index, FieldAttrib attrib,
bool MacProtocol::setFieldData(int index, const QVariant &value, bool MacProtocol::setFieldData(int index, const QVariant &value,
FieldAttrib attrib) FieldAttrib attrib)
{ {
// FIXME: make sure isOk is set correctly for all fields and protocols
bool isOk = false; bool isOk = false;
if (attrib != FieldValue) if (attrib != FieldValue)
@ -280,14 +279,16 @@ bool MacProtocol::setFieldData(int index, const QVariant &value,
{ {
case mac_dstAddr: case mac_dstAddr:
{ {
quint64 mac = value.toULongLong(); quint64 mac = value.toULongLong(&isOk);
data.set_dst_mac(mac); if (isOk)
data.set_dst_mac(mac);
break; break;
} }
case mac_srcAddr: case mac_srcAddr:
{ {
quint64 mac = value.toULongLong(); quint64 mac = value.toULongLong(&isOk);
data.set_src_mac(mac); if (isOk)
data.set_src_mac(mac);
break; break;
} }

View File

@ -423,6 +423,7 @@ bool MldProtocol::setFieldData(int index, const QVariant &value,
| (quint64(addr[14]) << 8) | (quint64(addr[14]) << 8)
| (quint64(addr[15]) << 0); | (quint64(addr[15]) << 0);
data.mutable_group_address()->set_v6_lo(x); data.mutable_group_address()->set_v6_lo(x);
isOk = true;
break; break;
} }
@ -457,6 +458,7 @@ bool MldProtocol::setFieldData(int index, const QVariant &value,
| (quint64(addr[15]) << 0); | (quint64(addr[15]) << 0);
src->set_v6_lo(x); src->set_v6_lo(x);
} }
isOk = true;
break; break;
} }
@ -524,7 +526,7 @@ bool MldProtocol::setFieldData(int index, const QVariant &value,
src->set_v6_lo(x); src->set_v6_lo(x);
} }
} }
isOk = true;
break; break;
} }