Search in sources :

Example 1 with RlocBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder in project lispflowmapping by opendaylight.

the class MapRequestUtilTest method selectItrRlocTest_Ipv6Binary.

/**
 * Tests {@link MapRequestUtil#selectItrRloc} method with Ipv6Binary.
 */
@Test
public void selectItrRlocTest_Ipv6Binary() {
    final ItrRlocBuilder itrRloc = new ItrRlocBuilder().setRloc(new RlocBuilder().setAddress(IPV6_ADDRESS_BINARY).build());
    final MapRequest request = new MapRequestBuilder().setItrRloc(Lists.newArrayList(itrRloc.build())).build();
    // expected result
    InetAddress expectedResult = InetAddresses.forString(IPV6_STRING);
    // result
    InetAddress result = MapRequestUtil.selectItrRloc(request);
    assertEquals(expectedResult, result);
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 2 with RlocBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder in project lispflowmapping by opendaylight.

the class MapRequestUtilTest method selectItrRlocTest_Ipv4.

/**
 * Tests {@link MapRequestUtil#selectItrRloc} method with Ipv4.
 */
@Test
public void selectItrRlocTest_Ipv4() {
    final ItrRlocBuilder itrRloc = new ItrRlocBuilder().setRloc(new RlocBuilder().setAddress(IPV4_ADDRESS).build());
    final MapRequest request = new MapRequestBuilder().setItrRloc(Lists.newArrayList(itrRloc.build())).build();
    // expected result
    InetAddress expectedResult = InetAddresses.forString(IPV4_STRING);
    // result
    InetAddress result = MapRequestUtil.selectItrRloc(request);
    assertEquals(expectedResult, result);
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 3 with RlocBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder in project lispflowmapping by opendaylight.

the class AfiListSerializerTest method serialize__Simple.

@Test
public void serialize__Simple() throws Exception {
    AfiListBuilder listBuilder = new AfiListBuilder();
    List<SimpleAddress> addressList = new ArrayList<SimpleAddress>();
    addressList.add(SimpleAddressBuilder.getDefaultInstance("170.187.204.221"));
    addressList.add(SimpleAddressBuilder.getDefaultInstance("1122:3344:1122:3344:1122:3344:1122:3344"));
    listBuilder.setAddressList(addressList);
    RlocBuilder rb = new RlocBuilder();
    rb.setAddressType(AfiListLcaf.class);
    rb.setVirtualNetworkId(null);
    rb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiListBuilder().setAfiList(listBuilder.build()).build());
    ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(rb.build()));
    LispAddressSerializer.getInstance().serialize(buf, rb.build());
    ByteBuffer expectedBuf = hexToByteBuffer(// 
    "40 03 00 00 " + // 
    "01 00 00 18 " + // IPv4
    "00 01 AA BB CC DD " + "00 02 11 22 33 44 11 22 33 44 11 22 33 44 11 22 33 44");
    ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
Also used : ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) AfiListBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiListBuilder) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Test(org.junit.Test)

Example 4 with RlocBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder in project lispflowmapping by opendaylight.

the class AfiListSerializerTest method serialize__NoAddresses.

@Test
public void serialize__NoAddresses() throws Exception {
    AfiListBuilder listBuilder = new AfiListBuilder();
    List<SimpleAddress> addressList = new ArrayList<SimpleAddress>();
    listBuilder.setAddressList(addressList);
    RlocBuilder rb = new RlocBuilder();
    rb.setAddressType(AfiListLcaf.class);
    rb.setVirtualNetworkId(null);
    rb.setAddress((Address) new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiListBuilder().setAfiList(listBuilder.build()).build());
    ByteBuffer buf = ByteBuffer.allocate(LispAddressSerializer.getInstance().getAddressSize(rb.build()));
    LispAddressSerializer.getInstance().serialize(buf, rb.build());
    ByteBuffer expectedBuf = hexToByteBuffer(// 
    "40 03 00 00 " + "01 00 00 00");
    ArrayAssert.assertEquals(expectedBuf.array(), buf.array());
}
Also used : ArrayList(java.util.ArrayList) ByteBuffer(java.nio.ByteBuffer) AfiListBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiListBuilder) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) Test(org.junit.Test)

Example 5 with RlocBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder in project lispflowmapping by opendaylight.

the class LispAddressUtil method convertToBinary.

public static Rloc convertToBinary(Rloc rloc) {
    Pair<Class<? extends LispAddressFamily>, Address> converted = convertToBinary(rloc.getAddress());
    if (converted.getRight() == null) {
        return rloc;
    }
    RlocBuilder rb = new RlocBuilder(rloc);
    rb.setAddressType(converted.getLeft());
    rb.setAddress(converted.getRight());
    return rb.build();
}
Also used : LispAddressFamily(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily) InetAddress(java.net.InetAddress) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Inet4Address(java.net.Inet4Address) Inet6Address(java.net.Inet6Address) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) KeyValueAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder)

Aggregations

RlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder)34 Test (org.junit.Test)9 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)8 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)7 InetAddress (java.net.InetAddress)6 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder)5 ByteBuffer (java.nio.ByteBuffer)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 ArrayList (java.util.ArrayList)3 KeyValueAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress)3 Ipv4BinaryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4BinaryBuilder)3 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)3 Preconditions (com.google.common.base.Preconditions)2 Inet4Address (java.net.Inet4Address)2 Inet6Address (java.net.Inet6Address)2 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)2 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)2 LispAddressFamily (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddressFamily)2