Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -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 | 83e090e | 2014-10-22 14:25:35 -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 | 83e090e | 2014-10-22 14:25:35 -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 | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
| 19 | import com.google.common.collect.ImmutableList; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 20 | import com.google.common.collect.Lists; |
Jonathan Hart | 8ef6d3b | 2015-03-08 21:21:27 -0700 | [diff] [blame] | 21 | import org.apache.commons.collections.ListUtils; |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 22 | import org.onlab.packet.IpAddress; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 23 | import org.onlab.packet.MacAddress; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 24 | import org.onlab.packet.MplsLabel; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 25 | import org.onlab.packet.VlanId; |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 26 | import org.onosproject.core.GroupId; |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 27 | import org.onosproject.net.PortNumber; |
| 28 | import org.onosproject.net.flow.instructions.Instruction; |
| 29 | import org.onosproject.net.flow.instructions.Instructions; |
tom | 1679e18 | 2014-10-09 13:50:45 -0700 | [diff] [blame] | 30 | |
Brian O'Connor | 6b52813 | 2015-03-10 16:39:52 -0700 | [diff] [blame] | 31 | import java.util.Collections; |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 32 | import java.util.List; |
| 33 | import java.util.Objects; |
Yuta HIGUCHI | 2809bf3 | 2014-10-20 22:44:12 -0700 | [diff] [blame] | 34 | |
Ray Milkey | 4250735 | 2015-03-20 15:16:10 -0700 | [diff] [blame] | 35 | import static com.google.common.base.Preconditions.checkNotNull; |
| 36 | |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Default traffic treatment implementation. |
| 39 | */ |
alshabib | 7b2748f | 2014-09-16 20:21:11 -0700 | [diff] [blame] | 40 | public final class DefaultTrafficTreatment implements TrafficTreatment { |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 41 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 42 | private final List<Instruction> immediate; |
| 43 | private final List<Instruction> deferred; |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 44 | private final List<Instruction> all; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 45 | private final Instructions.TableTypeTransition table; |
| 46 | |
| 47 | private final boolean hasClear; |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 48 | |
Brian O'Connor | 6b52813 | 2015-03-10 16:39:52 -0700 | [diff] [blame] | 49 | private static final DefaultTrafficTreatment EMPTY |
| 50 | = new DefaultTrafficTreatment(Collections.emptyList()); |
| 51 | |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 52 | /** |
| 53 | * Creates a new traffic treatment from the specified list of instructions. |
| 54 | * |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 55 | * @param immediate immediate instructions |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 56 | */ |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 57 | private DefaultTrafficTreatment(List<Instruction> immediate) { |
| 58 | this.immediate = ImmutableList.copyOf(checkNotNull(immediate)); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 59 | this.deferred = ImmutableList.of(); |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 60 | this.all = this.immediate; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 61 | this.hasClear = false; |
| 62 | this.table = null; |
| 63 | } |
| 64 | |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 65 | /** |
| 66 | * Creates a new traffic treatment from the specified list of instructions. |
| 67 | * |
| 68 | * @param deferred deferred instructions |
| 69 | * @param immediate immediate instructions |
| 70 | * @param table table transition instruction |
| 71 | * @param clear instruction to clear the deferred actions list |
| 72 | */ |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 73 | private DefaultTrafficTreatment(List<Instruction> deferred, |
| 74 | List<Instruction> immediate, |
| 75 | Instructions.TableTypeTransition table, |
| 76 | boolean clear) { |
Ray Milkey | 4250735 | 2015-03-20 15:16:10 -0700 | [diff] [blame] | 77 | this.immediate = ImmutableList.copyOf(checkNotNull(immediate)); |
| 78 | this.deferred = ImmutableList.copyOf(checkNotNull(deferred)); |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 79 | this.all = ListUtils.union(this.immediate, this.deferred); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 80 | this.table = table; |
| 81 | this.hasClear = clear; |
| 82 | |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | @Override |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 86 | public List<Instruction> deferred() { |
| 87 | return deferred; |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public List<Instruction> immediate() { |
| 92 | return immediate; |
| 93 | } |
| 94 | |
| 95 | @Override |
Jonathan Hart | 8ef6d3b | 2015-03-08 21:21:27 -0700 | [diff] [blame] | 96 | public List<Instruction> allInstructions() { |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 97 | return all; |
Jonathan Hart | 8ef6d3b | 2015-03-08 21:21:27 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | @Override |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 101 | public Instructions.TableTypeTransition tableTransition() { |
| 102 | return table; |
| 103 | } |
| 104 | |
| 105 | @Override |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 106 | public boolean clearedDeferred() { |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 107 | return hasClear; |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /** |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 111 | * Returns a new traffic treatment builder. |
| 112 | * |
| 113 | * @return traffic treatment builder |
| 114 | */ |
| 115 | public static TrafficTreatment.Builder builder() { |
| 116 | return new Builder(); |
| 117 | } |
| 118 | |
Jonathan Hart | 6e88c68 | 2014-10-21 17:05:25 -0700 | [diff] [blame] | 119 | /** |
Brian O'Connor | 6b52813 | 2015-03-10 16:39:52 -0700 | [diff] [blame] | 120 | * Returns an empty traffic treatment. |
| 121 | * |
| 122 | * @return empty traffic treatment |
| 123 | */ |
| 124 | public static TrafficTreatment emptyTreatment() { |
| 125 | return EMPTY; |
| 126 | } |
| 127 | |
| 128 | /** |
Jonathan Hart | 6e88c68 | 2014-10-21 17:05:25 -0700 | [diff] [blame] | 129 | * Returns a new traffic treatment builder primed to produce entities |
| 130 | * patterned after the supplied treatment. |
| 131 | * |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 132 | * @param treatment base treatment |
Jonathan Hart | 6e88c68 | 2014-10-21 17:05:25 -0700 | [diff] [blame] | 133 | * @return traffic treatment builder |
| 134 | */ |
| 135 | public static TrafficTreatment.Builder builder(TrafficTreatment treatment) { |
| 136 | return new Builder(treatment); |
| 137 | } |
| 138 | |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 139 | //FIXME: Order of instructions may affect hashcode |
| 140 | @Override |
| 141 | public int hashCode() { |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 142 | return Objects.hash(immediate, deferred, table); |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | @Override |
| 146 | public boolean equals(Object obj) { |
| 147 | if (this == obj) { |
| 148 | return true; |
| 149 | } |
| 150 | if (obj instanceof DefaultTrafficTreatment) { |
| 151 | DefaultTrafficTreatment that = (DefaultTrafficTreatment) obj; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 152 | return Objects.equals(immediate, that.immediate) && |
| 153 | Objects.equals(deferred, that.deferred) && |
| 154 | Objects.equals(table, that.table); |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 155 | |
| 156 | } |
| 157 | return false; |
| 158 | } |
| 159 | |
Jonathan Hart | d87aeca | 2014-10-21 10:42:52 -0700 | [diff] [blame] | 160 | @Override |
| 161 | public String toString() { |
| 162 | return MoreObjects.toStringHelper(getClass()) |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 163 | .add("immediate", immediate) |
| 164 | .add("deferred", deferred) |
| 165 | .add("transition", table == null ? "None" : table.toString()) |
| 166 | .add("cleared", hasClear) |
Jonathan Hart | d87aeca | 2014-10-21 10:42:52 -0700 | [diff] [blame] | 167 | .toString(); |
| 168 | } |
| 169 | |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 170 | /** |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 171 | * Builds a list of treatments following the following order. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 172 | * Modifications -> Group -> Output (including drop) |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 173 | */ |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 174 | public static final class Builder implements TrafficTreatment.Builder { |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 175 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 176 | boolean clear = false; |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 177 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 178 | Instructions.TableTypeTransition table; |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 179 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 180 | List<Instruction> deferred = Lists.newLinkedList(); |
| 181 | |
| 182 | List<Instruction> immediate = Lists.newLinkedList(); |
| 183 | |
| 184 | List<Instruction> current = immediate; |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 185 | |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 186 | // Creates a new builder |
| 187 | private Builder() { |
| 188 | } |
| 189 | |
Jonathan Hart | 6e88c68 | 2014-10-21 17:05:25 -0700 | [diff] [blame] | 190 | // Creates a new builder based off an existing treatment |
| 191 | private Builder(TrafficTreatment treatment) { |
Jonathan Hart | 4a0ba56 | 2015-03-23 17:23:33 -0700 | [diff] [blame] | 192 | deferred(); |
| 193 | treatment.deferred().forEach(i -> add(i)); |
| 194 | |
| 195 | immediate(); |
| 196 | treatment.immediate().forEach(i -> add(i)); |
| 197 | |
| 198 | clear = treatment.clearedDeferred(); |
Jonathan Hart | 6e88c68 | 2014-10-21 17:05:25 -0700 | [diff] [blame] | 199 | } |
| 200 | |
alshabib | 8ca5390 | 2014-10-07 13:11:17 -0700 | [diff] [blame] | 201 | @Override |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 202 | public Builder add(Instruction instruction) { |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 203 | |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 204 | switch (instruction.type()) { |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 205 | case DROP: |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 206 | case OUTPUT: |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 207 | case GROUP: |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 208 | case L0MODIFICATION: |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 209 | case L2MODIFICATION: |
| 210 | case L3MODIFICATION: |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 211 | current.add(instruction); |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 212 | break; |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 213 | case TABLE: |
| 214 | table = (Instructions.TableTypeTransition) instruction; |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 215 | break; |
| 216 | default: |
tom | 1679e18 | 2014-10-09 13:50:45 -0700 | [diff] [blame] | 217 | throw new IllegalArgumentException("Unknown instruction type: " + |
| 218 | instruction.type()); |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 219 | } |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 220 | |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 221 | return this; |
| 222 | } |
| 223 | |
| 224 | @Override |
Thomas Vachuska | f4df005 | 2015-01-06 12:30:11 -0800 | [diff] [blame] | 225 | public Builder drop() { |
| 226 | return add(Instructions.createDrop()); |
| 227 | } |
| 228 | |
| 229 | @Override |
| 230 | public Builder punt() { |
| 231 | return add(Instructions.createOutput(PortNumber.CONTROLLER)); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | @Override |
| 235 | public Builder setOutput(PortNumber number) { |
| 236 | return add(Instructions.createOutput(number)); |
| 237 | } |
| 238 | |
| 239 | @Override |
| 240 | public Builder setEthSrc(MacAddress addr) { |
| 241 | return add(Instructions.modL2Src(addr)); |
| 242 | } |
| 243 | |
| 244 | @Override |
| 245 | public Builder setEthDst(MacAddress addr) { |
| 246 | return add(Instructions.modL2Dst(addr)); |
| 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public Builder setVlanId(VlanId id) { |
| 251 | return add(Instructions.modVlanId(id)); |
| 252 | } |
| 253 | |
| 254 | @Override |
| 255 | public Builder setVlanPcp(Byte pcp) { |
| 256 | return add(Instructions.modVlanPcp(pcp)); |
| 257 | } |
| 258 | |
| 259 | @Override |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 260 | public Builder setIpSrc(IpAddress addr) { |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 261 | return add(Instructions.modL3Src(addr)); |
| 262 | } |
| 263 | |
| 264 | @Override |
Pavlin Radoslavov | 855ea2d | 2014-10-30 15:32:39 -0700 | [diff] [blame] | 265 | public Builder setIpDst(IpAddress addr) { |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 266 | return add(Instructions.modL3Dst(addr)); |
| 267 | } |
| 268 | |
| 269 | @Override |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 270 | public Builder decNwTtl() { |
| 271 | return add(Instructions.decNwTtl()); |
| 272 | } |
| 273 | |
| 274 | @Override |
| 275 | public Builder copyTtlIn() { |
| 276 | return add(Instructions.copyTtlIn()); |
| 277 | } |
| 278 | |
| 279 | @Override |
| 280 | public Builder copyTtlOut() { |
| 281 | return add(Instructions.copyTtlOut()); |
| 282 | } |
| 283 | |
| 284 | @Override |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 285 | public Builder pushMpls() { |
| 286 | return add(Instructions.pushMpls()); |
| 287 | } |
| 288 | |
| 289 | @Override |
| 290 | public Builder popMpls() { |
| 291 | return add(Instructions.popMpls()); |
| 292 | } |
| 293 | |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 294 | @Override |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 295 | public Builder popMpls(Short etherType) { |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 296 | return add(Instructions.popMpls(etherType)); |
| 297 | } |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 298 | |
| 299 | @Override |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 300 | public Builder setMpls(MplsLabel mplsLabel) { |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 301 | return add(Instructions.modMplsLabel(mplsLabel)); |
| 302 | } |
| 303 | |
| 304 | @Override |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 305 | public Builder decMplsTtl() { |
| 306 | return add(Instructions.decMplsTtl()); |
| 307 | } |
| 308 | |
| 309 | @Override |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 310 | public Builder setLambda(short lambda) { |
| 311 | return add(Instructions.modL0Lambda(lambda)); |
| 312 | } |
| 313 | |
| 314 | @Override |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 315 | public Builder group(GroupId groupId) { |
| 316 | return add(Instructions.createGroup(groupId)); |
| 317 | } |
| 318 | |
| 319 | @Override |
Saurav Das | fbe25c5 | 2015-03-04 11:12:00 -0800 | [diff] [blame] | 320 | public Builder popVlan() { |
| 321 | return add(Instructions.popVlan()); |
| 322 | } |
| 323 | |
| 324 | @Override |
Jonathan Hart | 54b406b | 2015-03-06 16:24:14 -0800 | [diff] [blame] | 325 | public Builder pushVlan() { |
| 326 | return add(Instructions.pushVlan()); |
| 327 | } |
| 328 | |
| 329 | @Override |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 330 | public Builder transition(FlowRule.Type type) { |
| 331 | return add(Instructions.transition(type)); |
| 332 | } |
| 333 | |
| 334 | @Override |
| 335 | public Builder immediate() { |
| 336 | current = immediate; |
| 337 | return this; |
| 338 | } |
| 339 | |
| 340 | @Override |
| 341 | public Builder deferred() { |
| 342 | current = deferred; |
| 343 | return this; |
| 344 | } |
| 345 | |
| 346 | @Override |
| 347 | public Builder wipeDeferred() { |
| 348 | clear = true; |
| 349 | return this; |
| 350 | } |
| 351 | |
| 352 | @Override |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 353 | public TrafficTreatment build() { |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 354 | if (deferred.size() == 0 && immediate.size() == 0 |
| 355 | && table == null && !clear) { |
| 356 | drop(); |
alshabib | 030111e | 2014-09-15 15:56:42 -0700 | [diff] [blame] | 357 | } |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 358 | return new DefaultTrafficTreatment(deferred, immediate, table, clear); |
alshabib | 1d4cace | 2014-09-13 19:16:26 -0700 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | } |
| 362 | |
| 363 | } |