X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fadsal%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fmatch%2Fextensible%2FNwTos.java;fp=opendaylight%2Fadsal%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fmatch%2Fextensible%2FNwTos.java;h=ba5b562bd279382a591d2ab053e3559c9ee3e74c;hb=42c32160bfd41de57189bb246fec5ffb48ed8e9e;hp=0000000000000000000000000000000000000000;hpb=edf5bfcee83c750853253ccfd991ba7000f5f65b;p=controller.git diff --git a/opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/NwTos.java b/opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/NwTos.java new file mode 100644 index 0000000000..ba5b562bd2 --- /dev/null +++ b/opendaylight/adsal/sal/api/src/main/java/org/opendaylight/controller/sal/match/extensible/NwTos.java @@ -0,0 +1,115 @@ +package org.opendaylight.controller.sal.match.extensible; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.opendaylight.controller.sal.utils.NetUtils; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.NONE) +public class NwTos extends MatchField { + private static final long serialVersionUID = 1L; + public static final String TYPE = "NW_TOS"; + private static final short MAX = 63; + private byte tos; + + /** + * Creates a Match field for the network TOS + * + * @param address + * the network TOS + */ + public NwTos(byte tos) { + super(TYPE); + this.tos = tos; + } + + public NwTos(int tos) { + super(TYPE); + this.tos = (byte) tos; + } + + public NwTos(short tos) { + super(TYPE); + this.tos = (byte) tos; + } + + // To satisfy JAXB + private NwTos() { + super(TYPE); + } + + @Override + public Byte getValue() { + return tos; + } + + @Override + @XmlElement(name = "value") + protected String getValueString() { + return String.format("0X%s", Integer.toHexString(NetUtils.getUnsignedByte(tos))); + } + + @Override + public Byte getMask() { + return null; + } + + @Override + protected String getMaskString() { + return null; + } + + @Override + public boolean isValid() { + return tos >= 0 && tos <= MAX; + } + + @Override + public boolean hasReverse() { + return false; + } + + @Override + public NwTos getReverse() { + return this.clone(); + } + + @Override + public NwTos clone() { + return new NwTos(tos); + } + + @Override + public boolean isV6() { + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + tos; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof NwTos)) { + return false; + } + NwTos other = (NwTos) obj; + if (tos != other.tos) { + return false; + } + return true; + } +} \ No newline at end of file