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%2FToSalConversionsUtils.java;h=dcc1a4660b5b71690419f377c84852f192b3c0dc;hb=34bc6ec632529a0dfe419aa7404bb42a456fbc96;hp=7bbf7f10e0c2be3c8246849d468fdbc0a8be5996;hpb=03ee21b4d6ae3dd6fd3a6991253e877dc96fabf5;p=controller.git diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java index 7bbf7f10e0..dcc1a4660b 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java @@ -128,7 +128,7 @@ public class ToSalConversionsUtils { private static final Logger LOG = LoggerFactory.getLogger(ToSalConversionsUtils.class); private ToSalConversionsUtils() { - + throw new IllegalAccessError("forcing no instance for factory"); } public static Flow toFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow source, Node node) { @@ -287,7 +287,7 @@ public class ToSalConversionsUtils { } else if (sourceAction instanceof SetNwTosActionCase) { Integer tos = ((SetNwTosActionCase) sourceAction).getSetNwTosAction().getTos(); if (tos != null) { - targetAction.add(new SetNwTos(tos)); + targetAction.add(new SetNwTos(ToSalConversionsUtils.tosToNwDscp(tos))); } } else if (sourceAction instanceof SetTpDstActionCase) { PortNumber port = ((SetTpDstActionCase) sourceAction).getSetTpDstAction().getPort(); @@ -356,23 +356,9 @@ public class ToSalConversionsUtils { } private static PushVlan pushVlanFrom(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction pushVlanAction) { - final int tag; - final int pcp; - final int cfi; - final int vlanId; - - if (pushVlanAction.getTag() != null) { - tag = pushVlanAction.getTag(); - if (pushVlanAction.getPcp() != null) { - pcp = pushVlanAction.getPcp(); - if (pushVlanAction.getCfi() != null && pushVlanAction.getCfi().getValue() != null) { - cfi = pushVlanAction.getCfi().getValue(); - if (pushVlanAction.getVlanId() != null && pushVlanAction.getVlanId().getValue() != null) { - vlanId = pushVlanAction.getVlanId().getValue(); - return new PushVlan(tag, pcp, cfi, vlanId); - } - } - } + Integer tag = pushVlanAction.getTag(); + if (tag != null) { + return new PushVlan(tag.intValue()); } return null; } @@ -430,13 +416,17 @@ public class ToSalConversionsUtils { if (vlanMatch != null) { VlanId vlanId = vlanMatch.getVlanId(); if (vlanId != null) { - org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId vlanIdInner = vlanId - .getVlanId(); - if (vlanIdInner != null) { - Integer vlanValue = vlanIdInner.getValue(); - if (vlanValue != null) { - target.setField(DL_VLAN, vlanValue.shortValue()); + if (Boolean.TRUE.equals(vlanId.isVlanIdPresent())) { + org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId vlanIdInner = vlanId + .getVlanId(); + if (vlanIdInner != null) { + Integer vlanValue = vlanIdInner.getValue(); + if (vlanValue != null) { + target.setField(DL_VLAN, vlanValue.shortValue()); + } } + } else { + target.setField(DL_VLAN, MatchType.DL_VLAN_NONE); } } VlanPcp vlanPcp = vlanMatch.getVlanPcp(); @@ -653,4 +643,12 @@ public class ToSalConversionsUtils { return mac; } + + /** + * @param nwTos NW-TOS + * @return shifted to NW-DSCP + */ + public static int tosToNwDscp(int nwTos) { + return (short) (nwTos >>> FromSalConversionsUtils.ENC_FIELD_BIT_SIZE); + } }