Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 24c849c | 2014-10-27 09:53:05 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 18 | |
| 19 | package org.onlab.packet; |
| 20 | |
Yi Tseng | c7403c2 | 2017-06-19 16:23:22 -0700 | [diff] [blame] | 21 | /** |
| 22 | * @deprecated 1.11 Loon, move into DHCP class. |
| 23 | */ |
| 24 | @Deprecated |
alshabib | c4901cd | 2014-09-05 16:50:40 -0700 | [diff] [blame] | 25 | public 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 | |
| 83 | return null; |
| 84 | } |
| 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 | } |