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