Moved PI constants to separate class
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/SpgwPiConstants.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/SpgwPiConstants.java
new file mode 100644
index 0000000..5dac361
--- /dev/null
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/SpgwPiConstants.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.fpcagent;
+
+import org.onosproject.net.pi.model.PiActionId;
+import org.onosproject.net.pi.model.PiActionParamId;
+import org.onosproject.net.pi.model.PiMatchFieldId;
+import org.onosproject.net.pi.model.PiTableId;
+import org.onosproject.net.pi.runtime.PiAction;
+
+public class SpgwPiConstants {
+ public static final PiTableId TBL_ID_UE_FILTER = PiTableId
+ .of("spgw_ingress.ue_filter_table");
+ public static final PiTableId TBL_ID_S1U_FILTER = PiTableId
+ .of("spgw_ingress.s1u_filter_table");
+ public static final PiTableId TBL_ID_DL_SESS_LOOKUP = PiTableId
+ .of("spgw_ingress.dl_sess_lookup");
+ public static final PiMatchFieldId MF_ID_IPV4_DST = PiMatchFieldId
+ .of("ipv4.dst_addr");
+ public static final PiMatchFieldId MF_ID_S1U_SGW_ADDR = PiMatchFieldId
+ .of("spgw_meta.s1u_sgw_addr");
+ public static final PiActionId ACT_ID_SET_DL_SESS_INFO = PiActionId
+ .of("spgw_ingress.set_dl_sess_info");
+ public static final PiActionParamId TEID = PiActionParamId
+ .of("teid");
+ public static final PiActionParamId PARAM_S1U_ENB_ADDR = PiActionParamId
+ .of("s1u_enb_addr");
+ public static final PiActionParamId PARAM_ID_S1U_SGW_ADDR = PiActionParamId
+ .of("s1u_sgw_addr");
+ public static final PiAction NO_ACTION = PiAction.builder()
+ .withId(PiActionId.of("NoAction"))
+ .build();
+}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
index e5433f2..c274b83 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
@@ -22,6 +22,7 @@
import org.onlab.packet.Ip4Address;
import org.onlab.util.ImmutableByteSequence;
import org.onosproject.core.ApplicationId;
+import org.onosproject.fpcagent.SpgwPiConstants;
import org.onosproject.net.DeviceId;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
@@ -31,10 +32,6 @@
import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.flow.criteria.PiCriterion;
import org.onosproject.net.intf.InterfaceAdminService;
-import org.onosproject.net.pi.model.PiActionId;
-import org.onosproject.net.pi.model.PiActionParamId;
-import org.onosproject.net.pi.model.PiMatchFieldId;
-import org.onosproject.net.pi.model.PiTableId;
import org.onosproject.net.pi.runtime.PiAction;
import org.onosproject.net.pi.runtime.PiActionParam;
import org.onosproject.routeservice.Route;
@@ -66,31 +63,6 @@
private final Logger log = LoggerFactory.getLogger(getClass());
- public static final PiTableId TBL_ID_UE_FILTER = PiTableId
- .of("spgw_ingress.ue_filter_table");
- public static final PiTableId TBL_ID_S1U_FILTER = PiTableId
- .of("spgw_ingress.s1u_filter_table");
- public static final PiTableId TBL_ID_DL_SESS_LOOKUP = PiTableId
- .of("spgw_ingress.dl_sess_lookup");
-
- public static final PiMatchFieldId MF_ID_IPV4_DST = PiMatchFieldId
- .of("ipv4.dst_addr");
- public static final PiMatchFieldId MF_ID_S1U_SGW_ADDR = PiMatchFieldId
- .of("spgw_meta.s1u_sgw_addr");
-
- public static final PiActionId ACT_ID_SET_DL_SESS_INFO = PiActionId
- .of("spgw_ingress.set_dl_sess_info");
- public static final PiActionParamId TEID = PiActionParamId
- .of("teid");
- public static final PiActionParamId PARAM_S1U_ENB_ADDR = PiActionParamId
- .of("s1u_enb_addr");
- public static final PiActionParamId PARAM_ID_S1U_SGW_ADDR = PiActionParamId
- .of("s1u_sgw_addr");
-
- public static final PiAction NO_ACTION = PiAction.builder()
- .withId(PiActionId.of("NoAction"))
- .build();
-
private static final ConcurrentMap<Long, Ip4Address> UE_ADDRESSES =
Maps.newConcurrentMap();
private static final ConcurrentMap<Long, Set<FlowRule>> FLOWS =
@@ -314,32 +286,32 @@
private FlowRule ueFilterRule(Ip4Address ueAddr) {
final PiCriterion piCriterion = PiCriterion.builder()
- .matchLpm(MF_ID_IPV4_DST, ueAddr.toOctets(), 32)
+ .matchLpm(SpgwPiConstants.MF_ID_IPV4_DST, ueAddr.toOctets(), 32)
.build();
return flowRuleBuilder()
- .forTable(TBL_ID_UE_FILTER)
+ .forTable(SpgwPiConstants.TBL_ID_UE_FILTER)
.withSelector(DefaultTrafficSelector.builder()
.matchPi(piCriterion)
.build())
.withTreatment(DefaultTrafficTreatment.builder()
- .piTableAction(NO_ACTION)
+ .piTableAction(SpgwPiConstants.NO_ACTION)
.build())
.build();
}
private FlowRule s1uFilterRule(Ip4Address s1uAddr) {
final PiCriterion piCriterion = PiCriterion.builder()
- .matchExact(MF_ID_S1U_SGW_ADDR, s1uAddr.toOctets())
+ .matchExact(SpgwPiConstants.MF_ID_S1U_SGW_ADDR, s1uAddr.toOctets())
.build();
return flowRuleBuilder()
- .forTable(TBL_ID_S1U_FILTER)
+ .forTable(SpgwPiConstants.TBL_ID_S1U_FILTER)
.withSelector(DefaultTrafficSelector.builder()
.matchPi(piCriterion)
.build())
.withTreatment(DefaultTrafficTreatment.builder()
- .piTableAction(NO_ACTION)
+ .piTableAction(SpgwPiConstants.NO_ACTION)
.build())
.build();
}
@@ -356,20 +328,20 @@
// Add rule to
final PiAction action = PiAction.builder()
- .withId(ACT_ID_SET_DL_SESS_INFO)
- .withParameter(new PiActionParam(TEID, revTeidBs))
- .withParameter(new PiActionParam(PARAM_S1U_ENB_ADDR,
+ .withId(SpgwPiConstants.ACT_ID_SET_DL_SESS_INFO)
+ .withParameter(new PiActionParam(SpgwPiConstants.TEID, revTeidBs))
+ .withParameter(new PiActionParam(SpgwPiConstants.PARAM_S1U_ENB_ADDR,
copyFrom(enbAddr.toOctets())))
- .withParameter(new PiActionParam(PARAM_ID_S1U_SGW_ADDR,
+ .withParameter(new PiActionParam(SpgwPiConstants.PARAM_ID_S1U_SGW_ADDR,
copyFrom(s1uAddr.toOctets())))
.build();
final PiCriterion piCriterion = PiCriterion.builder()
- .matchExact(MF_ID_IPV4_DST, ueAddr.toOctets())
+ .matchExact(SpgwPiConstants.MF_ID_IPV4_DST, ueAddr.toOctets())
.build();
return flowRuleBuilder()
- .forTable(TBL_ID_DL_SESS_LOOKUP)
+ .forTable(SpgwPiConstants.TBL_ID_DL_SESS_LOOKUP)
.withSelector(DefaultTrafficSelector.builder()
.matchPi(piCriterion)
.build())