use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder in project openflowplugin by opendaylight.
the class OfToSalSctpDstCase method process.
@Override
public Optional<MatchBuilder> process(@Nonnull SctpDstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final SctpMatchBuilder sctpMatchBuilder = data.getSctpMatchBuilder();
SctpDst sctpDst = source.getSctpDst();
PortNumber portNumber = sctpDst.getPort();
if (portNumber != null) {
sctpMatchBuilder.setSctpDestinationPort(portNumber);
matchBuilder.setLayer4Match(sctpMatchBuilder.build());
}
return Optional.of(matchBuilder);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder in project openflowplugin by opendaylight.
the class MatchConvertorTest method testSctpMatchConversion.
@Test
public void testSctpMatchConversion() {
MatchBuilder builder = new MatchBuilder();
SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
sctpMatchBuilder.setSctpSourcePort(new PortNumber(11));
sctpMatchBuilder.setSctpDestinationPort(new PortNumber(12));
builder.setLayer4Match(sctpMatchBuilder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
checkEntryHeader(entry, SctpSrc.class, false);
Assert.assertEquals("Wrong sctp src", 11, ((SctpSrcCase) entry.getMatchEntryValue()).getSctpSrc().getPort().getValue().intValue());
entry = entries.get(1);
checkEntryHeader(entry, SctpDst.class, false);
Assert.assertEquals("Wrong sctp dst", 12, ((SctpDstCase) entry.getMatchEntryValue()).getSctpDst().getPort().getValue().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction41.
private static InstructionsBuilder createAppyActionInstruction41() {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
final ActionBuilder ab1 = new ActionBuilder();
final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// Sctp
final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
final SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
final PortNumber srcport = new PortNumber(1435);
final PortNumber dstport = new PortNumber(22);
sctpmatch.setSctpSourcePort(srcport);
sctpmatch1.setSctpDestinationPort(dstport);
setFieldBuilder.setLayer4Match(sctpmatch.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
setFieldBuilder1.setLayer4Match(sctpmatch1.build());
ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
final InstructionsBuilder isb = new InstructionsBuilder();
final List<Instruction> instructions = new ArrayList<>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder in project openflowplugin by opendaylight.
the class SctpSourcePortEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
processHeader(message);
final int port = message.readUnsignedShort();
if (Objects.isNull(builder.getLayer4Match())) {
builder.setLayer4Match(new SctpMatchBuilder().setSctpSourcePort(new PortNumber(port)).build());
} else if (SctpMatch.class.isInstance(builder.getLayer4Match()) && Objects.isNull(SctpMatch.class.cast(builder.getLayer4Match()).getSctpSourcePort())) {
builder.setLayer4Match(new SctpMatchBuilder(SctpMatch.class.cast(builder.getLayer4Match())).setSctpSourcePort(new PortNumber(port)).build());
} else {
throwErrorOnMalformed(builder, "layer4Match", "sctpSourcePort");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder in project openflowplugin by opendaylight.
the class SctpSourcePortEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final int sctp = 10;
final Match sctpMatch = new MatchBuilder().setLayer4Match(new SctpMatchBuilder().setSctpSourcePort(new PortNumber(sctp)).build()).build();
assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), sctp));
}
Aggregations