X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2FFromSalConversionsUtils.java;h=ecf1a94c18c8123dbcffe5c9d398ce69566f356d;hb=4aac6809c89d1a58d1d7ab9aa4af528cc9d8bb3e;hp=53257f8c835759543fea5cc2c74dd4706e50f1dc;hpb=2c7c9ef5e517de98e0d740f938762cc746dbcde1;p=controller.git diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java index 53257f8c83..ecf1a94c18 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FromSalConversionsUtils.java @@ -61,10 +61,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026 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") @@ -103,7 +109,8 @@ public class FromSalConversionsUtils { 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; } @@ -203,8 +210,11 @@ public class FromSalConversionsUtils { 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()); } @@ -261,11 +271,11 @@ public class FromSalConversionsUtils { .setType(etherType); targetEthMatchBuild.setEthernetType(ethType.build()); } - if((sourceMatch.getField(DL_SRC) != null && sourceMatch.getField(DL_SRC).getValue() != null) || - (sourceMatch.getField(DL_DST) != null && sourceMatch.getField(DL_DST).getValue() != null)|| + if((sourceMatch.getField(DL_SRC) != null && sourceMatch.getField(DL_SRC).getValue() != null) || + (sourceMatch.getField(DL_DST) != null && sourceMatch.getField(DL_DST).getValue() != null)|| dataLinkType != null ) { - return targetEthMatchBuild.build(); - } + return targetEthMatchBuild.build(); + } return null; } @@ -372,7 +382,7 @@ public class FromSalConversionsUtils { .toAddrString(inetDestAddress); layer4MatchBuild .setIpv4Destination(new Ipv4Prefix(inetDstAddressString)); - } + } return layer4MatchBuild.build(); } @@ -388,13 +398,13 @@ public class FromSalConversionsUtils { } if(inetDestAddress != null) { String inetDstAddressString = InetAddresses - .toAddrString(inetDestAddress); + .toAddrString(inetDestAddress); layer6MatchBuild .setIpv6Destination(new Ipv6Prefix(inetDstAddressString)); } return layer6MatchBuild.build(); } - + public static boolean flowEquals(Flow statsFlow, Flow storedFlow) { if (statsFlow.getClass() != storedFlow.getClass()) { return false; @@ -465,5 +475,12 @@ public class FromSalConversionsUtils { 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); + } }