use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project openflowplugin by opendaylight.
the class MeterMessageDeserializer method deserialize.
@Override
public MeterMessage deserialize(ByteBuf message) {
final MeterMessageBuilder builder = new MeterMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(MeterModCommand.forValue(message.readUnsignedShort())).setFlags(readMeterFlags(message)).setMeterId(new MeterId(message.readUnsignedInt()));
final List<MeterBandHeader> bands = new ArrayList<>();
while (message.readableBytes() > 0) {
final MeterBandHeaderBuilder bandBuilder = new MeterBandHeaderBuilder();
final int bandStartIndex = message.readerIndex();
final int bandType = message.readUnsignedShort();
switch(bandType) {
case OFPMBTDROP:
{
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(true, false, false)).build()).setBandType(new DropBuilder().setDropRate(message.readUnsignedInt()).setDropBurstSize(message.readUnsignedInt()).build());
message.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
break;
}
case OFPMBTDSCP:
{
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, true, false)).build()).setBandType(new DscpRemarkBuilder().setDscpRemarkRate(message.readUnsignedInt()).setDscpRemarkBurstSize(message.readUnsignedInt()).setPrecLevel(message.readUnsignedByte()).build());
message.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
break;
}
case OFPMBTEXPERIMENTER:
{
// TODO: Finish meter band experimenter deserialization
long expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
message.readerIndex(bandStartIndex);
OFDeserializer<Experimenter> deserializer = registry.getDeserializer(new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, Experimenter.class));
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, false, true)).build()).setBandType(deserializer.deserialize(message));
break;
}
default:
}
bands.add(bandBuilder.build());
}
return builder.setMeterBandHeaders(new MeterBandHeadersBuilder().setMeterBandHeader(bands).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project openflowplugin by opendaylight.
the class ArpSourceHardwareAddressEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final Layer3Match layer3Match = builder.getLayer3Match();
final ArpSourceHardwareAddressBuilder arpBuilder = new ArpSourceHardwareAddressBuilder().setAddress(OxmDeserializerHelper.convertMacAddress(message));
if (hasMask) {
arpBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
}
if (Objects.isNull(layer3Match)) {
builder.setLayer3Match(new ArpMatchBuilder().setArpSourceHardwareAddress(arpBuilder.build()).build());
} else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpSourceHardwareAddress())) {
builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpSourceHardwareAddress(arpBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "arpSourceHardwareAddress");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project openflowplugin by opendaylight.
the class ArpTargetHardwareAddressEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final Layer3Match layer3Match = builder.getLayer3Match();
final ArpTargetHardwareAddressBuilder arpBuilder = new ArpTargetHardwareAddressBuilder().setAddress(OxmDeserializerHelper.convertMacAddress(message));
if (hasMask) {
arpBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
}
if (Objects.isNull(layer3Match)) {
builder.setLayer3Match(new ArpMatchBuilder().setArpTargetHardwareAddress(arpBuilder.build()).build());
} else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpTargetHardwareAddress())) {
builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpTargetHardwareAddress(arpBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "arpTargetHardwareAddress");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project openflowplugin by opendaylight.
the class EthernetDestinationEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final EthernetMatch ethernetMatch = builder.getEthernetMatch();
final EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
ethernetDestinationBuilder.setAddress(OxmDeserializerHelper.convertMacAddress(message));
if (hasMask) {
ethernetDestinationBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
}
if (Objects.isNull(ethernetMatch)) {
builder.setEthernetMatch(new EthernetMatchBuilder().setEthernetDestination(ethernetDestinationBuilder.build()).build());
} else if (Objects.isNull(ethernetMatch.getEthernetDestination())) {
builder.setEthernetMatch(new EthernetMatchBuilder(ethernetMatch).setEthernetDestination(ethernetDestinationBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "ethernetMatch", "ethernetDestination");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.add.bundle.messages.input.messages.Message in project openflowplugin by opendaylight.
the class MessageDeserializerInjector method injectDeserializers.
/**
* Injects message deserializers into provided.
* {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider}
*
* @param provider OpenflowJava deserializer extension provider
*/
static void injectDeserializers(final DeserializerExtensionProvider provider) {
// Inject new message deserializers here using injector created by createInjector method
final Function<Integer, Function<Class<? extends OfHeader>, Consumer<OFDeserializer<? extends OfHeader>>>> injector = createInjector(provider, EncodeConstants.OF13_VERSION_ID);
injector.apply(10).apply(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInMessage.class).accept(new PacketInMessageDeserializer());
injector.apply(19).apply(MultipartReply.class).accept(new MultipartReplyMessageDeserializer());
injector.apply(27).apply(AsyncConfigMessage.class).accept(new AsyncConfigMessageDeserializer());
}
Aggregations