use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project openflowplugin by opendaylight.
the class BulkOMaticUtils method getMatch.
public static Match getMatch(final int sourceIp) {
Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(ipIntToStr(sourceIp))).build();
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setLayer3Match(ipv4Match);
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
ethTypeBuilder.setType(new EtherType(2048L));
ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
matchBuilder.setEthernetMatch(ethMatchBuilder.build());
return matchBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project openflowplugin by opendaylight.
the class ArpSourceTransportAddressEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final Ipv4Prefix arpSourceTransportAddress = new Ipv4Prefix("192.168.0.0/24");
final Ipv4Prefix arpSourceTransportAddressNoMask = new Ipv4Prefix("192.168.0.0/32");
writeHeader(in, false);
Iterator<String> addressParts = IpConversionUtil.splitToParts(arpSourceTransportAddressNoMask);
in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
assertEquals(arpSourceTransportAddressNoMask.getValue(), ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceTransportAddress().getValue());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
addressParts = IpConversionUtil.splitToParts(arpSourceTransportAddress);
in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
in.writeBytes(MatchConvertorUtil.extractIpv4Mask(addressParts));
final Ipv4Prefix desAddress = ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceTransportAddress();
assertEquals(arpSourceTransportAddress.getValue(), desAddress.getValue());
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix 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.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project openflowplugin by opendaylight.
the class MatchConvertorTest method testArpMatchConversionWithMasks.
@Test
public void testArpMatchConversionWithMasks() {
ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
/* Use canonnical prefixes !!! */
arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/8"));
arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/31"));
ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();
srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
srcHwBuilder.setMask(new MacAddress("00:00:00:00:00:08"));
arpBuilder.setArpSourceHardwareAddress(srcHwBuilder.build());
ArpTargetHardwareAddressBuilder dstHwBuilder = new ArpTargetHardwareAddressBuilder();
dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
dstHwBuilder.setMask(new MacAddress("00:00:00:00:00:09"));
arpBuilder.setArpTargetHardwareAddress(dstHwBuilder.build());
MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(arpBuilder.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", 4, entries.size());
MatchEntry entry = entries.get(0);
entry = entries.get(0);
checkEntryHeader(entry, ArpSpa.class, true);
Assert.assertEquals("Wrong arp spa", "10.0.0.0", ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getIpv4Address().getValue());
Assert.assertArrayEquals("Wrong arp spa mask", new byte[] { (byte) 255, 0, 0, 0 }, ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getMask());
entry = entries.get(1);
checkEntryHeader(entry, ArpTpa.class, true);
Assert.assertEquals("Wrong arp tpa", "10.0.0.4", ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getIpv4Address().getValue());
Assert.assertArrayEquals("Wrong arp tpa mask", new byte[] { (byte) 255, (byte) 255, (byte) 255, (byte) 254 }, ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getMask());
entry = entries.get(2);
checkEntryHeader(entry, ArpSha.class, true);
Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:05", ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMacAddress().getValue());
Assert.assertArrayEquals("Wrong arp sha mask", new byte[] { 0, 0, 0, 0, 0, 8 }, ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMask());
entry = entries.get(3);
checkEntryHeader(entry, ArpTha.class, true);
Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:06", ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMacAddress().getValue());
Assert.assertArrayEquals("Wrong arp tha mask", new byte[] { 0, 0, 0, 0, 0, 9 }, ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMask());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix in project lispflowmapping by opendaylight.
the class LispSimpleAddressStringifierTest method getStringTest_asIpv4Prefix.
/**
* Tests {@link LispSimpleAddressStringifier#getString} with Ipv4Prefix.
*/
@Test
public void getStringTest_asIpv4Prefix() {
SimpleAddress simpleAddress = new SimpleAddress(IPV4_PREFIX);
String result = LispSimpleAddressStringifier.getString(simpleAddress);
assertEquals(IPV4_PREFIX.getIpv4Prefix().getValue(), result);
}
Aggregations