本文整理汇总了Java中org.projectfloodlight.openflow.types.OFPort.equals方法的典型用法代码示例。如果您正苦于以下问题:Java OFPort.equals方法的具体用法?Java OFPort.equals怎么用?Java OFPort.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.projectfloodlight.openflow.types.OFPort
的用法示例。
在下文中一共展示了OFPort.equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyDevice
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
/**
* Verify that the given device exactly matches the given fields. E.g.,
* if ip is not null we expect the device to have exactly one IP address.
* swId and port are the attachment point port.
* Vlan and ip are optional all other fields must be specified.
* @return
*/
private static void verifyDevice(IDevice d, MacAddress mac, VlanVid vlan, IPv4Address ipv4,
IPv6Address ipv6, DatapathId swId, OFPort port) {
assertNotNull(d);
if (!mac.equals(MacAddress.NONE)) {
assertEquals(mac, d.getMACAddress());
}
if (vlan != null) {
assertArrayEquals(new VlanVid[] { vlan }, d.getVlanId());
}
if (!ipv4.equals(IPv4Address.NONE)) {
assertArrayEquals(new IPv4Address[] { ipv4 }, d.getIPv4Addresses());
}
if (!ipv6.equals(IPv6Address.NONE)) {
assertArrayEquals(new IPv6Address[] { ipv6 }, d.getIPv6Addresses());
}
if (!swId.equals(DatapathId.NONE) && !port.equals(OFPort.ZERO)) {
SwitchPort expectedAp = new SwitchPort(swId, port);
assertArrayEquals(new SwitchPort[] { expectedAp }, d.getAttachmentPoints());
}
}
示例2: getEntityKeys
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
private EnumSet<DeviceField> getEntityKeys(@Nonnull MacAddress macAddress,
VlanVid vlan, /* A null VLAN means 'don't care'; VlanVid.ZERO means 'untagged' */
@Nonnull IPv4Address ipv4Address,
@Nonnull IPv6Address ipv6Address,
@Nonnull DatapathId switchDPID,
@Nonnull OFPort switchPort) {
EnumSet<DeviceField> keys = EnumSet.noneOf(DeviceField.class);
if (!macAddress.equals(MacAddress.NONE)) keys.add(DeviceField.MAC);
if (vlan != null) keys.add(DeviceField.VLAN); /* TODO verify fix. null means 'don't care' and will conduct full search; VlanVid.ZERO means 'untagged' and only uses untagged index */
if (!ipv4Address.equals(IPv4Address.NONE)) keys.add(DeviceField.IPv4);
if (!ipv6Address.equals(IPv6Address.NONE)) keys.add(DeviceField.IPv6);
if (!switchDPID.equals(DatapathId.NONE)) keys.add(DeviceField.SWITCH);
if (!switchPort.equals(OFPort.ZERO)) keys.add(DeviceField.PORT);
return keys;
}
示例3: doFlood
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的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
*/
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));
// Set Action to flood
OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
List<OFAction> actions = new ArrayList<OFAction>();
Set<OFPort> broadcastPorts = this.topologyService.getSwitchBroadcastPorts(sw.getId());
if (broadcastPorts == null) {
log.debug("BroadcastPorts returned null. Assuming single switch w/no links.");
/* Must be a single-switch w/no links */
broadcastPorts = Collections.singleton(OFPort.FLOOD);
}
for (OFPort p : broadcastPorts) {
if (p.equals(inPort)) continue;
actions.add(sw.getOFFactory().actions().output(p, Integer.MAX_VALUE));
}
pob.setActions(actions);
// log.info("actions {}",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;
}
示例4: pushPacket
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
/**
* Pushes a packet-out to a switch. The assumption here is that
* the packet-in was also generated from the same switch. Thus, if the input
* port of the packet-in and the outport are the same, the function will not
* push the packet-out.
* @param sw switch that generated the packet-in, and from which packet-out is sent
* @param match OFmatch
* @param pi packet-in
* @param outport output port
*/
private void pushPacket(IOFSwitch sw, Match match, OFPacketIn pi, OFPort outport) {
if (pi == null) {
return;
}
OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
// The assumption here is (sw) is the switch that generated the
// packet-in. If the input port is the same as output port, then
// the packet-out should be ignored.
if (inPort.equals(outport)) {
if (log.isDebugEnabled()) {
log.debug("Attempting to do packet-out to the same " +
"interface as packet-in. Dropping packet. " +
" SrcSwitch={}, match = {}, pi={}",
new Object[]{sw, match, pi});
return;
}
}
if (log.isTraceEnabled()) {
log.trace("PacketOut srcSwitch={} match={} pi={}",
new Object[] {sw, match, pi});
}
OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
// set actions
List<OFAction> actions = new ArrayList<OFAction>();
actions.add(sw.getOFFactory().actions().buildOutput().setPort(outport).setMaxLen(0xffFFffFF).build());
pob.setActions(actions);
// If the switch doens't support buffering set the buffer id to be none
// otherwise it'll be the the buffer id of the PacketIn
if (sw.getBuffers() == 0) {
// We set the PI buffer id here so we don't have to check again below
pi = pi.createBuilder().setBufferId(OFBufferId.NO_BUFFER).build();
pob.setBufferId(OFBufferId.NO_BUFFER);
} else {
pob.setBufferId(pi.getBufferId());
}
pob.setInPort(inPort);
// If the buffer id is none or the switch doesn's support buffering
// we send the data with the packet out
if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
byte[] packetData = pi.getData();
pob.setData(packetData);
}
counterPacketOut.increment();
sw.write(pob.build());
}
示例5: processPacketInMessage
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
/**
* Processes a OFPacketIn message. If the switch has learned the MAC/VLAN to port mapping
* for the pair it will write a FlowMod for. If the mapping has not been learned the
* we will flood the packet.
* @param sw
* @param pi
* @param cntx
* @return
*/
private Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
/* Read packet header attributes into Match */
Match m = createMatchFromPacket(sw, inPort, cntx);
MacAddress sourceMac = m.get(MatchField.ETH_SRC);
MacAddress destMac = m.get(MatchField.ETH_DST);
VlanVid vlan = m.get(MatchField.VLAN_VID) == null ? VlanVid.ZERO : m.get(MatchField.VLAN_VID).getVlanVid();
if (sourceMac == null) {
sourceMac = MacAddress.NONE;
}
if (destMac == null) {
destMac = MacAddress.NONE;
}
if (vlan == null) {
vlan = VlanVid.ZERO;
}
if ((destMac.getLong() & 0xfffffffffff0L) == 0x0180c2000000L) {
if (log.isTraceEnabled()) {
log.trace("ignoring packet addressed to 802.1D/Q reserved addr: switch {} vlan {} dest MAC {}",
new Object[]{ sw, vlan, destMac.toString() });
}
return Command.STOP;
}
if ((sourceMac.getLong() & 0x010000000000L) == 0) {
// If source MAC is a unicast address, learn the port for this MAC/VLAN
this.addToPortMap(sw, sourceMac, vlan, inPort);
}
// Now output flow-mod and/or packet
OFPort outPort = getFromPortMap(sw, destMac, vlan);
if (outPort == null) {
// If we haven't learned the port for the dest MAC/VLAN, flood it
// Don't flood broadcast packets if the broadcast is disabled.
// XXX For LearningSwitch this doesn't do much. The sourceMac is removed
// from port map whenever a flow expires, so you would still see
// a lot of floods.
this.writePacketOutForPacketIn(sw, pi, OFPort.FLOOD);
} else if (outPort.equals(inPort)) {
log.trace("ignoring packet that arrived on same port as learned destination:"
+ " switch {} vlan {} dest MAC {} port {}",
new Object[]{ sw, vlan, destMac.toString(), outPort.getPortNumber() });
} else {
// Add flow table entry matching source MAC, dest MAC, VLAN and input port
// that sends to the port we previously learned for the dest MAC/VLAN. Also
// add a flow table entry with source and destination MACs reversed, and
// input and output ports reversed. When either entry expires due to idle
// timeout, remove the other one. This ensures that if a device moves to
// a different port, a constant stream of packets headed to the device at
// its former location does not keep the stale entry alive forever.
// FIXME: current HP switches ignore DL_SRC and DL_DST fields, so we have to match on
// NW_SRC and NW_DST as well
// We write FlowMods with Buffer ID none then explicitly PacketOut the buffered packet
this.pushPacket(sw, m, pi, outPort);
this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, m, outPort);
if (LEARNING_SWITCH_REVERSE_FLOW) {
Match.Builder mb = m.createBuilder();
mb.setExact(MatchField.ETH_SRC, m.get(MatchField.ETH_DST))
.setExact(MatchField.ETH_DST, m.get(MatchField.ETH_SRC))
.setExact(MatchField.IN_PORT, outPort);
if (m.get(MatchField.VLAN_VID) != null) {
mb.setExact(MatchField.VLAN_VID, m.get(MatchField.VLAN_VID));
}
this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb.build(), inPort);
}
}
return Command.CONTINUE;
}
示例6: isConsistent
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
public boolean isConsistent(DatapathId oldSw, OFPort oldPort, DatapathId newSw, OFPort newPort) {
if (isInternalToOpenflowDomain(newSw, newPort)) return true;
return (oldSw.equals(newSw) && oldPort.equals(newPort));
}
示例7: processPacketInMessage
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
/**
* Processes a OFPacketIn message. If the switch has learned the MAC/VLAN to port mapping
* for the pair it will write a FlowMod for. If the mapping has not been learned the
* we will flood the packet.
* @param sw
* @param pi
* @param cntx
* @return
*/
private Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));
/* Read packet header attributes into Match */
Match m = createMatchFromPacket(sw, inPort, cntx);
MacAddress sourceMac = m.get(MatchField.ETH_SRC);
MacAddress destMac = m.get(MatchField.ETH_DST);
VlanVid vlan = m.get(MatchField.VLAN_VID) == null ? VlanVid.ZERO : m.get(MatchField.VLAN_VID).getVlanVid();
if (sourceMac == null) {
sourceMac = MacAddress.NONE;
}
if (destMac == null) {
destMac = MacAddress.NONE;
}
if (vlan == null) {
vlan = VlanVid.ZERO;
}
if ((destMac.getLong() & 0xfffffffffff0L) == 0x0180c2000000L) {
if (log.isTraceEnabled()) {
log.trace("ignoring packet addressed to 802.1D/Q reserved addr: switch {} vlan {} dest MAC {}",
new Object[]{ sw, vlan, destMac.toString() });
}
return Command.STOP;
}
if ((sourceMac.getLong() & 0x010000000000L) == 0) {
// If source MAC is a unicast address, learn the port for this MAC/VLAN
this.addToPortMap(sw, sourceMac, vlan, inPort);
}
// Now output flow-mod and/or packet
OFPort outPort = getFromPortMap(sw, destMac, vlan);
if (outPort == null) {
// If we haven't learned the port for the dest MAC/VLAN, flood it
// Don't flood broadcast packets if the broadcast is disabled.
// XXX For LearningSwitch this doesn't do much. The sourceMac is removed
// from port map whenever a flow expires, so you would still see
// a lot of floods.
this.writePacketOutForPacketIn(sw, pi, OFPort.FLOOD);
} else if (outPort.equals(inPort)) {
log.trace("ignoring packet that arrived on same port as learned destination:"
+ " switch {} vlan {} dest MAC {} port {}",
new Object[]{ sw, vlan, destMac.toString(), outPort.getPortNumber() });
} else {
// Add flow table entry matching source MAC, dest MAC, VLAN and input port
// that sends to the port we previously learned for the dest MAC/VLAN. Also
// add a flow table entry with source and destination MACs reversed, and
// input and output ports reversed. When either entry expires due to idle
// timeout, remove the other one. This ensures that if a device moves to
// a different port, a constant stream of packets headed to the device at
// its former location does not keep the stale entry alive forever.
// FIXME: current HP switches ignore DL_SRC and DL_DST fields, so we have to match on
// NW_SRC and NW_DST as well
// We write FlowMods with Buffer ID none then explicitly PacketOut the buffered packet
this.pushPacket(sw, m, pi, outPort);
this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, m, outPort);
if (LEARNING_SWITCH_REVERSE_FLOW) {
Match.Builder mb = m.createBuilder();
mb.setExact(MatchField.ETH_SRC, m.get(MatchField.ETH_DST))
.setExact(MatchField.ETH_DST, m.get(MatchField.ETH_SRC))
.setExact(MatchField.IN_PORT, outPort);
if (m.get(MatchField.VLAN_VID) != null) {
mb.setExact(MatchField.VLAN_VID, m.get(MatchField.VLAN_VID));
}
this.writeFlowMod(sw, OFFlowModCommand.ADD, OFBufferId.NO_BUFFER, mb.build(), inPort);
}
}
return Command.CONTINUE;
}
示例8: isConsistent
import org.projectfloodlight.openflow.types.OFPort; //导入方法依赖的package包/类
public boolean isConsistent(DatapathId oldSw, OFPort oldPort, DatapathId newSw,
OFPort newPort) {
if (isInternalToOpenflowDomain(newSw, newPort)) return true;
return (oldSw.equals(newSw) && oldPort.equals(newPort));
}