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