use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.
the class MapResolverTest method handleMapRequest__withSubscribersToRemove.
/**
* Tests {@link MapResolver#handleMapRequest} method.
*/
@Test
@Ignore
public void handleMapRequest__withSubscribersToRemove() {
// input mapping
final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
Mockito.when(mapServiceMock.getData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock);
Subscriber subscriberMock = new Subscriber(mapRequestBuilder.getItrRloc().get(0).getRloc(), mapRequestBuilder.getSourceEid().getEid(), Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT);
subscriberMock.setSubscriberTtlByRecordTtl(mappingRecordBuilder.getRecordTtl());
Mockito.when(subscriberSetMock.contains(subscriberMock)).thenReturn(true);
// result
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder.build()).build());
// check if a subscriber is re-instantiating when there already is one in the subscriber set
mapResolver.handleMapRequest(mapRequestBuilder.build());
Mockito.verify(subscriberSetMock).remove(subscriberMock);
Mockito.verify(subscriberSetMock).add(subscriberMock);
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
Mockito.verify(mapServiceMock).addData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS, subscriberSetMock);
// verify that itrRloc is subscribed to dst address
mappingRecordBuilder.setEid(SOURCE_DEST_KEY_EID);
mapRequestBuilder.getEidItem().add(new EidItemBuilder().setEid(IPV4_PREFIX_EID_2).build());
mappingData = getDefaultMappingData(mappingRecordBuilder.build());
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_2)).thenReturn(mappingData);
mapResolver.handleMapRequest(mapRequestBuilder.build());
Mockito.verify(mapServiceMock).getData(MappingOrigin.Southbound, SourceDestKeyHelper.getDstBinary(SOURCE_DEST_KEY_EID), SubKeys.SUBSCRIBERS);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.
the class MapResolverTest method handleMapRequest_withMultipleEids.
/**
* Tests {@link MapResolver#handleMapRequest} method.
*/
@Test
public void handleMapRequest_withMultipleEids() {
mapRequestBuilder.getEidItem().add(new EidItemBuilder().setEid(IPV6_PREFIX_EID).build());
final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder();
final LocatorRecordBuilder locatorRecordBuilder_2 = getDefaultLocatorBuilder();
locatorRecordBuilder_2.setRloc(LispAddressUtil.asIpv6Rloc(IPV6_STRING));
// input mapping
final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder();
mappingRecordBuilder_1.getLocatorRecord().add(locatorRecordBuilder_1.build());
final MappingData mappingData_1 = getDefaultMappingData(mappingRecordBuilder_1.build());
final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
mappingRecordBuilder_2.getLocatorRecord().add(locatorRecordBuilder_2.build());
mappingRecordBuilder_2.setEid(IPV6_PREFIX_EID);
final MappingData mappingData_2 = getDefaultMappingData(mappingRecordBuilder_2.build());
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), mapRequestBuilder.getEidItem().get(0).getEid())).thenReturn(mappingData_1);
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), mapRequestBuilder.getEidItem().get(1).getEid())).thenReturn(mappingData_2);
// result
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder_1.build()).build());
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder_2.build()).build());
mapResolver.handleMapRequest(mapRequestBuilder.build());
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder 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");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.
the class LispSouthboundHandlerTest method before.
@Override
@Before
public void before() throws Exception {
super.before();
mockLispSouthboundPlugin = Mockito.mock(LispSouthboundPlugin.class);
contextMockLispSouthboundPlugin = context.mock(LispSouthboundPlugin.class);
Mockito.when(mockLispSouthboundPlugin.isMapRegisterCacheEnabled()).thenReturn(true);
Mockito.when(mockLispSouthboundPlugin.getMapRegisterCacheTimeout()).thenReturn(CACHE_RECORD_TIMEOUT);
mapRegisterCache = new MapRegisterCache();
Mockito.when(mockLispSouthboundPlugin.getMapRegisterCache()).thenReturn(mapRegisterCache);
Mockito.when(mockLispSouthboundPlugin.getDataBroker()).thenReturn(Mockito.mock(DataBroker.class));
Mockito.when(mockLispSouthboundPlugin.getAkdb()).thenReturn(akdb);
Mockito.when(mockLispSouthboundPlugin.getAuthenticationKeyDataListener()).thenReturn(akdl);
ConcurrentLispSouthboundStats lispSouthboundStats = new ConcurrentLispSouthboundStats();
Mockito.when(mockLispSouthboundPlugin.getStats()).thenReturn(lispSouthboundStats);
testedLispService = new LispSouthboundHandler(mockLispSouthboundPlugin);
// SRC: 127.0.0.1:58560 to 127.0.0.1:4342
// LISP(Type = 8 - Encapsulated)
// IP: 192.168.136.10 -> 1.2.3.4
// UDP: 56756
// LISP(Type = 1 Map-Request
// Record Count: 1
// ITR-RLOC count: 0
// Source EID AFI: 0
// Source EID not present
// Nonce: 0x3d8d2acd39c8d608
// ITR-RLOC AFI=1 Address=192.168.136.10
// Record 1: 1.2.3.4/32
mapRequestPacket = extractWSUdpByteArray("0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 " + "0010 00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 " + "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 " + "0030 00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 " + "0040 03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d " + "0050 2a cd 39 c8 d6 08 00 01 01 02 03 04 00 01 c0 a8 88 0a 00 20 " + "0060 00 01 01 02 03 04");
mapReplyBuilder = new MapReplyBuilder();
mapReplyBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapReplyBuilder.setNonce((long) 0);
mapReplyBuilder.setEchoNonceEnabled(false);
mapReplyBuilder.setProbe(true);
mapReplyBuilder.setSecurityEnabled(true);
mappingRecordBuilder = new MappingRecordBuilder();
String ip = "0.0.0.0";
mappingRecordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid(ip + "/0"));
mappingRecordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
mappingRecordBuilder.setRecordTtl(10);
mappingRecordBuilder.setMapVersion((short) 0);
mappingRecordBuilder.setAction(Action.NativelyForward);
mappingRecordBuilder.setAuthoritative(false);
// eidToLocatorBuilder.setPrefix(new LispIpv4Address(0));
// mapReply.addEidToLocator(eidToLocatorBuilder);
// IP: 192.168.136.10 -> 128.223.156.35
// UDP: 49289 -> 4342
// LISP(Type = 3 Map-Register, P=1, M=1
// Record Counter: 1
// Nonce: 0
// Key ID: 0x0001
// AuthDataLength: 20 Data:
// e8:f5:0b:c5:c5:f2:b0:21:27:a8:21:41:04:f3:46:5a:a5:68:89:ec
// EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
// No-Action
// Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
// Priority/Weight: 1/100, Multicast Priority/Weight:
// 255/0
//
mapRegisterPacket = extractWSUdpByteArray("0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 " + "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df " + "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 " + "0030 00 00 00 00 00 00 00 01 00 14 0e a4 c6 d8 a4 06 " + "0040 71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 " + "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
mapNotifyBuilder = new MapNotifyBuilder();
mapNotifyBuilder.setAuthenticationData(new byte[0]);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.MapReplyBuilder in project lispflowmapping by opendaylight.
the class MapReplySerializationTest method serialize__SomeFlags.
@Test
public void serialize__SomeFlags() throws Exception {
MapReplyBuilder mr = new MapReplyBuilder();
mr.setMappingRecordItem(new ArrayList<MappingRecordItem>());
MappingRecordBuilder recordBuilder = new MappingRecordBuilder();
recordBuilder.setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"));
mr.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(recordBuilder.build()).build());
mr.setProbe(true);
mr.setEchoNonceEnabled(false);
ByteBuffer packet = MapReplySerializer.getInstance().serialize(mr.build());
byte firstByte = packet.get(0);
assertHexEquals((byte) 0x28, firstByte);
mr.setProbe(false);
mr.setEchoNonceEnabled(true);
packet = MapReplySerializer.getInstance().serialize(mr.build());
firstByte = packet.get(0);
assertHexEquals((byte) 0x24, firstByte);
}
Aggregations