lishuai
Committed by Gerrit Code Review

[ONOS-3473] Add the implementation of method

programL3ExPortClassifierRules which assemble the L3 Classifier table
rules sended from external port.

Change-Id: I0d7975fa810792483869aa5977cc03cb868c0323
...@@ -20,7 +20,9 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -20,7 +20,9 @@ import static org.slf4j.LoggerFactory.getLogger;
20 20
21 import org.onlab.osgi.DefaultServiceDirectory; 21 import org.onlab.osgi.DefaultServiceDirectory;
22 import org.onlab.osgi.ServiceDirectory; 22 import org.onlab.osgi.ServiceDirectory;
23 +import org.onlab.packet.Ethernet;
23 import org.onlab.packet.IpAddress; 24 import org.onlab.packet.IpAddress;
25 +import org.onlab.packet.IpPrefix;
24 import org.onlab.packet.MacAddress; 26 import org.onlab.packet.MacAddress;
25 import org.onosproject.core.ApplicationId; 27 import org.onosproject.core.ApplicationId;
26 import org.onosproject.net.DeviceId; 28 import org.onosproject.net.DeviceId;
...@@ -49,6 +51,7 @@ import com.google.common.collect.Sets; ...@@ -49,6 +51,7 @@ import com.google.common.collect.Sets;
49 public class ClassifierServiceImpl implements ClassifierService { 51 public class ClassifierServiceImpl implements ClassifierService {
50 private final Logger log = getLogger(getClass()); 52 private final Logger log = getLogger(getClass());
51 53
54 + private static final int L3_CLAFFIFIER_PRIORITY = 0xffff;
52 private static final int L2_CLAFFIFIER_PRIORITY = 50000; 55 private static final int L2_CLAFFIFIER_PRIORITY = 50000;
53 56
54 private final FlowObjectiveService flowObjectiveService; 57 private final FlowObjectiveService flowObjectiveService;
...@@ -120,10 +123,24 @@ public class ClassifierServiceImpl implements ClassifierService { ...@@ -120,10 +123,24 @@ public class ClassifierServiceImpl implements ClassifierService {
120 } 123 }
121 124
122 @Override 125 @Override
123 - public void programL3ExPortClassifierRules(DeviceId deviceId, 126 + public void programL3ExPortClassifierRules(DeviceId deviceId, PortNumber inPort,
124 - PortNumber exPort, 127 + IpAddress dstIp,
125 - IpAddress fIp, Operation type) { 128 + Objective.Operation type) {
126 - // TODO Auto-generated method stub 129 + TrafficSelector selector = DefaultTrafficSelector.builder()
130 + .matchEthType(Ethernet.TYPE_IPV4).matchInPort(inPort)
131 + .matchIPDst(IpPrefix.valueOf(dstIp, 32)).build();
132 + TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
133 + ForwardingObjective.Builder objective = DefaultForwardingObjective
134 + .builder().withTreatment(treatment).withSelector(selector)
135 + .fromApp(appId).withFlag(Flag.SPECIFIC)
136 + .withPriority(L3_CLAFFIFIER_PRIORITY);
137 + if (type.equals(Objective.Operation.ADD)) {
138 + log.debug("L3ExToInClassifierRules-->ADD");
139 + flowObjectiveService.forward(deviceId, objective.add());
140 + } else {
141 + log.debug("L3ExToInClassifierRules-->REMOVE");
142 + flowObjectiveService.forward(deviceId, objective.remove());
143 + }
127 } 144 }
128 145
129 @Override 146 @Override
......