Fix IGMP/MLD group address find/replace

fieldData/setFieldData changed to work with uint in addition to string
This commit is contained in:
Srivats P 2021-12-11 15:58:30 +05:30
parent 4aedc61c8e
commit 969e16aaf3
3 changed files with 18 additions and 2 deletions

View File

@ -57,7 +57,7 @@ void GmpConfigForm::loadWidget(AbstractProtocol *proto)
groupAddress->setText(
proto->fieldData(
GmpProtocol::kGroupAddress,
AbstractProtocol::FieldValue
AbstractProtocol::FieldTextValue
).toString());
groupMode->setCurrentIndex(
proto->fieldData(

View File

@ -134,6 +134,7 @@ QVariant IgmpProtocol::fieldData(int index, FieldAttrib attrib,
case FieldName:
return QString("Group Address");
case FieldValue:
return grpIp;
case FieldTextValue:
return QHostAddress(grpIp).toString();
case FieldFrameValue:
@ -289,8 +290,14 @@ bool IgmpProtocol::setFieldData(int index, const QVariant &value,
}
case kGroupAddress:
{
quint32 ip = value.toUInt(&isOk);
if (isOk) {
data.mutable_group_address()->set_v4(ip);
break;
}
QHostAddress addr(value.toString());
quint32 ip = addr.toIPv4Address();
ip = addr.toIPv4Address();
isOk = (addr.protocol() == QAbstractSocket::IPv4Protocol);
if (isOk)
data.mutable_group_address()->set_v4(ip);

View File

@ -195,6 +195,7 @@ QVariant MldProtocol::fieldData(int index, FieldAttrib attrib,
case FieldName:
return QString("Group Address");
case FieldValue:
return QVariant::fromValue(UInt128(grpHi, grpLo));
case FieldTextValue:
case FieldFrameValue:
{
@ -401,6 +402,14 @@ bool MldProtocol::setFieldData(int index, const QVariant &value,
{
case kGroupAddress:
{
if (value.typeName() == QString("UInt128")) {
UInt128 addr = value.value<UInt128>();
data.mutable_group_address()->set_v6_hi(addr.hi64());
data.mutable_group_address()->set_v6_lo(addr.lo64());
isOk = true;
break;
}
Q_IPV6ADDR addr = QHostAddress(value.toString()).toIPv6Address();
quint64 x;