use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project lispflowmapping by opendaylight.
the class Ipv6BinarySerializer method serializeData.
@Override
protected void serializeData(ByteBuffer buffer, LispAddress lispAddress) {
Ipv6Binary address = (Ipv6Binary) lispAddress.getAddress();
buffer.put(address.getIpv6Binary().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project lispflowmapping by opendaylight.
the class LispAddressUtil method convertFromBinary.
private static Pair<Class<? extends LispAddressFamily>, Address> convertFromBinary(Address addr) {
Address convAddr = null;
Class<? extends LispAddressFamily> convType = null;
if (addr instanceof Ipv4PrefixBinary) {
convAddr = convertFromBinary((Ipv4PrefixBinary) addr);
convType = Ipv4PrefixAfi.class;
} else if (addr instanceof Ipv6PrefixBinary) {
convAddr = convertFromBinary((Ipv6PrefixBinary) addr);
convType = Ipv6PrefixAfi.class;
} else if (addr instanceof Ipv4Binary) {
convAddr = convertFromBinary((Ipv4Binary) addr);
convType = Ipv4Afi.class;
} else if (addr instanceof Ipv6Binary) {
convAddr = convertFromBinary((Ipv6Binary) addr);
convType = Ipv6Afi.class;
}
return new ImmutablePair<Class<? extends LispAddressFamily>, Address>(convType, convAddr);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project openflowplugin by opendaylight.
the class IpConversionUtilTest method canonicalBinaryV6AddressPrefixTest.
@Test
public void canonicalBinaryV6AddressPrefixTest() {
byte[] ipv6binary = IpConversionUtil.canonicalBinaryV6Prefix(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001/64"));
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64 };
Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));
try {
Assert.assertEquals("Incorrect canonicalization - string", "::/64", IpConversionUtil.byteArrayV6PrefixToString(ipv6binary));
} catch (java.net.UnknownHostException e) {
Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project openflowplugin by opendaylight.
the class IpConversionUtilTest method canonicalBinaryV6AddressTest.
@Test
public void canonicalBinaryV6AddressTest() {
byte[] ipv6binary = IpConversionUtil.canonicalBinaryV6Address(new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0001"));
byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));
try {
Assert.assertEquals("Incorrect canonicalization - string", "::1", IpConversionUtil.byteArrayV6AddressToString(ipv6binary));
} catch (java.net.UnknownHostException e) {
Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method removePrefixIfNecessary.
static Eid removePrefixIfNecessary(Eid eid) {
EidBuilder eb = new EidBuilder(eid);
Address address = eid.getAddress();
if (address instanceof Ipv4PrefixBinary) {
Ipv4Binary convertedEid = new Ipv4BinaryBuilder().setIpv4Binary(((Ipv4PrefixBinary) address).getIpv4AddressBinary()).build();
return eb.setAddress(convertedEid).setAddressType(Ipv4BinaryAfi.class).build();
} else if (address instanceof Ipv6PrefixBinary) {
Ipv6Binary convertedEid = new Ipv6BinaryBuilder().setIpv6Binary(((Ipv6PrefixBinary) address).getIpv6AddressBinary()).build();
return eb.setAddress(convertedEid).setAddressType(Ipv6BinaryAfi.class).build();
}
return eid;
}
Aggregations