import com.google.common.net.InetAddresses;
-public class FromSalConversionsUtils {
+/**
+ * MD-SAL to AD-SAL conversions collection
+ */
+public final class FromSalConversionsUtils {
- private FromSalConversionsUtils() {
+ /** http://en.wikipedia.org/wiki/IPv4#Packet_structure (end of octet number 1, bit 14.+15.) */
+ public static final int ENC_FIELD_BIT_SIZE = 2;
+ private FromSalConversionsUtils() {
+ throw new IllegalAccessError("forcing no instance for factory");
}
@SuppressWarnings("unused")
private static NodeConnectorId inPortMatch(Match sourceMatch) {
MatchField inPort = sourceMatch.getField(MatchType.IN_PORT);
if(inPort != null && inPort.getValue() != null && (inPort.getValue() instanceof NodeConnector)) {
- return new NodeConnectorId(((NodeConnector) inPort.getValue()).getNodeConnectorIdAsString());
+ NodeConnector port = (NodeConnector)inPort.getValue();
+ return (NodeConnectorId)MDFlowMapping.toUri(port);
}
return null;
}
MatchField vlan = sourceMatch.getField(MatchType.DL_VLAN);
if (vlan != null && vlan.getValue() != null) {
VlanIdBuilder vlanIDBuilder = new VlanIdBuilder();
+ short vid = (short)vlan.getValue();
+ boolean present = (vid != MatchType.DL_VLAN_NONE);
vlanIDBuilder.setVlanId(new VlanId((NetUtils
- .getUnsignedShort((short) vlan.getValue()))));
+ .getUnsignedShort(vid))));
+ vlanIDBuilder.setVlanIdPresent(present);
vlanMatchBuild.setVlanId(vlanIDBuilder.build());
}
return true;
}
+ /**
+ * @param nwDscp NW-DSCP
+ * @return shifted to NW-TOS (with empty ECN part)
+ */
+ public static int dscpToTos(int nwDscp) {
+ return (short) (nwDscp << ENC_FIELD_BIT_SIZE);
+ }
}