use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class MaskUtil method normalize.
public static Eid normalize(Eid eid, short mask) {
Address address = eid.getAddress();
try {
if (address instanceof Ipv4PrefixBinary) {
byte[] addr = ((Ipv4PrefixBinary) address).getIpv4AddressBinary().getValue();
return LispAddressUtil.asIpv4PrefixBinaryEid(eid, normalizeByteArray(addr, mask), mask);
} else if (address instanceof Ipv6PrefixBinary) {
byte[] addr = ((Ipv6PrefixBinary) address).getIpv6AddressBinary().getValue();
return LispAddressUtil.asIpv6PrefixBinaryEid(eid, normalizeByteArray(addr, mask), mask);
} else if (address instanceof Ipv4Prefix) {
final String addr = getPrefixAddress(((Ipv4Prefix) address).getIpv4Prefix().getValue());
InetAddress normalized = normalizeIP(InetAddresses.forString(addr), mask);
return LispAddressUtil.asIpv4PrefixEid(eid, (Inet4Address) normalized, mask);
} else if (address instanceof Ipv6Prefix) {
final String addr = getPrefixAddress(((Ipv6Prefix) address).getIpv6Prefix().getValue());
InetAddress normalized = normalizeIP(InetAddresses.forString(addr), mask);
return LispAddressUtil.asIpv6PrefixEid(eid, (Inet6Address) normalized, mask);
} else if (address instanceof InstanceId) {
// TODO - not absolutely necessary, but should be implemented
return eid;
}
} catch (UnknownHostException e) {
LOG.warn("Failed to normalize EID {} with mask {}, returning original EID", eid, mask, e);
}
return eid;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class DistinguishedNameSerializerTest method deserialize__EmptyString.
@Test
public void deserialize__EmptyString() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("00 11 00"), null);
assertEquals(DistinguishedNameAfi.class, address.getAddressType());
DistinguishedName distinguishedName = (DistinguishedName) address.getAddress();
assertEquals("", distinguishedName.getDistinguishedName().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class DistinguishedNameSerializerTest method deserialize__DavidString.
@Test
public void deserialize__DavidString() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("00 11 64 61 76 69 64 00"), null);
assertEquals(DistinguishedNameAfi.class, address.getAddressType());
DistinguishedName distinguishedName = (DistinguishedName) address.getAddress();
assertEquals("david", distinguishedName.getDistinguishedName().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class DistinguishedNameSerializerTest method deserialize__inList.
@Test
public void deserialize__inList() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"01 00 00 8 " + "00 11 64 61 76 69 64 00"), null);
assertEquals(AfiListLcaf.class, address.getAddressType());
assertEquals("david", ((AfiList) address.getAddress()).getAfiList().getAddressList().get(0).getDistinguishedNameType().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.
the class DistinguishedNameSerializerTest method deserialize__ReadUntilZero.
@Test
public void deserialize__ReadUntilZero() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer("00 11 64 61 76 00 69 64"), null);
DistinguishedName distinguishedName = (DistinguishedName) address.getAddress();
assertEquals("dav", distinguishedName.getDistinguishedName().getValue());
}
Aggregations