本文整理汇总了Java中org.opendaylight.controller.sal.packet.LLDP类的典型用法代码示例。如果您正苦于以下问题:Java LLDP类的具体用法?Java LLDP怎么用?Java LLDP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LLDP类属于org.opendaylight.controller.sal.packet包,在下文中一共展示了LLDP类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receiveDataPacket
import org.opendaylight.controller.sal.packet.LLDP; //导入依赖的package包/类
@Override
public PacketResult receiveDataPacket(RawPacket inPkt) {
if (inPkt == null) {
logger.debug("Ignoring null packet");
return PacketResult.IGNORED;
}
byte[] data = inPkt.getPacketData();
if (data.length <= 0) {
logger.trace("Ignoring zero length packet");
return PacketResult.IGNORED;
}
if (!inPkt.getEncap().equals(LinkEncap.ETHERNET)) {
logger.trace("Ignoring non ethernet packet");
return PacketResult.IGNORED;
}
NodeConnector nodeConnector = inPkt.getIncomingNodeConnector();
if (((Short) nodeConnector.getID()).equals(NodeConnector.SPECIALNODECONNECTORID)) {
logger.trace("Ignoring ethernet packet received on special port: "
+ inPkt.getIncomingNodeConnector().toString());
return PacketResult.IGNORED;
}
if (!connectionOutService.isLocal(nodeConnector.getNode())) {
logger.debug("Discoery packets will not be processed from {} in a non-master controller", nodeConnector.toString());
return PacketResult.IGNORED;
}
Ethernet ethPkt = new Ethernet();
try {
ethPkt.deserialize(data, 0, data.length * NetUtils.NumBitsInAByte);
} catch (Exception e) {
logger.warn("Failed to decode LLDP packet from {}: {}", inPkt.getIncomingNodeConnector(), e);
return PacketResult.IGNORED;
}
if (ethPkt.getPayload() instanceof LLDP) {
NodeConnector dst = inPkt.getIncomingNodeConnector();
if (isEnabled(dst)) {
if (!processDiscoveryPacket(dst, ethPkt)) {
// Snoop the discovery pkt if not generated from us
snoopDiscoveryPacket(dst, ethPkt);
}
return PacketResult.CONSUME;
}
}
return PacketResult.IGNORED;
}