Add port speed and MTU properties
This commit only retreives these properties for Windows. Linux and BSD/MacOS are pending
This commit is contained in:
parent
14993073fe
commit
925edb8507
@ -212,6 +212,9 @@ message Port {
|
||||
optional TransmitMode transmit_mode = 7 [default = kSequentialTransmit];
|
||||
optional string user_name = 8;
|
||||
optional bool is_tracking_stream_stats = 9;
|
||||
|
||||
optional double speed = 10; // in Mbps
|
||||
optional uint32 mtu = 11;
|
||||
}
|
||||
|
||||
message PortConfigList {
|
||||
|
@ -64,6 +64,11 @@ AbstractPort::~AbstractPort()
|
||||
|
||||
void AbstractPort::init()
|
||||
{
|
||||
if (interfaceInfo_) {
|
||||
data_.set_speed(interfaceInfo_->speed);
|
||||
data_.set_mtu(interfaceInfo_->mtu);
|
||||
}
|
||||
|
||||
if (deviceManager_)
|
||||
deviceManager_->createHostDevices();
|
||||
}
|
||||
|
@ -214,6 +214,7 @@ void BsdPort::populateInterfaceInfo()
|
||||
}
|
||||
|
||||
interfaceInfo_ = new InterfaceInfo;
|
||||
// FIXME: speed, mtu
|
||||
interfaceInfo_->mac = mac;
|
||||
|
||||
//
|
||||
|
@ -39,6 +39,9 @@ struct InterfaceInfo
|
||||
quint64 mac;
|
||||
QList<Ip4Config> ip4;
|
||||
QList<Ip6Config> ip6;
|
||||
|
||||
double speed{0}; // in Mbps
|
||||
quint32 mtu{0};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -247,6 +247,7 @@ void LinuxPort::populateInterfaceInfo()
|
||||
rtnl_link_put(link);
|
||||
|
||||
interfaceInfo_ = new InterfaceInfo;
|
||||
// FIXME: speed, mtu
|
||||
interfaceInfo_->mac = mac;
|
||||
|
||||
//
|
||||
|
@ -74,7 +74,7 @@ PortManager::PortManager()
|
||||
{
|
||||
AbstractPort *port;
|
||||
|
||||
qDebug("%d. %s", i, device->name);
|
||||
qDebug("==========\n%d. %s", i, device->name);
|
||||
if (device->description)
|
||||
qDebug(" (%s)\n", device->description);
|
||||
|
||||
@ -122,6 +122,8 @@ PortManager::PortManager()
|
||||
qPrintable(QHostAddress(ip.address.toArray()).toString()),
|
||||
ip.prefixLength,
|
||||
qPrintable(QHostAddress(ip.gateway.toArray()).toString()));
|
||||
qDebug("Speed: %g Mbps", intfInfo->speed);
|
||||
qDebug("Mtu: %u", intfInfo->mtu);
|
||||
}
|
||||
|
||||
if (!port->setRateAccuracy(txRateAccuracy))
|
||||
|
@ -261,6 +261,11 @@ void WinPcapPort::populateInterfaceInfo()
|
||||
}
|
||||
|
||||
interfaceInfo_ = new InterfaceInfo;
|
||||
|
||||
interfaceInfo_->speed = adapter->TransmitLinkSpeed != quint64(-1) ?
|
||||
adapter->TransmitLinkSpeed/ulong(1e6) : 0;
|
||||
interfaceInfo_->mtu = adapter->Mtu;
|
||||
|
||||
if (adapter->PhysicalAddressLength == 6) {
|
||||
interfaceInfo_->mac = qFromBigEndian<quint64>(
|
||||
adapter->PhysicalAddress) >> 16;
|
||||
|
Loading…
Reference in New Issue
Block a user