Showing
13 changed files
with
380 additions
and
7 deletions
| 1 | +package org.onlab.onos.optical.testapp; | ||
| 2 | + | ||
| 3 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 4 | + | ||
| 5 | +import java.util.HashMap; | ||
| 6 | +import java.util.Map; | ||
| 7 | + | ||
| 8 | +import org.apache.felix.scr.annotations.Activate; | ||
| 9 | +import org.apache.felix.scr.annotations.Component; | ||
| 10 | +import org.apache.felix.scr.annotations.Deactivate; | ||
| 11 | +import org.apache.felix.scr.annotations.Reference; | ||
| 12 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 13 | +import org.onlab.onos.ApplicationId; | ||
| 14 | +import org.onlab.onos.CoreService; | ||
| 15 | +import org.onlab.onos.net.Device; | ||
| 16 | +import org.onlab.onos.net.DeviceId; | ||
| 17 | +import org.onlab.onos.net.PortNumber; | ||
| 18 | +import org.onlab.onos.net.device.DeviceEvent; | ||
| 19 | +import org.onlab.onos.net.device.DeviceListener; | ||
| 20 | +import org.onlab.onos.net.device.DeviceService; | ||
| 21 | +import org.onlab.onos.net.flow.DefaultFlowRule; | ||
| 22 | +import org.onlab.onos.net.flow.DefaultTrafficSelector; | ||
| 23 | +import org.onlab.onos.net.flow.DefaultTrafficTreatment; | ||
| 24 | +import org.onlab.onos.net.flow.FlowRule; | ||
| 25 | +import org.onlab.onos.net.flow.FlowRuleService; | ||
| 26 | +import org.onlab.onos.net.flow.TrafficSelector; | ||
| 27 | +import org.onlab.onos.net.flow.TrafficTreatment; | ||
| 28 | +import org.slf4j.Logger; | ||
| 29 | + | ||
| 30 | +/** | ||
| 31 | + * Sample reactive forwarding application. | ||
| 32 | + */ | ||
| 33 | +@Component(immediate = true) | ||
| 34 | +public class LambdaForwarding { | ||
| 35 | + | ||
| 36 | + private final Logger log = getLogger(getClass()); | ||
| 37 | + | ||
| 38 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 39 | + protected FlowRuleService flowRuleService; | ||
| 40 | + | ||
| 41 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 42 | + protected CoreService coreService; | ||
| 43 | + | ||
| 44 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 45 | + protected DeviceService deviceService; | ||
| 46 | + | ||
| 47 | + private ApplicationId appId; | ||
| 48 | + | ||
| 49 | + private final InternalDeviceListener listener = new InternalDeviceListener(); | ||
| 50 | + | ||
| 51 | + private final Map<DeviceId, Integer> uglyMap = new HashMap<>(); | ||
| 52 | + | ||
| 53 | + @Activate | ||
| 54 | + public void activate() { | ||
| 55 | + appId = coreService.registerApplication("org.onlab.onos.fwd"); | ||
| 56 | + | ||
| 57 | + deviceService.addListener(listener); | ||
| 58 | + | ||
| 59 | + uglyMap.put(DeviceId.deviceId("of:0000ffffffffff01"), 1); | ||
| 60 | + uglyMap.put(DeviceId.deviceId("of:0000ffffffffff02"), 2); | ||
| 61 | + uglyMap.put(DeviceId.deviceId("of:0000ffffffffff03"), 3); | ||
| 62 | + | ||
| 63 | + log.info("Started with Application ID {}", appId.id()); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Deactivate | ||
| 67 | + public void deactivate() { | ||
| 68 | + flowRuleService.removeFlowRulesById(appId); | ||
| 69 | + | ||
| 70 | + log.info("Stopped"); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + | ||
| 74 | + private void pushRules(Device device) { | ||
| 75 | + | ||
| 76 | + TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); | ||
| 77 | + TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder(); | ||
| 78 | + int inport; | ||
| 79 | + int outport; | ||
| 80 | + short lambda = 10; | ||
| 81 | + | ||
| 82 | + int switchNumber = uglyMap.get(device.id()); | ||
| 83 | + switch (switchNumber) { | ||
| 84 | + case 1: | ||
| 85 | + inport = 10; | ||
| 86 | + outport = 20; | ||
| 87 | + sbuilder.matchInport(PortNumber.portNumber(inport)); | ||
| 88 | + tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda); | ||
| 89 | + break; | ||
| 90 | + case 2: | ||
| 91 | + inport = 21; | ||
| 92 | + outport = 11; | ||
| 93 | + sbuilder.matchLambda(lambda).matchInport(PortNumber.portNumber(inport)); // match sigtype | ||
| 94 | + tbuilder.setOutput(PortNumber.portNumber(outport)); | ||
| 95 | + break; | ||
| 96 | + case 3: | ||
| 97 | + inport = 30; | ||
| 98 | + outport = 31; | ||
| 99 | + sbuilder.matchLambda(lambda).matchInport(PortNumber.portNumber(inport)); | ||
| 100 | + tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda); | ||
| 101 | + break; | ||
| 102 | + default: | ||
| 103 | + } | ||
| 104 | + sbuilder.matchLambda((short) 25).matchInport(PortNumber.portNumber(5)); | ||
| 105 | + | ||
| 106 | + tbuilder.setOutput(PortNumber.portNumber(5)); | ||
| 107 | + | ||
| 108 | + TrafficTreatment treatement = tbuilder.build(); | ||
| 109 | + TrafficSelector selector = sbuilder.build(); | ||
| 110 | + | ||
| 111 | + FlowRule f = new DefaultFlowRule(device.id(), selector, | ||
| 112 | + treatement, 100, appId, 600, false); | ||
| 113 | + | ||
| 114 | + flowRuleService.applyFlowRules(f); | ||
| 115 | + | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public class InternalDeviceListener implements DeviceListener { | ||
| 121 | + | ||
| 122 | + @Override | ||
| 123 | + public void event(DeviceEvent event) { | ||
| 124 | + switch (event.type()) { | ||
| 125 | + case DEVICE_ADDED: | ||
| 126 | + pushRules(event.subject()); | ||
| 127 | + break; | ||
| 128 | + case DEVICE_AVAILABILITY_CHANGED: | ||
| 129 | + break; | ||
| 130 | + case DEVICE_MASTERSHIP_CHANGED: | ||
| 131 | + break; | ||
| 132 | + case DEVICE_REMOVED: | ||
| 133 | + break; | ||
| 134 | + case DEVICE_SUSPENDED: | ||
| 135 | + break; | ||
| 136 | + case DEVICE_UPDATED: | ||
| 137 | + break; | ||
| 138 | + case PORT_ADDED: | ||
| 139 | + break; | ||
| 140 | + case PORT_REMOVED: | ||
| 141 | + break; | ||
| 142 | + case PORT_UPDATED: | ||
| 143 | + break; | ||
| 144 | + default: | ||
| 145 | + break; | ||
| 146 | + | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | + |
| ... | @@ -176,6 +176,11 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -176,6 +176,11 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | @Override | 178 | @Override |
| 179 | + public Builder matchLambda(short lambda) { | ||
| 180 | + return add(Criteria.matchLambda(lambda)); | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + @Override | ||
| 179 | public TrafficSelector build() { | 184 | public TrafficSelector build() { |
| 180 | return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values())); | 185 | return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values())); |
| 181 | } | 186 | } | ... | ... |
| ... | @@ -137,6 +137,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -137,6 +137,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
| 137 | case OUTPUT: | 137 | case OUTPUT: |
| 138 | outputs.add(instruction); | 138 | outputs.add(instruction); |
| 139 | break; | 139 | break; |
| 140 | + case L0MODIFICATION: | ||
| 140 | case L2MODIFICATION: | 141 | case L2MODIFICATION: |
| 141 | case L3MODIFICATION: | 142 | case L3MODIFICATION: |
| 142 | // TODO: enforce modification order if any | 143 | // TODO: enforce modification order if any |
| ... | @@ -193,6 +194,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -193,6 +194,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
| 193 | } | 194 | } |
| 194 | 195 | ||
| 195 | @Override | 196 | @Override |
| 197 | + public Builder setLambda(short lambda) { | ||
| 198 | + return add(Instructions.modL0Lambda(lambda)); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + @Override | ||
| 196 | public TrafficTreatment build() { | 202 | public TrafficTreatment build() { |
| 197 | 203 | ||
| 198 | //If we are dropping should we just return an emptry list? | 204 | //If we are dropping should we just return an emptry list? | ... | ... |
| ... | @@ -130,6 +130,13 @@ public interface TrafficSelector { | ... | @@ -130,6 +130,13 @@ public interface TrafficSelector { |
| 130 | public Builder matchTcpDst(Short tcpPort); | 130 | public Builder matchTcpDst(Short tcpPort); |
| 131 | 131 | ||
| 132 | /** | 132 | /** |
| 133 | + * Matches an optical signal ID or lambda. | ||
| 134 | + * @param lambda | ||
| 135 | + * @return a selection builder | ||
| 136 | + */ | ||
| 137 | + public Builder matchLambda(short lambda); | ||
| 138 | + | ||
| 139 | + /** | ||
| 133 | * Builds an immutable traffic selector. | 140 | * Builds an immutable traffic selector. |
| 134 | * | 141 | * |
| 135 | * @return traffic selector | 142 | * @return traffic selector | ... | ... |
| ... | @@ -105,6 +105,13 @@ public interface TrafficTreatment { | ... | @@ -105,6 +105,13 @@ public interface TrafficTreatment { |
| 105 | public Builder setIpDst(IpPrefix addr); | 105 | public Builder setIpDst(IpPrefix addr); |
| 106 | 106 | ||
| 107 | /** | 107 | /** |
| 108 | + * Sets the optical channel ID or lambda. | ||
| 109 | + * @param lambda optical channel ID | ||
| 110 | + * @return a treatment builder | ||
| 111 | + */ | ||
| 112 | + public Builder setLambda(short lambda); | ||
| 113 | + | ||
| 114 | + /** | ||
| 108 | * Builds an immutable traffic treatment descriptor. | 115 | * Builds an immutable traffic treatment descriptor. |
| 109 | * | 116 | * |
| 110 | * @return traffic treatment | 117 | * @return traffic treatment | ... | ... |
| ... | @@ -151,10 +151,19 @@ public final class Criteria { | ... | @@ -151,10 +151,19 @@ public final class Criteria { |
| 151 | return new TcpPortCriterion(tcpPort, Type.TCP_DST); | 151 | return new TcpPortCriterion(tcpPort, Type.TCP_DST); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | - /* | 154 | + /** |
| 155 | - * Implementations of criteria. | 155 | + * Creates a match on lambda field using the specified value. |
| 156 | + * | ||
| 157 | + * @param lambda | ||
| 158 | + * @return match criterion | ||
| 156 | */ | 159 | */ |
| 160 | + public static Criterion matchLambda(Short lambda) { | ||
| 161 | + return new LambdaCriterion(lambda, Type.OCH_SIGID); | ||
| 162 | + } | ||
| 157 | 163 | ||
| 164 | + /** | ||
| 165 | + * Implementations of criteria. | ||
| 166 | + */ | ||
| 158 | public static final class PortCriterion implements Criterion { | 167 | public static final class PortCriterion implements Criterion { |
| 159 | private final PortNumber port; | 168 | private final PortNumber port; |
| 160 | 169 | ||
| ... | @@ -523,4 +532,49 @@ public final class Criteria { | ... | @@ -523,4 +532,49 @@ public final class Criteria { |
| 523 | return false; | 532 | return false; |
| 524 | } | 533 | } |
| 525 | } | 534 | } |
| 535 | + | ||
| 536 | + public static final class LambdaCriterion implements Criterion { | ||
| 537 | + | ||
| 538 | + private final short lambda; | ||
| 539 | + private final Type type; | ||
| 540 | + | ||
| 541 | + public LambdaCriterion(short lambda, Type type) { | ||
| 542 | + this.lambda = lambda; | ||
| 543 | + this.type = type; | ||
| 544 | + } | ||
| 545 | + | ||
| 546 | + @Override | ||
| 547 | + public Type type() { | ||
| 548 | + return this.type; | ||
| 549 | + } | ||
| 550 | + | ||
| 551 | + public Short lambda() { | ||
| 552 | + return this.lambda; | ||
| 553 | + } | ||
| 554 | + | ||
| 555 | + @Override | ||
| 556 | + public String toString() { | ||
| 557 | + return toStringHelper(type().toString()) | ||
| 558 | + .add("lambda", lambda).toString(); | ||
| 559 | + } | ||
| 560 | + | ||
| 561 | + @Override | ||
| 562 | + public int hashCode() { | ||
| 563 | + return Objects.hash(lambda, type); | ||
| 564 | + } | ||
| 565 | + | ||
| 566 | + @Override | ||
| 567 | + public boolean equals(Object obj) { | ||
| 568 | + if (this == obj) { | ||
| 569 | + return true; | ||
| 570 | + } | ||
| 571 | + if (obj instanceof LambdaCriterion) { | ||
| 572 | + LambdaCriterion that = (LambdaCriterion) obj; | ||
| 573 | + return Objects.equals(lambda, that.lambda) && | ||
| 574 | + Objects.equals(type, that.type); | ||
| 575 | + } | ||
| 576 | + return false; | ||
| 577 | + } | ||
| 578 | + } | ||
| 579 | + | ||
| 526 | } | 580 | } | ... | ... |
| ... | @@ -108,7 +108,11 @@ public interface Criterion { | ... | @@ -108,7 +108,11 @@ public interface Criterion { |
| 108 | /** Logical Port Metadata. */ | 108 | /** Logical Port Metadata. */ |
| 109 | TUNNEL_ID, | 109 | TUNNEL_ID, |
| 110 | /** IPv6 Extension Header pseudo-field. */ | 110 | /** IPv6 Extension Header pseudo-field. */ |
| 111 | - IPV6_EXTHDR | 111 | + IPV6_EXTHDR, |
| 112 | + /** Optical channel signal ID (lambda). */ | ||
| 113 | + OCH_SIGID, | ||
| 114 | + /** Optical channel signal type (fixed or flexible). */ | ||
| 115 | + OCH_SIGTYPE | ||
| 112 | } | 116 | } |
| 113 | 117 | ||
| 114 | /** | 118 | /** | ... | ... |
| ... | @@ -43,6 +43,11 @@ public interface Instruction { | ... | @@ -43,6 +43,11 @@ public interface Instruction { |
| 43 | GROUP, | 43 | GROUP, |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | + * Signifies that the traffic should be modified in L0 way. | ||
| 47 | + */ | ||
| 48 | + L0MODIFICATION, | ||
| 49 | + | ||
| 50 | + /** | ||
| 46 | * Signifies that the traffic should be modified in L2 way. | 51 | * Signifies that the traffic should be modified in L2 way. |
| 47 | */ | 52 | */ |
| 48 | L2MODIFICATION, | 53 | L2MODIFICATION, | ... | ... |
| ... | @@ -24,6 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -24,6 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 24 | import java.util.Objects; | 24 | import java.util.Objects; |
| 25 | 25 | ||
| 26 | import org.onlab.onos.net.PortNumber; | 26 | import org.onlab.onos.net.PortNumber; |
| 27 | +import org.onlab.onos.net.flow.instructions.L0ModificationInstruction.L0SubType; | ||
| 28 | +import org.onlab.onos.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; | ||
| 27 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.L2SubType; | 29 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.L2SubType; |
| 28 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; | 30 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; |
| 29 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.L3SubType; | 31 | import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.L3SubType; |
| ... | @@ -62,6 +64,16 @@ public final class Instructions { | ... | @@ -62,6 +64,16 @@ public final class Instructions { |
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | /** | 66 | /** |
| 67 | + * Creates a l0 modification. | ||
| 68 | + * @param lambda the lambda to modify to. | ||
| 69 | + * @return a l0 modification | ||
| 70 | + */ | ||
| 71 | + public static L0ModificationInstruction modL0Lambda(short lambda) { | ||
| 72 | + checkNotNull(lambda, "L0 lambda cannot be null"); | ||
| 73 | + return new ModLambdaInstruction(L0SubType.LAMBDA, lambda); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 65 | * Creates a l2 src modification. | 77 | * Creates a l2 src modification. |
| 66 | * @param addr the mac address to modify to. | 78 | * @param addr the mac address to modify to. |
| 67 | * @return a l2 modification | 79 | * @return a l2 modification | ... | ... |
core/api/src/main/java/org/onlab/onos/net/flow/instructions/L0ModificationInstruction.java
0 → 100644
| 1 | +package org.onlab.onos.net.flow.instructions; | ||
| 2 | + | ||
| 3 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 4 | + | ||
| 5 | +import java.util.Objects; | ||
| 6 | + | ||
| 7 | +public abstract class L0ModificationInstruction implements Instruction { | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * Represents the type of traffic treatment. | ||
| 11 | + */ | ||
| 12 | + public enum L0SubType { | ||
| 13 | + /** | ||
| 14 | + * Lambda modification. | ||
| 15 | + */ | ||
| 16 | + LAMBDA | ||
| 17 | + | ||
| 18 | + //TODO: remaining types | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public abstract L0SubType subtype(); | ||
| 22 | + | ||
| 23 | + @Override | ||
| 24 | + public Type type() { | ||
| 25 | + return Type.L0MODIFICATION; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Represents a L0 lambda modification instruction. | ||
| 30 | + */ | ||
| 31 | + public static final class ModLambdaInstruction extends L0ModificationInstruction { | ||
| 32 | + | ||
| 33 | + private final L0SubType subtype; | ||
| 34 | + private final short lambda; | ||
| 35 | + | ||
| 36 | + public ModLambdaInstruction(L0SubType subType, short lambda) { | ||
| 37 | + this.subtype = subType; | ||
| 38 | + this.lambda = lambda; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public L0SubType subtype() { | ||
| 43 | + return this.subtype; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public short lambda() { | ||
| 47 | + return this.lambda; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public String toString() { | ||
| 52 | + return toStringHelper(subtype().toString()) | ||
| 53 | + .add("lambda", lambda).toString(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public int hashCode() { | ||
| 58 | + return Objects.hash(lambda, type(), subtype); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public boolean equals(Object obj) { | ||
| 63 | + if (this == obj) { | ||
| 64 | + return true; | ||
| 65 | + } | ||
| 66 | + if (obj instanceof ModLambdaInstruction) { | ||
| 67 | + ModLambdaInstruction that = (ModLambdaInstruction) obj; | ||
| 68 | + return Objects.equals(lambda, that.lambda) && | ||
| 69 | + Objects.equals(this.type(), that.type()) && | ||
| 70 | + Objects.equals(subtype, that.subtype); | ||
| 71 | + } | ||
| 72 | + return false; | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | +} |
| 1 | package org.onlab.onos.openflow.controller; | 1 | package org.onlab.onos.openflow.controller; |
| 2 | 2 | ||
| 3 | + | ||
| 4 | +import java.util.Collections; | ||
| 5 | +import java.util.concurrent.atomic.AtomicBoolean; | ||
| 6 | + | ||
| 3 | import org.onlab.packet.Ethernet; | 7 | import org.onlab.packet.Ethernet; |
| 4 | import org.projectfloodlight.openflow.protocol.OFPacketIn; | 8 | import org.projectfloodlight.openflow.protocol.OFPacketIn; |
| 5 | import org.projectfloodlight.openflow.protocol.OFPacketOut; | 9 | import org.projectfloodlight.openflow.protocol.OFPacketOut; |
| ... | @@ -9,9 +13,6 @@ import org.projectfloodlight.openflow.protocol.match.MatchField; | ... | @@ -9,9 +13,6 @@ import org.projectfloodlight.openflow.protocol.match.MatchField; |
| 9 | import org.projectfloodlight.openflow.types.OFBufferId; | 13 | import org.projectfloodlight.openflow.types.OFBufferId; |
| 10 | import org.projectfloodlight.openflow.types.OFPort; | 14 | import org.projectfloodlight.openflow.types.OFPort; |
| 11 | 15 | ||
| 12 | -import java.util.Collections; | ||
| 13 | -import java.util.concurrent.atomic.AtomicBoolean; | ||
| 14 | - | ||
| 15 | public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext { | 16 | public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext { |
| 16 | 17 | ||
| 17 | private final AtomicBoolean free = new AtomicBoolean(true); | 18 | private final AtomicBoolean free = new AtomicBoolean(true); | ... | ... |
| ... | @@ -23,6 +23,8 @@ import org.projectfloodlight.openflow.protocol.OFFlowRemoved; | ... | @@ -23,6 +23,8 @@ import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
| 23 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; | 23 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 24 | import org.projectfloodlight.openflow.protocol.OFInstructionType; | 24 | import org.projectfloodlight.openflow.protocol.OFInstructionType; |
| 25 | import org.projectfloodlight.openflow.protocol.action.OFAction; | 25 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| 26 | +import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; | ||
| 27 | +import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter; | ||
| 26 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; | 28 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
| 27 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; | 29 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; |
| 28 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc; | 30 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc; |
| ... | @@ -34,6 +36,7 @@ import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; | ... | @@ -34,6 +36,7 @@ import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
| 34 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; | 36 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; |
| 35 | import org.projectfloodlight.openflow.protocol.match.Match; | 37 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 36 | import org.projectfloodlight.openflow.protocol.match.MatchField; | 38 | import org.projectfloodlight.openflow.protocol.match.MatchField; |
| 39 | +import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; | ||
| 37 | import org.projectfloodlight.openflow.types.IPv4Address; | 40 | import org.projectfloodlight.openflow.types.IPv4Address; |
| 38 | import org.projectfloodlight.openflow.types.Masked; | 41 | import org.projectfloodlight.openflow.types.Masked; |
| 39 | import org.slf4j.Logger; | 42 | import org.slf4j.Logger; |
| ... | @@ -166,6 +169,15 @@ public class FlowEntryBuilder { | ... | @@ -166,6 +169,15 @@ public class FlowEntryBuilder { |
| 166 | builder.setIpSrc(IpPrefix.valueOf(si.getInt())); | 169 | builder.setIpSrc(IpPrefix.valueOf(si.getInt())); |
| 167 | } | 170 | } |
| 168 | break; | 171 | break; |
| 172 | + case EXPERIMENTER: | ||
| 173 | + OFActionExperimenter exp = (OFActionExperimenter) act; | ||
| 174 | + if (exp.getExperimenter() == 0x80005A06) { | ||
| 175 | + OFActionCircuit ct = (OFActionCircuit) exp; | ||
| 176 | + builder.setLambda(((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber()); | ||
| 177 | + } else { | ||
| 178 | + log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter()); | ||
| 179 | + } | ||
| 180 | + break; | ||
| 169 | case SET_TP_DST: | 181 | case SET_TP_DST: |
| 170 | case SET_TP_SRC: | 182 | case SET_TP_SRC: |
| 171 | case POP_MPLS: | 183 | case POP_MPLS: |
| ... | @@ -188,7 +200,7 @@ public class FlowEntryBuilder { | ... | @@ -188,7 +200,7 @@ public class FlowEntryBuilder { |
| 188 | case DEC_MPLS_TTL: | 200 | case DEC_MPLS_TTL: |
| 189 | case DEC_NW_TTL: | 201 | case DEC_NW_TTL: |
| 190 | case ENQUEUE: | 202 | case ENQUEUE: |
| 191 | - case EXPERIMENTER: | 203 | + |
| 192 | case GROUP: | 204 | case GROUP: |
| 193 | default: | 205 | default: |
| 194 | log.warn("Action type {} not yet implemented.", act.getType()); | 206 | log.warn("Action type {} not yet implemented.", act.getType()); |
| ... | @@ -268,6 +280,10 @@ public class FlowEntryBuilder { | ... | @@ -268,6 +280,10 @@ public class FlowEntryBuilder { |
| 268 | case TCP_SRC: | 280 | case TCP_SRC: |
| 269 | builder.matchTcpSrc((short) match.get(MatchField.TCP_SRC).getPort()); | 281 | builder.matchTcpSrc((short) match.get(MatchField.TCP_SRC).getPort()); |
| 270 | break; | 282 | break; |
| 283 | + case OCH_SIGID: | ||
| 284 | + builder.matchLambda(match.get(MatchField.OCH_SIGID).getChannelNumber()); | ||
| 285 | + break; | ||
| 286 | + case OCH_SIGTYPE_BASIC: | ||
| 271 | case ARP_OP: | 287 | case ARP_OP: |
| 272 | case ARP_SHA: | 288 | case ARP_SHA: |
| 273 | case ARP_SPA: | 289 | case ARP_SPA: | ... | ... |
| ... | @@ -14,6 +14,7 @@ import org.onlab.onos.net.flow.criteria.Criteria.EthCriterion; | ... | @@ -14,6 +14,7 @@ import org.onlab.onos.net.flow.criteria.Criteria.EthCriterion; |
| 14 | import org.onlab.onos.net.flow.criteria.Criteria.EthTypeCriterion; | 14 | import org.onlab.onos.net.flow.criteria.Criteria.EthTypeCriterion; |
| 15 | import org.onlab.onos.net.flow.criteria.Criteria.IPCriterion; | 15 | import org.onlab.onos.net.flow.criteria.Criteria.IPCriterion; |
| 16 | import org.onlab.onos.net.flow.criteria.Criteria.IPProtocolCriterion; | 16 | import org.onlab.onos.net.flow.criteria.Criteria.IPProtocolCriterion; |
| 17 | +import org.onlab.onos.net.flow.criteria.Criteria.LambdaCriterion; | ||
| 17 | import org.onlab.onos.net.flow.criteria.Criteria.PortCriterion; | 18 | import org.onlab.onos.net.flow.criteria.Criteria.PortCriterion; |
| 18 | import org.onlab.onos.net.flow.criteria.Criteria.TcpPortCriterion; | 19 | import org.onlab.onos.net.flow.criteria.Criteria.TcpPortCriterion; |
| 19 | import org.onlab.onos.net.flow.criteria.Criteria.VlanIdCriterion; | 20 | import org.onlab.onos.net.flow.criteria.Criteria.VlanIdCriterion; |
| ... | @@ -21,6 +22,8 @@ import org.onlab.onos.net.flow.criteria.Criteria.VlanPcpCriterion; | ... | @@ -21,6 +22,8 @@ import org.onlab.onos.net.flow.criteria.Criteria.VlanPcpCriterion; |
| 21 | import org.onlab.onos.net.flow.criteria.Criterion; | 22 | import org.onlab.onos.net.flow.criteria.Criterion; |
| 22 | import org.onlab.onos.net.flow.instructions.Instruction; | 23 | import org.onlab.onos.net.flow.instructions.Instruction; |
| 23 | import org.onlab.onos.net.flow.instructions.Instructions.OutputInstruction; | 24 | import org.onlab.onos.net.flow.instructions.Instructions.OutputInstruction; |
| 25 | +import org.onlab.onos.net.flow.instructions.L0ModificationInstruction; | ||
| 26 | +import org.onlab.onos.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction; | ||
| 24 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction; | 27 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction; |
| 25 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; | 28 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; |
| 26 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; | 29 | import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; |
| ... | @@ -35,6 +38,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowModFlags; | ... | @@ -35,6 +38,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowModFlags; |
| 35 | import org.projectfloodlight.openflow.protocol.action.OFAction; | 38 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| 36 | import org.projectfloodlight.openflow.protocol.match.Match; | 39 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 37 | import org.projectfloodlight.openflow.protocol.match.MatchField; | 40 | import org.projectfloodlight.openflow.protocol.match.MatchField; |
| 41 | +import org.projectfloodlight.openflow.types.CircuitSignalID; | ||
| 38 | import org.projectfloodlight.openflow.types.EthType; | 42 | import org.projectfloodlight.openflow.types.EthType; |
| 39 | import org.projectfloodlight.openflow.types.IPv4Address; | 43 | import org.projectfloodlight.openflow.types.IPv4Address; |
| 40 | import org.projectfloodlight.openflow.types.IpProtocol; | 44 | import org.projectfloodlight.openflow.types.IpProtocol; |
| ... | @@ -137,6 +141,8 @@ public class FlowModBuilder { | ... | @@ -137,6 +141,8 @@ public class FlowModBuilder { |
| 137 | case DROP: | 141 | case DROP: |
| 138 | log.warn("Saw drop action; assigning drop action"); | 142 | log.warn("Saw drop action; assigning drop action"); |
| 139 | return new LinkedList<>(); | 143 | return new LinkedList<>(); |
| 144 | + case L0MODIFICATION: | ||
| 145 | + acts.add(buildL0Modification(i)); | ||
| 140 | case L2MODIFICATION: | 146 | case L2MODIFICATION: |
| 141 | acts.add(buildL2Modification(i)); | 147 | acts.add(buildL2Modification(i)); |
| 142 | break; | 148 | break; |
| ... | @@ -157,6 +163,20 @@ public class FlowModBuilder { | ... | @@ -157,6 +163,20 @@ public class FlowModBuilder { |
| 157 | return acts; | 163 | return acts; |
| 158 | } | 164 | } |
| 159 | 165 | ||
| 166 | + private OFAction buildL0Modification(Instruction i) { | ||
| 167 | + L0ModificationInstruction l0m = (L0ModificationInstruction) i; | ||
| 168 | + switch (l0m.subtype()) { | ||
| 169 | + case LAMBDA: | ||
| 170 | + ModLambdaInstruction ml = (ModLambdaInstruction) i; | ||
| 171 | + return factory.actions().circuit(factory.oxms().ochSigidBasic( | ||
| 172 | + new CircuitSignalID((byte) 1, (byte) 2, ml.lambda(), (short) 1))); | ||
| 173 | + default: | ||
| 174 | + log.warn("Unimplemented action type {}.", l0m.subtype()); | ||
| 175 | + break; | ||
| 176 | + } | ||
| 177 | + return null; | ||
| 178 | + } | ||
| 179 | + | ||
| 160 | private OFAction buildL3Modification(Instruction i) { | 180 | private OFAction buildL3Modification(Instruction i) { |
| 161 | L3ModificationInstruction l3m = (L3ModificationInstruction) i; | 181 | L3ModificationInstruction l3m = (L3ModificationInstruction) i; |
| 162 | ModIPInstruction ip; | 182 | ModIPInstruction ip; |
| ... | @@ -261,6 +281,11 @@ public class FlowModBuilder { | ... | @@ -261,6 +281,11 @@ public class FlowModBuilder { |
| 261 | tp = (TcpPortCriterion) c; | 281 | tp = (TcpPortCriterion) c; |
| 262 | mBuilder.setExact(MatchField.TCP_SRC, TransportPort.of(tp.tcpPort())); | 282 | mBuilder.setExact(MatchField.TCP_SRC, TransportPort.of(tp.tcpPort())); |
| 263 | break; | 283 | break; |
| 284 | + case OCH_SIGID: | ||
| 285 | + LambdaCriterion lc = (LambdaCriterion) c; | ||
| 286 | + mBuilder.setExact(MatchField.OCH_SIGID, | ||
| 287 | + new CircuitSignalID((byte) 1, (byte) 2, lc.lambda(), (short) 1)); | ||
| 288 | + break; | ||
| 264 | case ARP_OP: | 289 | case ARP_OP: |
| 265 | case ARP_SHA: | 290 | case ARP_SHA: |
| 266 | case ARP_SPA: | 291 | case ARP_SPA: | ... | ... |
-
Please register or login to post a comment