本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFPortState类的典型用法代码示例。如果您正苦于以下问题:Java OFPortState类的具体用法?Java OFPortState怎么用?Java OFPortState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFPortState类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFPortState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSwitchPortStatusUpdate
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
private void generateSwitchPortStatusUpdate(DatapathId sw, OFPort port) {
UpdateOperation operation;
IOFSwitch iofSwitch = switchService.getSwitch(sw);
if (iofSwitch == null) return;
OFPortDesc ofp = iofSwitch.getPort(port);
if (ofp == null) return;
Set<OFPortState> srcPortState = ofp.getState();
boolean portUp = !srcPortState.contains(OFPortState.STP_BLOCK);
if (portUp) {
operation = UpdateOperation.PORT_UP;
} else {
operation = UpdateOperation.PORT_DOWN;
}
updates.add(new LDUpdate(sw, port, operation));
}
示例2: generateSwitchPortStatusUpdate
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
private void generateSwitchPortStatusUpdate(DatapathId sw, OFPort port) {
UpdateOperation operation;
IOFSwitch iofSwitch = switchService.getSwitch(sw);
if (iofSwitch == null) return;
OFPortDesc ofp = iofSwitch.getPort(port);
if (ofp == null) return;
Set<OFPortState> srcPortState = ofp.getState();
boolean portUp = !srcPortState.contains(OFPortState.STP_BLOCK);
if (portUp) {
operation = UpdateOperation.PORT_UP;
} else {
operation = UpdateOperation.PORT_DOWN;
}
updates.add(new LDUpdate(sw, port, operation));
}
示例3: portChanged
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
@Override
public void portChanged(Dpid dpid, OFPortStatus status) {
LinkDiscovery ld = discoverers.get(dpid);
if (ld == null) {
return;
}
final OFPortDesc port = status.getDesc();
final boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) &&
!port.getConfig().contains(OFPortConfig.PORT_DOWN);
if (enabled) {
ld.addPort(port);
} else {
/*
* remove port calls linkVanished
*/
ld.removePort(port);
}
}
示例4: toWireValue
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
public static int toWireValue(Set<OFPortState> set) {
int wireValue = 0;
for(OFPortState e: set) {
switch(e) {
case LINK_DOWN:
wireValue |= LINK_DOWN_VAL;
break;
case BLOCKED:
wireValue |= BLOCKED_VAL;
break;
case LIVE:
wireValue |= LIVE_VAL;
break;
default:
throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.2: " + e);
}
}
return wireValue;
}
示例5: toWireValue
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
public static int toWireValue(Set<OFPortState> set) {
int wireValue = 0;
for(OFPortState e: set) {
switch(e) {
case LINK_DOWN:
wireValue |= LINK_DOWN_VAL;
break;
case BLOCKED:
wireValue |= BLOCKED_VAL;
break;
case LIVE:
wireValue |= LIVE_VAL;
break;
default:
throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.3: " + e);
}
}
return wireValue;
}
示例6: toWireValue
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
public static int toWireValue(Set<OFPortState> set) {
int wireValue = 0;
for(OFPortState e: set) {
switch(e) {
case LINK_DOWN:
wireValue |= LINK_DOWN_VAL;
break;
case STP_LISTEN:
wireValue |= STP_LISTEN_VAL;
break;
case STP_LEARN:
wireValue |= STP_LEARN_VAL;
break;
case STP_FORWARD:
wireValue |= STP_FORWARD_VAL;
break;
case STP_BLOCK:
wireValue |= STP_BLOCK_VAL;
break;
default:
throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.0: " + e);
}
}
return wireValue;
}
示例7: toWireValue
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
public static int toWireValue(Set<OFPortState> set) {
int wireValue = 0;
for(OFPortState e: set) {
switch(e) {
case LINK_DOWN:
wireValue |= LINK_DOWN_VAL;
break;
case BLOCKED:
wireValue |= BLOCKED_VAL;
break;
case LIVE:
wireValue |= LIVE_VAL;
break;
default:
throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.1: " + e);
}
}
return wireValue;
}
示例8: toWireValue
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
public static int toWireValue(Set<OFPortState> set) {
int wireValue = 0;
for(OFPortState e: set) {
switch(e) {
case LINK_DOWN:
wireValue |= LINK_DOWN_VAL;
break;
case BLOCKED:
wireValue |= BLOCKED_VAL;
break;
case LIVE:
wireValue |= LIVE_VAL;
break;
default:
throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.4: " + e);
}
}
return wireValue;
}
示例9: createMockPortWithState
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
private OFPortDesc createMockPortWithState(short portNumber,
Set<OFPortState> state) {
OFPort ofPort = createMock(OFPort.class);
expect(ofPort.getShortPortNumber()).andReturn(portNumber).anyTimes();
OFPortDesc ofPortDesc = createMock(OFPortDesc.class);
expect(ofPortDesc.getPortNo()).andReturn(ofPort).anyTimes();
expect(ofPortDesc.getHwAddr()).andReturn(
MacAddress.of(DEFAULT_MAC_ADDRESS)).anyTimes();
expect(ofPortDesc.getConfig()).
andReturn(Collections.<OFPortConfig>emptySet()).anyTimes();
expect(ofPortDesc.getState()).andReturn(state).anyTimes();
replay(ofPort);
replay(ofPortDesc);
return ofPortDesc;
}
示例10: buildPortDescription
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
/**
* Build a portDescription from a given Ethernet port description.
*
* @param port the port to build from.
* @return portDescription for the port.
*/
private PortDescription buildPortDescription(OFPortDesc port) {
if (port.getVersion().wireVersion >= OFVersion.OF_14.getWireVersion()) {
return buildPortDescription14(port);
}
PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
boolean enabled =
!port.getState().contains(OFPortState.LINK_DOWN) &&
!port.getConfig().contains(OFPortConfig.PORT_DOWN);
Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
boolean adminDown = port.getConfig().contains(OFPortConfig.PORT_DOWN);
SparseAnnotations annotations = makePortAnnotation(port.getName(),
port.getHwAddr().toString(),
adminDown).build();
return new DefaultPortDescription(portNo, enabled, type,
portSpeed(port), annotations);
}
示例11: toWireValue
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
public static int toWireValue(Set<OFPortState> set) {
int wireValue = 0;
for(OFPortState e: set) {
switch(e) {
case LINK_DOWN:
wireValue |= LINK_DOWN_VAL;
break;
case BLOCKED:
wireValue |= BLOCKED_VAL;
break;
case LIVE:
wireValue |= LIVE_VAL;
break;
default:
throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.5: " + e);
}
}
return wireValue;
}
示例12: testIsEnabledForFactory
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
public void testIsEnabledForFactory(OFFactory factory) {
// Default
OFPortDesc desc = factory.buildPortDesc()
.build();
assertThat(desc.isEnabled(), is(true));
// Partially disabled
desc = factory.buildPortDesc()
.setConfig(new HashSet<OFPortConfig>(Arrays.asList(OFPortConfig.PORT_DOWN)))
.build();
assertThat(desc.isEnabled(), is(false));
// Fully disabled
desc = factory.buildPortDesc()
.setConfig(new HashSet<OFPortConfig>(Arrays.asList(OFPortConfig.PORT_DOWN)))
.setState(new HashSet<OFPortState>(Arrays.asList(OFPortState.LINK_DOWN)))
.build();
assertThat(desc.isEnabled(), is(false));
}
示例13: buildOduCltPortDescription
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
private PortDescription buildOduCltPortDescription(OFPortDesc port) {
PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) &&
!port.getConfig().contains(OFPortConfig.PORT_DOWN);
Long portSpeedInMbps = portSpeed(port);
CltSignalType sigType = null;
switch (portSpeedInMbps.toString()) {
case "1000":
sigType = CltSignalType.CLT_1GBE;
break;
case "10000":
sigType = CltSignalType.CLT_10GBE;
break;
case "40000":
sigType = CltSignalType.CLT_40GBE;
break;
case "100000":
sigType = CltSignalType.CLT_100GBE;
break;
default:
throw new RuntimeException("Un recognize OduClt speed: " + portSpeedInMbps.toString());
}
SparseAnnotations annotations = buildOduCltAnnotation(port);
return oduCltPortDescription(portNo, enabled, sigType, annotations);
}
示例14: buildPortDescription
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
/**
* Build a portDescription from a given Ethernet port description.
*
* @param port the port to build from.
* @return portDescription for the port.
*/
private PortDescription buildPortDescription(OFPortDesc port) {
PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
boolean enabled =
!port.getState().contains(OFPortState.LINK_DOWN) &&
!port.getConfig().contains(OFPortConfig.PORT_DOWN);
Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
return new DefaultPortDescription(portNo, enabled, type,
portSpeed(port), annotations);
}
示例15: getUpdateOperation
import org.projectfloodlight.openflow.protocol.OFPortState; //导入依赖的package包/类
protected UpdateOperation getUpdateOperation(OFPortState srcPortState, OFPortState dstPortState) {
boolean added = ((srcPortState != OFPortState.STP_BLOCK) && (dstPortState != OFPortState.STP_BLOCK));
if (added) {
return UpdateOperation.LINK_UPDATED;
} else {
return UpdateOperation.LINK_REMOVED;
}
}