/
IpV4SecurityOptionHandlingRestrictions.java
71 lines (60 loc) · 1.87 KB
/
IpV4SecurityOptionHandlingRestrictions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*_##########################################################################
_##
_## Copyright (C) 2011-2015 Pcap4J.org
_##
_##########################################################################
*/
package org.pcap4j.packet.namednumber;
import java.util.HashMap;
import java.util.Map;
import org.pcap4j.util.ByteArrays;
/**
* Handling Restrictions of IPv4 Security Option
*
* @see <a href="https://tools.ietf.org/html/rfc791">RFC 791</a>
* @author Kaito Yamada
* @since pcap4j 0.9.11
*/
public final class IpV4SecurityOptionHandlingRestrictions
extends NamedNumber<Short, IpV4SecurityOptionHandlingRestrictions> {
/** */
private static final long serialVersionUID = 3041825811304706489L;
private static final Map<Short, IpV4SecurityOptionHandlingRestrictions> registry =
new HashMap<Short, IpV4SecurityOptionHandlingRestrictions>();
static {
}
/**
* @param value value
* @param name name
*/
public IpV4SecurityOptionHandlingRestrictions(Short value, String name) {
super(value, name);
}
/**
* @param value value
* @return a IpV4SecurityOptionHandlingRestrictions object.
*/
public static IpV4SecurityOptionHandlingRestrictions getInstance(Short value) {
if (registry.containsKey(value)) {
return registry.get(value);
} else {
return new IpV4SecurityOptionHandlingRestrictions(value, "unknown");
}
}
/**
* @param number number
* @return a IpV4SecurityOptionHandlingRestrictions object.
*/
public static IpV4SecurityOptionHandlingRestrictions register(
IpV4SecurityOptionHandlingRestrictions number) {
return registry.put(number.value(), number);
}
@Override
public String valueAsString() {
return "0x" + ByteArrays.toHexString(value(), "");
}
@Override
public int compareTo(IpV4SecurityOptionHandlingRestrictions o) {
return value().compareTo(o.value());
}
}