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());
}
}
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());
}
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);
}
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;
}
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;
}
Aggregations