Search in sources :

Example 6 with Data

use of org.onlab.packet.Data in project onos by opennetworkinglab.

the class AuthenticationTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    data = new Data();
    data.setData("testSerialize".getBytes());
    udp = new UDP();
    udp.setPayload(data);
    byte[] bytePayload = udp.serialize();
    byte[] byteHeader = { (byte) 0x11, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x13, (byte) 0x57, (byte) 0x24, (byte) 0x68, (byte) 0x00, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33, (byte) 0x44 };
    bytePacket = new byte[byteHeader.length + bytePayload.length];
    System.arraycopy(byteHeader, 0, bytePacket, 0, byteHeader.length);
    System.arraycopy(bytePayload, 0, bytePacket, byteHeader.length, bytePayload.length);
}
Also used : UDP(org.onlab.packet.UDP) Data(org.onlab.packet.Data) BeforeClass(org.junit.BeforeClass)

Example 7 with Data

use of org.onlab.packet.Data in project fabric-tna by stratum.

the class FabricInterpreterTest method testMapInboundPacketWithShortMetadata.

@Test
public void testMapInboundPacketWithShortMetadata() throws ImmutableByteSequence.ByteSequenceTrimException, PiPipelineInterpreter.PiInterpreterException {
    PortNumber inputPort = PortNumber.portNumber(1);
    PiPacketMetadata pktInMetadata = PiPacketMetadata.builder().withId(P4InfoConstants.INGRESS_PORT).withValue(// deliberately smaller
    ImmutableByteSequence.copyFrom(inputPort.toLong()).fit(8)).build();
    Ethernet packet = new Ethernet();
    packet.setDestinationMACAddress(SRC_MAC);
    packet.setSourceMACAddress(DST_MAC);
    packet.setEtherType((short) 0xBA00);
    packet.setPayload(new Data());
    PiPacketOperation pktInOp = PiPacketOperation.builder().withMetadata(pktInMetadata).withData(ImmutableByteSequence.copyFrom(packet.serialize())).withType(PiPacketOperationType.PACKET_IN).build();
    InboundPacket result = interpreter.mapInboundPacket(pktInOp, DEVICE_ID);
    ConnectPoint receiveFrom = new ConnectPoint(DEVICE_ID, inputPort);
    InboundPacket expectedInboundPacket = new DefaultInboundPacket(receiveFrom, packet, ByteBuffer.wrap(packet.serialize()));
    assertEquals(result.receivedFrom(), expectedInboundPacket.receivedFrom());
    assertEquals(result.parsed(), expectedInboundPacket.parsed());
    assertEquals(result.cookie(), expectedInboundPacket.cookie());
    assertEquals(result.unparsed(), expectedInboundPacket.unparsed());
}
Also used : DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) PiPacketMetadata(org.onosproject.net.pi.runtime.PiPacketMetadata) Ethernet(org.onlab.packet.Ethernet) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) InboundPacket(org.onosproject.net.packet.InboundPacket) PiPacketOperation(org.onosproject.net.pi.runtime.PiPacketOperation) DriverData(org.onosproject.net.driver.DriverData) Data(org.onlab.packet.Data) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 8 with Data

use of org.onlab.packet.Data in project fabric-tna by stratum.

the class FabricInterpreterTest method testMapInboundPacketWithCpuPort.

@Test
public void testMapInboundPacketWithCpuPort() throws ImmutableByteSequence.ByteSequenceTrimException, PiPipelineInterpreter.PiInterpreterException {
    PortNumber inputPort = PortNumber.portNumber(Constants.PORT_CPU);
    PiPacketMetadata pktInMetadata = PiPacketMetadata.builder().withId(P4InfoConstants.INGRESS_PORT).withValue(ImmutableByteSequence.copyFrom(inputPort.toLong()).fit(P4InfoConstants.INGRESS_PORT_BITWIDTH)).build();
    Ethernet packet = new Ethernet();
    packet.setDestinationMACAddress(SRC_MAC);
    packet.setSourceMACAddress(DST_MAC);
    packet.setEtherType((short) 0xBA00);
    packet.setPayload(new Data());
    PiPacketOperation pktInOp = PiPacketOperation.builder().withMetadata(pktInMetadata).withData(ImmutableByteSequence.copyFrom(packet.serialize())).withType(PiPacketOperationType.PACKET_IN).build();
    InboundPacket result = interpreter.mapInboundPacket(pktInOp, DEVICE_ID);
    ConnectPoint receiveFrom = new ConnectPoint(DEVICE_ID, inputPort);
    InboundPacket expectedInboundPacket = new DefaultInboundPacket(receiveFrom, packet, ByteBuffer.wrap(packet.serialize()));
    assertEquals(result.receivedFrom(), expectedInboundPacket.receivedFrom());
    assertEquals(result.parsed(), expectedInboundPacket.parsed());
    assertEquals(result.cookie(), expectedInboundPacket.cookie());
    assertEquals(result.unparsed(), expectedInboundPacket.unparsed());
}
Also used : DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) PiPacketMetadata(org.onosproject.net.pi.runtime.PiPacketMetadata) Ethernet(org.onlab.packet.Ethernet) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) InboundPacket(org.onosproject.net.packet.InboundPacket) PiPacketOperation(org.onosproject.net.pi.runtime.PiPacketOperation) DriverData(org.onosproject.net.driver.DriverData) Data(org.onlab.packet.Data) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Aggregations

Data (org.onlab.packet.Data)8 BeforeClass (org.junit.BeforeClass)4 Test (org.junit.Test)4 Ethernet (org.onlab.packet.Ethernet)4 UDP (org.onlab.packet.UDP)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 PortNumber (org.onosproject.net.PortNumber)4 DriverData (org.onosproject.net.driver.DriverData)4 DefaultInboundPacket (org.onosproject.net.packet.DefaultInboundPacket)4 InboundPacket (org.onosproject.net.packet.InboundPacket)4 PiPacketMetadata (org.onosproject.net.pi.runtime.PiPacketMetadata)4 PiPacketOperation (org.onosproject.net.pi.runtime.PiPacketOperation)4 Port (org.onosproject.net.Port)1