blob: ccf730799c20a7b28b4d762c5afb40c0a5b0bb20 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
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 Dasd8b97002015-05-14 23:42:49 -070016package org.onosproject.driver.pipeline;
17
18import static org.slf4j.LoggerFactory.getLogger;
19
20import org.onlab.packet.Ethernet;
21import org.onosproject.net.flow.DefaultFlowRule;
22import org.onosproject.net.flow.DefaultTrafficSelector;
23import org.onosproject.net.flow.DefaultTrafficTreatment;
24import org.onosproject.net.flow.FlowRule;
25import org.onosproject.net.flow.FlowRuleOperations;
26import org.onosproject.net.flow.FlowRuleOperationsContext;
27import org.onosproject.net.flow.TrafficSelector;
28import org.onosproject.net.flow.TrafficTreatment;
29import org.slf4j.Logger;
30
Saurav Dasdecd7a62015-05-16 22:39:47 -070031/**
32 * Driver for Corsa TTP.
33 *
34 */
Saurav Dasd8b97002015-05-14 23:42:49 -070035public 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 Dasd8b97002015-05-14 23:42:49 -070059 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}