public class TestQPacketDecoder {
public static void main(String[] args) {
byte[] data = UIUtil.readExample("sv92.2.hex.txt");
QEthernetPacket ethernetPacket = new QEthernetPacket();
int ethernetType = PacketUtils.ethernetType(data);
int ethernetHeaderLen = PacketUtils.ethernetHeaderLen(data);
QProtocolStringField ethernetTypeField = QEthernetPacket.fetchEthernetType(data, 0);
if (QPacketConstants.EthernetType_Vlan.equalsIgnoreCase(ethernetTypeField.getValue())) {
QVlanPacket vlanPacket = new QVlanPacket();
vlanPacket.addField(QVlanPacket.fetchEthernetType(data, QPacketConstants.EthernetHeaderLen));
ethernetPacket.setPayload(vlanPacket);
}
ethernetPacket.addField(ethernetTypeField);
if (QPacketConstants.EthernetType_Goose == ethernetType) {
QGoosePacket goosePacket = new QGoosePacket();
goosePacket.addField(QGoosePacket.fetchAppId(data, ethernetHeaderLen));
goosePacket.addField(QGoosePacket.fetchPduLen(data, ethernetHeaderLen));
if (ethernetPacket.getPayload() == null) {
ethernetPacket.setPayload(goosePacket);
} else {
ethernetPacket.getPayload().setPayload(goosePacket);
}
} else if (QPacketConstants.EthernetType_Smv == ethernetType) {
QSvPacket smvPacket = new QSvPacket();
smvPacket.addField(QSvPacket.fetchAppId(data, ethernetHeaderLen));
smvPacket.addField(QSvPacket.fetchPduLen(data, ethernetHeaderLen));
if (ethernetPacket.getPayload() == null) {
ethernetPacket.setPayload(smvPacket);
} else {
ethernetPacket.getPayload().setPayload(smvPacket);
}
}
for (QIPacket packet = ethernetPacket; packet != null; packet = packet.getPayload()) {
System.out.println(packet.getDesc());
for (QIProtocolField field : packet.getFields()) {