java.lang.Object
org.jnetpcap.SockAddr
- Direct Known Subclasses:
SockAddr.Inet6SockAddr
,SockAddr.InetSockAddr
,SockAddr.IpxSockAddr
,SockAddr.IrdaSockAddr
,SockAddr.LinkSockAddr
,SockAddr.PacketSockAddr
The low level
sockaddr
structure containing an address of
different types, depending on the protocol family value. The class is
extended by specific subclasses which provide additional fields relating to
each protocol address family (AF).
BSD style structure
struct sockaddr {
u_char sa_len; // Total length of the structure
u_char sa_family; // Address family (e.g., AF_INET for IPv4)
char sa_data[14]; // Address data (actual size may vary)
};
POSIX style structure
struct sockaddr {
u_short sa_family; // Address family (e.g., AF_INET for IPv4)
char sa_data[14]; // Address data (actual size may vary)
};
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
The structure ofsockaddr_in6
, used for IPv6 sockets.static final class
The structure ofsockaddr_in
, used for IPv4 sockets.static final class
The structure ofsockaddr_ipx
, used for AF_IPX sockets.static final class
The structure ofsockaddr_irda
, used with AF_IRDA sockets on windows (winsock2.h) to access link-layer information.static final class
The structure ofsockaddr_dl
, used with AF_LINK sockets on macOS to access link-layer information.static final class
The structure ofsockaddr_ll
, used with AF_PACKET sockets for raw packet access on Linux. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
data()
Socket Address data (actual size may vary).int
family()
Address family (e.g., INET for IPv4)Gets the AF family value as a constant.boolean
isFamily
(SockAddrFamily family) Checks if this AF address is of specifc family type.toString()
String representation of the structure field values.The total length of the socket address structure in bytes.
-
Method Details
-
data
public byte[] data()Socket Address data (actual size may vary).- Returns:
- the byte array containing socket raw data
-
family
public int family()Address family (e.g., INET for IPv4)- Returns:
- 8 (BSD sockets) or 16 (Posix sockets) bit address family value
-
familyConstant
Gets the AF family value as a constant.- Returns:
- the socket address family constant
- Throws:
IllegalArgumentException
- thrown if the constant for the family value is not found.
-
isFamily
Checks if this AF address is of specifc family type.- Parameters:
family
- the AF family type- Returns:
- true, if address is of AF type specified
-
toString
String representation of the structure field values. -
totalLength
The total length of the socket address structure in bytes. The value is only returned on certain platforms (BSD style sockets)..- Returns:
- the length of the address structure if available on this particular platform
-