Search in sources :

Example 46 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address 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 47 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.

the class ApplicationDataSerializerTest method deserialize__Simple.

@Test
public void deserialize__Simple() throws Exception {
    Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(// 
    "40 03 00 00 " + // 
    "04 20 00 0E " + // IPTOS & protocol
    "AA BB CC DD " + // local port range
    "A6 A1 A6 A2 " + // remote port range
    "FF DD FF DE " + "00 01 11 22 33 44"), // AFI=1, IP=0x11223344
    null);
    assertEquals(ApplicationDataLcaf.class, address.getAddressType());
    ApplicationData appAddress = (ApplicationData) address.getAddress();
    assertEquals("17.34.51.68", String.valueOf(appAddress.getApplicationData().getAddress().getValue()));
    assertEquals(ByteUtil.getPartialInt(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC }), appAddress.getApplicationData().getIpTos().intValue());
    assertEquals((byte) 0xDD, appAddress.getApplicationData().getProtocol().byteValue());
    assertEquals((short) 0xA6A1, appAddress.getApplicationData().getLocalPortLow().getValue().shortValue());
    assertEquals((short) 0xA6A2, appAddress.getApplicationData().getLocalPortHigh().getValue().shortValue());
    assertEquals((short) 0xFFDD, appAddress.getApplicationData().getRemotePortLow().getValue().shortValue());
    assertEquals((short) 0xFFDE, appAddress.getApplicationData().getRemotePortHigh().getValue().shortValue());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ApplicationData(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationData) Test(org.junit.Test)

Example 48 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address 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)

Example 49 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.

the class LispAddressUtil method toEid.

public static Eid toEid(MacAddress mac, InstanceIdType vni) {
    EidBuilder builder = new EidBuilder();
    builder.setAddressType(MacAfi.class);
    builder.setVirtualNetworkId(vni);
    builder.setAddress((Address) new MacBuilder().setMac(mac).build());
    return builder.build();
}
Also used : EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder) MacBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder)

Example 50 with Address

use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address in project lispflowmapping by opendaylight.

the class LispAddressUtil method toEid.

public static Eid toEid(Ipv4PrefixBinary prefix, InstanceIdType vni) {
    EidBuilder builder = new EidBuilder();
    builder.setAddressType(Ipv4PrefixBinaryAfi.class);
    builder.setVirtualNetworkId(vni);
    builder.setAddress((Address) prefix);
    return builder.build();
}
Also used : EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)

Aggregations

Test (org.junit.Test)209 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)90 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)79 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)77 ArrayList (java.util.ArrayList)67 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)66 ByteBuf (io.netty.buffer.ByteBuf)57 InetAddress (java.net.InetAddress)57 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)55 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)52 BigInteger (java.math.BigInteger)41 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)41 Inet6Address (java.net.Inet6Address)39 KeyValueAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress)39 Inet4Address (java.net.Inet4Address)36 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)29 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)28 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)27 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)26 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)25