/**
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match;
+import com.google.common.base.Optional;
import org.opendaylight.openflowjava.nx.NiciraMatchCodecs;
import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
import org.opendaylight.openflowplugin.extension.api.ExtensionAugment;
import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.CodecPreconditionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.OfjAugNxMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.reg.grouping.RegValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.RegCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.RegCaseValueBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-
/**
* @author msunal
- *
*/
-public class RegConvertor implements ConvertorToOFJava<MatchEntries>, ConvertorFromOFJava<MatchEntries, MatchPath> {
+public class RegConvertor implements ConvertorToOFJava<MatchEntry>, ConvertorFromOFJava<MatchEntry, MatchPath> {
private final static Logger LOG = LoggerFactory.getLogger(RegConvertor.class);
*/
@SuppressWarnings("unchecked")
@Override
- public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntries input, MatchPath path) {
+ public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
NxmNxRegBuilder nxRegBuilder = new NxmNxRegBuilder();
if (!org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg.class
.isAssignableFrom(input.getOxmMatchField())) {
nxRegBuilder
.setReg((Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg>) input
.getOxmMatchField());
- nxRegBuilder.setValue(input.getAugmentation(OfjAugNxMatch.class).getRegValues().getValue());
+ RegCaseValue regCaseValue = ((RegCaseValue) input.getMatchEntryValue());
+ nxRegBuilder.setValue(regCaseValue.getRegValues().getValue());
return resolveAugmentation(nxRegBuilder.build(), path, resolveRegKey(input.getOxmMatchField()));
}
-
+
private static Class<? extends ExtensionKey> resolveRegKey(Class<? extends MatchField> oxmMatchField) {
if (NiciraMatchCodecs.REG0_CODEC.getNxmField().isAssignableFrom(oxmMatchField)) {
return NxmNxReg0Key.class;
}
private static ExtensionAugment<? extends Augmentation<Extension>> resolveAugmentation(NxmNxReg nxmNxReg,
- MatchPath path, Class<? extends ExtensionKey> key) {
+ MatchPath path, Class<? extends ExtensionKey> key) {
switch (path) {
- case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH:
- return new ExtensionAugment<>(NxAugMatchNotifUpdateFlowStats.class,
- new NxAugMatchNotifUpdateFlowStatsBuilder().setNxmNxReg(nxmNxReg).build(), key);
- case PACKETRECEIVED_MATCH:
- return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder()
- .setNxmNxReg(nxmNxReg).build(), key);
- case SWITCHFLOWREMOVED_MATCH:
- return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class,
- new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmNxReg(nxmNxReg).build(), key);
- default:
- throw new CodecPreconditionException(path);
+ case FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH:
+ return new ExtensionAugment<>(NxAugMatchNotifUpdateFlowStats.class,
+ new NxAugMatchNotifUpdateFlowStatsBuilder().setNxmNxReg(nxmNxReg).build(), key);
+ case PACKETRECEIVED_MATCH:
+ return new ExtensionAugment<>(NxAugMatchNotifPacketIn.class, new NxAugMatchNotifPacketInBuilder()
+ .setNxmNxReg(nxmNxReg).build(), key);
+ case SWITCHFLOWREMOVED_MATCH:
+ return new ExtensionAugment<>(NxAugMatchNotifSwitchFlowRemoved.class,
+ new NxAugMatchNotifSwitchFlowRemovedBuilder().setNxmNxReg(nxmNxReg).build(), key);
+ default:
+ throw new CodecPreconditionException(path);
}
}
* .rev140714.general.extension.grouping.Extension)
*/
@Override
- public MatchEntries convert(Extension extension) {
+ public MatchEntry convert(Extension extension) {
Optional<NxmNxRegGrouping> matchGrouping = MatchUtil.regResolver.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
NxmNxReg nxmNxReg = matchGrouping.get().getNxmNxReg();
RegValuesBuilder regValuesBuilder = new RegValuesBuilder().setValue(nxmNxReg.getValue());
- OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder().setRegValues(regValuesBuilder.build());
- return MatchUtil.createNiciraMatchEntries(Nxm1Class.class, nxmNxReg.getReg(), false, augNxMatchBuilder.build());
+ RegCaseValueBuilder regCaseValueBuilder = new RegCaseValueBuilder();
+ regCaseValueBuilder.setRegValues(regValuesBuilder.build());
+ return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg.class,
+ Nxm1Class.class,
+ regCaseValueBuilder.build()).build();
}
}