java - How do I get the IPv4 subnetmask on interface with both v4 and v6 address? -


I have an interface address that gives an IPv4 address (4 octets). However, the network prefix length is for the IPv6 address associated with the interface (it is returning as 128). How do I get the correct network prefix length?

  enumeration & lt; Network Interface & gt; For NetworkInterface.getNetworkInterfaces () (; interfaces.hasMoreElements ();) {From the last list & lt; InterfaceAddress & gt; InterfaceAddresses = interfaces.nextElement () getInterfaceAddresses (); For (Last Interface Address Address: Interface Attachments) {Insert (Address Gateadder (.) GetAddress (). Length == 4); // [sic] emphasis (address.getNetworkPrefixLength () <32); // & lt; - Failure actually, I think this is a bug in the original code. In fact, 128}}  

Both of you JVM's v4 for the same interface When v6 addresses, it gets confused.

/ Html>

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -