Toshio Koide | 5799b60 | 2014-02-10 15:29:06 -0800 | [diff] [blame^] | 1 | package net.onrc.onos.ofcontroller.networkgraph; |
| 2 | |
| 3 | import java.net.InetAddress; |
| 4 | import java.util.Collection; |
| 5 | import java.util.LinkedList; |
| 6 | |
| 7 | import net.floodlightcontroller.util.MACAddress; |
| 8 | |
| 9 | /** |
| 10 | * @author Toshio Koide (t-koide@onlab.us) |
| 11 | */ |
| 12 | public class DeviceImpl implements Device { |
| 13 | LinkedList<Port> attachmentPoints = new LinkedList<Port>(); |
| 14 | MACAddress macAddr; |
| 15 | |
| 16 | public DeviceImpl(NetworkGraph graph, MACAddress macAddr) { |
| 17 | this.macAddr = macAddr; |
| 18 | } |
| 19 | |
| 20 | @Override |
| 21 | public MACAddress getMacAddress() { |
| 22 | return macAddr; |
| 23 | } |
| 24 | |
| 25 | @Override |
| 26 | public Collection<InetAddress> getIpAddress() { |
| 27 | // TODO Auto-generated method stub |
| 28 | return null; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @return ports attached to the device. |
| 33 | * The last added port is stored as the first element. |
| 34 | */ |
| 35 | @Override |
| 36 | public Iterable<Port> getAttachmentPoints() { |
| 37 | return attachmentPoints; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public long getLastSeenTime() { |
| 42 | // TODO Auto-generated method stub |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | public void addAttachmentPoint(Port port) { |
| 47 | attachmentPoints.add(0, port); |
| 48 | } |
| 49 | |
| 50 | public void removeAttachmentPoint(Port port) { |
| 51 | attachmentPoints.remove(port); |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public String toString() { |
| 56 | return macAddr.toString(); |
| 57 | } |
| 58 | } |