Search in sources :

Example 21 with MapReply

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

the class LispMappingServiceTest method onRequestMappingTest.

/**
 * Tests {@link LispMappingService#onRequestMapping} method.
 */
@Test
public void onRequestMappingTest() {
    final RequestMapping requestMapping = Mockito.mock(RequestMapping.class);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest mapRequest = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest.class);
    final MapReply mapReply = new MapReplyBuilder().build();
    Mockito.when(requestMapping.getMapRequest()).thenReturn(mapRequest);
    Mockito.when(requestMapping.getTransportAddress()).thenReturn(TRANSPORT_ADDRESS_1);
    Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
    Mockito.when(tlsMapReplyMock.get()).thenReturn(mapReply);
    // result
    final SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder().setMapReply(new MapReplyBuilder(mapReply).build()).setTransportAddress(TRANSPORT_ADDRESS_1);
    lispMappingService.onRequestMapping(requestMapping);
    Mockito.verify(odlLispSbService).sendMapReply(smrib.build());
}
Also used : SendMapReplyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInputBuilder) 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) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) RequestMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.RequestMapping) XtrRequestMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrRequestMapping) Test(org.junit.Test)

Example 22 with MapReply

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

the class LispMappingServiceTest method onRequestMappingTest_withNullMapReply.

/**
 * Tests {@link LispMappingService#onRequestMapping} method with mapReply == null.
 */
@Test
public void onRequestMappingTest_withNullMapReply() {
    final RequestMapping requestMapping = Mockito.mock(RequestMapping.class);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest mapRequest = Mockito.mock(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequest.class);
    Mockito.when(requestMapping.getMapRequest()).thenReturn(mapRequest);
    Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
    Mockito.when(tlsMapReplyMock.get()).thenReturn(null);
    lispMappingService.onRequestMapping(requestMapping);
    Mockito.verifyZeroInteractions(odlLispSbService);
}
Also used : RequestMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.RequestMapping) XtrRequestMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrRequestMapping) Test(org.junit.Test)

Example 23 with MapReply

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

the class LispMappingServiceTest method handleMapRequestTest.

/**
 * Tests {@link LispMappingService#handleMapRequest} method.
 */
@Test
public void handleMapRequestTest() {
    final MapRequest mapRequest = Mockito.mock(MapRequest.class);
    final MapReply mapReply = new MapReplyBuilder().build();
    Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
    Mockito.when(tlsMapRequestMock.get()).thenReturn(null);
    Mockito.when(tlsMapReplyMock.get()).thenReturn(mapReply);
    final MapReply result = lispMappingService.handleMapRequest(mapRequest);
    Mockito.verify(tlsMapRequestMock).set(null);
    Mockito.verify(tlsMapRequestMock).get();
    Mockito.verifyNoMoreInteractions(tlsMapRequestMock);
    Mockito.verify(mapResolverMock).handleMapRequest(mapRequest);
    Mockito.verify(tlsMapReplyMock).set(Mockito.any(MapReply.class));
    Mockito.verify(tlsMapReplyMock).get();
    assertEquals(result, mapReply);
}
Also used : MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.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) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) Test(org.junit.Test)

Example 24 with MapReply

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

the class LispMappingService method onRequestMapping.

@Override
public void onRequestMapping(RequestMapping mapRequestNotification) {
    MapReply mapReply = handleMapRequest(mapRequestNotification.getMapRequest());
    if (mapReply != null) {
        SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder();
        smrib.setMapReply((new MapReplyBuilder(mapReply).build()));
        smrib.setTransportAddress(mapRequestNotification.getTransportAddress());
        getLispSB().sendMapReply(smrib.build());
    } else {
        LOG.debug("handleMapRequest: Got null MapReply");
    }
}
Also used : SendMapReplyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInputBuilder) 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) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder)

Example 25 with MapReply

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

the class LispSouthboundHandler method handleMapReply.

@SuppressWarnings("checkstyle:IllegalCatch")
private void handleMapReply(ByteBuffer inBuffer, InetAddress sourceAddress, int port) {
    try {
        MapReply mapReply = MapReplySerializer.getInstance().deserialize(inBuffer);
        GotMapReplyBuilder gotMapReplyBuilder = new GotMapReplyBuilder();
        gotMapReplyBuilder.setMapReply(LispNotificationHelper.convertMapReply(mapReply));
        TransportAddressBuilder transportAddressBuilder = new TransportAddressBuilder();
        transportAddressBuilder.setIpAddress(LispNotificationHelper.getIpAddressBinaryFromInetAddress(sourceAddress));
        transportAddressBuilder.setPort(new PortNumber(port));
        gotMapReplyBuilder.setTransportAddress(transportAddressBuilder.build());
        lispSbPlugin.sendNotificationIfPossible(gotMapReplyBuilder.build());
    } catch (RuntimeException re) {
        throw new LispMalformedPacketException("Couldn't deserialize Map-Reply (len=" + inBuffer.capacity() + ")", re);
    } catch (InterruptedException e) {
        LOG.warn("Notification publication interrupted!");
    }
}
Also used : MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) LispMalformedPacketException(org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException) GotMapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReplyBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) TransportAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder)

Aggregations

MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)44 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)38 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)25 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)12 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)9 SourceEidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.SourceEidBuilder)9 Test (org.junit.Test)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)8 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 MapRequest (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)6 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)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 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)5 EidItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder)5 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 MapRegister (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRegister)4 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)4 MapRequestBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder)4