Module org.jnetpcap

Enum Class SockAddrFamily

java.lang.Object
java.lang.Enum<SockAddrFamily>
org.jnetpcap.constant.SockAddrFamily
All Implemented Interfaces:
Serializable, Comparable<SockAddrFamily>, Constable, IntSupplier

public enum SockAddrFamily extends Enum<SockAddrFamily> implements IntSupplier
Enumerates socket address protocol families and their platform-specific constants. This enum provides mapping between protocol families and their numeric identifiers on different platforms (BSD vs POSIX), along with structure layout information needed for correct address interpretation.

Platform Differences

Socket address families are represented differently across platforms:
  • POSIX/Linux systems use different numeric values than BSD systems
  • BSD systems include an extra length field (sa_len) in their structures
  • Some address families are platform-specific and not available everywhere

Common Address Families

  • UNSPEC - Unspecified protocol family
  • INET - IPv4 Internet protocols
  • INET6 - IPv6 Internet protocols
  • PACKET - Low-level packet interface (Linux)
  • LINK - Link layer interface (BSD)
  • LOCAL/UNIX - Local communication

Usage Example


 
 // Get the correct family constant for the current platform
 int familyValue = SockAddrFamily.INET.getAsInt();
 
 // Look up a family from a native value
 Optional<SockAddrFamily> family = SockAddrFamily.lookup(2); // AF_INET
 
 // Check if a network interface has an IPv6 address
 boolean hasIPv6 = SockAddrFamily.INET6.checkIfContains(networkInterface);
 
See Also: