use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method runPrefixTest.
private void runPrefixTest(Eid registerEID, Eid matchedAddress, Eid unMatchedAddress) throws SocketTimeoutException {
mapService.addAuthenticationKey(registerEID, NULL_AUTH_KEY);
sleepForSeconds(1);
MapRegisterBuilder mapRegister = new MapRegisterBuilder();
mapRegister.setWantMapNotify(true);
mapRegister.setNonce((long) 8);
mapRegister.setWantMapNotify(true);
mapRegister.setKeyId((short) 0);
mapRegister.setAuthenticationData(new byte[0]);
mapRegister.setNonce((long) 8);
mapRegister.setProxyMapReply(false);
MappingRecordBuilder etlr = new MappingRecordBuilder();
etlr.setRecordTtl(254);
etlr.setAction(Action.NoAction);
etlr.setAuthoritative(false);
etlr.setMapVersion((short) 0);
etlr.setEid(registerEID);
etlr.setRecordTtl(254);
LocatorRecordBuilder record = new LocatorRecordBuilder();
record.setRloc(LispAddressUtil.asIpv4Rloc("4.3.2.1"));
record.setLocalLocator(false);
record.setRlocProbed(false);
record.setRouted(true);
record.setMulticastPriority((short) 0);
record.setMulticastWeight((short) 0);
record.setPriority((short) 0);
record.setWeight((short) 0);
etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
etlr.getLocatorRecord().add(record.build());
mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());
sendMapRegister(mapRegister.build());
MapNotify mapNotify = receiveMapNotify();
assertEquals(8, mapNotify.getNonce().longValue());
sleepForSeconds(1);
MapRequestBuilder mapRequest = new MapRequestBuilder();
mapRequest.setNonce((long) 4);
mapRequest.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(ourAddress)).build());
mapRequest.setEidItem(new ArrayList<EidItem>());
mapRequest.setAuthoritative(false);
mapRequest.setMapDataPresent(false);
mapRequest.setPitr(false);
mapRequest.setProbe(false);
mapRequest.setSmr(false);
mapRequest.setSmrInvoked(false);
mapRequest.getEidItem().add(new EidItemBuilder().setEid(matchedAddress).build());
mapRequest.setItrRloc(new ArrayList<ItrRloc>());
mapRequest.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(ourAddress)).build());
sendMapRequest(mapRequest.build());
MapReply mapReply = receiveMapReply();
assertEquals(4, mapReply.getNonce().longValue());
assertEquals(record.getRloc(), mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc());
mapRequest.setEidItem(new ArrayList<EidItem>());
mapRequest.getEidItem().add(new EidItemBuilder().setEid(unMatchedAddress).build());
sendMapRequest(mapRequest.build());
mapReply = receiveMapReply();
assertEquals(0, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method testMultipleMappings.
private void testMultipleMappings() throws UnknownHostException {
final InstanceIdType iid = new InstanceIdType(1L);
// prefix from the intersection of NB and SB gaps
final String prefix1 = "1.1.127.10/32";
// prefix with existing mapping in NB
final String prefix2 = "1.1.200.255/32";
final String prefix3 = "1.3.255.255/32";
final MapRequest mapRequest = new MapRequestBuilder().setSmrInvoked(false).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix1, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix2, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix3, iid)).build())).build();
final MapReply mapReply = lms.handleMapRequest(mapRequest);
// expected result
final String resultPrefix1 = "1.1.64.0";
final Address resultNegMapping1 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix1).getAddress())).setIpv4MaskLength((short) 18).build();
final String resultPrefix2 = "1.1.128.0";
final Address resultMapping2 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix2).getAddress())).setIpv4MaskLength((short) 17).build();
final String resultPrefix3 = "1.3.0.0";
final Address resultNegMapping3 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix3).getAddress())).setIpv4MaskLength((short) 16).build();
assertEquals(resultNegMapping1, mapReply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress());
assertEquals(resultMapping2, mapReply.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress());
assertEquals(resultNegMapping3, mapReply.getMappingRecordItem().get(2).getMappingRecord().getEid().getAddress());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method sendSMRInvokedMapRequestMessage.
/**
* This method expects a SMR Map-Request as input, which it will turn into a SMR-invoked Map-Request and use the
* LISP mapping service to send it
*
* @param mapRequest the SMR Map-Request
* @param lms referencs to the LISP Mapping Service
*/
static void sendSMRInvokedMapRequestMessage(MapRequest mapRequest, IFlowMapping lms) {
Eid eid = addMaximumPrefixIfNecessary(mapRequest.getSourceEid().getEid());
final EidItemBuilder eidItemBuilder = new EidItemBuilder();
eidItemBuilder.setEid(eid);
eidItemBuilder.setEidItemId(LispAddressStringifier.getString(eid));
final List<EidItem> eidItem = Collections.singletonList(eidItemBuilder.build());
final MapRequestBuilder mapRequestBuilder = new MapRequestBuilder(mapRequest);
mapRequestBuilder.setSmr(false);
mapRequestBuilder.setSmrInvoked(true);
mapRequestBuilder.setItrRloc(getDefaultItrRlocList(LispAddressUtil.asIpv4Rloc(RECEIVE_ADDRESS)));
mapRequestBuilder.setEidItem(eidItem);
for (EidItem srcEid : mapRequest.getEidItem()) {
mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(removePrefixIfNecessary(srcEid.getEid())).build());
LOG.debug("Sending SMR-invoked Map-Request for EID {}, Source EID {}", LispAddressStringifier.getString(eid), LispAddressStringifier.getString(srcEid.getEid()));
lms.handleMapRequest(mapRequestBuilder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder in project lispflowmapping by opendaylight.
the class MultiSiteScenario method emitMapRequestMessage.
private MapReply emitMapRequestMessage(final String siteFromEidPrefix, final String siteToEidPrefix, final InstanceIdType vniValue) {
final MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
final EidItemBuilder eidItemBuilder = new EidItemBuilder();
Eid dstEid = toEid(siteToEidPrefix, vniValue, IP_MASK);
eidItemBuilder.setEid(dstEid);
eidItemBuilder.setEidItemId(siteFromEidPrefix + siteToEidPrefix);
final List<EidItem> eidItem = Collections.singletonList(eidItemBuilder.build());
final Eid srcEid = MappingServiceIntegrationTestUtil.removePrefixIfNecessary(toEid(siteFromEidPrefix, vniValue, IP_MASK));
mapRequestBuilder.setSourceEid(new SourceEidBuilder().setEid(srcEid).build());
mapRequestBuilder.setEidItem(eidItem);
mapRequestBuilder.setItrRloc(MappingServiceIntegrationTestUtil.getDefaultItrRlocList(LispAddressUtil.asIpv4Rloc(ourAddress)));
mapRequestBuilder.setSmrInvoked(false);
return lms.handleMapRequest(mapRequestBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder in project lispflowmapping by opendaylight.
the class MapRequestSerializationTest method serialize__SingleEidItem.
@Test
public void serialize__SingleEidItem() throws Exception {
MapRequestBuilder mrBuilder = new MapRequestBuilder();
mrBuilder.setEidItem(new ArrayList<EidItem>());
mrBuilder.getEidItem().add(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("1.2.3.4/32")).build());
ByteBuffer expected = hexToByteBuffer(//
"10 00 00 01 00 00 " + "00 00 00 00 00 00 00 00 00 20 00 01 01 02 03 04");
assertArrayEquals(expected.array(), MapRequestSerializer.getInstance().serialize(mrBuilder.build()).array());
}
Aggregations