java.lang.Object
java.lang.Enum<FamilyAndTransport>
org.apache.sshd.contrib.server.session.proxyprotocolv2.data.FamilyAndTransport
All Implemented Interfaces:
Serializable, Comparable<FamilyAndTransport>

public enum FamilyAndTransport extends Enum<FamilyAndTransport>
Family and Transport Enumeration.

The 14th byte contains the transport protocol and address family. The highest 4 bits contain the address family, the lowest 4 bits contain the protocol.

The address family maps to the original socket family without necessarily matching the values internally used by the system. It may be one of : - 0x0 : AF_UNSPEC : the connection is forwarded for an unknown, unspecified or unsupported protocol. The sender should use this family when sending LOCAL commands or when dealing with unsupported protocol families. The receiver is free to accept the connection anyway and use the real endpoint addresses or to reject it. The receiver should ignore address information. - 0x1 : AF_INET : the forwarded connection uses the AF_INET address family (IPv4). The addresses are exactly 4 bytes each in network byte order, followed by transport protocol information (typically ports). - 0x2 : AF_INET6 : the forwarded connection uses the AF_INET6 address family (IPv6). The addresses are exactly 16 bytes each in network byte order, followed by transport protocol information (typically ports). - 0x3 : AF_UNIX : the forwarded connection uses the AF_UNIX address family (UNIX). The addresses are exactly 108 bytes each. - other values are unspecified and must not be emitted in version 2 of this protocol and must be rejected as invalid by receivers.

The transport protocol is specified in the lowest 4 bits of the 14th byte : - 0x0 : UNSPEC : the connection is forwarded for an unknown, unspecified or unsupported protocol. The sender should use this family when sending LOCAL commands or when dealing with unsupported protocol families. The receiver is free to accept the connection anyway and use the real endpoint addresses or to reject it. The receiver should ignore address information. - 0x1 : STREAM : the forwarded connection uses a SOCK_STREAM protocol (eg: TCP or UNIX_STREAM). When used with AF_INET/AF_INET6 (TCP), the addresses are followed by the source and destination ports represented on 2 bytes each in network byte order. - 0x2 : DGRAM : the forwarded connection uses a SOCK_DGRAM protocol (eg: UDP or UNIX_DGRAM). When used with AF_INET/AF_INET6 (UDP), the addresses are followed by the source and destination ports represented on 2 bytes each in network byte order. - other values are unspecified and must not be emitted in version 2 of this protocol and must be rejected as invalid by receivers.

In practice, the following protocol bytes are expected : - \x00 : UNSPEC : the connection is forwarded for an unknown, unspecified or unsupported protocol. The sender should use this family when sending LOCAL commands or when dealing with unsupported protocol families. When used with a LOCAL command, the receiver must accept the connection and ignore any address information. For other commands, the receiver is free to accept the connection anyway and use the real endpoints addresses or to reject the connection. The receiver should ignore address information. - \x11 : TCP over IPv4 : the forwarded connection uses TCP over the AF_INET protocol family. Address length is 2*4 + 2*2 = 12 bytes. - \x12 : UDP over IPv4 : the forwarded connection uses UDP over the AF_INET protocol family. Address length is 2*4 + 2*2 = 12 bytes. - \x21 : TCP over IPv6 : the forwarded connection uses TCP over the AF_INET6 protocol family. Address length is 2*16 + 2*2 = 36 bytes. - \x22 : UDP over IPv6 : the forwarded connection uses UDP over the AF_INET6 protocol family. Address length is 2*16 + 2*2 = 36 bytes. - \x31 : UNIX stream : the forwarded connection uses SOCK_STREAM over the AF_UNIX protocol family. Address length is 2*108 = 216 bytes. - \x32 : UNIX datagram : the forwarded connection uses SOCK_DGRAM over the AF_UNIX protocol family. Address length is 2*108 = 216 bytes.

Only the UNSPEC protocol byte (\x00) is mandatory to implement on the receiver. A receiver is not required to implement other ones, provided that it automatically falls back to the UNSPEC mode for the valid combinations above that it does not support.

  • Enum Constant Details

  • Field Details

    • value

      private final byte value
    • addressLength

      private final int addressLength
    • portLength

      private final int portLength
  • Constructor Details

    • FamilyAndTransport

      private FamilyAndTransport(byte value, int addressLength, int portLength)
  • Method Details

    • values

      public static FamilyAndTransport[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static FamilyAndTransport valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
      NullPointerException - if the argument is null
    • extractValue

      public static FamilyAndTransport extractValue(org.slf4j.Logger logger, org.apache.sshd.server.session.ServerSession session, org.apache.sshd.common.util.buffer.Buffer buffer) throws ProxyProtocolException
      Throws:
      ProxyProtocolException
    • getAddressLength

      public int getAddressLength()
    • getDataLength

      public int getDataLength()
    • hasInetAddress

      public boolean hasInetAddress()
    • hasPort

      public boolean hasPort()
    • hasSockAddress

      public boolean hasSockAddress()