+ public void removeAuthenticationKey(LispAddressContainer address, int maskLen) {
+ mapServer.removeAuthenticationKey(address, maskLen);
+ }
+
+ public void addAuthenticationKey(LispAddressContainer address, int maskLen, String key) {
+ mapServer.addAuthenticationKey(address, maskLen, key);
+ }
+
+ public void removeMapping(LispAddressContainer address, int maskLen) {
+ mapServer.removeMapping(address, maskLen, smr, this);
+ }
+
+ public boolean shouldIterateMask() {
+ return this.shouldIterateMask;
+ }
+
+ public boolean shouldUseSmr() {
+ return this.smr;
+ }
+
+ public void setShouldUseSmr(boolean smr) {
+ this.smr = smr;
+ }
+
+ public void setShouldIterateMask(boolean shouldIterateMask) {
+ this.shouldIterateMask = shouldIterateMask;
+ this.mapResolver.setShouldIterateMask(shouldIterateMask);
+ this.mapServer.setShouldIterateMask(shouldIterateMask);
+ }
+
+ public void setShouldAuthenticate(boolean shouldAuthenticate) {
+ this.shouldAuthenticate = shouldAuthenticate;
+ this.mapResolver.setShouldAuthenticate(shouldAuthenticate);
+ this.mapServer.setShouldAuthenticate(shouldAuthenticate);
+ }
+
+ public boolean shouldAuthenticate() {
+ return shouldAuthenticate;
+ }
+
+ @Override
+ public void onSessionInitiated(ProviderContext session) {
+ LOG.info("Lisp Consumer session initialized!");
+ notificationService = session.getSALService(NotificationService.class);
+ registerNotificationListener(AddMapping.class, new MapRegisterNotificationHandler());
+ registerNotificationListener(RequestMapping.class, new MapRequestNotificationHandler());
+ session.addRpcImplementation(LfmMappingDatabaseService.class, this);
+ this.session = session;
+ }
+
+ public <T extends Notification> void registerNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
+ notificationService.registerNotificationListener(notificationType, listener);
+ }
+
+ private class MapRegisterNotificationHandler implements NotificationListener<AddMapping> {
+
+ @Override
+ public void onNotification(AddMapping mapRegisterNotification) {
+ MapNotify mapNotify = handleMapRegister(mapRegisterNotification.getMapRegister(), smr);
+ if (mapNotify != null) {
+ TransportAddressBuilder tab = new TransportAddressBuilder();
+ tab.setIpAddress(mapRegisterNotification.getTransportAddress().getIpAddress());
+ tab.setPort(new PortNumber(LispMessage.PORT_NUM));
+ SendMapNotifyInputBuilder smnib = new SendMapNotifyInputBuilder();
+ smnib.setMapNotify(new MapNotifyBuilder(mapNotify).build());
+ smnib.setTransportAddress(tab.build());
+ getLispSB().sendMapNotify(smnib.build());
+ } else {
+ LOG.warn("got null map notify");
+ }
+
+ }
+ }
+
+ private class MapRequestNotificationHandler implements NotificationListener<RequestMapping> {
+
+ @Override
+ public void onNotification(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.warn("got null map reply");
+ }
+ }
+ }
+
+ private LfmControlPlaneService getLispSB() {
+ if (lispSB == null) {
+ lispSB = session.getRpcService(LfmControlPlaneService.class);
+ }
+ return lispSB;
+ }
+
+ public void handleMapReply(MapReply reply) {
+ tlsMapReply.set(reply);
+ }
+
+ public void handleMapNotify(MapNotify notify) {
+ tlsMapNotify.set(notify);
+ }
+
+ public void handleSMR(MapRequest smr, LispAddressContainer subscriber) {
+ LOG.debug("Sending SMR to " + subscriber.toString());
+ SendMapRequestInputBuilder smrib = new SendMapRequestInputBuilder();
+ smrib.setMapRequest(new MapRequestBuilder(smr).build());
+ smrib.setTransportAddress(LispNotificationHelper.getTransportAddressFromContainer(subscriber));
+ getLispSB().sendMapRequest(smrib.build());
+
+ }
+
+ @Override
+ public void handleNonProxyMapRequest(MapRequest mapRequest, TransportAddress transportAddress) {
+ tlsMapRequest.set(new MutablePair<MapRequest, TransportAddress>(mapRequest, transportAddress));
+ }
+
+ @Override
+ public void clean() {
+ lispDao.removeAll();
+ }
+
+ @Override
+ public boolean shouldOverwrite() {
+ return mapServer.shouldOverwrite();
+ }
+
+ @Override
+ public void setOverwrite(boolean overwrite) {
+ mapServer.setOverwrite(overwrite);
+ }
+
+ @Override
+ public Future<RpcResult<AddKeyOutput>> addKey(AddKeyInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<AddMappingOutput>> addMapping(AddMappingInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<GetKeyOutput>> getKey(GetKeyInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<GetKeyWithRefOutput>> getKeyWithRef(
+ GetKeyWithRefInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<GetMappingOutput>> getMapping(GetMappingInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<GetMappingWithRefOutput>> getMappingWithRef(
+ GetMappingWithRefInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<Void>> removeKey(RemoveKeyInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<Void>> removeKeyWithRef(RemoveKeyWithRefInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<Void>> removeMapping(RemoveMappingInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<Void>> removeMappingWithRef(
+ RemoveMappingWithRefInput input) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<Void>> updateKey(UpdateKeyInput input) {
+ // TODO Auto-generated method stub
+ return null;