blob: fd2316d7cf9d9c44ee2f43360fed10fdbebcca42 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.openflow.controller;
tom7ef8ff92014-09-17 13:08:06 -070017
18import java.util.List;
19
20import org.projectfloodlight.openflow.protocol.OFFactory;
21import org.projectfloodlight.openflow.protocol.OFMessage;
22import org.projectfloodlight.openflow.protocol.OFPortDesc;
Saurav Dasfa2fa932015-03-03 11:29:48 -080023import org.projectfloodlight.openflow.types.TableId;
tom7ef8ff92014-09-17 13:08:06 -070024
25/**
26 * Represents to provider facing side of a switch.
27 */
28public interface OpenFlowSwitch {
29
30 /**
sangho11c30ac2015-01-22 14:30:55 -080031 * The TableType is used to determine in which table (TableID) each flow rule
32 * needs to be put for multi-table support switch.
33 * It is used only for multi-table support switch.
34 */
35 public static enum TableType {
alshabib9af70072015-02-09 14:34:16 -080036 /* VLAN-to-MPLS table */
37 VLAN_MPLS,
38
39 /* VLAN table */
40 VLAN,
41
Saurav Dasfa2fa932015-03-03 11:29:48 -080042 /* Ethertype table */
alshabib9af70072015-02-09 14:34:16 -080043 ETHER,
44
45 /* Class of Service table */
46 COS,
47
sangho11c30ac2015-01-22 14:30:55 -080048 /* IP table */
49 IP,
50 /* MPLS table */
51 MPLS,
52 /* ACL table */
53 ACL,
54 /* Single table */
55 NONE,
Saurav Dasfa2fa932015-03-03 11:29:48 -080056 /* First table in multi-table */
57 FIRST,
alshabib9af70072015-02-09 14:34:16 -080058
59
sangho11c30ac2015-01-22 14:30:55 -080060 }
61
62 /**
tom7ef8ff92014-09-17 13:08:06 -070063 * Writes the message to the driver.
64 *
65 * @param msg the message to write
66 */
67 public void sendMsg(OFMessage msg);
68
69 /**
Saurav Dasfa2fa932015-03-03 11:29:48 -080070 * Writes the OFMessage list to the driver.
tom7ef8ff92014-09-17 13:08:06 -070071 *
72 * @param msgs the messages to be written
73 */
74 public void sendMsg(List<OFMessage> msgs);
75
76 /**
Saurav Dasfa2fa932015-03-03 11:29:48 -080077 * Transforms FlowMod messages by setting the correct table-ids and sending
78 * them to the switch. TableType is used to determine the table ID for the OFMessage.
79 * Switch drivers that supports multi-table pipelines should implement this
80 * method.
sangho11c30ac2015-01-22 14:30:55 -080081 *
82 * @param msg the message to be written
Saurav Dasfa2fa932015-03-03 11:29:48 -080083 * @param tableType the type of table in which the FlowMods need to be inserted
sangho11c30ac2015-01-22 14:30:55 -080084 */
Saurav Dasfa2fa932015-03-03 11:29:48 -080085 public void transformAndSendMsg(OFMessage msg, TableType tableType);
sangho11c30ac2015-01-22 14:30:55 -080086
87 /**
tom7ef8ff92014-09-17 13:08:06 -070088 * Handle a message from the switch.
89 * @param fromSwitch the message to handle
90 */
91 public void handleMessage(OFMessage fromSwitch);
92
93 /**
94 * Sets the role for this switch.
95 * @param role the role to set.
96 */
97 public void setRole(RoleState role);
98
99 /**
100 * Fetch the role for this switch.
101 * @return the role.
102 */
103 public RoleState getRole();
104
105 /**
106 * Fetches the ports of this switch.
107 * @return unmodifiable list of the ports.
108 */
109 public List<OFPortDesc> getPorts();
110
111 /**
112 * Provides the factory for this OF version.
113 * @return OF version specific factory.
114 */
115 public OFFactory factory();
116
117 /**
118 * Gets a string version of the ID for this switch.
119 *
120 * @return string version of the ID
121 */
122 public String getStringId();
123
124 /**
125 * Gets the datapathId of the switch.
126 *
127 * @return the switch dpid in long format
128 */
129 public long getId();
130
131 /**
132 * fetch the manufacturer description.
133 * @return the description
134 */
Ray Milkeyd3edd032015-01-16 11:38:58 -0800135 public String manufacturerDescription();
tom7ef8ff92014-09-17 13:08:06 -0700136
137 /**
138 * fetch the datapath description.
139 * @return the description
140 */
141 public String datapathDescription();
142
143 /**
144 * fetch the hardware description.
145 * @return the description
146 */
147 public String hardwareDescription();
148
149 /**
150 * fetch the software description.
151 * @return the description
152 */
153 public String softwareDescription();
154
155 /**
156 * fetch the serial number.
157 * @return the serial
158 */
159 public String serialNumber();
160
161 /**
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700162 * Checks if the switch is still connected.
163 *
164 * @return whether the switch is still connected
165 */
166 public boolean isConnected();
167
168 /**
tom7ef8ff92014-09-17 13:08:06 -0700169 * Disconnects the switch by closing the TCP connection. Results in a call
170 * to the channel handler's channelDisconnected method for cleanup
171 */
172 public void disconnectSwitch();
173
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700174 /**
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700175 * Notifies the controller that the device has responded to a set-role request.
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700176 *
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700177 * @param requested the role requested by the controller
178 * @param response the role set at the device
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700179 */
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800180 public void returnRoleReply(RoleState requested, RoleState response);
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700181
182 /**
183 * Indicates if this switch is optical.
184 *
185 * @return true if optical
186 */
187 public boolean isOptical();
188
Ray Milkeye53f1712015-01-16 09:17:16 -0800189 /**
190 * Identifies the channel used to communicate with the switch.
Ray Milkeyf25d1352015-01-23 15:14:08 -0800191 *
192 * @return string representation of the connection to the device
Ray Milkeye53f1712015-01-16 09:17:16 -0800193 */
194 public String channelId();
195
Saurav Dasfa2fa932015-03-03 11:29:48 -0800196 /**
197 * Returns the TableType corresponding to the TableId used to identify
198 * a table in an OpenFlow switch.
199 * @param tid identifies a table in an OpenFlow switch using TableId
200 * @return TableType corresponding to 'tid' identifying the type of table
201 */
202 public TableType getTableType(TableId tid);
tom7ef8ff92014-09-17 13:08:06 -0700203}