Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.provider.of.flow.impl; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 18 | import com.google.common.collect.Lists; |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 19 | |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 20 | import org.onlab.packet.Ip4Address; |
| 21 | import org.onlab.packet.Ip4Prefix; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 22 | import org.onlab.packet.Ip6Address; |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 23 | import org.onlab.packet.Ip6Prefix; |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 24 | import org.onlab.packet.MacAddress; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 25 | import org.onlab.packet.MplsLabel; |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 26 | import org.onlab.packet.VlanId; |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 27 | import org.onosproject.core.DefaultGroupId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 28 | import org.onosproject.net.DeviceId; |
Sho SHIMIZU | 4f828ee | 2015-05-28 09:38:21 -0700 | [diff] [blame] | 29 | import org.onosproject.net.Lambda; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 30 | import org.onosproject.net.PortNumber; |
| 31 | import org.onosproject.net.flow.DefaultFlowEntry; |
| 32 | import org.onosproject.net.flow.DefaultFlowRule; |
| 33 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 34 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 35 | import org.onosproject.net.flow.FlowEntry; |
| 36 | import org.onosproject.net.flow.FlowEntry.FlowEntryState; |
| 37 | import org.onosproject.net.flow.FlowRule; |
| 38 | import org.onosproject.net.flow.TrafficSelector; |
| 39 | import org.onosproject.net.flow.TrafficTreatment; |
Sho SHIMIZU | 9553bb8 | 2015-06-30 16:02:45 -0700 | [diff] [blame^] | 40 | import org.onosproject.net.flow.instructions.Instructions; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 41 | import org.onosproject.openflow.controller.Dpid; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 42 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 43 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
| 44 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 45 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 46 | import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; |
| 47 | import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter; |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 48 | import org.projectfloodlight.openflow.protocol.action.OFActionGroup; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 49 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 50 | import org.projectfloodlight.openflow.protocol.action.OFActionPopMpls; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 51 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; |
| 52 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc; |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 53 | import org.projectfloodlight.openflow.protocol.action.OFActionSetField; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 54 | import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst; |
| 55 | import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc; |
| 56 | import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp; |
| 57 | import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 58 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
Jonathan Hart | cf78320 | 2014-11-24 18:55:42 -0800 | [diff] [blame] | 59 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; |
alshabib | bdcbb10 | 2015-04-22 14:16:38 -0700 | [diff] [blame] | 60 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 61 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteActions; |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 62 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 63 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 64 | import org.projectfloodlight.openflow.protocol.match.MatchField; |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 65 | import org.projectfloodlight.openflow.protocol.oxm.OFOxm; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 66 | import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 67 | import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13; |
Sho SHIMIZU | 4f828ee | 2015-05-28 09:38:21 -0700 | [diff] [blame] | 68 | import org.projectfloodlight.openflow.types.CircuitSignalID; |
sangho | c0b3c34 | 2015-03-12 17:12:10 -0700 | [diff] [blame] | 69 | import org.projectfloodlight.openflow.types.EthType; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 70 | import org.projectfloodlight.openflow.types.IPv4Address; |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 71 | import org.projectfloodlight.openflow.types.IPv6Address; |
Jonathan Hart | 0e12fad | 2014-10-17 14:54:58 -0700 | [diff] [blame] | 72 | import org.projectfloodlight.openflow.types.Masked; |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 73 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 74 | import org.projectfloodlight.openflow.types.U32; |
Sho SHIMIZU | 4f828ee | 2015-05-28 09:38:21 -0700 | [diff] [blame] | 75 | import org.projectfloodlight.openflow.types.U8; |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 76 | import org.projectfloodlight.openflow.types.VlanPcp; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 77 | import org.slf4j.Logger; |
| 78 | |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 79 | import java.util.List; |
| 80 | |
Sho SHIMIZU | 4f828ee | 2015-05-28 09:38:21 -0700 | [diff] [blame] | 81 | import static org.onosproject.net.flow.criteria.Criteria.matchLambda; |
| 82 | import static org.onosproject.net.flow.criteria.Criteria.matchOchSignalType; |
Sho SHIMIZU | c17042d | 2015-05-28 12:07:23 -0700 | [diff] [blame] | 83 | import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupChannelSpacing; |
| 84 | import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupGridType; |
| 85 | import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupOchSignalType; |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 86 | import static org.slf4j.LoggerFactory.getLogger; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 87 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 88 | public class FlowEntryBuilder { |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 89 | private final Logger log = getLogger(getClass()); |
| 90 | |
| 91 | private final OFFlowStatsEntry stat; |
| 92 | private final OFFlowRemoved removed; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 93 | private final OFFlowMod flowMod; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 94 | |
| 95 | private final Match match; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 96 | |
Jonathan Hart | 67fc097 | 2015-03-19 15:21:20 -0700 | [diff] [blame] | 97 | // All actions are contained in an OFInstruction. For OF1.0 |
| 98 | // the instruction type is apply instruction (immediate set in ONOS speak) |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 99 | private final List<OFInstruction> instructions; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 100 | |
| 101 | private final Dpid dpid; |
| 102 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 103 | public enum FlowType { STAT, REMOVED, MOD } |
| 104 | |
| 105 | private final FlowType type; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 106 | |
alshabib | bdcbb10 | 2015-04-22 14:16:38 -0700 | [diff] [blame] | 107 | public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry) { |
Saurav Das | fa2fa93 | 2015-03-03 11:29:48 -0800 | [diff] [blame] | 108 | this.stat = entry; |
| 109 | this.match = entry.getMatch(); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 110 | this.instructions = getInstructions(entry); |
Saurav Das | fa2fa93 | 2015-03-03 11:29:48 -0800 | [diff] [blame] | 111 | this.dpid = dpid; |
| 112 | this.removed = null; |
| 113 | this.flowMod = null; |
| 114 | this.type = FlowType.STAT; |
Saurav Das | fa2fa93 | 2015-03-03 11:29:48 -0800 | [diff] [blame] | 115 | } |
| 116 | |
alshabib | bdcbb10 | 2015-04-22 14:16:38 -0700 | [diff] [blame] | 117 | public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed) { |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 118 | this.match = removed.getMatch(); |
| 119 | this.removed = removed; |
| 120 | |
| 121 | this.dpid = dpid; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 122 | this.instructions = null; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 123 | this.stat = null; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 124 | this.flowMod = null; |
| 125 | this.type = FlowType.REMOVED; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 126 | |
| 127 | } |
| 128 | |
alshabib | bdcbb10 | 2015-04-22 14:16:38 -0700 | [diff] [blame] | 129 | public FlowEntryBuilder(Dpid dpid, OFFlowMod fm) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 130 | this.match = fm.getMatch(); |
| 131 | this.dpid = dpid; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 132 | this.instructions = getInstructions(fm); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 133 | this.type = FlowType.MOD; |
| 134 | this.flowMod = fm; |
| 135 | this.stat = null; |
| 136 | this.removed = null; |
| 137 | } |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 138 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 139 | public FlowEntry build(FlowEntryState... state) { |
| 140 | FlowRule rule; |
| 141 | switch (this.type) { |
| 142 | case STAT: |
alshabib | bdcbb10 | 2015-04-22 14:16:38 -0700 | [diff] [blame] | 143 | rule = DefaultFlowRule.builder() |
| 144 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
| 145 | .withSelector(buildSelector()) |
| 146 | .withTreatment(buildTreatment()) |
| 147 | .withPriority(stat.getPriority()) |
| 148 | .makeTemporary(stat.getIdleTimeout()) |
| 149 | .withCookie(stat.getCookie().getValue()) |
| 150 | .forTable(stat.getTableId().getValue()) |
| 151 | .build(); |
| 152 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 153 | return new DefaultFlowEntry(rule, FlowEntryState.ADDED, |
| 154 | stat.getDurationSec(), stat.getPacketCount().getValue(), |
| 155 | stat.getByteCount().getValue()); |
| 156 | case REMOVED: |
alshabib | bdcbb10 | 2015-04-22 14:16:38 -0700 | [diff] [blame] | 157 | rule = DefaultFlowRule.builder() |
| 158 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
| 159 | .withSelector(buildSelector()) |
| 160 | .withPriority(removed.getPriority()) |
| 161 | .makeTemporary(removed.getIdleTimeout()) |
| 162 | .withCookie(removed.getCookie().getValue()) |
| 163 | .forTable(removed.getTableId().getValue()) |
| 164 | .build(); |
| 165 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 166 | return new DefaultFlowEntry(rule, FlowEntryState.REMOVED, removed.getDurationSec(), |
| 167 | removed.getPacketCount().getValue(), removed.getByteCount().getValue()); |
| 168 | case MOD: |
| 169 | FlowEntryState flowState = state.length > 0 ? state[0] : FlowEntryState.FAILED; |
alshabib | bdcbb10 | 2015-04-22 14:16:38 -0700 | [diff] [blame] | 170 | rule = DefaultFlowRule.builder() |
| 171 | .forDevice(DeviceId.deviceId(Dpid.uri(dpid))) |
| 172 | .withSelector(buildSelector()) |
| 173 | .withTreatment(buildTreatment()) |
| 174 | .withPriority(flowMod.getPriority()) |
| 175 | .makeTemporary(flowMod.getIdleTimeout()) |
| 176 | .withCookie(flowMod.getCookie().getValue()) |
| 177 | .forTable(flowMod.getTableId().getValue()) |
| 178 | .build(); |
| 179 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 180 | return new DefaultFlowEntry(rule, flowState, 0, 0, 0); |
| 181 | default: |
| 182 | log.error("Unknown flow type : {}", this.type); |
| 183 | return null; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 184 | } |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 185 | |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 186 | } |
| 187 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 188 | private List<OFInstruction> getInstructions(OFFlowMod entry) { |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 189 | switch (entry.getVersion()) { |
| 190 | case OF_10: |
Jonathan Hart | 8ef6d3b | 2015-03-08 21:21:27 -0700 | [diff] [blame] | 191 | return Lists.newArrayList(OFFactoryVer13.INSTANCE.instructions() |
| 192 | .applyActions( |
| 193 | entry.getActions())); |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 194 | case OF_11: |
| 195 | case OF_12: |
| 196 | case OF_13: |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 197 | return entry.getInstructions(); |
| 198 | default: |
| 199 | log.warn("Unknown OF version {}", entry.getVersion()); |
| 200 | } |
| 201 | return Lists.newLinkedList(); |
| 202 | } |
| 203 | |
| 204 | private List<OFInstruction> getInstructions(OFFlowStatsEntry entry) { |
| 205 | switch (entry.getVersion()) { |
| 206 | case OF_10: |
| 207 | return Lists.newArrayList( |
| 208 | OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions())); |
| 209 | case OF_11: |
| 210 | case OF_12: |
| 211 | case OF_13: |
| 212 | return entry.getInstructions(); |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 213 | default: |
| 214 | log.warn("Unknown OF version {}", entry.getVersion()); |
| 215 | } |
| 216 | return Lists.newLinkedList(); |
| 217 | } |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 218 | |
| 219 | private TrafficTreatment buildTreatment() { |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 220 | TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 221 | // If this is a drop rule |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 222 | if (instructions.size() == 0) { |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 223 | builder.drop(); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 224 | return builder.build(); |
| 225 | } |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 226 | for (OFInstruction in : instructions) { |
| 227 | switch (in.getType()) { |
| 228 | case GOTO_TABLE: |
alshabib | bdcbb10 | 2015-04-22 14:16:38 -0700 | [diff] [blame] | 229 | builder.transition(((int) ((OFInstructionGotoTable) in) |
| 230 | .getTableId().getValue())); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 231 | break; |
| 232 | case WRITE_METADATA: |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 233 | OFInstructionWriteMetadata m = (OFInstructionWriteMetadata) in; |
| 234 | builder.writeMetadata(m.getMetadata().getValue(), |
| 235 | m.getMetadataMask().getValue()); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 236 | break; |
| 237 | case WRITE_ACTIONS: |
| 238 | builder.deferred(); |
| 239 | buildActions(((OFInstructionWriteActions) in).getActions(), |
| 240 | builder); |
| 241 | break; |
| 242 | case APPLY_ACTIONS: |
| 243 | builder.immediate(); |
| 244 | buildActions(((OFInstructionApplyActions) in).getActions(), |
| 245 | builder); |
| 246 | break; |
| 247 | case CLEAR_ACTIONS: |
| 248 | builder.wipeDeferred(); |
| 249 | break; |
| 250 | case EXPERIMENTER: |
| 251 | break; |
| 252 | case METER: |
| 253 | break; |
| 254 | default: |
| 255 | log.warn("Unknown instructions type {}", in.getType()); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
| 259 | return builder.build(); |
| 260 | } |
| 261 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 262 | private TrafficTreatment.Builder buildActions(List<OFAction> actions, |
| 263 | TrafficTreatment.Builder builder) { |
| 264 | for (OFAction act : actions) { |
| 265 | switch (act.getType()) { |
| 266 | case OUTPUT: |
| 267 | OFActionOutput out = (OFActionOutput) act; |
| 268 | builder.setOutput( |
| 269 | PortNumber.portNumber(out.getPort().getPortNumber())); |
| 270 | break; |
| 271 | case SET_VLAN_VID: |
| 272 | OFActionSetVlanVid vlan = (OFActionSetVlanVid) act; |
| 273 | builder.setVlanId(VlanId.vlanId(vlan.getVlanVid().getVlan())); |
| 274 | break; |
| 275 | case SET_VLAN_PCP: |
| 276 | OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act; |
| 277 | builder.setVlanPcp(pcp.getVlanPcp().getValue()); |
| 278 | break; |
| 279 | case SET_DL_DST: |
| 280 | OFActionSetDlDst dldst = (OFActionSetDlDst) act; |
| 281 | builder.setEthDst( |
| 282 | MacAddress.valueOf(dldst.getDlAddr().getLong())); |
| 283 | break; |
| 284 | case SET_DL_SRC: |
| 285 | OFActionSetDlSrc dlsrc = (OFActionSetDlSrc) act; |
| 286 | builder.setEthSrc( |
| 287 | MacAddress.valueOf(dlsrc.getDlAddr().getLong())); |
| 288 | |
| 289 | break; |
| 290 | case SET_NW_DST: |
| 291 | OFActionSetNwDst nwdst = (OFActionSetNwDst) act; |
| 292 | IPv4Address di = nwdst.getNwAddr(); |
| 293 | builder.setIpDst(Ip4Address.valueOf(di.getInt())); |
| 294 | break; |
| 295 | case SET_NW_SRC: |
| 296 | OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act; |
| 297 | IPv4Address si = nwsrc.getNwAddr(); |
| 298 | builder.setIpSrc(Ip4Address.valueOf(si.getInt())); |
| 299 | break; |
| 300 | case EXPERIMENTER: |
| 301 | OFActionExperimenter exp = (OFActionExperimenter) act; |
| 302 | if (exp.getExperimenter() == 0x80005A06 || |
| 303 | exp.getExperimenter() == 0x748771) { |
| 304 | OFActionCircuit ct = (OFActionCircuit) exp; |
Sho SHIMIZU | 9553bb8 | 2015-06-30 16:02:45 -0700 | [diff] [blame^] | 305 | short lambda = ((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber(); |
| 306 | builder.add(Instructions.modL0Lambda(Lambda.indexedLambda(lambda))); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 307 | } else { |
| 308 | log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter()); |
| 309 | } |
| 310 | break; |
| 311 | case SET_FIELD: |
| 312 | OFActionSetField setField = (OFActionSetField) act; |
| 313 | handleSetField(builder, setField.getField()); |
| 314 | break; |
| 315 | case POP_MPLS: |
| 316 | OFActionPopMpls popMpls = (OFActionPopMpls) act; |
| 317 | builder.popMpls((short) popMpls.getEthertype().getValue()); |
| 318 | break; |
| 319 | case PUSH_MPLS: |
| 320 | builder.pushMpls(); |
| 321 | break; |
| 322 | case COPY_TTL_IN: |
| 323 | builder.copyTtlIn(); |
| 324 | break; |
| 325 | case COPY_TTL_OUT: |
| 326 | builder.copyTtlOut(); |
| 327 | break; |
| 328 | case DEC_MPLS_TTL: |
| 329 | builder.decMplsTtl(); |
| 330 | break; |
| 331 | case DEC_NW_TTL: |
| 332 | builder.decNwTtl(); |
| 333 | break; |
| 334 | case GROUP: |
| 335 | OFActionGroup group = (OFActionGroup) act; |
| 336 | builder.group(new DefaultGroupId(group.getGroup().getGroupNumber())); |
| 337 | break; |
Jonathan Hart | 67fc097 | 2015-03-19 15:21:20 -0700 | [diff] [blame] | 338 | case STRIP_VLAN: |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 339 | case POP_VLAN: |
| 340 | builder.popVlan(); |
| 341 | break; |
Jonathan Hart | 8ef6d3b | 2015-03-08 21:21:27 -0700 | [diff] [blame] | 342 | case PUSH_VLAN: |
| 343 | builder.pushVlan(); |
| 344 | break; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 345 | case SET_TP_DST: |
| 346 | case SET_TP_SRC: |
| 347 | case POP_PBB: |
| 348 | case PUSH_PBB: |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 349 | case SET_MPLS_LABEL: |
| 350 | case SET_MPLS_TC: |
| 351 | case SET_MPLS_TTL: |
| 352 | case SET_NW_ECN: |
| 353 | case SET_NW_TOS: |
| 354 | case SET_NW_TTL: |
| 355 | case SET_QUEUE: |
| 356 | |
| 357 | case ENQUEUE: |
| 358 | default: |
| 359 | log.warn("Action type {} not yet implemented.", act.getType()); |
| 360 | } |
| 361 | } |
| 362 | return builder; |
| 363 | } |
| 364 | |
| 365 | |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 366 | private void handleSetField(TrafficTreatment.Builder builder, OFOxm<?> oxm) { |
| 367 | switch (oxm.getMatchField().id) { |
| 368 | case VLAN_PCP: |
| 369 | @SuppressWarnings("unchecked") |
| 370 | OFOxm<VlanPcp> vlanpcp = (OFOxm<VlanPcp>) oxm; |
| 371 | builder.setVlanPcp(vlanpcp.getValue().getValue()); |
| 372 | break; |
| 373 | case VLAN_VID: |
| 374 | @SuppressWarnings("unchecked") |
| 375 | OFOxm<OFVlanVidMatch> vlanvid = (OFOxm<OFVlanVidMatch>) oxm; |
| 376 | builder.setVlanId(VlanId.vlanId(vlanvid.getValue().getVlan())); |
| 377 | break; |
| 378 | case ETH_DST: |
| 379 | @SuppressWarnings("unchecked") |
| 380 | OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethdst = |
| 381 | (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm; |
| 382 | builder.setEthDst(MacAddress.valueOf(ethdst.getValue().getLong())); |
| 383 | break; |
| 384 | case ETH_SRC: |
| 385 | @SuppressWarnings("unchecked") |
| 386 | OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethsrc = |
| 387 | (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm; |
| 388 | builder.setEthSrc(MacAddress.valueOf(ethsrc.getValue().getLong())); |
| 389 | break; |
| 390 | case IPV4_DST: |
| 391 | @SuppressWarnings("unchecked") |
| 392 | OFOxm<IPv4Address> ip4dst = (OFOxm<IPv4Address>) oxm; |
| 393 | builder.setIpDst(Ip4Address.valueOf(ip4dst.getValue().getInt())); |
| 394 | break; |
| 395 | case IPV4_SRC: |
| 396 | @SuppressWarnings("unchecked") |
| 397 | OFOxm<IPv4Address> ip4src = (OFOxm<IPv4Address>) oxm; |
| 398 | builder.setIpSrc(Ip4Address.valueOf(ip4src.getValue().getInt())); |
| 399 | break; |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 400 | case MPLS_LABEL: |
| 401 | @SuppressWarnings("unchecked") |
| 402 | OFOxm<U32> labelId = (OFOxm<U32>) oxm; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 403 | builder.setMpls(MplsLabel.mplsLabel((int) labelId.getValue().getValue())); |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 404 | break; |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 405 | case ARP_OP: |
| 406 | case ARP_SHA: |
| 407 | case ARP_SPA: |
| 408 | case ARP_THA: |
| 409 | case ARP_TPA: |
| 410 | case BSN_EGR_PORT_GROUP_ID: |
| 411 | case BSN_GLOBAL_VRF_ALLOWED: |
| 412 | case BSN_IN_PORTS_128: |
| 413 | case BSN_L3_DST_CLASS_ID: |
| 414 | case BSN_L3_INTERFACE_CLASS_ID: |
| 415 | case BSN_L3_SRC_CLASS_ID: |
| 416 | case BSN_LAG_ID: |
| 417 | case BSN_TCP_FLAGS: |
| 418 | case BSN_UDF0: |
| 419 | case BSN_UDF1: |
| 420 | case BSN_UDF2: |
| 421 | case BSN_UDF3: |
| 422 | case BSN_UDF4: |
| 423 | case BSN_UDF5: |
| 424 | case BSN_UDF6: |
| 425 | case BSN_UDF7: |
| 426 | case BSN_VLAN_XLATE_PORT_GROUP_ID: |
| 427 | case BSN_VRF: |
| 428 | case ETH_TYPE: |
| 429 | case ICMPV4_CODE: |
| 430 | case ICMPV4_TYPE: |
| 431 | case ICMPV6_CODE: |
| 432 | case ICMPV6_TYPE: |
| 433 | case IN_PHY_PORT: |
| 434 | case IN_PORT: |
| 435 | case IPV6_DST: |
| 436 | case IPV6_FLABEL: |
| 437 | case IPV6_ND_SLL: |
| 438 | case IPV6_ND_TARGET: |
| 439 | case IPV6_ND_TLL: |
| 440 | case IPV6_SRC: |
| 441 | case IP_DSCP: |
| 442 | case IP_ECN: |
| 443 | case IP_PROTO: |
| 444 | case METADATA: |
Jonathan Hart | d0ef752 | 2014-12-11 11:51:18 -0800 | [diff] [blame] | 445 | case MPLS_TC: |
| 446 | case OCH_SIGID: |
| 447 | case OCH_SIGID_BASIC: |
| 448 | case OCH_SIGTYPE: |
| 449 | case OCH_SIGTYPE_BASIC: |
| 450 | case SCTP_DST: |
| 451 | case SCTP_SRC: |
| 452 | case TCP_DST: |
| 453 | case TCP_SRC: |
| 454 | case TUNNEL_ID: |
| 455 | case UDP_DST: |
| 456 | case UDP_SRC: |
| 457 | default: |
| 458 | log.warn("Set field type {} not yet implemented.", oxm.getMatchField().id); |
| 459 | break; |
| 460 | } |
| 461 | } |
| 462 | |
Sho SHIMIZU | 6f1b09e | 2015-05-05 11:26:22 -0700 | [diff] [blame] | 463 | // CHECKSTYLE IGNORE MethodLength FOR NEXT 1 LINES |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 464 | private TrafficSelector buildSelector() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 465 | MacAddress mac; |
| 466 | Ip4Prefix ip4Prefix; |
| 467 | Ip6Address ip6Address; |
| 468 | Ip6Prefix ip6Prefix; |
| 469 | |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 470 | TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 471 | for (MatchField<?> field : match.getMatchFields()) { |
| 472 | switch (field.id) { |
| 473 | case IN_PORT: |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 474 | builder.matchInPort(PortNumber |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 475 | .portNumber(match.get(MatchField.IN_PORT).getPortNumber())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 476 | break; |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 477 | case IN_PHY_PORT: |
| 478 | builder.matchInPhyPort(PortNumber |
| 479 | .portNumber(match.get(MatchField.IN_PHY_PORT).getPortNumber())); |
| 480 | break; |
| 481 | case METADATA: |
| 482 | long metadata = |
| 483 | match.get(MatchField.METADATA).getValue().getValue(); |
| 484 | builder.matchMetadata(metadata); |
| 485 | break; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 486 | case ETH_DST: |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 487 | mac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong()); |
| 488 | builder.matchEthDst(mac); |
| 489 | break; |
| 490 | case ETH_SRC: |
| 491 | mac = MacAddress.valueOf(match.get(MatchField.ETH_SRC).getLong()); |
| 492 | builder.matchEthSrc(mac); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 493 | break; |
| 494 | case ETH_TYPE: |
| 495 | int ethType = match.get(MatchField.ETH_TYPE).getValue(); |
sangho | c0b3c34 | 2015-03-12 17:12:10 -0700 | [diff] [blame] | 496 | if (ethType == EthType.VLAN_FRAME.getValue()) { |
| 497 | builder.matchVlanId(VlanId.ANY); |
| 498 | } else { |
| 499 | builder.matchEthType((short) ethType); |
| 500 | } |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 501 | break; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 502 | case VLAN_VID: |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 503 | VlanId vlanId = null; |
| 504 | if (match.isPartiallyMasked(MatchField.VLAN_VID)) { |
| 505 | Masked<OFVlanVidMatch> masked = match.getMasked(MatchField.VLAN_VID); |
| 506 | if (masked.getValue().equals(OFVlanVidMatch.PRESENT) |
| 507 | && masked.getMask().equals(OFVlanVidMatch.PRESENT)) { |
| 508 | vlanId = VlanId.ANY; |
| 509 | } |
| 510 | } else { |
| 511 | vlanId = VlanId.vlanId(match.get(MatchField.VLAN_VID).getVlan()); |
| 512 | } |
| 513 | if (vlanId != null) { |
| 514 | builder.matchVlanId(vlanId); |
| 515 | } |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 516 | break; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 517 | case VLAN_PCP: |
| 518 | byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue(); |
| 519 | builder.matchVlanPcp(vlanPcp); |
| 520 | break; |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 521 | case IP_DSCP: |
| 522 | byte ipDscp = match.get(MatchField.IP_DSCP).getDscpValue(); |
| 523 | builder.matchIPDscp(ipDscp); |
| 524 | break; |
| 525 | case IP_ECN: |
| 526 | byte ipEcn = match.get(MatchField.IP_ECN).getEcnValue(); |
| 527 | builder.matchIPEcn(ipEcn); |
| 528 | break; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 529 | case IP_PROTO: |
| 530 | short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber(); |
| 531 | builder.matchIPProtocol((byte) proto); |
| 532 | break; |
| 533 | case IPV4_SRC: |
| 534 | if (match.isPartiallyMasked(MatchField.IPV4_SRC)) { |
| 535 | Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_SRC); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 536 | ip4Prefix = Ip4Prefix.valueOf( |
| 537 | maskedIp.getValue().getInt(), |
| 538 | maskedIp.getMask().asCidrMaskLength()); |
| 539 | } else { |
| 540 | ip4Prefix = Ip4Prefix.valueOf( |
| 541 | match.get(MatchField.IPV4_SRC).getInt(), |
| 542 | Ip4Prefix.MAX_MASK_LENGTH); |
| 543 | } |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 544 | builder.matchIPSrc(ip4Prefix); |
| 545 | break; |
| 546 | case IPV4_DST: |
| 547 | if (match.isPartiallyMasked(MatchField.IPV4_DST)) { |
| 548 | Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_DST); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 549 | ip4Prefix = Ip4Prefix.valueOf( |
| 550 | maskedIp.getValue().getInt(), |
| 551 | maskedIp.getMask().asCidrMaskLength()); |
| 552 | } else { |
| 553 | ip4Prefix = Ip4Prefix.valueOf( |
| 554 | match.get(MatchField.IPV4_DST).getInt(), |
| 555 | Ip4Prefix.MAX_MASK_LENGTH); |
| 556 | } |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 557 | builder.matchIPDst(ip4Prefix); |
Jonathan Hart | 34bc614 | 2014-10-17 11:00:43 -0700 | [diff] [blame] | 558 | break; |
| 559 | case TCP_SRC: |
| 560 | builder.matchTcpSrc((short) match.get(MatchField.TCP_SRC).getPort()); |
| 561 | break; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 562 | case TCP_DST: |
| 563 | builder.matchTcpDst((short) match.get(MatchField.TCP_DST).getPort()); |
| 564 | break; |
| 565 | case UDP_SRC: |
| 566 | builder.matchUdpSrc((short) match.get(MatchField.UDP_SRC).getPort()); |
| 567 | break; |
| 568 | case UDP_DST: |
| 569 | builder.matchUdpDst((short) match.get(MatchField.UDP_DST).getPort()); |
Sho SHIMIZU | 6f1b09e | 2015-05-05 11:26:22 -0700 | [diff] [blame] | 570 | break; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 571 | case MPLS_LABEL: |
| 572 | builder.matchMplsLabel(MplsLabel.mplsLabel((int) match.get(MatchField.MPLS_LABEL) |
| 573 | .getValue())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 574 | break; |
| 575 | case SCTP_SRC: |
| 576 | builder.matchSctpSrc((short) match.get(MatchField.SCTP_SRC).getPort()); |
| 577 | break; |
| 578 | case SCTP_DST: |
| 579 | builder.matchSctpDst((short) match.get(MatchField.SCTP_DST).getPort()); |
| 580 | break; |
| 581 | case ICMPV4_TYPE: |
| 582 | byte icmpType = (byte) match.get(MatchField.ICMPV4_TYPE).getType(); |
| 583 | builder.matchIcmpType(icmpType); |
| 584 | break; |
| 585 | case ICMPV4_CODE: |
| 586 | byte icmpCode = (byte) match.get(MatchField.ICMPV4_CODE).getCode(); |
| 587 | builder.matchIcmpCode(icmpCode); |
| 588 | break; |
| 589 | case IPV6_SRC: |
| 590 | if (match.isPartiallyMasked(MatchField.IPV6_SRC)) { |
| 591 | Masked<IPv6Address> maskedIp = match.getMasked(MatchField.IPV6_SRC); |
| 592 | ip6Prefix = Ip6Prefix.valueOf( |
| 593 | maskedIp.getValue().getBytes(), |
| 594 | maskedIp.getMask().asCidrMaskLength()); |
| 595 | } else { |
| 596 | ip6Prefix = Ip6Prefix.valueOf( |
| 597 | match.get(MatchField.IPV6_SRC).getBytes(), |
| 598 | Ip6Prefix.MAX_MASK_LENGTH); |
| 599 | } |
| 600 | builder.matchIPv6Src(ip6Prefix); |
| 601 | break; |
| 602 | case IPV6_DST: |
| 603 | if (match.isPartiallyMasked(MatchField.IPV6_DST)) { |
| 604 | Masked<IPv6Address> maskedIp = match.getMasked(MatchField.IPV6_DST); |
| 605 | ip6Prefix = Ip6Prefix.valueOf( |
| 606 | maskedIp.getValue().getBytes(), |
| 607 | maskedIp.getMask().asCidrMaskLength()); |
| 608 | } else { |
| 609 | ip6Prefix = Ip6Prefix.valueOf( |
| 610 | match.get(MatchField.IPV6_DST).getBytes(), |
| 611 | Ip6Prefix.MAX_MASK_LENGTH); |
| 612 | } |
| 613 | builder.matchIPv6Dst(ip6Prefix); |
| 614 | break; |
| 615 | case IPV6_FLABEL: |
| 616 | int flowLabel = |
| 617 | match.get(MatchField.IPV6_FLABEL).getIPv6FlowLabelValue(); |
| 618 | builder.matchIPv6FlowLabel(flowLabel); |
| 619 | break; |
| 620 | case ICMPV6_TYPE: |
| 621 | byte icmpv6type = (byte) match.get(MatchField.ICMPV6_TYPE).getValue(); |
| 622 | builder.matchIcmpv6Type(icmpv6type); |
| 623 | break; |
| 624 | case ICMPV6_CODE: |
| 625 | byte icmpv6code = (byte) match.get(MatchField.ICMPV6_CODE).getValue(); |
| 626 | builder.matchIcmpv6Code(icmpv6code); |
| 627 | break; |
| 628 | case IPV6_ND_TARGET: |
| 629 | ip6Address = |
| 630 | Ip6Address.valueOf(match.get(MatchField.IPV6_ND_TARGET).getBytes()); |
| 631 | builder.matchIPv6NDTargetAddress(ip6Address); |
| 632 | break; |
| 633 | case IPV6_ND_SLL: |
| 634 | mac = MacAddress.valueOf(match.get(MatchField.IPV6_ND_SLL).getLong()); |
| 635 | builder.matchIPv6NDSourceLinkLayerAddress(mac); |
| 636 | break; |
| 637 | case IPV6_ND_TLL: |
| 638 | mac = MacAddress.valueOf(match.get(MatchField.IPV6_ND_TLL).getLong()); |
| 639 | builder.matchIPv6NDTargetLinkLayerAddress(mac); |
| 640 | break; |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 641 | case IPV6_EXTHDR: |
Charles M.C. Chan | 2184de1 | 2015-04-26 02:24:53 +0800 | [diff] [blame] | 642 | builder.matchIPv6ExthdrFlags((short) match.get(MatchField.IPV6_EXTHDR) |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 643 | .getValue()); |
| 644 | break; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 645 | case OCH_SIGID: |
Sho SHIMIZU | 4f828ee | 2015-05-28 09:38:21 -0700 | [diff] [blame] | 646 | CircuitSignalID sigId = match.get(MatchField.OCH_SIGID); |
| 647 | builder.add(matchLambda(Lambda.ochSignal( |
Sho SHIMIZU | c17042d | 2015-05-28 12:07:23 -0700 | [diff] [blame] | 648 | lookupGridType(sigId.getGridType()), lookupChannelSpacing(sigId.getChannelSpacing()), |
Sho SHIMIZU | 4f828ee | 2015-05-28 09:38:21 -0700 | [diff] [blame] | 649 | sigId.getChannelNumber(), sigId.getChannelSpacing()) |
| 650 | )); |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 651 | break; |
Praseed Balakrishnan | 2dd5abd | 2014-11-03 14:56:28 -0800 | [diff] [blame] | 652 | case OCH_SIGTYPE: |
Sho SHIMIZU | 4f828ee | 2015-05-28 09:38:21 -0700 | [diff] [blame] | 653 | U8 sigType = match.get(MatchField.OCH_SIGTYPE); |
Sho SHIMIZU | c17042d | 2015-05-28 12:07:23 -0700 | [diff] [blame] | 654 | builder.add(matchOchSignalType(lookupOchSignalType((byte) sigType.getValue()))); |
Praseed Balakrishnan | 2dd5abd | 2014-11-03 14:56:28 -0800 | [diff] [blame] | 655 | break; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 656 | case ARP_OP: |
| 657 | case ARP_SHA: |
| 658 | case ARP_SPA: |
| 659 | case ARP_THA: |
| 660 | case ARP_TPA: |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 661 | case MPLS_TC: |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 662 | case TUNNEL_ID: |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 663 | default: |
| 664 | log.warn("Match type {} not yet implemented.", field.id); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 665 | } |
| 666 | } |
| 667 | return builder.build(); |
| 668 | } |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 669 | } |