Search in sources :

Example 21 with MapRequest

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

the class LispMappingService method handleSMR.

@Override
public void handleSMR(MapRequest smrMapRequest, Rloc subscriber) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Sending SMR Map-Request to {} with Source-EID {} and EID Record {} (reversed)", LispAddressStringifier.getString(subscriber), LispAddressStringifier.getString(smrMapRequest.getSourceEid().getEid()), LispAddressStringifier.getString(smrMapRequest.getEidItem().get(0).getEid()));
    }
    SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder();
    smrib.setMapRequest(new MapRequestBuilder(smrMapRequest).build());
    smrib.setTransportAddress(LispNotificationHelper.getTransportAddressFromRloc(subscriber));
    getLispSB().sendMapRequest(smrib.build());
}
Also used : SendMapRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestInputBuilder) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder)

Example 22 with MapRequest

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

the class LispSouthboundRpcTest method sendMapRequestTest_inputNotNull.

/**
 * Tests {@link LispSouthboundRPC#sendMapRequest} method.
 */
@Test
public void sendMapRequestTest_inputNotNull() throws ExecutionException, InterruptedException {
    final MapRequest mapRequest = new MapRequestBuilder().build();
    final TransportAddress transportAddress = new TransportAddressBuilder().build();
    final SendMapRequestInput sendMapRequestInputMock = Mockito.mock(SendMapRequestInput.class);
    Mockito.when(sendMapRequestInputMock.getTransportAddress()).thenReturn(transportAddress);
    Mockito.when(sendMapRequestInputMock.getMapRequest()).thenReturn(mapRequest);
    assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), lispSouthboundRPC.sendMapRequest(sendMapRequestInputMock).get().isSuccessful());
    Mockito.verify(lispSouthboundPlugin).handleSerializedLispBuffer(transportAddress, MapRequestSerializer.getInstance().serialize(mapRequest), MessageType.MapRequest);
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequest) TransportAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress) MapRequestBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder) SendMapRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestInput) Test(org.junit.Test)

Example 23 with MapRequest

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

the class LispSouthboundHandler method handleMapRequest.

@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapRequest(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
    try {
        MapRequest request = MapRequestSerializer.getInstance().deserialize(inBuffer, sourceAddress);
        InetAddress finalSourceAddress = MapRequestUtil.selectItrRloc(request);
        if (finalSourceAddress == null) {
            throw new LispMalformedPacketException("Couldn't deserialize Map-Request, no ITR Rloc found!");
        }
        RequestMappingBuilder requestMappingBuilder = new RequestMappingBuilder();
        requestMappingBuilder.setMapRequest(LispNotificationHelper.convertMapRequest(request));
        TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
        transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(finalSourceAddress));
        transportAddressBuilder.setPort(new PortNumber(port));
        requestMappingBuilder.setTransportAddress(transportAddressBuilder.build());
        lispSbPlugin.sendNotificationIfPossible(requestMappingBuilder.build());
    } catch (RuntimeException re) {
        throw new LispMalformedPacketException("Couldn't deserialize Map-Request (len=" + inBuffer.capacity() + ")", re);
    } catch (InterruptedException e) {
        LOG.warn("Notification publication interrupted!");
    }
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest) RequestMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.RequestMappingBuilder) LispMalformedPacketException(org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) InetAddress(java.net.InetAddress) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)

Example 24 with MapRequest

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

the class MappingServiceIntegrationTest method testRepeatedSmr.

private void testRepeatedSmr() throws SocketTimeoutException, UnknownHostException {
    cleanUP();
    long timeout = ConfigIni.getInstance().getSmrTimeout();
    ConfigIni.getInstance().setSmrRetryCount(5);
    final InstanceIdType iid = new InstanceIdType(1L);
    final Eid eid1 = LispAddressUtil.asIpv4Eid("1.1.1.1", 1L);
    final Eid subscriberEid = LispAddressUtil.asIpv4Eid("2.2.2.2", 1L);
    final int expectedSmrs1 = 2;
    final int expectedSmrs2 = 3;
    /* set auth */
    final Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("0.0.0.0/0", iid);
    mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
    /* add subscribers */
    final String subscriberSrcRloc1 = "127.0.0.3";
    final String subscriberSrcRloc2 = "127.0.0.4";
    final Set<Subscriber> subscriberSet1 = Sets.newHashSet(newSubscriber(subscriberEid, subscriberSrcRloc1), newSubscriber(subscriberEid, subscriberSrcRloc2));
    mapService.addData(MappingOrigin.Southbound, eid1, SubKeys.SUBSCRIBERS, subscriberSet1);
    final SocketReader reader1 = startSocketReader(subscriberSrcRloc1, 15000);
    final SocketReader reader2 = startSocketReader(subscriberSrcRloc2, 15000);
    sleepForSeconds(1);
    /* add mapping */
    final MappingRecord mapping1 = new MappingRecordBuilder().setEid(eid1).setTimestamp(System.currentTimeMillis()).setRecordTtl(1440).build();
    mapService.addMapping(MappingOrigin.Northbound, eid1, null, new MappingData(mapping1));
    sleepForMilliseconds((timeout * expectedSmrs1) - (timeout / 2));
    final List<MapRequest> requests1 = processSmrPackets(reader1, subscriberSrcRloc1, expectedSmrs1);
    final MapReply mapReply1 = lms.handleMapRequest(new MapRequestBuilder(requests1.get(0)).setSourceEid(new SourceEidBuilder().setEid(subscriberEid).build()).setItrRloc(Lists.newArrayList(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(subscriberSrcRloc1)).build())).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(eid1).build())).setSmrInvoked(true).setSmr(false).build());
    // sleep to get 1 extra smr request
    sleepForMilliseconds(timeout * 1);
    final List<MapRequest> requests2 = processSmrPackets(reader2, subscriberSrcRloc2, expectedSmrs2);
    final MapReply mapReply2 = lms.handleMapRequest(new MapRequestBuilder(requests2.get(0)).setSourceEid(new SourceEidBuilder().setEid(subscriberEid).build()).setItrRloc(Lists.newArrayList(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(subscriberSrcRloc2)).build())).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(eid1).build())).setSmrInvoked(true).setSmr(false).build());
    sleepForSeconds(3);
    assertEquals(expectedSmrs1, requests1.size());
    assertEquals(expectedSmrs2, requests2.size());
    assertEquals((long) mapReply1.getNonce(), (long) requests1.get(0).getNonce());
    assertEquals((long) mapReply2.getNonce(), (long) requests2.get(0).getNonce());
    assertNextBufferEmpty(reader1);
    assertNextBufferEmpty(reader2);
    reader1.stopReading();
    reader2.stopReading();
}
Also used : 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) 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) 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) InstanceIdType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) 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) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData)

Example 25 with MapRequest

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

the class MappingServiceIntegrationTest method mapRequestMapRegisterAndMapRequest.

public void mapRequestMapRegisterAndMapRequest() throws SocketTimeoutException {
    cleanUP();
    Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32");
    mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
    sleepForSeconds(1);
    MapRequest mapRequest = MappingServiceIntegrationTestUtil.getDefaultMapRequestBuilder(eid).build();
    sendMapRequest(mapRequest);
    MapReply mapReply = receiveMapReply();
    assertEquals(4, mapReply.getNonce().longValue());
    assertEquals(0, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
    MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
    sendMapRegister(mapRegister);
    MapNotify mapNotify = receiveMapNotify();
    assertEquals(8, mapNotify.getNonce().longValue());
    sleepForSeconds(1);
    sendMapRequest(mapRequest);
    mapReply = receiveMapReply();
    assertEquals(4, mapReply.getNonce().longValue());
    assertEquals(MappingServiceIntegrationTestUtil.DEFAULT_IPV4_RLOC, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc());
}
Also used : 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) 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) 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) MapRegister(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)

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