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 LispAddressUtil method asTeLcafRloc.
public static Rloc asTeLcafRloc(List<IpAddress> hopList) {
ExplicitLocatorPathBuilder teAddrBuilder = new ExplicitLocatorPathBuilder();
teAddrBuilder.setHop(new ArrayList<Hop>());
for (IpAddress hop : hopList) {
HopBuilder hopBuilder = new HopBuilder();
hopBuilder.setAddress(new SimpleAddress(hop));
hopBuilder.setHopId("Hop " + teAddrBuilder.getHop().size());
hopBuilder.setLrsBits(new LrsBits(false, false, false));
teAddrBuilder.getHop().add(hopBuilder.build());
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder elpBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder();
elpBuilder.setExplicitLocatorPath(teAddrBuilder.build());
RlocBuilder teBuilder = new RlocBuilder();
teBuilder.setAddress(elpBuilder.build());
teBuilder.setAddressType(ExplicitLocatorPathLcaf.class);
return teBuilder.build();
}
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 MaskUtil method normalizeSrcDst.
private static Eid normalizeSrcDst(Eid eid) throws UnknownHostException {
final SimpleAddress normalizedSrc = normalizeSimpleAddress(((SourceDestKey) eid.getAddress()).getSourceDestKey().getSource());
final SimpleAddress normalizedDst = normalizeSimpleAddress(((SourceDestKey) eid.getAddress()).getSourceDestKey().getDest());
return LispAddressUtil.asSrcDstEid(new SourceDestKeyBuilder().setSource(normalizedSrc).setDest(normalizedDst).build(), 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 KeyValueAddressSerializerTest method serialize__Simple.
@Test
public void serialize__Simple() throws Exception {
KeyValueAddressBuilder addressBuilder = new KeyValueAddressBuilder();
addressBuilder.setKey(new SimpleAddress(new IpAddress(new Ipv4Address("17.34.51.68"))));
addressBuilder.setValue(new SimpleAddress(new IpAddress(new Ipv4Address("34.51.68.85"))));
EidBuilder eb = new EidBuilder();
eb.setAddressType(KeyValueAddressLcaf.class);
eb.setVirtualNetworkId(null);
eb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddressBuilder().setKeyValueAddress(addressBuilder.build()).build());
ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(eb.build()));
LispAddressSerializer.getInstance().serialize(buf, eb.build());
ByteBuffer expectedBuf = hexToByteBuffer(//
"40 03 00 00 " + //
"0F 00 00 0C " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44 " + // AFI=1, IP=0x22334455
"00 01 22 33 44 55");
ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
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 addressFromSimpleAddressTest_asIpPrefix.
/**
* Tests {@link LispAddressUtil#addressTypeFromSimpleAddress} and {@link
* LispAddressUtil#addressFromSimpleAddress} methods
* with ipPrefix.
*/
@Test
public void addressFromSimpleAddressTest_asIpPrefix() {
final SimpleAddress simpleAddress = new SimpleAddress(new IpPrefix(new Ipv4Prefix(IPV4_ADDRESS_PREFIX_VALUE_TEST)));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromSimpleAddress(simpleAddress);
assertEquals(Ipv4PrefixAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromSimpleAddress(simpleAddress);
assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix);
}
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 addressFromSimpleAddressTest_asAddress.
/**
* Tests {@link LispAddressUtil#addressTypeFromSimpleAddress} and {@link
* LispAddressUtil#addressFromSimpleAddress} methods
* with general address.
*/
@Test
public void addressFromSimpleAddressTest_asAddress() {
final SimpleAddress simpleAddress = new SimpleAddress(DUMMY_CHARACTER_ARRAY_TEST);
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromSimpleAddress(simpleAddress);
assertEquals(DistinguishedNameAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromSimpleAddress(simpleAddress);
assertTrue(address instanceof DistinguishedName);
}
Aggregations