use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address 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 in project openflowplugin by opendaylight.
the class MatchV10Convertor method convertL3Ipv4SrcMatch.
/**
* Method splits the IP address and its mask and set their respective values in MatchV10Builder instance.
* Wildcard value of the IP mask will be determined by Openflow java encoding library.
*
* @param matchBuilder match builder
* @param ipv4 ip v4 match
*/
private static void convertL3Ipv4SrcMatch(final MatchV10Builder matchBuilder, final Ipv4Match ipv4) {
if (ipv4.getIpv4Source() != null) {
Iterator<String> addressParts = IpConversionUtil.PREFIX_SPLITTER.split(ipv4.getIpv4Source().getValue()).iterator();
Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
int prefix = buildPrefix(addressParts);
matchBuilder.setNwSrc(ipv4Address);
matchBuilder.setNwSrcMask((short) prefix);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.
the class Ipv4ArbitraryBitMaskSourceEntrySerializerTest 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().setIpv4SourceAddressNoMask(ipv4Address).setIpv4SourceArbitraryBitmask(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().setIpv4SourceAddressNoMask(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 });
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.
the class SetDlDstActionSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final MacAddress address = new MacAddress("00:01:02:03:04:05");
final Action action = new SetDlDstActionCaseBuilder().setSetDlDstAction(new SetDlDstActionBuilder().setAddress(address).build()).build();
assertAction(action, out -> {
byte[] addressBytes = new byte[6];
out.readBytes(addressBytes);
assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address 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 });
});
}
Aggregations