当前位置: 首页>>代码示例>>Java>>正文


Java LLDP类代码示例

本文整理汇总了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;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:51,代码来源:DiscoveryService.java


注:本文中的org.opendaylight.controller.sal.packet.LLDP类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。