use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method sendSMRInvokedMapRequestMessage.
/**
* This method expects a SMR Map-Request as input, which it will turn into a SMR-invoked Map-Request and use the
* LISP mapping service to send it
*
* @param mapRequest the SMR Map-Request
* @param lms referencs to the LISP Mapping Service
*/
static void sendSMRInvokedMapRequestMessage(MapRequest mapRequest, IFlowMapping lms) {
Eid eid = addMaximumPrefixIfNecessary(mapRequest.getSourceEid().getEid());
final EidItemBuilder eidItemBuilder = new EidItemBuilder();
eidItemBuilder.setEid(eid);
eidItemBuilder.setEidItemId(LispAddressStringifier.getString(eid));
final List<EidItem> eidItem = Collections.singletonList(eidItemBuilder.build());
final MapRequestBuilder mapRequestBuilder = new MapRequestBuilder(mapRequest);
mapRequestBuilder.setSmr(false);
mapRequestBuilder.setSmrInvoked(true);
mapRequestBuilder.setItrRloc(getDefaultItrRlocList(LispAddressUtil.asIpv4Rloc(RECEIVE_ADDRESS)));
mapRequestBuilder.setEidItem(eidItem);
for (EidItem srcEid : mapRequest.getEidItem()) {
mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(removePrefixIfNecessary(srcEid.getEid())).build());
LOG.debug("Sending SMR-invoked Map-Request for EID {}, Source EID {}", LispAddressStringifier.getString(eid), LispAddressStringifier.getString(srcEid.getEid()));
lms.handleMapRequest(mapRequestBuilder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method receiveExpectedSmrs.
/**
* Receive a given number of SMR packets on the given UDP socket or fail.
*
* @param datagramSocket the receive socket
* @param count the number of expected SMRs
* @return the list of received SMRs
*/
static List<MapRequest> receiveExpectedSmrs(DatagramSocket datagramSocket, int count) {
LOG.debug("Expecting {} SMRs ", count);
List<MapRequest> mapRequests = new ArrayList<>();
int i = 0;
try {
while (i < count) {
MapRequest mapRequest = receiveMapRequest(datagramSocket, DEFAULT_SOCKET_TIMEOUT);
LOG.trace("Solicit Map-Request: {}", mapRequest);
assertEquals(true, mapRequest.isSmr());
if (mapRequest.getEidItem().isEmpty()) {
fail("Empty SMR received (no EID record)!");
}
mapRequests.add(mapRequest);
i++;
}
} catch (SocketTimeoutException ste) {
fail("Expected " + count + " SMRs, received " + i);
}
return mapRequests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest in project lispflowmapping by opendaylight.
the class MultiSiteScenario method checkSMR.
void checkSMR(final SocketReader socketReader, final String site, final String... hosts) {
LOG.debug("\n" + mapService.prettyPrintMappings());
byte[][] buffers = socketReader.getBuffers(hosts.length);
if (areBuffersEmpty(buffers)) {
fail("No SMR received!");
}
List<MapRequest> mapRequests = translateBuffersToMapRequest(buffers);
if (hosts.length != mapRequests.size()) {
LOG.error("Expected {} SMRs, received {}", hosts.length, mapRequests.size());
fail("Unexpected number of SMRs received");
}
final Set<Eid> eids = prepareExpectedEid(hosts);
final SourceEid expectedSourceEid = prepareSourceEid(site);
for (MapRequest mapRequest : mapRequests) {
LOG.trace("Map-Request: {}", mapRequest);
assertTrue(mapRequest.isSmr());
final SourceEid receivedSourceEid = mapRequest.getSourceEid();
assertEquals(expectedSourceEid, receivedSourceEid);
final List<EidItem> currentEidItems = mapRequest.getEidItem();
assertNotNull(currentEidItems);
assertTrue(SMRContainsExpectedEid(eids, currentEidItems));
MappingServiceIntegrationTestUtil.sendSMRInvokedMapRequestMessage(mapRequest, lms);
}
// all expected eids should be after looping via mapRequests matched.
assertTrue("Expected eids wasn't/weren't found " + eids, eids.isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest in project lispflowmapping by opendaylight.
the class MultiSiteScenario method translateBuffersToMapRequest.
private List<MapRequest> translateBuffersToMapRequest(byte[][] buffers) {
final List<MapRequest> mapRequests = new ArrayList<>();
for (byte[] buffer : buffers) {
if (isBufferEmpty(buffer)) {
LOG.error("Empty buffer while translating Map-Request");
continue;
}
final MapRequest mapRequest = MapRequestSerializer.getInstance().deserialize(ByteBuffer.wrap(buffer), null);
assertNotNull(mapRequest);
mapRequests.add(mapRequest);
}
return mapRequests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest in project lispflowmapping by opendaylight.
the class MapRequestUtilTest method selectItrRlocTest_Ipv4Prefix.
/**
* Tests {@link MapRequestUtil#selectItrRloc} method with Ipv4Prefix.
*/
@Test
public void selectItrRlocTest_Ipv4Prefix() {
final ItrRlocBuilder itrRloc = new ItrRlocBuilder().setRloc(new RlocBuilder().setAddress(IPV4_ADDRESS_PREFIX).build());
final MapRequest request = new MapRequestBuilder().setItrRloc(Lists.newArrayList(itrRloc.build())).build();
assertNull(MapRequestUtil.selectItrRloc(request));
}
Aggregations