rNew = new ArrayList<>();
for (VirtualNetworkRoute r : routes) {
rCurrent.add(r.toString());
}
for (VirtualNetworkRoute r : cfg.routes) {
rNew.add(r.toString());
}
Collections.sort(rCurrent);
Collections.sort(rNew);
Log.i(TAG, "Managed Routes Changed");
Log.i(TAG, "Old:");
for (String s : rCurrent) {
Log.i(TAG, " " + s);
}
Log.i(TAG, "");
Log.i(TAG, "New:");
for (String s : rNew) {
Log.i(TAG, " " + s);
}
Log.i(TAG, "");
return false;
}
boolean dnsEquals;
if (this.dns == null) {
//noinspection RedundantIfStatement
if (cfg.dns == null) {
dnsEquals = true;
} else {
dnsEquals = false;
}
} else {
if (cfg.dns == null) {
dnsEquals = false;
} else {
dnsEquals = this.dns.equals(cfg.dns);
}
}
if (!dnsEquals) {
return false;
}
return true;
}
@Override
public int compareTo(VirtualNetworkConfig cfg) {
return Long.compare(this.nwid, cfg.nwid);
}
@Override
public int hashCode() {
int result = 17;
result = 37 * result + (int) (nwid ^ (nwid >>> 32));
result = 37 * result + (int) (mac ^ (mac >>> 32));
result = 37 * result + name.hashCode();
result = 37 * result + status.hashCode();
result = 37 * result + type.hashCode();
result = 37 * result + mtu;
result = 37 * result + (dhcp ? 1 : 0);
result = 37 * result + (bridge ? 1 : 0);
result = 37 * result + (broadcastEnabled ? 1 : 0);
// result = 37 * result + portError;
// result = 37 * result + (int) (netconfRevision ^ (netconfRevision >>> 32));
result = 37 * result + Arrays.hashCode(assignedAddresses);
result = 37 * result + Arrays.hashCode(routes);
result = 37 * result + (dns == null ? 0 : dns.hashCode());
return result;
}
/**
* 64-bit ZeroTier network ID
*/
public long getNwid() {
return nwid;
}
/**
* Ethernet MAC (48 bits) that should be assigned to port
*/
public long getMac() {
return mac;
}
/**
* Network name (from network configuration master)
*/
public String getName() {
return name;
}
/**
* Network configuration request status
*/
public VirtualNetworkStatus getStatus() {
return status;
}
/**
* Network type
*/
public VirtualNetworkType getType() {
return type;
}
/**
* Maximum interface MTU
*/
public int getMtu() {
return mtu;
}
/**
* If the network this port belongs to indicates DHCP availability
*
* This is a suggestion. The underlying implementation is free to ignore it
* for security or other reasons. This is simply a netconf parameter that
* means 'DHCP is available on this network.'
*/
public boolean isDhcp() {
return dhcp;
}
/**
* If this port is allowed to bridge to other networks
*
* This is informational. If this is false, bridged packets will simply
* be dropped and bridging won't work.
*/
public boolean isBridge() {
return bridge;
}
/**
* If true, this network supports and allows broadcast (ff:ff:ff:ff:ff:ff) traffic
*/
public boolean isBroadcastEnabled() {
return broadcastEnabled;
}
/**
* If the network is in PORT_ERROR state, this is the error most recently returned by the port config callback
*/
// public int getPortError() {
// return portError;
// }
/**
* Network config revision as reported by netconf master
*
* If this is zero, it means we're still waiting for our netconf.
*/
// public long getNetconfRevision() {
// return netconfRevision;
// }
/**
* ZeroTier-assigned addresses (in {@link InetSocketAddress} objects)
*
* For IP, the port number of the sockaddr_XX structure contains the number
* of bits in the address netmask. Only the IP address and port are used.
* Other fields like interface number can be ignored.
*
* This is only used for ZeroTier-managed address assignments sent by the
* virtual network's configuration master.
*/
public InetSocketAddress[] getAssignedAddresses() {
return assignedAddresses;
}
/**
* ZeroTier-assigned routes (in {@link VirtualNetworkRoute} objects)
*/
public VirtualNetworkRoute[] getRoutes() {
return routes;
}
/**
* Network specific DNS configuration
*/
public VirtualNetworkDNS getDns() {
return dns;
}
}