blob: 9e85def08ac3dd11cff1e4d2001060fd2de0c385 [file] [log] [blame]
sanghoc0b3c342015-03-12 17:12:10 -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 */
16package org.onosproject.openflow.drivers;
17
sanghoc0b3c342015-03-12 17:12:10 -070018import org.onosproject.openflow.controller.Dpid;
19import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
sanghoc0b3c342015-03-12 17:12:10 -070020import org.projectfloodlight.openflow.protocol.OFMessage;
Saurav Das3ea46622015-04-22 14:01:34 -070021/*import com.google.common.collect.Lists;
22import org.projectfloodlight.openflow.protocol.OFFlowMod;
sanghoc0b3c342015-03-12 17:12:10 -070023import org.projectfloodlight.openflow.protocol.OFType;
24import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
25import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable;
26import org.projectfloodlight.openflow.types.TableId;
sanghoc0b3c342015-03-12 17:12:10 -070027import java.util.List;
Saurav Das3ea46622015-04-22 14:01:34 -070028*/
29import java.util.Collections;
sanghoc0b3c342015-03-12 17:12:10 -070030
31public class OFOVSSwitchCorsaTTP extends OFCorsaSwitchDriver {
32
33 OFOVSSwitchCorsaTTP(Dpid dpid, OFDescStatsReply desc) {
34 super(dpid, desc);
35 }
36
37 @Override
38 public void transformAndSendMsg(OFMessage msg, TableType type) {
Saurav Das3ea46622015-04-22 14:01:34 -070039 /*log.trace("Trying to send {} of TableType {}", msg, type);
sanghoc0b3c342015-03-12 17:12:10 -070040 if (msg.getType() == OFType.FLOW_MOD) {
41 OFFlowMod flowMod = (OFFlowMod) msg;
42 OFFlowMod.Builder builder = flowMod.createBuilder();
43 List<OFInstruction> instructions = flowMod.getInstructions();
44 List<OFInstruction> newInstructions = Lists.newArrayList();
45 for (OFInstruction i : instructions) {
46 if (i instanceof OFInstructionGotoTable) {
47 OFInstructionGotoTable gotoTable = (OFInstructionGotoTable) i;
48 TableType tid = TableType.values()[gotoTable.getTableId().getValue()];
49 switch (tid) {
50 case VLAN_MPLS:
51 newInstructions.add(
52 gotoTable.createBuilder()
53 .setTableId(TableId.of(VLAN_MPLS_TABLE)).build());
54 break;
55 case VLAN:
56 newInstructions.add(
57 gotoTable.createBuilder()
58 .setTableId(TableId.of(VLAN_TABLE)).build());
59 break;
60 case ETHER:
61 newInstructions.add(
62 gotoTable.createBuilder()
63 .setTableId(TableId.of(ETHER_TABLE)).build());
64 break;
65 case COS:
66 newInstructions.add(
67 gotoTable.createBuilder()
68 .setTableId(TableId.of(COS_MAP_TABLE)).build());
69 break;
70 case IP:
71 newInstructions.add(
72 gotoTable.createBuilder()
73 .setTableId(TableId.of(FIB_TABLE)).build());
74 break;
75 case MPLS:
76 newInstructions.add(
77 gotoTable.createBuilder()
78 .setTableId(TableId.of(MPLS_TABLE)).build());
79 break;
80 case ACL:
81 newInstructions.add(
82 gotoTable.createBuilder()
83 .setTableId(TableId.of(LOCAL_TABLE)).build());
84 break;
85 case NONE:
86 log.error("Should never have to go to Table 0");
Saurav Das3ea46622015-04-22 14:01:34 -070087 newInstructions.add(
sanghoc0b3c342015-03-12 17:12:10 -070088 gotoTable.createBuilder()
89 .setTableId(TableId.of(0)).build());
Saurav Das3ea46622015-04-22 14:01:34 -070090
sanghoc0b3c342015-03-12 17:12:10 -070091 break;
92 default:
93 log.warn("Unknown table type: {}", tid);
94 }
95 } else {
96 newInstructions.add(i);
97 }
98 }
99 switch (type) {
100 case VLAN_MPLS:
101 builder.setTableId(TableId.of(VLAN_MPLS_TABLE));
102 break;
103 case VLAN:
104 builder.setTableId(TableId.of(VLAN_TABLE));
105 break;
106 case ETHER:
107 builder.setTableId(TableId.of(ETHER_TABLE));
108 break;
109 case COS:
110 builder.setTableId(TableId.of(COS_MAP_TABLE));
111 break;
112 case IP:
113 builder.setTableId(TableId.of(FIB_TABLE));
114 break;
115 case MPLS:
116 builder.setTableId(TableId.of(MPLS_TABLE));
117 break;
118 case ACL:
119 builder.setTableId(TableId.of(LOCAL_TABLE));
120 break;
121 case FIRST:
122 builder.setTableId(TableId.of(FIRST_TABLE));
123 break;
124 case NONE:
125 builder.setTableId(TableId.of(LOCAL_TABLE));
126 break;
127 default:
128 log.warn("Unknown table type: {}", type);
129 }
130 builder.setInstructions(newInstructions);
131 OFMessage msgnew = builder.build();
132 channel.write(Collections.singletonList(msgnew));
133 log.debug("Installed {}", msgnew);
134
135 } else {
136 channel.write(Collections.singletonList(msg));
Saurav Das3ea46622015-04-22 14:01:34 -0700137 }*/
138 channel.write(Collections.singletonList(msg));
sanghoc0b3c342015-03-12 17:12:10 -0700139 }
140}