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;
}
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());
}
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());
}
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;
}
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());
}
Aggregations