use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class ArpSourceTransportAddressEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Match arpSpaMatch = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpSourceTransportAddress(new Ipv4Prefix("10.0.2.0/24")).build()).build();
assertMatch(arpSpaMatch, 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 arpSpaMatchNoMask = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/32")).build()).build();
assertMatch(arpSpaMatchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class OfToSalArpTpaCase method process.
@Override
public Optional<MatchBuilder> process(@Nonnull ArpTpaCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder();
ArpTpa arpTpa = source.getArpTpa();
if (arpTpa != null) {
int mask = 32;
if (null != arpTpa.getMask()) {
mask = IpConversionUtil.countBits(arpTpa.getMask());
}
Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpTpa.getIpv4Address(), mask);
arpMatchBuilder.setArpTargetTransportAddress(ipv4Prefix);
matchBuilder.setLayer3Match(arpMatchBuilder.build());
}
return Optional.of(matchBuilder);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class SetNwSrcActionSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Ipv4 address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("192.168.76.2/32")).build();
final Action action = new SetNwSrcActionCaseBuilder().setSetNwSrcAction(new SetNwSrcActionBuilder().setAddress(address).build()).build();
assertAction(action, out -> {
byte[] addressBytes = new byte[4];
out.readBytes(addressBytes);
assertArrayEquals(addressBytes, new byte[] { (byte) 192, (byte) 168, 76, 2 });
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class TunnelIpv4SourceEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Match ipv4match = new MatchBuilder().setLayer3Match(new TunnelIpv4MatchBuilder().setTunnelIpv4Source(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().setTunnelIpv4Source(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 });
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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();
}
Aggregations