#include <QHostAddress>
#include <QString>
#include <QDebug>
bool isInMulticastRange(const QString &ipAddress) {
// 创建QHostAddress对象
QHostAddress address(ipAddress);
// 检查是否为有效的IPv4地址
if (!address.toIPv4Address()) {
qWarning() << "Invalid IPv4 address.";
return false;
}
// 多播地址范围
QHostAddress lowerBound("224.0.0.1");
QHostAddress upperBound("224.0.0.254");
// 判断地址是否在多播范围内
bool inRange = address.isInSubnet(lowerBound, 24) && address.toIPv4Address() != upperBound.toIPv4Address();
return inRange;
}