diff --git a/client/portmodel.cpp b/client/portmodel.cpp index f1e50b6..ae3d81e 100644 --- a/client/portmodel.cpp +++ b/client/portmodel.cpp @@ -118,7 +118,7 @@ QVariant PortModel::data(const QModelIndex &index, int role) const if (!parent.isValid()) { // Top Level Item - PortGroup - if ((role == Qt::DisplayRole)) + if (role == Qt::DisplayRole) { DBG0("Exit PortModel data 1\n"); return QString("Port Group %1: %2 [%3]:%4 (%5)"). @@ -128,7 +128,7 @@ QVariant PortModel::data(const QModelIndex &index, int role) const arg(pgl->mPortGroups.at(index.row())->serverPort()). arg(pgl->mPortGroups.value(index.row())->numPorts()); } - else if ((role == Qt::DecorationRole)) + else if (role == Qt::DecorationRole) { DBG0("Exit PortModel data 2\n"); switch(pgl->mPortGroups.at(index.row())->state()) @@ -170,7 +170,7 @@ QVariant PortModel::data(const QModelIndex &index, int role) const Port *port = pgl->mPortGroups.at(parent.row())->mPorts[index.row()]; // Non Top Level - Port - if ((role == Qt::DisplayRole)) + if (role == Qt::DisplayRole) { QString rsvdBy; @@ -183,11 +183,11 @@ QVariant PortModel::data(const QModelIndex &index, int role) const .arg(rsvdBy) .arg(port->description()); } - else if ((role == Qt::DecorationRole)) + else if (role == Qt::DecorationRole) { return portIconFactory[port->linkState()][port->hasExclusiveControl()]; } - else if ((role == Qt::ForegroundRole)) + else if (role == Qt::ForegroundRole) { return port->isDirty() ? QBrush(Qt::red) : QVariant(); } diff --git a/client/streammodel.cpp b/client/streammodel.cpp index dc7f2af..af8e435 100644 --- a/client/streammodel.cpp +++ b/client/streammodel.cpp @@ -113,7 +113,7 @@ QVariant StreamModel::data(const QModelIndex &index, int role) const } case StreamStatus: { - if ((role == Qt::CheckStateRole)) + if (role == Qt::CheckStateRole) { if (mCurrentPort->streamByIndex(index.row())->isEnabled()) return Qt::Checked; diff --git a/server/device.cpp b/server/device.cpp index 4cc1b00..3219243 100644 --- a/server/device.cpp +++ b/server/device.cpp @@ -28,6 +28,7 @@ along with this program. If not, see const int kBaseHex = 16; const quint64 kBcastMac = 0xffffffffffffULL; +const quint16 kEthTypeArp = 0x0806; const quint16 kEthTypeIp4 = 0x0800; const quint16 kEthTypeIp6 = 0x86dd; const int kIp6HdrLen = 40; @@ -237,17 +238,17 @@ void Device::receivePacket(PacketBuffer *pktBuf) switch(ethType) { - case 0x0806: // ARP + case kEthTypeArp: // ARP if (hasIp4_) receiveArp(pktBuf); break; - case 0x0800: // IPv4 + case kEthTypeIp4: // IPv4 if (hasIp4_) receiveIp4(pktBuf); break; - case 0x86dd: // IPv6 + case kEthTypeIp6: // IPv6 if (hasIp6_) receiveIp6(pktBuf); break; @@ -313,12 +314,12 @@ void Device::resolveNeighbor(PacketBuffer *pktBuf) switch(ethType) { - case 0x0800: // IPv4 + case kEthTypeIp4: // IPv4 if (hasIp4_) sendArpRequest(pktBuf); break; - case 0x86dd: // IPv6 + case kEthTypeIp6: // IPv6 if (hasIp6_) sendNeighborSolicit(pktBuf); break; @@ -369,7 +370,7 @@ bool Device::isOrigin(const PacketBuffer *pktBuf) // We know only about IP packets - adjust for ethType length (2 bytes) // when checking that we have a complete IP header - if ((ethType == 0x0800) && hasIp4_) { // IPv4 + if ((ethType == kEthTypeIp4) && hasIp4_) { // IPv4 int ipHdrLen = (pktData[0] & 0x0F) << 2; quint32 srcIp; @@ -411,7 +412,7 @@ quint64 Device::neighborMac(const PacketBuffer *pktBuf) pktData += 2; // We know only about IP packets - if ((ethType == 0x0800) && hasIp4_) { // IPv4 + if ((ethType == kEthTypeIp4) && hasIp4_) { // IPv4 int ipHdrLen = (pktData[0] & 0x0F) << 2; quint32 dstIp, tgtIp; @@ -489,7 +490,7 @@ void Device::receiveArp(PacketBuffer *pktBuf) protoType = qFromBigEndian(pktData + offset); offset += 2; - if (protoType != 0x0800) // IPv4 + if (protoType != kEthTypeIp4) // IPv4 goto _invalid_exit; hwAddrLen = pktData[offset]; @@ -541,7 +542,7 @@ void Device::receiveArp(PacketBuffer *pktBuf) *(quint32*)(pktData+24) = qToBigEndian(srcIp); } - encap(rspPkt, srcMac, 0x0806); + encap(rspPkt, srcMac, kEthTypeArp); transmitPacket(rspPkt); qDebug("Sent ARP Reply for srcIp/tgtIp=%s/%s", @@ -622,7 +623,7 @@ void Device::sendArpRequest(quint32 tgtIp) *(quint32*)(pktData+24) = qToBigEndian(tgtIp); } - encap(reqPkt, kBcastMac, 0x0806); + encap(reqPkt, kBcastMac, kEthTypeArp); transmitPacket(reqPkt); arpTable_.insert(tgtIp, 0); @@ -713,7 +714,7 @@ void Device::sendIp4Reply(PacketBuffer *pktBuf) sum = (sum & 0xFFFF) + (sum >> 16); *(quint16*)(pktData + 10) = qToBigEndian(quint16(~sum)); - encap(pktBuf, arpTable_.value(tgtIp), 0x0800); + encap(pktBuf, arpTable_.value(tgtIp), kEthTypeIp4); transmitPacket(pktBuf); } @@ -866,7 +867,7 @@ void Device::sendIp6Reply(PacketBuffer *pktBuf) // Reset TTL pktData[7] = 64; - encap(pktBuf, ndpTable_.value(tgtIp), 0x86dd); + encap(pktBuf, ndpTable_.value(tgtIp), kEthTypeIp6); transmitPacket(pktBuf); }