blob: 2a3f03ca0c91a93faeb4d0ac12e030c8695ac875 [file] [log] [blame]
alshabibc4901cd2014-09-05 16:50:40 -07001/*******************************************************************************
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************/
16/**
17 * Copyright 2011, Big Switch Networks, Inc.
18 * Originally created by David Erickson, Stanford University
19 *
20 * Licensed under the Apache License, Version 2.0 (the "License"); you may
21 * not use this file except in compliance with the License. You may obtain
22 * a copy of the License at
23 *
24 * http://www.apache.org/licenses/LICENSE-2.0
25 *
26 * Unless required by applicable law or agreed to in writing, software
27 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
28 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
29 * License for the specific language governing permissions and limitations
30 * under the License.
31 **/
32
33package org.onlab.packet;
34
35import java.util.Arrays;
36
37/**
38 *
alshabibc4901cd2014-09-05 16:50:40 -070039 */
40public class DHCPOption {
41 protected byte code;
42 protected byte length;
43 protected byte[] data;
44
45 /**
46 * @return the code
47 */
48 public byte getCode() {
49 return this.code;
50 }
51
52 /**
53 * @param code
54 * the code to set
55 */
56 public DHCPOption setCode(final byte code) {
57 this.code = code;
58 return this;
59 }
60
61 /**
62 * @return the length
63 */
64 public byte getLength() {
65 return this.length;
66 }
67
68 /**
69 * @param length
70 * the length to set
71 */
72 public DHCPOption setLength(final byte length) {
73 this.length = length;
74 return this;
75 }
76
77 /**
78 * @return the data
79 */
80 public byte[] getData() {
81 return this.data;
82 }
83
84 /**
85 * @param data
86 * the data to set
87 */
88 public DHCPOption setData(final byte[] data) {
89 this.data = data;
90 return this;
91 }
92
93 /*
94 * (non-Javadoc)
95 *
96 * @see java.lang.Object#hashCode()
97 */
98 @Override
99 public int hashCode() {
100 final int prime = 31;
101 int result = 1;
102 result = prime * result + this.code;
103 result = prime * result + Arrays.hashCode(this.data);
104 result = prime * result + this.length;
105 return result;
106 }
107
108 /*
109 * (non-Javadoc)
110 *
111 * @see java.lang.Object#equals(java.lang.Object)
112 */
113 @Override
114 public boolean equals(final Object obj) {
115 if (this == obj) {
116 return true;
117 }
118 if (obj == null) {
119 return false;
120 }
121 if (!(obj instanceof DHCPOption)) {
122 return false;
123 }
124 final DHCPOption other = (DHCPOption) obj;
125 if (this.code != other.code) {
126 return false;
127 }
128 if (!Arrays.equals(this.data, other.data)) {
129 return false;
130 }
131 if (this.length != other.length) {
132 return false;
133 }
134 return true;
135 }
136
137 /*
138 * (non-Javadoc)
139 *
140 * @see java.lang.Object#toString()
141 */
142 @Override
143 public String toString() {
144 return "DHCPOption [code=" + this.code + ", length=" + this.length
145 + ", data=" + Arrays.toString(this.data) + "]";
146 }
147}