Committed by
Gerrit Code Review
[ONOS-3475] Add the implementation of method programArpClassifierRules
which assemble the Arp Classifier table rules. Change-Id: Ic4bebc1035cf2a22ee9c86cf51ecc68719a0c94f
Showing
1 changed file
with
25 additions
and
4 deletions
| ... | @@ -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.EthType.EtherType; | ||
| 23 | import org.onlab.packet.Ethernet; | 24 | import org.onlab.packet.Ethernet; |
| 25 | +import org.onlab.packet.Ip4Address; | ||
| 24 | import org.onlab.packet.IpAddress; | 26 | import org.onlab.packet.IpAddress; |
| 25 | import org.onlab.packet.IpPrefix; | 27 | import org.onlab.packet.IpPrefix; |
| 26 | import org.onlab.packet.MacAddress; | 28 | import org.onlab.packet.MacAddress; |
| ... | @@ -38,7 +40,6 @@ import org.onosproject.net.flowobjective.FlowObjectiveService; | ... | @@ -38,7 +40,6 @@ import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 38 | import org.onosproject.net.flowobjective.ForwardingObjective; | 40 | import org.onosproject.net.flowobjective.ForwardingObjective; |
| 39 | import org.onosproject.net.flowobjective.ForwardingObjective.Flag; | 41 | import org.onosproject.net.flowobjective.ForwardingObjective.Flag; |
| 40 | import org.onosproject.net.flowobjective.Objective; | 42 | import org.onosproject.net.flowobjective.Objective; |
| 41 | -import org.onosproject.net.flowobjective.Objective.Operation; | ||
| 42 | import org.onosproject.vtn.table.ClassifierService; | 43 | import org.onosproject.vtn.table.ClassifierService; |
| 43 | import org.onosproject.vtnrsc.SegmentationId; | 44 | import org.onosproject.vtnrsc.SegmentationId; |
| 44 | import org.slf4j.Logger; | 45 | import org.slf4j.Logger; |
| ... | @@ -51,6 +52,8 @@ import com.google.common.collect.Sets; | ... | @@ -51,6 +52,8 @@ import com.google.common.collect.Sets; |
| 51 | public class ClassifierServiceImpl implements ClassifierService { | 52 | public class ClassifierServiceImpl implements ClassifierService { |
| 52 | private final Logger log = getLogger(getClass()); | 53 | private final Logger log = getLogger(getClass()); |
| 53 | 54 | ||
| 55 | + private static final EtherType ETH_TYPE = EtherType.ARP; | ||
| 56 | + private static final int ARP_CLAFFIFIER_PRIORITY = 60000; | ||
| 54 | private static final int L3_CLAFFIFIER_PRIORITY = 0xffff; | 57 | private static final int L3_CLAFFIFIER_PRIORITY = 0xffff; |
| 55 | private static final int L2_CLAFFIFIER_PRIORITY = 50000; | 58 | private static final int L2_CLAFFIFIER_PRIORITY = 50000; |
| 56 | 59 | ||
| ... | @@ -167,9 +170,27 @@ public class ClassifierServiceImpl implements ClassifierService { | ... | @@ -167,9 +170,27 @@ public class ClassifierServiceImpl implements ClassifierService { |
| 167 | } | 170 | } |
| 168 | 171 | ||
| 169 | @Override | 172 | @Override |
| 170 | - public void programArpClassifierRules(DeviceId deviceId, IpAddress srcGwIp, | 173 | + public void programArpClassifierRules(DeviceId deviceId, IpAddress dstIp, |
| 171 | - SegmentationId srcVni, Operation type) { | 174 | + SegmentationId actionVni, |
| 172 | - // TODO Auto-generated method stub | 175 | + Objective.Operation type) { |
| 176 | + TrafficSelector selector = DefaultTrafficSelector.builder() | ||
| 177 | + .matchEthType(ETH_TYPE.ethType().toShort()) | ||
| 178 | + .matchArpTpa(Ip4Address.valueOf(dstIp.toString())) | ||
| 179 | + .build(); | ||
| 180 | + TrafficTreatment treatment = DefaultTrafficTreatment.builder() | ||
| 181 | + .setTunnelId(Long.parseLong(actionVni.segmentationId())) | ||
| 182 | + .build(); | ||
| 183 | + ForwardingObjective.Builder objective = DefaultForwardingObjective | ||
| 184 | + .builder().withTreatment(treatment).withSelector(selector) | ||
| 185 | + .fromApp(appId).withFlag(Flag.SPECIFIC) | ||
| 186 | + .withPriority(ARP_CLAFFIFIER_PRIORITY); | ||
| 187 | + if (type.equals(Objective.Operation.ADD)) { | ||
| 188 | + log.debug("ArpClassifierRules-->ADD"); | ||
| 189 | + flowObjectiveService.forward(deviceId, objective.add()); | ||
| 190 | + } else { | ||
| 191 | + log.debug("ArpClassifierRules-->REMOVE"); | ||
| 192 | + flowObjectiveService.forward(deviceId, objective.remove()); | ||
| 193 | + } | ||
| 173 | } | 194 | } |
| 174 | 195 | ||
| 175 | } | 196 | } | ... | ... |
-
Please register or login to post a comment