blob: c88b9073d133fc3cad0dc89626f7c667c55ac932 [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2014-present Open Networking Foundation
alshabibc4901cd2014-09-05 16:50:40 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
alshabibc4901cd2014-09-05 16:50:40 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska24c849c2014-10-27 09:53:05 -070015 */
16
17
alshabibc4901cd2014-09-05 16:50:40 -070018
19package org.onlab.packet;
20
Yi Tsengc7403c22017-06-19 16:23:22 -070021/**
22 * @deprecated 1.11 Loon, move into DHCP class.
23 */
24@Deprecated
alshabibc4901cd2014-09-05 16:50:40 -070025public enum DHCPPacketType {
26 // From RFC 1533
27 DHCPDISCOVER(1), DHCPOFFER(2), DHCPREQUEST(3), DHCPDECLINE(4), DHCPACK(5), DHCPNAK(
28 6), DHCPRELEASE(7),
29
30 // From RFC2132
31 DHCPINFORM(8),
32
33 // From RFC3203
34 DHCPFORCERENEW(9),
35
36 // From RFC4388
37 DHCPLEASEQUERY(10), DHCPLEASEUNASSIGNED(11), DHCPLEASEUNKNOWN(12), DHCPLEASEACTIVE(
38 13);
39
40 protected int value;
41
42 private DHCPPacketType(final int value) {
43 this.value = value;
44 }
45
46 public int getValue() {
47 return this.value;
48 }
49
50 @Override
51 public String toString() {
52 switch (this.value) {
53 case 1:
54 return "DHCPDISCOVER";
55 case 2:
56 return "DHCPOFFER";
57 case 3:
58 return "DHCPREQUEST";
59 case 4:
60 return "DHCPDECLINE";
61 case 5:
62 return "DHCPACK";
63 case 6:
64 return "DHCPNAK";
65 case 7:
66 return "DHCPRELEASE";
67 case 8:
68 return "DHCPINFORM";
69 case 9:
70 return "DHCPFORCERENEW";
71 case 10:
72 return "DHCPLEASEQUERY";
73 case 11:
74 return "DHCPLEASEUNASSIGNED";
75 case 12:
76 return "DHCPLEASEUNKNOWN";
77 case 13:
78 return "DHCPLEASEACTIVE";
79 default:
80 break;
81 }
82
Ray Milkeyc42dc902018-01-24 16:45:51 -080083 return "";
alshabibc4901cd2014-09-05 16:50:40 -070084 }
85
86 public static DHCPPacketType getType(final int value) {
87 switch (value) {
88 case 1:
89 return DHCPDISCOVER;
90 case 2:
91 return DHCPOFFER;
92 case 3:
93 return DHCPREQUEST;
94 case 4:
95 return DHCPDECLINE;
96 case 5:
97 return DHCPACK;
98 case 6:
99 return DHCPNAK;
100 case 7:
101 return DHCPRELEASE;
102 case 8:
103 return DHCPINFORM;
104 case 9:
105 return DHCPFORCERENEW;
106 case 10:
107 return DHCPLEASEQUERY;
108 case 11:
109 return DHCPLEASEUNASSIGNED;
110 case 12:
111 return DHCPLEASEUNKNOWN;
112 case 13:
113 return DHCPLEASEACTIVE;
114 default:
115 break;
116 }
117
118 return null;
119 }
120}