Search in sources :

Example 36 with MapRequest

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());
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceEidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder) 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)

Example 37 with MapRequest

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;
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) SocketTimeoutException(java.net.SocketTimeoutException) ArrayList(java.util.ArrayList)

Example 38 with MapRequest

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());
}
Also used : SourceEid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEid) Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) SourceEid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEid) EidItem(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem)

Example 39 with MapRequest

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;
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) ArrayList(java.util.ArrayList)

Example 40 with MapRequest

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));
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) RlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder) ItrRlocBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder) Test(org.junit.Test)

Aggregations

MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)33 Test (org.junit.Test)24 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)11 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)11 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)10 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder)10 ItrRlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRlocBuilder)9 InetAddress (java.net.InetAddress)8 EidItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItem)6 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)6 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)6 RlocBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder)6 GotMapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapNotify)5 MapNotify (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify)5 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)5 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)5 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)5 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequest)5 Ipv4Binary (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary)4 XtrRequestMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrRequestMapping)4