*/
package org.opendaylight.openflowplugin.openflow.md.core.translator;
-import org.opendaylight.openflowplugin.openflow.md.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.IMDMessageTranslator;
-import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
+import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
+import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
+import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
-import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
+import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowVersion;
+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.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.concurrent.CopyOnWriteArrayList;
public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
map.put(6, pseudoField.isHop());
map.put(7, pseudoField.isUnrep());
map.put(8, pseudoField.isUnseq());
- int bitmap = fillBitMaskFromMap(map);
+ int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
ipv6ExtHeaderBuilder.setIpv6Exthdr(bitmap);
if (entry.isHasMask()) {
ipv6ExtHeaderBuilder.setIpv6ExthdrMask(
tunnel.setTunnelMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, entry.getAugmentation(MaskMatchEntry.class).getMask()));
}
matchBuilder.setTunnel(tunnel.build());
- }
+ }
}
-
+
+ AugmentTuple<Match> matchExtensionWrap =
+ MatchExtensionHelper.processAllExtensions(
+ ofMatch.getMatchEntries(), ofVersion, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ if (matchExtensionWrap != null) {
+ matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
+ }
+
+
if (ethernetMatch != null) {
matchBuilder.setEthernetMatch(ethernetMatch.build());
}
return matchBuilder.build();
}
- /**
- * Fills the bitmask from boolean map where key is bit position
- *
- * @param booleanMap
- * bit to boolean mapping
- * @return bit mask
- */
- private int fillBitMaskFromMap(Map<Integer, Boolean> booleanMap) {
- int bitmask = 0;
-
- for (Entry<Integer, Boolean> iterator : booleanMap.entrySet()) {
- if (iterator.getValue() != null && iterator.getValue().booleanValue()) {
- bitmask |= 1 << iterator.getKey();
- }
- }
- return bitmask;
- }
-
- private Ipv4Prefix toIpv4Prefix(MatchEntries entry) {
- String ipv4Prefix = entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().toString();
+ protected Ipv4Prefix toIpv4Prefix(MatchEntries entry) {
+ String ipv4Prefix = entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().getValue();
if (entry.isHasMask()) {
byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
ipv4Prefix = ipv4Prefix + PREFIX_SEPARATOR + countBits(mask);
return new Ipv4Prefix(ipv4Prefix);
}
- private Ipv6Prefix toIpv6Prefix(MatchEntries entry) {
- String ipv6Prefix = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().toString();
+ protected Ipv6Prefix toIpv6Prefix(MatchEntries entry) {
+ String ipv6Prefix = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue();
if (entry.isHasMask()) {
byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask();
ipv6Prefix = ipv6Prefix + PREFIX_SEPARATOR + countBits(mask);