use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method insertNBMappingSourceDest.
private void insertNBMappingSourceDest(long iid, String src, String dst, String locator) {
String srcAddress = MaskUtil.getPrefixAddress(src);
String dstAddress = MaskUtil.getPrefixAddress(dst);
int srcMask = Integer.parseInt(MaskUtil.getPrefixMask(src));
int dstMask = Integer.parseInt(MaskUtil.getPrefixMask(dst));
LOG.debug("Adding Northbound mapping in VNI {} for prefix {}|{}, locator {}", iid, src, dst, locator);
Eid eid = LispAddressUtil.asSrcDstEid(srcAddress, dstAddress, srcMask, dstMask, iid);
List<Rloc> rlocs = Arrays.asList(LispAddressUtil.asIpv4Rloc(locator));
insertNBMapping(eid, rlocs);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method removeNBMapping.
private void removeNBMapping(long iid, String prefix) {
LOG.debug("Removing Northbound mapping in VNI {} for prefix {}", iid, prefix);
Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid(iid, prefix);
mapService.removeMapping(MappingOrigin.Northbound, eid);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method insertNBMapping.
private void insertNBMapping(long iid, String prefix, String... locators) {
LOG.debug("Adding Northbound mapping in VNI {} for prefix {}, locators {}", iid, prefix, locators);
Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid(iid, prefix);
List<Rloc> rlocs = new ArrayList<>();
for (String locator : locators) {
rlocs.add(LispAddressUtil.asIpv4Rloc(locator));
}
insertNBMapping(eid, rlocs);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method checkSmr.
/**
* Read packets from the given socket until a Map-Request is found. Assert that the request is an SMR, and the
* Source EID field contains the given IPv4 EID. Note that the source EID does not have a mask length. If a
* reference to the LISP Mapping Service is passed, send an SMR-invoked Map-Request, to simulate what would happen
* in the real world. If a reference to the Mapping Service is passed, the internal state of the map caches and
* subscribers is logged.
*
* @param socket the receive socket
* @param lms reference to the LISP Mapping Service, if present, an SMR-invoked Map-Request is sent in reply to the
* SMR
* @param ms reference to the Mapping System, if present, the internal state of map-caches and subscribers is logged
* @param vni the VNI for the expected EID
* @param eids the expected EIDs, as an IPv4 string, without mask length
*/
static void checkSmr(DatagramSocket socket, IFlowMapping lms, IMappingService ms, long vni, String... eids) {
LOG.debug("checkSmr: expecting {} SMRs: {}", eids.length, eids);
List<MapRequest> mapRequests = receiveExpectedSmrs(socket, eids.length);
assertNoMoreSMRs(socket, ms);
HashMap<Eid, Integer> eidSet = prepareExpectedEids(vni, eids);
for (MapRequest mapRequest : mapRequests) {
LOG.trace("Solicit Map-Request: {}", mapRequest);
Eid originalSourceEid = mapRequest.getEidItem().get(0).getEid();
assertEquals(DEFAULT_IPV4_EID_PREFIX, originalSourceEid);
Eid smrEid = mapRequest.getSourceEid().getEid();
int counterDecremented = eidSet.get(smrEid) - 1;
if (counterDecremented < 0) {
fail("checkSmr: SMR contains EID " + LispAddressStringifier.getString(smrEid) + ", which is not in the list of expected EIDs: " + eidSet);
} else {
LOG.debug("checkSmr: successfully received expected SMR for {}", LispAddressStringifier.getString(smrEid));
}
if (lms != null) {
sendSMRInvokedMapRequestMessage(mapRequest, lms);
// TODO Capture the reply to the SMR-invoked Map-Request and assert on the expected result
}
}
if (ms != null) {
printMapCacheState(ms);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping 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());
}
}
Aggregations