Implemented storage for PortAddresses in HostStore
diff --git a/core/net/src/main/java/org/onlab/onos/net/host/impl/DefaultPortAddresses.java b/core/net/src/main/java/org/onlab/onos/net/host/impl/DefaultPortAddresses.java
new file mode 100644
index 0000000..fb656cf
--- /dev/null
+++ b/core/net/src/main/java/org/onlab/onos/net/host/impl/DefaultPortAddresses.java
@@ -0,0 +1,36 @@
+package org.onlab.onos.net.host.impl;
+
+import org.onlab.onos.net.ConnectPoint;
+import org.onlab.onos.net.host.PortAddresses;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+
+public class DefaultPortAddresses implements PortAddresses {
+
+ private final ConnectPoint connectPoint;
+ private final IpAddress ipAddress;
+ private final MacAddress macAddress;
+
+ public DefaultPortAddresses(ConnectPoint connectPoint,
+ IpAddress ip, MacAddress mac) {
+ this.connectPoint = connectPoint;
+ this.ipAddress = ip;
+ this.macAddress = mac;
+ }
+
+ @Override
+ public ConnectPoint connectPoint() {
+ return connectPoint;
+ }
+
+ @Override
+ public IpAddress ip() {
+ return ipAddress;
+ }
+
+ @Override
+ public MacAddress mac() {
+ return macAddress;
+ }
+
+}
diff --git a/core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java b/core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
index e2c9858..3c1a499 100644
--- a/core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
@@ -157,26 +157,22 @@
@Override
public void bindAddressesToPort(IpAddress ip, MacAddress mac,
ConnectPoint connectPoint) {
- // TODO Auto-generated method stub
-
+ store.updateAddressBindings(new DefaultPortAddresses(connectPoint, ip, mac));
}
@Override
public void unbindAddressesFromPort(ConnectPoint connectPoint) {
- // TODO Auto-generated method stub
-
+ store.removeAddressBindings(connectPoint);
}
@Override
public Set<PortAddresses> getAddressBindings() {
- // TODO Auto-generated method stub
- return null;
+ return store.getAddressBindings();
}
@Override
public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) {
- // TODO Auto-generated method stub
- return null;
+ return store.getAddressBindingsForPort(connectPoint);
}
// Personalized host provider service issued to the supplied provider.
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
index 752ec9e..6568d43 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
@@ -51,6 +51,9 @@
// Hosts tracked by their location
private final Multimap<ConnectPoint, Host> locations = HashMultimap.create();
+ private final Map<ConnectPoint, PortAddresses> portAddresses =
+ new ConcurrentHashMap<>();
+
@Activate
public void activate() {
log.info("Started");
@@ -195,26 +198,22 @@
@Override
public void updateAddressBindings(PortAddresses addresses) {
- // TODO Auto-generated method stub
-
+ portAddresses.put(addresses.connectPoint(), addresses);
}
@Override
public void removeAddressBindings(ConnectPoint connectPoint) {
- // TODO Auto-generated method stub
-
+ portAddresses.remove(connectPoint);
}
@Override
public Set<PortAddresses> getAddressBindings() {
- // TODO Auto-generated method stub
- return null;
+ return new HashSet<>(portAddresses.values());
}
@Override
public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) {
- // TODO Auto-generated method stub
- return null;
+ return portAddresses.get(connectPoint);
}
}