@Test public void testAddressesAreOnSameLan() { LanTcpPlugin plugin = new LanTcpPlugin(null, null, null, 0, 0); assertTrue(plugin.addressesAreOnSameLan(makeAddress(10, 0, 0, 0), makeAddress(10, 255, 255, 255))); assertTrue(plugin.addressesAreOnSameLan(makeAddress(172, 16, 0, 0), makeAddress(172, 31, 255, 255))); assertTrue(plugin.addressesAreOnSameLan(makeAddress(192, 168, 0, 0), makeAddress(192, 168, 255, 255))); assertTrue(plugin.addressesAreOnSameLan(makeAddress(169, 254, 0, 0), makeAddress(169, 254, 255, 255))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(10, 0, 0, 0), makeAddress(172, 31, 255, 255))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(10, 0, 0, 0), makeAddress(192, 168, 255, 255))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(172, 16, 0, 0), makeAddress(10, 255, 255, 255))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(172, 16, 0, 0), makeAddress(192, 168, 255, 255))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(192, 168, 0, 0), makeAddress(10, 255, 255, 255))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(192, 168, 0, 0), makeAddress(172, 31, 255, 255))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(10, 0, 0, 0), makeAddress(1, 2, 3, 4))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(172, 16, 0, 0), makeAddress(1, 2, 3, 4))); assertFalse(plugin.addressesAreOnSameLan(makeAddress(192, 168, 0, 0), makeAddress(1, 2, 3, 4))); assertTrue(plugin.addressesAreOnSameLan(makeAddress(1, 2, 3, 4), makeAddress(5, 6, 7, 8))); }
boolean addressesAreOnSameLan(byte[] localIp, byte[] remoteIp) { if (isPrefix10(localIp)) return isPrefix10(remoteIp); if (isPrefix172(localIp)) return isPrefix172(remoteIp); if (isPrefix192(localIp)) return isPrefix192(remoteIp); return true; }
LanTcpPlugin extends TcpPlugin { boolean addressesAreOnSameLan(byte[] localIp, byte[] remoteIp) { if (isPrefix10(localIp)) return isPrefix10(remoteIp); if (isPrefix172(localIp)) return isPrefix172(remoteIp); if (isPrefix192(localIp)) return isPrefix192(remoteIp); return true; } }
LanTcpPlugin extends TcpPlugin { boolean addressesAreOnSameLan(byte[] localIp, byte[] remoteIp) { if (isPrefix10(localIp)) return isPrefix10(remoteIp); if (isPrefix172(localIp)) return isPrefix172(remoteIp); if (isPrefix192(localIp)) return isPrefix192(remoteIp); return true; } LanTcpPlugin(Executor ioExecutor, Backoff backoff,
			DuplexPluginCallback callback, int maxLatency, int maxIdleTime); }
LanTcpPlugin extends TcpPlugin { boolean addressesAreOnSameLan(byte[] localIp, byte[] remoteIp) { if (isPrefix10(localIp)) return isPrefix10(remoteIp); if (isPrefix172(localIp)) return isPrefix172(remoteIp); if (isPrefix192(localIp)) return isPrefix192(remoteIp); return true; } LanTcpPlugin(Executor ioExecutor, Backoff backoff,
			DuplexPluginCallback callback, int maxLatency, int maxIdleTime); @Override TransportId getId(); @Override boolean supportsKeyAgreement(); @Override KeyAgreementListener createKeyAgreementListener(byte[] commitment); @Override DuplexTransportConnection createKeyAgreementConnection(
			byte[] commitment, BdfList descriptor); }
LanTcpPlugin extends TcpPlugin { boolean addressesAreOnSameLan(byte[] localIp, byte[] remoteIp) { if (isPrefix10(localIp)) return isPrefix10(remoteIp); if (isPrefix172(localIp)) return isPrefix172(remoteIp); if (isPrefix192(localIp)) return isPrefix192(remoteIp); return true; } LanTcpPlugin(Executor ioExecutor, Backoff backoff,
			DuplexPluginCallback callback, int maxLatency, int maxIdleTime); @Override TransportId getId(); @Override boolean supportsKeyAgreement(); @Override KeyAgreementListener createKeyAgreementListener(byte[] commitment); @Override DuplexTransportConnection createKeyAgreementConnection(
			byte[] commitment, BdfList descriptor);  }