Merge "Netvirt - Neutron QoS rate limit support"
[netvirt.git] / vpnservice / aclservice / impl / src / main / java / org / opendaylight / netvirt / aclservice / utils / AclConstants.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netvirt.aclservice.utils;
10
11 import java.math.BigInteger;
12 import java.util.Collections;
13 import java.util.HashMap;
14 import java.util.Map;
15 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
16
17 /**
18  * The class to have ACL related constants.
19  */
20 public final class AclConstants {
21
22     public static final short INGRESS_ACL_DEFAULT_FLOW_PRIORITY = 1;
23     public static final short EGRESS_ACL_DEFAULT_FLOW_PRIORITY = 11;
24
25     public static final Integer PROTO_IPV6_DROP_PRIORITY = 63020;
26     public static final Integer PROTO_IPV6_ALLOWED_PRIORITY = 63010;
27     public static final Integer PROTO_DHCP_SERVER_MATCH_PRIORITY = 63010;
28     public static final Integer PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY = 63010;
29     public static final Integer PROTO_ARP_TRAFFIC_MATCH_PRIORITY = 63010;
30     public static final Integer PROTO_MATCH_PRIORITY = 61010;
31     public static final Integer PREFIX_MATCH_PRIORITY = 61009;
32     public static final Integer PROTO_PREFIX_MATCH_PRIORITY = 61008;
33     public static final Integer PROTO_PORT_MATCH_PRIORITY = 61007;
34     public static final Integer PROTO_PORT_PREFIX_MATCH_PRIORITY = 61007;
35     public static final Integer PROTO_MATCH_SYN_ALLOW_PRIORITY = 61005;
36     public static final Integer PROTO_MATCH_SYN_ACK_ALLOW_PRIORITY = 61004;
37     public static final Integer PROTO_MATCH_SYN_DROP_PRIORITY = 61003;
38     public static final Integer PROTO_VM_IP_MAC_MATCH_PRIORITY = 36001;
39     public static final Integer CT_STATE_UNTRACKED_PRIORITY = 62030;
40     public static final Integer CT_STATE_TRACKED_EXIST_PRIORITY = 62020;
41     public static final Integer CT_STATE_TRACKED_NEW_PRIORITY = 62010;
42     public static final Integer CT_STATE_NEW_PRIORITY_DROP = 36007;
43     public static final short DHCP_CLIENT_PORT_IPV4 = 68;
44     public static final short DHCP_SERVER_PORT_IPV4 = 67;
45     public static final short DHCP_CLIENT_PORT_IPV6 = 546;
46     public static final short DHCP_SERVER_PORT_IPV6 = 547;
47     public static final BigInteger COOKIE_ACL_BASE = new BigInteger("6900000", 16);
48
49     public static final int UNTRACKED_CT_STATE = 0x00;
50     public static final int TRACKED_CT_STATE = 0x20;
51     public static final int TRACKED_EST_CT_STATE = 0x22;
52     public static final int TRACKED_REL_CT_STATE = 0x24;
53     public static final int TRACKED_NEW_CT_STATE = 0x21;
54     public static final int TRACKED_INV_CT_STATE = 0x30;
55
56     public static final int UNTRACKED_CT_STATE_MASK = 0x20;
57     public static final int TRACKED_CT_STATE_MASK = 0x20;
58     public static final int TRACKED_EST_CT_STATE_MASK = 0x37;
59     public static final int TRACKED_REL_CT_STATE_MASK = 0x37;
60     public static final int TRACKED_NEW_CT_STATE_MASK = 0x21;
61     public static final int TRACKED_INV_CT_STATE_MASK = 0x30;
62
63     public static final String IPV4_ALL_NETWORK = "0.0.0.0/0";
64     public static final long TCP_FLAG_SYN = 1 << 1;
65     public static final long TCP_FLAG_ACK = 1 << 4;
66     public static final long TCP_FLAG_SYN_ACK = TCP_FLAG_SYN + TCP_FLAG_ACK;
67
68     public static final int ICMPV6_TYPE_MLD_QUERY = 130;
69     public static final int ICMPV6_TYPE_RS = 133;
70     public static final int ICMPV6_TYPE_RA = 134;
71     public static final int ICMPV6_TYPE_NS = 135;
72     public static final int ICMPV6_TYPE_NA = 136;
73     public static final int ICMPV6_TYPE_MLD2_REPORT = 143;
74
75     public static final BigInteger METADATA_MASK_LEARN_FLAG = new BigInteger("FFFFFFFFFFFFFFFE", 16);
76
77     public static final String SECURITY_GROUP_TCP_IDLE_TO_KEY = "security-group-tcp-idle-timeout";
78     public static final String SECURITY_GROUP_TCP_HARD_TO_KEY = "security-group-tcp-hard-timeout";
79     public static final String SECURITY_GROUP_TCP_FIN_IDLE_TO_KEY = "security-group-tcp-fin-idle-timeout";
80     public static final String SECURITY_GROUP_TCP_FIN_HARD_TO_KEY = "security-group-tcp-fin-hard-timeout";
81     public static final String SECURITY_GROUP_UDP_IDLE_TO_KEY = "security-group-udp-idle-timeout";
82     public static final String SECURITY_GROUP_UDP_HARD_TO_KEY = "security-group-udp-hard-timeout";
83
84     public static final String LEARN_MATCH_REG_VALUE = "1";
85
86     private AclConstants() {
87     }
88
89     private static Map<String, Object> globalConf = Collections.synchronizedMap(new HashMap<>());
90
91     public static String getGlobalConf(String key, String defaultValue) {
92         String ret = defaultValue;
93         String value = (String)globalConf.get(key);
94         if (value == null) {
95             String propertyStr = ConfigProperties.getProperty(AclConstants.class, key);
96             if (propertyStr != null) {
97                 ret = propertyStr;
98             }
99             globalConf.put(key, ret);
100         }
101         return ret;
102     }
103
104 }