本文整理汇总了Java中net.floodlightcontroller.core.IOFSwitch.hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java IOFSwitch.hasAttribute方法的具体用法?Java IOFSwitch.hasAttribute怎么用?Java IOFSwitch.hasAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.core.IOFSwitch
的用法示例。
在下文中一共展示了IOFSwitch.hasAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFlood
import net.floodlightcontroller.core.IOFSwitch; //导入方法依赖的package包/类
/**
* Creates a OFPacketOut with the OFPacketIn data that is flooded on all ports unless
* the port is blocked, in which case the packet will be dropped.
* @param sw The switch that receives the OFPacketIn
* @param pi The OFPacketIn that came to the switch
* @param cntx The FloodlightContext associated with this OFPacketIn
*/
@LogMessageDoc(level="ERROR",
message="Failure writing PacketOut " +
"switch={switch} packet-in={packet-in} " +
"packet-out={packet-out}",
explanation="An I/O error occured while writing a packet " +
"out message to the switch",
recommendation=LogMessageDoc.CHECK_SWITCH)
protected void doFlood(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
if (topologyService.isIncomingBroadcastAllowed(sw.getId(), inPort) == false) {
if (log.isTraceEnabled()) {
log.trace("doFlood, drop broadcast packet, pi={}, " +
"from a blocked port, srcSwitch=[{},{}], linkInfo={}",
new Object[] {pi, sw.getId(), inPort});
}
return;
}
// Set Action to flood
OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
List<OFAction> actions = new ArrayList<OFAction>();
if (sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_FLOOD)) {
actions.add(sw.getOFFactory().actions().output(OFPort.FLOOD, Integer.MAX_VALUE)); // FLOOD is a more selective/efficient version of ALL
} else {
actions.add(sw.getOFFactory().actions().output(OFPort.ALL, Integer.MAX_VALUE));
}
pob.setActions(actions);
// set buffer-id, in-port and packet-data based on packet-in
pob.setBufferId(OFBufferId.NO_BUFFER);
pob.setInPort(inPort);
pob.setData(pi.getData());
try {
if (log.isTraceEnabled()) {
log.trace("Writing flood PacketOut switch={} packet-in={} packet-out={}",
new Object[] {sw, pi, pob.build()});
}
messageDamper.write(sw, pob.build());
} catch (IOException e) {
log.error("Failure writing PacketOut switch={} packet-in={} packet-out={}",
new Object[] {sw, pi, pob.build()}, e);
}
return;
}