use of org.onosproject.p4runtime.api.P4RuntimePacketIn in project onos by opennetworkinglab.
the class P4RuntimePacketProvider method handleP4RuntimeEvent.
private void handleP4RuntimeEvent(P4RuntimeEvent event) {
// FIXME we need the device ID into p4RuntimeEvnetSubject to check for mastsership
if (!(event.subject() instanceof P4RuntimePacketIn) || event.type() != P4RuntimeEvent.Type.PACKET_IN) {
log.debug("Unrecognized event type {}, discarding", event.type());
// Not a packet-in event, ignore it.
return;
}
P4RuntimePacketIn eventSubject = (P4RuntimePacketIn) event.subject();
DeviceId deviceId = eventSubject.deviceId();
Device device = deviceService.getDevice(eventSubject.deviceId());
if (device == null) {
log.warn("Unable to process packet-in from {}, device is null in the core", deviceId);
return;
}
if (!device.is(PiPipelineInterpreter.class)) {
log.warn("Unable to process packet-in from {}, device has no PiPipelineInterpreter behaviour", deviceId);
return;
}
PiPacketOperation operation = eventSubject.packetOperation();
InboundPacket inPkt;
try {
inPkt = device.as(PiPipelineInterpreter.class).mapInboundPacket(operation, deviceId);
} catch (PiPipelineInterpreter.PiInterpreterException e) {
log.warn("Unable to interpret inbound packet from {}: {}", deviceId, e.getMessage());
return;
}
if (log.isTraceEnabled()) {
final EthType.EtherType etherType = getEtherType(inPkt.unparsed());
log.trace("Received PACKET-IN <<< device={} ingress_port={} eth_type={}", inPkt.receivedFrom().deviceId(), inPkt.receivedFrom().port(), etherType.ethType().toString());
}
if (inPkt == null) {
log.debug("Received null inbound packet. Ignoring.");
return;
}
OutboundPacket outPkt = new DefaultOutboundPacket(eventSubject.deviceId(), null, operation.data().asReadOnlyBuffer());
PacketContext pktCtx = new P4RuntimePacketContext(System.currentTimeMillis(), inPkt, outPkt, false);
// Pushing the packet context up for processing.
providerService.processPacket(pktCtx);
}
Aggregations