Search in sources :

Example 26 with LocatorRecord

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

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

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

the class LispAuthenticationTest method authenticate__MapNotifyNoAuthenticationData.

// @Test
// public void authenticate__MapNotifySHA1() throws Exception {
// MapNotify mapNotify = new MapNotify();
// mapNotify.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(1)));
// 
// mapNotify.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(73)));
// mapNotify.setNonce(6161616161L);
// mapNotify.setKeyId((short) 0x0001);
// byte[] wantedAuthenticationData = new byte[] { (byte) 0x66, (byte) 0x69,
// (byte) 0x2c, (byte) 0xb8, (byte) 0xb8, (byte) 0x58, (byte) 0x7c,
// (byte) 0x8f, (byte) 0x4c, (byte) 0xd4, (byte) 0x8b, (byte) 0x77, (byte)
// 0x46, (byte) 0xf0, (byte) 0x6b, (byte) 0x9f, (byte) 0x66,
// (byte) 0xd2, (byte) 0xaa, (byte) 0x2c };
// ArrayAssert.assertEquals(wantedAuthenticationData,
// LispAuthenticationUtil.createAuthenticationData(mapNotify, "password"));
// 
// }
// 
// @Test
// public void authenticate__MapNotifySHA256() throws Exception {
// MapNotify mapNotify = new MapNotify();
// mapNotify.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(1)));
// 
// mapNotify.addEidToLocator(new EidToLocatorRecord().setPrefix(new
// LispIpv4Address(73)));
// mapNotify.setNonce(6161616161L);
// mapNotify.setKeyId((short) 0x0002);
// byte[] wantedAuthenticationData = new byte[] { (byte) 0x4c, (byte) 0xf1,
// (byte) 0x5a, (byte) 0x4c, (byte) 0xdb, (byte) 0x8d, (byte) 0x88,
// (byte) 0x47, (byte) 0xf1, (byte) 0x7f, (byte) 0x27, (byte) 0x81, (byte)
// 0x1e, (byte) 0xbf, (byte) 0x22, (byte) 0xc7, (byte) 0xe6,
// (byte) 0x70, (byte) 0x16, (byte) 0x5e, (byte) 0xa1, (byte) 0x59, (byte)
// 0xe4, (byte) 0x06, (byte) 0x3f, (byte) 0xc2, (byte) 0x6a,
// (byte) 0x1c, (byte) 0x86, (byte) 0xa5, (byte) 0x8d, (byte) 0x63 };
// ArrayAssert.assertEquals(wantedAuthenticationData,
// LispAuthenticationUtil.createAuthenticationData(mapNotify, "password"));
// 
// }
@Test
public void authenticate__MapNotifyNoAuthenticationData() throws Exception {
    MapNotifyBuilder mapNotifyBuilder = new MapNotifyBuilder();
    mapNotifyBuilder.setKeyId((short) 0x0000);
    mapNotifyBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    MappingRecordBuilder etlrBuilder = new MappingRecordBuilder();
    etlrBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
    etlrBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("1.1.1.1/32"));
    etlrBuilder.setRecordTtl(55);
    mapNotifyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlrBuilder.build()).build());
    final ByteBuffer serializedMapNotifyMsg = MapNotifySerializer.getInstance().serialize(mapNotifyBuilder.build());
    ArrayAssert.assertEquals(new byte[0], LispAuthenticationUtil.createAuthenticationData(serializedMapNotifyMsg, "password"));
}
Also used : 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) MapNotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder) ByteBuffer(java.nio.ByteBuffer) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord) Test(org.junit.Test)

Example 29 with LocatorRecord

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

Example 30 with LocatorRecord

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

the class MappingDataListener method convertToBinaryIfNecessary.

private static List<LocatorRecord> convertToBinaryIfNecessary(List<LocatorRecord> originalLocators) {
    List<LocatorRecord> convertedLocators = null;
    for (LocatorRecord record : originalLocators) {
        if (LispAddressUtil.addressNeedsConversionToBinary(record.getRloc().getAddress())) {
            LocatorRecordBuilder lrb = new LocatorRecordBuilder(record);
            lrb.setRloc(LispAddressUtil.convertToBinary(record.getRloc()));
            if (convertedLocators == null) {
                convertedLocators = new ArrayList<LocatorRecord>();
            }
            convertedLocators.add(lrb.build());
        }
    }
    if (convertedLocators != null) {
        return convertedLocators;
    }
    return originalLocators;
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

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