Search in sources :

Example 46 with MapReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReply in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method testMultipleMappings.

private void testMultipleMappings() throws UnknownHostException {
    final InstanceIdType iid = new InstanceIdType(1L);
    // prefix from the intersection of NB and SB gaps
    final String prefix1 = "1.1.127.10/32";
    // prefix with existing mapping in NB
    final String prefix2 = "1.1.200.255/32";
    final String prefix3 = "1.3.255.255/32";
    final MapRequest mapRequest = new MapRequestBuilder().setSmrInvoked(false).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix1, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix2, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix3, iid)).build())).build();
    final MapReply mapReply = lms.handleMapRequest(mapRequest);
    // expected result
    final String resultPrefix1 = "1.1.64.0";
    final Address resultNegMapping1 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix1).getAddress())).setIpv4MaskLength((short) 18).build();
    final String resultPrefix2 = "1.1.128.0";
    final Address resultMapping2 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix2).getAddress())).setIpv4MaskLength((short) 17).build();
    final String resultPrefix3 = "1.3.0.0";
    final Address resultNegMapping3 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix3).getAddress())).setIpv4MaskLength((short) 16).build();
    assertEquals(resultNegMapping1, mapReply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress());
    assertEquals(resultMapping2, mapReply.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress());
    assertEquals(resultNegMapping3, mapReply.getMappingRecordItem().get(2).getMappingRecord().getEid().getAddress());
}
Also used : InstanceIdType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) Ipv4AddressBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary) 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) 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) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) InetSocketAddress(java.net.InetSocketAddress) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) Ipv4PrefixBinaryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)

Example 47 with MapReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReply in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTest method testMapRegisterDoesntOverwritesNoSubkey.

public void testMapRegisterDoesntOverwritesNoSubkey() throws SocketTimeoutException {
    cleanUP();
    mapService.setMappingMerge(true);
    Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32");
    Rloc rloc1Value = LispAddressUtil.asIpv4Rloc("4.3.2.1");
    Rloc rloc2Value = LispAddressUtil.asIpv4Rloc("4.3.2.2");
    MapReply mapReply = sendMapRegisterTwiceWithDiffrentValues(eid, rloc1Value, rloc2Value);
    assertEquals(1, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
    Rloc rloc1ReturnValueContainer = mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc();
    Rloc rloc2ReturnValueContainer = mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getRloc();
    assertTrue((rloc1Value.equals(rloc1ReturnValueContainer) && rloc2Value.equals(rloc2ReturnValueContainer)) || (rloc1Value.equals(rloc2ReturnValueContainer) && rloc2Value.equals(rloc1ReturnValueContainer)));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) GotMapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)

Example 48 with MapReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReply in project lispflowmapping by opendaylight.

the class MultiSiteScenario method verifyMappingRecord.

private MappingRecord verifyMappingRecord(MapReply mapReply) {
    assertNotNull(mapReply);
    final List<MappingRecordItem> mappingRecordItems = mapReply.getMappingRecordItem();
    assertNotNull(mappingRecordItems);
    assertEquals(1, mappingRecordItems.size());
    final MappingRecordItem mappingRecordItem = mappingRecordItems.get(0);
    assertNotNull(mappingRecordItem);
    final MappingRecord mappingRecord = mappingRecordItem.getMappingRecord();
    assertNotNull(mappingRecord);
    return mappingRecord;
}
Also used : MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)

Example 49 with MapReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReply in project lispflowmapping by opendaylight.

the class MultiSiteScenario method checkActionAndRloc.

boolean checkActionAndRloc(final Site dstSite, boolean expectedPingWorks, MapReply mapReplyFromSrcToDst, final Site... additionalSitesFromMapping) {
    final MappingRecord mappingRecord = verifyMappingRecord(mapReplyFromSrcToDst);
    final boolean isNotDroppendSrcDst = !MappingRecord.Action.Drop.equals(mappingRecord.getAction());
    if (isPossibleAssertPingResultImmediately(expectedPingWorks, isNotDroppendSrcDst, "Drop action has appeared " + "during ping")) {
        return true;
    }
    final List<LocatorRecord> locatorRecords = verifyLocatorRecordExists(mappingRecord);
    for (Site expectedTargetSite : concatenateSites(dstSite, additionalSitesFromMapping)) {
        boolean expectedTargetFound = false;
        for (LocatorRecord locatorRecord : locatorRecords) {
            if (expectedTargetSite.getRloc().equals(rlocToString(locatorRecord))) {
                final byte[] ipv4AddressSrcDst = verifyIpv4Address(locatorRecord).getValue();
                final byte[] rloc = InetAddresses.forString((expectedTargetSite.getRloc())).getAddress();
                final boolean isRlocSrcDstEqual = Arrays.equals(ipv4AddressSrcDst, rloc);
                if (isPossibleAssertPingResultImmediately(expectedPingWorks, isRlocSrcDstEqual, "Unexpected RLOC." + "Expected value " + rloc + ". Real value " + ipv4AddressSrcDst + ".")) {
                    return true;
                }
                final boolean isWeightEquals = expectedTargetSite.getWeight() == locatorRecord.getWeight();
                if (isPossibleAssertPingResultImmediately(expectedPingWorks, isWeightEquals, "Weight isn't equal." + "Expected value " + expectedTargetSite.getWeight() + ". Value from mapping" + locatorRecord.getWeight() + ".")) {
                    return true;
                }
                final boolean isPriorityEquals = expectedTargetSite.getPriority() == locatorRecord.getPriority();
                if (isPossibleAssertPingResultImmediately(expectedPingWorks, isPriorityEquals, "Priority isn't " + "equal. Expected value " + expectedTargetSite.getPriority() + ". Value from mapping" + locatorRecord.getPriority() + ".")) {
                    return true;
                }
                expectedTargetFound = true;
                break;
            }
        }
        if (isPossibleAssertPingResultImmediately(expectedPingWorks, expectedTargetFound, "Mapping for " + expectedTargetSite.getRloc() + " was expected but wasn't returned from mapping service." + expectedTargetFound)) {
            return true;
        }
    }
    return false;
}
Also used : Site(org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 50 with MapReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReply in project lispflowmapping by opendaylight.

the class MultiSiteScenario method emitMapRequestMessage.

private MapReply emitMapRequestMessage(final String siteFromEidPrefix, final String siteToEidPrefix, final InstanceIdType vniValue) {
    final MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
    final EidItemBuilder eidItemBuilder = new EidItemBuilder();
    Eid dstEid = toEid(siteToEidPrefix, vniValue, IP_MASK);
    eidItemBuilder.setEid(dstEid);
    eidItemBuilder.setEidItemId(siteFromEidPrefix + siteToEidPrefix);
    final List<EidItem> eidItem = Collections.singletonList(eidItemBuilder.build());
    final Eid srcEid = MappingServiceIntegrationTestUtil.removePrefixIfNecessary(toEid(siteFromEidPrefix, vniValue, IP_MASK));
    mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(srcEid).build());
    mapRequestBuilder.setEidItem(eidItem);
    mapRequestBuilder.setItrRloc(MappingServiceIntegrationTestUtil.getDefaultItrRlocList(LispAddressUtil.asIpv4Rloc(ourAddress)));
    mapRequestBuilder.setSmrInvoked(false);
    return lms.handleMapRequest(mapRequestBuilder.build());
}
Also used : SourceEid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEid) Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder) EidItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem)

Aggregations

MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)44 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)38 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)25 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)12 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)9 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)9 Test (org.junit.Test)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)8 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)6 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)6 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)5 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)5 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)5 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)5 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)4 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)4 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)4