2 * Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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
18 package org.openflow.protocol;
21 import java.util.Arrays;
23 import org.jboss.netty.buffer.ChannelBuffer;
24 import org.openflow.util.U16;
27 * Represents an ofp_echo_request message
29 * @author Rob Sherwood (rob.sherwood@stanford.edu)
32 public class OFEchoRequest extends OFMessage {
33 public static int MINIMUM_LENGTH = 8;
36 public OFEchoRequest() {
38 this.type = OFType.ECHO_REQUEST;
39 this.length = U16.t(MINIMUM_LENGTH);
43 public void readFrom(ChannelBuffer bb) {
45 int datalen = this.getLengthU() - MINIMUM_LENGTH;
47 this.payload = new byte[datalen];
48 bb.readBytes(payload);
55 public byte[] getPayload() {
63 public void setPayload(byte[] payload) {
64 this.payload = payload;
68 public void writeTo(ChannelBuffer bb) {
71 bb.writeBytes(payload);
75 * @see java.lang.Object#hashCode()
78 public int hashCode() {
80 int result = super.hashCode();
81 result = prime * result + Arrays.hashCode(payload);
86 * @see java.lang.Object#equals(java.lang.Object)
89 public boolean equals(Object obj) {
92 if (!super.equals(obj))
94 if (getClass() != obj.getClass())
96 OFEchoRequest other = (OFEchoRequest) obj;
97 if (!Arrays.equals(payload, other.payload))