use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.
the class PbbEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final long pbb = message.readUnsignedMedium();
final PbbBuilder pbbBuilder = new PbbBuilder().setPbbIsid(pbb);
if (hasMask) {
pbbBuilder.setPbbMask((long) message.readUnsignedMedium());
}
if (Objects.isNull(builder.getProtocolMatchFields())) {
builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setPbb(pbbBuilder.build()).build());
} else if (Objects.isNull(builder.getProtocolMatchFields().getPbb())) {
builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields()).setPbb(pbbBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "protocolMatchFields", "pbb");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.
the class MplsLabelEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final int mplsLabel = 10;
writeHeader(in, false);
in.writeInt(mplsLabel);
ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
assertEquals(mplsLabel, match.getMplsLabel().intValue());
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.
the class PbbEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final long pbb = 6;
final long pbbMask = 5;
writeHeader(in, false);
in.writeMedium((int) pbb);
ProtocolMatchFields match = deserialize(in).getProtocolMatchFields();
assertEquals(pbb, match.getPbb().getPbbIsid().longValue());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
in.writeMedium((int) pbb);
in.writeMedium((int) pbbMask);
match = deserialize(in).getProtocolMatchFields();
assertEquals(pbb, match.getPbb().getPbbIsid().longValue());
assertEquals(pbbMask, match.getPbb().getPbbMask().longValue());
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields in project openflowplugin by opendaylight.
the class MplsBosEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
processHeader(message);
final short mplsBos = message.readUnsignedByte();
if (Objects.isNull(builder.getProtocolMatchFields())) {
builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder().setMplsBos(mplsBos).build());
} else if (Objects.isNull(builder.getProtocolMatchFields().getMplsBos())) {
builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields()).setMplsBos(mplsBos).build());
} else {
throwErrorOnMalformed(builder, "protocolMatchFields", "mplsBos");
}
}
Aggregations