MCPcopy Create free account
hub / github.com/antlr/codebuff / getTeredoInfo

Method getTeredoInfo

output/java_guava/1.4.18/InetAddresses.java:685–700  ·  view source on GitHub ↗

Returns the Teredo information embedded in a Teredo address. @param ip Inet6Address to be examined for embedded Teredo information @return extracted TeredoInfo @throws IllegalArgumentException if the argument is not a valid IPv6 Teredo address

(Inet6Address ip)

Source from the content-addressed store, hash-verified

683
684
685 public static TeredoInfo getTeredoInfo(Inet6Address ip) {
686 Preconditions.checkArgument(isTeredoAddress(ip), "Address '%s' is not a Teredo address.", toAddrString(ip));
687 byte[] bytes = ip.getAddress();
688 Inet4Address server = getInet4Address(Arrays.copyOfRange(bytes, 4, 8));
689 int flags = ByteStreams.newDataInput(bytes, 8).readShort() & 0xffff;
690
691 // Teredo obfuscates the mapped client port, per section 4 of the RFC.
692 int port = ~ByteStreams.newDataInput(bytes, 10).readShort() & 0xffff;
693 byte[] clientBytes = Arrays.copyOfRange(bytes, 12, 16);
694 for (int i = 0; i < clientBytes.length; i++) {
695 // Teredo obfuscates the mapped client IP, per section 4 of the RFC.
696 clientBytes[i] = (byte) ~ clientBytes[i];
697 }
698 Inet4Address client = getInet4Address(clientBytes);
699 return new TeredoInfo(server, client, port, flags);
700 }
701
702 /**
703 * Evaluates whether the argument is an ISATAP address.

Callers 1

Calls 6

checkArgumentMethod · 0.95
isTeredoAddressMethod · 0.95
toAddrStringMethod · 0.95
getInet4AddressMethod · 0.95
newDataInputMethod · 0.95
readShortMethod · 0.65

Tested by

no test coverage detected