Opendaylight BORON 数据包处理(Hydrogen 的 IListenDataPacket class)

Opendaylight BORON packet handling ( Hydrogen's IListenDataPacket class)

使用什么 API 来处理到达 ODL 控制器的数据包? 在 Hydrogen 版本中,我可以实现 IListenDataPacket class,它完成了工作。

文档找了好久,没弄明白

由于 Beryllium IListenDataPacketPacketProcessingListener 取代,作为从 ADSAL

走向 MDSAL 的一部分

通过扩展 PacketProcsessingListener 创建侦听器。并注册这个监听器。如果你需要从控制器发送数据包到OVS,你可以使用PacketProcessingService。

public class PacketHandler implements PacketProcessingListener {

    private final static Logger LOG = LoggerFactory.getLogger(PacketHandler.class);
    private final DataBroker dataBroker;
    private final PacketProcessingService packetProcessor;

    public PacketHandler(DataBroker dataBroker, PacketProcessingService packetProcessor) {
        super();
        this.dataBroker = dataBroker;
        this.packetProcessor = packetProcessor;
    }

    @Override
    public void onPacketReceived(PacketReceived notification) {

        LOG.trace("PacketReceived invoked...");
        short tableId = notification.getTableId().getValue();
        byte[] data = notification.getPayload();
        // BigInteger metadata =
        // notification.getMatch().getMetadata().getMetadata();
        Ethernet res = new Ethernet();

        try {
            res.deserialize(data, 0, data.length * NetUtils.NumBitsInAByte);
        } catch (Exception e) {
            LOG.warn("Failed to decode Packet ", e);
            return;
        }
        try {
            Packet pkt = res.getPayload();
            if (pkt instanceof IPv4) {
                IPv4 ipv4 = (IPv4) pkt;
                // Handle IPv4 packet
            }
            return;

        } catch (Exception ex) {
            // Failed to handle packet
            LOG.error("Failed to handle subnetroute packets ", ex);
        }
        return;

    }
}