1 package org.opendaylight.controller.sal.match.extensible;
3 import javax.xml.bind.annotation.XmlAccessType;
4 import javax.xml.bind.annotation.XmlAccessorType;
5 import javax.xml.bind.annotation.XmlElement;
6 import javax.xml.bind.annotation.XmlRootElement;
8 import org.opendaylight.controller.sal.utils.NetUtils;
11 @XmlAccessorType(XmlAccessType.NONE)
12 public class NwProtocol extends MatchField<Byte> {
13 private static final long serialVersionUID = 1L;
14 public static final String TYPE = "NW_PROTO";
15 private static final short MAX = 255;
16 private byte protocol;
19 * Creates a Match field for the network protocol
24 public NwProtocol(byte protocol) {
26 this.protocol = protocol;
29 public NwProtocol(int protocol) {
31 this.protocol = (byte) protocol;
34 public NwProtocol(short protocol) {
36 this.protocol = (byte) protocol;
40 private NwProtocol() {
45 public Byte getValue() {
50 @XmlElement(name = "value")
51 protected String getValueString() {
52 return String.format("0X%s", Integer.toHexString(NetUtils.getUnsignedByte(protocol)));
56 public Byte getMask() {
61 protected String getMaskString() {
66 public boolean isValid() {
67 int intProtocol = NetUtils.getUnsignedByte(protocol);
68 return intProtocol >= 0 && intProtocol <= MAX;
72 public boolean hasReverse() {
77 public NwProtocol getReverse() {
82 public NwProtocol clone() {
83 return new NwProtocol(protocol);
87 public boolean isV6() {
92 public int hashCode() {
95 result = prime * result + protocol;
100 public boolean equals(Object obj) {
107 if (!(obj instanceof NwProtocol)) {
110 NwProtocol other = (NwProtocol) obj;
111 if (protocol != other.protocol) {