Search in sources :

Example 6 with Ipv6PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.

the class HashMapDb method tryRemoveFromTrie.

private void tryRemoveFromTrie(Object key) {
    if (key instanceof Eid) {
        Eid eid = (Eid) key;
        if (eid.getAddress() instanceof Ipv4PrefixBinary) {
            Ipv4PrefixBinary prefix = (Ipv4PrefixBinary) eid.getAddress();
            ip4Trie.remove(prefix.getIpv4AddressBinary().getValue(), prefix.getIpv4MaskLength());
        } else if (eid.getAddress() instanceof Ipv6PrefixBinary) {
            Ipv6PrefixBinary prefix = (Ipv6PrefixBinary) eid.getAddress();
            ip6Trie.remove(prefix.getIpv6AddressBinary().getValue(), prefix.getIpv6MaskLength());
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Ipv4PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary) Ipv6PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary)

Example 7 with Ipv6PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTestUtil method removePrefixIfNecessary.

static Eid removePrefixIfNecessary(Eid eid) {
    EidBuilder eb = new EidBuilder(eid);
    Address address = eid.getAddress();
    if (address instanceof Ipv4PrefixBinary) {
        Ipv4Binary convertedEid = new Ipv4BinaryBuilder().setIpv4Binary(((Ipv4PrefixBinary) address).getIpv4AddressBinary()).build();
        return eb.setAddress(convertedEid).setAddressType(Ipv4BinaryAfi.class).build();
    } else if (address instanceof Ipv6PrefixBinary) {
        Ipv6Binary convertedEid = new Ipv6BinaryBuilder().setIpv6Binary(((Ipv6PrefixBinary) address).getIpv6AddressBinary()).build();
        return eb.setAddress(convertedEid).setAddressType(Ipv6BinaryAfi.class).build();
    }
    return eid;
}
Also used : Ipv4PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary) Ipv4BinaryAfi(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv4BinaryAfi) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) EidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder) InetAddress(java.net.InetAddress) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) InetSocketAddress(java.net.InetSocketAddress) Ipv4BinaryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4BinaryBuilder) Ipv6PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary) Ipv4Binary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary) Ipv6BinaryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6BinaryBuilder) Ipv6Binary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary)

Example 8 with Ipv6PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.

the class MaskUtilTest method normalizeTest_withIpv6PrefixBinary_withMask.

/**
 * Tests {@link MaskUtil#normalize(Eid eid, short mask)} method with Ipv6PrefixBinary.
 */
@Test
public void normalizeTest_withIpv6PrefixBinary_withMask() throws UnknownHostException {
    // input ip: 1111:2222:3333:4444:5555:6666:7777:8888, mask: 66
    final Eid result = MaskUtil.normalize(EID_IPV6_PREFIX_BINARY, (short) 66);
    final Ipv6PrefixBinary resultPrefix = (Ipv6PrefixBinary) result.getAddress();
    // expected result
    assertArrayEquals(ipv6ExpectedByteAddress, resultPrefix.getIpv6AddressBinary().getValue());
    assertEquals((short) 66, (short) resultPrefix.getIpv6MaskLength());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Ipv6PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary) Test(org.junit.Test)

Example 9 with Ipv6PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.

the class MaskUtilTest method normalizeTest_withIpv6PrefixBinary.

/**
 * Tests {@link MaskUtil#normalize(Eid eid)} method with Ipv6PrefixBinary.
 */
@Test
public void normalizeTest_withIpv6PrefixBinary() throws UnknownHostException {
    // input ip: 1111:2222:3333:4444:5555:6666:7777:8888, mask: 66
    final Eid result = MaskUtil.normalize(EID_IPV6_PREFIX_BINARY);
    final Ipv6PrefixBinary resultPrefix = (Ipv6PrefixBinary) result.getAddress();
    // expected result
    final byte[] expectedResult = Inet6Address.getByName("1111:2222:3333:4444:4000::").getAddress();
    assertArrayEquals(expectedResult, resultPrefix.getIpv6AddressBinary().getValue());
    assertEquals((short) 66, (short) resultPrefix.getIpv6MaskLength());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Ipv6PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary) Test(org.junit.Test)

Example 10 with Ipv6PrefixBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.

the class LispAddressUtilTest method toEid_ipv6PrefixBinary.

/**
 * Test
 * - {@link LispAddressUtil#toEid(Ipv6PrefixBinary, InstanceIdType)}
 * - {@link LispAddressUtil#asIpv6PrefixBinaryEid(String)}
 * - {@link LispAddressUtil#asIpv6PrefixBinaryEid(String, InstanceIdType)}
 * - {@link LispAddressUtil#asIpv6PrefixBinaryEid(Eid, byte[], short)}
 * method.
 */
@Test
public void toEid_ipv6PrefixBinary() {
    Eid eidFromIpv6PrefixBinary = LispAddressUtil.toEid(IPV6_ADDRESS_PREFIX_BINARY_1, INSTANCE_ID_TYPE_TEST);
    verifyToEidWithIpv6PrefixBinary(eidFromIpv6PrefixBinary, true, MASK_OK_TEST, Ipv6PrefixBinaryAfi.class);
    eidFromIpv6PrefixBinary = LispAddressUtil.asIpv6PrefixBinaryEid(IPV6_ADDRESS_PREFIX_VALUE_TEST);
    verifyToEidWithIpv6PrefixBinary(eidFromIpv6PrefixBinary, false, MASK_OK_TEST, Ipv6PrefixBinaryAfi.class);
    eidFromIpv6PrefixBinary = LispAddressUtil.asIpv6PrefixBinaryEid(IPV6_ADDRESS_PREFIX_VALUE_TEST, INSTANCE_ID_TYPE_TEST);
    verifyToEidWithIpv6PrefixBinary(eidFromIpv6PrefixBinary, true, MASK_OK_TEST, Ipv6PrefixBinaryAfi.class);
    eidFromIpv6PrefixBinary = LispAddressUtil.asIpv6PrefixBinaryEid(IPV6_ADDRESS_PREFIX_BINARY_EID_1, IPV6_ADDRESS_BYTES_A_TEST, MASK_OK_TEST);
    verifyToEidWithIpv6PrefixBinary(eidFromIpv6PrefixBinary, true, MASK_OK_TEST, Ipv6PrefixBinaryAfi.class);
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Test(org.junit.Test)

Aggregations

Ipv6PrefixBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary)12 Ipv4PrefixBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary)8 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 InetAddress (java.net.InetAddress)4 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)4 Inet4Address (java.net.Inet4Address)3 Inet6Address (java.net.Inet6Address)3 Test (org.junit.Test)3 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)3 UnknownHostException (java.net.UnknownHostException)2 InstanceId (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.InstanceId)2 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix)2 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix)2 Ipv6AddressBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv6AddressBinary)2 Ipv4Binary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary)2 Ipv6Binary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary)2 Ipv6PrefixBinaryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinaryBuilder)2 InetSocketAddress (java.net.InetSocketAddress)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1