Showing
7 changed files
with
267 additions
and
61 deletions
| ... | @@ -21,8 +21,6 @@ import org.onlab.onos.net.flow.FlowRule; | ... | @@ -21,8 +21,6 @@ import org.onlab.onos.net.flow.FlowRule; |
| 21 | import org.onlab.onos.net.flow.FlowRuleService; | 21 | import org.onlab.onos.net.flow.FlowRuleService; |
| 22 | import org.onlab.onos.net.flow.TrafficSelector; | 22 | import org.onlab.onos.net.flow.TrafficSelector; |
| 23 | import org.onlab.onos.net.flow.TrafficTreatment; | 23 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 24 | -import org.onlab.onos.net.flow.criteria.Criteria; | ||
| 25 | -import org.onlab.onos.net.flow.instructions.Instructions; | ||
| 26 | import org.onlab.onos.net.host.HostService; | 24 | import org.onlab.onos.net.host.HostService; |
| 27 | import org.onlab.onos.net.packet.InboundPacket; | 25 | import org.onlab.onos.net.packet.InboundPacket; |
| 28 | import org.onlab.onos.net.packet.PacketContext; | 26 | import org.onlab.onos.net.packet.PacketContext; |
| ... | @@ -153,7 +151,7 @@ public class ReactiveForwarding { | ... | @@ -153,7 +151,7 @@ public class ReactiveForwarding { |
| 153 | 151 | ||
| 154 | // Sends a packet out the specified port. | 152 | // Sends a packet out the specified port. |
| 155 | private void packetOut(PacketContext context, PortNumber portNumber) { | 153 | private void packetOut(PacketContext context, PortNumber portNumber) { |
| 156 | - context.treatmentBuilder().add(Instructions.createOutput(portNumber)); | 154 | + context.treatmentBuilder().setOutput(portNumber); |
| 157 | context.send(); | 155 | context.send(); |
| 158 | } | 156 | } |
| 159 | 157 | ||
| ... | @@ -165,13 +163,13 @@ public class ReactiveForwarding { | ... | @@ -165,13 +163,13 @@ public class ReactiveForwarding { |
| 165 | // Install the flow rule to handle this type of message from now on. | 163 | // Install the flow rule to handle this type of message from now on. |
| 166 | Ethernet inPkt = context.inPacket().parsed(); | 164 | Ethernet inPkt = context.inPacket().parsed(); |
| 167 | TrafficSelector.Builder builder = new DefaultTrafficSelector.Builder(); | 165 | TrafficSelector.Builder builder = new DefaultTrafficSelector.Builder(); |
| 168 | - builder.add(Criteria.matchEthType(inPkt.getEtherType())) | 166 | + builder.matchEthType(inPkt.getEtherType()) |
| 169 | - .add(Criteria.matchEthSrc(inPkt.getSourceMAC())) | 167 | + .matchEthSrc(inPkt.getSourceMAC()) |
| 170 | - .add(Criteria.matchEthDst(inPkt.getDestinationMAC())) | 168 | + .matchEthDst(inPkt.getDestinationMAC()) |
| 171 | - .add(Criteria.matchInPort(context.inPacket().receivedFrom().port())); | 169 | + .matchInport(context.inPacket().receivedFrom().port()); |
| 172 | 170 | ||
| 173 | TrafficTreatment.Builder treat = new DefaultTrafficTreatment.Builder(); | 171 | TrafficTreatment.Builder treat = new DefaultTrafficTreatment.Builder(); |
| 174 | - treat.add(Instructions.createOutput(portNumber)); | 172 | + treat.setOutput(portNumber); |
| 175 | 173 | ||
| 176 | FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), | 174 | FlowRule f = new DefaultFlowRule(context.inPacket().receivedFrom().deviceId(), |
| 177 | builder.build(), treat.build(), 0, appId); | 175 | builder.build(), treat.build(), 0, appId); | ... | ... |
| ... | @@ -6,7 +6,12 @@ import java.util.Collections; | ... | @@ -6,7 +6,12 @@ import java.util.Collections; |
| 6 | import java.util.LinkedList; | 6 | import java.util.LinkedList; |
| 7 | import java.util.List; | 7 | import java.util.List; |
| 8 | 8 | ||
| 9 | +import org.onlab.onos.net.PortNumber; | ||
| 10 | +import org.onlab.onos.net.flow.criteria.Criteria; | ||
| 9 | import org.onlab.onos.net.flow.criteria.Criterion; | 11 | import org.onlab.onos.net.flow.criteria.Criterion; |
| 12 | +import org.onlab.packet.IpPrefix; | ||
| 13 | +import org.onlab.packet.MacAddress; | ||
| 14 | +import org.onlab.packet.VlanId; | ||
| 10 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
| 11 | 16 | ||
| 12 | public final class DefaultTrafficSelector implements TrafficSelector { | 17 | public final class DefaultTrafficSelector implements TrafficSelector { |
| ... | @@ -29,11 +34,47 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -29,11 +34,47 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
| 29 | private final List<Criterion> selector = new LinkedList<>(); | 34 | private final List<Criterion> selector = new LinkedList<>(); |
| 30 | 35 | ||
| 31 | @Override | 36 | @Override |
| 32 | - public TrafficSelector.Builder add(Criterion criterion) { | 37 | + public Builder add(Criterion criterion) { |
| 33 | selector.add(criterion); | 38 | selector.add(criterion); |
| 34 | return this; | 39 | return this; |
| 35 | } | 40 | } |
| 36 | 41 | ||
| 42 | + public Builder matchInport(PortNumber port) { | ||
| 43 | + return add(Criteria.matchInPort(port)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public Builder matchEthSrc(MacAddress addr) { | ||
| 47 | + return add(Criteria.matchEthSrc(addr)); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public Builder matchEthDst(MacAddress addr) { | ||
| 51 | + return add(Criteria.matchEthDst(addr)); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public Builder matchEthType(short ethType) { | ||
| 55 | + return add(Criteria.matchEthType(ethType)); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public Builder matchVlanId(VlanId vlanId) { | ||
| 59 | + return add(Criteria.matchVlanId(vlanId)); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public Builder matchVlanPcp(Byte vlanPcp) { | ||
| 63 | + return add(Criteria.matchVlanPcp(vlanPcp)); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public Builder matchIPProtocol(Byte proto) { | ||
| 67 | + return add(Criteria.matchIPProtocol(proto)); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public Builder matchIPSrc(IpPrefix ip) { | ||
| 71 | + return add(Criteria.matchIPSrc(ip)); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + public Builder matchIPDst(IpPrefix ip) { | ||
| 75 | + return add(Criteria.matchIPDst(ip)); | ||
| 76 | + } | ||
| 77 | + | ||
| 37 | @Override | 78 | @Override |
| 38 | public TrafficSelector build() { | 79 | public TrafficSelector build() { |
| 39 | return new DefaultTrafficSelector(selector); | 80 | return new DefaultTrafficSelector(selector); | ... | ... |
| ... | @@ -6,7 +6,12 @@ import java.util.Collections; | ... | @@ -6,7 +6,12 @@ import java.util.Collections; |
| 6 | import java.util.LinkedList; | 6 | import java.util.LinkedList; |
| 7 | import java.util.List; | 7 | import java.util.List; |
| 8 | 8 | ||
| 9 | +import org.onlab.onos.net.PortNumber; | ||
| 9 | import org.onlab.onos.net.flow.instructions.Instruction; | 10 | import org.onlab.onos.net.flow.instructions.Instruction; |
| 11 | +import org.onlab.onos.net.flow.instructions.Instructions; | ||
| 12 | +import org.onlab.packet.IpPrefix; | ||
| 13 | +import org.onlab.packet.MacAddress; | ||
| 14 | +import org.onlab.packet.VlanId; | ||
| 10 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
| 11 | 16 | ||
| 12 | public final class DefaultTrafficTreatment implements TrafficTreatment { | 17 | public final class DefaultTrafficTreatment implements TrafficTreatment { |
| ... | @@ -42,9 +47,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -42,9 +47,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
| 42 | // TODO: should be a list of instructions based on modification objects | 47 | // TODO: should be a list of instructions based on modification objects |
| 43 | List<Instruction> modifications = new LinkedList<>(); | 48 | List<Instruction> modifications = new LinkedList<>(); |
| 44 | 49 | ||
| 45 | - | ||
| 46 | - @Override | ||
| 47 | public Builder add(Instruction instruction) { | 50 | public Builder add(Instruction instruction) { |
| 51 | + if (drop) { | ||
| 52 | + return this; | ||
| 53 | + } | ||
| 48 | switch (instruction.type()) { | 54 | switch (instruction.type()) { |
| 49 | case DROP: | 55 | case DROP: |
| 50 | drop = true; | 56 | drop = true; |
| ... | @@ -67,6 +73,46 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -67,6 +73,46 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
| 67 | } | 73 | } |
| 68 | 74 | ||
| 69 | @Override | 75 | @Override |
| 76 | + public void drop() { | ||
| 77 | + add(Instructions.createDrop()); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public Builder setOutput(PortNumber number) { | ||
| 82 | + return add(Instructions.createOutput(number)); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Override | ||
| 86 | + public Builder setEthSrc(MacAddress addr) { | ||
| 87 | + return add(Instructions.modL2Src(addr)); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @Override | ||
| 91 | + public Builder setEthDst(MacAddress addr) { | ||
| 92 | + return add(Instructions.modL2Dst(addr)); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @Override | ||
| 96 | + public Builder setVlanId(VlanId id) { | ||
| 97 | + return add(Instructions.modVlanId(id)); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + @Override | ||
| 101 | + public Builder setVlanPcp(Byte pcp) { | ||
| 102 | + return add(Instructions.modVlanPcp(pcp)); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + @Override | ||
| 106 | + public Builder setIpSrc(IpPrefix addr) { | ||
| 107 | + return add(Instructions.modL3Src(addr)); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @Override | ||
| 111 | + public Builder setIpDst(IpPrefix addr) { | ||
| 112 | + return add(Instructions.modL3Dst(addr)); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + @Override | ||
| 70 | public TrafficTreatment build() { | 116 | public TrafficTreatment build() { |
| 71 | 117 | ||
| 72 | //If we are dropping should we just return an emptry list? | 118 | //If we are dropping should we just return an emptry list? | ... | ... |
| ... | @@ -2,7 +2,11 @@ package org.onlab.onos.net.flow; | ... | @@ -2,7 +2,11 @@ package org.onlab.onos.net.flow; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | 4 | ||
| 5 | +import org.onlab.onos.net.PortNumber; | ||
| 5 | import org.onlab.onos.net.flow.criteria.Criterion; | 6 | import org.onlab.onos.net.flow.criteria.Criterion; |
| 7 | +import org.onlab.packet.IpPrefix; | ||
| 8 | +import org.onlab.packet.MacAddress; | ||
| 9 | +import org.onlab.packet.VlanId; | ||
| 6 | 10 | ||
| 7 | /** | 11 | /** |
| 8 | * Abstraction of a slice of network traffic. | 12 | * Abstraction of a slice of network traffic. |
| ... | @@ -31,6 +35,69 @@ public interface TrafficSelector { | ... | @@ -31,6 +35,69 @@ public interface TrafficSelector { |
| 31 | Builder add(Criterion criterion); | 35 | Builder add(Criterion criterion); |
| 32 | 36 | ||
| 33 | /** | 37 | /** |
| 38 | + * Matches an inport. | ||
| 39 | + * @param port the inport | ||
| 40 | + * @return a selection builder | ||
| 41 | + */ | ||
| 42 | + public Builder matchInport(PortNumber port); | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Matches a l2 src address. | ||
| 46 | + * @param addr a l2 address | ||
| 47 | + * @return a selection builder | ||
| 48 | + */ | ||
| 49 | + public Builder matchEthSrc(MacAddress addr); | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * Matches a l2 dst address. | ||
| 53 | + * @param addr a l2 address | ||
| 54 | + * @return a selection builder | ||
| 55 | + */ | ||
| 56 | + public Builder matchEthDst(MacAddress addr); | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * Matches the ethernet type. | ||
| 60 | + * @param ethType an ethernet type | ||
| 61 | + * @return a selection builder | ||
| 62 | + */ | ||
| 63 | + public Builder matchEthType(short ethType); | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * Matches the vlan id. | ||
| 67 | + * @param vlanId a vlan id | ||
| 68 | + * @return a selection builder | ||
| 69 | + */ | ||
| 70 | + public Builder matchVlanId(VlanId vlanId); | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * Matches a vlan priority. | ||
| 74 | + * @param vlanPcp a vlan priority | ||
| 75 | + * @return a selection builder | ||
| 76 | + */ | ||
| 77 | + public Builder matchVlanPcp(Byte vlanPcp); | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * Matches the l3 protocol. | ||
| 81 | + * @param proto a l3 protocol | ||
| 82 | + * @return a selection builder | ||
| 83 | + */ | ||
| 84 | + public Builder matchIPProtocol(Byte proto); | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * Matches a l3 address. | ||
| 88 | + * @param ip a l3 address | ||
| 89 | + * @return a selection builder | ||
| 90 | + */ | ||
| 91 | + public Builder matchIPSrc(IpPrefix ip); | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * Matches a l3 address. | ||
| 95 | + * @param ip a l3 address | ||
| 96 | + * @return a selection builder | ||
| 97 | + */ | ||
| 98 | + public Builder matchIPDst(IpPrefix ip); | ||
| 99 | + | ||
| 100 | + /** | ||
| 34 | * Builds an immutable traffic selector. | 101 | * Builds an immutable traffic selector. |
| 35 | * | 102 | * |
| 36 | * @return traffic selector | 103 | * @return traffic selector | ... | ... |
| ... | @@ -2,7 +2,11 @@ package org.onlab.onos.net.flow; | ... | @@ -2,7 +2,11 @@ package org.onlab.onos.net.flow; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | 4 | ||
| 5 | +import org.onlab.onos.net.PortNumber; | ||
| 5 | import org.onlab.onos.net.flow.instructions.Instruction; | 6 | import org.onlab.onos.net.flow.instructions.Instruction; |
| 7 | +import org.onlab.packet.IpPrefix; | ||
| 8 | +import org.onlab.packet.MacAddress; | ||
| 9 | +import org.onlab.packet.VlanId; | ||
| 6 | 10 | ||
| 7 | /** | 11 | /** |
| 8 | * Abstraction of network traffic treatment. | 12 | * Abstraction of network traffic treatment. |
| ... | @@ -22,14 +26,67 @@ public interface TrafficTreatment { | ... | @@ -22,14 +26,67 @@ public interface TrafficTreatment { |
| 22 | public interface Builder { | 26 | public interface Builder { |
| 23 | 27 | ||
| 24 | /** | 28 | /** |
| 25 | - * Adds a traffic treatment instruction. If a same type instruction has | 29 | + * Adds an instruction to the builder. |
| 26 | - * already been added, it will be replaced by this one. | 30 | + * @param instruction an instruction |
| 27 | - * | 31 | + * @return a treatment builder |
| 28 | - * @param instruction new instruction | ||
| 29 | */ | 32 | */ |
| 30 | Builder add(Instruction instruction); | 33 | Builder add(Instruction instruction); |
| 31 | 34 | ||
| 32 | /** | 35 | /** |
| 36 | + * Adds a drop instruction and does not return a builder. | ||
| 37 | + */ | ||
| 38 | + public void drop(); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * Set the output port. | ||
| 42 | + * @param number the out port | ||
| 43 | + * @return a treatment builder | ||
| 44 | + */ | ||
| 45 | + public Builder setOutput(PortNumber number); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * Sets the src l2 address. | ||
| 49 | + * @param addr a macaddress | ||
| 50 | + * @return a treatment builder | ||
| 51 | + */ | ||
| 52 | + public Builder setEthSrc(MacAddress addr); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Sets the dst l2 address. | ||
| 56 | + * @param addr a macaddress | ||
| 57 | + * @return a treatment builder | ||
| 58 | + */ | ||
| 59 | + public Builder setEthDst(MacAddress addr); | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * Sets the vlan id. | ||
| 63 | + * @param id a vlanid | ||
| 64 | + * @return a treatment builder | ||
| 65 | + */ | ||
| 66 | + public Builder setVlanId(VlanId id); | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * Sets the vlan priority. | ||
| 70 | + * @param pcp a vlan priority | ||
| 71 | + * @return a treatment builder | ||
| 72 | + */ | ||
| 73 | + public Builder setVlanPcp(Byte pcp); | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * Sets the src l3 address. | ||
| 77 | + * @param addr an ip | ||
| 78 | + * @return a treatment builder | ||
| 79 | + */ | ||
| 80 | + public Builder setIpSrc(IpPrefix addr); | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * Sets the dst l3 address. | ||
| 84 | + * @param addr an ip | ||
| 85 | + * @return a treatment builder | ||
| 86 | + */ | ||
| 87 | + public Builder setIpDst(IpPrefix addr); | ||
| 88 | + | ||
| 89 | + /** | ||
| 33 | * Builds an immutable traffic treatment descriptor. | 90 | * Builds an immutable traffic treatment descriptor. |
| 34 | * | 91 | * |
| 35 | * @return traffic treatment | 92 | * @return traffic treatment | ... | ... |
| ... | @@ -65,12 +65,12 @@ public class HostMonitor implements TimerTask { | ... | @@ -65,12 +65,12 @@ public class HostMonitor implements TimerTask { |
| 65 | 65 | ||
| 66 | private final long probeRate; | 66 | private final long probeRate; |
| 67 | 67 | ||
| 68 | - private Timeout timeout; | 68 | + private final Timeout timeout; |
| 69 | 69 | ||
| 70 | public HostMonitor(HostService hostService, TopologyService topologyService, | 70 | public HostMonitor(HostService hostService, TopologyService topologyService, |
| 71 | - DeviceService deviceService, | 71 | + DeviceService deviceService, |
| 72 | - HostProvider hostProvider, PacketService packetService, | 72 | + HostProvider hostProvider, PacketService packetService, |
| 73 | - HostStore hostStore) { | 73 | + HostStore hostStore) { |
| 74 | this.hostService = hostService; | 74 | this.hostService = hostService; |
| 75 | this.topologyService = topologyService; | 75 | this.topologyService = topologyService; |
| 76 | this.deviceService = deviceService; | 76 | this.deviceService = deviceService; |
| ... | @@ -147,10 +147,9 @@ public class HostMonitor implements TimerTask { | ... | @@ -147,10 +147,9 @@ public class HostMonitor implements TimerTask { |
| 147 | List<Instruction> instructions = new ArrayList<>(); | 147 | List<Instruction> instructions = new ArrayList<>(); |
| 148 | instructions.add(Instructions.createOutput(port.number())); | 148 | instructions.add(Instructions.createOutput(port.number())); |
| 149 | 149 | ||
| 150 | - TrafficTreatment treatment = | 150 | + TrafficTreatment treatment = new DefaultTrafficTreatment.Builder() |
| 151 | - new DefaultTrafficTreatment.Builder() | 151 | + .setOutput(port.number()) |
| 152 | - .add(Instructions.createOutput(port.number())) | 152 | + .build(); |
| 153 | - .build(); | ||
| 154 | 153 | ||
| 155 | OutboundPacket outboundPacket = | 154 | OutboundPacket outboundPacket = |
| 156 | new DefaultOutboundPacket(deviceId, treatment, | 155 | new DefaultOutboundPacket(deviceId, treatment, |
| ... | @@ -163,9 +162,9 @@ public class HostMonitor implements TimerTask { | ... | @@ -163,9 +162,9 @@ public class HostMonitor implements TimerTask { |
| 163 | 162 | ||
| 164 | ARP arp = new ARP(); | 163 | ARP arp = new ARP(); |
| 165 | arp.setHardwareType(ARP.HW_TYPE_ETHERNET) | 164 | arp.setHardwareType(ARP.HW_TYPE_ETHERNET) |
| 166 | - .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH) | 165 | + .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH) |
| 167 | - .setProtocolType(ARP.PROTO_TYPE_IP) | 166 | + .setProtocolType(ARP.PROTO_TYPE_IP) |
| 168 | - .setProtocolAddressLength((byte) IpPrefix.INET_LEN); | 167 | + .setProtocolAddressLength((byte) IpPrefix.INET_LEN); |
| 169 | 168 | ||
| 170 | byte[] sourceMacAddress; | 169 | byte[] sourceMacAddress; |
| 171 | if (portAddresses.mac() == null) { | 170 | if (portAddresses.mac() == null) { |
| ... | @@ -175,15 +174,15 @@ public class HostMonitor implements TimerTask { | ... | @@ -175,15 +174,15 @@ public class HostMonitor implements TimerTask { |
| 175 | } | 174 | } |
| 176 | 175 | ||
| 177 | arp.setSenderHardwareAddress(sourceMacAddress) | 176 | arp.setSenderHardwareAddress(sourceMacAddress) |
| 178 | - //TODO .setSenderProtocolAddress(portAddresses.ips().toOctets()) | 177 | + //TODO .setSenderProtocolAddress(portAddresses.ips().toOctets()) |
| 179 | - .setTargetHardwareAddress(ZERO_MAC_ADDRESS) | 178 | + .setTargetHardwareAddress(ZERO_MAC_ADDRESS) |
| 180 | - .setTargetProtocolAddress(targetIp.toOctets()); | 179 | + .setTargetProtocolAddress(targetIp.toOctets()); |
| 181 | 180 | ||
| 182 | Ethernet ethernet = new Ethernet(); | 181 | Ethernet ethernet = new Ethernet(); |
| 183 | ethernet.setEtherType(Ethernet.TYPE_ARP) | 182 | ethernet.setEtherType(Ethernet.TYPE_ARP) |
| 184 | - .setDestinationMACAddress(BROADCAST_MAC) | 183 | + .setDestinationMACAddress(BROADCAST_MAC) |
| 185 | - .setSourceMACAddress(sourceMacAddress) | 184 | + .setSourceMACAddress(sourceMacAddress) |
| 186 | - .setPayload(arp); | 185 | + .setPayload(arp); |
| 187 | 186 | ||
| 188 | return ethernet; | 187 | return ethernet; |
| 189 | } | 188 | } | ... | ... |
| ... | @@ -13,8 +13,6 @@ import org.onlab.onos.net.flow.FlowRule; | ... | @@ -13,8 +13,6 @@ import org.onlab.onos.net.flow.FlowRule; |
| 13 | import org.onlab.onos.net.flow.FlowRule.FlowRuleState; | 13 | import org.onlab.onos.net.flow.FlowRule.FlowRuleState; |
| 14 | import org.onlab.onos.net.flow.TrafficSelector; | 14 | import org.onlab.onos.net.flow.TrafficSelector; |
| 15 | import org.onlab.onos.net.flow.TrafficTreatment; | 15 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 16 | -import org.onlab.onos.net.flow.criteria.Criteria; | ||
| 17 | -import org.onlab.onos.net.flow.instructions.Instructions; | ||
| 18 | import org.onlab.onos.openflow.controller.Dpid; | 16 | import org.onlab.onos.openflow.controller.Dpid; |
| 19 | import org.onlab.packet.IpPrefix; | 17 | import org.onlab.packet.IpPrefix; |
| 20 | import org.onlab.packet.MacAddress; | 18 | import org.onlab.packet.MacAddress; |
| ... | @@ -88,53 +86,53 @@ public class FlowRuleBuilder { | ... | @@ -88,53 +86,53 @@ public class FlowRuleBuilder { |
| 88 | TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder(); | 86 | TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder(); |
| 89 | // If this is a drop rule | 87 | // If this is a drop rule |
| 90 | if (actions.size() == 0) { | 88 | if (actions.size() == 0) { |
| 91 | - builder.add(Instructions.createDrop()); | 89 | + builder.drop(); |
| 92 | return builder.build(); | 90 | return builder.build(); |
| 93 | } | 91 | } |
| 94 | for (OFAction act : actions) { | 92 | for (OFAction act : actions) { |
| 95 | switch (act.getType()) { | 93 | switch (act.getType()) { |
| 96 | case OUTPUT: | 94 | case OUTPUT: |
| 97 | OFActionOutput out = (OFActionOutput) act; | 95 | OFActionOutput out = (OFActionOutput) act; |
| 98 | - builder.add(Instructions.createOutput( | 96 | + builder.setOutput( |
| 99 | - PortNumber.portNumber(out.getPort().getPortNumber()))); | 97 | + PortNumber.portNumber(out.getPort().getPortNumber())); |
| 100 | break; | 98 | break; |
| 101 | - case SET_VLAN_PCP: | 99 | + case SET_VLAN_VID: |
| 102 | OFActionSetVlanVid vlan = (OFActionSetVlanVid) act; | 100 | OFActionSetVlanVid vlan = (OFActionSetVlanVid) act; |
| 103 | - builder.add(Instructions.modVlanId(VlanId.vlanId(vlan.getVlanVid().getVlan()))); | 101 | + builder.setVlanId(VlanId.vlanId(vlan.getVlanVid().getVlan())); |
| 104 | break; | 102 | break; |
| 105 | - case SET_VLAN_VID: | 103 | + case SET_VLAN_PCP: |
| 106 | OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act; | 104 | OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act; |
| 107 | - builder.add(Instructions.modVlanId(VlanId.vlanId(pcp.getVlanPcp().getValue()))); | 105 | + builder.setVlanId(VlanId.vlanId(pcp.getVlanPcp().getValue())); |
| 108 | break; | 106 | break; |
| 109 | case SET_DL_DST: | 107 | case SET_DL_DST: |
| 110 | OFActionSetDlDst dldst = (OFActionSetDlDst) act; | 108 | OFActionSetDlDst dldst = (OFActionSetDlDst) act; |
| 111 | - builder.add(Instructions.modL2Dst( | 109 | + builder.setEthDst( |
| 112 | - MacAddress.valueOf(dldst.getDlAddr().getLong()))); | 110 | + MacAddress.valueOf(dldst.getDlAddr().getLong())); |
| 113 | break; | 111 | break; |
| 114 | case SET_DL_SRC: | 112 | case SET_DL_SRC: |
| 115 | OFActionSetDlSrc dlsrc = (OFActionSetDlSrc) act; | 113 | OFActionSetDlSrc dlsrc = (OFActionSetDlSrc) act; |
| 116 | - builder.add(Instructions.modL2Src( | 114 | + builder.setEthSrc( |
| 117 | - MacAddress.valueOf(dlsrc.getDlAddr().getLong()))); | 115 | + MacAddress.valueOf(dlsrc.getDlAddr().getLong())); |
| 118 | 116 | ||
| 119 | break; | 117 | break; |
| 120 | case SET_NW_DST: | 118 | case SET_NW_DST: |
| 121 | OFActionSetNwDst nwdst = (OFActionSetNwDst) act; | 119 | OFActionSetNwDst nwdst = (OFActionSetNwDst) act; |
| 122 | IPv4Address di = nwdst.getNwAddr(); | 120 | IPv4Address di = nwdst.getNwAddr(); |
| 123 | if (di.isCidrMask()) { | 121 | if (di.isCidrMask()) { |
| 124 | - builder.add(Instructions.modL3Dst(IpPrefix.valueOf(di.getInt(), | 122 | + builder.setIpDst(IpPrefix.valueOf(di.getInt(), |
| 125 | - di.asCidrMaskLength()))); | 123 | + di.asCidrMaskLength())); |
| 126 | } else { | 124 | } else { |
| 127 | - builder.add(Instructions.modL3Dst(IpPrefix.valueOf(di.getInt()))); | 125 | + builder.setIpDst(IpPrefix.valueOf(di.getInt())); |
| 128 | } | 126 | } |
| 129 | break; | 127 | break; |
| 130 | case SET_NW_SRC: | 128 | case SET_NW_SRC: |
| 131 | OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act; | 129 | OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act; |
| 132 | IPv4Address si = nwsrc.getNwAddr(); | 130 | IPv4Address si = nwsrc.getNwAddr(); |
| 133 | if (si.isCidrMask()) { | 131 | if (si.isCidrMask()) { |
| 134 | - builder.add(Instructions.modL3Dst(IpPrefix.valueOf(si.getInt(), | 132 | + builder.setIpSrc(IpPrefix.valueOf(si.getInt(), |
| 135 | - si.asCidrMaskLength()))); | 133 | + si.asCidrMaskLength())); |
| 136 | } else { | 134 | } else { |
| 137 | - builder.add(Instructions.modL3Dst(IpPrefix.valueOf(si.getInt()))); | 135 | + builder.setIpSrc(IpPrefix.valueOf(si.getInt())); |
| 138 | } | 136 | } |
| 139 | break; | 137 | break; |
| 140 | case SET_TP_DST: | 138 | case SET_TP_DST: |
| ... | @@ -174,20 +172,20 @@ public class FlowRuleBuilder { | ... | @@ -174,20 +172,20 @@ public class FlowRuleBuilder { |
| 174 | for (MatchField<?> field : match.getMatchFields()) { | 172 | for (MatchField<?> field : match.getMatchFields()) { |
| 175 | switch (field.id) { | 173 | switch (field.id) { |
| 176 | case IN_PORT: | 174 | case IN_PORT: |
| 177 | - builder.add(Criteria.matchInPort(PortNumber | 175 | + builder.matchInport(PortNumber |
| 178 | - .portNumber(match.get(MatchField.IN_PORT).getPortNumber()))); | 176 | + .portNumber(match.get(MatchField.IN_PORT).getPortNumber())); |
| 179 | break; | 177 | break; |
| 180 | case ETH_SRC: | 178 | case ETH_SRC: |
| 181 | MacAddress sMac = MacAddress.valueOf(match.get(MatchField.ETH_SRC).getLong()); | 179 | MacAddress sMac = MacAddress.valueOf(match.get(MatchField.ETH_SRC).getLong()); |
| 182 | - builder.add(Criteria.matchEthSrc(sMac)); | 180 | + builder.matchEthSrc(sMac); |
| 183 | break; | 181 | break; |
| 184 | case ETH_DST: | 182 | case ETH_DST: |
| 185 | MacAddress dMac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong()); | 183 | MacAddress dMac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong()); |
| 186 | - builder.add(Criteria.matchEthDst(dMac)); | 184 | + builder.matchEthDst(dMac); |
| 187 | break; | 185 | break; |
| 188 | case ETH_TYPE: | 186 | case ETH_TYPE: |
| 189 | int ethType = match.get(MatchField.ETH_TYPE).getValue(); | 187 | int ethType = match.get(MatchField.ETH_TYPE).getValue(); |
| 190 | - builder.add(Criteria.matchEthType((short) ethType)); | 188 | + builder.matchEthType((short) ethType); |
| 191 | break; | 189 | break; |
| 192 | case IPV4_DST: | 190 | case IPV4_DST: |
| 193 | IPv4Address di = match.get(MatchField.IPV4_DST); | 191 | IPv4Address di = match.get(MatchField.IPV4_DST); |
| ... | @@ -197,7 +195,7 @@ public class FlowRuleBuilder { | ... | @@ -197,7 +195,7 @@ public class FlowRuleBuilder { |
| 197 | } else { | 195 | } else { |
| 198 | dip = IpPrefix.valueOf(di.getInt()); | 196 | dip = IpPrefix.valueOf(di.getInt()); |
| 199 | } | 197 | } |
| 200 | - builder.add(Criteria.matchIPDst(dip)); | 198 | + builder.matchIPDst(dip); |
| 201 | break; | 199 | break; |
| 202 | case IPV4_SRC: | 200 | case IPV4_SRC: |
| 203 | IPv4Address si = match.get(MatchField.IPV4_SRC); | 201 | IPv4Address si = match.get(MatchField.IPV4_SRC); |
| ... | @@ -207,19 +205,19 @@ public class FlowRuleBuilder { | ... | @@ -207,19 +205,19 @@ public class FlowRuleBuilder { |
| 207 | } else { | 205 | } else { |
| 208 | sip = IpPrefix.valueOf(si.getInt()); | 206 | sip = IpPrefix.valueOf(si.getInt()); |
| 209 | } | 207 | } |
| 210 | - builder.add(Criteria.matchIPSrc(sip)); | 208 | + builder.matchIPSrc(sip); |
| 211 | break; | 209 | break; |
| 212 | case IP_PROTO: | 210 | case IP_PROTO: |
| 213 | short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber(); | 211 | short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber(); |
| 214 | - builder.add(Criteria.matchIPProtocol((byte) proto)); | 212 | + builder.matchIPProtocol((byte) proto); |
| 215 | break; | 213 | break; |
| 216 | case VLAN_PCP: | 214 | case VLAN_PCP: |
| 217 | byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue(); | 215 | byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue(); |
| 218 | - builder.add(Criteria.matchVlanPcp(vlanPcp)); | 216 | + builder.matchVlanPcp(vlanPcp); |
| 219 | break; | 217 | break; |
| 220 | case VLAN_VID: | 218 | case VLAN_VID: |
| 221 | VlanId vlanId = VlanId.vlanId(match.get(MatchField.VLAN_VID).getVlan()); | 219 | VlanId vlanId = VlanId.vlanId(match.get(MatchField.VLAN_VID).getVlan()); |
| 222 | - builder.add(Criteria.matchVlanId(vlanId)); | 220 | + builder.matchVlanId(vlanId); |
| 223 | break; | 221 | break; |
| 224 | case ARP_OP: | 222 | case ARP_OP: |
| 225 | case ARP_SHA: | 223 | case ARP_SHA: | ... | ... |
-
Please register or login to post a comment