Search in sources :

Example 1 with PacketInEvent

use of org.onosproject.p4runtime.ctl.controller.PacketInEvent in project onos by opennetworkinglab.

the class StreamClientImpl method handlePacketIn.

private void handlePacketIn(P4RuntimeOuterClass.PacketIn packetInMsg) {
    if (log.isTraceEnabled()) {
        log.trace("Received packet-in from {}: {}", deviceId, packetInMsg);
    }
    if (!pipeconfService.getPipeconf(deviceId).isPresent()) {
        log.warn("Unable to handle packet-in from {}, missing pipeconf: {}", deviceId, TextFormat.shortDebugString(packetInMsg));
        return;
    }
    // Decode packet message and post event.
    // TODO: consider implementing a cache to speed up
    // encoding/deconding of packet-in/out (e.g. LLDP, ARP)
    final PiPipeconf pipeconf = pipeconfService.getPipeconf(deviceId).get();
    final PiPacketOperation pktOperation;
    try {
        pktOperation = CODECS.packetIn().decode(packetInMsg, null, pipeconf);
    } catch (CodecException e) {
        log.warn("Unable to process packet-int: {}", e.getMessage());
        return;
    }
    controller.postEvent(new P4RuntimeEvent(P4RuntimeEvent.Type.PACKET_IN, new PacketInEvent(deviceId, pktOperation)));
}
Also used : PacketInEvent(org.onosproject.p4runtime.ctl.controller.PacketInEvent) PiPipeconf(org.onosproject.net.pi.model.PiPipeconf) PiPacketOperation(org.onosproject.net.pi.runtime.PiPacketOperation) CodecException(org.onosproject.p4runtime.ctl.codec.CodecException) P4RuntimeEvent(org.onosproject.p4runtime.api.P4RuntimeEvent)

Aggregations

PiPipeconf (org.onosproject.net.pi.model.PiPipeconf)1 PiPacketOperation (org.onosproject.net.pi.runtime.PiPacketOperation)1 P4RuntimeEvent (org.onosproject.p4runtime.api.P4RuntimeEvent)1 CodecException (org.onosproject.p4runtime.ctl.codec.CodecException)1 PacketInEvent (org.onosproject.p4runtime.ctl.controller.PacketInEvent)1