add a virtual gateway for reactive routing

  There is no physical gateway in SDN network.
  However a host needs a gateway when it tries to communicate with a remote host.
  So we designed a virtual gateway for SDN network.
  The virtual gateway can have multiple IP addresses.
  Each IP address is used as the default gateway address of an IP prefix.
  We only configure one MAC address to the virtual gateway.
  You can choose any MAC address from the BGP speakers as the virtual gateway MAC address.
  We configure this MAC address staticly in the sdnip.json configuration file.

Change-Id: I2a72bef797fc55d25bb5473e8fca624ad659e1d1
diff --git a/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java b/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
index abb6a13..c45d286 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
@@ -29,6 +29,7 @@
 import org.onlab.packet.Ip6Address;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.host.HostService;
 import org.onosproject.routing.config.BgpPeer;
@@ -43,6 +44,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -68,6 +70,7 @@
 
     private Map<String, BgpSpeaker> bgpSpeakers = new ConcurrentHashMap<>();
     private Map<IpAddress, BgpPeer> bgpPeers = new ConcurrentHashMap<>();
+    private Set<IpAddress> gatewayIpAddresses = new HashSet<>();
 
     private InvertedRadixTree<LocalIpPrefixEntry>
             localPrefixTable4 = new ConcurrentInvertedRadixTree<>(
@@ -76,6 +79,7 @@
             localPrefixTable6 = new ConcurrentInvertedRadixTree<>(
                     new DefaultByteArrayNodeFactory());
 
+    private MacAddress virtualGatewayMacAddress;
     private HostToInterfaceAdaptor hostAdaptor;
 
     @Activate
@@ -109,12 +113,16 @@
             for (LocalIpPrefixEntry entry : config.getLocalIp4PrefixEntries()) {
                 localPrefixTable4.put(createBinaryString(entry.ipPrefix()),
                                       entry);
+                gatewayIpAddresses.add(entry.getGatewayIpAddress());
             }
             for (LocalIpPrefixEntry entry : config.getLocalIp6PrefixEntries()) {
                 localPrefixTable6.put(createBinaryString(entry.ipPrefix()),
                                       entry);
+                gatewayIpAddresses.add(entry.getGatewayIpAddress());
             }
 
+            virtualGatewayMacAddress = config.getVirtualGatewayMacAddress();
+
         } catch (FileNotFoundException e) {
             log.warn("Configuration file not found: {}", configFileName);
         } catch (IOException e) {
@@ -178,4 +186,14 @@
                 createBinaryString(ipPrefix)) != null);
     }
 
+    @Override
+    public boolean isVirtualGatewayIpAddress(IpAddress ipAddress) {
+        return gatewayIpAddresses.contains(ipAddress);
+    }
+
+    @Override
+    public MacAddress getVirtualGatewayMacAddress() {
+        return virtualGatewayMacAddress;
+    }
+
 }