blob: 8254c7703630c201201499f5f7d46c460ba3afc5 [file] [log] [blame]
Thomas Vachuska24c849c2014-10-27 09:53:05 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
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
21public enum DHCPPacketType {
22 // From RFC 1533
23 DHCPDISCOVER(1), DHCPOFFER(2), DHCPREQUEST(3), DHCPDECLINE(4), DHCPACK(5), DHCPNAK(
24 6), DHCPRELEASE(7),
25
26 // From RFC2132
27 DHCPINFORM(8),
28
29 // From RFC3203
30 DHCPFORCERENEW(9),
31
32 // From RFC4388
33 DHCPLEASEQUERY(10), DHCPLEASEUNASSIGNED(11), DHCPLEASEUNKNOWN(12), DHCPLEASEACTIVE(
34 13);
35
36 protected int value;
37
38 private DHCPPacketType(final int value) {
39 this.value = value;
40 }
41
42 public int getValue() {
43 return this.value;
44 }
45
46 @Override
47 public String toString() {
48 switch (this.value) {
49 case 1:
50 return "DHCPDISCOVER";
51 case 2:
52 return "DHCPOFFER";
53 case 3:
54 return "DHCPREQUEST";
55 case 4:
56 return "DHCPDECLINE";
57 case 5:
58 return "DHCPACK";
59 case 6:
60 return "DHCPNAK";
61 case 7:
62 return "DHCPRELEASE";
63 case 8:
64 return "DHCPINFORM";
65 case 9:
66 return "DHCPFORCERENEW";
67 case 10:
68 return "DHCPLEASEQUERY";
69 case 11:
70 return "DHCPLEASEUNASSIGNED";
71 case 12:
72 return "DHCPLEASEUNKNOWN";
73 case 13:
74 return "DHCPLEASEACTIVE";
75 default:
76 break;
77 }
78
79 return null;
80 }
81
82 public static DHCPPacketType getType(final int value) {
83 switch (value) {
84 case 1:
85 return DHCPDISCOVER;
86 case 2:
87 return DHCPOFFER;
88 case 3:
89 return DHCPREQUEST;
90 case 4:
91 return DHCPDECLINE;
92 case 5:
93 return DHCPACK;
94 case 6:
95 return DHCPNAK;
96 case 7:
97 return DHCPRELEASE;
98 case 8:
99 return DHCPINFORM;
100 case 9:
101 return DHCPFORCERENEW;
102 case 10:
103 return DHCPLEASEQUERY;
104 case 11:
105 return DHCPLEASEUNASSIGNED;
106 case 12:
107 return DHCPLEASEUNKNOWN;
108 case 13:
109 return DHCPLEASEACTIVE;
110 default:
111 break;
112 }
113
114 return null;
115 }
116}