Search in sources :

Example 6 with MapRegisterBuilder

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

the class MapServerTest method getDefaultMapRegisterBuilder.

private static MapRegisterBuilder getDefaultMapRegisterBuilder() {
    final MapRegisterBuilder mapRegisterBuilder = new MapRegisterBuilder().setProxyMapReply(true).setWantMapNotify(true).setKeyId((short) 0).setMappingRecordItem(new ArrayList<>()).setMergeEnabled(true).setNonce(1L).setSiteId(new SiteId(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 })).setXtrId(new XtrId(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 })).setXtrSiteIdPresent(true);
    mapRegisterBuilder.getMappingRecordItem().add(getDefaultMappingRecordItemBuilder().build());
    return mapRegisterBuilder;
}
Also used : SiteId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId) ArrayList(java.util.ArrayList) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder) XtrId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)

Example 7 with MapRegisterBuilder

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

the class MultiSiteScenario method emitMapRegisterMessage.

private void emitMapRegisterMessage(final Site dstSite, final boolean merge) {
    final MapRegisterBuilder mapRegisterBuilder = new MapRegisterBuilder();
    mapRegisterBuilder.setXtrSiteIdPresent(true);
    mapRegisterBuilder.setXtrId(dstSite.getXtrId());
    mapRegisterBuilder.setSiteId(new SiteId(DEFAULT_SITE_ID));
    mapRegisterBuilder.setMergeEnabled(merge);
    final MappingRecordItemBuilder mappingRecordItemBuilder = new MappingRecordItemBuilder();
    mappingRecordItemBuilder.setMappingRecordItemId(MAP_RECORD_A);
    final MappingRecordBuilder mrb = prepareMappingRecord(EidType.EID_WITH_PREFIX, null, dstSite);
    mappingRecordItemBuilder.setMappingRecord(mrb.build());
    mapRegisterBuilder.setMappingRecordItem(Collections.singletonList(mappingRecordItemBuilder.build()));
    lms.handleMapRegister(mapRegisterBuilder.build());
}
Also used : SiteId(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder)

Example 8 with MapRegisterBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder 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 9 with MapRegisterBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder 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 10 with MapRegisterBuilder

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

the class MapRegisterSerializationTest method serialize__NoAuthenticationData.

@Test
public void serialize__NoAuthenticationData() throws Exception {
    MapRegisterBuilder mrBuilder = new MapRegisterBuilder();
    mrBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
    mrBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setRecordTtl(55).setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build()).build());
    // mrBuilder.addEidToLocator(new EidToLocatorRecord().setPrefix(new
    // LispIpv4Address(1)).setRecordTtl(55));
    ByteBuffer bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
    mrBuilder.setAuthenticationData(null);
    bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
    mrBuilder.setAuthenticationData(new byte[0]);
    bb = MapRegisterSerializer.getInstance().serialize(mrBuilder.build());
    // jump to AuthenticationDataLength
    bb.position(bb.position() + 14);
    assertEquals(0, bb.getShort());
    assertEquals(55, bb.getInt());
}
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) ByteBuffer(java.nio.ByteBuffer) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder) Test(org.junit.Test)

Aggregations

MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)9 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)8 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)8 MapRegisterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregisternotification.MapRegisterBuilder)8 Test (org.junit.Test)5 SiteId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId)4 MapRegisterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder)4 ByteBuffer (java.nio.ByteBuffer)3 ArrayList (java.util.ArrayList)3 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)3 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)3 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)2 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)2 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)2 Ignore (org.junit.Ignore)1 LispSerializationException (org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException)1 AddMappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMappingBuilder)1 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)1 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)1 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)1