QVariant MacProtocol::fieldData(int index, FieldAttrib attrib, int streamIndex) const { switch (index) { case mac_dstAddr: { int u; quint64 dstMac = 0; switch (data.dst_mac_mode()) { case OstProto::Mac::e_mm_fixed: dstMac = data.dst_mac(); break; case OstProto::Mac::e_mm_inc: u = (streamIndex % data.dst_mac_count()) * data.dst_mac_step(); dstMac = data.dst_mac() + u; break; case OstProto::Mac::e_mm_dec: u = (streamIndex % data.dst_mac_count()) * data.dst_mac_step(); dstMac = data.dst_mac() - u; break; default: qWarning("Unhandled dstMac_mode %d", data.dst_mac_mode()); } switch(attrib) { case FieldName: return QString("Desination"); case FieldValue: return dstMac; case FieldTextValue: return uintToMacStr(dstMac); case FieldFrameValue: { QByteArray fv; fv.resize(8); qToBigEndian(dstMac, (uchar*) fv.data()); fv.remove(0, 2); return fv; } default: break; } break; } case mac_srcAddr: { int u; quint64 srcMac = 0; switch (data.src_mac_mode()) { case OstProto::Mac::e_mm_fixed: srcMac = data.src_mac(); break; case OstProto::Mac::e_mm_inc: u = (streamIndex % data.src_mac_count()) * data.src_mac_step(); srcMac = data.src_mac() + u; break; case OstProto::Mac::e_mm_dec: u = (streamIndex % data.src_mac_count()) * data.src_mac_step(); srcMac = data.src_mac() - u; break; default: qWarning("Unhandled srcMac_mode %d", data.src_mac_mode()); } switch(attrib) { case FieldName: return QString("Source"); case FieldValue: return srcMac; case FieldTextValue: return uintToMacStr(srcMac); case FieldFrameValue: { QByteArray fv; fv.resize(8); qToBigEndian(srcMac, (uchar*) fv.data()); fv.remove(0, 2); return fv; } default: break; } break; } // Meta fields case mac_dstMacMode: switch(attrib) { case FieldValue: return data.dst_mac_mode(); default: break; } break; case mac_dstMacCount: switch(attrib) { case FieldValue: return data.dst_mac_count(); default: break; } break; case mac_dstMacStep: switch(attrib) { case FieldValue: return data.dst_mac_step(); default: break; } break; case mac_srcMacMode: switch(attrib) { case FieldValue: return data.src_mac_mode(); default: break; } break; case mac_srcMacCount: switch(attrib) { case FieldValue: return data.src_mac_count(); default: break; } break; case mac_srcMacStep: switch(attrib) { case FieldValue: return data.src_mac_step(); default: break; } break; default: break; } return AbstractProtocol::fieldData(index, attrib, streamIndex); }
QVariant StpProtocol::fieldData(int index, FieldAttrib attrib, int streamIndex) const { QString str[] = {"Topology Change", "Topology Change Acknowledgment"}; switch (index) { case stp_protocol_id: { switch (attrib) { case FieldName: return QString("Protocol Identifier"); case FieldValue: return data_.protocol_id(); case FieldTextValue: return QString("0x%1").arg(data_.protocol_id(), 4, BASE_HEX, QChar('0')); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data_.protocol_id(), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(2); default: break; } break; } case stp_version_id: { switch (attrib) { case FieldName: return QString("Version Identifier"); case FieldValue: return data_.protocol_version_id(); case FieldTextValue: return QString("%1").arg( data_.protocol_version_id()); case FieldFrameValue: return QByteArray(1, (char)data_.protocol_version_id()); case FieldBitSize: return BYTES_TO_BITS(1); default: break; } break; } case stp_bpdu_type: { switch (attrib) { case FieldName: return QString("BPDU Type"); case FieldValue: return data_.bpdu_type(); case FieldTextValue: return QString("0x%1").arg(data_.bpdu_type(), 2, BASE_HEX, QChar('0')); case FieldFrameValue: return QByteArray(1, (char)data_.bpdu_type()); case FieldBitSize: return BYTES_TO_BITS(1); default: break; } break; } case stp_flags: { switch (attrib) { case FieldName: return QString("BPDU Flags"); case FieldValue: return data_.flags(); case FieldTextValue: { QString strTemp = "("; if((data_.flags() & ONE_BIT(0))) strTemp += str[0] + ", "; if((data_.flags() & ONE_BIT(7))) strTemp += str[1] + ", "; strTemp += ")"; strTemp.replace(", )", ")"); return strTemp; } case FieldFrameValue: return QByteArray(1, (char)data_.flags()); case FieldBitSize: return BYTES_TO_BITS(1); default: break; } break; } case stp_root_id: { switch (attrib) { case FieldName: return QString("Root Identifier"); case FieldValue: return (quint64) data_.root_id(); case FieldTextValue: { // Root ID contain two value: // Root ID Priority(first 2 bytes) // and Root ID MAC (last 6 bytes). (IEEE802.1D-2008) quint16 priority = ( data_.root_id() & 0xFFFF000000000000ULL) >> (BYTES_TO_BITS(6)); quint64 mac = data_.root_id() & 0x0000FFFFFFFFFFFFULL; return QString("Priority: %1 / MAC: %2") .arg(QString::number(priority), uintToMacStr(mac)); } case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(8)); qToBigEndian((quint64)data_.root_id(), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(8); default: break; } break; } case stp_root_path_cost: { switch (attrib) { case FieldName: return QString("Root Path Cost"); case FieldValue: return data_.root_path_cost(); case FieldTextValue: return QString("%1").arg(data_.root_path_cost()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(4)); qToBigEndian(data_.root_path_cost(), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(4); default: break; } break; } case stp_bridge_id: { switch (attrib) { case FieldName: return QString("Bridge Identifier"); case FieldValue: return (quint64) data_.bridge_id(); case FieldTextValue: { // Bridge ID contain two value: // Bridge ID Priority(first 2 bytes) // and Bridge ID MAC (last 6 bytes). (IEEE802.1D-2008) quint16 priority = (data_.bridge_id() & 0xFFFF000000000000ULL ) >> (BYTES_TO_BITS(6)); quint64 mac = data_.bridge_id() & 0x0000FFFFFFFFFFFFULL; return QString("Priority: %1 / MAC: %2").arg(QString::number(priority), uintToMacStr(mac)); } case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(8)); qToBigEndian((quint64)data_.bridge_id(), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(8); default: break; } break; } case stp_port_id: { switch (attrib) { case FieldName: return QString("Port Identifier"); case FieldValue: return data_.port_id(); case FieldTextValue: return QString("0x%1").arg(data_.port_id(), 4, BASE_HEX, QChar('0')); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data_.port_id(), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(2); default: break; } break; } case stp_message_age: { switch (attrib) { case FieldName: return QString("Message Age"); case FieldValue: return data_.message_age(); case FieldTextValue: return QString("%1").arg(data_.message_age()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)(data_.message_age()), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(2); default: break; } break; } case stp_max_age: { switch (attrib) { case FieldName: return QString("Max Age"); case FieldValue: return data_.max_age(); case FieldTextValue: return QString("%1").arg(data_.max_age()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data_.max_age(), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(2); default: break; } break; } case stp_hello_time: { switch (attrib) { case FieldName: return QString("Hello Time"); case FieldValue: return data_.hello_time(); case FieldTextValue: return QString("%1").arg(data_.hello_time()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data_.hello_time(), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(2); default: break; } break; } case stp_forward_delay: { switch (attrib) { case FieldName: return QString("Forward Delay"); case FieldValue: return data_.forward_delay(); case FieldTextValue: return QString("%1").arg(data_.forward_delay()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data_.forward_delay(), (uchar*)fv.data()); return fv; } case FieldBitSize: return BYTES_TO_BITS(2); default: break; } break; } default: break; } return AbstractProtocol::fieldData(index, attrib, streamIndex); }
QVariant ArpProtocol::fieldData(int index, FieldAttrib attrib, int streamIndex) const { switch (index) { case arp_hwType: { switch(attrib) { case FieldName: return QString("Hardware Type"); case FieldValue: return data.hw_type(); case FieldTextValue: return QString("%1").arg(data.hw_type()); case FieldFrameValue: { QByteArray fv; fv.resize(2); qToBigEndian((quint16) data.hw_type(), (uchar*) fv.data()); return fv; } default: break; } break; } case arp_protoType: { switch(attrib) { case FieldName: return QString("Protocol Type"); case FieldValue: return data.proto_type(); case FieldTextValue: return QString("%1").arg(data.proto_type(), 4, BASE_HEX, QChar('0')); case FieldFrameValue: { QByteArray fv; fv.resize(2); qToBigEndian((quint16) data.proto_type(), (uchar*) fv.data()); return fv; } default: break; } break; } case arp_hwAddrLen: { switch(attrib) { case FieldName: return QString("Hardware Address Length"); case FieldValue: return data.hw_addr_len(); case FieldTextValue: return QString("%1").arg(data.hw_addr_len()); case FieldFrameValue: return QByteArray(1, (char) data.hw_addr_len()); default: break; } break; } case arp_protoAddrLen: { switch(attrib) { case FieldName: return QString("Protocol Address Length"); case FieldValue: return data.proto_addr_len(); case FieldTextValue: return QString("%1").arg(data.proto_addr_len()); case FieldFrameValue: return QByteArray(1, (char) data.proto_addr_len()); default: break; } break; } case arp_opCode: { switch(attrib) { case FieldName: return QString("Operation Code"); case FieldValue: return data.op_code(); case FieldTextValue: return QString("%1").arg(data.op_code()); case FieldFrameValue: { QByteArray fv; fv.resize(2); qToBigEndian((quint16) data.op_code(), (uchar*) fv.data()); return fv; } default: break; } break; } case arp_senderHwAddr: { int u; const int hwAddrStep = 1; quint64 hwAddr = 0; switch (data.sender_hw_addr_mode()) { case OstProto::Arp::kFixed: hwAddr = data.sender_hw_addr(); break; case OstProto::Arp::kIncrement: u = (streamIndex % data.sender_hw_addr_count()) * hwAddrStep; hwAddr = data.sender_hw_addr() + u; break; case OstProto::Arp::kDecrement: u = (streamIndex % data.sender_hw_addr_count()) * hwAddrStep; hwAddr = data.sender_hw_addr() - u; break; default: qWarning("Unhandled hw_addr_mode %d", data.sender_hw_addr_mode()); } switch(attrib) { case FieldName: return QString("Sender Hardware Address"); case FieldValue: return hwAddr; case FieldTextValue: return uintToMacStr(hwAddr); case FieldFrameValue: { QByteArray fv; fv.resize(8); qToBigEndian((quint64) hwAddr, (uchar*) fv.data()); fv.remove(0, 2); return fv; } default: break; } break; } case arp_senderProtoAddr: { int u; quint32 subnet, host, protoAddr = 0; switch(data.sender_proto_addr_mode()) { case OstProto::Arp::kFixedHost: protoAddr = data.sender_proto_addr(); break; case OstProto::Arp::kIncrementHost: u = streamIndex % data.sender_proto_addr_count(); subnet = data.sender_proto_addr() & data.sender_proto_addr_mask(); host = (((data.sender_proto_addr() & ~data.sender_proto_addr_mask()) + u) & ~data.sender_proto_addr_mask()); protoAddr = subnet | host; break; case OstProto::Arp::kDecrementHost: u = streamIndex % data.sender_proto_addr_count(); subnet = data.sender_proto_addr() & data.sender_proto_addr_mask(); host = (((data.sender_proto_addr() & ~data.sender_proto_addr_mask()) - u) & ~data.sender_proto_addr_mask()); protoAddr = subnet | host; break; case OstProto::Arp::kRandomHost: subnet = data.sender_proto_addr() & data.sender_proto_addr_mask(); host = (qrand() & ~data.sender_proto_addr_mask()); protoAddr = subnet | host; break; default: qWarning("Unhandled sender_proto_addr_mode = %d", data.sender_proto_addr_mode()); } switch(attrib) { case FieldName: return QString("Sender Protocol Address"); case FieldValue: return protoAddr; case FieldFrameValue: { QByteArray fv; fv.resize(4); qToBigEndian((quint32) protoAddr, (uchar*) fv.data()); return fv; } case FieldTextValue: return QHostAddress(protoAddr).toString(); default: break; } break; } case arp_targetHwAddr: { int u; const int hwAddrStep = 1; quint64 hwAddr = 0; switch (data.target_hw_addr_mode()) { case OstProto::Arp::kFixed: hwAddr = data.target_hw_addr(); break; case OstProto::Arp::kIncrement: u = (streamIndex % data.target_hw_addr_count()) * hwAddrStep; hwAddr = data.target_hw_addr() + u; break; case OstProto::Arp::kDecrement: u = (streamIndex % data.target_hw_addr_count()) * hwAddrStep; hwAddr = data.target_hw_addr() - u; break; default: qWarning("Unhandled hw_addr_mode %d", data.target_hw_addr_mode()); } switch(attrib) { case FieldName: return QString("Target Hardware Address"); case FieldValue: return hwAddr; case FieldTextValue: return uintToMacStr(hwAddr); case FieldFrameValue: { QByteArray fv; fv.resize(8); qToBigEndian((quint64) hwAddr, (uchar*) fv.data()); fv.remove(0, 2); return fv; } default: break; } break; } case arp_targetProtoAddr: { int u; quint32 subnet, host, protoAddr = 0; switch(data.target_proto_addr_mode()) { case OstProto::Arp::kFixed: protoAddr = data.target_proto_addr(); break; case OstProto::Arp::kIncrementHost: u = streamIndex % data.target_proto_addr_count(); subnet = data.target_proto_addr() & data.target_proto_addr_mask(); host = (((data.target_proto_addr() & ~data.target_proto_addr_mask()) + u) & ~data.target_proto_addr_mask()); protoAddr = subnet | host; break; case OstProto::Arp::kDecrementHost: u = streamIndex % data.target_proto_addr_count(); subnet = data.target_proto_addr() & data.target_proto_addr_mask(); host = (((data.target_proto_addr() & ~data.target_proto_addr_mask()) - u) & ~data.target_proto_addr_mask()); protoAddr = subnet | host; break; case OstProto::Arp::kRandomHost: subnet = data.target_proto_addr() & data.target_proto_addr_mask(); host = (qrand() & ~data.target_proto_addr_mask()); protoAddr = subnet | host; break; default: qWarning("Unhandled target_proto_addr_mode = %d", data.target_proto_addr_mode()); } switch(attrib) { case FieldName: return QString("Target Protocol Address"); case FieldValue: return protoAddr; case FieldFrameValue: { QByteArray fv; fv.resize(4); qToBigEndian((quint32) protoAddr, (uchar*) fv.data()); return fv; } case FieldTextValue: return QHostAddress(protoAddr).toString(); default: break; } break; } // Meta fields case arp_senderHwAddrMode: switch(attrib) { case FieldName: return QString("Sender Hardware Address Mode"); case FieldValue: return data.sender_hw_addr_mode(); default: break; } break; case arp_senderHwAddrCount: switch(attrib) { case FieldName: return QString("Sender Hardware Address Count"); case FieldValue: return data.sender_hw_addr_count(); default: break; } break; case arp_senderProtoAddrMode: switch(attrib) { case FieldName: return QString("Sender Protocol Address Mode"); case FieldValue: return data.sender_proto_addr_mode(); default: break; } break; case arp_senderProtoAddrCount: switch(attrib) { case FieldName: return QString("Sender Protocol Address Count"); case FieldValue: return data.sender_proto_addr_count(); default: break; } break; case arp_senderProtoAddrMask: switch(attrib) { case FieldName: return QString("Sender Protocol Address Mask"); case FieldValue: return data.sender_proto_addr_mask(); default: break; } break; case arp_targetHwAddrMode: switch(attrib) { case FieldName: return QString("Target Hardware Address Mode"); case FieldValue: return data.target_hw_addr_mode(); default: break; } break; case arp_targetHwAddrCount: switch(attrib) { case FieldName: return QString("Target Hardware Address Count"); case FieldValue: return data.target_hw_addr_count(); default: break; } break; case arp_targetProtoAddrMode: switch(attrib) { case FieldName: return QString("Target Protocol Address Mode"); case FieldValue: return data.target_proto_addr_mode(); default: break; } break; case arp_targetProtoAddrCount: switch(attrib) { case FieldName: return QString("Target Protocol Address Count"); case FieldValue: return data.target_proto_addr_count(); default: break; } break; case arp_targetProtoAddrMask: switch(attrib) { case FieldName: return QString("Target Protocol Address Mask"); case FieldValue: return data.target_proto_addr_mask(); default: break; } break; default: qFatal("%s: unimplemented case %d in switch", __PRETTY_FUNCTION__, index); break; } return AbstractProtocol::fieldData(index, attrib, streamIndex); }
QVariant LacpProtocol::fieldData(int index, FieldAttrib attrib, int streamIndex) const { QString str[8]={"Activity", "Timeout", "Aggregation", "Synchronization", "Collecting", "Distributing", "Defaulted", "Expired"}; switch (index) { case lacp_subtype: { switch (attrib) { case FieldName: return QString("Subtype"); case FieldValue: return data.subtype(); case FieldTextValue: return QString("0x%1").arg(data.subtype(), 2, BASE_HEX, QChar('0')); case FieldFrameValue: return QByteArray(1, (char)data.subtype()); default: break; } break; } case lacp_version_number: { switch (attrib) { case FieldName: return QString("Version Number"); case FieldValue: return data.version_number(); case FieldTextValue: return QString("0x%1").arg(data.version_number(), 2, BASE_HEX, QChar('0')); case FieldFrameValue: return QByteArray(1, (char)data.version_number()); default: break; } break; } //--------------------------------Actor----------------------------------------- case lacp_tlv_type_actor: { switch (attrib) { case FieldName: return QString("Actor Information"); case FieldValue: return data.tlv_type_actor(); case FieldTextValue: return QString("%1").arg(data.tlv_type_actor()); case FieldFrameValue: return QByteArray(1, (char)data.tlv_type_actor()); default: break; } break; } case lacp_actor_length: { switch (attrib) { case FieldName: return QString("Actor Information Length"); case FieldValue: return data.actor_info_length(); case FieldTextValue: return QString("%1").arg(data.actor_info_length()); case FieldFrameValue: return QByteArray(1, (char)data.actor_info_length()); default: break; } break; } case lacp_actor_system_priority: { switch (attrib) { case FieldName: return QString("Actor System Priority"); case FieldValue: return data.actor_system_priority(); case FieldTextValue: return QString("%1").arg(data.actor_system_priority()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.actor_system_priority(), (uchar*)fv.data()); return fv; } default: break; } break; } case lacp_actor_system: { switch (attrib) { case FieldName: return QString("Actor System"); case FieldValue: return (quint64)data.actor_system(); case FieldTextValue: return uintToMacStr(data.actor_system()); case FieldFrameValue: { QByteArray fv; // 8 bytes because data.actor_system is UInt64 fv.resize(BYTES(8)); qToBigEndian(data.actor_system() , (uchar*)fv.data()); // remove first two bytes because actor system have 6 byte // (IEEE802.1AX-2008) fv.remove(0, 2); return fv; } default: break; } break; } case lacp_actor_key: { switch (attrib) { case FieldName: return QString("Actor Key"); case FieldValue: return data.actor_key(); case FieldTextValue: return QString("%1").arg(data.actor_key()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.actor_key(), (uchar*) fv.data()); return fv; } default: break; } break; } case lacp_actor_port_priority: { switch (attrib) { case FieldName: return QString("Actor Port Priority"); case FieldValue: return data.actor_port_priority(); case FieldTextValue: return QString("%1").arg(data.actor_port_priority()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.actor_port_priority(), (uchar*)fv.data()); return fv; } default: break; } break; } case lacp_actor_port: { switch (attrib) { case FieldName: return QString("Actor Port"); case FieldValue: return data.actor_port(); case FieldTextValue: return QString("%1").arg(data.actor_port()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.actor_port(), (uchar*)fv.data()); return fv; } default: break; } break; } case lacp_actor_state: { switch (attrib) { case FieldName: return QString("Actor State"); case FieldValue: return data.actor_state(); case FieldTextValue: { QString str_temp = "("; if ((data.actor_state() & ONE_BIT(0))) str_temp += str[0] + ", "; if ((data.actor_state() & ONE_BIT(1))) str_temp += str[1] + ", "; if ((data.actor_state() & ONE_BIT(2))) str_temp += str[2] + ", "; if ((data.actor_state() & ONE_BIT(3))) str_temp += str[3] + ", "; if ((data.actor_state() & ONE_BIT(4))) str_temp += str[4] + ", "; if ((data.actor_state() & ONE_BIT(5))) str_temp += str[5] + ", "; if ((data.actor_state() & ONE_BIT(6))) str_temp += str[6] + ", "; if ((data.actor_state() & ONE_BIT(7))) str_temp += str[7] + ", "; str_temp += ")"; str_temp.replace(", )", ")"); return str_temp; } case FieldFrameValue: return QByteArray(1, (char)data.actor_state()); default: break; } break; } case lacp_actor_reserved: { switch (attrib) { case FieldName: return QString("Reserved"); case FieldValue: return QString("%1").arg(data.actor_reserved(), 6, BASE_HEX, QChar('0')); case FieldTextValue: return QString("0x%1").arg(data.actor_reserved(), 6, BASE_HEX, QChar('0')); case FieldFrameValue: { QByteArray fv; // must have 4 bytes because data.actor_reserved is int32 fv.resize(BYTES(4)); qToBigEndian(data.actor_reserved(), (uchar*)fv.data()); // remove first byte, because field actor reserved // have 3 byte (IEEE802.1AX-2008) fv.remove(0, 1); return fv; } default: break; } break; } //--------------------------------Partner--------------------------------------- case lacp_tlv_type_partner: { switch (attrib) { case FieldName: return QString("Partner Information"); case FieldValue: return data.tlv_type_partner(); case FieldTextValue: return QString("%1").arg(data.tlv_type_partner()); case FieldFrameValue: return QByteArray(1, (char)data.tlv_type_partner()); default: break; } break; } case lacp_partner_length: { switch (attrib) { case FieldName: return QString("Partner Information Length"); case FieldValue: return data.partner_info_length(); case FieldTextValue: return QString("%1").arg(data.partner_info_length()); case FieldFrameValue: return QByteArray(1, (char)data.partner_info_length()); default: break; } break; } case lacp_partner_system_priority: { switch (attrib) { case FieldName: return QString("Partner System Priority"); case FieldValue: return data.partner_system_priority(); case FieldTextValue: return QString("%1").arg(data.partner_system_priority()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.partner_system_priority(), (uchar*)fv.data()); return fv; } default: break; } break; } case lacp_partner_system: { switch (attrib) { case FieldName: return QString("Partner System"); case FieldValue: return (quint64)data.partner_system(); case FieldTextValue: return uintToMacStr(data.partner_system()); case FieldFrameValue: { QByteArray fv; // must have 8 bytes because data.partner_system is UInt64 fv.resize(BYTES(8)); qToBigEndian(data.partner_system() , (uchar*)fv.data()); // remove first byte, because field partner system // have 6 byte (IEEE802.1AX-2008) fv.remove(0, 2); return fv; } default: break; } break; } case lacp_partner_key: { switch (attrib) { case FieldName: return QString("Partner Key"); case FieldValue: return (quint64)data.partner_key(); case FieldTextValue: return QString("%1").arg(data.partner_key()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.partner_key(), (uchar*)fv.data()); return fv; } default: break; } break; } case lacp_partner_port_priority: { switch (attrib) { case FieldName: return QString("Partner Port Priority"); case FieldValue: return data.partner_port_priority(); case FieldTextValue: return QString("%1").arg(data.partner_port_priority()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.partner_port_priority(), (uchar*)fv.data()); return fv; } default: break; } break; } case lacp_partner_port: { switch (attrib) { case FieldName: return QString("Partner Port"); case FieldValue: return data.partner_port(); case FieldTextValue: return QString("%1").arg(data.partner_port()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.partner_port(), (uchar*)fv.data()); return fv; } default: break; } break; } case lacp_partner_state: { switch (attrib) { case FieldName: return QString("Partner State"); case FieldValue: return data.partner_state(); case FieldTextValue: { QString str_temp="("; if ((data.partner_state() & ONE_BIT(0))) str_temp += str[0] + ", "; if ((data.partner_state() & ONE_BIT(1))) str_temp += str[1] + ", "; if ((data.partner_state() & ONE_BIT(2))) str_temp += str[2] + ", "; if ((data.partner_state() & ONE_BIT(3))) str_temp += str[3] + ", "; if ((data.partner_state() & ONE_BIT(4))) str_temp += str[4] + ", "; if ((data.partner_state() & ONE_BIT(5))) str_temp += str[5] + ", "; if ((data.partner_state() & ONE_BIT(6))) str_temp += str[6] + ", "; if ((data.partner_state() & ONE_BIT(7))) str_temp += str[7] + ", "; str_temp+=")"; str_temp.replace(", )", ")"); return str_temp; } case FieldFrameValue: return QByteArray(1, (char)data.partner_state()); default: break; } break; } case lacp_partner_reserved: { switch (attrib) { case FieldName: return QString("Reserved"); case FieldValue: return data.partner_reserved(); case FieldTextValue: return QString("0x%1").arg(data.partner_reserved(), 6, BASE_HEX, QChar('0')); case FieldFrameValue: { QByteArray fv; // must have 4 bytes because data.partner_reserved is UInt32 fv.resize(4); qToBigEndian(data.partner_reserved(), (uchar*)fv.data()); // remove first byte, because field partner reserved // have 3 byte (IEEE802.1AX-2008) fv.remove(0, 1); return fv; } default: break; } break; } //--------------------------------------------Collector------------------------- case lacp_tlv_type_collector: { switch (attrib) { case FieldName: return QString("Collector Information"); case FieldValue: return data.tlv_type_collector(); case FieldTextValue: return QString("%1").arg(data.tlv_type_collector()); case FieldFrameValue: return QByteArray(1, (char)data.tlv_type_collector()); default: break; } break; } case lacp_collector_length: { switch (attrib) { case FieldName: return QString("Collector Information Length"); case FieldValue: return data.collector_info_length(); case FieldTextValue: return QString("%1").arg(data.collector_info_length()); case FieldFrameValue: return QByteArray(1, (char)data.collector_info_length()); default: break; } break; } case lacp_collector_maxDelay: { switch (attrib) { case FieldName: return QString("Collector Max Delay"); case FieldValue: return data.collector_maxdelay(); case FieldTextValue: return QString("%1"). arg(data.collector_maxdelay()); case FieldFrameValue: { QByteArray fv; fv.resize(BYTES(2)); qToBigEndian((quint16)data.collector_maxdelay(), (uchar*)fv.data()); return fv; } default: break; } break; } case lacp_collector_reserved: { QByteArray ba; bool isOk = false; QString reserved; reserved.append(QString().fromStdString(data.collector_reserved())); //insert 0 to left side of string reserved.insert(0, QString().fill(QChar().fromAscii('0'), BYTES(12) * 2 - reserved.size())); // create Byte Array from string with HEX for (int i = 0; i < reserved.size(); i += 2) ba.append(((QString)reserved[i] + (QString)reserved[i + 1]).toUInt(&isOk, BASE_HEX)); switch (attrib) { case FieldName: return QString("Reserved"); case FieldValue: return ba; case FieldTextValue: return QString("0x%1").arg(reserved).toLower(); case FieldFrameValue: return ba; default: break; } break; } //--------------------------------------------terminator------------------------ case lacp_tlv_type_terminator: { switch (attrib) { case FieldName: return QString("Terminator Information"); case FieldValue: return data.tlv_type_terminator(); case FieldTextValue: return QString("%1").arg(data.tlv_type_terminator()); case FieldFrameValue: return QByteArray(1, (char)data.tlv_type_terminator()); default: break; } break; } case lacp_terminator_length: { switch (attrib) { case FieldName: return QString("Terminator Length"); case FieldValue: return data.terminator_length(); case FieldTextValue: return QString("%1").arg(data.terminator_length()); case FieldFrameValue: return QByteArray(1, (char)data.terminator_length()); default: break; } break; } case lacp_terminator_reserved: { QByteArray ba; bool isOk = false; QString reserved; reserved.append( QString().fromStdString(data.terminator_reserved())); //insert 0 to left side of string reserved.insert(0, QString().fill(QChar().fromAscii('0'), BYTES(50) * 2 - reserved.size())); // create Byte Array from string with HEX for (int i = 0; i < reserved.size(); i += 2) ba.append(((QString)reserved[i] + (QString)reserved[i + 1]).toUInt(&isOk, BASE_HEX)); switch (attrib) { case FieldName: return QString("Reserved"); case FieldValue: return ba; case FieldTextValue: return QString("0x%1").arg(reserved).toLower(); case FieldFrameValue: return ba; default: break; } break; } //------------------meta fields------------------------------------------------- case is_override_subtype: { switch (attrib) { case FieldValue: return data.is_override_subtype(); default: break; } } case is_override_version: { switch (attrib) { case FieldValue: return data.is_override_version_number(); default: break; } } case is_override_tlv_actor : { switch (attrib) { case FieldValue: return data.is_override_tlv_type_actor(); default: break; } } case is_override_actor_info: { switch (attrib) { case FieldValue: return data.is_override_actor_info_length(); default: break; } } case is_override_actor_reserved: { switch (attrib) { case FieldValue: return data.is_override_actor_reserved(); default: break; } } case is_override_tlv_partner: { switch (attrib) { case FieldValue: return data.is_override_tlv_type_partner(); default: break; } } case is_override_partner_info: { switch (attrib) { case FieldValue: return data.is_override_partner_info_length(); default: break; } } case is_override_partner_reserved: { switch (attrib) { case FieldValue: return data.is_override_partner_reserved(); default: break; } } case is_override_tlv_collector: { switch (attrib) { case FieldValue: return data.is_override_tlv_type_collector(); default: break; } } case is_override_collector_info: { switch (attrib) { case FieldValue: return data.is_override_collector_info_length(); default: break; } } case is_override_collector_reserved: { switch (attrib) { case FieldValue: return data.is_override_collector_reserved(); default: break; } } case is_override_tlv_terminator: { switch (attrib) { case FieldValue: return data.is_override_tlv_type_terminator(); default: break; } } case is_override_terminator_info: { switch (attrib) { case FieldValue: return data.is_override_terminator_length(); default: break; } } case is_override_terminator_reserved: { switch (attrib) { case FieldValue: return data.is_override_terminator_reserved(); default: break; } } break; default: qFatal("%s: unimplemented case %d in switch", __PRETTY_FUNCTION__, index); break; } return AbstractProtocol::fieldData(index, attrib, streamIndex); }