AFUNIXSocketCapability.java

  1. /*
  2.  * junixsocket
  3.  *
  4.  * Copyright 2009-2024 Christian Kohlschütter
  5.  *
  6.  * Licensed under the Apache License, Version 2.0 (the "License");
  7.  * you may not use this file except in compliance with the License.
  8.  * You may obtain a copy of the License at
  9.  *
  10.  *     http://www.apache.org/licenses/LICENSE-2.0
  11.  *
  12.  * Unless required by applicable law or agreed to in writing, software
  13.  * distributed under the License is distributed on an "AS IS" BASIS,
  14.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15.  * See the License for the specific language governing permissions and
  16.  * limitations under the License.
  17.  */
  18. package org.newsclub.net.unix;

  19. /**
  20.  * Describes junixsocket capabilities the current environment (system platform, native library,
  21.  * etc.) may or may not support.
  22.  *
  23.  * You can check whether your environment supports a given capability by calling
  24.  * {@link AFUNIXSocket#supports(AFUNIXSocketCapability)}.
  25.  *
  26.  * This enum is deprecated. Use {@link AFSocketCapability} instead.
  27.  *
  28.  * @see AFSocketCapability
  29.  */
  30. @Deprecated
  31. public enum AFUNIXSocketCapability {
  32.   // see org_newsclub_net_unix_NativeUnixSocket.c in junixsocket-native

  33.   /** Socket supports retrieving peer credentials. */
  34.   CAPABILITY_PEER_CREDENTIALS(0),

  35.   /** Socket supports sending and receiving ancillary messages. */
  36.   CAPABILITY_ANCILLARY_MESSAGES(1),

  37.   /** Socket supports passing file descriptors via ancillary messages. */
  38.   CAPABILITY_FILE_DESCRIPTORS(2),

  39.   /** Socket addressing supports the abstract namespace (Linux). */
  40.   CAPABILITY_ABSTRACT_NAMESPACE(3),

  41.   /** Support for AF_UNIX datagrams (not on Windows yet). */
  42.   CAPABILITY_DATAGRAMS(4),

  43.   /**
  44.    * A pair of interconnected sockets can be created natively.
  45.    *
  46.    * This currently not possible on Windows, but instead emulated via anonymous AF_INET ports when
  47.    * you use {@link AFUNIXSocketPair}.
  48.    */
  49.   CAPABILITY_NATIVE_SOCKETPAIR(5),

  50.   ; // end of list

  51.   private final int bitmask;

  52.   AFUNIXSocketCapability(int bit) {
  53.     this.bitmask = 1 << bit;
  54.   }

  55.   int getBitmask() {
  56.     return bitmask;
  57.   }
  58. }