use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv6AddressBinary in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method toEid_ipv6.
/**
* Test
* - {@link LispAddressUtil#toEid(Ipv6Address, InstanceIdType)}
* - {@link LispAddressUtil#toEid(Ipv6AddressBinary, InstanceIdType)}
* - {@link LispAddressUtil#asIpv6Eid(String)}
* - {@link LispAddressUtil#asIpv6Eid(String, long)}
* methods.
*/
@Test
public void toEid_ipv6() {
Eid eidFromIpv6 = LispAddressUtil.toEid(IPV6_ADDRESS_TEST, INSTANCE_ID_TYPE_TEST);
verifyToEidWithIpv6(eidFromIpv6, true);
eidFromIpv6 = LispAddressUtil.toEid(IPV6_ADDRESS_BINARY_TEST, INSTANCE_ID_TYPE_TEST);
verifyToEidWithIpv6Binary(eidFromIpv6, true);
eidFromIpv6 = LispAddressUtil.asIpv6Eid(IPV6_ADDRESS_VALUE_TEST);
verifyToEidWithIpv6Binary(eidFromIpv6, false);
eidFromIpv6 = LispAddressUtil.asIpv6Eid(IPV6_ADDRESS_VALUE_TEST, INSTANCE_ID_TYPE_VALUE_TEST);
verifyToEidWithIpv6Binary(eidFromIpv6, true);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv6AddressBinary in project lispflowmapping by opendaylight.
the class LispAddressUtil method asIpv6PrefixBinaryEid.
public static Eid asIpv6PrefixBinaryEid(InstanceIdType vni, byte[] address, short mask) {
Preconditions.checkArgument(address.length == 16, "asIpv6PrefixBinaryEid called with incorrect length byte array ({})", address.length);
EidBuilder builder = new EidBuilder();
builder.setAddressType(Ipv6PrefixBinaryAfi.class);
builder.setVirtualNetworkId(vni);
builder.setAddress(new Ipv6PrefixBinaryBuilder().setIpv6AddressBinary(new Ipv6AddressBinary(address)).setIpv6MaskLength(mask).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv6AddressBinary in project lispflowmapping by opendaylight.
the class LispNotificationHelper method getTransportAddressFromRloc.
public static TransportAddress getTransportAddressFromRloc(Rloc rloc) {
TransportAddressBuilder tab = new TransportAddressBuilder();
Address address = rloc.getAddress();
// object, yey!
if (address instanceof Ipv4) {
String ipv4 = ((Ipv4) address).getIpv4().getValue();
tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ipv4).getAddress()));
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
} else if (address instanceof Ipv6) {
String ipv6 = ((Ipv6) address).getIpv6().getValue();
tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ipv6).getAddress()));
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
} else if (address instanceof Ipv4Binary) {
Ipv4AddressBinary ipv6 = ((Ipv4Binary) address).getIpv4Binary();
tab.setIpAddress(new IpAddressBinary(ipv6));
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
} else if (address instanceof Ipv6Binary) {
Ipv6AddressBinary ipv6 = ((Ipv6Binary) address).getIpv6Binary();
tab.setIpAddress(new IpAddressBinary(ipv6));
tab.setPort(new PortNumber(LispMessage.PORT_NUM));
} else if (address instanceof KeyValueAddress) {
SimpleAddress sa = ((KeyValueAddress) address).getKeyValueAddress().getValue();
if (sa.getDistinguishedNameType() != null) {
final Iterator<String> it = COLON_SPLITTER.split(sa.getDistinguishedNameType().getValue()).iterator();
String ip = it.next();
int port = Integer.valueOf(it.next());
tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ip).getAddress()));
tab.setPort(new PortNumber(port));
}
} else if (address instanceof DistinguishedName) {
DistinguishedName dname = (DistinguishedName) address;
final Iterator<String> it = COLON_SPLITTER.split(dname.getDistinguishedName().getValue()).iterator();
String ip = it.next();
int port = Integer.valueOf(it.next());
tab.setIpAddress(IpAddressBinaryBuilder.getDefaultInstance(InetAddresses.forString(ip).getAddress()));
tab.setPort(new PortNumber(port));
} else if (address instanceof ApplicationData) {
ApplicationData appData = (ApplicationData) address;
tab.setIpAddress(getIpAddressBinary(appData.getApplicationData().getAddress().getIpAddress()));
tab.setPort(new PortNumber(appData.getApplicationData().getLocalPortLow()));
}
return tab.build();
}
Aggregations