Odlparent 3.0.0 will have updated checkstyle rules, see [0] for details.
This patch makes sure the code base will pass those new rules when we
upgrade.
[0] https://lists.opendaylight.org/pipermail/release/2017-September/012353.html
Change-Id: I5d8165f21a276468a2e2262fb106792b0e670885
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
return this.smr;
}
- public void setShouldUseSmr(boolean smr) {
- this.smr = smr;
+ public void setShouldUseSmr(boolean shouldUseSmr) {
+ this.smr = shouldUseSmr;
if (mapServer != null) {
- mapServer.setSubscriptionService(smr);
+ mapServer.setSubscriptionService(shouldUseSmr);
}
if (mapResolver != null) {
- mapResolver.setSubscriptionService(smr);
+ mapResolver.setSubscriptionService(shouldUseSmr);
}
- ConfigIni.getInstance().setSmr(smr);
+ ConfigIni.getInstance().setSmr(shouldUseSmr);
}
public NotificationService getNotificationService() {
}
@Override
- public void handleSMR(MapRequest smr, Rloc subscriber) {
+ 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(smr.getSourceEid().getEid()),
- LispAddressStringifier.getString(smr.getEidItem().get(0).getEid()));
+ LispAddressStringifier.getString(smrMapRequest.getSourceEid().getEid()),
+ LispAddressStringifier.getString(smrMapRequest.getEidItem().get(0).getEid()));
}
SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder();
- smrib.setMapRequest(new MapRequestBuilder(smr).build());
+ smrib.setMapRequest(new MapRequestBuilder(smrMapRequest).build());
smrib.setTransportAddress(LispNotificationHelper.getTransportAddressFromRloc(subscriber));
getLispSB().sendMapRequest(smrib.build());
this);
}
- public void setDataStoreBackEnd(DataStoreBackEnd dsbe) {
- this.dsbe = dsbe;
+ public void setDataStoreBackEnd(DataStoreBackEnd dataStoreBackEnd) {
+ this.dsbe = dataStoreBackEnd;
}
@Override
executionCount++;
}
- private void cancelAndRemove(Subscriber subscriber, Eid eid) {
+ private void cancelAndRemove(Subscriber sub, Eid eid) {
final Map<Subscriber, ScheduledFuture<?>> subscriberFutureMap = eidFutureMap.get(eid);
if (subscriberFutureMap == null) {
- LOG.warn("Couldn't find subscriber {} in SMR scheduler internal list", subscriber);
+ LOG.warn("Couldn't find subscriber {} in SMR scheduler internal list", sub);
return;
}
- if (subscriberFutureMap.containsKey(subscriber)) {
- ScheduledFuture<?> eidFuture = subscriberFutureMap.get(subscriber);
- subscriberFutureMap.remove(subscriber);
+ if (subscriberFutureMap.containsKey(sub)) {
+ ScheduledFuture<?> eidFuture = subscriberFutureMap.get(sub);
+ subscriberFutureMap.remove(sub);
eidFuture.cancel(false);
}
if (subscriberFutureMap.isEmpty()) {
private static final Eid EID_IPV4_1 = LispAddressUtil.asIpv4Eid(IPV4_STRING_1);
private static final Eid EID_IPV4_2 = LispAddressUtil.asIpv4Eid(IPV4_STRING_2);
private static final Eid EID_SERVICE_PATH = new EidBuilder().setAddress(getDefaultServicePath((short) 253)).build();
+ // with index out of bounds
private static final Eid EID_SERVICE_PATH_INDEX_OOB = new EidBuilder()
- .setAddress(getDefaultServicePath((short) 200)).build(); // with index out of bounds
+ .setAddress(getDefaultServicePath((short) 200)).build();
public static final SimpleAddress SIMPLE_ADDR_1 = new SimpleAddress(new IpAddress(new Ipv4Address(IPV4_STRING_1)));
public static final SimpleAddress SIMPLE_ADDR_2 = new SimpleAddress(new IpAddress(new Ipv4Address(IPV4_STRING_2)));
public void getMappingTest_NbFirst_withServicePathDestinationAddress_multipleLocatorRecords() {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder()
.setLocatorRecord(Lists.newArrayList(
- getDefaultLocatorRecordBuilder().build(), // set two locators
+ // set two locators
+ getDefaultLocatorRecordBuilder().build(),
getDefaultLocatorRecordBuilder().build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData);
public void getMappingTest_NbFirst_withServicePathDestinationAddress_singleIpv4LocatorRecord() {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder()
.setLocatorRecord(Lists.newArrayList(
- getDefaultLocatorRecordBuilder().build())).build(); // Ipv4 type Rloc
+ // Ipv4 type Rloc
+ getDefaultLocatorRecordBuilder().build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData);
setLookupPolicy(IMappingService.LookupPolicy.NB_AND_SB);
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder()
.setLocatorRecord(Lists.newArrayList(
- getDefaultLocatorRecordBuilder().build())).build(); // Ipv4 type Rloc
+ // Ipv4 type Rloc
+ getDefaultLocatorRecordBuilder().build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData);
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder()
.setLocatorRecord(Lists.newArrayList(
- getDefaultLocatorRecordBuilder().build())).build(); // Ipv4 type Rloc
+ // Ipv4 type Rloc
+ getDefaultLocatorRecordBuilder().build())).build();
MappingData nbMappingData = getDefaultMappingData(mappingRecord);
MappingData sbMappingData = getDefaultMappingData(mappingRecord);
sbMappingData.setTimestamp(EXPIRED_DATE);
mapResolver = new MapResolver(mapServiceMock, true, "both", lispMappingServiceMock);
final List<IpAddress> ipAddressList = new ArrayList<>();
- ipAddressList.add(IPV4_ADDRESS_1); // hop 1
- ipAddressList.add(IPV4_ADDRESS_2); // hop 2
+ // hop 1
+ ipAddressList.add(IPV4_ADDRESS_1);
+ // hop 2
+ ipAddressList.add(IPV4_ADDRESS_2);
final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddressList);
final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder();
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build());
final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
- final MapRequestBuilder mapRequestBuilder = getDefaultMapRequestBuilder();
- mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1))
- .build());
- mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2))
- .build());
+ final MapRequestBuilder mrb = getDefaultMapRequestBuilder();
+ mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)).build());
+ mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).build());
- Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1))
- .thenReturn(mappingData);
+ Mockito.when(mapServiceMock.getMapping(mrb.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
// result
final LocatorRecordBuilder locatorRecordBuilder_3 = getDefaultLocatorBuilder()
- .setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).setPriority((short) 1); // priority increased by 1
+ // priority increased by 1
+ .setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).setPriority((short) 1);
final MappingRecordBuilder resultMappingRecordBuilder = getDefaultMappingRecordBuilder();
- resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build()); // as Ipv4
- resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build()); // as ELP
- resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build()); // added to the result
+ // as Ipv4
+ resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
+ // as ELP
+ resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build());
+ // added to the result
+ resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build());
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder()
.setMappingRecord(resultMappingRecordBuilder.build()).build());
// invocation
- mapResolver.handleMapRequest(mapRequestBuilder.build());
+ mapResolver.handleMapRequest(mrb.build());
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
mapResolver = new MapResolver(mapServiceMock, true, "replace", lispMappingServiceMock);
final List<IpAddress> ipAddressList = new ArrayList<>();
- ipAddressList.add(IPV4_ADDRESS_1); // hop 1
- ipAddressList.add(IPV4_ADDRESS_2); // hop 2
+ // hop 1
+ ipAddressList.add(IPV4_ADDRESS_1);
+ // hop 2
+ ipAddressList.add(IPV4_ADDRESS_2);
final Rloc rloc = LispAddressUtil.asTeLcafRloc(ipAddressList);
final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder();
mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_2.build());
final MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
- final MapRequestBuilder mapRequestBuilder = getDefaultMapRequestBuilder();
- mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1))
- .build());
- mapRequestBuilder.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2))
- .build());
+ final MapRequestBuilder mrb = getDefaultMapRequestBuilder();
+ mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_1)).build());
+ mrb.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2)).build());
- Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1))
- .thenReturn(mappingData);
+ Mockito.when(mapServiceMock.getMapping(mrb.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
// result
final LocatorRecordBuilder locatorRecordBuilder_3 = getDefaultLocatorBuilder()
.setRloc(LispAddressUtil.asIpv4Rloc(IPV4_STRING_2));
final MappingRecordBuilder resultMappingRecordBuilder = getDefaultMappingRecordBuilder();
- resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build()); // as Ipv4
- resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build()); // added to the result
+ // as Ipv4
+ resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_1.build());
+ // added to the result
+ resultMappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder_3.build());
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder()
.setMappingRecord(resultMappingRecordBuilder.build()).build());
// invocation
- mapResolver.handleMapRequest(mapRequestBuilder.build());
+ mapResolver.handleMapRequest(mrb.build());
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
private static final long TWO_DAYS = 86400000L * 2;
- private static final Subscriber SUBSCRIBER_RLOC_1 = new Subscriber(RLOC_1, // timedOut() == true
+ // timedOut() == true
+ private static final Subscriber SUBSCRIBER_RLOC_1 = new Subscriber(RLOC_1,
IPV4_SOURCE_EID_1, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT,
new Date(System.currentTimeMillis() - TWO_DAYS));
- private static final Subscriber SUBSCRIBER_RLOC_2 = new Subscriber(RLOC_2, // timedOut() == false
+ // timedOut() == false
+ private static final Subscriber SUBSCRIBER_RLOC_2 = new Subscriber(RLOC_2,
IPV4_SOURCE_EID_2, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT);
- private static final Subscriber SUBSCRIBER_RLOC_3 = new Subscriber(RLOC_3, // timedOut() == true
+ // timedOut() == true
+ private static final Subscriber SUBSCRIBER_RLOC_3 = new Subscriber(RLOC_3,
IPV4_SOURCE_EID_3, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT,
new Date(System.currentTimeMillis() - TWO_DAYS));
- private static final Subscriber SUBSCRIBER_RLOC_4 = new Subscriber(RLOC_4, // timedOut() == false
+ // timedOut() == false
+ private static final Subscriber SUBSCRIBER_RLOC_4 = new Subscriber(RLOC_4,
IPV4_SOURCE_EID_4, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT);
- private static final Subscriber SUBSCRIBER_RLOC_5 = new Subscriber(RLOC_5, // timedOut() == true
+ // timedOut() == true
+ private static final Subscriber SUBSCRIBER_RLOC_5 = new Subscriber(RLOC_5,
IPV4_SOURCE_EID_5, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT,
new Date(System.currentTimeMillis() - TWO_DAYS));
- private static final Subscriber SUBSCRIBER_RLOC_6 = new Subscriber(RLOC_6, // timedOut() == false
+ // timedOut() == false
+ private static final Subscriber SUBSCRIBER_RLOC_6 = new Subscriber(RLOC_6,
IPV4_SOURCE_EID_6, Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT);
private static final Eid SOURCE_DEST_KEY_EID = LispAddressUtil
.setEid(eid);
}
- private static MapNotifyBuilder getDefaultMapNotifyBuilder(MapRegister mapRegister) {
+ private static MapNotifyBuilder getDefaultMapNotifyBuilder(MapRegister mr) {
final MapNotifyBuilder mapNotifyBuilder = new MapNotifyBuilder()
- .setXtrSiteIdPresent(mapRegister.isXtrSiteIdPresent())
- .setSiteId(mapRegister.getSiteId())
- .setXtrId(mapRegister.getXtrId())
- .setNonce(mapRegister.getNonce())
- .setKeyId(mapRegister.getKeyId())
- .setMergeEnabled(mapRegister.isMergeEnabled())
+ .setXtrSiteIdPresent(mr.isXtrSiteIdPresent())
+ .setSiteId(mr.getSiteId())
+ .setXtrId(mr.getXtrId())
+ .setNonce(mr.getNonce())
+ .setKeyId(mr.getKeyId())
+ .setMergeEnabled(mr.isMergeEnabled())
.setMappingRecordItem(new ArrayList<>())
.setAuthenticationData(new byte[]{});
mapNotifyBuilder.getMappingRecordItem().add(getDefaultMappingRecordItemBuilder().build());
// input
final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.PROTOCOL, "data-exists",
"Key already exists! Please use update-key if you want to change it.").build();
- final RpcError error = rpc.getErrors().iterator().next(); // equals() not implemented int RpcError
+ // equals() not implemented int RpcError
+ final RpcError error = rpc.getErrors().iterator().next();
// result
final Future<RpcResult<Void>> result = mappingService.addKey(addKeyInput);
assertEquals(2, result.getRecord().getLocatorRecord().size());
assertEquals("NB-locator-id", resultLocator_1.getLocatorId());
- assertEquals(255, (short) resultLocator_1.getPriority()); // priority changed to 255
+ // priority changed to 255
+ assertEquals(255, (short) resultLocator_1.getPriority());
assertEquals("NB-locator-id", resultLocator_2.getLocatorId());
- assertEquals(1, (short) resultLocator_2.getPriority()); // priority remains original
+ // priority remains original
+ assertEquals(1, (short) resultLocator_2.getPriority());
}
private static MappingData getDefaultMappingData() {
@Override
public SimpleImmutableEntry<Eid, Map<String, ?>> getBestPair(Object key) {
- Map<String, ?> data = null;
+ Map<String, ?> result = null;
if (key instanceof Eid) {
Eid eid = (Eid) key;
RadixTrie<Object>.TrieNode node = lookupBestNode(eid);
if (node == null) {
- data = get(key);
- return (data == null) ? null : new SimpleImmutableEntry<>((Eid)key, data);
+ result = get(key);
+ return (result == null) ? null : new SimpleImmutableEntry<>((Eid)key, result);
}
- data = get(node.data());
- return (data == null) ? null : new SimpleImmutableEntry<>((Eid)node.data(), data);
+ result = get(node.data());
+ return (result == null) ? null : new SimpleImmutableEntry<>((Eid)node.data(), result);
}
return null;
}
this.bit = prefixlen;
this.prefix = prefix;
this.data = data;
- left = right = null;
+ left = null;
+ right = null;
}
public byte[] prefix() {
/**
* Finds closest prefix NOT the longest prefix match.
*
- * @param prefix Searched prefix
+ * @param pref Searched prefix
* @param preflen Searched prefix length
* @return The node found
*/
- public TrieNode findClosest(byte[] prefix, int preflen) {
+ public TrieNode findClosest(byte[] pref, int preflen) {
TrieNode node = this;
while (node.prefix == null || node.bit < preflen) {
- if (testBitInPrefixByte(prefix, node.bit)) {
+ if (testBitInPrefixByte(pref, node.bit)) {
if (node.right == null) {
break;
}
/**
* Compares prefix to node's prefix and returns position of first different bit.
*
- * @param prefix Prefix to be compared.
+ * @param pref Prefix to be compared.
* @param preflen Prefix length.
* @return Position of first different bit.
*/
- public int firstDifferentBit(byte[] prefix, int preflen) {
+ public int firstDifferentBit(byte[] pref, int preflen) {
int bitxor;
int maxbit = (bit < preflen) ? bit : preflen;
int diffbit = 0;
for (int i = 0; i * 8 < maxbit; i++) {
+ bitxor = ((toUnsignedInt(this.prefix[i])) ^ toUnsignedInt(pref[i]));
// if match, move to next byte
- if ((bitxor = ((toUnsignedInt(this.prefix[i])) ^ toUnsignedInt(prefix[i]))) == 0) {
+ if (bitxor == 0) {
diffbit = (i + 1) * 8;
continue;
}
* @param pref Prefix to be inserted.
* @param preflen Prefix length of the prefix to be inserted.
* @param diffbit Bit index of the first different bit between prefix and current node
- * @param data Data to be stored together with the prefix
+ * @param prefdata Data to be stored together with the prefix
* @return The trie node created or current node if it's an overwrite.
*/
- public TrieNode insert(byte[] pref, int preflen, int diffbit, T data, byte[] closest) {
+ public TrieNode insert(byte[] pref, int preflen, int diffbit, T prefdata, byte[] closest) {
TrieNode parent;
// same node, check if prefix needs saving
return this;
}
this.prefix = pref;
- this.data = data;
+ this.data = prefdata;
nbActiveNodes++;
return this;
}
- TrieNode newNode = new TrieNode(pref, preflen, data);
+ TrieNode newNode = new TrieNode(pref, preflen, prefdata);
// node is more specific, add new prefix as parent
if (preflen == diffbit) {
return false;
}
}
- if ((remainder = bit % 8) != 0) {
+
+ remainder = bit % 8;
+ if (remainder != 0) {
int mask = (0xFF << (8 - remainder)) & 0xFF;
return ((prefix[iterator] & mask) == (pref[iterator] & mask));
}
@Test
public void testClearIntermediariesToRoot() {
- RadixTrie<String> radixTrie4 = new RadixTrie<>(32);
+ RadixTrie<String> stringRadixTrie4 = new RadixTrie<>(32);
// Add prefixes
- radixTrie4.insert(IP4_BYTES22, 32, "1.1.1.1");
- radixTrie4.insert(IP4_BYTES23, 32, "2.2.2.2");
- radixTrie4.insert(IP4_BYTES24, 32, "10.10.10.10");
- radixTrie4.insert(IP4_BYTES25, 32, "20.20.20.20");
+ stringRadixTrie4.insert(IP4_BYTES22, 32, "1.1.1.1");
+ stringRadixTrie4.insert(IP4_BYTES23, 32, "2.2.2.2");
+ stringRadixTrie4.insert(IP4_BYTES24, 32, "10.10.10.10");
+ stringRadixTrie4.insert(IP4_BYTES25, 32, "20.20.20.20");
// Remove 10.10.10.10 & 20.20.20.20 (root should be updated)
- radixTrie4.remove(IP4_BYTES24, 32);
- radixTrie4.remove(IP4_BYTES25, 32);
+ stringRadixTrie4.remove(IP4_BYTES24, 32);
+ stringRadixTrie4.remove(IP4_BYTES25, 32);
// Re-add 10.10.10.10 & 20.20.20.20
- radixTrie4.insert(IP4_BYTES24, 32, "10.10.10.10");
- radixTrie4.insert(IP4_BYTES25, 32, "20.20.20.20");
+ stringRadixTrie4.insert(IP4_BYTES24, 32, "10.10.10.10");
+ stringRadixTrie4.insert(IP4_BYTES25, 32, "20.20.20.20");
// Make sure 10.10.10.10 & 20.20.20.20 lookup succeeds
- RadixTrie<String>.TrieNode res2 = radixTrie4.lookupBest(IP4_BYTES24, 32);
+ RadixTrie<String>.TrieNode res2 = stringRadixTrie4.lookupBest(IP4_BYTES24, 32);
assertTrue("Lookup 10.10.10.10 result is NULL", res2 != null);
assertTrue("Lookup Result for 10.10.10.10 is not right", res2.data().equals("10.10.10.10"));
- RadixTrie<String>.TrieNode res3 = radixTrie4.lookupBest(IP4_BYTES25, 32);
+ RadixTrie<String>.TrieNode res3 = stringRadixTrie4.lookupBest(IP4_BYTES25, 32);
assertTrue("Lookup 20.20.20.20 result is NULL", res3 != null);
assertTrue("Lookup Result for 20.20.20.20 is not right", res3.data().equals("20.20.20.20"));
// Remove 10.10.10.10 & 20.20.20.20 (root should be updated)
- radixTrie4.remove(IP4_BYTES24, 32);
- radixTrie4.remove(IP4_BYTES25, 32);
+ stringRadixTrie4.remove(IP4_BYTES24, 32);
+ stringRadixTrie4.remove(IP4_BYTES25, 32);
// Add 10.10.10.0 & 20.20.20.0
- radixTrie4.insert(IP4_BYTES25, 24, "20.20.20.0");
- radixTrie4.insert(IP4_BYTES24, 24, "10.10.10.0");
+ stringRadixTrie4.insert(IP4_BYTES25, 24, "20.20.20.0");
+ stringRadixTrie4.insert(IP4_BYTES24, 24, "10.10.10.0");
- RadixTrie<String>.TrieNode res4 = radixTrie4.lookupBest(IP4_BYTES23, 32);
+ RadixTrie<String>.TrieNode res4 = stringRadixTrie4.lookupBest(IP4_BYTES23, 32);
assertTrue("Lookup 2.2.2.2 result is NULL", res4 != null);
assertTrue("Lookup Result for 2.2.2.2 is not right", res4.data().equals("2.2.2.2"));
- RadixTrie<String>.TrieNode res5 = radixTrie4.lookupBest(IP4_BYTES22, 32);
+ RadixTrie<String>.TrieNode res5 = stringRadixTrie4.lookupBest(IP4_BYTES22, 32);
assertTrue("Lookup 1.1.1.1 result is NULL", res5 != null);
assertTrue("Lookup Result for 1.1.1.1 is not right", res5.data().equals("1.1.1.1"));
- RadixTrie<String>.TrieNode res6 = radixTrie4.lookupBest(IP4_BYTES25, 24);
+ RadixTrie<String>.TrieNode res6 = stringRadixTrie4.lookupBest(IP4_BYTES25, 24);
assertTrue("Lookup 20.20.20.20 result is NULL", res6 != null);
assertTrue("Lookup Result for 20.20.20.0 is not right", res6.data().equals("20.20.20.0"));
- RadixTrie<String>.TrieNode res7 = radixTrie4.lookupBest(IP4_BYTES24, 24);
+ RadixTrie<String>.TrieNode res7 = stringRadixTrie4.lookupBest(IP4_BYTES24, 24);
assertTrue("Lookup 10.10.10.10 result is NULL", res7 != null);
assertTrue("Lookup Result for 10.10.10.0 is not right", res7.data().equals("10.10.10.0"));
}
@Test
public void testLookupExact() {
- RadixTrie<String> radixTrie4 = new RadixTrie<>(32);
+ RadixTrie<String> stringRadixTrie4 = new RadixTrie<>(32);
- radixTrie4.insert(IP4_BYTES1, 16, "192.168.0.0");
+ stringRadixTrie4.insert(IP4_BYTES1, 16, "192.168.0.0");
- RadixTrie<String>.TrieNode res1 = radixTrie4.lookupExact(IP4_BYTES4, 24);
+ RadixTrie<String>.TrieNode res1 = stringRadixTrie4.lookupExact(IP4_BYTES4, 24);
assertTrue("Lookup for 192.168.1.0 is not NULL", res1 == null);
- RadixTrie<String>.TrieNode res2 = radixTrie4.lookupExact(IP4_BYTES1, 16);
+ RadixTrie<String>.TrieNode res2 = stringRadixTrie4.lookupExact(IP4_BYTES1, 16);
assertTrue("Lookup for 192.168.0.0 is NULL", res2 != null);
}
return table;
}
- private ILispDAO getOrInstantiateXtrIdTable(Eid eid, ILispDAO dao) {
- ILispDAO table = (ILispDAO) dao.getSpecific(eid, SubKeys.XTRID_RECORDS);
+ private ILispDAO getOrInstantiateXtrIdTable(Eid eid, ILispDAO lispDAO) {
+ ILispDAO table = (ILispDAO) lispDAO.getSpecific(eid, SubKeys.XTRID_RECORDS);
if (table == null) {
- table = dao.putNestedTable(eid, SubKeys.XTRID_RECORDS);
+ table = lispDAO.putNestedTable(eid, SubKeys.XTRID_RECORDS);
}
return table;
}
// Returns the mapping corresponding to the longest prefix match for eid. eid must be a simple (maskable or not)
// address
- private Object getMappingLpmEid(Eid eid, XtrId xtrId, ILispDAO dao) {
- SimpleImmutableEntry<Eid, Map<String, ?>> daoEntry = dao.getBestPair(MaskUtil.normalize(eid));
+ private Object getMappingLpmEid(Eid eid, XtrId xtrId, ILispDAO lispDAO) {
+ SimpleImmutableEntry<Eid, Map<String, ?>> daoEntry = lispDAO.getBestPair(MaskUtil.normalize(eid));
if (daoEntry != null) {
if (xtrId != null) {
ILispDAO xtrIdTable = (ILispDAO) daoEntry.getValue().get(SubKeys.XTRID_RECORDS);
}
// Returns the list of mappings stored in an xTR-ID DAO
- private List<Object> getXtrIdMappingList(ILispDAO dao) {
- if (dao != null) {
+ private List<Object> getXtrIdMappingList(ILispDAO lispDAO) {
+ if (lispDAO != null) {
final List<Object> records = new ArrayList<>();
- dao.getAll(new IRowVisitor() {
+ lispDAO.getAll(new IRowVisitor() {
public void visitRow(Object keyId, String valueKey, Object value) {
if (valueKey.equals(SubKeys.RECORD)) {
records.add(value);
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
-public class LispMapCacheStringifier {
+public final class LispMapCacheStringifier {
+ // Utility class, should not be instantiated
+ private LispMapCacheStringifier() {
+ }
+
public static String printKeys(ILispDAO dao) {
final StringBuilder sb = new StringBuilder();
sb.append("Keys\tValues\n");
Mockito.when(daoMock.getSpecific(VNI_0, SubKeys.VNI)).thenReturn(tableMock);
Mockito.when(tableMock.getBestPair(NORMALIZED_EID_IPV4_PREFIX_DST)).thenReturn(mapPair);
Mockito.when(mapMock.get(SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock);
- Mockito.when(xtrIdDaoMock.getSpecific(XTR_ID, SubKeys.RECORD))
- .thenReturn(mappingData); // second invocation
+ // second invocation
+ Mockito.when(xtrIdDaoMock.getSpecific(XTR_ID, SubKeys.RECORD)).thenReturn(mappingData);
// with non-expired mapping record
assertEquals(mappingData, simpleMapCache.getMapping(EID_IPV4_PREFIX_DST, XTR_ID));
Mockito.when(daoMock.getSpecific(VNI_0, SubKeys.VNI)).thenReturn(tableMock);
Mockito.when(tableMock.getSpecific(NORMALIZED_EID_2, SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock);
- simpleMapCache.addMapping(EID_IPV4_PREFIX_2, mappingDataMock); // Eid VNI_100 == null
+ // Eid VNI_100 == null
+ simpleMapCache.addMapping(EID_IPV4_PREFIX_2, mappingDataMock);
Mockito.verify(daoMock).getSpecific(VNI_0, SubKeys.VNI);
Mockito.verify(daoMock, Mockito.never()).putNestedTable(VNI_0, SubKeys.VNI);
}
Mockito.when(tableMock.getSpecific(NORMALIZED_EID_2, SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock);
Mockito.when(daoMock.putNestedTable(VNI_0, SubKeys.VNI)).thenReturn(tableMock);
- simpleMapCache.addMapping(EID_IPV4_PREFIX_2, mappingDataMock); // Eid VNI_100 == null
+ // Eid VNI_100 == null
+ simpleMapCache.addMapping(EID_IPV4_PREFIX_2, mappingDataMock);
Mockito.verify(daoMock).putNestedTable(VNI_0, SubKeys.VNI);
}
Mockito.when(tableMock.getSpecific(NORMALIZED_EID_1, SubKeys.XTRID_RECORDS)).thenReturn(xtrIdDaoMock);
Mockito.when(daoMock.putNestedTable(VNI_100, SubKeys.VNI)).thenReturn(tableMock);
- simpleMapCache.addMapping(EID_IPV4_PREFIX_1_VNI, mappingDataMock); // Eid VNI_100 == null
+ // Eid VNI_100 == null
+ simpleMapCache.addMapping(EID_IPV4_PREFIX_1_VNI, mappingDataMock);
Mockito.verify(daoMock).putNestedTable(VNI_100, SubKeys.VNI);
}
/**
* Created by Shakib Ahmed on 1/24/17.
*/
-public class IntentHandlerAsyncExecutorProvider {
+public final class IntentHandlerAsyncExecutorProvider {
private static ListeningExecutorService listeningExecutorService;
private static final int EXTRA_THREADS_TO_HANDLE_VPP_LISTENER = 1;
public void close() {
listeningExecutorService.shutdown();
}
-}
\ No newline at end of file
+}
* Created by Shakib Ahmed on 1/12/17.
*/
public class RlocNotFoundOnVppNode extends RuntimeException {
+ private static final String MESSAGE = "No available interface found on node ";
+
public RlocNotFoundOnVppNode(String hostId) {
- super("No available interface found on node " + hostId);
+ super(MESSAGE + hostId);
+ }
+
+ public RlocNotFoundOnVppNode(String hostId, Throwable cause) {
+ super(MESSAGE + hostId, cause);
}
}
/**
* Created by Shakib Ahmed on 1/23/17.
*/
-public class InfoUtil {
-
+public final class InfoUtil {
private InfoUtil() {
-
}
public static String topology(final KeyedInstanceIdentifier<Topology, TopologyKey> topoIID) {
/**
* Created by Shakib Ahmed on 1/12/17.
*/
-public class LispNeutronUtil {
+public final class LispNeutronUtil {
protected static final Logger LOG = LoggerFactory.getLogger(LispNeutronUtil.class);
- private LispNeutronUtil(){}
+ private LispNeutronUtil() {
+ }
public static DataBroker resolveDataBrokerForMountPoint(InstanceIdentifier<Node> iiToMountPoint,
MountPointService mountService) {
/**
* Created by Shakib Ahmed on 1/12/17.
*/
-public class VppNetconfTrasaction {
+public final class VppNetconfTrasaction {
private static final Logger LOG = LoggerFactory.getLogger(VppNetconfTrasaction.class);
public static final byte RETRY_COUNT = 5;
+ private VppNetconfTrasaction() {
+ }
+
public static synchronized <T extends DataObject> Optional<T> read(DataBroker dataBroker,
LogicalDatastoreType datastoreType,
InstanceIdentifier<T> instanceIdentifier) {
} catch (final InterruptedException | ExecutionException ex) {
LOG.warn("Got exception while reading IP addresses from nodes {}",
InfoUtil.node(instanceIdentifierToVppNode));
- throw new RlocNotFoundOnVppNode(InfoUtil.node(instanceIdentifierToVppNode));
+ throw new RlocNotFoundOnVppNode(InfoUtil.node(instanceIdentifierToVppNode), ex);
}
}
private static HostInformationManager instance;
- private HostInformationManager() {
+ HostInformationManager() {
hostIdToPortDataMapper = new HostIdToPortDataMapper();
hostIdToRlocMapper = new HostIdToRlocMapper();
neutronTenantToVniMapper = new NeutronTenantToVniMapper();
return neutronTenantToVniMapper.getVni(tenantUuid);
}
- public void setOdlMappingserviceService(OdlMappingserviceService lfmDbService) {
- this.lfmDbService = lfmDbService;
+ public void setOdlMappingserviceService(OdlMappingserviceService mappingservice) {
+ this.lfmDbService = mappingservice;
}
public synchronized void addHostRelatedInfo(String hostId, Object data) {
lfmDbService.removeMapping(removeMappingInput);
uuidToEidMapper.deleteProcessedPortData(portUuid);
}
-}
\ No newline at end of file
+}
future = Mockito.mock(Future.class);
rpcResult = Mockito.mock(RpcResult.class);
Whitebox.setInternalState(portDataProcessor, "hostInformationManager", hostInformationManager);
- commonStubbing(); // common stubbing is called before invocation of each test
+ // common stubbing is called before invocation of each test
+ commonStubbing();
}
/**
*/
@Test
public void createTest_nullHostId() throws ExecutionException, InterruptedException {
- Mockito.when(augmentationMock.getHostId()).thenReturn(null); // overriding default stubbing
+ // overriding default stubbing
+ Mockito.when(augmentationMock.getHostId()).thenReturn(null);
portDataProcessor.create(portMock);
this.dsbe = new DataStoreBackEnd(dataBroker);
restoreDaoFromDatastore();
- LispSouthboundHandler lispSouthboundHandler = new LispSouthboundHandler(this);
- this.lispSouthboundHandler = lispSouthboundHandler;
+ LispSouthboundHandler lsbh = new LispSouthboundHandler(this);
+ this.lispSouthboundHandler = lsbh;
- LispXtrSouthboundHandler lispXtrSouthboundHandler = new LispXtrSouthboundHandler(this);
- this.lispXtrSouthboundHandler = lispXtrSouthboundHandler;
+ LispXtrSouthboundHandler lxsbh = new LispXtrSouthboundHandler(this);
+ this.lispXtrSouthboundHandler = lxsbh;
if (Epoll.isAvailable()) {
eventLoopGroup = new EpollEventLoopGroup(numChannels, threadFactory);
bootstrap.group(eventLoopGroup);
bootstrap.channel(channelType);
- bootstrap.handler(lispSouthboundHandler);
+ bootstrap.handler(lsbh);
xtrBootstrap.group(eventLoopGroup);
xtrBootstrap.channel(channelType);
- xtrBootstrap.handler(lispXtrSouthboundHandler);
+ xtrBootstrap.handler(lxsbh);
start();
startXtr();
Mockito.verify(handlerMock).close();
assertNull(getField("lispSouthboundHandler"));
assertNull(getField("lispXtrSouthboundHandler"));
- Channel[] channel = getField("channel");
- assertNull(channel[0]);
+ Channel[] channels = getField("channel");
+ assertNull(channels[0]);
}
private static void injectChannel() throws NoSuchFieldException, IllegalAccessException {
// Nonce: 0x3d8d2acd39c8d608
// ITR-RLOC AFI=1 Address=192.168.136.10
// Record 1: 1.2.3.4/32
- mapRequestPacket = extractWSUdpByteArray(new String(
+ 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"));
+ + "0060 00 01 01 02 03 04");
mapReplyBuilder = new MapReplyBuilder();
mapReplyBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapReplyBuilder.setNonce((long) 0);
// 255/0
//
- mapRegisterPacket = extractWSUdpByteArray(new String(
+ 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"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
mapNotifyBuilder = new MapNotifyBuilder();
mapNotifyBuilder.setAuthenticationData(new byte[0]);
}
@Test(expected = LispMalformedPacketException.class)
public void mapRegister__IllegalPacket() throws Exception {
- mapRegisterPacket = extractWSUdpByteArray(new String(
+ mapRegisterPacket = extractWSUdpByteArray(
"0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
+ "0010 00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 "
- + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 "));
+ + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 ");
handleMapRegisterPacket(mapRegisterPacket);
}
@Test(expected = LispMalformedPacketException.class)
public void mapRequest__IllegalPacket() throws Exception {
- mapRequestPacket = extractWSUdpByteArray(new String(
+ 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 "));
+ + "0040 03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d ");
handleMapRequestPacket(mapRequestPacket);
}
@Test(expected = LispMalformedPacketException.class)
public void mapRequest__IllegalEncapsulatedPacket() throws Exception {
- mapRequestPacket = extractWSUdpByteArray(new String(
+ 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 "));
+ + "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 ");
handleMapRequestPacket(mapRequestPacket);
}
// Priority/Weight: 255/0
// Local RLOC: 192.168.136.51, Reachable, Priority/Weight: 6/100,
// Multicast Priority/Weight: 255/0
- mapRegisterPacket = extractWSUdpByteArray(new String(
+ mapRegisterPacket = extractWSUdpByteArray(
"0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
+ "0010 00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 "
+ "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 "
+ "0040 e9 35 75 6e f1 29 27 a3 45 20 96 06 c2 e1 00 00 "
+ "0050 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 01 64 "
+ "0060 ff 00 00 05 00 01 0a 01 00 6e 06 64 ff 00 00 05 "
- + "0070 00 01 c0 a8 88 33"));
+ + "0070 00 01 c0 a8 88 33");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(mapRegisterPacket);
// Local RLOC: 10.0.58.156, Reachable, Priority/Weight: 1/100, Multicast
// Priority/Weight: 255/0
- mapRegisterPacket = extractWSUdpByteArray(new String(
+ mapRegisterPacket = extractWSUdpByteArray(
"0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 "
+ "0010 00 68 00 00 40 00 40 11 ea c3 0a 00 3a 9c 0a 00 "
+ "0020 01 26 10 f6 10 f6 00 54 f5 9a 38 00 03 01 00 00 "
+ "0040 0f 91 c6 c4 01 ef 7f bb 77 58 39 5c 92 23 00 00 "
+ "0050 00 0a 01 80 10 00 00 00 00 02 26 10 00 d0 ff ff "
+ "0060 01 92 00 00 00 00 00 00 00 01 01 64 ff 00 00 05 "
- + "0070 00 01 0a 00 3a 9c"));
+ + "0070 00 01 0a 00 3a 9c");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(mapRegisterPacket);
@Test
public void mapRegister__NonSetMBit() throws Exception {
- byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String(
+ byte[] registerWithNonSetMBit = 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 00 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 79 d1 44 66 19 99 "
+ "0040 83 63 a7 79 6e f0 40 97 54 26 3a 44 b4 eb 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"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(registerWithNonSetMBit);
@Test
public void mapRegister__NonSetMBitWithNonZeroReservedBits() throws Exception {
- byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String(
+ byte[] registerWithNonSetMBit = 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 02 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 c0 c7 c5 2f 57 f6 "
+ "0040 e7 20 25 3d e8 b2 07 e2 63 de 62 2b 7a 20 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"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(registerWithNonSetMBit);
@Test
public void mapRegister__SetMBitWithNonZeroReservedBits() throws Exception {
- byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String(
+ byte[] registerWithNonSetMBit = 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 03 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 a2 72 40 7b 1a ae "
+ "0040 4e 6b e2 e5 e1 01 40 8a c9 e1 d1 80 cb 72 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"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(registerWithNonSetMBit);
public void mapRegister_isMappingKeepAliveAndMapNotifyGenerated() throws InterruptedException,
UnknownHostException {
byte[] eidPrefixAfi = new byte[] {
- 0x00, 0x01 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x00, 0x01
};
byte[] eidPrefix = new byte[] {
- 0x0a, 0x0a, 0x0a, 0x0a //ipv4 address
+ //ipv4 address
+ 0x0a, 0x0a, 0x0a, 0x0a
};
//send stream of byte -> map register message
@Test
public void mapRegister_cacheWithEidPrefixIpv4Test() throws InterruptedException {
byte[] eidPrefixAfi = new byte[] {
- 0x00, 0x01 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x00, 0x01
};
byte[] eidPrefix = new byte[] {
- 0x0a, 0x0a, 0x0a, 0x0a //ipv4 address
+ //ipv4 address
+ 0x0a, 0x0a, 0x0a, 0x0a
};
cacheTest(eidPrefixAfi, eidPrefix, MapRegisterCacheTestUtil.AUTH_DATA);
@Test
public void mapRegister_cacheWithEidPrefixIpv6Test() throws InterruptedException {
byte[] eidPrefixAfi = new byte[] {
- 0x00, 0x02 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x00, 0x02
};
byte[] eidPrefix = new byte[] {
- 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address
- 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address
- 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address
- 0x0f, 0x0f, 0x0f, 0x0f //ipv6 address
+ //ipv6 address
+ 0x0f, 0x0f, 0x0f, 0x0f,
+ //ipv6 address
+ 0x0f, 0x0f, 0x0f, 0x0f,
+ //ipv6 address
+ 0x0f, 0x0f, 0x0f, 0x0f,
+ //ipv6 address
+ 0x0f, 0x0f, 0x0f, 0x0f
};
- byte[] authenticationData = new byte[]{
+ byte[] authenticationData = new byte[] {
0x00, 0x14,
0x41,(byte)0x83,0x13,0x7C,
0x48,(byte)0xEE,0x75,(byte)0x9A,
@Test
public void mapRegister_cacheWithEidPrefixMac48Test() throws InterruptedException {
byte[] eidPrefixAfi = new byte[] {
- 0x40, 0x05 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x40, 0x05
};
byte[] eidPrefix = new byte[] {
- 0x0a, 0x0b, 0x0c, 0x0d, //mac address
- 0x0e, 0x0f //mac address
+ //mac address
+ 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
};
- byte[] authenticationData = new byte[]{
+
+ byte[] authenticationData = new byte[] {
0x00, 0x14,
(byte)0xB2,(byte)0x8E,0x6,(byte)0x9D,
0x61,(byte)0xD8,0xC,0x24,
@Test
public void mapRegister_cacheWithEidPrefixLcafTest() throws InterruptedException {
byte[] eidPrefixAfi = new byte[] {
- 0x40, 0x03 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x40, 0x03
};
//following lcaf prefixed variables are defined according to https://tools.ietf
byte[] eidPrefix = joinArrays(lcafRsvd1, lcafFlags, lcafType, lcafIIDMaskLength, lcafLength, lcafInstanceId,
lcafAfi, lcafAddress);
- byte[] authenticationData = new byte[]{
- 0x00, 0x14, //authentication data length
- 0x68, 0x1d, (byte) 0x9e, 0x6e, //auth data
- 0x5e, 0x32, (byte) 0x88, 0x1a, //auth data
- (byte) 0xae, 0x6b, (byte) 0xe3, 0x40, //auth data
- 0x30, (byte) 0x0b, (byte) 0xb6, (byte) 0xa0, //auth data
- 0x71, (byte) 0xf4, (byte) 0x8c, 0x5f //auth data
+ byte[] authenticationData = new byte[] {
+ //authentication data length
+ 0x00, 0x14,
+ //auth data
+ 0x68, 0x1d, (byte) 0x9e, 0x6e,
+ //auth data
+ 0x5e, 0x32, (byte) 0x88, 0x1a,
+ //auth data
+ (byte) 0xae, 0x6b, (byte) 0xe3, 0x40,
+ //auth data
+ 0x30, (byte) 0x0b, (byte) 0xb6, (byte) 0xa0,
+ //auth data
+ 0x71, (byte) 0xf4, (byte) 0x8c, 0x5f
};
// Map-Reply Record: EID prefix: 2610:d0:ffff:192::1/128, TTL: 10,
// Authoritative, No-Action
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 "
+ "0010 00 b0 00 00 40 00 40 11 ea 7b 0a 00 3a 9c 0a 00 "
+ "0020 01 26 10 f6 10 f6 00 9c 9b 19 80 00 00 00 60 00 "
+ "0080 3a 9c 00 80 00 02 26 10 00 d0 ff ff 01 92 00 00 "
+ "0090 00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 "
+ "00a0 00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 "
- + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"));
+ + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c");
ArgumentCaptor<RequestMapping> captor = ArgumentCaptor.forClass(RequestMapping.class);
handleMapRequestAsByteArray(mapRequestPacket);
// (2610:d0:ffff:192::2)
// encapsulated UDP source port: 4342
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 "
+ "0010 00 b0 00 00 40 00 40 11 ea 7b 0a 00 3a 9c 0a 00 "
+ "0020 01 26 10 f6 10 f6 00 9c 9b 19 80 00 00 00 60 00 "
+ "0080 3a 9c 00 80 00 02 26 10 00 d0 ff ff 01 92 00 00 "
+ "0090 00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 "
+ "00a0 00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 "
- + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"));
+ + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c");
ArgumentCaptor<RequestMapping> captor = ArgumentCaptor.forClass(RequestMapping.class);
DatagramPacket replyPacket = handleMapRequestPacket(mapRequestPacket);
// encapsulated LISP packet
// Source EID = 153.16.254.1
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 0c 29 7a ce 83 00 15 17 c6 4a c9 08 00 45 00 "
+ "0010 00 78 00 00 40 00 3e 11 ec b1 0a 00 01 26 0a 00 "
+ "0020 3a 9e 10 f6 10 f6 00 64 c3 a5 80 00 00 00 45 00 "
+ "0050 ff 53 27 36 38 3a 00 01 99 10 fe 01 00 01 0a 00 "
+ "0060 01 26 00 20 00 01 0a 00 14 c8 00 00 00 0a 01 20 "
+ "0070 10 00 00 00 00 01 99 10 fe 01 01 64 ff 00 00 05 "
- + "0080 00 01 0a 00 01 26"));
+ + "0080 00 01 0a 00 01 26");
ArgumentCaptor<RequestMapping> captor = ArgumentCaptor.forClass(RequestMapping.class);
handleMapRequestAsByteArray(mapRequestPacket);
// UDP: 49289 -> 4342
// LISP(Type = 14 UNKNOWN!!!, P=1, M=1
- byte[] unknownTypePacket = extractWSUdpByteArray(new String(
+ byte[] unknownTypePacket = 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 F8 00 01 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 e8 f5 0b c5 c5 f2 "
+ "0040 b0 21 27 a8 21 41 04 f3 46 5a a5 68 89 ec 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"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
assertNull(handlePacket(unknownTypePacket));
}
// ITR-RLOC 1: 10.1.0.111
// ITR-RLOC 2: 192.168.136.51
//
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
+ "0010 00 8a 00 00 40 00 40 11 25 f2 0a 01 00 6f 0a 01 "
+ "0020 00 01 10 f6 10 f6 00 76 06 1f 80 00 00 00 45 00 "
+ "0060 00 6f 00 01 c0 a8 88 33 00 20 00 01 08 08 08 08 "
+ "0070 00 00 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 "
+ "0080 01 64 ff 00 00 05 00 01 0a 01 00 6f 06 64 ff 00 "
- + "0090 00 05 00 01 c0 a8 88 33"));
+ + "0090 00 05 00 01 c0 a8 88 33");
handleMapRequestAsByteArray(mapRequestPacket);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(Mockito.any(RequestMapping.class));
@Test(expected = LispMalformedPacketException.class)
public void mapRequest__NoIpItrRloc() throws Exception {
- mapRequestPacket = hexToByteBuffer("10 00 " //
- + "02 " // This means 3 ITR - RLOCs
- + "01 3d 8d 2a cd 39 c8 d6 08 00 00 " //
- + "40 05 c0 a8 88 0a 01 02 " // MAC (ITR-RLOC #1 of 3)
- + "40 05 00 00 00 00 00 00 " // MAC (ITR-RLOC #2 of 3)
- + "40 05 11 22 34 56 78 90 " // MAC (ITR-RLOC #3 of 3)
+ mapRequestPacket = hexToByteBuffer("10 00 "
+ // This means 3 ITR - RLOCs
+ + "02 "
+ + "01 3d 8d 2a cd 39 c8 d6 08 00 00 "
+ // MAC (ITR-RLOC #1 of 3)
+ + "40 05 c0 a8 88 0a 01 02 "
+ // MAC (ITR-RLOC #2 of 3)
+ + "40 05 00 00 00 00 00 00 "
+ // MAC (ITR-RLOC #3 of 3)
+ + "40 05 11 22 34 56 78 90 "
+ "00 20 00 01 01 02 03 04").array();
handleMapRequestPacket(mapRequestPacket);
}
final class MapRegisterCacheTestUtil {
static final byte[] DATA1 = new byte[] {
- 0x33, 0x00, 0x01, 0x01 //Type, P, I, R, Reserved, M, Record Count
+ //Type, P, I, R, Reserved, M, Record Count
+ 0x33, 0x00, 0x01, 0x01
};
static final byte[] NONCE = new byte[] {
- 0x00, 0x00, 0x00, 0x00, //nonce
- 0x00, 0x00, 0x00, 0x00 //nonce
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
static final byte[] KEY_ID = new byte[] {
- 0x00, 0x01 //key ID
+ 0x00, 0x01
};
- static final byte[] AUTH_DATA = new byte[]{
- 0x00, 0x14, //authentication data length
- (byte)0xfa, 0x50, 0x1d, (byte)0xd6, //auth data
- 0x63, 0x53, 0x67, 0x6c, //auth data
- 0x00, 0x3c, 0x61, 0x67, //auth data
- 0x35, (byte) 0xb8, (byte) 0xcf, 0x16, //auth data
- (byte) 0x91, (byte) 0xcd, 0x6b, (byte) 0x95 //auth data
+ static final byte[] AUTH_DATA = new byte[] {
+ //authentication data length
+ 0x00, 0x14,
+ //auth data
+ (byte)0xfa, 0x50, 0x1d, (byte)0xd6,
+ //auth data
+ 0x63, 0x53, 0x67, 0x6c,
+ //auth data
+ 0x00, 0x3c, 0x61, 0x67,
+ //auth data
+ 0x35, (byte) 0xb8, (byte) 0xcf, 0x16,
+ //auth data
+ (byte) 0x91, (byte) 0xcd, 0x6b, (byte) 0x95
};
- static final byte[] DATA2 = new byte[]{
- 0x00, 0x00, 0x00, 0x6f, //TTL
+ static final byte[] DATA2 = new byte[] {
+ //TTL
+ 0x00, 0x00, 0x00, 0x6f,
+ //Rsvd, Map-Version Number
0x01, 0x08, 0x00, 0x00,
- 0x00, 0x01 //Rsvd, Map-Version Number
+ 0x00, 0x01
};
static final byte[] DATA3 = new byte[] {
- 0x01, 0x0c, 0x0d, 0x0b, //Priority, Weight, M Priority, M Weight
- 0x00, 0x00, 0x00, 0x01, //Unused Flags, L, p, R, Loc-Afi
- 0x0c, 0x0c, 0x0c, 0x0c //Locator
+ //Priority, Weight, M Priority, M Weight
+ 0x01, 0x0c, 0x0d, 0x0b,
+ //Unused Flags, L, p, R, Loc-Afi
+ 0x00, 0x00, 0x00, 0x01,
+ //Locator
+ 0x0c, 0x0c, 0x0c, 0x0c
};
- static final byte[] XTR_ID = new byte[]{
- 0x53, 0x61, 0x6e, 0x20, //xTR id
- 0x4a, 0x6f, 0x73, 0x65, //xTR id
- 0x2c, 0x20, 0x32, 0x66, //xTR id
- 0x33, 0x72, 0x32, 0x64 //xTR id
+ static final byte[] XTR_ID = new byte[] {
+ 0x53, 0x61, 0x6e, 0x20,
+ 0x4a, 0x6f, 0x73, 0x65,
+ 0x2c, 0x20, 0x32, 0x66,
+ 0x33, 0x72, 0x32, 0x64
};
- static final byte[] SITE_ID = new byte[]{
- 0x33, 0x2c, 0x31, 0x34, //site id
- 0x31, 0x35, 0x39, 0x32 //site id
+ static final byte[] SITE_ID = new byte[] {
+ 0x33, 0x2c, 0x31, 0x34,
+ 0x31, 0x35, 0x39, 0x32
};
};
final byte[] newAuthenticationData = new byte [] {
- (byte) 0x00, (byte) 0x14, // authentication data length
+ // authentication data length
+ (byte) 0x00, (byte) 0x14,
(byte) 0x7A, (byte) 0x53, (byte) 0x7F, (byte) 0xF6,
(byte) 0xB8, (byte) 0x91, (byte) 0x33, (byte) 0x7F,
(byte) 0xB1, (byte) 0x41, (byte) 0xC3, (byte) 0x51,