use of org.onosproject.net.packet.DefaultInboundPacket in project onos by opennetworkinglab.
the class DefaultVirtualPacketProviderTest method virtualizePacket.
/**
* Test the physical packet context is delivered to a proper (physical)
* virtual network and device.
*/
@Test
public void virtualizePacket() {
Ethernet eth = new Ethernet();
eth.setSourceMACAddress(SRC_MAC_ADDR);
eth.setDestinationMACAddress(DST_MAC_ADDR);
eth.setVlanID((short) 1);
eth.setPayload(null);
InboundPacket pInPacket = new DefaultInboundPacket(CP22, eth, ByteBuffer.wrap(eth.serialize()));
PacketContext pContext = new TestPacketContext(System.nanoTime(), pInPacket, null, false);
testPacketService.sendTestPacketContext(pContext);
PacketContext vContext = providerService.getRequestedPacketContext(0);
InboundPacket vInPacket = vContext.inPacket();
assertEquals("the packet should be received from VCP12", VCP12, vInPacket.receivedFrom());
assertEquals("VLAN tag should be excludede", VlanId.UNTAGGED, vInPacket.parsed().getVlanID());
}
use of org.onosproject.net.packet.DefaultInboundPacket in project onos by opennetworkinglab.
the class OpenstackRoutingSnatIcmpHandlerTest method sendPacket.
private void sendPacket(Ethernet ethernet) {
final ByteBuffer byteBuffer = ByteBuffer.wrap(ethernet.serialize());
InboundPacket inPacket = new DefaultInboundPacket(connectPoint(srcDeviceId1.toString(), Integer.parseInt(srcPortNum1.toString())), ethernet, byteBuffer);
PacketContext context = new TestPacketContext(127L, inPacket, null, false);
packetProcessor.process(context);
}
use of org.onosproject.net.packet.DefaultInboundPacket in project onos by opennetworkinglab.
the class OpenstackSwitchingArpHandlerTest method sendPacket.
/**
* Sends an Ethernet packet to the process method of the Packet processor.
*
* @param ethernet Ethernet packet
*/
private void sendPacket(Ethernet ethernet) {
final ByteBuffer byteBuffer = ByteBuffer.wrap(ethernet.serialize());
InboundPacket inPacket = new DefaultInboundPacket(connectPoint("1", 1), ethernet, byteBuffer);
PacketContext context = new TestPacketContext(127L, inPacket, null, false);
packetProcessor.process(context);
}
use of org.onosproject.net.packet.DefaultInboundPacket in project onos by opennetworkinglab.
the class OpenstackSwitchingDhcpHandlerTest method sendPacket.
/**
* Sends an Ethernet packet to the process method of the Packet Processor.
*
* @param ethernet Ethernet packet
*/
private void sendPacket(Ethernet ethernet) {
final ByteBuffer byteBuffer = ByteBuffer.wrap(ethernet.serialize());
InboundPacket inPacket = new DefaultInboundPacket(connectPoint("1", 1), ethernet, byteBuffer);
PacketContext context = new TestPacketContext(127L, inPacket, null, false);
packetProcessor.process(context);
}
use of org.onosproject.net.packet.DefaultInboundPacket in project TFG by mattinelorza.
the class InterpreterImpl method mapInboundPacket.
/**
* Returns an ONS InboundPacket equivalent to the given pipeconf-specific
* packet-in operation.
*
* @param packetIn packet operation
* @param deviceId ID of the device that originated the packet-in
* @return inbound packet
* @throws PiInterpreterException if the packet operation cannot be mapped
* to an inbound packet
*/
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId) throws PiInterpreterException {
// Find the ingress_port metadata.
// *** TODO EXERCISE 4: modify metadata names to match P4Info
// ---- START SOLUTION ----
final String inportMetadataName = "ADD HERE METADATA NAME FOR THE INGRESS PORT";
// ---- END SOLUTION ----
Optional<PiPacketMetadata> inportMetadata = packetIn.metadatas().stream().filter(meta -> meta.id().id().equals(inportMetadataName)).findFirst();
if (!inportMetadata.isPresent()) {
throw new PiInterpreterException(format("Missing metadata '%s' in packet-in received from '%s': %s", inportMetadataName, deviceId, packetIn));
}
// Build ONOS InboundPacket instance with the given ingress port.
// 1. Parse packet-in object into Ethernet packet instance.
final byte[] payloadBytes = packetIn.data().asArray();
final ByteBuffer rawData = ByteBuffer.wrap(payloadBytes);
final Ethernet ethPkt;
try {
ethPkt = Ethernet.deserializer().deserialize(payloadBytes, 0, packetIn.data().size());
} catch (DeserializationException dex) {
throw new PiInterpreterException(dex.getMessage());
}
// 2. Get ingress port
final ImmutableByteSequence portBytes = inportMetadata.get().value();
final short portNum = portBytes.asReadOnlyBuffer().getShort();
final ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(portNum));
return new DefaultInboundPacket(receivedFrom, ethPkt, rawData);
}
Aggregations