use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class OFPluginFlowTest method createMatch1.
private static MatchBuilder createMatch1() {
MatchBuilder match = new MatchBuilder();
Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
ipv4Match.setIpv4Destination(prefix);
Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
EthernetMatchBuilder eth = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class MatchResponseConvertorTest method checkDefaultV10.
private static void checkDefaultV10(final Match match, final FlowWildcardsV10 wc, final int vid) {
EthernetMatch ethMatch = match.getEthernetMatch();
if (wc.isDLSRC()) {
if (ethMatch != null) {
assertEquals(null, ethMatch.getEthernetSource());
}
} else {
assertEquals(MAC_SRC, ethMatch.getEthernetSource().getAddress());
}
if (ethMatch != null) {
if (wc.isDLDST()) {
assertEquals(null, ethMatch.getEthernetDestination());
} else {
assertNotEquals(null, ethMatch.getEthernetDestination());
assertEquals(MAC_DST, ethMatch.getEthernetDestination().getAddress());
}
}
if (wc.isDLTYPE()) {
if (ethMatch != null) {
assertEquals(null, ethMatch.getEthernetType());
}
assertEquals(null, match.getLayer3Match());
} else {
assert ethMatch != null;
assertEquals(ETHTYPE_IPV4, ethMatch.getEthernetType().getType().getValue().intValue());
Ipv4Match ipv4Match = (Ipv4Match) match.getLayer3Match();
assertEquals(IPV4_SRC.getValue() + "/32", ipv4Match.getIpv4Source().getValue());
assertEquals(IPV4_DST.getValue() + "/32", ipv4Match.getIpv4Destination().getValue());
}
VlanMatch vlanMatch = match.getVlanMatch();
if (wc.isDLVLAN()) {
assertEquals(null, vlanMatch);
} else {
int expectedVid;
Boolean expectedCfi;
if (vid == DL_VLAN_NONE) {
expectedVid = 0;
expectedCfi = Boolean.FALSE;
} else {
expectedVid = vid;
expectedCfi = Boolean.TRUE;
}
assertEquals(expectedVid, vlanMatch.getVlanId().getVlanId().getValue().intValue());
assertEquals(expectedCfi, vlanMatch.getVlanId().isVlanIdPresent());
if (wc.isDLVLANPCP()) {
assertEquals(null, vlanMatch.getVlanPcp());
} else {
assertEquals(VLAN_PCP, vlanMatch.getVlanPcp().getValue().shortValue());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createMatch33.
private static MatchBuilder createMatch33() {
final MatchBuilder match = new MatchBuilder();
final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
ipv4Match.setIpv4Source(prefix);
final Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
final EthernetMatchBuilder eth = new EthernetMatchBuilder();
final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0xfffeL));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction38.
private static InstructionsBuilder createAppyActionInstruction38() {
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();
// IPv4
final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
final Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
ipv4Match1.setIpv4Destination(dstip);
ipv4Match.setIpv4Source(srcip);
setFieldBuilder.setLayer3Match(ipv4Match.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
setFieldBuilder1.setLayer3Match(ipv4Match1.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._3.match.Ipv4Match in project openflowplugin by opendaylight.
the class SalToOfIpv4MatchCase method process.
@Override
public Optional<List<MatchEntry>> process(@Nonnull Ipv4Match source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
List<MatchEntry> result = new ArrayList<>();
if (source.getIpv4Source() != null) {
Ipv4Prefix ipv4Prefix = source.getIpv4Source();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
ipv4SrcBuilder.setIpv4Address(ipv4Address);
boolean hasMask = false;
byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
if (null != mask) {
ipv4SrcBuilder.setMask(mask);
hasMask = true;
}
matchEntryBuilder.setHasMask(hasMask);
Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
if (source.getIpv4Destination() != null) {
Ipv4Prefix ipv4Prefix = source.getIpv4Destination();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
ipv4DstBuilder.setIpv4Address(ipv4Address);
boolean hasMask = false;
byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
if (null != mask) {
ipv4DstBuilder.setMask(mask);
hasMask = true;
}
matchEntryBuilder.setHasMask(hasMask);
Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
return Optional.of(result);
}
Aggregations