Skip to content
Snippets Groups Projects
  • André Mantas's avatar
    b1a86c6c
    deserialize fix for not-known Ethernet types · b1a86c6c
    André Mantas authored
    For Ethernet types not in Ethernet.etherTypeClassMap, the deserialization would set the payload to the whole data array (including the mac addresses and eth type) instead of the rest of the data array.
    
    For example, this would fail to print:
    
    Ethernet l2 = new Ethernet();
    l2.setEtherType(EthType.of(65535)); // some type
    l2.setSourceMACAddress(MacAddress.of("00:00:00:00:00:01"));
    l2.setDestinationMACAddress(MacAddress.BROADCAST);
    Data packetData = new Data();
    packetData.setData("some string".getBytes());
    l2.setPayload(packetData);
    byte[] l2bytes = l2.serialize();
    Ethernet l2d = new Ethernet();
    l2d.deserialize(l2bytes, 0, l2bytes.length);
    Data packetDataDeserialized = (Data) l2d.getPayload();
    // printing "new String(packetDataDeserialized.getData())" gives "?????"
    
    I ran the JUnit tests in floodlightcontroller.core.internal, floodlightcontroller.core.test and floodlightcontroller.packet. Are there any more relevant tests?
    b1a86c6c
    History
    deserialize fix for not-known Ethernet types
    André Mantas authored
    For Ethernet types not in Ethernet.etherTypeClassMap, the deserialization would set the payload to the whole data array (including the mac addresses and eth type) instead of the rest of the data array.
    
    For example, this would fail to print:
    
    Ethernet l2 = new Ethernet();
    l2.setEtherType(EthType.of(65535)); // some type
    l2.setSourceMACAddress(MacAddress.of("00:00:00:00:00:01"));
    l2.setDestinationMACAddress(MacAddress.BROADCAST);
    Data packetData = new Data();
    packetData.setData("some string".getBytes());
    l2.setPayload(packetData);
    byte[] l2bytes = l2.serialize();
    Ethernet l2d = new Ethernet();
    l2d.deserialize(l2bytes, 0, l2bytes.length);
    Data packetDataDeserialized = (Data) l2d.getPayload();
    // printing "new String(packetDataDeserialized.getData())" gives "?????"
    
    I ran the JUnit tests in floodlightcontroller.core.internal, floodlightcontroller.core.test and floodlightcontroller.packet. Are there any more relevant tests?
Ethernet.java 16.54 KiB