use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder in project openflowplugin by opendaylight.
the class SetTpDstActionSerializer method buildAction.
@Override
protected SetFieldCase buildAction(Action input) {
final SetTpDstAction setTpDstAction = SetTpDstActionCase.class.cast(input).getSetTpDstAction();
final PortNumber port = setTpDstAction.getPort();
final SetFieldBuilder builder = new SetFieldBuilder();
Optional.ofNullable(IPProtocols.fromProtocolNum(setTpDstAction.getIpProtocol())).ifPresent(proto -> {
switch(proto) {
case ICMP:
{
builder.setIcmpv4Match(new Icmpv4MatchBuilder().setIcmpv4Code((short) (0xFF & port.getValue())).build());
break;
}
case ICMPV6:
{
builder.setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Code((short) (0xFF & port.getValue())).build());
break;
}
case TCP:
{
builder.setLayer4Match(new TcpMatchBuilder().setTcpDestinationPort(port).build());
break;
}
case UDP:
{
builder.setLayer4Match(new UdpMatchBuilder().setUdpDestinationPort(port).build());
break;
}
default:
}
});
return new SetFieldCaseBuilder().setSetField(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder in project openflowplugin by opendaylight.
the class UdpSourcePortEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final int tcp = 10;
final Match sctpMatch = new MatchBuilder().setLayer4Match(new UdpMatchBuilder().setUdpSourcePort(new PortNumber(tcp)).build()).build();
assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), tcp));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder in project openflowplugin by opendaylight.
the class MatchConvertorV10Test method createL4UdpMatch.
private static MatchBuilder createL4UdpMatch() {
MatchBuilder matchBuilder = createMatchBuilderWithDefaults();
UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
udpMatchBuilder.setUdpDestinationPort(DEFAULT_PORT);
udpMatchBuilder.setUdpSourcePort(DEFAULT_PORT);
matchBuilder.setLayer4Match(udpMatchBuilder.build());
return matchBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder in project openflowplugin by opendaylight.
the class MatchConvertorTest method testUdpMatchConversion.
@Test
public void testUdpMatchConversion() {
MatchBuilder builder = new MatchBuilder();
UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
udpMatchBuilder.setUdpSourcePort(new PortNumber(11));
udpMatchBuilder.setUdpDestinationPort(new PortNumber(12));
builder.setLayer4Match(udpMatchBuilder.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, UdpSrc.class, false);
Assert.assertEquals("Wrong udp src", 11, ((UdpSrcCase) entry.getMatchEntryValue()).getUdpSrc().getPort().getValue().intValue());
entry = entries.get(1);
checkEntryHeader(entry, UdpDst.class, false);
Assert.assertEquals("Wrong udp dst", 12, ((UdpDstCase) entry.getMatchEntryValue()).getUdpDst().getPort().getValue().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction40.
private static InstructionsBuilder createAppyActionInstruction40() {
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();
// Udp
final PortNumber udpsrcport = new PortNumber(1325);
final PortNumber udpdstport = new PortNumber(42);
final UdpMatchBuilder udpmatch = new UdpMatchBuilder();
final UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
udpmatch.setUdpDestinationPort(udpdstport);
udpmatch1.setUdpSourcePort(udpsrcport);
setFieldBuilder.setLayer4Match(udpmatch.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
setFieldBuilder1.setLayer4Match(udpmatch1.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;
}
Aggregations