- All Implemented Interfaces:
Serializable
,Comparable<SockAddrFamily>
,Constable
,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 familyINET
- IPv4 Internet protocolsINET6
- IPv6 Internet protocolsPACKET
- 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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionThe alg.The appletalk.The ash.The atmpvc.The atmsvc.The ax25.The bluetooth.The bridge.The caif.The can.CCITT protocols, X.25 etc.MIT CHAOS protocols.Computer Network Technology.connection-oriented IP, aka ST II.Datakit protocols.DECnet.The decnet.DEC Direct data link interface.Integrated Services Digital Network.European computer manufacturers.NSC Hyperchannel.The ieee802154.Arpanet imp addresses.The inet.The inet6.The ipx.The irda.The isdn.ISO protocols.The kcm.The key.LAT.Link layer interface.The llc.The local.The mpls.Native ATM access.Network Driver 'raw' access.The netbeui.The netlink.The netrom.The nfc.XEROX NS protocols.ISO protocols.The packet.The phonet.The pppox.Identify packets for Blue Box.Internal key-management function.Help Identify PIP packets.Help Identify RTIP packets.eXpress Transfer Protocol (no AF).PUP protocols: e.g.The qipcrtr.The rds.The rose.Internal Routing Protocol.The rxrpc.The security.Simple Internet Protocol.The smc.The sna.Kernel event messages.The tipc.The unspec.The vsock.The wanpipe.The x25. -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkIfContains
(PcapIf dev) Checks if a network interface (PcapIf) has an address of this family type.int
getAsInt()
Returns the platform-specific numeric value for this address family.boolean
isMatch
(int family) Checks if a given numeric family value matches this address family constant for the current platform.static Optional
<SockAddrFamily> lookup
(int family) Looks up a socket address family constant using a platform-specific numeric value.Returns the total length of the socket address structure for this family.static SockAddrFamily
Returns the enum constant of this class with the specified name.static SockAddrFamily[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
UNSPEC
The unspec. -
LOCAL
The local. -
INET
The inet. -
AX25
The ax25. -
IPX
The ipx. -
APPLETALK
The appletalk. -
NETROM
The netrom. -
BRIDGE
The bridge. -
ATMPVC
The atmpvc. -
X25
The x25. -
INET6
The inet6. -
ROSE
The rose. -
DECNET
The decnet. -
NETBEUI
The netbeui. -
SECURITY
The security. -
KEY
The key. -
NETLINK
The netlink. -
PACKET
The packet. -
ASH
The ash. -
ATMSVC
The atmsvc. -
RDS
The rds. -
SNA
The sna. -
IRDA
The irda. -
PPPOX
The pppox. -
WANPIPE
The wanpipe. -
LLC
The llc. -
MPLS
The mpls. -
CAN
The can. -
TIPC
The tipc. -
BLUETOOTH
The bluetooth. -
RXRPC
The rxrpc. -
ISDN
The isdn. -
PHONET
The phonet. -
IEEE802154
The ieee802154. -
CAIF
The caif. -
ALG
The alg. -
NFC
The nfc. -
VSOCK
The vsock. -
KCM
The kcm. -
QIPCRTR
The qipcrtr. -
SMC
The smc. -
IMPLINK
Arpanet imp addresses. -
PUP
PUP protocols: e.g. BSP. -
CHAOS
MIT CHAOS protocols. -
NS
XEROX NS protocols. -
ISO
ISO protocols. -
OSI
ISO protocols. -
ECMA
European computer manufacturers. -
DATAKIT
Datakit protocols. -
CCITT
CCITT protocols, X.25 etc. -
DECnet
DECnet. -
DLI
DEC Direct data link interface. -
LAT
LAT. -
HYLINK
NSC Hyperchannel. -
ROUTE
Internal Routing Protocol. -
LINK
Link layer interface. -
PSEUDO_XTP
eXpress Transfer Protocol (no AF). -
COIP
connection-oriented IP, aka ST II. -
CNT
Computer Network Technology. -
PSEUDO_RTIP
Help Identify RTIP packets. -
SIP
Simple Internet Protocol. -
PSEUDO_PIP
Help Identify PIP packets. -
PSEUDO_BLUE
Identify packets for Blue Box. -
NDRV
Network Driver 'raw' access. -
E164
Integrated Services Digital Network. -
PSEUDO_KEY
Internal key-management function. -
NATM
Native ATM access. -
SYSTEM
Kernel event messages.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
lookup
Looks up a socket address family constant using a platform-specific numeric value. The lookup considers the current platform (BSD vs POSIX) when matching values.- Parameters:
family
- The platform-specific address family value- Returns:
- An Optional containing the matching SockAddrFamily constant, or empty if not found
-
checkIfContains
Checks if a network interface (PcapIf) has an address of this family type. This is useful for determining what types of addresses are available on a particular interface.- Parameters:
dev
- The network interface to check- Returns:
- true if the interface has an address of this family type
-
getAsInt
public int getAsInt()Returns the platform-specific numeric value for this address family. The value returned depends on the current platform (BSD vs POSIX).- Specified by:
getAsInt
in interfaceIntSupplier
- Returns:
- The numeric address family value for the current platform
-
isMatch
public boolean isMatch(int family) Checks if a given numeric family value matches this address family constant for the current platform.- Parameters:
family
- The numeric family value to check- Returns:
- true if the value matches this family on the current platform
-
totalLength
Returns the total length of the socket address structure for this family. The length is platform-dependent and primarily relevant for BSD systems which include it in their socket address structures.- Returns:
- An OptionalInt containing the structure length if defined for this family and platform, empty otherwise
-