use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.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!");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.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());
}
Aggregations