Search in sources :

Example 81 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message in project openflowplugin by opendaylight.

the class VlanVidEntryDeserializer method deserializeEntry.

@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
    final boolean hasMask = processHeader(message);
    final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
    final int vlanVidValue = message.readUnsignedShort();
    if (hasMask) {
        // Skip mask
        message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
        vlanIdBuilder.setVlanId(new VlanId(0)).setVlanIdPresent(true);
    } else {
        final boolean vidPresent = (vlanVidValue & (1 << 12)) != 0;
        vlanIdBuilder.setVlanId(new VlanId((vidPresent ? vlanVidValue & ((1 << 12) - 1) : vlanVidValue))).setVlanIdPresent(vidPresent);
    }
    if (Objects.isNull(builder.getVlanMatch())) {
        builder.setVlanMatch(new VlanMatchBuilder().setVlanId(vlanIdBuilder.build()).build());
    } else if (Objects.isNull(builder.getVlanMatch().getVlanId())) {
        builder.setVlanMatch(new VlanMatchBuilder(builder.getVlanMatch()).setVlanId(vlanIdBuilder.build()).build());
    } else {
        throwErrorOnMalformed(builder, "vlanMatch", "vlanVid");
    }
}
Also used : VlanMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder) VlanIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)

Example 82 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message in project openflowplugin by opendaylight.

the class FlowMessageDeserializer method deserialize.

@Override
@SuppressWarnings("checkstyle:LineLength")
public FlowMessage deserialize(ByteBuf message) {
    final FlowMessageBuilder builder = new FlowMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCookie(new FlowCookie(BigInteger.valueOf(message.readLong()))).setCookieMask(new FlowCookie(BigInteger.valueOf(message.readLong()))).setTableId(message.readUnsignedByte()).setCommand(FlowModCommand.forValue(message.readUnsignedByte())).setIdleTimeout(message.readUnsignedShort()).setHardTimeout(message.readUnsignedShort()).setPriority(message.readUnsignedShort()).setBufferId(message.readUnsignedInt()).setOutPort(BigInteger.valueOf(message.readUnsignedInt())).setOutGroup(message.readUnsignedInt()).setFlags(createFlowModFlagsFromBitmap(message.readUnsignedShort()));
    message.skipBytes(PADDING);
    final OFDeserializer<Match> matchDeserializer = Preconditions.checkNotNull(registry).getDeserializer(MATCH_KEY);
    builder.setMatch(new MatchBuilder(matchDeserializer.deserialize(message)).build());
    final int length = message.readableBytes();
    if (length > 0) {
        final List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> instructions = new ArrayList<>();
        final int startIndex = message.readerIndex();
        int offset = 0;
        while (message.readerIndex() - startIndex < length) {
            final int type = message.getUnsignedShort(message.readerIndex());
            OFDeserializer<Instruction> deserializer = null;
            if (InstructionConstants.APPLY_ACTIONS_TYPE == type) {
                deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeActionExperimenterKey(EncodeConstants.OF13_VERSION_ID, type, Instruction.class, ActionPath.INVENTORY_FLOWNODE_TABLE_APPLY_ACTIONS, null));
            } else if (InstructionConstants.WRITE_ACTIONS_TYPE == type) {
                deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeActionExperimenterKey(EncodeConstants.OF13_VERSION_ID, type, Instruction.class, ActionPath.INVENTORY_FLOWNODE_TABLE_WRITE_ACTIONS, null));
            } else {
                Long expId = null;
                if (EncodeConstants.EXPERIMENTER_VALUE == type) {
                    expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
                }
                deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeExperimenterKey(EncodeConstants.OF13_VERSION_ID, type, Instruction.class, expId));
            }
            instructions.add(new InstructionBuilder().setKey(new InstructionKey(offset)).setOrder(offset).setInstruction(deserializer.deserialize(message)).build());
            offset++;
        }
        builder.setInstructions(new InstructionsBuilder().setInstruction(instructions).build());
    }
    return builder.build();
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) ArrayList(java.util.ArrayList) FlowMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessageBuilder) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction) MessageCodeExperimenterKey(org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) MessageCodeActionExperimenterKey(org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeActionExperimenterKey)

Example 83 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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();
}
Also used : OFDeserializer(org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer) DscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder) MeterBandType(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType) MeterBandTypesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder) ArrayList(java.util.ArrayList) MeterBandHeaderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder) DropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DropBuilder) ExperimenterIdDeserializerKey(org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterBandHeadersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder) MeterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterMessageBuilder) MeterBandHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)

Example 84 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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");
    }
}
Also used : Layer3Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match) ArpSourceHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)

Example 85 with Message

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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");
    }
}
Also used : Layer3Match(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match) ArpTargetHardwareAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder) ArpMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch) ArpMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder)

Aggregations

Test (org.junit.Test)192 ByteBuf (io.netty.buffer.ByteBuf)179 ArrayList (java.util.ArrayList)84 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)53 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)45 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)44 BigInteger (java.math.BigInteger)40 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)26 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)25 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)25 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)22 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)20 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)18 List (java.util.List)17 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)17 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)17 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message)16 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)15 Message (org.eclipse.bpmn2.Message)13 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)13