use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv4UdpMatchTest.
@Test
public void buildIpv4UdpMatchTest() {
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
aceIpBuilder.setProtocol(IPProtocols.UDP.shortValue());
SourcePortRangeBuilder srcPortRange = new SourcePortRangeBuilder();
srcPortRange.setLowerPort(new PortNumber(UDP_SRC_LOWER_PORT));
srcPortRange.setUpperPort(new PortNumber(UDP_SRC_UPPER_PORT));
aceIpBuilder.setSourcePortRange(srcPortRange.build());
DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
dstPortRange.setLowerPort(new PortNumber(UDP_DST_LOWER_PORT));
dstPortRange.setUpperPort(new PortNumber(UDP_DST_UPPER_PORT));
aceIpBuilder.setDestinationPortRange(dstPortRange.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// There should be an IPv4 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
// Make sure its UDP
IpMatch ipMatch = matchBuilder.getIpMatch();
assertNotNull(ipMatch);
assertEquals(ipMatch.getIpProtocol(), Short.valueOf(IPProtocols.UDP.shortValue()));
// Currently ranges arent supported, only the lower port is used
UdpMatch udpMatch = (UdpMatch) matchBuilder.getLayer4Match();
assertEquals(udpMatch.getUdpSourcePort().getValue(), Integer.valueOf(UDP_SRC_LOWER_PORT));
assertEquals(udpMatch.getUdpDestinationPort().getValue(), Integer.valueOf(UDP_DST_LOWER_PORT));
// The layer3 match should be null
assertNull(matchBuilder.getLayer3Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createL4UDPMatch.
private static MatchBuilder createL4UDPMatch() {
final MatchBuilder match = new MatchBuilder();
final EthernetMatchBuilder eth = new EthernetMatchBuilder();
final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
// ipv4 version
final IpMatchBuilder ipmatch = new IpMatchBuilder();
ipmatch.setIpProtocol((short) 17);
match.setIpMatch(ipmatch.build());
final PortNumber srcport = new PortNumber(1325);
final PortNumber dstport = new PortNumber(42);
// udp match
final UdpMatchBuilder udpmatch = new UdpMatchBuilder();
udpmatch.setUdpDestinationPort(dstport);
udpmatch.setUdpSourcePort(srcport);
match.setLayer4Match(udpmatch.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch in project openflowplugin by opendaylight.
the class SalToOfUdpMatchCase method process.
@Override
public Optional<List<MatchEntry>> process(@Nonnull UdpMatch source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
List<MatchEntry> result = new ArrayList<>();
if (source.getUdpSourcePort() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(UdpSrc.class);
UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
udpSrcBuilder.setPort(source.getUdpSourcePort());
udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
matchEntryBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
matchEntryBuilder.setHasMask(false);
result.add(matchEntryBuilder.build());
}
if (source.getUdpDestinationPort() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(UdpDst.class);
UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
udpDstBuilder.setPort(source.getUdpDestinationPort());
udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
matchEntryBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
matchEntryBuilder.setHasMask(false);
result.add(matchEntryBuilder.build());
}
return Optional.of(result);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testLayer4MatchUdp.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testLayer4MatchUdp() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc.class);
entriesBuilder.setHasMask(false);
final UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
final UdpSrcBuilder portBuilder = new UdpSrcBuilder();
portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(11));
udpSrcCaseBuilder.setUdpSrc(portBuilder.build());
entriesBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(UdpDst.class);
entriesBuilder.setHasMask(false);
final UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
final UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(12));
udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
entriesBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
entries.add(entriesBuilder.build());
builder.setMatchEntry(entries);
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder builtMatch = convert(builder.build(), datapathIdConvertorData);
final UdpMatch udpMatch = (UdpMatch) builtMatch.getLayer4Match();
Assert.assertEquals("Wrong udp src port", 11, udpMatch.getUdpSourcePort().getValue().intValue());
Assert.assertEquals("Wrong udp dst port", 12, udpMatch.getUdpDestinationPort().getValue().intValue());
}
Aggregations