Search in sources :

Example 1 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class LispAddressUtilTest method addressBinaryFromInet_Inet6Address.

/**
 * Tests {@link LispAddressUtil#addressBinaryFromInet(InetAddress)} method with Inet6Address.
 */
@Test
public void addressBinaryFromInet_Inet6Address() throws UnknownHostException {
    final InetAddress inet4Address = InetAddress.getByName(IPV6_ADDRESS_VALUE_TEST);
    assertEquals(new IpAddressBinary(IPV6_ADDRESS_BINARY_TEST), LispAddressUtil.addressBinaryFromInet(inet4Address));
}
Also used : IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 2 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class SimpleMapCache method addMapping.

@Override
public void addMapping(Eid key, Object value, Set<IpAddressBinary> sourceRlocs) {
    Eid eid = MaskUtil.normalize(key);
    ILispDAO table = getOrInstantiateVniTable(key);
    table.put(eid, new MappingEntry<>(SubKeys.RECORD, value));
    if (sourceRlocs != null) {
        table.put(eid, new MappingEntry<>(SubKeys.SRC_RLOCS, sourceRlocs));
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) ILispDAO(org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)

Example 3 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class MappingMergeUtil method mergeXtrIdMappings.

public static MappingData mergeXtrIdMappings(List<Object> mappingDataList, List<MappingData> expiredMappingDataList, Set<IpAddressBinary> sourceRlocs) {
    MappingRecordBuilder mrb = null;
    XtrId xtrId = null;
    Long timestamp = Long.MAX_VALUE;
    for (int i = 0; i < mappingDataList.size(); i++) {
        MappingData mappingData = (MappingData) mappingDataList.get(i);
        MappingRecord record = mappingData.getRecord();
        // Skip expired mappings and add them to a list to be returned to the caller
        if (timestampIsExpired(mappingData.getTimestamp())) {
            expiredMappingDataList.add(mappingData);
            continue;
        }
        if (mrb == null) {
            mrb = new MappingRecordBuilder(record);
        }
        // Save the oldest valid timestamp
        if (mappingData.getTimestamp().getTime() < timestamp) {
            timestamp = mappingData.getTimestamp().getTime();
            xtrId = mappingData.getXtrId();
        }
        // Merge record fields and locators
        mergeCommonMappingRecordFields(mrb, record);
        mergeLocatorRecords(mrb, record);
        // Save source locator for use in Map-Notify
        sourceRlocs.add(record.getSourceRloc());
    }
    if (mrb == null) {
        LOG.warn("All mappings expired when merging! Unexpected!");
        return null;
    }
    mrb.setXtrId(xtrId);
    return new MappingData(mrb.build(), new Date(timestamp));
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Date(java.util.Date) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Example 4 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class LispNotificationHelperTest method getTransportAddressFromRlocTest_withIpv6Address.

/**
 * Tests {@link LispNotificationHelper#getTransportAddressFromRloc} method with Ipv6 type address.
 */
@Test
public void getTransportAddressFromRlocTest_withIpv6Address() {
    final TransportAddress result = new TransportAddressBuilder().setIpAddress(new IpAddressBinary(ADDRESS_IPV6_BINARY)).setPort(new PortNumber(LispMessage.PORT_NUM)).build();
    assertEquals(result, LispNotificationHelper.getTransportAddressFromRloc(RLOC_IPV6));
}
Also used : IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder) Test(org.junit.Test)

Example 5 with IpAddressBinary

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary in project lispflowmapping by opendaylight.

the class LispNotificationHelperTest method getTransportAddressFromRlocTest_withIpv6AddressBinary.

/**
 * Tests {@link LispNotificationHelper#getTransportAddressFromRloc} method with Ipv6AddressBinary type address.
 */
@Test
public void getTransportAddressFromRlocTest_withIpv6AddressBinary() {
    final TransportAddress result = new TransportAddressBuilder().setIpAddress(new IpAddressBinary(ADDRESS_IPV6_BINARY)).setPort(new PortNumber(LispMessage.PORT_NUM)).build();
    assertEquals(result, LispNotificationHelper.getTransportAddressFromRloc(RLOC_IPV6_BINARY));
}
Also used : IpAddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary) TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder) Test(org.junit.Test)

Aggregations

IpAddressBinary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.IpAddressBinary)16 TransportAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress)11 Test (org.junit.Test)10 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)10 TransportAddressBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)10 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)4 InetAddress (java.net.InetAddress)3 ArrayList (java.util.ArrayList)3 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)3 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)3 HashSet (java.util.HashSet)2 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)2 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)2 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)2 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)1 SmrEvent (org.opendaylight.lispflowmapping.interfaces.lisp.SmrEvent)1