1 /* ****************************************************************
3 * Copyright 2017 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 package org.iotivity.ca;
23 import java.util.EnumSet;
24 import java.security.InvalidParameterException;
26 public enum CaTransportFlags {
30 /** Insecure transport is the default (subject to change) */
31 CA_SECURE (1 << 4), // secure the transport path
33 /** IPv4 & IPv6 autoselection is the default */
34 CA_IPV6 (1 << 5), // IP adapter only
35 CA_IPV4 (1 << 6), // IP adapter only
37 /** Indication that a message was received by multicast. */
38 CA_MULTICAST (1 << 7),
40 /** Link-Local multicast is the default multicast scope for IPv6.
41 *These correspond in both value and position to the IPv6 address bits. */
42 CA_SCOPE_INTERFACE (0x1), // IPv6 Interface-Local scope
43 CA_SCOPE_LINK (0x2), // IPv6 Link-Local scope (default)
44 CA_SCOPE_REALM (0x3), // IPv6 Realm-Local scope
45 CA_SCOPE_ADMIN (0x4), // IPv6 Admin-Local scope
46 CA_SCOPE_SITE (0x5), // IPv6 Site-Local scope
47 CA_SCOPE_ORG (0x8), // IPv6 Organization-Local scope
48 CA_SCOPE_GLOBAL (0xE), // IPv6 Global scope
52 private CaTransportFlags(int value) {
56 public int getValue() {
60 public static EnumSet<CaTransportFlags> convertToEnumSet(int value) {
62 EnumSet<CaTransportFlags> typeSet = null;
63 for (CaTransportFlags v : values()) {
64 if (0 != (value & v.getValue())) {
65 if (null == typeSet) {
66 typeSet = EnumSet.of(v);
73 if (null == typeSet || typeSet.isEmpty()) {
74 throw new InvalidParameterException("Unexpected CaTransportFlag value:" + value);