Created
January 16, 2019 10:21
-
-
Save wido/948ece578864f8de3d5e145853bf5e32 to your computer and use it in GitHub Desktop.
Check if IPv6 Address is EUI-64 in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.googlecode.ipv6.IPv6Address; | |
/* | |
Replace the IPv6 address with anything you like, Link Local or Global, based on the 'ff:fe' in the address | |
this code will tell you if the address is EUI-64 | |
Author: Wido den Hollander <wido@widodh.nl> | |
*/ | |
public class IPv6 { | |
public static void main(String[] args) { | |
String address = "fe80::800:27ff:fe00:0"; | |
IPv6Address addr = IPv6Address.fromString(address); | |
byte[] bytes = addr.toByteArray(); | |
if (bytes[11] == -1 && bytes[12] == -2) { | |
System.out.println("True"); | |
} else { | |
System.out.println("False"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment