use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder in project lispflowmapping by opendaylight.
the class MapRequestUtil method prepareSMR.
public static MapRequestBuilder prepareSMR(Eid srcEid, Rloc itrRloc) {
MapRequestBuilder builder = new MapRequestBuilder();
builder.setAuthoritative(false);
builder.setMapDataPresent(false);
builder.setPitr(false);
builder.setProbe(false);
builder.setSmr(true);
builder.setSmrInvoked(false);
builder.setSourceEid(new SourceEidBuilder().setEid(srcEid).build());
builder.setItrRloc(new ArrayList<ItrRloc>());
builder.getItrRloc().add(new ItrRlocBuilder().setRloc(itrRloc).build());
builder.setMapReply(null);
builder.setNonce(new Random().nextLong());
return builder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder in project lispflowmapping by opendaylight.
the class MapServer method sendSmrs.
private void sendSmrs(Eid eid, Set<Subscriber> subscribers) {
if (subscribers == null) {
return;
}
final MapRequestBuilder mrb = MapRequestUtil.prepareSMR(eid, LispAddressUtil.toRloc(getLocalAddress()));
LOG.trace("Built SMR packet template (EID field will be set later): " + mrb.build().toString());
scheduler.scheduleSmrs(mrb, subscribers.iterator());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder in project lispflowmapping by opendaylight.
the class MapResolverTest method handleMapRequest_withBothPolicy.
/**
* Tests {@link MapResolver#handleMapRequest} method.
*/
@Test
public void handleMapRequest_withBothPolicy() {
mapResolver = new MapResolver(mapServiceMock, true, "both", lispMappingServiceMock);
final List<IpAddress> ipAddressList = new ArrayList<>();
// hop 1
ipAddressList.add(IPV4_ADDRESS_1);
// hop 2
ipAddressList.add(IPV4_ADDRESS_2);
final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddressList);
final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder();
final LocatorRecordBuilder locatorRecordBuilder_2 = getDefaultLocatorBuilder().setRloc(rloc);
// input mapping
final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build());
final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
final MapRequestBuilder mrb = getDefaultMapRequestBuilder();
mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)).build());
mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).build());
Mockito.when(mapServiceMock.getMapping(mrb.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
// result
final LocatorRecordBuilder locatorRecordBuilder_3 = getDefaultLocatorBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).setPriority((short) 1);
final MappingRecordBuilder resultMappingRecordBuilder = getDefaultMappingRecordBuilder();
// as Ipv4
resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
// as ELP
resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build());
// added to the result
resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build());
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(resultMappingRecordBuilder.build()).build());
// invocation
mapResolver.handleMapRequest(mrb.build());
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder in project lispflowmapping by opendaylight.
the class MapResolverTest method handleMapRequest_withReplacePolicy.
/**
* Tests {@link MapResolver#handleMapRequest} method.
*/
@Test
public void handleMapRequest_withReplacePolicy() {
mapResolver = new MapResolver(mapServiceMock, true, "replace", lispMappingServiceMock);
final List<IpAddress> ipAddressList = new ArrayList<>();
// hop 1
ipAddressList.add(IPV4_ADDRESS_1);
// hop 2
ipAddressList.add(IPV4_ADDRESS_2);
final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddressList);
final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder();
final LocatorRecordBuilder locatorRecordBuilder_2 = getDefaultLocatorBuilder().setRloc(rloc);
// input mapping
final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build());
final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
final MapRequestBuilder mrb = getDefaultMapRequestBuilder();
mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)).build());
mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).build());
Mockito.when(mapServiceMock.getMapping(mrb.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
// result
final LocatorRecordBuilder locatorRecordBuilder_3 = getDefaultLocatorBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2));
final MappingRecordBuilder resultMappingRecordBuilder = getDefaultMappingRecordBuilder();
// as Ipv4
resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
// added to the result
resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build());
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(resultMappingRecordBuilder.build()).build());
// invocation
mapResolver.handleMapRequest(mrb.build());
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder in project lispflowmapping by opendaylight.
the class LispMappingService method handleMapRequest.
public MapReply handleMapRequest(MapRequest request) {
if (LOG.isDebugEnabled()) {
LOG.debug("LISP: Retrieving mapping for {}", LispAddressStringifier.getString(request.getEidItem().get(0).getEid()));
}
tlsMapReply.set(null);
tlsMapRequest.set(null);
mapResolver.handleMapRequest(request);
// After this invocation we assume that the thread local is filled with the reply
if (tlsMapRequest.get() != null) {
SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder();
smrib.setMapRequest(new MapRequestBuilder(tlsMapRequest.get().getLeft()).build());
smrib.setTransportAddress(tlsMapRequest.get().getRight());
getLispSB().sendMapRequest(smrib.build());
return null;
} else {
return tlsMapReply.get();
}
}
Aggregations