blob: 1fcc324b4844459be3d5ebb0a7e9d7619b39f678 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2* Copyright 2011, Big Switch Networks, Inc.
3* Originally created by David Erickson, Stanford 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
18package net.floodlightcontroller.packet;
19
20import java.util.Arrays;
21
22/**
23 *
24 * @author David Erickson (daviderickson@cs.stanford.edu)
25 */
26public class DHCPOption {
27 protected byte code;
28 protected byte length;
29 protected byte[] data;
30
31 /**
32 * @return the code
33 */
34 public byte getCode() {
35 return code;
36 }
37
38 /**
39 * @param code the code to set
40 */
41 public DHCPOption setCode(byte code) {
42 this.code = code;
43 return this;
44 }
45
46 /**
47 * @return the length
48 */
49 public byte getLength() {
50 return length;
51 }
52
53 /**
54 * @param length the length to set
55 */
56 public DHCPOption setLength(byte length) {
57 this.length = length;
58 return this;
59 }
60
61 /**
62 * @return the data
63 */
64 public byte[] getData() {
65 return data;
66 }
67
68 /**
69 * @param data the data to set
70 */
71 public DHCPOption setData(byte[] data) {
72 this.data = data;
73 return this;
74 }
75
76 /* (non-Javadoc)
77 * @see java.lang.Object#hashCode()
78 */
79 @Override
80 public int hashCode() {
81 final int prime = 31;
82 int result = 1;
83 result = prime * result + code;
84 result = prime * result + Arrays.hashCode(data);
85 result = prime * result + length;
86 return result;
87 }
88
89 /* (non-Javadoc)
90 * @see java.lang.Object#equals(java.lang.Object)
91 */
92 @Override
93 public boolean equals(Object obj) {
94 if (this == obj)
95 return true;
96 if (obj == null)
97 return false;
98 if (!(obj instanceof DHCPOption))
99 return false;
100 DHCPOption other = (DHCPOption) obj;
101 if (code != other.code)
102 return false;
103 if (!Arrays.equals(data, other.data))
104 return false;
105 if (length != other.length)
106 return false;
107 return true;
108 }
109
110 /* (non-Javadoc)
111 * @see java.lang.Object#toString()
112 */
113 @Override
114 public String toString() {
115 return "DHCPOption [code=" + code + ", length=" + length + ", data="
116 + Arrays.toString(data) + "]";
117 }
118}