MCPcopy Index your code
hub / github.com/antlr/codebuff / getTeredoInfo

Method getTeredoInfo

output/java_guava/1.4.19/InetAddresses.java:686–701  ·  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

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