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)
13 public class NwProtocol extends MatchField<Byte> {
14 private static final long serialVersionUID = 1L;
15 public static final String TYPE = "NW_PROTO";
16 private static final short MAX = 255;
17 private byte protocol;
20 * Creates a Match field for the network protocol
25 public NwProtocol(byte protocol) {
27 this.protocol = protocol;
30 public NwProtocol(int protocol) {
32 this.protocol = (byte) protocol;
35 public NwProtocol(short protocol) {
37 this.protocol = (byte) protocol;
41 private NwProtocol() {
46 public Byte getValue() {
51 @XmlElement(name = "value")
52 protected String getValueString() {
53 return String.format("0X%s", Integer.toHexString(NetUtils.getUnsignedByte(protocol)));
57 public Byte getMask() {
62 protected String getMaskString() {
67 public boolean isValid() {
68 int intProtocol = NetUtils.getUnsignedByte(protocol);
69 return intProtocol >= 0 && intProtocol <= MAX;
73 public boolean hasReverse() {
78 public NwProtocol getReverse() {
83 public NwProtocol clone() {
84 return new NwProtocol(protocol);
88 public boolean isV6() {
93 public int hashCode() {
96 result = prime * result + protocol;
101 public boolean equals(Object obj) {
108 if (!(obj instanceof NwProtocol)) {
111 NwProtocol other = (NwProtocol) obj;
112 if (protocol != other.protocol) {