本文整理汇总了Java中org.projectfloodlight.openflow.types.MacAddress.NONE属性的典型用法代码示例。如果您正苦于以下问题:Java MacAddress.NONE属性的具体用法?Java MacAddress.NONE怎么用?Java MacAddress.NONE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.projectfloodlight.openflow.types.MacAddress
的用法示例。
在下文中一共展示了MacAddress.NONE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FirewallRule
/**
* The default rule is to match on anything.
*/
public FirewallRule() {
this.dpid = DatapathId.NONE;
this.in_port = OFPort.ANY;
this.dl_src = MacAddress.NONE;
this.dl_dst = MacAddress.NONE;
this.dl_type = EthType.NONE;
this.nw_src_prefix_and_mask = IPv4AddressWithMask.NONE;
this.nw_dst_prefix_and_mask = IPv4AddressWithMask.NONE;
this.nw_proto = IpProtocol.NONE;
this.tp_src = TransportPort.NONE;
this.tp_dst = TransportPort.NONE;
this.any_dpid = true;
this.any_in_port = true;
this.any_dl_src = true;
this.any_dl_dst = true;
this.any_dl_type = true;
this.any_nw_src = true;
this.any_nw_dst = true;
this.any_nw_proto = true;
this.any_tp_src = true;
this.any_tp_dst = true;
this.priority = 0;
this.action = FirewallAction.ALLOW;
this.ruleid = 0;
}
示例2: processPacketInMessage
/**
* 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;
}
示例3: processPacketInMessage
/**
* 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;
}