2 * Copyright (c) 2013 Contextream, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.lispflowmapping.implementation.lisp;
11 import java.util.ArrayList;
12 import java.util.List;
14 import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
15 import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO.MappingEntry;
16 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapServer;
17 import org.opendaylight.lispflowmapping.type.lisp.EidToLocatorRecord;
18 import org.opendaylight.lispflowmapping.type.lisp.LocatorRecord;
19 import org.opendaylight.lispflowmapping.type.lisp.MapNotify;
20 import org.opendaylight.lispflowmapping.type.lisp.MapRegister;
21 import org.opendaylight.lispflowmapping.type.lisp.address.LispAddress;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 public class MapServer implements IMapServer {
27 protected static final Logger logger = LoggerFactory.getLogger(MapServer.class);
29 public MapServer(ILispDAO dao) {
33 public MapNotify handleMapRegister(MapRegister mapRegister) {
35 logger.warn("handleMapRegister called while dao is uninitialized");
38 EidToLocatorRecord eidRecord = mapRegister.getEidToLocatorRecords().get(0);
39 List<MappingEntry<?>> rlocs = new ArrayList<ILispDAO.MappingEntry<?>>();
40 rlocs.add(new MappingEntry<Integer>("NumRLOCs", eidRecord.getLocators().size()));
42 for (LocatorRecord locatorRecord : eidRecord.getLocators()) {
43 rlocs.add(new MappingEntry<LispAddress>("RLOC" + (i++), locatorRecord.getLocator()));
45 dao.put(eidRecord.getPrefix(), rlocs.toArray(new MappingEntry[rlocs.size()]));
46 MapNotify mapNotify = null;
47 if (mapRegister.isWantMapNotify()) {
48 mapNotify = new MapNotify();
49 mapNotify.setFromMapRegister(mapRegister);