use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder in project openflowplugin by opendaylight.
the class TcpFlagsEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
// Just skip experimenter ID for now, not used
message.readUnsignedInt();
final TcpFlagsMatchBuilder tcpFlagsBuilder = new TcpFlagsMatchBuilder().setTcpFlags(message.readUnsignedShort());
if (hasMask) {
tcpFlagsBuilder.setTcpFlagsMask(message.readUnsignedShort());
}
if (Objects.isNull(builder.getTcpFlagsMatch())) {
builder.setTcpFlagsMatch(tcpFlagsBuilder.build());
} else {
throwErrorOnMalformed(builder, "tcpFlagsMatch");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder in project bgpcep by opendaylight.
the class SimpleFlowspecIpv4NlriParserTest method testExtractFlowspecSourceTcpFlags.
@Test
public void testExtractFlowspecSourceTcpFlags() {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry = Builders.mapEntryBuilder();
entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.choiceBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID).withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.TCP_FLAGS_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID).withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID).withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE)).build()).withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID).withValue(Uint16.valueOf(99)).build()).build()).build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(Lists.newArrayList(new TcpFlagsBuilder().setValue(Uint16.valueOf(99)).setOp(new BitmaskOperand(true, true, false, false)).build())).build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder 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.TcpFlagsBuilder in project openflowplugin by opendaylight.
the class OnfOxmTcpFlagsDeserializer method addTcpFlagsAugmentation.
private static void addTcpFlagsAugmentation(ByteBuf input, ExperimenterIdCaseBuilder expCaseBuilder, boolean hasMask) {
TcpFlagsContainerBuilder flagsContainerBuilder = new TcpFlagsContainerBuilder();
TcpFlagsBuilder flagsBuilder = new TcpFlagsBuilder();
flagsBuilder.setFlags(input.readUnsignedShort());
if (hasMask) {
byte[] mask = new byte[EncodeConstants.SIZE_OF_SHORT_IN_BYTES];
input.readBytes(mask);
flagsBuilder.setMask(mask);
}
flagsContainerBuilder.setTcpFlags(flagsBuilder.build());
expCaseBuilder.addAugmentation(TcpFlagsContainer.class, flagsContainerBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.tcp.flags._case.TcpFlagsBuilder in project openflowplugin by opendaylight.
the class MatchConvertor method tcpFlagsMatch.
private static void tcpFlagsMatch(List<MatchEntry> matchEntryList, TcpFlagsMatch tcpFlagsMatch) {
ExperimenterIdCaseBuilder expIdCaseBuilder = new ExperimenterIdCaseBuilder();
if (tcpFlagsMatch != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(ExperimenterClass.class);
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setOxmMatchField(TcpFlags.class);
TcpFlagsContainerBuilder tcpFlagsContainerBuilder = new TcpFlagsContainerBuilder();
TcpFlagsBuilder tcpFlagsBuilder = new TcpFlagsBuilder();
tcpFlagsBuilder.setFlags(tcpFlagsMatch.getTcpFlags());
if (tcpFlagsMatch.getTcpFlagsMask() != null) {
matchEntryBuilder.setHasMask(true);
tcpFlagsBuilder.setMask(ByteUtil.unsignedShortToBytes(tcpFlagsMatch.getTcpFlagsMask()));
}
tcpFlagsContainerBuilder.setTcpFlags(tcpFlagsBuilder.build());
// Set experimenter ID.
ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder();
experimenterBuilder.setExperimenter(new ExperimenterId(OFApprovedExperimenterIds.MATCH_TCP_FLAGS_EXP_ID));
expIdCaseBuilder.setExperimenter(experimenterBuilder.build());
expIdCaseBuilder.addAugmentation(TcpFlagsContainer.class, tcpFlagsContainerBuilder.build());
matchEntryBuilder.setMatchEntryValue(expIdCaseBuilder.build());
matchEntryList.add(matchEntryBuilder.build());
}
}
Aggregations