X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fhosttracker_new%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fhosttracker%2FEntity.java;h=64f4c7ef1e1d65bddcafd7310dccfe6b44278741;hb=fba140bf09ffbf8694aa41f544caaa331c2ec29a;hp=7c98e9505b28b1b51098a9d9c9c3e29ab9af6a2c;hpb=ff1b4a79cca00743a00c3b0b1100bd0ab2b2fb31;p=controller.git diff --git a/opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java b/opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java index 7c98e9505b..64f4c7ef1e 100644 --- a/opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java +++ b/opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java @@ -33,9 +33,12 @@ package org.opendaylight.controller.hosttracker; +import java.net.InetAddress; import java.util.Date; +import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.utils.NetUtils; /** * An entity on the network is a visible trace of a device that corresponds to a @@ -218,6 +221,19 @@ public class Entity implements Comparable { return true; } + public HostNodeConnector toHostNodeConnector() { + try { + NodeConnector n = this.getPort(); + InetAddress ip = InetAddress.getByAddress(NetUtils.intToByteArray4(this.getIpv4Address())); + byte[] macAddr = NetUtils.longToByteArray6(this.getMacAddress()); + HostNodeConnector nc = new HostNodeConnector(macAddr, ip, n, + (short) 0); + return nc; + } catch (Exception e) { + return null; + } + } + @Override public String toString() { return "Entity [macAddress=" + macAddress + ", ipv4Address=" @@ -228,10 +244,12 @@ public class Entity implements Comparable { @Override public int compareTo(Entity o) { int r; - if (port == null) + if (port == null) { r = o.port == null ? 0 : -1; - else if (o.port == null) + } + else if (o.port == null) { r = 1; + } else { // XXX - the node id is only defined as an object rather // than something useful. We're just going to have to