Search in sources :

Example 1 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags in project openflowplugin by opendaylight.

the class OnfOxmTcpFlagsSerializer method serialize.

@Override
public void serialize(MatchEntry entry, ByteBuf outBuffer) {
    super.serialize(entry, outBuffer);
    ExperimenterIdCase expCase = serializeExperimenterId(entry, outBuffer);
    TcpFlags tcpFlags = expCase.getAugmentation(TcpFlagsContainer.class).getTcpFlags();
    outBuffer.writeShort(tcpFlags.getFlags());
    if (entry.isHasMask()) {
        outBuffer.writeBytes(tcpFlags.getMask());
    }
}
Also used : ExperimenterIdCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase) TcpFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlags) TcpFlagsContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer)

Example 2 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags in project openflowplugin by opendaylight.

the class TcpFlagsEntryDeserializerTest method deserializeEntry.

@Test
public void deserializeEntry() throws Exception {
    final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
    final int tcpFlags = 6;
    final int tcpFlagsMask = 5;
    writeHeader(in, false);
    in.writeInt((int) EncodeConstants.ONF_EXPERIMENTER_ID);
    in.writeShort(tcpFlags);
    TcpFlagsMatch match = deserialize(in).getTcpFlagsMatch();
    assertEquals(tcpFlags, match.getTcpFlags().intValue());
    assertEquals(0, in.readableBytes());
    writeHeader(in, true);
    in.writeInt((int) EncodeConstants.ONF_EXPERIMENTER_ID);
    in.writeShort(tcpFlags);
    in.writeShort(tcpFlagsMask);
    match = deserialize(in).getTcpFlagsMatch();
    assertEquals(tcpFlags, match.getTcpFlags().intValue());
    assertEquals(tcpFlagsMask, match.getTcpFlagsMask().intValue());
    assertEquals(0, in.readableBytes());
}
Also used : TcpFlagsMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 3 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags in project openflowplugin by opendaylight.

the class OfToSalExperimenterIdCase method process.

@Override
public Optional<MatchBuilder> process(@Nonnull ExperimenterIdCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
    final MatchBuilder matchBuilder = data.getMatchBuilder();
    if (data.getOxmMatchField().equals(TcpFlags.class)) {
        final TcpFlagsMatchBuilder tcpFlagsMatchBuilder = data.getTcpFlagsMatchBuilder();
        final TcpFlagsContainer tcpFlagsContainer = source.getAugmentation(TcpFlagsContainer.class);
        if (tcpFlagsContainer != null) {
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlags tcpFlags = tcpFlagsContainer.getTcpFlags();
            tcpFlagsMatchBuilder.setTcpFlags(tcpFlags.getFlags());
            byte[] mask = tcpFlags.getMask();
            if (mask != null) {
                tcpFlagsMatchBuilder.setTcpFlagsMask(ByteUtil.bytesToUnsignedShort(mask));
            }
            matchBuilder.setTcpFlagsMatch(tcpFlagsMatchBuilder.build());
        }
    }
    return Optional.of(matchBuilder);
}
Also used : TcpFlagsMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder) TcpFlagsContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) TcpFlagsMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder)

Example 4 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method createTcpFlags.

private static List<TcpFlags> createTcpFlags(final UnkeyedListNode tcpFlagsData) {
    final List<TcpFlags> tcpFlags = new ArrayList<>();
    for (final UnkeyedListEntryNode node : tcpFlagsData.body()) {
        final TcpFlagsBuilder tcpFlagsBuilder = new TcpFlagsBuilder();
        node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> tcpFlagsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
        node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> tcpFlagsBuilder.setValue((Uint16) dataContainerChild.body()));
        tcpFlags.add(tcpFlagsBuilder.build());
    }
    return tcpFlags;
}
Also used : TcpFlagsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder) TcpFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags) ArrayList(java.util.ArrayList) Uint16(org.opendaylight.yangtools.yang.common.Uint16) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)

Example 5 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags in project bgpcep by opendaylight.

the class FSTcpFlagsHandler method parseTcpFlags.

private static List<TcpFlags> parseTcpFlags(final ByteBuf nlri) {
    final List<TcpFlags> flags = new ArrayList<>();
    boolean end = false;
    // we can do this as all fields will be rewritten in the cycle
    final TcpFlagsBuilder builder = new TcpFlagsBuilder();
    while (!end) {
        final byte b = nlri.readByte();
        final BitmaskOperand op = BitmaskOperandParser.INSTANCE.parse(b);
        builder.setOp(op);
        final short length = AbstractOperandParser.parseLength(b);
        builder.setValue(Uint16.valueOf(ByteArray.bytesToInt(ByteArray.readBytes(nlri, length))));
        end = op.getEndOfList();
        flags.add(builder.build());
    }
    return flags;
}
Also used : TcpFlagsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder) TcpFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags) ArrayList(java.util.ArrayList) BitmaskOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.BitmaskOperand)

Aggregations

TcpFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags)4 ByteBuf (io.netty.buffer.ByteBuf)2 ArrayList (java.util.ArrayList)2 TcpFlagsContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer)2 TcpFlagsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder)2 Test (org.junit.Test)1 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)1 TcpFlagsMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatch)1 TcpFlagsMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder)1 TcpFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlags)1 ExperimenterIdCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase)1 BitmaskOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.BitmaskOperand)1 Uint16 (org.opendaylight.yangtools.yang.common.Uint16)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1