blob: f020a1aa607e69e8b16e1cc1642d9e94b4cca9e8 [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 {
35 /* IP table */
36 IP,
37 /* MPLS table */
38 MPLS,
39 /* ACL table */
40 ACL,
41 /* Single table */
42 NONE,
43 }
44
45 /**
tom7ef8ff92014-09-17 13:08:06 -070046 * Writes the message to the driver.
47 *
48 * @param msg the message to write
49 */
50 public void sendMsg(OFMessage msg);
51
52 /**
53 * Writes to the OFMessage list to the driver.
54 *
55 * @param msgs the messages to be written
56 */
57 public void sendMsg(List<OFMessage> msgs);
58
59 /**
sangho11c30ac2015-01-22 14:30:55 -080060 * Writes to the OFMessage list to the driver.
61 * TableType is used to determine the table ID for the OFMessage.
62 * The switch driver that supports multi-table should implement the function.
63 *
64 * @param msg the message to be written
65 * @param tableType the type of table in which the OFMessage needs to put
66 */
67 public void sendMsg(OFMessage msg, TableType tableType);
68
69 /**
tom7ef8ff92014-09-17 13:08:06 -070070 * Handle a message from the switch.
71 * @param fromSwitch the message to handle
72 */
73 public void handleMessage(OFMessage fromSwitch);
74
75 /**
76 * Sets the role for this switch.
77 * @param role the role to set.
78 */
79 public void setRole(RoleState role);
80
81 /**
82 * Fetch the role for this switch.
83 * @return the role.
84 */
85 public RoleState getRole();
86
87 /**
88 * Fetches the ports of this switch.
89 * @return unmodifiable list of the ports.
90 */
91 public List<OFPortDesc> getPorts();
92
93 /**
94 * Provides the factory for this OF version.
95 * @return OF version specific factory.
96 */
97 public OFFactory factory();
98
99 /**
100 * Gets a string version of the ID for this switch.
101 *
102 * @return string version of the ID
103 */
104 public String getStringId();
105
106 /**
107 * Gets the datapathId of the switch.
108 *
109 * @return the switch dpid in long format
110 */
111 public long getId();
112
113 /**
114 * fetch the manufacturer description.
115 * @return the description
116 */
Ray Milkeyd3edd032015-01-16 11:38:58 -0800117 public String manufacturerDescription();
tom7ef8ff92014-09-17 13:08:06 -0700118
119 /**
120 * fetch the datapath description.
121 * @return the description
122 */
123 public String datapathDescription();
124
125 /**
126 * fetch the hardware description.
127 * @return the description
128 */
129 public String hardwareDescription();
130
131 /**
132 * fetch the software description.
133 * @return the description
134 */
135 public String softwareDescription();
136
137 /**
138 * fetch the serial number.
139 * @return the serial
140 */
141 public String serialNumber();
142
143 /**
Yuta HIGUCHI69a27352014-10-31 15:48:37 -0700144 * Checks if the switch is still connected.
145 *
146 * @return whether the switch is still connected
147 */
148 public boolean isConnected();
149
150 /**
tom7ef8ff92014-09-17 13:08:06 -0700151 * Disconnects the switch by closing the TCP connection. Results in a call
152 * to the channel handler's channelDisconnected method for cleanup
153 */
154 public void disconnectSwitch();
155
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700156 /**
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700157 * Notifies the controller that the device has responded to a set-role request.
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700158 *
Ayaka Koshibe3ef2b0d2014-10-31 13:58:27 -0700159 * @param requested the role requested by the controller
160 * @param response the role set at the device
Ayaka Koshibeab91cc42014-09-25 10:20:52 -0700161 */
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800162 public void returnRoleReply(RoleState requested, RoleState response);
Praseed Balakrishnana22eadf2014-10-20 14:21:45 -0700163
164 /**
165 * Indicates if this switch is optical.
166 *
167 * @return true if optical
168 */
169 public boolean isOptical();
170
Ray Milkeye53f1712015-01-16 09:17:16 -0800171 /**
172 * Identifies the channel used to communicate with the switch.
Ray Milkeyf25d1352015-01-23 15:14:08 -0800173 *
174 * @return string representation of the connection to the device
Ray Milkeye53f1712015-01-16 09:17:16 -0800175 */
176 public String channelId();
177
tom7ef8ff92014-09-17 13:08:06 -0700178}