Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Saurav Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 16 | package org.onosproject.driver.pipeline; |
| 17 | |
| 18 | import static org.slf4j.LoggerFactory.getLogger; |
| 19 | |
| 20 | import org.onlab.packet.Ethernet; |
| 21 | import org.onosproject.net.flow.DefaultFlowRule; |
| 22 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 23 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 24 | import org.onosproject.net.flow.FlowRule; |
| 25 | import org.onosproject.net.flow.FlowRuleOperations; |
| 26 | import org.onosproject.net.flow.FlowRuleOperationsContext; |
| 27 | import org.onosproject.net.flow.TrafficSelector; |
| 28 | import org.onosproject.net.flow.TrafficTreatment; |
| 29 | import org.slf4j.Logger; |
| 30 | |
Saurav Das | decd7a6 | 2015-05-16 22:39:47 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Driver for Corsa TTP. |
| 33 | * |
| 34 | */ |
Saurav Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 35 | public class CorsaPipeline extends OVSCorsaPipeline { |
| 36 | |
| 37 | private final Logger log = getLogger(getClass()); |
| 38 | |
| 39 | @Override |
| 40 | protected void processVlanMplsTable(boolean install) { |
| 41 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
| 42 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment |
| 43 | .builder(); |
| 44 | FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
| 45 | FlowRule rule; |
| 46 | // corsa uses non-OF-standard way to match on presence of VLAN tags |
| 47 | selector.matchEthType(Ethernet.TYPE_VLAN); |
| 48 | treatment.transition(VLAN_TABLE); |
| 49 | |
| 50 | rule = DefaultFlowRule.builder() |
| 51 | .forDevice(deviceId) |
| 52 | .withSelector(selector.build()) |
| 53 | .withTreatment(treatment.build()) |
| 54 | .withPriority(CONTROLLER_PRIORITY) |
| 55 | .fromApp(appId) |
| 56 | .makePermanent() |
| 57 | .forTable(VLAN_MPLS_TABLE).build(); |
| 58 | |
Saurav Das | d8b9700 | 2015-05-14 23:42:49 -0700 | [diff] [blame] | 59 | ops = install ? ops.add(rule) : ops.remove(rule); |
| 60 | |
| 61 | flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { |
| 62 | @Override |
| 63 | public void onSuccess(FlowRuleOperations ops) { |
| 64 | log.info("Provisioned vlan/mpls table"); |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void onError(FlowRuleOperations ops) { |
| 69 | log.info( |
| 70 | "Failed to provision vlan/mpls table"); |
| 71 | } |
| 72 | })); |
| 73 | |
| 74 | } |
| 75 | |
| 76 | } |