import java.math.BigInteger;
import java.util.Iterator;
+import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
* The value 0xffff (OFP_VLAN_NONE) is used to indicate
* that no VLAN ID is set for OF Flow.
*/
- private static final int OFP_VLAN_NONE = (int) 0xffff;
+ private static final int OFP_VLAN_NONE = 0xffff;
/**
* Method builds openflow 1.0 specific match (MatchV10) from MD-SAL match.
private static boolean convertNwTos(final MatchV10Builder matchBuilder,
final IpMatch ipMatch) {
if (ipMatch.getIpDscp() != null) {
- matchBuilder.setNwTos(ipMatch.getIpDscp().getValue());
+ matchBuilder.setNwTos(ActionUtil.dscpToTos(ipMatch.getIpDscp().getValue()));
return false;
}
return true;
public static Short tosToDscp(short tosValue) {
return (short) (tosValue >>> ActionUtil.ENC_FIELD_BIT_SIZE);
}
+
+ /**
+ * @param dscpValue TypeOfService value
+ * @return TOS value
+ */
+ public static Short dscpToTos(short dscpValue) {
+ return (short) (dscpValue << ActionUtil.ENC_FIELD_BIT_SIZE);
+ }
}
Assert.assertEquals(63, ActionUtil.tosToDscp((short) 252).intValue());
}
+ /**
+ * Test method for {@link org.opendaylight.openflowplugin.openflow.md.util.ActionUtil#dscpToTos(short)}.
+ */
+ @Test
+ public void testDscpToTos() {
+ Assert.assertEquals(0, ActionUtil.dscpToTos((short) 0).intValue());
+ Assert.assertEquals(4, ActionUtil.dscpToTos((short) 1).intValue());
+ Assert.assertEquals(16, ActionUtil.dscpToTos((short) 4).intValue());
+ Assert.assertEquals(252, ActionUtil.dscpToTos((short) 63).intValue());
+ }
}