use of org.onlab.packet.Ethernet in project onos by opennetworkinglab.
the class PipelineInterpreterImpl method mapInboundPacket.
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId) throws PiInterpreterException {
// We assume that the packet is ethernet, which is fine since mytunnel.p4
// can deparse only ethernet packets.
Ethernet ethPkt;
try {
ethPkt = Ethernet.deserializer().deserialize(packetIn.data().asArray(), 0, packetIn.data().size());
} catch (DeserializationException dex) {
throw new PiInterpreterException(dex.getMessage());
}
// Returns the ingress port packet metadata.
Optional<PiPacketMetadata> packetMetadata = packetIn.metadatas().stream().filter(metadata -> metadata.id().toString().equals(INGRESS_PORT)).findFirst();
if (packetMetadata.isPresent()) {
short s = packetMetadata.get().value().asReadOnlyBuffer().getShort();
ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(s));
return new DefaultInboundPacket(receivedFrom, ethPkt, packetIn.data().asReadOnlyBuffer());
} else {
throw new PiInterpreterException(format("Missing metadata '%s' in packet-in received from '%s': %s", INGRESS_PORT, deviceId, packetIn));
}
}
use of org.onlab.packet.Ethernet in project onos by opennetworkinglab.
the class DefaultNeighbourMessageActionsTest method reply.
@Test
public void reply() throws Exception {
Ethernet request = NeighbourTestUtils.createArpRequest(IP1);
Ip4Address ip4Address = INTF1.ipAddressesList().get(0).ipAddress().getIp4Address();
Ethernet response = ARP.buildArpReply(ip4Address, MAC2, request);
packetService.emit(outbound(response, CP1));
expectLastCall().once();
replay(packetService);
actions.reply(createContext(request, CP1, null), MAC2);
verify(packetService);
}
use of org.onlab.packet.Ethernet in project onos by opennetworkinglab.
the class DefaultNeighbourMessageActionsTest method forwardToConnectPoint.
@Test
public void forwardToConnectPoint() {
Ethernet request = NeighbourTestUtils.createArpRequest(IP1);
packetService.emit(outbound(request, CP2));
expectLastCall().once();
replay(packetService);
actions.forward(createContext(request, CP1, null), CP2);
verify(packetService);
}
use of org.onlab.packet.Ethernet in project onos by opennetworkinglab.
the class DefaultNeighbourMessageActionsTest method forwardToInterface.
@Test
public void forwardToInterface() {
Ethernet request = NeighbourTestUtils.createArpRequest(IP1);
Ethernet forwardedRequest = request.duplicate();
forwardedRequest.setSourceMACAddress(INTF2.mac());
forwardedRequest.setVlanID(INTF2.vlan().toShort());
packetService.emit(outbound(forwardedRequest, CP2));
expectLastCall().once();
replay(packetService);
actions.forward(createContext(request, CP1, null), INTF2);
verify(packetService);
}
use of org.onlab.packet.Ethernet in project onos by opennetworkinglab.
the class DefaultNeighbourMessageActionsTest method flood.
@Test
public void flood() {
Ethernet request = NeighbourTestUtils.createArpRequest(IP1);
// Expect the packet to be emitted out all ports apart from the in port
Sets.difference(Sets.newLinkedHashSet(EDGE_PORTS), Collections.singleton(CP1)).forEach(cp -> {
packetService.emit(outbound(request, cp));
expectLastCall().once();
});
replay(packetService);
actions.flood(createContext(request, CP1, null));
verify(packetService);
}
Aggregations