Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior |
| 3 | * University |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | * not use this file except in compliance with the License. You may obtain |
| 7 | * a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | * License for the specific language governing permissions and limitations |
| 15 | * under the License. |
| 16 | **/ |
| 17 | |
| 18 | package org.openflow.protocol.statistics; |
| 19 | |
| 20 | |
| 21 | import org.codehaus.jackson.annotate.JsonIgnore; |
| 22 | import org.jboss.netty.buffer.ChannelBuffer; |
| 23 | |
| 24 | /** |
| 25 | * Represents an ofp_port_stats structure |
| 26 | * @author David Erickson (daviderickson@cs.stanford.edu) |
| 27 | */ |
| 28 | public class OFPortStatisticsReply implements OFStatistics { |
| 29 | protected short portNumber; |
| 30 | protected long receivePackets; |
| 31 | protected long transmitPackets; |
| 32 | protected long receiveBytes; |
| 33 | protected long transmitBytes; |
| 34 | protected long receiveDropped; |
| 35 | protected long transmitDropped; |
| 36 | protected long receiveErrors; |
| 37 | protected long transmitErrors; |
| 38 | protected long receiveFrameErrors; |
| 39 | protected long receiveOverrunErrors; |
| 40 | protected long receiveCRCErrors; |
| 41 | protected long collisions; |
| 42 | |
| 43 | /** |
| 44 | * @return the portNumber |
| 45 | */ |
| 46 | public short getPortNumber() { |
| 47 | return portNumber; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @param portNumber the portNumber to set |
| 52 | */ |
| 53 | public void setPortNumber(short portNumber) { |
| 54 | this.portNumber = portNumber; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * @return the receivePackets |
| 59 | */ |
| 60 | public long getreceivePackets() { |
| 61 | return receivePackets; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @param receivePackets the receivePackets to set |
| 66 | */ |
| 67 | public void setreceivePackets(long receivePackets) { |
| 68 | this.receivePackets = receivePackets; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * @return the transmitPackets |
| 73 | */ |
| 74 | public long getTransmitPackets() { |
| 75 | return transmitPackets; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @param transmitPackets the transmitPackets to set |
| 80 | */ |
| 81 | public void setTransmitPackets(long transmitPackets) { |
| 82 | this.transmitPackets = transmitPackets; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @return the receiveBytes |
| 87 | */ |
| 88 | public long getReceiveBytes() { |
| 89 | return receiveBytes; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @param receiveBytes the receiveBytes to set |
| 94 | */ |
| 95 | public void setReceiveBytes(long receiveBytes) { |
| 96 | this.receiveBytes = receiveBytes; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @return the transmitBytes |
| 101 | */ |
| 102 | public long getTransmitBytes() { |
| 103 | return transmitBytes; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * @param transmitBytes the transmitBytes to set |
| 108 | */ |
| 109 | public void setTransmitBytes(long transmitBytes) { |
| 110 | this.transmitBytes = transmitBytes; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @return the receiveDropped |
| 115 | */ |
| 116 | public long getReceiveDropped() { |
| 117 | return receiveDropped; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * @param receiveDropped the receiveDropped to set |
| 122 | */ |
| 123 | public void setReceiveDropped(long receiveDropped) { |
| 124 | this.receiveDropped = receiveDropped; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * @return the transmitDropped |
| 129 | */ |
| 130 | public long getTransmitDropped() { |
| 131 | return transmitDropped; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * @param transmitDropped the transmitDropped to set |
| 136 | */ |
| 137 | public void setTransmitDropped(long transmitDropped) { |
| 138 | this.transmitDropped = transmitDropped; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * @return the receiveErrors |
| 143 | */ |
| 144 | public long getreceiveErrors() { |
| 145 | return receiveErrors; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * @param receiveErrors the receiveErrors to set |
| 150 | */ |
| 151 | public void setreceiveErrors(long receiveErrors) { |
| 152 | this.receiveErrors = receiveErrors; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * @return the transmitErrors |
| 157 | */ |
| 158 | public long getTransmitErrors() { |
| 159 | return transmitErrors; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * @param transmitErrors the transmitErrors to set |
| 164 | */ |
| 165 | public void setTransmitErrors(long transmitErrors) { |
| 166 | this.transmitErrors = transmitErrors; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * @return the receiveFrameErrors |
| 171 | */ |
| 172 | public long getReceiveFrameErrors() { |
| 173 | return receiveFrameErrors; |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * @param receiveFrameErrors the receiveFrameErrors to set |
| 178 | */ |
| 179 | public void setReceiveFrameErrors(long receiveFrameErrors) { |
| 180 | this.receiveFrameErrors = receiveFrameErrors; |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * @return the receiveOverrunErrors |
| 185 | */ |
| 186 | public long getReceiveOverrunErrors() { |
| 187 | return receiveOverrunErrors; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * @param receiveOverrunErrors the receiveOverrunErrors to set |
| 192 | */ |
| 193 | public void setReceiveOverrunErrors(long receiveOverrunErrors) { |
| 194 | this.receiveOverrunErrors = receiveOverrunErrors; |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * @return the receiveCRCErrors |
| 199 | */ |
| 200 | public long getReceiveCRCErrors() { |
| 201 | return receiveCRCErrors; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * @param receiveCRCErrors the receiveCRCErrors to set |
| 206 | */ |
| 207 | public void setReceiveCRCErrors(long receiveCRCErrors) { |
| 208 | this.receiveCRCErrors = receiveCRCErrors; |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * @return the collisions |
| 213 | */ |
| 214 | public long getCollisions() { |
| 215 | return collisions; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * @param collisions the collisions to set |
| 220 | */ |
| 221 | public void setCollisions(long collisions) { |
| 222 | this.collisions = collisions; |
| 223 | } |
| 224 | |
| 225 | @Override |
| 226 | @JsonIgnore |
| 227 | public int getLength() { |
| 228 | return 104; |
| 229 | } |
| 230 | |
| 231 | @Override |
| 232 | public void readFrom(ChannelBuffer data) { |
| 233 | this.portNumber = data.readShort(); |
| 234 | data.readShort(); // pad |
| 235 | data.readInt(); // pad |
| 236 | this.receivePackets = data.readLong(); |
| 237 | this.transmitPackets = data.readLong(); |
| 238 | this.receiveBytes = data.readLong(); |
| 239 | this.transmitBytes = data.readLong(); |
| 240 | this.receiveDropped = data.readLong(); |
| 241 | this.transmitDropped = data.readLong(); |
| 242 | this.receiveErrors = data.readLong(); |
| 243 | this.transmitErrors = data.readLong(); |
| 244 | this.receiveFrameErrors = data.readLong(); |
| 245 | this.receiveOverrunErrors = data.readLong(); |
| 246 | this.receiveCRCErrors = data.readLong(); |
| 247 | this.collisions = data.readLong(); |
| 248 | } |
| 249 | |
| 250 | @Override |
| 251 | public void writeTo(ChannelBuffer data) { |
| 252 | data.writeShort(this.portNumber); |
| 253 | data.writeShort((short) 0); // pad |
| 254 | data.writeInt(0); // pad |
| 255 | data.writeLong(this.receivePackets); |
| 256 | data.writeLong(this.transmitPackets); |
| 257 | data.writeLong(this.receiveBytes); |
| 258 | data.writeLong(this.transmitBytes); |
| 259 | data.writeLong(this.receiveDropped); |
| 260 | data.writeLong(this.transmitDropped); |
| 261 | data.writeLong(this.receiveErrors); |
| 262 | data.writeLong(this.transmitErrors); |
| 263 | data.writeLong(this.receiveFrameErrors); |
| 264 | data.writeLong(this.receiveOverrunErrors); |
| 265 | data.writeLong(this.receiveCRCErrors); |
| 266 | data.writeLong(this.collisions); |
| 267 | } |
| 268 | |
| 269 | @Override |
| 270 | public int hashCode() { |
| 271 | final int prime = 431; |
| 272 | int result = 1; |
| 273 | result = prime * result + (int) (collisions ^ (collisions >>> 32)); |
| 274 | result = prime * result + portNumber; |
| 275 | result = prime * result |
| 276 | + (int) (receivePackets ^ (receivePackets >>> 32)); |
| 277 | result = prime * result + (int) (receiveBytes ^ (receiveBytes >>> 32)); |
| 278 | result = prime * result |
| 279 | + (int) (receiveCRCErrors ^ (receiveCRCErrors >>> 32)); |
| 280 | result = prime * result |
| 281 | + (int) (receiveDropped ^ (receiveDropped >>> 32)); |
| 282 | result = prime * result |
| 283 | + (int) (receiveFrameErrors ^ (receiveFrameErrors >>> 32)); |
| 284 | result = prime * result |
| 285 | + (int) (receiveOverrunErrors ^ (receiveOverrunErrors >>> 32)); |
| 286 | result = prime * result |
| 287 | + (int) (receiveErrors ^ (receiveErrors >>> 32)); |
| 288 | result = prime * result |
| 289 | + (int) (transmitBytes ^ (transmitBytes >>> 32)); |
| 290 | result = prime * result |
| 291 | + (int) (transmitDropped ^ (transmitDropped >>> 32)); |
| 292 | result = prime * result |
| 293 | + (int) (transmitErrors ^ (transmitErrors >>> 32)); |
| 294 | result = prime * result |
| 295 | + (int) (transmitPackets ^ (transmitPackets >>> 32)); |
| 296 | return result; |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public boolean equals(Object obj) { |
| 301 | if (this == obj) { |
| 302 | return true; |
| 303 | } |
| 304 | if (obj == null) { |
| 305 | return false; |
| 306 | } |
| 307 | if (!(obj instanceof OFPortStatisticsReply)) { |
| 308 | return false; |
| 309 | } |
| 310 | OFPortStatisticsReply other = (OFPortStatisticsReply) obj; |
| 311 | if (collisions != other.collisions) { |
| 312 | return false; |
| 313 | } |
| 314 | if (portNumber != other.portNumber) { |
| 315 | return false; |
| 316 | } |
| 317 | if (receivePackets != other.receivePackets) { |
| 318 | return false; |
| 319 | } |
| 320 | if (receiveBytes != other.receiveBytes) { |
| 321 | return false; |
| 322 | } |
| 323 | if (receiveCRCErrors != other.receiveCRCErrors) { |
| 324 | return false; |
| 325 | } |
| 326 | if (receiveDropped != other.receiveDropped) { |
| 327 | return false; |
| 328 | } |
| 329 | if (receiveFrameErrors != other.receiveFrameErrors) { |
| 330 | return false; |
| 331 | } |
| 332 | if (receiveOverrunErrors != other.receiveOverrunErrors) { |
| 333 | return false; |
| 334 | } |
| 335 | if (receiveErrors != other.receiveErrors) { |
| 336 | return false; |
| 337 | } |
| 338 | if (transmitBytes != other.transmitBytes) { |
| 339 | return false; |
| 340 | } |
| 341 | if (transmitDropped != other.transmitDropped) { |
| 342 | return false; |
| 343 | } |
| 344 | if (transmitErrors != other.transmitErrors) { |
| 345 | return false; |
| 346 | } |
| 347 | if (transmitPackets != other.transmitPackets) { |
| 348 | return false; |
| 349 | } |
| 350 | return true; |
| 351 | } |
| 352 | } |