use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.
the class PacketReceivedTranslator method getPacketInMatch.
@VisibleForTesting
org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match getPacketInMatch(final PacketInMessage input, final BigInteger datapathId) {
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(input.getVersion());
datapathIdConvertorData.setDatapathId(datapathId);
final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder> matchOptional = convertorExecutor.convert(input.getMatch(), datapathIdConvertorData);
final MatchBuilder matchBuilder = matchOptional.map(matchBuilder1 -> new MatchBuilder(matchBuilder1.build())).orElseGet(MatchBuilder::new);
final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()), MatchPath.PACKET_RECEIVED_MATCH);
if (matchExtensionWrap != null) {
matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
}
return matchBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.
the class UdpDestinationPortEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final int tcp = 10;
final Match sctpMatch = new MatchBuilder().setLayer4Match(new UdpMatchBuilder().setUdpDestinationPort(new PortNumber(tcp)).build()).build();
assertMatch(sctpMatch, false, (out) -> assertEquals(out.readUnsignedShort(), tcp));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.
the class InPortEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final int port = 42;
final Match match = new MatchBuilder().setInPort(new NodeConnectorId("openflow:1:" + port)).build();
assertMatch(match, false, (out) -> assertEquals(out.readUnsignedInt(), port));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.
the class IpEcnEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final short ecn = (short) 58;
final Match match = new MatchBuilder().setIpMatch(new IpMatchBuilder().setIpEcn(ecn).build()).build();
assertMatch(match, false, (out) -> assertEquals(out.readUnsignedByte(), ecn));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder in project openflowplugin by opendaylight.
the class Ipv4ArbitraryBitMaskDestinationEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Ipv4Address ipv4Address = new Ipv4Address("192.168.10.0");
final DottedQuad ipv4mask = new DottedQuad("255.255.255.0");
final Match ipv4abmMatch = new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4DestinationAddressNoMask(ipv4Address).setIpv4DestinationArbitraryBitmask(ipv4mask).build()).build();
assertMatch(ipv4abmMatch, true, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { (byte) 192, (byte) 168, 10, 0 });
byte[] mask = new byte[4];
out.readBytes(mask);
assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
});
final Match ipv4abmMatchNoMask = new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4DestinationAddressNoMask(ipv4Address).build()).build();
assertMatch(ipv4abmMatchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { (byte) 192, (byte) 168, 10, 0 });
});
}
Aggregations