本文整理汇总了Java中org.projectfloodlight.openflow.types.OFPort.LOCAL属性的典型用法代码示例。如果您正苦于以下问题:Java OFPort.LOCAL属性的具体用法?Java OFPort.LOCAL怎么用?Java OFPort.LOCAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.projectfloodlight.openflow.types.OFPort
的用法示例。
在下文中一共展示了OFPort.LOCAL属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isIncomingDiscoveryAllowed
/**
* Check if incoming discovery messages are enabled or not.
* @param sw
* @param port
* @param isStandard
* @return
*/
protected boolean isIncomingDiscoveryAllowed(DatapathId sw, OFPort port,
boolean isStandard) {
if (isLinkDiscoverySuppressed(sw, port)) {
/* Do not process LLDPs from this port as suppressLLDP is set */
return false;
}
IOFSwitch iofSwitch = switchService.getSwitch(sw);
if (iofSwitch == null) {
return false;
}
if (port == OFPort.LOCAL) return false;
OFPortDesc ofpPort = iofSwitch.getPort(port);
if (ofpPort == null) {
if (log.isTraceEnabled()) {
log.trace("Null physical port. sw={}, port={}",
sw.toString(), port.getPortNumber());
}
return false;
}
return true;
}
示例2: isOutgoingDiscoveryAllowed
/**
* Check if outgoing discovery messages are enabled or not.
* @param sw
* @param port
* @param isStandard
* @param isReverse
* @return
*/
protected boolean isOutgoingDiscoveryAllowed(DatapathId sw, OFPort port,
boolean isStandard,
boolean isReverse) {
if (isLinkDiscoverySuppressed(sw, port)) {
/* Dont send LLDPs out of this port as suppressLLDP is set */
return false;
}
IOFSwitch iofSwitch = switchService.getSwitch(sw);
if (iofSwitch == null) {
return false;
}
if (port == OFPort.LOCAL) return false;
OFPortDesc ofpPort = iofSwitch.getPort(port);
if (ofpPort == null) {
if (log.isTraceEnabled()) {
log.trace("Null physical port. sw={}, port={}",
sw.toString(), port.getPortNumber());
}
return false;
} else {
return true;
}
}
示例3: decode_output
/**
* Parse string and numerical port representations.
* The key and delimiter for the action should be omitted, and only the
* data should be presented to this decoder. Data can be any signed integer
* as a string or the strings 'controller', 'local', 'ingress-port', 'normal',
* or 'flood'.
* @param actionToDecode; The action as a string to decode
* @param version; The OF version to create the action for
* @param log
* @return
*/
private static OFActionOutput decode_output(String actionToDecode, OFVersion version, Logger log) {
Matcher n = Pattern.compile("((all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(actionToDecode);
OFActionOutput.Builder ab = OFFactories.getFactory(version).actions().buildOutput();
OFPort port = OFPort.ANY;
if (n.matches()) {
if (n.group(1) != null && n.group(1).equals("all"))
port = OFPort.ALL;
else if (n.group(1) != null && n.group(1).equals("controller"))
port = OFPort.CONTROLLER;
else if (n.group(1) != null && n.group(1).equals("local"))
port = OFPort.LOCAL;
else if (n.group(1) != null && n.group(1).equals("ingress-port"))
port = OFPort.IN_PORT;
else if (n.group(1) != null && n.group(1).equals("normal"))
port = OFPort.NORMAL;
else if (n.group(1) != null && n.group(1).equals("flood"))
port = OFPort.FLOOD;
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
log.debug("action {}", ab.build());
return ab.build();
}
else {
try {
port = OFPort.of(Integer.parseInt(actionToDecode));
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
return ab.build();
} catch (NumberFormatException e) {
log.error("Could not parse Integer port: '{}'", actionToDecode);
return null;
}
}
}
示例4: decode_output
/**
* Parse string and numerical port representations.
* The key and delimiter for the action should be omitted, and only the
* data should be presented to this decoder. Data can be any signed integer
* as a string or the strings 'controller', 'local', 'ingress-port', 'normal',
* or 'flood'.
* @param actionToDecode; The action as a string to decode
* @param version; The OF version to create the action for
* @param log
* @return
*/
@LogMessageDoc(level="ERROR",
message="Invalid subaction: '{subaction}'",
explanation="A static flow entry contained an invalid subaction",
recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
private static OFActionOutput decode_output(String actionToDecode, OFVersion version, Logger log) {
Matcher n = Pattern.compile("((all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(actionToDecode);
OFActionOutput.Builder ab = OFFactories.getFactory(version).actions().buildOutput();
OFPort port = OFPort.ANY;
if (n.matches()) {
if (n.group(1) != null && n.group(1).equals("all"))
port = OFPort.ALL;
else if (n.group(1) != null && n.group(1).equals("controller"))
port = OFPort.CONTROLLER;
else if (n.group(1) != null && n.group(1).equals("local"))
port = OFPort.LOCAL;
else if (n.group(1) != null && n.group(1).equals("ingress-port"))
port = OFPort.IN_PORT;
else if (n.group(1) != null && n.group(1).equals("normal"))
port = OFPort.NORMAL;
else if (n.group(1) != null && n.group(1).equals("flood"))
port = OFPort.FLOOD;
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
log.debug("action {}", ab.build());
return ab.build();
}
else {
try {
port = OFPort.of(Integer.parseInt(actionToDecode));
ab.setPort(port);
ab.setMaxLen(Integer.MAX_VALUE);
return ab.build();
} catch (NumberFormatException e) {
log.error("Could not parse Integer port: '{}'", actionToDecode);
return null;
}
}
}
示例5: compare
@Override
public int compare(AttachmentPoint oldAP, AttachmentPoint newAP) {
//First compare based on L2 domain ID;
DatapathId oldSw = oldAP.getSw();
OFPort oldPort = oldAP.getPort();
DatapathId oldDomain = topology.getOpenflowDomainId(oldSw);
boolean oldBD = topology.isBroadcastDomainPort(oldSw, oldPort);
DatapathId newSw = newAP.getSw();
OFPort newPort = newAP.getPort();
DatapathId newDomain = topology.getOpenflowDomainId(newSw);
boolean newBD = topology.isBroadcastDomainPort(newSw, newPort);
if (oldDomain.getLong() < newDomain.getLong()) return -1;
else if (oldDomain.getLong() > newDomain.getLong()) return 1;
// Give preference to LOCAL always
if (oldPort != OFPort.LOCAL &&
newPort == OFPort.LOCAL) {
return -1;
} else if (oldPort == OFPort.LOCAL &&
newPort != OFPort.LOCAL) {
return 1;
}
// We expect that the last seen of the new AP is higher than
// old AP, if it is not, just reverse and send the negative
// of the result.
if (oldAP.getLastSeen().after(newAP.getLastSeen())) //TODO should this be lastSeen? @Ryan did change this from activeSince
return -compare(newAP, oldAP);
long activeOffset = 0;
if (!topology.isConsistent(oldSw, oldPort, newSw, newPort)) {
if (!newBD && oldBD) {
return -1;
}
if (newBD && oldBD) {
activeOffset = AttachmentPoint.EXTERNAL_TO_EXTERNAL_TIMEOUT;
}
else if (newBD && !oldBD){
activeOffset = AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT;
}
} else {
// The attachment point is consistent.
activeOffset = AttachmentPoint.CONSISTENT_TIMEOUT;
}
if ((newAP.getActiveSince().getTime() > oldAP.getLastSeen().getTime() + activeOffset) ||
(newAP.getLastSeen().getTime() > oldAP.getLastSeen().getTime() +
AttachmentPoint.INACTIVITY_INTERVAL)) {
return -1;
}
return 1;
}
示例6: testLOCALAttachmentPointLearning
/**
* This test verifies that the learning behavior on OFPP_LOCAL ports.
* Once a host is learned on OFPP_LOCAL, it is allowed to move only from
* one OFPP_LOCAL to another OFPP_LOCAL port.
* @throws Exception
*/
@Test
public void testLOCALAttachmentPointLearning() throws Exception {
ITopologyService mockTopology = createMock(ITopologyService.class);
expect(mockTopology.getOpenflowDomainId(DatapathId.of(anyLong()))).
andReturn(DatapathId.of(1L)).anyTimes();
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(1))).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.LOCAL)).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(2))).
andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1),
DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.LOCAL,
DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2),
DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes();
Date topologyUpdateTime = new Date();
expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
anyTimes();
replay(mockTopology);
deviceManager.topology = mockTopology;
Calendar c = Calendar.getInstance();
Entity entity1 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.of(1), IPv6Address.NONE, DatapathId.of(1L), OFPort.of(1), c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
Entity entity2 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.LOCAL, c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT + 1);
Entity entity3 = new Entity(MacAddress.of(1L), VlanVid.ZERO, IPv4Address.NONE, IPv6Address.NONE, DatapathId.of(1L), OFPort.of(2), c.getTime());
IDevice d;
SwitchPort[] aps;
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);
// Ensure that the attachment point changes to OFPP_LOCAL
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
// Even though the new attachment point is consistent with old
// and the time has elapsed, OFPP_LOCAL attachment point should
// be maintained.
d = deviceManager.learnDeviceByEntity(entity3);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
}
示例7: compare
@Override
public int compare(AttachmentPoint oldAP, AttachmentPoint newAP) {
//First compare based on L2 domain ID;
DatapathId oldSw = oldAP.getSw();
OFPort oldPort = oldAP.getPort();
DatapathId oldDomain = topology.getL2DomainId(oldSw);
boolean oldBD = topology.isBroadcastDomainPort(oldSw, oldPort);
DatapathId newSw = newAP.getSw();
OFPort newPort = newAP.getPort();
DatapathId newDomain = topology.getL2DomainId(newSw);
boolean newBD = topology.isBroadcastDomainPort(newSw, newPort);
if (oldDomain.getLong() < newDomain.getLong()) return -1;
else if (oldDomain.getLong() > newDomain.getLong()) return 1;
// Give preference to LOCAL always
if (oldPort != OFPort.LOCAL &&
newPort == OFPort.LOCAL) {
return -1;
} else if (oldPort == OFPort.LOCAL &&
newPort != OFPort.LOCAL) {
return 1;
}
// We expect that the last seen of the new AP is higher than
// old AP, if it is not, just reverse and send the negative
// of the result.
if (oldAP.getActiveSince().after(newAP.getActiveSince()))
return -compare(newAP, oldAP);
long activeOffset = 0;
if (!topology.isConsistent(oldSw, oldPort, newSw, newPort)) {
if (!newBD && oldBD) {
return -1;
}
if (newBD && oldBD) {
activeOffset = AttachmentPoint.EXTERNAL_TO_EXTERNAL_TIMEOUT;
}
else if (newBD && !oldBD){
activeOffset = AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT;
}
} else {
// The attachment point is consistent.
activeOffset = AttachmentPoint.CONSISTENT_TIMEOUT;
}
if ((newAP.getActiveSince().getTime() > oldAP.getLastSeen().getTime() + activeOffset) ||
(newAP.getLastSeen().getTime() > oldAP.getLastSeen().getTime() +
AttachmentPoint.INACTIVITY_INTERVAL)) {
return -1;
}
return 1;
}
示例8: testLOCALAttachmentPointLearning
/**
* This test verifies that the learning behavior on OFPP_LOCAL ports.
* Once a host is learned on OFPP_LOCAL, it is allowed to move only from
* one OFPP_LOCAL to another OFPP_LOCAL port.
* @throws Exception
*/
@Test
public void testLOCALAttachmentPointLearning() throws Exception {
ITopologyService mockTopology = createMock(ITopologyService.class);
expect(mockTopology.getL2DomainId(DatapathId.of(anyLong()))).
andReturn(DatapathId.of(1L)).anyTimes();
expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()), OFPort.of(anyShort()))).
andReturn(true).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(1))).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.LOCAL)).
andReturn(false).anyTimes();
expect(mockTopology.isBroadcastDomainPort(DatapathId.of(1L), OFPort.of(2))).
andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(1),
DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.LOCAL,
DatapathId.of(1L), OFPort.of(2))).andReturn(true).anyTimes();
expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(1L), OFPort.of(2),
DatapathId.of(1L), OFPort.LOCAL)).andReturn(true).anyTimes();
expect(mockTopology.isConsistent(DatapathId.of(anyLong()), OFPort.of(anyShort()), DatapathId.of(anyLong()), OFPort.of(anyShort()))).andReturn(false).anyTimes();
Date topologyUpdateTime = new Date();
expect(mockTopology.getLastUpdateTime()).andReturn(topologyUpdateTime).
anyTimes();
replay(mockTopology);
deviceManager.topology = mockTopology;
Calendar c = Calendar.getInstance();
Entity entity1 = new Entity(MacAddress.of(1L), null, IPv4Address.of(1), DatapathId.of(1L), OFPort.of(1), c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT/ 2);
Entity entity2 = new Entity(MacAddress.of(1L), null, null, DatapathId.of(1L), OFPort.LOCAL, c.getTime());
c.add(Calendar.MILLISECOND,
(int)AttachmentPoint.OPENFLOW_TO_EXTERNAL_TIMEOUT + 1);
Entity entity3 = new Entity(MacAddress.of(1L), null, null, DatapathId.of(1L), OFPort.of(2), c.getTime());
IDevice d;
SwitchPort[] aps;
d = deviceManager.learnDeviceByEntity(entity1);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.of(1)) }, aps);
// Ensure that the attachment point changes to OFPP_LOCAL
d = deviceManager.learnDeviceByEntity(entity2);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
// Even though the new attachment point is consistent with old
// and the time has elapsed, OFPP_LOCAL attachment point should
// be maintained.
d = deviceManager.learnDeviceByEntity(entity3);
assertEquals(1, deviceManager.getAllDevices().size());
aps = d.getAttachmentPoints();
assertArrayEquals(new SwitchPort[] { new SwitchPort(DatapathId.of(1L), OFPort.LOCAL) }, aps);
}