blob: a400b8ee3b0c9ba3511a7c32048ae80afb5ed46c [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;
23
24/**
25 * Represents to provider facing side of a switch.
26 */
27public interface OpenFlowSwitch {
28
29 /**
sangho11c30ac2015-01-22 14:30:55 -080030 * The TableType is used to determine in which table (TableID) each flow rule
31 * needs to be put for multi-table support switch.
32 * It is used only for multi-table support switch.
33 */
34 public static enum TableType {
alshabib9af70072015-02-09 14:34:16 -080035 /* VLAN-to-MPLS table */
36 VLAN_MPLS,
37
38 /* VLAN table */
39 VLAN,
40
41 /* L2 table */
42 ETHER,
43
44 /* Class of Service table */
45 COS,
46
sangho11c30ac2015-01-22 14:30:55 -080047 /* IP table */
48 IP,
49 /* MPLS table */
50 MPLS,
51 /* ACL table */
52 ACL,
53 /* Single table */
54 NONE,
alshabib9af70072015-02-09 14:34:16 -080055
56
sangho11c30ac2015-01-22 14:30:55 -080057 }
58
59 /**
tom7ef8ff92014-09-17 13:08:06 -070060 * Writes the message to the driver.
61 *
62 * @param msg the message to write
63 */
64 public void sendMsg(OFMessage msg);
65
66 /**
67 * Writes to the OFMessage list to the driver.
68 *
69 * @param msgs the messages to be written
70 */
71 public void sendMsg(List<OFMessage> msgs);
72
73 /**
sangho11c30ac2015-01-22 14:30:55 -080074 * Writes to the OFMessage list to the driver.
75 * TableType is used to determine the table ID for the OFMessage.
76 * The switch driver that supports multi-table should implement the function.
77 *
78 * @param msg the message to be written
79 * @param tableType the type of table in which the OFMessage needs to put
80 */
81 public void sendMsg(OFMessage msg, TableType tableType);
82
83 /**
tom7ef8ff92014-09-17 13:08:06 -070084 * Handle a message from the switch.
85 * @param fromSwitch the message to handle
86 */
87 public void handleMessage(OFMessage fromSwitch);
88
89 /**
90 * Sets the role for this switch.
91 * @param role the role to set.
92 */
93 public void setRole(RoleState role);
94
95 /**
96 * Fetch the role for this switch.
97 * @return the role.
98 */
99 public RoleState getRole();
100
101 /**
102 * Fetches the ports of this switch.
103 * @return unmodifiable list of the ports.
104 */
105 public List<OFPortDesc> getPorts();
106
107 /**
108 * Provides the factory for this OF version.
109 * @return OF version specific factory.
110 */
111 public OFFactory factory();
112
113 /**
114 * Gets a string version of the ID for this switch.
115 *
116 * @return string version of the ID
117 */
118 public String getStringId();
119
120 /**
121 * Gets the datapathId of the switch.
122 *
123 * @return the switch dpid in long format
124 */
125 public long getId();
126
127 /**
128 * fetch the manufacturer description.
129 * @return the description
130 */
Ray Milkeyd3edd032015-01-16 11:38:58 -0800131 public String manufacturerDescription();
tom7ef8ff92014-09-17 13:08:06 -0700132
133 /**
134 * fetch the datapath description.
135 * @return the description
136 */
137 public String datapathDescription();
138
139 /**
140 * fetch the hardware description.
141 * @return the description
142 */
143 public String hardwareDescription();
144
145 /**
146 * fetch the software description.
147 * @return the description
148 */
149 public String softwareDescription();
150
151 /**
152 * fetch the serial number.
153 * @return the serial
154 */
155 public String serialNumber();
156
157 /**
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700158 * Checks if the switch is still connected.
159 *
160 * @return whether the switch is still connected
161 */
162 public boolean isConnected();
163
164 /**
tom7ef8ff92014-09-17 13:08:06 -0700165 * Disconnects the switch by closing the TCP connection. Results in a call
166 * to the channel handler's channelDisconnected method for cleanup
167 */
168 public void disconnectSwitch();
169
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700170 /**
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700171 * Notifies the controller that the device has responded to a set-role request.
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700172 *
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700173 * @param requested the role requested by the controller
174 * @param response the role set at the device
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700175 */
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800176 public void returnRoleReply(RoleState requested, RoleState response);
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700177
178 /**
179 * Indicates if this switch is optical.
180 *
181 * @return true if optical
182 */
183 public boolean isOptical();
184
Ray Milkeye53f1712015-01-16 09:17:16 -0800185 /**
186 * Identifies the channel used to communicate with the switch.
Ray Milkeyf25d1352015-01-23 15:14:08 -0800187 *
188 * @return string representation of the connection to the device
Ray Milkeye53f1712015-01-16 09:17:16 -0800189 */
190 public String channelId();
191
tom7ef8ff92014-09-17 13:08:06 -0700192}