From 9e4e43a29a22252cd183969f3ab710b8cff692fd Mon Sep 17 00:00:00 2001 From: lishuai Date: Thu, 26 Nov 2015 19:30:55 +0800 Subject: [PATCH] [ONOS-3473] Add the implementation of method programL3ExPortClassifierRules which assemble the L3 Classifier table rules sended from external port. Change-Id: I0d7975fa810792483869aa5977cc03cb868c0323 --- .../vtn/table/impl/ClassifierServiceImpl.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java index 1689c23b27..4c3b0f9bae 100644 --- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java +++ b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java @@ -20,7 +20,9 @@ import static org.slf4j.LoggerFactory.getLogger; import org.onlab.osgi.DefaultServiceDirectory; import org.onlab.osgi.ServiceDirectory; +import org.onlab.packet.Ethernet; import org.onlab.packet.IpAddress; +import org.onlab.packet.IpPrefix; import org.onlab.packet.MacAddress; import org.onosproject.core.ApplicationId; import org.onosproject.net.DeviceId; @@ -49,6 +51,7 @@ import com.google.common.collect.Sets; public class ClassifierServiceImpl implements ClassifierService { private final Logger log = getLogger(getClass()); + private static final int L3_CLAFFIFIER_PRIORITY = 0xffff; private static final int L2_CLAFFIFIER_PRIORITY = 50000; private final FlowObjectiveService flowObjectiveService; @@ -120,10 +123,24 @@ public class ClassifierServiceImpl implements ClassifierService { } @Override - public void programL3ExPortClassifierRules(DeviceId deviceId, - PortNumber exPort, - IpAddress fIp, Operation type) { - // TODO Auto-generated method stub + public void programL3ExPortClassifierRules(DeviceId deviceId, PortNumber inPort, + IpAddress dstIp, + Objective.Operation type) { + TrafficSelector selector = DefaultTrafficSelector.builder() + .matchEthType(Ethernet.TYPE_IPV4).matchInPort(inPort) + .matchIPDst(IpPrefix.valueOf(dstIp, 32)).build(); + TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); + ForwardingObjective.Builder objective = DefaultForwardingObjective + .builder().withTreatment(treatment).withSelector(selector) + .fromApp(appId).withFlag(Flag.SPECIFIC) + .withPriority(L3_CLAFFIFIER_PRIORITY); + if (type.equals(Objective.Operation.ADD)) { + log.debug("L3ExToInClassifierRules-->ADD"); + flowObjectiveService.forward(deviceId, objective.add()); + } else { + log.debug("L3ExToInClassifierRules-->REMOVE"); + flowObjectiveService.forward(deviceId, objective.remove()); + } } @Override