use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project openflowplugin by opendaylight.
the class Nshc4Convertor method convert.
@Override
public MatchEntry convert(Extension extension) {
Optional<NxmNxNshc4Grouping> matchGrouping = MatchUtil.NSC4_RESOLVER.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
Long value = matchGrouping.get().getNxmNxNshc4().getValue();
Nshc4CaseValueBuilder nsc4CaseValueBuilder = new Nshc4CaseValueBuilder();
nsc4CaseValueBuilder.setNshc4Values(new Nshc4ValuesBuilder().setNshc(value).build());
return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNshc4.class, Nxm1Class.class, nsc4CaseValueBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project openflowplugin by opendaylight.
the class NspConvertor method convert.
@Override
public MatchEntry convert(Extension extension) {
Optional<NxmNxNspGrouping> matchGrouping = MatchUtil.NSP_RESOLVER.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
Long value = matchGrouping.get().getNxmNxNsp().getValue();
NspCaseValueBuilder nspCaseValueBuilder = new NspCaseValueBuilder();
nspCaseValueBuilder.setNspValues(new NspValuesBuilder().setNsp(value).build());
return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxNsp.class, Nxm1Class.class, nspCaseValueBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project openflowplugin by opendaylight.
the class RegConvertor method convert.
@SuppressWarnings("unchecked")
@Override
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())) {
String msg = input.getOxmMatchField() + " does not implement " + org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg.class;
LOG.warn(msg);
throw new IllegalStateException(msg);
}
nxRegBuilder.setReg((Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg>) input.getOxmMatchField());
RegCaseValue regCaseValue = (RegCaseValue) input.getMatchEntryValue();
nxRegBuilder.setValue(regCaseValue.getRegValues().getValue());
if (input.isHasMask()) {
nxRegBuilder.setMask(regCaseValue.getRegValues().getMask());
}
return resolveAugmentation(nxRegBuilder.build(), path, resolveRegKey(input.getOxmMatchField()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project openflowplugin by opendaylight.
the class TcpSrcConvertor method convert.
@Override
public ExtensionAugment<? extends Augmentation<Extension>> convert(MatchEntry input, MatchPath path) {
TcpSrcCaseValue tcpSrcCaseValue = (TcpSrcCaseValue) input.getMatchEntryValue();
NxmOfTcpSrcBuilder tcpSrcBuilder = new NxmOfTcpSrcBuilder();
tcpSrcBuilder.setPort(tcpSrcCaseValue.getTcpSrcValues().getPort());
tcpSrcBuilder.setMask(tcpSrcCaseValue.getTcpSrcValues().getMask());
return resolveAugmentation(tcpSrcBuilder.build(), path, NxmOfTcpSrcKey.class);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension in project openflowplugin by opendaylight.
the class MatchConvertor method convert.
@Override
public List<MatchEntry> convert(final Match source, final VersionConvertorData data) {
List<MatchEntry> result = new ArrayList<>();
if (source == null) {
return result;
}
final ExtensionConverterProvider extensionConvertorProvider = OFSessionUtil.getExtensionConvertorProvider();
inPortMatch(result, source.getInPort());
inPhyPortMatch(result, source.getInPhyPort());
metadataMatch(result, source.getMetadata());
ethernetMatch(result, source.getEthernetMatch());
vlanMatch(result, source.getVlanMatch());
ipMatch(result, source.getIpMatch());
layer4Match(result, source.getLayer4Match(), getConvertorExecutor(), extensionConvertorProvider);
icmpv4Match(result, source.getIcmpv4Match());
icmpv6Match(result, source.getIcmpv6Match());
layer3Match(result, source.getLayer3Match(), getConvertorExecutor(), extensionConvertorProvider);
protocolMatchFields(result, source.getProtocolMatchFields());
tunnelMatch(result, source.getTunnel());
tcpFlagsMatch(result, source.getTcpFlagsMatch());
/*
* TODO: EXTENSION PROPOSAL (source, MD-SAL to OFJava)
* - we might need version for conversion and for key
*/
Optional<GeneralExtensionListGrouping> extensionListOpt = ExtensionResolvers.getMatchExtensionResolver().getExtension(source);
if (extensionListOpt.isPresent()) {
List<ExtensionList> extensionListList = extensionListOpt.get().getExtensionList();
for (ExtensionList extensionItem : extensionListList) {
// TODO: get real version
ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3);
ConvertorToOFJava<MatchEntry> convertor = extensionConvertorProvider.getConverter(key);
if (convertor == null) {
throw new IllegalStateException("No converter found for key: " + key.toString());
}
MatchEntry ofMatch = convertor.convert(extensionItem.getExtension());
result.add(ofMatch);
}
}
return result;
}
Aggregations