Ported PeerConnectivity onto ONOS next, and implemented a service that can
construct Interface objects based on PortAddresses from HostService.
diff --git a/apps/sdnip/src/main/java/org/onlab/onos/sdnip/config/Interface.java b/apps/sdnip/src/main/java/org/onlab/onos/sdnip/config/Interface.java
index 33287ad..88de952 100644
--- a/apps/sdnip/src/main/java/org/onlab/onos/sdnip/config/Interface.java
+++ b/apps/sdnip/src/main/java/org/onlab/onos/sdnip/config/Interface.java
@@ -1,86 +1,78 @@
 package org.onlab.onos.sdnip.config;
 
 import java.util.Objects;
+import java.util.Set;
 
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
 import org.onlab.onos.net.ConnectPoint;
-import org.onlab.onos.net.DeviceId;
-import org.onlab.onos.net.PortNumber;
+import org.onlab.onos.net.host.PortAddresses;
 import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.Sets;
 
 /**
- * Represents an interface, which is an external-facing switch port that
- * connects to another network.
- * <p/>
- * SDN-IP treats external-facing ports similarly to router ports. Logically, it
- * assigns an IP subnetwork prefix and several IP addresses to each port which
- * are used for communication with the BGP peers located in other networks, for
- * example, the BGP peering sessions. The peers in other networks will be
- * configured to peer with the IP addresses (logically) assigned to the
- * interface. The logical {@code Interface} construct maps on to a physical
- * port in the data plane, which of course has no notion of IP addresses.
- * <p/>
- * Each interface has a name, which is a unique identifying String that is used
- * to reference this interface in the configuration (for example, to map
- * {@link BgpPeer}s to {@code Interfaces}.
+ * An Interface is a set of addresses that are logically mapped to a switch
+ * port in the network.
  */
 public class Interface {
-    private final String name;
-    private final ConnectPoint switchPort;
-    private final IpPrefix ip4Prefix;
+    private final ConnectPoint connectPoint;
+    private final Set<IpPrefix> ipAddresses;
+    private final MacAddress macAddress;
 
     /**
-     * Class constructor used by the JSON library to create an object.
+     * Creates an Interface based on a connection point, a set of IP addresses
+     * and a MAC address.
      *
-     * @param name the name of the interface
-     * @param dpid the dpid of the switch
-     * @param port the port on the switch
-     * @param prefixAddress the network prefix address logically assigned to the
-     * interface
-     * @param prefixLength the length of the network prefix of the IP address
+     * @param connectPoint the connect point this interface is mapped to
+     * @param prefixAddress the IP addresses for the interface
+     * @param macAddress the MAC address of the interface
      */
-    @JsonCreator
-    public Interface(@JsonProperty("name") String name,
-                     @JsonProperty("dpid") String dpid,
-                     @JsonProperty("port") int port,
-                     @JsonProperty("ipAddress") String prefixAddress,
-                     @JsonProperty("prefixLength") short prefixLength) {
-        this.name = name;
-        this.switchPort = new ConnectPoint(
-                DeviceId.deviceId(SdnIpConfigReader.dpidToUri(dpid)),
-                PortNumber.portNumber(port));
-        this.ip4Prefix = IpPrefix.valueOf(prefixAddress + "/" + prefixLength);
+    public Interface(ConnectPoint connectPoint, Set<IpPrefix> prefixAddress,
+                     MacAddress macAddress) {
+        this.connectPoint = connectPoint;
+        this.ipAddresses = Sets.newHashSet(prefixAddress);
+        this.macAddress = macAddress;
     }
 
     /**
-     * Gets the name of the interface.
+     * Creates an Interface based on a PortAddresses object.
      *
-     * @return the name of the interface
+     * @param portAddresses the PortAddresses object to turn into an Interface
      */
-    public String getName() {
-        return name;
+    public Interface(PortAddresses portAddresses) {
+        connectPoint = portAddresses.connectPoint();
+        ipAddresses = Sets.newHashSet(portAddresses.ips());
+        macAddress = portAddresses.mac();
     }
 
     /**
-     * Gets the {@link SwitchPort} that this interface maps to.
+     * Retrieves the connection point that this interface maps to.
      *
-     * @return the switch port
+     * @return the connection point
      */
-    public ConnectPoint getSwitchPort() {
-        return switchPort;
+    public ConnectPoint connectPoint() {
+        return connectPoint;
     }
 
     /**
-     * Gets the IP prefix of the subnetwork which is logically assigned
-     * to the switch port.
+     * Retrieves the set of IP addresses that are assigned to the interface.
      *
-     * @return the IP prefix
+     * @return the set of IP addresses
      */
-   public IpPrefix getIp4Prefix() {
-        return ip4Prefix;
+   public Set<IpPrefix> ips() {
+        return ipAddresses;
     }
 
+   /**
+    * Retrieves the MAC address that is assigned to the interface.
+    *
+    * @return the MAC address
+    */
+   public MacAddress mac() {
+       return macAddress;
+   }
+
     @Override
     public boolean equals(Object other) {
         if (!(other instanceof Interface)) {
@@ -89,13 +81,22 @@
 
         Interface otherInterface = (Interface) other;
 
-        return  name.equals(otherInterface.name) &&
-                switchPort.equals(otherInterface.switchPort) &&
-                ip4Prefix.equals(otherInterface.ip4Prefix);
+        return  connectPoint.equals(otherInterface.connectPoint) &&
+                ipAddresses.equals(otherInterface.ipAddresses) &&
+                macAddress.equals(otherInterface.macAddress);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(name, switchPort, ip4Prefix);
+        return Objects.hash(connectPoint, ipAddresses, macAddress);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("connectPoint", connectPoint)
+                .add("ipAddresses", ipAddresses)
+                .add("macAddress", macAddress)
+                .toString();
     }
 }