Search in sources :

Example 11 with LocatorRecordBuilder

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

the class MappingServiceIntegrationTest method runPrefixTest.

private void runPrefixTest(Eid registerEID, Eid matchedAddress, Eid unMatchedAddress) throws SocketTimeoutException {
    mapService.addAuthenticationKey(registerEID, NULL_AUTH_KEY);
    sleepForSeconds(1);
    MapRegisterBuilder mapRegister = new MapRegisterBuilder();
    mapRegister.setWantMapNotify(true);
    mapRegister.setNonce((long) 8);
    mapRegister.setWantMapNotify(true);
    mapRegister.setKeyId((short) 0);
    mapRegister.setAuthenticationData(new byte[0]);
    mapRegister.setNonce((long) 8);
    mapRegister.setProxyMapReply(false);
    MappingRecordBuilder etlr = new MappingRecordBuilder();
    etlr.setRecordTtl(254);
    etlr.setAction(Action.NoAction);
    etlr.setAuthoritative(false);
    etlr.setMapVersion((short) 0);
    etlr.setEid(registerEID);
    etlr.setRecordTtl(254);
    LocatorRecordBuilder record = new LocatorRecordBuilder();
    record.setRloc(LispAddressUtil.asIpv4Rloc("4.3.2.1"));
    record.setLocalLocator(false);
    record.setRlocProbed(false);
    record.setRouted(true);
    record.setMulticastPriority((short) 0);
    record.setMulticastWeight((short) 0);
    record.setPriority((short) 0);
    record.setWeight((short) 0);
    etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
    etlr.getLocatorRecord().add(record.build());
    mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());
    sendMapRegister(mapRegister.build());
    MapNotify mapNotify = receiveMapNotify();
    assertEquals(8, mapNotify.getNonce().longValue());
    sleepForSeconds(1);
    MapRequestBuilder mapRequest = new MapRequestBuilder();
    mapRequest.setNonce((long) 4);
    mapRequest.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(ourAddress)).build());
    mapRequest.setEidItem(new ArrayList<EidItem>());
    mapRequest.setAuthoritative(false);
    mapRequest.setMapDataPresent(false);
    mapRequest.setPitr(false);
    mapRequest.setProbe(false);
    mapRequest.setSmr(false);
    mapRequest.setSmrInvoked(false);
    mapRequest.getEidItem().add(new EidItemBuilder().setEid(matchedAddress).build());
    mapRequest.setItrRloc(new ArrayList<ItrRloc>());
    mapRequest.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(ourAddress)).build());
    sendMapRequest(mapRequest.build());
    MapReply mapReply = receiveMapReply();
    assertEquals(4, mapReply.getNonce().longValue());
    assertEquals(record.getRloc(), mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc());
    mapRequest.setEidItem(new ArrayList<EidItem>());
    mapRequest.getEidItem().add(new EidItemBuilder().setEid(unMatchedAddress).build());
    sendMapRequest(mapRequest.build());
    mapReply = receiveMapReply();
    assertEquals(0, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem) 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) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) GotMapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify) MapNotify(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify) 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) 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) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)

Example 12 with LocatorRecordBuilder

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

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

the class MapReplySerializationTest method serialize__LocatorRecordFields.

@Test
public void serialize__LocatorRecordFields() throws Exception {
    MapReplyBuilder mrBuilder = new MapReplyBuilder();
    mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    MappingRecordBuilder eidToLocatorBuilder = new MappingRecordBuilder();
    eidToLocatorBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
    eidToLocatorBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    LocatorRecordBuilder locatorBuilder1 = new LocatorRecordBuilder();
    locatorBuilder1.setPriority((short) 0xF3);
    locatorBuilder1.setWeight((short) 0xF6);
    locatorBuilder1.setMulticastPriority((short) 0xA3);
    locatorBuilder1.setMulticastWeight((short) 0x06);
    locatorBuilder1.setRloc(LispAddressUtil.asIpv4Rloc("0.0.0.1"));
    locatorBuilder1.setLocalLocator(true);
    locatorBuilder1.setRlocProbed(true);
    locatorBuilder1.setRouted(true);
    eidToLocatorBuilder.getLocatorRecord().add(locatorBuilder1.build());
    LocatorRecordBuilder locatorBuilder2 = new LocatorRecordBuilder();
    locatorBuilder2.setPriority((short) 0x03);
    locatorBuilder2.setWeight((short) 0x06);
    locatorBuilder2.setMulticastPriority((short) 0x03);
    locatorBuilder2.setMulticastWeight((short) 0xF1);
    locatorBuilder2.setRloc(LispAddressUtil.asIpv4Rloc("0.0.0.2"));
    locatorBuilder2.setLocalLocator(false);
    locatorBuilder2.setRlocProbed(false);
    locatorBuilder2.setRouted(false);
    eidToLocatorBuilder.getLocatorRecord().add(locatorBuilder2.build());
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(eidToLocatorBuilder.build()).build());
    ByteBuffer packet = MapReplySerializer.getInstance().serialize(mrBuilder.build());
    // First locator record
    packet.position(12 + 16);
    assertHexEquals((byte) 0xF3, packet.get());
    assertHexEquals((byte) 0xF6, packet.get());
    assertHexEquals((byte) 0xA3, packet.get());
    assertHexEquals((byte) 0x06, packet.get());
    packet.position(packet.position() + 1);
    assertHexEquals((byte) 0x07, packet.get());
    // Second locator record
    packet.position(packet.position() + 6);
    assertHexEquals((byte) 0x03, packet.get());
    assertHexEquals((byte) 0x06, packet.get());
    assertHexEquals((byte) 0x03, packet.get());
    assertHexEquals((byte) 0xF1, packet.get());
    packet.position(packet.position() + 1);
    assertHexEquals((byte) 0x00, packet.get());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) 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) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) ByteBuffer(java.nio.ByteBuffer) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) Test(org.junit.Test)

Example 14 with LocatorRecordBuilder

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

the class MapRequestSerializationTest method serialize__AllWithMapReply.

@Test
public void serialize__AllWithMapReply() throws Exception {
    MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
    mapRequestBuilder.setProbe(true);
    mapRequestBuilder.setMapDataPresent(true);
    mapRequestBuilder.setPitr(true);
    mapRequestBuilder.setNonce((long) 13);
    mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(("10.0.0.1"))).build());
    mapRequestBuilder.setItrRloc(new ArrayList<ItrRloc>());
    mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc("1.2.3.4")).build());
    mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv6Rloc("1:2:3:4:5:6:7:8")).build());
    mapRequestBuilder.setEidItem(new ArrayList<EidItem>());
    mapRequestBuilder.getEidItem().add(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("1.2.3.4/32")).build());
    MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
    recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/0"));
    recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    LocatorRecordBuilder locatorBuilder = new LocatorRecordBuilder();
    locatorBuilder.setRloc(LispAddressUtil.asIpv4Rloc("0.0.0.2"));
    recordBuilder.getLocatorRecord().add(locatorBuilder.build());
    MapReplyBuilder mapreplyBuilder = new MapReplyBuilder();
    mapreplyBuilder.setMappingRecord(recordBuilder.build());
    mapRequestBuilder.setMapReply(mapreplyBuilder.build());
    ByteBuffer expected = hexToByteBuffer("16 80 01 01 00 00 " + "00 00 00 00 00 0D 00 01 0a 00 00 01 00 01 01 02 03 04 00 02 00 01 00 02 00 03 00 04 00 05 00 06 " + // map
    "00 07 00 08 00 20 00 01 01 02 03 04 " + "00 00 00 00 01 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 02");
    assertArrayEquals(expected.array(), MapRequestSerializer.getInstance().serialize(mapRequestBuilder.build()).array());
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder) 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) ByteBuffer(java.nio.ByteBuffer) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) Test(org.junit.Test)

Example 15 with LocatorRecordBuilder

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

the class MappingSystem method updateServicePathMappingRecord.

private MappingData updateServicePathMappingRecord(MappingData mappingData, Eid eid) {
    // keep properties of original record
    MappingRecordBuilder recordBuilder = new MappingRecordBuilder(mappingData.getRecord());
    recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    // there should only be one locator record
    if (mappingData.getRecord().getLocatorRecord().size() != 1) {
        LOG.warn("MappingRecord associated to ServicePath EID has more than one locator!");
        return mappingData;
    }
    LocatorRecord locatorRecord = mappingData.getRecord().getLocatorRecord().get(0);
    long serviceIndex = ((ServicePath) eid.getAddress()).getServicePath().getServiceIndex();
    int index = LispAddressUtil.STARTING_SERVICE_INDEX - (int) serviceIndex;
    Rloc rloc = locatorRecord.getRloc();
    if (rloc.getAddress() instanceof Ipv4 || rloc.getAddress() instanceof Ipv6) {
        if (index != 0) {
            LOG.warn("Service Index should be 255 for simple IP RLOCs!");
        }
        return mappingData;
    } else if (rloc.getAddress() instanceof ExplicitLocatorPath) {
        ExplicitLocatorPath elp = (ExplicitLocatorPath) rloc.getAddress();
        List<Hop> hops = elp.getExplicitLocatorPath().getHop();
        if (index < 0 || index > hops.size()) {
            LOG.warn("Service Index out of bounds!");
            return mappingData;
        }
        SimpleAddress nextHop = hops.get(index).getAddress();
        LocatorRecordBuilder lrb = new LocatorRecordBuilder(locatorRecord);
        lrb.setRloc(LispAddressUtil.toRloc(nextHop));
        recordBuilder.getLocatorRecord().add(lrb.build());
        return new MappingData(recordBuilder.build());
    } else {
        LOG.warn("Nothing to do with ServicePath mapping record");
        return mappingData;
    }
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) Ipv6(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) Ipv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) List(java.util.List) ArrayList(java.util.ArrayList) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) ExplicitLocatorPath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath)

Aggregations

LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)22 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)13 Test (org.junit.Test)11 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)11 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)9 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)8 MapReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)7 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)7 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)6 ArrayList (java.util.ArrayList)5 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)5 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)4 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)4 Ignore (org.junit.Ignore)3 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)3 ByteBuffer (java.nio.ByteBuffer)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)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