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 | /** |
| 19 | * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010 |
| 20 | */ |
| 21 | package org.openflow.protocol.action; |
| 22 | |
| 23 | |
| 24 | import org.jboss.netty.buffer.ChannelBuffer; |
| 25 | |
| 26 | /** |
| 27 | * Represents an ofp_action_nw_addr |
| 28 | * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 11, 2010 |
| 29 | */ |
| 30 | public abstract class OFActionNetworkLayerAddress extends OFAction { |
| 31 | public static int MINIMUM_LENGTH = 8; |
| 32 | |
| 33 | protected int networkAddress; |
| 34 | |
| 35 | /** |
| 36 | * @return the networkAddress |
| 37 | */ |
| 38 | public int getNetworkAddress() { |
| 39 | return networkAddress; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @param networkAddress the networkAddress to set |
| 44 | */ |
| 45 | public void setNetworkAddress(int networkAddress) { |
| 46 | this.networkAddress = networkAddress; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public void readFrom(ChannelBuffer data) { |
| 51 | super.readFrom(data); |
| 52 | this.networkAddress = data.readInt(); |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public void writeTo(ChannelBuffer data) { |
| 57 | super.writeTo(data); |
| 58 | data.writeInt(this.networkAddress); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public int hashCode() { |
| 63 | final int prime = 353; |
| 64 | int result = super.hashCode(); |
| 65 | result = prime * result + networkAddress; |
| 66 | return result; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public boolean equals(Object obj) { |
| 71 | if (this == obj) { |
| 72 | return true; |
| 73 | } |
| 74 | if (!super.equals(obj)) { |
| 75 | return false; |
| 76 | } |
| 77 | if (!(obj instanceof OFActionNetworkLayerAddress)) { |
| 78 | return false; |
| 79 | } |
| 80 | OFActionNetworkLayerAddress other = (OFActionNetworkLayerAddress) obj; |
| 81 | if (networkAddress != other.networkAddress) { |
| 82 | return false; |
| 83 | } |
| 84 | return true; |
| 85 | } |
| 86 | } |