+ public HostNodeConnector toHostNodeConnector() {
+ Integer[] ipv4s = this.getIPv4Addresses();
+ try {
+ Entity e = this.entities[this.entities.length-1];
+ NodeConnector n = null;
+ if(e!=null)
+ n = e.getPort();
+ InetAddress ip = InetAddress.getByName(ipv4s[ipv4s.length - 1]
+ .toString());
+ byte[] macAddr = macLongToByte(this.getMACAddress());
+ HostNodeConnector nc = new HostNodeConnector(macAddr, ip, n,
+ (short) 0);
+ nc.setStaticHost(this.isStaticHost());
+ return nc;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private byte[] macLongToByte(long mac) {
+ byte[] macAddr = new byte[6];
+ for (int i = 0; i < 6; i++) {
+ macAddr[5 - i] = (byte) (mac >> (8 * i));
+ }
+ return macAddr;
+ }
+
+ public boolean isStaticHost(){
+ return this.staticHost;
+ }
+
+ public void setStaticHost(boolean isStatic){
+ this.staticHost = isStatic;
+ }
+