用于处理到达ODL控制器的数据包的API是什么? 在Hydrogen版本中,我可以实现IListenDataPacket类,它完成了这项工作。
我搜索了很长一段时间的文档,但我无法弄明白。
答案 0 :(得分:2)
由于铍IListenDataPacket
已替换为PacketProcessingListener
,因为从MDSAL
ADSAL
通过扩展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;
}
}