alshabib | 86ac11c | 2014-08-14 16:14:41 -0700 | [diff] [blame^] | 1 | // Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | // Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | // Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 4 | // This library was generated by the LoxiGen Compiler. |
| 5 | // See the file LICENSE.txt which should have been included in the source distribution |
| 6 | |
| 7 | // Automatically generated by LOXI from template of_class.java |
| 8 | // Do not modify |
| 9 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver13; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; |
| 28 | import java.util.Set; |
| 29 | import com.google.common.collect.ImmutableSet; |
| 30 | import java.util.List; |
| 31 | import com.google.common.collect.ImmutableList; |
| 32 | import org.jboss.netty.buffer.ChannelBuffer; |
| 33 | import com.google.common.hash.PrimitiveSink; |
| 34 | import com.google.common.hash.Funnel; |
| 35 | |
| 36 | class OFFlowStatsEntryVer13 implements OFFlowStatsEntry { |
| 37 | private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsEntryVer13.class); |
| 38 | // version: 1.3 |
| 39 | final static byte WIRE_VERSION = 4; |
| 40 | final static int MINIMUM_LENGTH = 56; |
| 41 | |
| 42 | private final static TableId DEFAULT_TABLE_ID = TableId.ALL; |
| 43 | private final static long DEFAULT_DURATION_SEC = 0x0L; |
| 44 | private final static long DEFAULT_DURATION_NSEC = 0x0L; |
| 45 | private final static int DEFAULT_PRIORITY = 0x0; |
| 46 | private final static int DEFAULT_IDLE_TIMEOUT = 0x0; |
| 47 | private final static int DEFAULT_HARD_TIMEOUT = 0x0; |
| 48 | private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of(); |
| 49 | private final static U64 DEFAULT_COOKIE = U64.ZERO; |
| 50 | private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO; |
| 51 | private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO; |
| 52 | private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL; |
| 53 | private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of(); |
| 54 | |
| 55 | // OF message fields |
| 56 | private final TableId tableId; |
| 57 | private final long durationSec; |
| 58 | private final long durationNsec; |
| 59 | private final int priority; |
| 60 | private final int idleTimeout; |
| 61 | private final int hardTimeout; |
| 62 | private final Set<OFFlowModFlags> flags; |
| 63 | private final U64 cookie; |
| 64 | private final U64 packetCount; |
| 65 | private final U64 byteCount; |
| 66 | private final Match match; |
| 67 | private final List<OFInstruction> instructions; |
| 68 | // |
| 69 | // Immutable default instance |
| 70 | final static OFFlowStatsEntryVer13 DEFAULT = new OFFlowStatsEntryVer13( |
| 71 | DEFAULT_TABLE_ID, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_PRIORITY, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_FLAGS, DEFAULT_COOKIE, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS |
| 72 | ); |
| 73 | |
| 74 | // package private constructor - used by readers, builders, and factory |
| 75 | OFFlowStatsEntryVer13(TableId tableId, long durationSec, long durationNsec, int priority, int idleTimeout, int hardTimeout, Set<OFFlowModFlags> flags, U64 cookie, U64 packetCount, U64 byteCount, Match match, List<OFInstruction> instructions) { |
| 76 | this.tableId = tableId; |
| 77 | this.durationSec = durationSec; |
| 78 | this.durationNsec = durationNsec; |
| 79 | this.priority = priority; |
| 80 | this.idleTimeout = idleTimeout; |
| 81 | this.hardTimeout = hardTimeout; |
| 82 | this.flags = flags; |
| 83 | this.cookie = cookie; |
| 84 | this.packetCount = packetCount; |
| 85 | this.byteCount = byteCount; |
| 86 | this.match = match; |
| 87 | this.instructions = instructions; |
| 88 | } |
| 89 | |
| 90 | // Accessors for OF message fields |
| 91 | @Override |
| 92 | public TableId getTableId() { |
| 93 | return tableId; |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public long getDurationSec() { |
| 98 | return durationSec; |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public long getDurationNsec() { |
| 103 | return durationNsec; |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public int getPriority() { |
| 108 | return priority; |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public int getIdleTimeout() { |
| 113 | return idleTimeout; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public int getHardTimeout() { |
| 118 | return hardTimeout; |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public U64 getCookie() { |
| 123 | return cookie; |
| 124 | } |
| 125 | |
| 126 | @Override |
| 127 | public U64 getPacketCount() { |
| 128 | return packetCount; |
| 129 | } |
| 130 | |
| 131 | @Override |
| 132 | public U64 getByteCount() { |
| 133 | return byteCount; |
| 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public Match getMatch() { |
| 138 | return match; |
| 139 | } |
| 140 | |
| 141 | @Override |
| 142 | public List<OFInstruction> getInstructions() { |
| 143 | return instructions; |
| 144 | } |
| 145 | |
| 146 | @Override |
| 147 | public List<OFAction> getActions()throws UnsupportedOperationException { |
| 148 | throw new UnsupportedOperationException("Property actions not supported in version 1.3"); |
| 149 | } |
| 150 | |
| 151 | @Override |
| 152 | public Set<OFFlowModFlags> getFlags() { |
| 153 | return flags; |
| 154 | } |
| 155 | |
| 156 | @Override |
| 157 | public OFVersion getVersion() { |
| 158 | return OFVersion.OF_13; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | |
| 163 | public OFFlowStatsEntry.Builder createBuilder() { |
| 164 | return new BuilderWithParent(this); |
| 165 | } |
| 166 | |
| 167 | static class BuilderWithParent implements OFFlowStatsEntry.Builder { |
| 168 | final OFFlowStatsEntryVer13 parentMessage; |
| 169 | |
| 170 | // OF message fields |
| 171 | private boolean tableIdSet; |
| 172 | private TableId tableId; |
| 173 | private boolean durationSecSet; |
| 174 | private long durationSec; |
| 175 | private boolean durationNsecSet; |
| 176 | private long durationNsec; |
| 177 | private boolean prioritySet; |
| 178 | private int priority; |
| 179 | private boolean idleTimeoutSet; |
| 180 | private int idleTimeout; |
| 181 | private boolean hardTimeoutSet; |
| 182 | private int hardTimeout; |
| 183 | private boolean flagsSet; |
| 184 | private Set<OFFlowModFlags> flags; |
| 185 | private boolean cookieSet; |
| 186 | private U64 cookie; |
| 187 | private boolean packetCountSet; |
| 188 | private U64 packetCount; |
| 189 | private boolean byteCountSet; |
| 190 | private U64 byteCount; |
| 191 | private boolean matchSet; |
| 192 | private Match match; |
| 193 | private boolean instructionsSet; |
| 194 | private List<OFInstruction> instructions; |
| 195 | |
| 196 | BuilderWithParent(OFFlowStatsEntryVer13 parentMessage) { |
| 197 | this.parentMessage = parentMessage; |
| 198 | } |
| 199 | |
| 200 | @Override |
| 201 | public TableId getTableId() { |
| 202 | return tableId; |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public OFFlowStatsEntry.Builder setTableId(TableId tableId) { |
| 207 | this.tableId = tableId; |
| 208 | this.tableIdSet = true; |
| 209 | return this; |
| 210 | } |
| 211 | @Override |
| 212 | public long getDurationSec() { |
| 213 | return durationSec; |
| 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public OFFlowStatsEntry.Builder setDurationSec(long durationSec) { |
| 218 | this.durationSec = durationSec; |
| 219 | this.durationSecSet = true; |
| 220 | return this; |
| 221 | } |
| 222 | @Override |
| 223 | public long getDurationNsec() { |
| 224 | return durationNsec; |
| 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) { |
| 229 | this.durationNsec = durationNsec; |
| 230 | this.durationNsecSet = true; |
| 231 | return this; |
| 232 | } |
| 233 | @Override |
| 234 | public int getPriority() { |
| 235 | return priority; |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public OFFlowStatsEntry.Builder setPriority(int priority) { |
| 240 | this.priority = priority; |
| 241 | this.prioritySet = true; |
| 242 | return this; |
| 243 | } |
| 244 | @Override |
| 245 | public int getIdleTimeout() { |
| 246 | return idleTimeout; |
| 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) { |
| 251 | this.idleTimeout = idleTimeout; |
| 252 | this.idleTimeoutSet = true; |
| 253 | return this; |
| 254 | } |
| 255 | @Override |
| 256 | public int getHardTimeout() { |
| 257 | return hardTimeout; |
| 258 | } |
| 259 | |
| 260 | @Override |
| 261 | public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) { |
| 262 | this.hardTimeout = hardTimeout; |
| 263 | this.hardTimeoutSet = true; |
| 264 | return this; |
| 265 | } |
| 266 | @Override |
| 267 | public U64 getCookie() { |
| 268 | return cookie; |
| 269 | } |
| 270 | |
| 271 | @Override |
| 272 | public OFFlowStatsEntry.Builder setCookie(U64 cookie) { |
| 273 | this.cookie = cookie; |
| 274 | this.cookieSet = true; |
| 275 | return this; |
| 276 | } |
| 277 | @Override |
| 278 | public U64 getPacketCount() { |
| 279 | return packetCount; |
| 280 | } |
| 281 | |
| 282 | @Override |
| 283 | public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) { |
| 284 | this.packetCount = packetCount; |
| 285 | this.packetCountSet = true; |
| 286 | return this; |
| 287 | } |
| 288 | @Override |
| 289 | public U64 getByteCount() { |
| 290 | return byteCount; |
| 291 | } |
| 292 | |
| 293 | @Override |
| 294 | public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) { |
| 295 | this.byteCount = byteCount; |
| 296 | this.byteCountSet = true; |
| 297 | return this; |
| 298 | } |
| 299 | @Override |
| 300 | public Match getMatch() { |
| 301 | return match; |
| 302 | } |
| 303 | |
| 304 | @Override |
| 305 | public OFFlowStatsEntry.Builder setMatch(Match match) { |
| 306 | this.match = match; |
| 307 | this.matchSet = true; |
| 308 | return this; |
| 309 | } |
| 310 | @Override |
| 311 | public List<OFInstruction> getInstructions() { |
| 312 | return instructions; |
| 313 | } |
| 314 | |
| 315 | @Override |
| 316 | public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) { |
| 317 | this.instructions = instructions; |
| 318 | this.instructionsSet = true; |
| 319 | return this; |
| 320 | } |
| 321 | @Override |
| 322 | public List<OFAction> getActions()throws UnsupportedOperationException { |
| 323 | throw new UnsupportedOperationException("Property actions not supported in version 1.3"); |
| 324 | } |
| 325 | |
| 326 | @Override |
| 327 | public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException { |
| 328 | throw new UnsupportedOperationException("Property actions not supported in version 1.3"); |
| 329 | } |
| 330 | @Override |
| 331 | public Set<OFFlowModFlags> getFlags() { |
| 332 | return flags; |
| 333 | } |
| 334 | |
| 335 | @Override |
| 336 | public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) { |
| 337 | this.flags = flags; |
| 338 | this.flagsSet = true; |
| 339 | return this; |
| 340 | } |
| 341 | @Override |
| 342 | public OFVersion getVersion() { |
| 343 | return OFVersion.OF_13; |
| 344 | } |
| 345 | |
| 346 | |
| 347 | |
| 348 | @Override |
| 349 | public OFFlowStatsEntry build() { |
| 350 | TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId; |
| 351 | if(tableId == null) |
| 352 | throw new NullPointerException("Property tableId must not be null"); |
| 353 | long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec; |
| 354 | long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec; |
| 355 | int priority = this.prioritySet ? this.priority : parentMessage.priority; |
| 356 | int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout; |
| 357 | int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout; |
| 358 | Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags; |
| 359 | if(flags == null) |
| 360 | throw new NullPointerException("Property flags must not be null"); |
| 361 | U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie; |
| 362 | if(cookie == null) |
| 363 | throw new NullPointerException("Property cookie must not be null"); |
| 364 | U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount; |
| 365 | if(packetCount == null) |
| 366 | throw new NullPointerException("Property packetCount must not be null"); |
| 367 | U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount; |
| 368 | if(byteCount == null) |
| 369 | throw new NullPointerException("Property byteCount must not be null"); |
| 370 | Match match = this.matchSet ? this.match : parentMessage.match; |
| 371 | if(match == null) |
| 372 | throw new NullPointerException("Property match must not be null"); |
| 373 | List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions; |
| 374 | if(instructions == null) |
| 375 | throw new NullPointerException("Property instructions must not be null"); |
| 376 | |
| 377 | // |
| 378 | return new OFFlowStatsEntryVer13( |
| 379 | tableId, |
| 380 | durationSec, |
| 381 | durationNsec, |
| 382 | priority, |
| 383 | idleTimeout, |
| 384 | hardTimeout, |
| 385 | flags, |
| 386 | cookie, |
| 387 | packetCount, |
| 388 | byteCount, |
| 389 | match, |
| 390 | instructions |
| 391 | ); |
| 392 | } |
| 393 | |
| 394 | } |
| 395 | |
| 396 | static class Builder implements OFFlowStatsEntry.Builder { |
| 397 | // OF message fields |
| 398 | private boolean tableIdSet; |
| 399 | private TableId tableId; |
| 400 | private boolean durationSecSet; |
| 401 | private long durationSec; |
| 402 | private boolean durationNsecSet; |
| 403 | private long durationNsec; |
| 404 | private boolean prioritySet; |
| 405 | private int priority; |
| 406 | private boolean idleTimeoutSet; |
| 407 | private int idleTimeout; |
| 408 | private boolean hardTimeoutSet; |
| 409 | private int hardTimeout; |
| 410 | private boolean flagsSet; |
| 411 | private Set<OFFlowModFlags> flags; |
| 412 | private boolean cookieSet; |
| 413 | private U64 cookie; |
| 414 | private boolean packetCountSet; |
| 415 | private U64 packetCount; |
| 416 | private boolean byteCountSet; |
| 417 | private U64 byteCount; |
| 418 | private boolean matchSet; |
| 419 | private Match match; |
| 420 | private boolean instructionsSet; |
| 421 | private List<OFInstruction> instructions; |
| 422 | |
| 423 | @Override |
| 424 | public TableId getTableId() { |
| 425 | return tableId; |
| 426 | } |
| 427 | |
| 428 | @Override |
| 429 | public OFFlowStatsEntry.Builder setTableId(TableId tableId) { |
| 430 | this.tableId = tableId; |
| 431 | this.tableIdSet = true; |
| 432 | return this; |
| 433 | } |
| 434 | @Override |
| 435 | public long getDurationSec() { |
| 436 | return durationSec; |
| 437 | } |
| 438 | |
| 439 | @Override |
| 440 | public OFFlowStatsEntry.Builder setDurationSec(long durationSec) { |
| 441 | this.durationSec = durationSec; |
| 442 | this.durationSecSet = true; |
| 443 | return this; |
| 444 | } |
| 445 | @Override |
| 446 | public long getDurationNsec() { |
| 447 | return durationNsec; |
| 448 | } |
| 449 | |
| 450 | @Override |
| 451 | public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) { |
| 452 | this.durationNsec = durationNsec; |
| 453 | this.durationNsecSet = true; |
| 454 | return this; |
| 455 | } |
| 456 | @Override |
| 457 | public int getPriority() { |
| 458 | return priority; |
| 459 | } |
| 460 | |
| 461 | @Override |
| 462 | public OFFlowStatsEntry.Builder setPriority(int priority) { |
| 463 | this.priority = priority; |
| 464 | this.prioritySet = true; |
| 465 | return this; |
| 466 | } |
| 467 | @Override |
| 468 | public int getIdleTimeout() { |
| 469 | return idleTimeout; |
| 470 | } |
| 471 | |
| 472 | @Override |
| 473 | public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) { |
| 474 | this.idleTimeout = idleTimeout; |
| 475 | this.idleTimeoutSet = true; |
| 476 | return this; |
| 477 | } |
| 478 | @Override |
| 479 | public int getHardTimeout() { |
| 480 | return hardTimeout; |
| 481 | } |
| 482 | |
| 483 | @Override |
| 484 | public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) { |
| 485 | this.hardTimeout = hardTimeout; |
| 486 | this.hardTimeoutSet = true; |
| 487 | return this; |
| 488 | } |
| 489 | @Override |
| 490 | public U64 getCookie() { |
| 491 | return cookie; |
| 492 | } |
| 493 | |
| 494 | @Override |
| 495 | public OFFlowStatsEntry.Builder setCookie(U64 cookie) { |
| 496 | this.cookie = cookie; |
| 497 | this.cookieSet = true; |
| 498 | return this; |
| 499 | } |
| 500 | @Override |
| 501 | public U64 getPacketCount() { |
| 502 | return packetCount; |
| 503 | } |
| 504 | |
| 505 | @Override |
| 506 | public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) { |
| 507 | this.packetCount = packetCount; |
| 508 | this.packetCountSet = true; |
| 509 | return this; |
| 510 | } |
| 511 | @Override |
| 512 | public U64 getByteCount() { |
| 513 | return byteCount; |
| 514 | } |
| 515 | |
| 516 | @Override |
| 517 | public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) { |
| 518 | this.byteCount = byteCount; |
| 519 | this.byteCountSet = true; |
| 520 | return this; |
| 521 | } |
| 522 | @Override |
| 523 | public Match getMatch() { |
| 524 | return match; |
| 525 | } |
| 526 | |
| 527 | @Override |
| 528 | public OFFlowStatsEntry.Builder setMatch(Match match) { |
| 529 | this.match = match; |
| 530 | this.matchSet = true; |
| 531 | return this; |
| 532 | } |
| 533 | @Override |
| 534 | public List<OFInstruction> getInstructions() { |
| 535 | return instructions; |
| 536 | } |
| 537 | |
| 538 | @Override |
| 539 | public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) { |
| 540 | this.instructions = instructions; |
| 541 | this.instructionsSet = true; |
| 542 | return this; |
| 543 | } |
| 544 | @Override |
| 545 | public List<OFAction> getActions()throws UnsupportedOperationException { |
| 546 | throw new UnsupportedOperationException("Property actions not supported in version 1.3"); |
| 547 | } |
| 548 | |
| 549 | @Override |
| 550 | public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException { |
| 551 | throw new UnsupportedOperationException("Property actions not supported in version 1.3"); |
| 552 | } |
| 553 | @Override |
| 554 | public Set<OFFlowModFlags> getFlags() { |
| 555 | return flags; |
| 556 | } |
| 557 | |
| 558 | @Override |
| 559 | public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) { |
| 560 | this.flags = flags; |
| 561 | this.flagsSet = true; |
| 562 | return this; |
| 563 | } |
| 564 | @Override |
| 565 | public OFVersion getVersion() { |
| 566 | return OFVersion.OF_13; |
| 567 | } |
| 568 | |
| 569 | // |
| 570 | @Override |
| 571 | public OFFlowStatsEntry build() { |
| 572 | TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID; |
| 573 | if(tableId == null) |
| 574 | throw new NullPointerException("Property tableId must not be null"); |
| 575 | long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC; |
| 576 | long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC; |
| 577 | int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY; |
| 578 | int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT; |
| 579 | int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT; |
| 580 | Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS; |
| 581 | if(flags == null) |
| 582 | throw new NullPointerException("Property flags must not be null"); |
| 583 | U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE; |
| 584 | if(cookie == null) |
| 585 | throw new NullPointerException("Property cookie must not be null"); |
| 586 | U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT; |
| 587 | if(packetCount == null) |
| 588 | throw new NullPointerException("Property packetCount must not be null"); |
| 589 | U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT; |
| 590 | if(byteCount == null) |
| 591 | throw new NullPointerException("Property byteCount must not be null"); |
| 592 | Match match = this.matchSet ? this.match : DEFAULT_MATCH; |
| 593 | if(match == null) |
| 594 | throw new NullPointerException("Property match must not be null"); |
| 595 | List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS; |
| 596 | if(instructions == null) |
| 597 | throw new NullPointerException("Property instructions must not be null"); |
| 598 | |
| 599 | |
| 600 | return new OFFlowStatsEntryVer13( |
| 601 | tableId, |
| 602 | durationSec, |
| 603 | durationNsec, |
| 604 | priority, |
| 605 | idleTimeout, |
| 606 | hardTimeout, |
| 607 | flags, |
| 608 | cookie, |
| 609 | packetCount, |
| 610 | byteCount, |
| 611 | match, |
| 612 | instructions |
| 613 | ); |
| 614 | } |
| 615 | |
| 616 | } |
| 617 | |
| 618 | |
| 619 | final static Reader READER = new Reader(); |
| 620 | static class Reader implements OFMessageReader<OFFlowStatsEntry> { |
| 621 | @Override |
| 622 | public OFFlowStatsEntry readFrom(ChannelBuffer bb) throws OFParseError { |
| 623 | int start = bb.readerIndex(); |
| 624 | int length = U16.f(bb.readShort()); |
| 625 | if(length < MINIMUM_LENGTH) |
| 626 | throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length); |
| 627 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 628 | // Buffer does not have all data yet |
| 629 | bb.readerIndex(start); |
| 630 | return null; |
| 631 | } |
| 632 | if(logger.isTraceEnabled()) |
| 633 | logger.trace("readFrom - length={}", length); |
| 634 | TableId tableId = TableId.readByte(bb); |
| 635 | // pad: 1 bytes |
| 636 | bb.skipBytes(1); |
| 637 | long durationSec = U32.f(bb.readInt()); |
| 638 | long durationNsec = U32.f(bb.readInt()); |
| 639 | int priority = U16.f(bb.readShort()); |
| 640 | int idleTimeout = U16.f(bb.readShort()); |
| 641 | int hardTimeout = U16.f(bb.readShort()); |
| 642 | Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer13.readFrom(bb); |
| 643 | // pad: 4 bytes |
| 644 | bb.skipBytes(4); |
| 645 | U64 cookie = U64.ofRaw(bb.readLong()); |
| 646 | U64 packetCount = U64.ofRaw(bb.readLong()); |
| 647 | U64 byteCount = U64.ofRaw(bb.readLong()); |
| 648 | Match match = ChannelUtilsVer13.readOFMatch(bb); |
| 649 | List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer13.READER); |
| 650 | |
| 651 | OFFlowStatsEntryVer13 flowStatsEntryVer13 = new OFFlowStatsEntryVer13( |
| 652 | tableId, |
| 653 | durationSec, |
| 654 | durationNsec, |
| 655 | priority, |
| 656 | idleTimeout, |
| 657 | hardTimeout, |
| 658 | flags, |
| 659 | cookie, |
| 660 | packetCount, |
| 661 | byteCount, |
| 662 | match, |
| 663 | instructions |
| 664 | ); |
| 665 | if(logger.isTraceEnabled()) |
| 666 | logger.trace("readFrom - read={}", flowStatsEntryVer13); |
| 667 | return flowStatsEntryVer13; |
| 668 | } |
| 669 | } |
| 670 | |
| 671 | public void putTo(PrimitiveSink sink) { |
| 672 | FUNNEL.funnel(this, sink); |
| 673 | } |
| 674 | |
| 675 | final static OFFlowStatsEntryVer13Funnel FUNNEL = new OFFlowStatsEntryVer13Funnel(); |
| 676 | static class OFFlowStatsEntryVer13Funnel implements Funnel<OFFlowStatsEntryVer13> { |
| 677 | private static final long serialVersionUID = 1L; |
| 678 | @Override |
| 679 | public void funnel(OFFlowStatsEntryVer13 message, PrimitiveSink sink) { |
| 680 | // FIXME: skip funnel of length |
| 681 | message.tableId.putTo(sink); |
| 682 | // skip pad (1 bytes) |
| 683 | sink.putLong(message.durationSec); |
| 684 | sink.putLong(message.durationNsec); |
| 685 | sink.putInt(message.priority); |
| 686 | sink.putInt(message.idleTimeout); |
| 687 | sink.putInt(message.hardTimeout); |
| 688 | OFFlowModFlagsSerializerVer13.putTo(message.flags, sink); |
| 689 | // skip pad (4 bytes) |
| 690 | message.cookie.putTo(sink); |
| 691 | message.packetCount.putTo(sink); |
| 692 | message.byteCount.putTo(sink); |
| 693 | message.match.putTo(sink); |
| 694 | FunnelUtils.putList(message.instructions, sink); |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | |
| 699 | public void writeTo(ChannelBuffer bb) { |
| 700 | WRITER.write(bb, this); |
| 701 | } |
| 702 | |
| 703 | final static Writer WRITER = new Writer(); |
| 704 | static class Writer implements OFMessageWriter<OFFlowStatsEntryVer13> { |
| 705 | @Override |
| 706 | public void write(ChannelBuffer bb, OFFlowStatsEntryVer13 message) { |
| 707 | int startIndex = bb.writerIndex(); |
| 708 | // length is length of variable message, will be updated at the end |
| 709 | int lengthIndex = bb.writerIndex(); |
| 710 | bb.writeShort(U16.t(0)); |
| 711 | |
| 712 | message.tableId.writeByte(bb); |
| 713 | // pad: 1 bytes |
| 714 | bb.writeZero(1); |
| 715 | bb.writeInt(U32.t(message.durationSec)); |
| 716 | bb.writeInt(U32.t(message.durationNsec)); |
| 717 | bb.writeShort(U16.t(message.priority)); |
| 718 | bb.writeShort(U16.t(message.idleTimeout)); |
| 719 | bb.writeShort(U16.t(message.hardTimeout)); |
| 720 | OFFlowModFlagsSerializerVer13.writeTo(bb, message.flags); |
| 721 | // pad: 4 bytes |
| 722 | bb.writeZero(4); |
| 723 | bb.writeLong(message.cookie.getValue()); |
| 724 | bb.writeLong(message.packetCount.getValue()); |
| 725 | bb.writeLong(message.byteCount.getValue()); |
| 726 | message.match.writeTo(bb); |
| 727 | ChannelUtils.writeList(bb, message.instructions); |
| 728 | |
| 729 | // update length field |
| 730 | int length = bb.writerIndex() - startIndex; |
| 731 | bb.setShort(lengthIndex, length); |
| 732 | |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | @Override |
| 737 | public String toString() { |
| 738 | StringBuilder b = new StringBuilder("OFFlowStatsEntryVer13("); |
| 739 | b.append("tableId=").append(tableId); |
| 740 | b.append(", "); |
| 741 | b.append("durationSec=").append(durationSec); |
| 742 | b.append(", "); |
| 743 | b.append("durationNsec=").append(durationNsec); |
| 744 | b.append(", "); |
| 745 | b.append("priority=").append(priority); |
| 746 | b.append(", "); |
| 747 | b.append("idleTimeout=").append(idleTimeout); |
| 748 | b.append(", "); |
| 749 | b.append("hardTimeout=").append(hardTimeout); |
| 750 | b.append(", "); |
| 751 | b.append("flags=").append(flags); |
| 752 | b.append(", "); |
| 753 | b.append("cookie=").append(cookie); |
| 754 | b.append(", "); |
| 755 | b.append("packetCount=").append(packetCount); |
| 756 | b.append(", "); |
| 757 | b.append("byteCount=").append(byteCount); |
| 758 | b.append(", "); |
| 759 | b.append("match=").append(match); |
| 760 | b.append(", "); |
| 761 | b.append("instructions=").append(instructions); |
| 762 | b.append(")"); |
| 763 | return b.toString(); |
| 764 | } |
| 765 | |
| 766 | @Override |
| 767 | public boolean equals(Object obj) { |
| 768 | if (this == obj) |
| 769 | return true; |
| 770 | if (obj == null) |
| 771 | return false; |
| 772 | if (getClass() != obj.getClass()) |
| 773 | return false; |
| 774 | OFFlowStatsEntryVer13 other = (OFFlowStatsEntryVer13) obj; |
| 775 | |
| 776 | if (tableId == null) { |
| 777 | if (other.tableId != null) |
| 778 | return false; |
| 779 | } else if (!tableId.equals(other.tableId)) |
| 780 | return false; |
| 781 | if( durationSec != other.durationSec) |
| 782 | return false; |
| 783 | if( durationNsec != other.durationNsec) |
| 784 | return false; |
| 785 | if( priority != other.priority) |
| 786 | return false; |
| 787 | if( idleTimeout != other.idleTimeout) |
| 788 | return false; |
| 789 | if( hardTimeout != other.hardTimeout) |
| 790 | return false; |
| 791 | if (flags == null) { |
| 792 | if (other.flags != null) |
| 793 | return false; |
| 794 | } else if (!flags.equals(other.flags)) |
| 795 | return false; |
| 796 | if (cookie == null) { |
| 797 | if (other.cookie != null) |
| 798 | return false; |
| 799 | } else if (!cookie.equals(other.cookie)) |
| 800 | return false; |
| 801 | if (packetCount == null) { |
| 802 | if (other.packetCount != null) |
| 803 | return false; |
| 804 | } else if (!packetCount.equals(other.packetCount)) |
| 805 | return false; |
| 806 | if (byteCount == null) { |
| 807 | if (other.byteCount != null) |
| 808 | return false; |
| 809 | } else if (!byteCount.equals(other.byteCount)) |
| 810 | return false; |
| 811 | if (match == null) { |
| 812 | if (other.match != null) |
| 813 | return false; |
| 814 | } else if (!match.equals(other.match)) |
| 815 | return false; |
| 816 | if (instructions == null) { |
| 817 | if (other.instructions != null) |
| 818 | return false; |
| 819 | } else if (!instructions.equals(other.instructions)) |
| 820 | return false; |
| 821 | return true; |
| 822 | } |
| 823 | |
| 824 | @Override |
| 825 | public int hashCode() { |
| 826 | final int prime = 31; |
| 827 | int result = 1; |
| 828 | |
| 829 | result = prime * result + ((tableId == null) ? 0 : tableId.hashCode()); |
| 830 | result = prime * (int) (durationSec ^ (durationSec >>> 32)); |
| 831 | result = prime * (int) (durationNsec ^ (durationNsec >>> 32)); |
| 832 | result = prime * result + priority; |
| 833 | result = prime * result + idleTimeout; |
| 834 | result = prime * result + hardTimeout; |
| 835 | result = prime * result + ((flags == null) ? 0 : flags.hashCode()); |
| 836 | result = prime * result + ((cookie == null) ? 0 : cookie.hashCode()); |
| 837 | result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode()); |
| 838 | result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode()); |
| 839 | result = prime * result + ((match == null) ? 0 : match.hashCode()); |
| 840 | result = prime * result + ((instructions == null) ? 0 : instructions.hashCode()); |
| 841 | return result; |
| 842 | } |
| 843 | |
| 844 | } |