use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder in project openflowplugin by opendaylight.
the class MatchConvertorTest method testTunnelIpv4MatchConversion.
@Test
public void testTunnelIpv4MatchConversion() {
MatchBuilder builder = new MatchBuilder();
TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
tunnelIpv4MatchBuilder.setTunnelIpv4Source(new Ipv4Prefix("10.0.0.1/32"));
tunnelIpv4MatchBuilder.setTunnelIpv4Destination(new Ipv4Prefix("10.0.0.2/32"));
builder.setLayer3Match(tunnelIpv4MatchBuilder.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, Ipv4Src.class, false);
Assert.assertEquals("Wrong ipv4 tunnel src", "10.0.0.1", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
entry = entries.get(1);
checkEntryHeader(entry, Ipv4Dst.class, false);
Assert.assertEquals("Wrong ipv4 tunnel dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createTunnelIpv4DstInstructions.
private static InstructionsBuilder createTunnelIpv4DstInstructions() {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
// Build the tunnel endpoint destination IPv4 address
final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
final Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.100");
// Add the mew IPv4 object as the tunnel destination
final TunnelIpv4MatchBuilder tunnelIpv4DstMatchBuilder = new TunnelIpv4MatchBuilder();
tunnelIpv4DstMatchBuilder.setTunnelIpv4Destination(dstIp);
setFieldBuilder.setLayer3Match(tunnelIpv4DstMatchBuilder.build());
// Add the IPv4 tunnel dst to the set_field value
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setOrder(0);
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_dst)
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Add the action to the ordered list of Instructions
final InstructionBuilder ib = new InstructionBuilder();
ib.setOrder(0);
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Add the 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._3.match.TunnelIpv4MatchBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createTunnelIpv4SrcInstructions.
private static InstructionsBuilder createTunnelIpv4SrcInstructions() {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
// Build the tunnel endpoint source IPv4 address
final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
final Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.200");
// Add the new IPv4 object as the tunnel destination
final TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
tunnelIpv4MatchBuilder.setTunnelIpv4Source(dstIp);
setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
// Add the IPv4 tunnel src to the set_field value
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setOrder(0);
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Add the action to the ordered list of Instructions
final InstructionBuilder ib = new InstructionBuilder();
ib.setOrder(0);
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._3.match.TunnelIpv4MatchBuilder in project openflowplugin by opendaylight.
the class TunnelIpv4DestinationEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Match ipv4match = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Destination(new Ipv4Prefix("10.0.2.0/24")).build()).build();
assertMatch(ipv4match, true, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 2, 0 });
byte[] mask = new byte[4];
out.readBytes(mask);
assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
});
final Match ipv4matchNoMask = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Destination(new Ipv4Prefix("10.0.0.0/32")).build()).build();
assertMatch(ipv4matchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
});
}
Aggregations