Search in sources :

Example 21 with LocatorRecord

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

the class MappingServiceIntegrationTest method createNonProxyMapRequest.

private MapRequest createNonProxyMapRequest(String eid, Rloc adLcaf) throws SocketTimeoutException {
    MapRegister mr = createMapRegister(LispAddressUtil.asIpv4PrefixBinaryEid(eid));
    LocatorRecord record = new LocatorRecordBuilder(mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0)).setRloc(adLcaf).build();
    mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().set(0, record);
    sendMapRegister(mr);
    assertMapNotifyReceived();
    MapRequest mapRequest = createMapRequest(LispAddressUtil.asIpv4PrefixBinaryEid(eid));
    MapRequestBuilder builder = new MapRequestBuilder(mapRequest);
    builder.setPitr(true);
    mapRequest = builder.build();
    return mapRequest;
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 22 with LocatorRecord

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

the class MappingServiceIntegrationTestUtil method getDefaultMapRegisterBuilder.

/* Map-Register */
/**
 * Create a default MapRegisterBuilder object with a non-empty default LocatorRecord.
 *
 * @param eid EID for the single mapping record, if null, a default will be added
 * @return the MapRegisterBuilder object
 */
static MapRegisterBuilder getDefaultMapRegisterBuilder(Eid eid) {
    MapRegisterBuilder mapRegisterBuilder = getDefaultMapRegisterBuilder(eid, null);
    mapRegisterBuilder.setMappingRecordItem(new ArrayList<>());
    mapRegisterBuilder.getMappingRecordItem().add(getDefaultMappingRecordItemBuilder(eid, DEFAULT_IPV4_RLOC).build());
    return mapRegisterBuilder;
}
Also used : MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder)

Example 23 with LocatorRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord 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 24 with LocatorRecord

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

the class MapNotifySerializationTest method deserialize__Locators.

@Test
public void deserialize__Locators() throws Exception {
    MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 01 01 " + "FF BB 00 00 00 00 00 00 00 01 00 14 f1 b8 ab f0 " + "66 bb 2e ef 12 70 74 46 6f 6b 8e ca bf 1e 68 40 " + "00 00 00 0a " + // Locator Count
    "03 " + "20 10 00 00 00 00 01 99 10 fe 01 " + // Locator 1
    "01 64 1f 00 " + // priorities + weights
    "00 05 " + // Flags
    "00 01 c0 a8 88 0a " + // Locator 2
    "67 00 30 34 " + // priorities + weights
    "00 02 " + // Flags
    "00 01 cc aa AA 11 " + // Locator 3
    "60 11 34 A4 " + // priorities + weights
    "00 03 " + // Flags
    "00 01 c0 a8 88 0a "));
    assertEquals(1, mn.getMappingRecordItem().size());
    MappingRecordItem eidToLocator = mn.getMappingRecordItem().get(0);
    assertEquals(3, eidToLocator.getMappingRecord().getLocatorRecord().size());
    LocatorRecord loc0 = eidToLocator.getMappingRecord().getLocatorRecord().get(0);
    LocatorRecord loc1 = eidToLocator.getMappingRecord().getLocatorRecord().get(1);
    LocatorRecord loc2 = eidToLocator.getMappingRecord().getLocatorRecord().get(2);
    assertEquals((byte) 0x01, loc0.getPriority().byteValue());
    assertEquals((byte) 0x67, loc1.getPriority().byteValue());
    assertEquals((byte) 0x60, loc2.getPriority().byteValue());
    assertEquals((byte) 0x64, loc0.getWeight().byteValue());
    assertEquals((byte) 0x00, loc1.getWeight().byteValue());
    assertEquals((byte) 0x11, loc2.getWeight().byteValue());
    assertEquals((byte) 0x1F, loc0.getMulticastPriority().byteValue());
    assertEquals((byte) 0x30, loc1.getMulticastPriority().byteValue());
    assertEquals((byte) 0x34, loc2.getMulticastPriority().byteValue());
    assertEquals((byte) 0x00, loc0.getMulticastWeight().byteValue());
    assertEquals((byte) 0x34, loc1.getMulticastWeight().byteValue());
    assertEquals((byte) 0xA4, loc2.getMulticastWeight().byteValue());
    assertTrue(loc0.isLocalLocator());
    assertFalse(loc1.isLocalLocator());
    assertFalse(loc2.isLocalLocator());
    assertFalse(loc0.isRlocProbed());
    assertTrue(loc1.isRlocProbed());
    assertTrue(loc2.isRlocProbed());
    assertTrue(loc0.isRouted());
    assertFalse(loc1.isRouted());
    assertTrue(loc2.isRouted());
    assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), loc0.getRloc());
    assertEquals(LispAddressUtil.asIpv4Rloc("204.170.170.17"), loc1.getRloc());
}
Also used : MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) Test(org.junit.Test)

Example 25 with LocatorRecord

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

the class MapRegisterSerializationTest method serialize__Fields.

@Test
public void serialize__Fields() throws Exception {
    MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
    mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
    recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32"));
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
    mrBuilder.setNonce(6161616161L);
    mrBuilder.setKeyId((short) 0x0001);
    mrBuilder.setWantMapNotify(true);
    mrBuilder.setProxyMapReply(true);
    mrBuilder.setXtrSiteIdPresent(true);
    byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d, (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba, (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
    mrBuilder.setAuthenticationData(authenticationData);
    XtrId xtrId = new XtrId(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 });
    mrBuilder.setXtrId(xtrId);
    SiteId siteId = new SiteId(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 });
    mrBuilder.setSiteId(siteId);
    ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
    // Type + MSByte of reserved
    assertHexEquals((byte) 0x3a, bb.get());
    // Rest of reserved + want map notify
    assertEquals(1, bb.getShort());
    // Record Count
    assertEquals(2, bb.get());
    // Nonce
    assertEquals(6161616161L, bb.getLong());
    // Key ID
    assertHexEquals((short) 0x0001, bb.getShort());
    assertEquals(authenticationData.length, bb.getShort());
    byte[] actualAuthenticationData = new byte[20];
    bb.get(actualAuthenticationData);
    ArrayAssert.assertEquals(authenticationData, actualAuthenticationData);
    // EID in first record
    bb.position(bb.position() + 12);
    assertEquals(0x1, bb.getInt());
    // EID in second record
    bb.position(bb.position() + 12);
    assertEquals(73, bb.getInt());
    byte[] actualXtrId = new byte[Length.XTRID_SIZE];
    bb.get(actualXtrId);
    ArrayAssert.assertEquals(xtrId.getValue(), actualXtrId);
    byte[] actualSiteId = new byte[Length.SITEID_SIZE];
    bb.get(actualSiteId);
    ArrayAssert.assertEquals(siteId.getValue(), actualSiteId);
    assertEquals(bb.position(), bb.capacity());
}
Also used : MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) SiteId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ByteBuffer(java.nio.ByteBuffer) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId) Test(org.junit.Test)

Aggregations

LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)28 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)16 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)13 Test (org.junit.Test)9 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)9 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)8 ArrayList (java.util.ArrayList)5 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)5 ByteBuffer (java.nio.ByteBuffer)4 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)4 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)3 MapRegisterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder)3 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)3 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)3 LinkedHashMap (java.util.LinkedHashMap)2 Site (org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site)2 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)2 ExplicitLocatorPath (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)2 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)2