use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.
the class NeighbourResolutionManagerTest method context.
/**
* Creates a packet context for the given packet coming in the given port.
*
* @param packet packet to wrap in a packet context
* @param inPort input port of the packet
* @return packet context
*/
private static PacketContext context(Ethernet packet, ConnectPoint inPort) {
InboundPacket inboundPacket = new DefaultInboundPacket(inPort, packet, null);
OutboundPacket outboundPacket = new DefaultOutboundPacket(null, null, null);
return new PacketContextAdapter(0, inboundPacket, outboundPacket, false);
}
use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.
the class PacketManagerTest method packetProviderfallbackBasics.
/**
* Tests the correct usage of fallback driver provider for packets.
*/
@Test
public void packetProviderfallbackBasics() {
OutboundPacket packet = new DefaultOutboundPacket(FOO_DID, DefaultTrafficTreatment.emptyTreatment(), ByteBuffer.allocate(5));
mgr.emit(packet);
assertEquals("Packet not emitted correctly", packet, emittedPacket);
}
use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.
the class LinkDiscovery method createOutBoundLldp.
/**
* Creates packet_out LLDP for specified output port.
*
* @param portNumber the port
* @param portDesc the port description
* @return Packet_out message with LLDP data
*/
private OutboundPacket createOutBoundLldp(Long portNumber, String portDesc) {
if (portNumber == null) {
return null;
}
ONOSLLDP lldp = getLinkProbe(portNumber, portDesc);
if (lldp == null) {
log.warn("Cannot get link probe with portNumber {} and portDesc {} for {} at LLDP packet creation.", portNumber, portDesc, deviceId);
return null;
}
ethPacket.setSourceMACAddress(context.fingerprint()).setPayload(lldp);
return new DefaultOutboundPacket(deviceId, builder().setOutput(portNumber(portNumber)).build(), ByteBuffer.wrap(ethPacket.serialize()));
}
use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.
the class DefaultOutboundPacketSerializer method read.
@Override
public DefaultOutboundPacket read(Kryo kryo, Input input, Class<DefaultOutboundPacket> type) {
DeviceId sendThrough = (DeviceId) kryo.readClassAndObject(input);
TrafficTreatment treatment = (TrafficTreatment) kryo.readClassAndObject(input);
byte[] data = (byte[]) kryo.readClassAndObject(input);
return new DefaultOutboundPacket(sendThrough, treatment, ByteBuffer.wrap(data));
}
use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.
the class DefaultVirtualPacketProviderTest method devirtualizePacket.
/**
* Test the virtual outbound packet is delivered to a proper (physical)
* device.
*/
@Test
public void devirtualizePacket() {
TrafficTreatment tr = DefaultTrafficTreatment.builder().setOutput(VPORT_NUM1).build();
ByteBuffer data = ByteBuffer.wrap("abc".getBytes());
OutboundPacket vOutPacket = new DefaultOutboundPacket(VDID, tr, data);
virtualProvider.emit(VNET_ID, vOutPacket);
assertEquals("The count should be 1", 1, testPacketService.getRequestedPacketCount());
OutboundPacket pOutPacket = testPacketService.getRequestedPacket(0);
assertEquals("The packet should be requested on DEV1", DID1, pOutPacket.sendThrough());
PortNumber outPort = pOutPacket.treatment().allInstructions().stream().filter(i -> i.type() == Instruction.Type.OUTPUT).map(i -> (Instructions.OutputInstruction) i).map(i -> i.port()).findFirst().get();
assertEquals("The packet should be out at PORT1 of DEV1", PORT_NUM1, outPort);
}
Aggregations