Search in sources :

Example 1 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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.getValue()) {
        final TcpFlagsBuilder tcpFlagsBuilder = new TcpFlagsBuilder();
        final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
        if (opValue.isPresent()) {
            tcpFlagsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
        }
        final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
        if (valueNode.isPresent()) {
            tcpFlagsBuilder.setValue((Integer) valueNode.get().getValue());
        }
        tcpFlags.add(tcpFlagsBuilder.build());
    }
    return tcpFlags;
}
Also used : TcpFlagsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder) TcpFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags) Set(java.util.Set) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)

Example 2 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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 3 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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 4 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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 5 with TcpFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method stringTcpFlags.

private static String stringTcpFlags(final List<TcpFlags> flags) {
    final StringBuilder buffer = new StringBuilder("where TCP flags ");
    boolean isFirst = true;
    for (final TcpFlags item : flags) {
        buffer.append(BitmaskOperandParser.INSTANCE.toString(item.getOp(), isFirst));
        buffer.append(item.getValue());
        buffer.append(' ');
        if (isFirst) {
            isFirst = false;
        }
    }
    return buffer.toString();
}
Also used : TcpFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlags)

Aggregations

TcpFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.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.rev171207.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder)2 Set (java.util.Set)1 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.rev171207.BitmaskOperand)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1