use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method toRloc.
/**
* Tests:
* - {@link LispAddressUtil#toRloc(InetAddress)}
* - {@link LispAddressUtil#toRloc(Ipv4Address)}
* - {@link LispAddressUtil#toRloc(Ipv6Address)}
* - {@link LispAddressUtil#toRloc(SimpleAddress)}
* methods.
*/
@Test
public void toRloc() throws UnknownHostException {
InetAddress ipv4AddressInet = Inet4Address.getByAddress(IPV4_ADDRESS_BYTES_A_TEST);
final Rloc rlocFromInetAddress = LispAddressUtil.toRloc(ipv4AddressInet);
assertEquals(Ipv4BinaryAfi.class, rlocFromInetAddress.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromInetAddress.getAddress()).getIpv4Binary());
final Rloc rlocFromIpv4Address = LispAddressUtil.toRloc(IPV4_ADDRESS_TEST);
assertEquals(Ipv4Afi.class, rlocFromIpv4Address.getAddressType());
assertEquals(IPV4_ADDRESS_VALUE_TEST, ((Ipv4) rlocFromIpv4Address.getAddress()).getIpv4().getValue());
final Rloc rlocFromIpv6Address = LispAddressUtil.toRloc(IPV6_ADDRESS_TEST);
assertEquals(Ipv6Afi.class, rlocFromIpv6Address.getAddressType());
assertEquals(IPV6_ADDRESS_VALUE_TEST, ((Ipv6) rlocFromIpv6Address.getAddress()).getIpv6().getValue());
final Rloc rlocFromSimpleAddress = LispAddressUtil.toRloc(SIMPLE_ADDRESS_IPV4_TEST);
assertEquals(Ipv4BinaryAfi.class, rlocFromSimpleAddress.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromSimpleAddress.getAddress()).getIpv4Binary());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asEid.
/**
* Tests {@link LispAddressUtil#asEid(SimpleAddress, InstanceIdType)} method.
*/
@Test
public void asEid() {
final Eid eid = LispAddressUtil.asEid(SIMPLE_ADDRESS_IPV4_TEST, INSTANCE_ID_TYPE_TEST);
assertNotNull(eid);
assertEquals(Ipv4BinaryAfi.class, eid.getAddressType());
final Ipv4Binary address = (Ipv4Binary) eid.getAddress();
assertArrayEquals(InetAddresses.forString(SIMPLE_ADDRESS_IPV4_TEST.getIpAddress().getIpv4Address().getValue()).getAddress(), address.getIpv4Binary().getValue());
assertEquals(INSTANCE_ID_TYPE_TEST, eid.getVirtualNetworkId());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class AfiListSerializer method getLcafLength.
@Override
protected short getLcafLength(LispAddress lispAddress) {
short totalSize = 0;
AfiList afiList = (((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiList) lispAddress.getAddress()).getAfiList());
for (SimpleAddress address : afiList.getAddressList()) {
totalSize += SimpleAddressSerializer.getInstance().getAddressSize(address);
}
return totalSize;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class Ipv6PrefixBinarySerializer method deserializeSimpleAddressData.
@Override
protected SimpleAddress deserializeSimpleAddressData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
byte[] ipBuffer = new byte[16];
InetAddress address = null;
buffer.get(ipBuffer);
try {
address = InetAddress.getByAddress(ipBuffer);
} catch (UnknownHostException e) {
LOG.debug("Unknown host {}", ipBuffer, e);
}
return new SimpleAddress(new IpPrefix(new Ipv6Prefix(address.getHostAddress() + "/" + ctx.getMaskLen())));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress in project lispflowmapping by opendaylight.
the class LispAddressStringifier method getStringFromAfiList.
protected static String getStringFromAfiList(Destination dst, AfiList addr) {
// AFI 16387, LCAF Type 1; Address List
// Example rendering:
// {192.0.2.1,192.0.2.2,2001:db8::1}
List<SimpleAddress> addresses = addr.getAfiList().getAddressList();
StringBuilder sb = new StringBuilder("{");
boolean needComma = false;
for (SimpleAddress a : addresses) {
if (needComma) {
sb.append(",");
}
sb.append(a.getValue());
needComma = true;
}
sb.append("}");
return sb.toString();
}
Aggregations